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

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

Issue 2580093002: Revert of Convert USE_PROPRIETARY_CODECS to a buildflag header. (Closed)
Patch Set: Created 4 years 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"
33 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
34 33
35 #if defined(OS_ANDROID) 34 #if defined(OS_ANDROID)
36 #include "base/android/build_info.h" 35 #include "base/android/build_info.h"
37 #include "media/base/android/media_codec_util.h" 36 #include "media/base/android/media_codec_util.h"
38 #include "media/filters/android/media_codec_audio_decoder.h" 37 #include "media/filters/android/media_codec_audio_decoder.h"
39 38
40 #if BUILDFLAG(USE_PROPRIETARY_CODECS) 39 #if defined(USE_PROPRIETARY_CODECS)
41 #include "media/formats/mpeg/adts_stream_parser.h" 40 #include "media/formats/mpeg/adts_stream_parser.h"
42 #endif 41 #endif
43 42
44 // Helper macro to skip the test if MediaCodec is not available. 43 // Helper macro to skip the test if MediaCodec is not available.
45 #define SKIP_TEST_IF_NO_MEDIA_CODEC() \ 44 #define SKIP_TEST_IF_NO_MEDIA_CODEC() \
46 do { \ 45 do { \
47 if (GetParam().decoder_type == MEDIA_CODEC) { \ 46 if (GetParam().decoder_type == MEDIA_CODEC) { \
48 if (!MediaCodecUtil::IsMediaCodecAvailable()) { \ 47 if (!MediaCodecUtil::IsMediaCodecAvailable()) { \
49 VLOG(0) << "Could not run test - no MediaCodec on device."; \ 48 VLOG(0) << "Could not run test - no MediaCodec on device."; \
50 return; \ 49 return; \
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 start_timestamp_ = ConvertFromTimeBase( 180 start_timestamp_ = ConvertFromTimeBase(
182 reader_->GetAVStreamForTesting()->time_base, packet.pts); 181 reader_->GetAVStreamForTesting()->time_base, packet.pts);
183 182
184 // Seek back to the beginning. 183 // Seek back to the beginning.
185 ASSERT_TRUE(reader_->SeekForTesting(start_timestamp_)); 184 ASSERT_TRUE(reader_->SeekForTesting(start_timestamp_));
186 185
187 AudioDecoderConfig config; 186 AudioDecoderConfig config;
188 ASSERT_TRUE(AVCodecContextToAudioDecoderConfig( 187 ASSERT_TRUE(AVCodecContextToAudioDecoderConfig(
189 reader_->codec_context_for_testing(), Unencrypted(), &config)); 188 reader_->codec_context_for_testing(), Unencrypted(), &config));
190 189
191 #if defined(OS_ANDROID) && BUILDFLAG(USE_PROPRIETARY_CODECS) 190 #if defined(OS_ANDROID) && defined(USE_PROPRIETARY_CODECS)
192 // MEDIA_CODEC type requires config->extra_data() for AAC codec. For ADTS 191 // MEDIA_CODEC type requires config->extra_data() for AAC codec. For ADTS
193 // streams we need to extract it with a separate procedure. 192 // streams we need to extract it with a separate procedure.
194 if (GetParam().decoder_type == MEDIA_CODEC && 193 if (GetParam().decoder_type == MEDIA_CODEC &&
195 GetParam().codec == kCodecAAC && config.extra_data().empty()) { 194 GetParam().codec == kCodecAAC && config.extra_data().empty()) {
196 int sample_rate; 195 int sample_rate;
197 ChannelLayout channel_layout; 196 ChannelLayout channel_layout;
198 std::vector<uint8_t> extra_data; 197 std::vector<uint8_t> extra_data;
199 ASSERT_GT(ADTSStreamParser().ParseFrameHeader( 198 ASSERT_GT(ADTSStreamParser().ParseFrameHeader(
200 packet.data, packet.size, nullptr, &sample_rate, 199 packet.data, packet.size, nullptr, &sample_rate,
201 &channel_layout, nullptr, nullptr, &extra_data), 200 &channel_layout, nullptr, nullptr, &extra_data),
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 EXPECT_EQ(DecodeStatus::DECODE_ERROR, last_decode_status()); 451 EXPECT_EQ(DecodeStatus::DECODE_ERROR, last_decode_status());
453 } 452 }
454 453
455 const DecodedBufferExpectations kBearOpusExpectations[] = { 454 const DecodedBufferExpectations kBearOpusExpectations[] = {
456 {500, 3500, "-0.26,0.87,1.36,0.84,-0.30,-1.22,"}, 455 {500, 3500, "-0.26,0.87,1.36,0.84,-0.30,-1.22,"},
457 {4000, 10000, "0.09,0.23,0.21,0.03,-0.17,-0.24,"}, 456 {4000, 10000, "0.09,0.23,0.21,0.03,-0.17,-0.24,"},
458 {14000, 10000, "0.10,0.24,0.23,0.04,-0.14,-0.23,"}, 457 {14000, 10000, "0.10,0.24,0.23,0.04,-0.14,-0.23,"},
459 }; 458 };
460 459
461 #if defined(OS_ANDROID) 460 #if defined(OS_ANDROID)
462 #if BUILDFLAG(USE_PROPRIETARY_CODECS) 461 #if defined(USE_PROPRIETARY_CODECS)
463 const DecodedBufferExpectations kSfxAdtsMcExpectations[] = { 462 const DecodedBufferExpectations kSfxAdtsMcExpectations[] = {
464 {0, 23219, "-1.80,-1.49,-0.23,1.11,1.54,-0.11,"}, 463 {0, 23219, "-1.80,-1.49,-0.23,1.11,1.54,-0.11,"},
465 {23219, 23219, "-1.90,-1.53,-0.15,1.28,1.23,-0.33,"}, 464 {23219, 23219, "-1.90,-1.53,-0.15,1.28,1.23,-0.33,"},
466 {46439, 23219, "0.54,0.88,2.19,3.54,3.24,1.63,"}, 465 {46439, 23219, "0.54,0.88,2.19,3.54,3.24,1.63,"},
467 }; 466 };
468 467
469 const DecodedBufferExpectations kHeAacMcExpectations[] = { 468 const DecodedBufferExpectations kHeAacMcExpectations[] = {
470 {0, 42666, "-1.76,-0.12,1.72,1.45,0.10,-1.32,"}, 469 {0, 42666, "-1.76,-0.12,1.72,1.45,0.10,-1.32,"},
471 {42666, 42666, "-1.78,-0.13,1.70,1.44,0.09,-1.32,"}, 470 {42666, 42666, "-1.78,-0.13,1.70,1.44,0.09,-1.32,"},
472 {85333, 42666, "-1.78,-0.13,1.70,1.44,0.08,-1.33,"}, 471 {85333, 42666, "-1.78,-0.13,1.70,1.44,0.08,-1.33,"},
473 }; 472 };
474 #endif 473 #endif
475 474
476 const DecoderTestData kMediaCodecTests[] = { 475 const DecoderTestData kMediaCodecTests[] = {
477 {MEDIA_CODEC, kCodecOpus, "bear-opus.ogg", kBearOpusExpectations, 24, 48000, 476 {MEDIA_CODEC, kCodecOpus, "bear-opus.ogg", kBearOpusExpectations, 24, 48000,
478 CHANNEL_LAYOUT_STEREO}, 477 CHANNEL_LAYOUT_STEREO},
479 #if BUILDFLAG(USE_PROPRIETARY_CODECS) 478 #if defined(USE_PROPRIETARY_CODECS)
480 {MEDIA_CODEC, kCodecAAC, "sfx.adts", kSfxAdtsMcExpectations, 0, 44100, 479 {MEDIA_CODEC, kCodecAAC, "sfx.adts", kSfxAdtsMcExpectations, 0, 44100,
481 CHANNEL_LAYOUT_MONO}, 480 CHANNEL_LAYOUT_MONO},
482 {MEDIA_CODEC, kCodecAAC, "bear-audio-implicit-he-aac-v2.aac", 481 {MEDIA_CODEC, kCodecAAC, "bear-audio-implicit-he-aac-v2.aac",
483 kHeAacMcExpectations, 0, 24000, CHANNEL_LAYOUT_MONO}, 482 kHeAacMcExpectations, 0, 24000, CHANNEL_LAYOUT_MONO},
484 #endif 483 #endif
485 }; 484 };
486 485
487 INSTANTIATE_TEST_CASE_P(MediaCodecAudioDecoderTest, 486 INSTANTIATE_TEST_CASE_P(MediaCodecAudioDecoderTest,
488 AudioDecoderTest, 487 AudioDecoderTest,
489 testing::ValuesIn(kMediaCodecTests)); 488 testing::ValuesIn(kMediaCodecTests));
490 #endif // defined(OS_ANDROID) 489 #endif // defined(OS_ANDROID)
491 490
492 #if BUILDFLAG(USE_PROPRIETARY_CODECS) 491 #if defined(USE_PROPRIETARY_CODECS)
493 const DecodedBufferExpectations kSfxMp3Expectations[] = { 492 const DecodedBufferExpectations kSfxMp3Expectations[] = {
494 {0, 1065, "2.81,3.99,4.53,4.10,3.08,2.46,"}, 493 {0, 1065, "2.81,3.99,4.53,4.10,3.08,2.46,"},
495 {1065, 26122, "-3.81,-4.14,-3.90,-3.36,-3.03,-3.23,"}, 494 {1065, 26122, "-3.81,-4.14,-3.90,-3.36,-3.03,-3.23,"},
496 {27188, 26122, "4.24,3.95,4.22,4.78,5.13,4.93,"}, 495 {27188, 26122, "4.24,3.95,4.22,4.78,5.13,4.93,"},
497 }; 496 };
498 497
499 const DecodedBufferExpectations kSfxAdtsExpectations[] = { 498 const DecodedBufferExpectations kSfxAdtsExpectations[] = {
500 {0, 23219, "-1.90,-1.53,-0.15,1.28,1.23,-0.33,"}, 499 {0, 23219, "-1.90,-1.53,-0.15,1.28,1.23,-0.33,"},
501 {23219, 23219, "0.54,0.88,2.19,3.54,3.24,1.63,"}, 500 {23219, 23219, "0.54,0.88,2.19,3.54,3.24,1.63,"},
502 {46439, 23219, "1.42,1.69,2.95,4.23,4.02,2.36,"}, 501 {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
541 }; 540 };
542 #else 541 #else
543 const DecodedBufferExpectations kSfxOpusExpectations[] = { 542 const DecodedBufferExpectations kSfxOpusExpectations[] = {
544 {0, 13500, "-2.70,-1.41,-0.78,-1.27,-2.56,-3.73,"}, 543 {0, 13500, "-2.70,-1.41,-0.78,-1.27,-2.56,-3.73,"},
545 {13500, 20000, "5.48,5.93,6.04,5.83,5.54,5.45,"}, 544 {13500, 20000, "5.48,5.93,6.04,5.83,5.54,5.45,"},
546 {33500, 20000, "-3.45,-3.35,-3.57,-4.12,-4.74,-5.14,"}, 545 {33500, 20000, "-3.45,-3.35,-3.57,-4.12,-4.74,-5.14,"},
547 }; 546 };
548 #endif 547 #endif
549 548
550 const DecoderTestData kFFmpegTests[] = { 549 const DecoderTestData kFFmpegTests[] = {
551 #if BUILDFLAG(USE_PROPRIETARY_CODECS) 550 #if defined(USE_PROPRIETARY_CODECS)
552 {FFMPEG, kCodecMP3, "sfx.mp3", kSfxMp3Expectations, 0, 44100, 551 {FFMPEG, kCodecMP3, "sfx.mp3", kSfxMp3Expectations, 0, 44100,
553 CHANNEL_LAYOUT_MONO}, 552 CHANNEL_LAYOUT_MONO},
554 {FFMPEG, kCodecAAC, "sfx.adts", kSfxAdtsExpectations, 0, 44100, 553 {FFMPEG, kCodecAAC, "sfx.adts", kSfxAdtsExpectations, 0, 44100,
555 CHANNEL_LAYOUT_MONO}, 554 CHANNEL_LAYOUT_MONO},
556 #endif 555 #endif
557 {FFMPEG, kCodecFLAC, "sfx.flac", kSfxFlacExpectations, 0, 44100, 556 {FFMPEG, kCodecFLAC, "sfx.flac", kSfxFlacExpectations, 0, 44100,
558 CHANNEL_LAYOUT_MONO}, 557 CHANNEL_LAYOUT_MONO},
559 {FFMPEG, kCodecPCM, "sfx_f32le.wav", kSfxWaveExpectations, 0, 44100, 558 {FFMPEG, kCodecPCM, "sfx_f32le.wav", kSfxWaveExpectations, 0, 44100,
560 CHANNEL_LAYOUT_MONO}, 559 CHANNEL_LAYOUT_MONO},
561 {FFMPEG, kCodecPCM, "4ch.wav", kFourChannelWaveExpectations, 0, 44100, 560 {FFMPEG, kCodecPCM, "4ch.wav", kFourChannelWaveExpectations, 0, 44100,
(...skipping 16 matching lines...) Expand all
578 }; 577 };
579 578
580 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderTest, 579 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderTest,
581 AudioDecoderTest, 580 AudioDecoderTest,
582 testing::ValuesIn(kFFmpegTests)); 581 testing::ValuesIn(kFFmpegTests));
583 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderBehavioralTest, 582 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderBehavioralTest,
584 FFmpegAudioDecoderBehavioralTest, 583 FFmpegAudioDecoderBehavioralTest,
585 testing::ValuesIn(kFFmpegBehavioralTest)); 584 testing::ValuesIn(kFFmpegBehavioralTest));
586 585
587 } // namespace media 586 } // 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