OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h" | 25 #include "webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h" |
26 #include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_decoder_isac
fix.h" | 26 #include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_decoder_isac
fix.h" |
27 #include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_encoder_isac
fix.h" | 27 #include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_encoder_isac
fix.h" |
28 #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_decoder_isa
c.h" | 28 #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_decoder_isa
c.h" |
29 #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isa
c.h" | 29 #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isa
c.h" |
30 #include "webrtc/modules/audio_coding/codecs/opus/audio_decoder_opus.h" | 30 #include "webrtc/modules/audio_coding/codecs/opus/audio_decoder_opus.h" |
31 #include "webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h" | 31 #include "webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h" |
32 #include "webrtc/modules/audio_coding/codecs/pcm16b/audio_decoder_pcm16b.h" | 32 #include "webrtc/modules/audio_coding/codecs/pcm16b/audio_decoder_pcm16b.h" |
33 #include "webrtc/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h" | 33 #include "webrtc/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h" |
34 #include "webrtc/modules/audio_coding/neteq/tools/resample_input_audio_file.h" | 34 #include "webrtc/modules/audio_coding/neteq/tools/resample_input_audio_file.h" |
35 #include "webrtc/system_wrappers/include/data_log.h" | |
36 #include "webrtc/test/gtest.h" | 35 #include "webrtc/test/gtest.h" |
37 #include "webrtc/test/testsupport/fileutils.h" | 36 #include "webrtc/test/testsupport/fileutils.h" |
38 | 37 |
39 namespace webrtc { | 38 namespace webrtc { |
40 | 39 |
41 namespace { | 40 namespace { |
42 // The absolute difference between the input and output (the first channel) is | 41 // The absolute difference between the input and output (the first channel) is |
43 // compared vs |tolerance|. The parameter |delay| is used to correct for codec | 42 // compared vs |tolerance|. The parameter |delay| is used to correct for codec |
44 // delays. | 43 // delays. |
45 void CompareInputOutput(const std::vector<int16_t>& input, | 44 void CompareInputOutput(const std::vector<int16_t>& input, |
46 const std::vector<int16_t>& output, | 45 const std::vector<int16_t>& output, |
47 size_t num_samples, | 46 size_t num_samples, |
48 size_t channels, | 47 size_t channels, |
49 int tolerance, | 48 int tolerance, |
50 int delay) { | 49 int delay) { |
51 ASSERT_LE(num_samples, input.size()); | 50 ASSERT_LE(num_samples, input.size()); |
52 ASSERT_LE(num_samples * channels, output.size()); | 51 ASSERT_LE(num_samples * channels, output.size()); |
53 for (unsigned int n = 0; n < num_samples - delay; ++n) { | 52 for (unsigned int n = 0; n < num_samples - delay; ++n) { |
54 ASSERT_NEAR(input[n], output[channels * n + delay], tolerance) | 53 ASSERT_NEAR(input[n], output[channels * n + delay], tolerance) |
55 << "Exit test on first diff; n = " << n; | 54 << "Exit test on first diff; n = " << n; |
56 DataLog::InsertCell("CodecTest", "input", input[n]); | |
57 DataLog::InsertCell("CodecTest", "output", output[channels * n]); | |
58 DataLog::NextRow("CodecTest"); | |
59 } | 55 } |
60 } | 56 } |
61 | 57 |
62 // The absolute difference between the first two channels in |output| is | 58 // The absolute difference between the first two channels in |output| is |
63 // compared vs |tolerance|. | 59 // compared vs |tolerance|. |
64 void CompareTwoChannels(const std::vector<int16_t>& output, | 60 void CompareTwoChannels(const std::vector<int16_t>& output, |
65 size_t samples_per_channel, | 61 size_t samples_per_channel, |
66 size_t channels, | 62 size_t channels, |
67 int tolerance) { | 63 int tolerance) { |
68 ASSERT_GE(channels, 2u); | 64 ASSERT_GE(channels, 2u); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 payload_type_(17), | 102 payload_type_(17), |
107 decoder_(NULL) {} | 103 decoder_(NULL) {} |
108 | 104 |
109 virtual ~AudioDecoderTest() {} | 105 virtual ~AudioDecoderTest() {} |
110 | 106 |
111 virtual void SetUp() { | 107 virtual void SetUp() { |
112 if (audio_encoder_) | 108 if (audio_encoder_) |
113 codec_input_rate_hz_ = audio_encoder_->SampleRateHz(); | 109 codec_input_rate_hz_ = audio_encoder_->SampleRateHz(); |
114 // Create arrays. | 110 // Create arrays. |
115 ASSERT_GT(data_length_, 0u) << "The test must set data_length_ > 0"; | 111 ASSERT_GT(data_length_, 0u) << "The test must set data_length_ > 0"; |
116 // Logging to view input and output in Matlab. | |
117 // Use 'gyp -Denable_data_logging=1' to enable logging. | |
118 DataLog::CreateLog(); | |
119 DataLog::AddTable("CodecTest"); | |
120 DataLog::AddColumn("CodecTest", "input", 1); | |
121 DataLog::AddColumn("CodecTest", "output", 1); | |
122 } | 112 } |
123 | 113 |
124 virtual void TearDown() { | 114 virtual void TearDown() { |
125 delete decoder_; | 115 delete decoder_; |
126 decoder_ = NULL; | 116 decoder_ = NULL; |
127 // Close log. | |
128 DataLog::ReturnLog(); | |
129 } | 117 } |
130 | 118 |
131 virtual void InitEncoder() { } | 119 virtual void InitEncoder() { } |
132 | 120 |
133 // TODO(henrik.lundin) Change return type to size_t once most/all overriding | 121 // TODO(henrik.lundin) Change return type to size_t once most/all overriding |
134 // implementations are gone. | 122 // implementations are gone. |
135 virtual int EncodeFrame(const int16_t* input, | 123 virtual int EncodeFrame(const int16_t* input, |
136 size_t input_len_samples, | 124 size_t input_len_samples, |
137 rtc::Buffer* output) { | 125 rtc::Buffer* output) { |
138 AudioEncoder::EncodedInfo encoded_info; | 126 AudioEncoder::EncodedInfo encoded_info; |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 EXPECT_TRUE(CodecSupported(NetEqDecoder::kDecoderCNGnb)); | 686 EXPECT_TRUE(CodecSupported(NetEqDecoder::kDecoderCNGnb)); |
699 EXPECT_TRUE(CodecSupported(NetEqDecoder::kDecoderCNGwb)); | 687 EXPECT_TRUE(CodecSupported(NetEqDecoder::kDecoderCNGwb)); |
700 EXPECT_TRUE(CodecSupported(NetEqDecoder::kDecoderCNGswb32kHz)); | 688 EXPECT_TRUE(CodecSupported(NetEqDecoder::kDecoderCNGswb32kHz)); |
701 EXPECT_TRUE(CodecSupported(NetEqDecoder::kDecoderCNGswb48kHz)); | 689 EXPECT_TRUE(CodecSupported(NetEqDecoder::kDecoderCNGswb48kHz)); |
702 EXPECT_TRUE(CodecSupported(NetEqDecoder::kDecoderArbitrary)); | 690 EXPECT_TRUE(CodecSupported(NetEqDecoder::kDecoderArbitrary)); |
703 EXPECT_EQ(has_opus, CodecSupported(NetEqDecoder::kDecoderOpus)); | 691 EXPECT_EQ(has_opus, CodecSupported(NetEqDecoder::kDecoderOpus)); |
704 EXPECT_EQ(has_opus, CodecSupported(NetEqDecoder::kDecoderOpus_2ch)); | 692 EXPECT_EQ(has_opus, CodecSupported(NetEqDecoder::kDecoderOpus_2ch)); |
705 } | 693 } |
706 | 694 |
707 } // namespace webrtc | 695 } // namespace webrtc |
OLD | NEW |