Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: media/filters/audio_decoder_unittest.cc

Issue 2643333002: Convert USE_PROPRIETARY_CODECS to a buildflag header. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/cdm/cdm_adapter_unittest.cc ('k') | media/filters/audio_file_reader_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 11 matching lines...) Expand all
22 #include "media/base/audio_hash.h" 22 #include "media/base/audio_hash.h"
23 #include "media/base/decoder_buffer.h" 23 #include "media/base/decoder_buffer.h"
24 #include "media/base/media_util.h" 24 #include "media/base/media_util.h"
25 #include "media/base/test_data_util.h" 25 #include "media/base/test_data_util.h"
26 #include "media/base/test_helpers.h" 26 #include "media/base/test_helpers.h"
27 #include "media/base/timestamp_constants.h" 27 #include "media/base/timestamp_constants.h"
28 #include "media/ffmpeg/ffmpeg_common.h" 28 #include "media/ffmpeg/ffmpeg_common.h"
29 #include "media/filters/audio_file_reader.h" 29 #include "media/filters/audio_file_reader.h"
30 #include "media/filters/ffmpeg_audio_decoder.h" 30 #include "media/filters/ffmpeg_audio_decoder.h"
31 #include "media/filters/in_memory_url_protocol.h" 31 #include "media/filters/in_memory_url_protocol.h"
32 #include "media/media_features.h"
32 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
33 34
34 #if defined(OS_ANDROID) 35 #if defined(OS_ANDROID)
35 #include "base/android/build_info.h" 36 #include "base/android/build_info.h"
36 #include "media/base/android/media_codec_util.h" 37 #include "media/base/android/media_codec_util.h"
37 #include "media/filters/android/media_codec_audio_decoder.h" 38 #include "media/filters/android/media_codec_audio_decoder.h"
38 39
39 #if defined(USE_PROPRIETARY_CODECS) 40 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
40 #include "media/formats/mpeg/adts_stream_parser.h" 41 #include "media/formats/mpeg/adts_stream_parser.h"
41 #endif 42 #endif
42 43
43 // Helper macro to skip the test if MediaCodec is not available. 44 // Helper macro to skip the test if MediaCodec is not available.
44 #define SKIP_TEST_IF_NO_MEDIA_CODEC() \ 45 #define SKIP_TEST_IF_NO_MEDIA_CODEC() \
45 do { \ 46 do { \
46 if (GetParam().decoder_type == MEDIA_CODEC) { \ 47 if (GetParam().decoder_type == MEDIA_CODEC) { \
47 if (!MediaCodecUtil::IsMediaCodecAvailable()) { \ 48 if (!MediaCodecUtil::IsMediaCodecAvailable()) { \
48 VLOG(0) << "Could not run test - no MediaCodec on device."; \ 49 VLOG(0) << "Could not run test - no MediaCodec on device."; \
49 return; \ 50 return; \
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 start_timestamp_ = ConvertFromTimeBase( 181 start_timestamp_ = ConvertFromTimeBase(
181 reader_->GetAVStreamForTesting()->time_base, packet.pts); 182 reader_->GetAVStreamForTesting()->time_base, packet.pts);
182 183
183 // Seek back to the beginning. 184 // Seek back to the beginning.
184 ASSERT_TRUE(reader_->SeekForTesting(start_timestamp_)); 185 ASSERT_TRUE(reader_->SeekForTesting(start_timestamp_));
185 186
186 AudioDecoderConfig config; 187 AudioDecoderConfig config;
187 ASSERT_TRUE(AVCodecContextToAudioDecoderConfig( 188 ASSERT_TRUE(AVCodecContextToAudioDecoderConfig(
188 reader_->codec_context_for_testing(), Unencrypted(), &config)); 189 reader_->codec_context_for_testing(), Unencrypted(), &config));
189 190
190 #if defined(OS_ANDROID) && defined(USE_PROPRIETARY_CODECS) 191 #if defined(OS_ANDROID) && BUILDFLAG(USE_PROPRIETARY_CODECS)
191 // MEDIA_CODEC type requires config->extra_data() for AAC codec. For ADTS 192 // MEDIA_CODEC type requires config->extra_data() for AAC codec. For ADTS
192 // streams we need to extract it with a separate procedure. 193 // streams we need to extract it with a separate procedure.
193 if (GetParam().decoder_type == MEDIA_CODEC && 194 if (GetParam().decoder_type == MEDIA_CODEC &&
194 GetParam().codec == kCodecAAC && config.extra_data().empty()) { 195 GetParam().codec == kCodecAAC && config.extra_data().empty()) {
195 int sample_rate; 196 int sample_rate;
196 ChannelLayout channel_layout; 197 ChannelLayout channel_layout;
197 std::vector<uint8_t> extra_data; 198 std::vector<uint8_t> extra_data;
198 ASSERT_GT(ADTSStreamParser().ParseFrameHeader( 199 ASSERT_GT(ADTSStreamParser().ParseFrameHeader(
199 packet.data, packet.size, nullptr, &sample_rate, 200 packet.data, packet.size, nullptr, &sample_rate,
200 &channel_layout, nullptr, nullptr, &extra_data), 201 &channel_layout, nullptr, nullptr, &extra_data),
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 EXPECT_EQ(DecodeStatus::DECODE_ERROR, last_decode_status()); 450 EXPECT_EQ(DecodeStatus::DECODE_ERROR, last_decode_status());
450 } 451 }
451 452
452 const DecodedBufferExpectations kBearOpusExpectations[] = { 453 const DecodedBufferExpectations kBearOpusExpectations[] = {
453 {500, 3500, "-0.26,0.87,1.36,0.84,-0.30,-1.22,"}, 454 {500, 3500, "-0.26,0.87,1.36,0.84,-0.30,-1.22,"},
454 {4000, 10000, "0.09,0.23,0.21,0.03,-0.17,-0.24,"}, 455 {4000, 10000, "0.09,0.23,0.21,0.03,-0.17,-0.24,"},
455 {14000, 10000, "0.10,0.24,0.23,0.04,-0.14,-0.23,"}, 456 {14000, 10000, "0.10,0.24,0.23,0.04,-0.14,-0.23,"},
456 }; 457 };
457 458
458 #if defined(OS_ANDROID) 459 #if defined(OS_ANDROID)
459 #if defined(USE_PROPRIETARY_CODECS) 460 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
460 const DecodedBufferExpectations kSfxAdtsMcExpectations[] = { 461 const DecodedBufferExpectations kSfxAdtsMcExpectations[] = {
461 {0, 23219, "-1.80,-1.49,-0.23,1.11,1.54,-0.11,"}, 462 {0, 23219, "-1.80,-1.49,-0.23,1.11,1.54,-0.11,"},
462 {23219, 23219, "-1.90,-1.53,-0.15,1.28,1.23,-0.33,"}, 463 {23219, 23219, "-1.90,-1.53,-0.15,1.28,1.23,-0.33,"},
463 {46439, 23219, "0.54,0.88,2.19,3.54,3.24,1.63,"}, 464 {46439, 23219, "0.54,0.88,2.19,3.54,3.24,1.63,"},
464 }; 465 };
465 466
466 const DecodedBufferExpectations kHeAacMcExpectations[] = { 467 const DecodedBufferExpectations kHeAacMcExpectations[] = {
467 {0, 42666, "-1.76,-0.12,1.72,1.45,0.10,-1.32,"}, 468 {0, 42666, "-1.76,-0.12,1.72,1.45,0.10,-1.32,"},
468 {42666, 42666, "-1.78,-0.13,1.70,1.44,0.09,-1.32,"}, 469 {42666, 42666, "-1.78,-0.13,1.70,1.44,0.09,-1.32,"},
469 {85333, 42666, "-1.78,-0.13,1.70,1.44,0.08,-1.33,"}, 470 {85333, 42666, "-1.78,-0.13,1.70,1.44,0.08,-1.33,"},
470 }; 471 };
471 #endif 472 #endif
472 473
473 const DecoderTestData kMediaCodecTests[] = { 474 const DecoderTestData kMediaCodecTests[] = {
474 {MEDIA_CODEC, kCodecOpus, "bear-opus.ogg", kBearOpusExpectations, 24, 48000, 475 {MEDIA_CODEC, kCodecOpus, "bear-opus.ogg", kBearOpusExpectations, 24, 48000,
475 CHANNEL_LAYOUT_STEREO}, 476 CHANNEL_LAYOUT_STEREO},
476 #if defined(USE_PROPRIETARY_CODECS) 477 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
477 {MEDIA_CODEC, kCodecAAC, "sfx.adts", kSfxAdtsMcExpectations, 0, 44100, 478 {MEDIA_CODEC, kCodecAAC, "sfx.adts", kSfxAdtsMcExpectations, 0, 44100,
478 CHANNEL_LAYOUT_MONO}, 479 CHANNEL_LAYOUT_MONO},
479 {MEDIA_CODEC, kCodecAAC, "bear-audio-implicit-he-aac-v2.aac", 480 {MEDIA_CODEC, kCodecAAC, "bear-audio-implicit-he-aac-v2.aac",
480 kHeAacMcExpectations, 0, 24000, CHANNEL_LAYOUT_MONO}, 481 kHeAacMcExpectations, 0, 24000, CHANNEL_LAYOUT_MONO},
481 #endif 482 #endif
482 }; 483 };
483 484
484 INSTANTIATE_TEST_CASE_P(MediaCodec, 485 INSTANTIATE_TEST_CASE_P(MediaCodec,
485 AudioDecoderTest, 486 AudioDecoderTest,
486 testing::ValuesIn(kMediaCodecTests)); 487 testing::ValuesIn(kMediaCodecTests));
487 #endif // defined(OS_ANDROID) 488 #endif // defined(OS_ANDROID)
488 489
489 #if defined(USE_PROPRIETARY_CODECS) 490 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
490 const DecodedBufferExpectations kSfxMp3Expectations[] = { 491 const DecodedBufferExpectations kSfxMp3Expectations[] = {
491 {0, 1065, "2.81,3.99,4.53,4.10,3.08,2.46,"}, 492 {0, 1065, "2.81,3.99,4.53,4.10,3.08,2.46,"},
492 {1065, 26122, "-3.81,-4.14,-3.90,-3.36,-3.03,-3.23,"}, 493 {1065, 26122, "-3.81,-4.14,-3.90,-3.36,-3.03,-3.23,"},
493 {27188, 26122, "4.24,3.95,4.22,4.78,5.13,4.93,"}, 494 {27188, 26122, "4.24,3.95,4.22,4.78,5.13,4.93,"},
494 }; 495 };
495 496
496 const DecodedBufferExpectations kSfxAdtsExpectations[] = { 497 const DecodedBufferExpectations kSfxAdtsExpectations[] = {
497 {0, 23219, "-1.90,-1.53,-0.15,1.28,1.23,-0.33,"}, 498 {0, 23219, "-1.90,-1.53,-0.15,1.28,1.23,-0.33,"},
498 {23219, 23219, "0.54,0.88,2.19,3.54,3.24,1.63,"}, 499 {23219, 23219, "0.54,0.88,2.19,3.54,3.24,1.63,"},
499 {46439, 23219, "1.42,1.69,2.95,4.23,4.02,2.36,"}, 500 {46439, 23219, "1.42,1.69,2.95,4.23,4.02,2.36,"},
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 }; 539 };
539 #else 540 #else
540 const DecodedBufferExpectations kSfxOpusExpectations[] = { 541 const DecodedBufferExpectations kSfxOpusExpectations[] = {
541 {0, 13500, "-2.70,-1.41,-0.78,-1.27,-2.56,-3.73,"}, 542 {0, 13500, "-2.70,-1.41,-0.78,-1.27,-2.56,-3.73,"},
542 {13500, 20000, "5.48,5.93,6.04,5.83,5.54,5.45,"}, 543 {13500, 20000, "5.48,5.93,6.04,5.83,5.54,5.45,"},
543 {33500, 20000, "-3.45,-3.35,-3.57,-4.12,-4.74,-5.14,"}, 544 {33500, 20000, "-3.45,-3.35,-3.57,-4.12,-4.74,-5.14,"},
544 }; 545 };
545 #endif 546 #endif
546 547
547 const DecoderTestData kFFmpegTests[] = { 548 const DecoderTestData kFFmpegTests[] = {
548 #if defined(USE_PROPRIETARY_CODECS) 549 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
549 {FFMPEG, kCodecMP3, "sfx.mp3", kSfxMp3Expectations, 0, 44100, 550 {FFMPEG, kCodecMP3, "sfx.mp3", kSfxMp3Expectations, 0, 44100,
550 CHANNEL_LAYOUT_MONO}, 551 CHANNEL_LAYOUT_MONO},
551 {FFMPEG, kCodecAAC, "sfx.adts", kSfxAdtsExpectations, 0, 44100, 552 {FFMPEG, kCodecAAC, "sfx.adts", kSfxAdtsExpectations, 0, 44100,
552 CHANNEL_LAYOUT_MONO}, 553 CHANNEL_LAYOUT_MONO},
553 #endif 554 #endif
554 {FFMPEG, kCodecFLAC, "sfx.flac", kSfxFlacExpectations, 0, 44100, 555 {FFMPEG, kCodecFLAC, "sfx.flac", kSfxFlacExpectations, 0, 44100,
555 CHANNEL_LAYOUT_MONO}, 556 CHANNEL_LAYOUT_MONO},
556 {FFMPEG, kCodecPCM, "sfx_f32le.wav", kSfxWaveExpectations, 0, 44100, 557 {FFMPEG, kCodecPCM, "sfx_f32le.wav", kSfxWaveExpectations, 0, 44100,
557 CHANNEL_LAYOUT_MONO}, 558 CHANNEL_LAYOUT_MONO},
558 {FFMPEG, kCodecPCM, "4ch.wav", kFourChannelWaveExpectations, 0, 44100, 559 {FFMPEG, kCodecPCM, "4ch.wav", kFourChannelWaveExpectations, 0, 44100,
559 CHANNEL_LAYOUT_QUAD}, 560 CHANNEL_LAYOUT_QUAD},
560 {FFMPEG, kCodecVorbis, "sfx.ogg", kSfxOggExpectations, 0, 44100, 561 {FFMPEG, kCodecVorbis, "sfx.ogg", kSfxOggExpectations, 0, 44100,
561 CHANNEL_LAYOUT_MONO}, 562 CHANNEL_LAYOUT_MONO},
562 // Note: bear.ogv is incorrectly muxed such that valid samples are given 563 // Note: bear.ogv is incorrectly muxed such that valid samples are given
563 // negative timestamps, this marks them for discard per the ogg vorbis spec. 564 // negative timestamps, this marks them for discard per the ogg vorbis spec.
564 {FFMPEG, kCodecVorbis, "bear.ogv", kBearOgvExpectations, -704, 44100, 565 {FFMPEG, kCodecVorbis, "bear.ogv", kBearOgvExpectations, -704, 44100,
565 CHANNEL_LAYOUT_STEREO}, 566 CHANNEL_LAYOUT_STEREO},
566 {FFMPEG, kCodecOpus, "sfx-opus.ogg", kSfxOpusExpectations, -312, 48000, 567 {FFMPEG, kCodecOpus, "sfx-opus.ogg", kSfxOpusExpectations, -312, 48000,
567 CHANNEL_LAYOUT_MONO}, 568 CHANNEL_LAYOUT_MONO},
568 {FFMPEG, kCodecOpus, "bear-opus.ogg", kBearOpusExpectations, 24, 48000, 569 {FFMPEG, kCodecOpus, "bear-opus.ogg", kBearOpusExpectations, 24, 48000,
569 CHANNEL_LAYOUT_STEREO}, 570 CHANNEL_LAYOUT_STEREO},
570 }; 571 };
571 572
572 INSTANTIATE_TEST_CASE_P(FFmpeg, 573 INSTANTIATE_TEST_CASE_P(FFmpeg,
573 AudioDecoderTest, 574 AudioDecoderTest,
574 testing::ValuesIn(kFFmpegTests)); 575 testing::ValuesIn(kFFmpegTests));
575 576
576 } // namespace media 577 } // namespace media
OLDNEW
« no previous file with comments | « media/cdm/cdm_adapter_unittest.cc ('k') | media/filters/audio_file_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698