blob: 8014f8a5d073ef69e023dbda0d3d46a5a5f3570e [file] [log] [blame]
peah57d5a2e2016-03-29 09:48:36 -07001/*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10#include <vector>
11
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020012#include "api/array_view.h"
13#include "modules/audio_processing/audio_buffer.h"
14#include "modules/audio_processing/gain_control_impl.h"
15#include "modules/audio_processing/test/audio_buffer_tools.h"
16#include "modules/audio_processing/test/bitexactness_tools.h"
17#include "test/gtest.h"
peah57d5a2e2016-03-29 09:48:36 -070018
peah57d5a2e2016-03-29 09:48:36 -070019namespace webrtc {
20namespace {
21
22const int kNumFramesToProcess = 100;
23
24void ProcessOneFrame(int sample_rate_hz,
25 AudioBuffer* render_audio_buffer,
26 AudioBuffer* capture_audio_buffer,
27 GainControlImpl* gain_controller) {
28 if (sample_rate_hz > AudioProcessing::kSampleRate16kHz) {
29 render_audio_buffer->SplitIntoFrequencyBands();
30 capture_audio_buffer->SplitIntoFrequencyBands();
31 }
32
peah701d6282016-10-25 05:42:20 -070033 std::vector<int16_t> render_audio;
34 GainControlImpl::PackRenderAudioBuffer(render_audio_buffer, &render_audio);
35 gain_controller->ProcessRenderAudio(render_audio);
peah57d5a2e2016-03-29 09:48:36 -070036 gain_controller->AnalyzeCaptureAudio(capture_audio_buffer);
37 gain_controller->ProcessCaptureAudio(capture_audio_buffer, false);
38
39 if (sample_rate_hz > AudioProcessing::kSampleRate16kHz) {
40 capture_audio_buffer->MergeFrequencyBands();
41 }
42}
43
44void SetupComponent(int sample_rate_hz,
45 GainControl::Mode mode,
46 int target_level_dbfs,
47 int stream_analog_level,
48 int compression_gain_db,
49 bool enable_limiter,
50 int analog_level_min,
51 int analog_level_max,
52 GainControlImpl* gain_controller) {
53 gain_controller->Initialize(1, sample_rate_hz);
54 GainControl* gc = static_cast<GainControl*>(gain_controller);
55 gc->Enable(true);
56 gc->set_mode(mode);
57 gc->set_stream_analog_level(stream_analog_level);
58 gc->set_target_level_dbfs(target_level_dbfs);
59 gc->set_compression_gain_db(compression_gain_db);
60 gc->enable_limiter(enable_limiter);
61 gc->set_analog_level_limits(analog_level_min, analog_level_max);
62}
63
64void RunBitExactnessTest(int sample_rate_hz,
65 size_t num_channels,
66 GainControl::Mode mode,
67 int target_level_dbfs,
68 int stream_analog_level,
69 int compression_gain_db,
70 bool enable_limiter,
71 int analog_level_min,
72 int analog_level_max,
73 int achieved_stream_analog_level_reference,
74 rtc::ArrayView<const float> output_reference) {
Sam Zackrissonf0d1c032019-03-27 13:28:08 +010075 GainControlImpl gain_controller;
peah57d5a2e2016-03-29 09:48:36 -070076 SetupComponent(sample_rate_hz, mode, target_level_dbfs, stream_analog_level,
77 compression_gain_db, enable_limiter, analog_level_min,
78 analog_level_max, &gain_controller);
79
80 const int samples_per_channel = rtc::CheckedDivExact(sample_rate_hz, 100);
81 const StreamConfig render_config(sample_rate_hz, num_channels, false);
82 AudioBuffer render_buffer(
Per Åhgrend47941e2019-08-22 11:51:13 +020083 render_config.sample_rate_hz(), render_config.num_channels(),
84 render_config.sample_rate_hz(), 1, render_config.sample_rate_hz(), 1);
peah57d5a2e2016-03-29 09:48:36 -070085 test::InputAudioFile render_file(
86 test::GetApmRenderTestVectorFileName(sample_rate_hz));
87 std::vector<float> render_input(samples_per_channel * num_channels);
88
89 const StreamConfig capture_config(sample_rate_hz, num_channels, false);
90 AudioBuffer capture_buffer(
Per Åhgrend47941e2019-08-22 11:51:13 +020091 capture_config.sample_rate_hz(), capture_config.num_channels(),
92 capture_config.sample_rate_hz(), 1, capture_config.sample_rate_hz(), 1);
peah57d5a2e2016-03-29 09:48:36 -070093 test::InputAudioFile capture_file(
94 test::GetApmCaptureTestVectorFileName(sample_rate_hz));
95 std::vector<float> capture_input(samples_per_channel * num_channels);
96
97 for (int frame_no = 0; frame_no < kNumFramesToProcess; ++frame_no) {
98 ReadFloatSamplesFromStereoFile(samples_per_channel, num_channels,
99 &render_file, render_input);
100 ReadFloatSamplesFromStereoFile(samples_per_channel, num_channels,
101 &capture_file, capture_input);
102
103 test::CopyVectorToAudioBuffer(render_config, render_input, &render_buffer);
104 test::CopyVectorToAudioBuffer(capture_config, capture_input,
105 &capture_buffer);
106
107 ProcessOneFrame(sample_rate_hz, &render_buffer, &capture_buffer,
108 &gain_controller);
109 }
110
111 // Extract and verify the test results.
112 std::vector<float> capture_output;
113 test::ExtractVectorFromAudioBuffer(capture_config, &capture_buffer,
114 &capture_output);
115
116 EXPECT_EQ(achieved_stream_analog_level_reference,
117 gain_controller.stream_analog_level());
118
119 // Compare the output with the reference. Only the first values of the output
120 // from last frame processed are compared in order not having to specify all
121 // preceeding frames as testvectors. As the algorithm being tested has a
122 // memory, testing only the last frame implicitly also tests the preceeding
123 // frames.
peah7ea928e2016-03-30 08:13:57 -0700124 const float kElementErrorBound = 1.0f / 32768.0f;
125 EXPECT_TRUE(test::VerifyDeinterleavedArray(
peah57d5a2e2016-03-29 09:48:36 -0700126 capture_config.num_frames(), capture_config.num_channels(),
peah7ea928e2016-03-30 08:13:57 -0700127 output_reference, capture_output, kElementErrorBound));
peah57d5a2e2016-03-29 09:48:36 -0700128}
129
130} // namespace
131
peah51fbdd62016-03-30 14:58:32 -0700132// TODO(peah): Activate all these tests for ARM and ARM64 once the issue on the
133// Chromium ARM and ARM64 boths have been identified. This is tracked in the
134// issue https://bugs.chromium.org/p/webrtc/issues/detail?id=5711.
135
136#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
137 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700138TEST(GainControlBitExactnessTest,
139 Mono8kHz_AdaptiveAnalog_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700140#else
141TEST(GainControlBitExactnessTest,
142 DISABLED_Mono8kHz_AdaptiveAnalog_Tl10_SL50_CG5_Lim_AL0_100) {
143#endif
peah57d5a2e2016-03-29 09:48:36 -0700144 const int kStreamAnalogLevelReference = 50;
145 const float kOutputReference[] = {-0.006622f, -0.002747f, 0.001587f};
146 RunBitExactnessTest(8000, 1, GainControl::Mode::kAdaptiveAnalog, 10, 50, 5,
147 true, 0, 100, kStreamAnalogLevelReference,
148 kOutputReference);
149}
150
peah51fbdd62016-03-30 14:58:32 -0700151#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
152 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700153TEST(GainControlBitExactnessTest,
154 Mono16kHz_AdaptiveAnalog_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700155#else
156TEST(GainControlBitExactnessTest,
157 DISABLED_Mono16kHz_AdaptiveAnalog_Tl10_SL50_CG5_Lim_AL0_100) {
158#endif
peah57d5a2e2016-03-29 09:48:36 -0700159 const int kStreamAnalogLevelReference = 50;
160 const float kOutputReference[] = {-0.006561f, -0.004608f, -0.002899f};
161 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveAnalog, 10, 50, 5,
162 true, 0, 100, kStreamAnalogLevelReference,
163 kOutputReference);
164}
165
peah51fbdd62016-03-30 14:58:32 -0700166#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
167 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700168TEST(GainControlBitExactnessTest,
169 Stereo16kHz_AdaptiveAnalog_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700170#else
171TEST(GainControlBitExactnessTest,
172 DISABLED_Stereo16kHz_AdaptiveAnalog_Tl10_SL50_CG5_Lim_AL0_100) {
173#endif
peah57d5a2e2016-03-29 09:48:36 -0700174 const int kStreamAnalogLevelReference = 50;
175 const float kOutputReference[] = {-0.027313f, -0.015900f, -0.028107f,
176 -0.027313f, -0.015900f, -0.028107f};
177 RunBitExactnessTest(16000, 2, GainControl::Mode::kAdaptiveAnalog, 10, 50, 5,
178 true, 0, 100, kStreamAnalogLevelReference,
179 kOutputReference);
180}
181
peah51fbdd62016-03-30 14:58:32 -0700182#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
183 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700184TEST(GainControlBitExactnessTest,
185 Mono32kHz_AdaptiveAnalog_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700186#else
187TEST(GainControlBitExactnessTest,
188 DISABLED_Mono32kHz_AdaptiveAnalog_Tl10_SL50_CG5_Lim_AL0_100) {
189#endif
peah57d5a2e2016-03-29 09:48:36 -0700190 const int kStreamAnalogLevelReference = 50;
191 const float kOutputReference[] = {-0.010162f, -0.009155f, -0.008301f};
192 RunBitExactnessTest(32000, 1, GainControl::Mode::kAdaptiveAnalog, 10, 50, 5,
193 true, 0, 100, kStreamAnalogLevelReference,
194 kOutputReference);
195}
196
peah51fbdd62016-03-30 14:58:32 -0700197#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
198 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700199TEST(GainControlBitExactnessTest,
200 Mono48kHz_AdaptiveAnalog_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700201#else
202TEST(GainControlBitExactnessTest,
203 DISABLED_Mono48kHz_AdaptiveAnalog_Tl10_SL50_CG5_Lim_AL0_100) {
204#endif
peah57d5a2e2016-03-29 09:48:36 -0700205 const int kStreamAnalogLevelReference = 50;
206 const float kOutputReference[] = {-0.010162f, -0.009155f, -0.008301f};
207 RunBitExactnessTest(32000, 1, GainControl::Mode::kAdaptiveAnalog, 10, 50, 5,
208 true, 0, 100, kStreamAnalogLevelReference,
209 kOutputReference);
210}
211
peah51fbdd62016-03-30 14:58:32 -0700212#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
213 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700214TEST(GainControlBitExactnessTest,
215 Mono8kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700216#else
217TEST(GainControlBitExactnessTest,
218 DISABLED_Mono8kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) {
219#endif
peah57d5a2e2016-03-29 09:48:36 -0700220 const int kStreamAnalogLevelReference = 50;
minyuefd634c42016-06-17 04:36:10 -0700221 const float kOutputReference[] = {-0.004028f, -0.001678f, 0.000946f};
peah57d5a2e2016-03-29 09:48:36 -0700222 RunBitExactnessTest(8000, 1, GainControl::Mode::kAdaptiveDigital, 10, 50, 5,
223 true, 0, 100, kStreamAnalogLevelReference,
224 kOutputReference);
225}
226
peah51fbdd62016-03-30 14:58:32 -0700227#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
228 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700229TEST(GainControlBitExactnessTest,
230 Mono16kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700231#else
232TEST(GainControlBitExactnessTest,
233 DISABLED_Mono16kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) {
234#endif
peah57d5a2e2016-03-29 09:48:36 -0700235 const int kStreamAnalogLevelReference = 50;
peah12986c42016-10-22 02:38:32 -0700236 const float kOutputReference[] = {-0.003967f, -0.002777f, -0.001770f};
peah57d5a2e2016-03-29 09:48:36 -0700237 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveDigital, 10, 50, 5,
238 true, 0, 100, kStreamAnalogLevelReference,
239 kOutputReference);
240}
241
peah51fbdd62016-03-30 14:58:32 -0700242#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
243 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700244TEST(GainControlBitExactnessTest,
245 Stereo16kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700246#else
247TEST(GainControlBitExactnessTest,
248 DISABLED_Stereo16kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) {
249#endif
peah57d5a2e2016-03-29 09:48:36 -0700250 const int kStreamAnalogLevelReference = 50;
minyuefd634c42016-06-17 04:36:10 -0700251 const float kOutputReference[] = {-0.015411f, -0.008972f, -0.015839f,
252 -0.015411f, -0.008972f, -0.015839f};
peah57d5a2e2016-03-29 09:48:36 -0700253 RunBitExactnessTest(16000, 2, GainControl::Mode::kAdaptiveDigital, 10, 50, 5,
254 true, 0, 100, kStreamAnalogLevelReference,
255 kOutputReference);
256}
257
peah51fbdd62016-03-30 14:58:32 -0700258#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
259 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700260TEST(GainControlBitExactnessTest,
261 Mono32kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700262#else
263TEST(GainControlBitExactnessTest,
264 DISABLED_Mono32kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) {
265#endif
peah57d5a2e2016-03-29 09:48:36 -0700266 const int kStreamAnalogLevelReference = 50;
peah12986c42016-10-22 02:38:32 -0700267 const float kOutputReference[] = {-0.006104f, -0.005524f, -0.004974f};
peah57d5a2e2016-03-29 09:48:36 -0700268 RunBitExactnessTest(32000, 1, GainControl::Mode::kAdaptiveDigital, 10, 50, 5,
269 true, 0, 100, kStreamAnalogLevelReference,
270 kOutputReference);
271}
272
peah51fbdd62016-03-30 14:58:32 -0700273#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
274 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700275TEST(GainControlBitExactnessTest,
276 Mono48kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700277#else
278TEST(GainControlBitExactnessTest,
279 DISABLED_Mono48kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) {
280#endif
peah57d5a2e2016-03-29 09:48:36 -0700281 const int kStreamAnalogLevelReference = 50;
peah12986c42016-10-22 02:38:32 -0700282 const float kOutputReference[] = {-0.006104f, -0.005524f, -0.004974f};
peah57d5a2e2016-03-29 09:48:36 -0700283 RunBitExactnessTest(32000, 1, GainControl::Mode::kAdaptiveDigital, 10, 50, 5,
284 true, 0, 100, kStreamAnalogLevelReference,
285 kOutputReference);
286}
287
peah51fbdd62016-03-30 14:58:32 -0700288#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
289 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700290TEST(GainControlBitExactnessTest,
291 Mono8kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700292#else
293TEST(GainControlBitExactnessTest,
294 DISABLED_Mono8kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) {
295#endif
peah57d5a2e2016-03-29 09:48:36 -0700296 const int kStreamAnalogLevelReference = 50;
297 const float kOutputReference[] = {-0.011871f, -0.004944f, 0.002838f};
298 RunBitExactnessTest(8000, 1, GainControl::Mode::kFixedDigital, 10, 50, 5,
299 true, 0, 100, kStreamAnalogLevelReference,
300 kOutputReference);
301}
302
peah51fbdd62016-03-30 14:58:32 -0700303#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
304 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700305TEST(GainControlBitExactnessTest,
306 Mono16kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700307#else
308TEST(GainControlBitExactnessTest,
309 DISABLED_Mono16kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) {
310#endif
peah57d5a2e2016-03-29 09:48:36 -0700311 const int kStreamAnalogLevelReference = 50;
peah12986c42016-10-22 02:38:32 -0700312 const float kOutputReference[] = {-0.011749f, -0.008270f, -0.005219f};
peah57d5a2e2016-03-29 09:48:36 -0700313 RunBitExactnessTest(16000, 1, GainControl::Mode::kFixedDigital, 10, 50, 5,
314 true, 0, 100, kStreamAnalogLevelReference,
315 kOutputReference);
316}
317
peah51fbdd62016-03-30 14:58:32 -0700318#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
319 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700320TEST(GainControlBitExactnessTest,
321 Stereo16kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700322#else
323TEST(GainControlBitExactnessTest,
324 DISABLED_Stereo16kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) {
325#endif
peah57d5a2e2016-03-29 09:48:36 -0700326 const int kStreamAnalogLevelReference = 50;
327 const float kOutputReference[] = {-0.048950f, -0.028503f, -0.050354f,
328 -0.048950f, -0.028503f, -0.050354f};
329 RunBitExactnessTest(16000, 2, GainControl::Mode::kFixedDigital, 10, 50, 5,
330 true, 0, 100, kStreamAnalogLevelReference,
331 kOutputReference);
332}
333
peah51fbdd62016-03-30 14:58:32 -0700334#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
335 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700336TEST(GainControlBitExactnessTest,
337 Mono32kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700338#else
339TEST(GainControlBitExactnessTest,
340 DISABLED_Mono32kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) {
341#endif
peah57d5a2e2016-03-29 09:48:36 -0700342 const int kStreamAnalogLevelReference = 50;
343 const float kOutputReference[] = {-0.018188f, -0.016418f, -0.014862f};
344 RunBitExactnessTest(32000, 1, GainControl::Mode::kFixedDigital, 10, 50, 5,
345 true, 0, 100, kStreamAnalogLevelReference,
346 kOutputReference);
347}
348
peah51fbdd62016-03-30 14:58:32 -0700349#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
350 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700351TEST(GainControlBitExactnessTest,
352 Mono48kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700353#else
354TEST(GainControlBitExactnessTest,
355 DISABLED_Mono48kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) {
356#endif
peah57d5a2e2016-03-29 09:48:36 -0700357 const int kStreamAnalogLevelReference = 50;
358 const float kOutputReference[] = {-0.018188f, -0.016418f, -0.014862f};
359 RunBitExactnessTest(32000, 1, GainControl::Mode::kFixedDigital, 10, 50, 5,
360 true, 0, 100, kStreamAnalogLevelReference,
361 kOutputReference);
362}
363
peah51fbdd62016-03-30 14:58:32 -0700364#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
365 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700366TEST(GainControlBitExactnessTest,
367 Mono16kHz_AdaptiveAnalog_Tl10_SL10_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700368#else
369TEST(GainControlBitExactnessTest,
370 DISABLED_Mono16kHz_AdaptiveAnalog_Tl10_SL10_CG5_Lim_AL0_100) {
371#endif
peah57d5a2e2016-03-29 09:48:36 -0700372 const int kStreamAnalogLevelReference = 12;
373 const float kOutputReference[] = {-0.006561f, -0.004608f, -0.002899f};
374 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveAnalog, 10, 10, 5,
375 true, 0, 100, kStreamAnalogLevelReference,
376 kOutputReference);
377}
378
peah51fbdd62016-03-30 14:58:32 -0700379#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
380 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700381TEST(GainControlBitExactnessTest,
382 Mono16kHz_AdaptiveAnalog_Tl10_SL100_CG5_Lim_AL70_80) {
peah51fbdd62016-03-30 14:58:32 -0700383#else
384TEST(GainControlBitExactnessTest,
385 DISABLED_Mono16kHz_AdaptiveAnalog_Tl10_SL100_CG5_Lim_AL70_80) {
386#endif
peah57d5a2e2016-03-29 09:48:36 -0700387 const int kStreamAnalogLevelReference = 100;
peah12986c42016-10-22 02:38:32 -0700388 const float kOutputReference[] = {-0.003998f, -0.002808f, -0.001770f};
peah57d5a2e2016-03-29 09:48:36 -0700389 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveAnalog, 10, 100, 5,
390 true, 70, 80, kStreamAnalogLevelReference,
391 kOutputReference);
392}
393
peah51fbdd62016-03-30 14:58:32 -0700394#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
395 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700396TEST(GainControlBitExactnessTest,
397 Mono16kHz_AdaptiveDigital_Tl10_SL100_CG5_NoLim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700398#else
399TEST(GainControlBitExactnessTest,
400 DISABLED_Mono16kHz_AdaptiveDigital_Tl10_SL100_CG5_NoLim_AL0_100) {
401#endif
peah57d5a2e2016-03-29 09:48:36 -0700402 const int kStreamAnalogLevelReference = 100;
peah12986c42016-10-22 02:38:32 -0700403 const float kOutputReference[] = {-0.004028f, -0.002838f, -0.001770f};
peah57d5a2e2016-03-29 09:48:36 -0700404 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveDigital, 10, 100, 5,
405 false, 0, 100, kStreamAnalogLevelReference,
406 kOutputReference);
407}
408
peah51fbdd62016-03-30 14:58:32 -0700409#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
410 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700411TEST(GainControlBitExactnessTest,
412 Mono16kHz_AdaptiveDigital_Tl40_SL100_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700413#else
414TEST(GainControlBitExactnessTest,
415 DISABLED_Mono16kHz_AdaptiveDigital_Tl40_SL100_CG5_Lim_AL0_100) {
416#endif
peah57d5a2e2016-03-29 09:48:36 -0700417 const int kStreamAnalogLevelReference = 100;
peah12986c42016-10-22 02:38:32 -0700418 const float kOutputReference[] = {-0.008728f, -0.006134f, -0.003845f};
peah57d5a2e2016-03-29 09:48:36 -0700419 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveDigital, 40, 100, 5,
420 true, 0, 100, kStreamAnalogLevelReference,
421 kOutputReference);
422}
423
peah51fbdd62016-03-30 14:58:32 -0700424#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
425 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700426TEST(GainControlBitExactnessTest,
427 Mono16kHz_AdaptiveDigital_Tl10_SL100_CG30_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700428#else
429TEST(GainControlBitExactnessTest,
430 DISABLED_Mono16kHz_AdaptiveDigital_Tl10_SL100_CG30_Lim_AL0_100) {
431#endif
peah57d5a2e2016-03-29 09:48:36 -0700432 const int kStreamAnalogLevelReference = 100;
peah12986c42016-10-22 02:38:32 -0700433 const float kOutputReference[] = {-0.005859f, -0.004120f, -0.002594f};
peah57d5a2e2016-03-29 09:48:36 -0700434 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveDigital, 10, 100,
435 30, true, 0, 100, kStreamAnalogLevelReference,
436 kOutputReference);
437}
438
439} // namespace webrtc