Index: media/filters/audio_decoder_unittest_chromium.cc |
diff --git a/media/filters/audio_decoder_unittest_chromium.cc b/media/filters/audio_decoder_unittest_chromium.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7194a4ee1c4de8bc9f836b7eda7b17bdf546ad28 |
--- /dev/null |
+++ b/media/filters/audio_decoder_unittest_chromium.cc |
@@ -0,0 +1,80 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "media/filters/audio_decoder_test.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace media { |
+ |
+static const uint8_t kOpusExtraData[] = { |
+ 0x4f, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64, 0x01, 0x02, |
+ // The next two bytes represent the codec delay. |
+ 0x00, 0x00, 0x80, 0xbb, 0x00, 0x00, 0x00, 0x00, 0x00}; |
+ |
+class OpusAudioDecoderBehavioralTest : public AudioDecoderTest {}; |
+ |
+TEST_P(OpusAudioDecoderBehavioralTest, InitializeWithNoCodecDelay) { |
+ ASSERT_EQ(GetParam().decoder_type, OPUS); |
+ std::vector<uint8_t> extra_data(kOpusExtraData, |
+ kOpusExtraData + arraysize(kOpusExtraData)); |
+ AudioDecoderConfig decoder_config; |
+ decoder_config.Initialize(kCodecOpus, kSampleFormatF32, CHANNEL_LAYOUT_STEREO, |
+ 48000, extra_data, false, |
+ base::TimeDelta::FromMilliseconds(80), 0); |
+ InitializeDecoder(decoder_config); |
+} |
+ |
+TEST_P(OpusAudioDecoderBehavioralTest, InitializeWithBadCodecDelay) { |
+ ASSERT_EQ(GetParam().decoder_type, OPUS); |
+ std::vector<uint8_t> extra_data(kOpusExtraData, |
+ kOpusExtraData + arraysize(kOpusExtraData)); |
+ AudioDecoderConfig decoder_config; |
+ decoder_config.Initialize( |
+ kCodecOpus, kSampleFormatF32, CHANNEL_LAYOUT_STEREO, 48000, extra_data, |
+ false, base::TimeDelta::FromMilliseconds(80), |
+ // Use a different codec delay than in the extradata. |
+ 100); |
+ InitializeDecoderWithResult(decoder_config, true); |
+} |
+ |
+#if defined(OPUS_FIXED_POINT) |
+const DecodedBufferExpectations kSfxOpusExpectations[] = { |
+ {0, 13500, "-2.70,-1.41,-0.78,-1.27,-2.56,-3.73,"}, |
+ {13500, 20000, "5.48,5.93,6.05,5.83,5.54,5.46,"}, |
+ {33500, 20000, "-3.44,-3.34,-3.57,-4.11,-4.74,-5.13,"}, |
+}; |
+#else |
+const DecodedBufferExpectations kSfxOpusExpectations[] = { |
+ {0, 13500, "-2.70,-1.41,-0.78,-1.27,-2.56,-3.73,"}, |
+ {13500, 20000, "5.48,5.93,6.04,5.83,5.54,5.45,"}, |
+ {33500, 20000, "-3.45,-3.35,-3.57,-4.12,-4.74,-5.14,"}, |
+}; |
+#endif |
+ |
+const DecodedBufferExpectations kBearOpusExpectations[] = { |
+ {500, 3500, "-0.26,0.87,1.36,0.84,-0.30,-1.22,"}, |
+ {4000, 10000, "0.09,0.23,0.21,0.03,-0.17,-0.24,"}, |
+ {14000, 10000, "0.10,0.24,0.23,0.04,-0.14,-0.23,"}, |
+}; |
+ |
+const DecoderTestData kOpusTests[] = { |
+ {OPUS, kCodecOpus, "sfx-opus.ogg", kSfxOpusExpectations, -312, 48000, |
+ CHANNEL_LAYOUT_MONO}, |
+ {OPUS, kCodecOpus, "bear-opus.ogg", kBearOpusExpectations, 24, 48000, |
+ CHANNEL_LAYOUT_STEREO}, |
+}; |
+ |
+// Dummy data for Opus behavioral tests. |
+const DecoderTestData kOpusBehavioralTest[] = { |
+ {OPUS, kUnknownAudioCodec, "", NULL, 0, 0, CHANNEL_LAYOUT_NONE}, |
+}; |
+ |
+INSTANTIATE_TEST_CASE_P(OpusAudioDecoderTest, |
+ AudioDecoderTest, |
+ testing::ValuesIn(kOpusTests)); |
+INSTANTIATE_TEST_CASE_P(OpusAudioDecoderBehavioralTest, |
+ OpusAudioDecoderBehavioralTest, |
+ testing::ValuesIn(kOpusBehavioralTest)); |
+ |
+} // namespace media |