OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "webrtc/base/array_view.h" | 14 #include "webrtc/base/array_view.h" |
15 #include "webrtc/base/optional.h" | |
15 #include "webrtc/modules/audio_processing/audio_buffer.h" | 16 #include "webrtc/modules/audio_processing/audio_buffer.h" |
16 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 17 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
17 #include "webrtc/modules/audio_processing/level_controller/level_controller.h" | 18 #include "webrtc/modules/audio_processing/level_controller/level_controller.h" |
18 #include "webrtc/modules/audio_processing/test/audio_buffer_tools.h" | 19 #include "webrtc/modules/audio_processing/test/audio_buffer_tools.h" |
19 #include "webrtc/modules/audio_processing/test/bitexactness_tools.h" | 20 #include "webrtc/modules/audio_processing/test/bitexactness_tools.h" |
20 | 21 |
21 namespace webrtc { | 22 namespace webrtc { |
22 namespace { | 23 namespace { |
23 | 24 |
24 const int kNumFramesToProcess = 1000; | 25 const int kNumFramesToProcess = 1000; |
25 | 26 |
26 // Processes a specified amount of frames, verifies the results and reports | 27 // Processes a specified amount of frames, verifies the results and reports |
27 // any errors. | 28 // any errors. |
28 void RunBitexactnessTest(int sample_rate_hz, | 29 void RunBitexactnessTest(int sample_rate_hz, |
29 size_t num_channels, | 30 size_t num_channels, |
31 rtc::Optional<float> initial_level, | |
30 rtc::ArrayView<const float> output_reference) { | 32 rtc::ArrayView<const float> output_reference) { |
31 LevelController level_controller; | 33 LevelController level_controller; |
32 level_controller.Initialize(sample_rate_hz); | 34 level_controller.Initialize(sample_rate_hz); |
35 if (initial_level) { | |
the sun
2016/09/16 08:00:40
Note, since you currently have an optional in the
peah-webrtc
2016/09/16 11:36:05
True! This is, however, now changed and therefore
| |
36 AudioProcessing::Config::LevelController config; | |
37 config.initial_level = rtc::Optional<float>(*initial_level); | |
38 level_controller.ApplyConfig(config); | |
39 } | |
33 | 40 |
34 int samples_per_channel = rtc::CheckedDivExact(sample_rate_hz, 100); | 41 int samples_per_channel = rtc::CheckedDivExact(sample_rate_hz, 100); |
35 const StreamConfig capture_config(sample_rate_hz, num_channels, false); | 42 const StreamConfig capture_config(sample_rate_hz, num_channels, false); |
36 AudioBuffer capture_buffer( | 43 AudioBuffer capture_buffer( |
37 capture_config.num_frames(), capture_config.num_channels(), | 44 capture_config.num_frames(), capture_config.num_channels(), |
38 capture_config.num_frames(), capture_config.num_channels(), | 45 capture_config.num_frames(), capture_config.num_channels(), |
39 capture_config.num_frames()); | 46 capture_config.num_frames()); |
40 test::InputAudioFile capture_file( | 47 test::InputAudioFile capture_file( |
41 test::GetApmCaptureTestVectorFileName(sample_rate_hz)); | 48 test::GetApmCaptureTestVectorFileName(sample_rate_hz)); |
42 std::vector<float> capture_input(samples_per_channel * num_channels); | 49 std::vector<float> capture_input(samples_per_channel * num_channels); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 } | 90 } |
84 | 91 |
85 TEST(LevelControlConfigTest, DefaultValue) { | 92 TEST(LevelControlConfigTest, DefaultValue) { |
86 AudioProcessing::Config config; | 93 AudioProcessing::Config config; |
87 EXPECT_FALSE(config.level_controller.enabled); | 94 EXPECT_FALSE(config.level_controller.enabled); |
88 } | 95 } |
89 | 96 |
90 TEST(LevelControlBitExactnessTest, DISABLED_Mono8kHz) { | 97 TEST(LevelControlBitExactnessTest, DISABLED_Mono8kHz) { |
91 const float kOutputReference[] = {-0.013939f, -0.012154f, -0.009054f}; | 98 const float kOutputReference[] = {-0.013939f, -0.012154f, -0.009054f}; |
92 RunBitexactnessTest(AudioProcessing::kSampleRate8kHz, 1, | 99 RunBitexactnessTest(AudioProcessing::kSampleRate8kHz, 1, |
93 kOutputReference); | 100 rtc::Optional<float>(), kOutputReference); |
94 } | 101 } |
95 | 102 |
96 TEST(LevelControlBitExactnessTest, DISABLED_Mono16kHz) { | 103 TEST(LevelControlBitExactnessTest, DISABLED_Mono16kHz) { |
97 const float kOutputReference[] = {-0.013706f, -0.013215f, -0.013018f}; | 104 const float kOutputReference[] = {-0.013706f, -0.013215f, -0.013018f}; |
98 RunBitexactnessTest(AudioProcessing::kSampleRate16kHz, 1, | 105 RunBitexactnessTest(AudioProcessing::kSampleRate16kHz, 1, |
99 kOutputReference); | 106 rtc::Optional<float>(), kOutputReference); |
100 } | 107 } |
101 | 108 |
102 TEST(LevelControlBitExactnessTest, DISABLED_Mono32kHz) { | 109 TEST(LevelControlBitExactnessTest, DISABLED_Mono32kHz) { |
103 const float kOutputReference[] = {-0.014495f, -0.016425f, -0.016085f}; | 110 const float kOutputReference[] = {-0.014495f, -0.016425f, -0.016085f}; |
104 RunBitexactnessTest(AudioProcessing::kSampleRate32kHz, 1, | 111 RunBitexactnessTest(AudioProcessing::kSampleRate32kHz, 1, |
105 kOutputReference); | 112 rtc::Optional<float>(), kOutputReference); |
106 } | 113 } |
107 | 114 |
108 // TODO(peah): Investigate why this particular testcase differ between Android | 115 // TODO(peah): Investigate why this particular testcase differ between Android |
109 // and the rest of the platforms. | 116 // and the rest of the platforms. |
110 TEST(LevelControlBitExactnessTest, DISABLED_Mono48kHz) { | 117 TEST(LevelControlBitExactnessTest, DISABLED_Mono48kHz) { |
111 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ | 118 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ |
112 defined(WEBRTC_ANDROID)) | 119 defined(WEBRTC_ANDROID)) |
113 const float kOutputReference[] = {-0.014277f, -0.015180f, -0.017437f}; | 120 const float kOutputReference[] = {-0.014277f, -0.015180f, -0.017437f}; |
114 #else | 121 #else |
115 const float kOutputReference[] = {-0.015949f, -0.016957f, -0.019478f}; | 122 const float kOutputReference[] = {-0.015949f, -0.016957f, -0.019478f}; |
116 #endif | 123 #endif |
117 RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 1, | 124 RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 1, |
118 kOutputReference); | 125 rtc::Optional<float>(), kOutputReference); |
119 } | 126 } |
120 | 127 |
121 TEST(LevelControlBitExactnessTest, DISABLED_Stereo8kHz) { | 128 TEST(LevelControlBitExactnessTest, DISABLED_Stereo8kHz) { |
122 const float kOutputReference[] = {-0.014063f, -0.008450f, -0.012159f, | 129 const float kOutputReference[] = {-0.014063f, -0.008450f, -0.012159f, |
123 -0.051967f, -0.023202f, -0.047858f}; | 130 -0.051967f, -0.023202f, -0.047858f}; |
124 RunBitexactnessTest(AudioProcessing::kSampleRate8kHz, 2, | 131 RunBitexactnessTest(AudioProcessing::kSampleRate8kHz, 2, |
125 kOutputReference); | 132 rtc::Optional<float>(), kOutputReference); |
126 } | 133 } |
127 | 134 |
128 TEST(LevelControlBitExactnessTest, DISABLED_Stereo16kHz) { | 135 TEST(LevelControlBitExactnessTest, DISABLED_Stereo16kHz) { |
129 const float kOutputReference[] = {-0.012714f, -0.005896f, -0.012220f, | 136 const float kOutputReference[] = {-0.012714f, -0.005896f, -0.012220f, |
130 -0.053306f, -0.024549f, -0.051527f}; | 137 -0.053306f, -0.024549f, -0.051527f}; |
131 RunBitexactnessTest(AudioProcessing::kSampleRate16kHz, 2, | 138 RunBitexactnessTest(AudioProcessing::kSampleRate16kHz, 2, |
132 kOutputReference); | 139 rtc::Optional<float>(), kOutputReference); |
133 } | 140 } |
134 | 141 |
135 TEST(LevelControlBitExactnessTest, DISABLED_Stereo32kHz) { | 142 TEST(LevelControlBitExactnessTest, DISABLED_Stereo32kHz) { |
136 const float kOutputReference[] = {-0.011737f, -0.007018f, -0.013446f, | 143 const float kOutputReference[] = {-0.011737f, -0.007018f, -0.013446f, |
137 -0.053505f, -0.026292f, -0.056221f}; | 144 -0.053505f, -0.026292f, -0.056221f}; |
138 RunBitexactnessTest(AudioProcessing::kSampleRate32kHz, 2, | 145 RunBitexactnessTest(AudioProcessing::kSampleRate32kHz, 2, |
139 kOutputReference); | 146 rtc::Optional<float>(), kOutputReference); |
140 } | 147 } |
141 | 148 |
142 TEST(LevelControlBitExactnessTest, DISABLED_Stereo48kHz) { | 149 TEST(LevelControlBitExactnessTest, DISABLED_Stereo48kHz) { |
143 const float kOutputReference[] = {-0.010643f, -0.006334f, -0.011377f, | 150 const float kOutputReference[] = {-0.010643f, -0.006334f, -0.011377f, |
144 -0.049088f, -0.023600f, -0.050465f}; | 151 -0.049088f, -0.023600f, -0.050465f}; |
145 RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 2, | 152 RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 2, |
146 kOutputReference); | 153 rtc::Optional<float>(), kOutputReference); |
154 } | |
155 | |
156 TEST(LevelControlBitExactnessTest, DISABLED_MonoInitial48kHz) { | |
157 const float kOutputReference[] = {-0.013753f, -0.014623f, -0.016797f}; | |
158 RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 1, | |
159 rtc::Optional<float>(-50), kOutputReference); | |
147 } | 160 } |
148 | 161 |
149 | 162 |
150 | 163 |
151 } // namespace webrtc | 164 } // namespace webrtc |
OLD | NEW |