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

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

Issue 2572883002: Convert USE_PROPRIETARY_CODECS to a buildflag header. (Closed)
Patch Set: Merge 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"
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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 EXPECT_EQ(DecodeStatus::DECODE_ERROR, last_decode_status()); 452 EXPECT_EQ(DecodeStatus::DECODE_ERROR, last_decode_status());
452 } 453 }
453 454
454 const DecodedBufferExpectations kBearOpusExpectations[] = { 455 const DecodedBufferExpectations kBearOpusExpectations[] = {
455 {500, 3500, "-0.26,0.87,1.36,0.84,-0.30,-1.22,"}, 456 {500, 3500, "-0.26,0.87,1.36,0.84,-0.30,-1.22,"},
456 {4000, 10000, "0.09,0.23,0.21,0.03,-0.17,-0.24,"}, 457 {4000, 10000, "0.09,0.23,0.21,0.03,-0.17,-0.24,"},
457 {14000, 10000, "0.10,0.24,0.23,0.04,-0.14,-0.23,"}, 458 {14000, 10000, "0.10,0.24,0.23,0.04,-0.14,-0.23,"},
458 }; 459 };
459 460
460 #if defined(OS_ANDROID) 461 #if defined(OS_ANDROID)
461 #if defined(USE_PROPRIETARY_CODECS) 462 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
462 const DecodedBufferExpectations kSfxAdtsMcExpectations[] = { 463 const DecodedBufferExpectations kSfxAdtsMcExpectations[] = {
463 {0, 23219, "-1.80,-1.49,-0.23,1.11,1.54,-0.11,"}, 464 {0, 23219, "-1.80,-1.49,-0.23,1.11,1.54,-0.11,"},
464 {23219, 23219, "-1.90,-1.53,-0.15,1.28,1.23,-0.33,"}, 465 {23219, 23219, "-1.90,-1.53,-0.15,1.28,1.23,-0.33,"},
465 {46439, 23219, "0.54,0.88,2.19,3.54,3.24,1.63,"}, 466 {46439, 23219, "0.54,0.88,2.19,3.54,3.24,1.63,"},
466 }; 467 };
467 468
468 const DecodedBufferExpectations kHeAacMcExpectations[] = { 469 const DecodedBufferExpectations kHeAacMcExpectations[] = {
469 {0, 42666, "-1.76,-0.12,1.72,1.45,0.10,-1.32,"}, 470 {0, 42666, "-1.76,-0.12,1.72,1.45,0.10,-1.32,"},
470 {42666, 42666, "-1.78,-0.13,1.70,1.44,0.09,-1.32,"}, 471 {42666, 42666, "-1.78,-0.13,1.70,1.44,0.09,-1.32,"},
471 {85333, 42666, "-1.78,-0.13,1.70,1.44,0.08,-1.33,"}, 472 {85333, 42666, "-1.78,-0.13,1.70,1.44,0.08,-1.33,"},
472 }; 473 };
473 #endif 474 #endif
474 475
475 const DecoderTestData kMediaCodecTests[] = { 476 const DecoderTestData kMediaCodecTests[] = {
476 {MEDIA_CODEC, kCodecOpus, "bear-opus.ogg", kBearOpusExpectations, 24, 48000, 477 {MEDIA_CODEC, kCodecOpus, "bear-opus.ogg", kBearOpusExpectations, 24, 48000,
477 CHANNEL_LAYOUT_STEREO}, 478 CHANNEL_LAYOUT_STEREO},
478 #if defined(USE_PROPRIETARY_CODECS) 479 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
479 {MEDIA_CODEC, kCodecAAC, "sfx.adts", kSfxAdtsMcExpectations, 0, 44100, 480 {MEDIA_CODEC, kCodecAAC, "sfx.adts", kSfxAdtsMcExpectations, 0, 44100,
480 CHANNEL_LAYOUT_MONO}, 481 CHANNEL_LAYOUT_MONO},
481 {MEDIA_CODEC, kCodecAAC, "bear-audio-implicit-he-aac-v2.aac", 482 {MEDIA_CODEC, kCodecAAC, "bear-audio-implicit-he-aac-v2.aac",
482 kHeAacMcExpectations, 0, 24000, CHANNEL_LAYOUT_MONO}, 483 kHeAacMcExpectations, 0, 24000, CHANNEL_LAYOUT_MONO},
483 #endif 484 #endif
484 }; 485 };
485 486
486 INSTANTIATE_TEST_CASE_P(MediaCodecAudioDecoderTest, 487 INSTANTIATE_TEST_CASE_P(MediaCodecAudioDecoderTest,
487 AudioDecoderTest, 488 AudioDecoderTest,
488 testing::ValuesIn(kMediaCodecTests)); 489 testing::ValuesIn(kMediaCodecTests));
489 #endif // defined(OS_ANDROID) 490 #endif // defined(OS_ANDROID)
490 491
491 #if defined(USE_PROPRIETARY_CODECS) 492 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
492 const DecodedBufferExpectations kSfxMp3Expectations[] = { 493 const DecodedBufferExpectations kSfxMp3Expectations[] = {
493 {0, 1065, "2.81,3.99,4.53,4.10,3.08,2.46,"}, 494 {0, 1065, "2.81,3.99,4.53,4.10,3.08,2.46,"},
494 {1065, 26122, "-3.81,-4.14,-3.90,-3.36,-3.03,-3.23,"}, 495 {1065, 26122, "-3.81,-4.14,-3.90,-3.36,-3.03,-3.23,"},
495 {27188, 26122, "4.24,3.95,4.22,4.78,5.13,4.93,"}, 496 {27188, 26122, "4.24,3.95,4.22,4.78,5.13,4.93,"},
496 }; 497 };
497 498
498 const DecodedBufferExpectations kSfxAdtsExpectations[] = { 499 const DecodedBufferExpectations kSfxAdtsExpectations[] = {
499 {0, 23219, "-1.90,-1.53,-0.15,1.28,1.23,-0.33,"}, 500 {0, 23219, "-1.90,-1.53,-0.15,1.28,1.23,-0.33,"},
500 {23219, 23219, "0.54,0.88,2.19,3.54,3.24,1.63,"}, 501 {23219, 23219, "0.54,0.88,2.19,3.54,3.24,1.63,"},
501 {46439, 23219, "1.42,1.69,2.95,4.23,4.02,2.36,"}, 502 {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
540 }; 541 };
541 #else 542 #else
542 const DecodedBufferExpectations kSfxOpusExpectations[] = { 543 const DecodedBufferExpectations kSfxOpusExpectations[] = {
543 {0, 13500, "-2.70,-1.41,-0.78,-1.27,-2.56,-3.73,"}, 544 {0, 13500, "-2.70,-1.41,-0.78,-1.27,-2.56,-3.73,"},
544 {13500, 20000, "5.48,5.93,6.04,5.83,5.54,5.45,"}, 545 {13500, 20000, "5.48,5.93,6.04,5.83,5.54,5.45,"},
545 {33500, 20000, "-3.45,-3.35,-3.57,-4.12,-4.74,-5.14,"}, 546 {33500, 20000, "-3.45,-3.35,-3.57,-4.12,-4.74,-5.14,"},
546 }; 547 };
547 #endif 548 #endif
548 549
549 const DecoderTestData kFFmpegTests[] = { 550 const DecoderTestData kFFmpegTests[] = {
550 #if defined(USE_PROPRIETARY_CODECS) 551 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
551 {FFMPEG, kCodecMP3, "sfx.mp3", kSfxMp3Expectations, 0, 44100, 552 {FFMPEG, kCodecMP3, "sfx.mp3", kSfxMp3Expectations, 0, 44100,
552 CHANNEL_LAYOUT_MONO}, 553 CHANNEL_LAYOUT_MONO},
553 {FFMPEG, kCodecAAC, "sfx.adts", kSfxAdtsExpectations, 0, 44100, 554 {FFMPEG, kCodecAAC, "sfx.adts", kSfxAdtsExpectations, 0, 44100,
554 CHANNEL_LAYOUT_MONO}, 555 CHANNEL_LAYOUT_MONO},
555 #endif 556 #endif
556 {FFMPEG, kCodecFLAC, "sfx.flac", kSfxFlacExpectations, 0, 44100, 557 {FFMPEG, kCodecFLAC, "sfx.flac", kSfxFlacExpectations, 0, 44100,
557 CHANNEL_LAYOUT_MONO}, 558 CHANNEL_LAYOUT_MONO},
558 {FFMPEG, kCodecPCM, "sfx_f32le.wav", kSfxWaveExpectations, 0, 44100, 559 {FFMPEG, kCodecPCM, "sfx_f32le.wav", kSfxWaveExpectations, 0, 44100,
559 CHANNEL_LAYOUT_MONO}, 560 CHANNEL_LAYOUT_MONO},
560 {FFMPEG, kCodecPCM, "4ch.wav", kFourChannelWaveExpectations, 0, 44100, 561 {FFMPEG, kCodecPCM, "4ch.wav", kFourChannelWaveExpectations, 0, 44100,
(...skipping 16 matching lines...) Expand all
577 }; 578 };
578 579
579 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderTest, 580 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderTest,
580 AudioDecoderTest, 581 AudioDecoderTest,
581 testing::ValuesIn(kFFmpegTests)); 582 testing::ValuesIn(kFFmpegTests));
582 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderBehavioralTest, 583 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderBehavioralTest,
583 FFmpegAudioDecoderBehavioralTest, 584 FFmpegAudioDecoderBehavioralTest,
584 testing::ValuesIn(kFFmpegBehavioralTest)); 585 testing::ValuesIn(kFFmpegBehavioralTest));
585 586
586 } // namespace media 587 } // 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