blob: 1662dc506f1f849fcaf4c7dac30d70f82cdf218a [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;
Per Åhgrene35b32c2019-11-22 18:22:04 +010034 GainControlImpl::PackRenderAudioBuffer(*render_audio_buffer, &render_audio);
peah701d6282016-10-25 05:42:20 -070035 gain_controller->ProcessRenderAudio(render_audio);
Per Åhgrene35b32c2019-11-22 18:22:04 +010036 gain_controller->AnalyzeCaptureAudio(*capture_audio_buffer);
peah57d5a2e2016-03-29 09:48:36 -070037 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);
peah57d5a2e2016-03-29 09:48:36 -070055 gc->set_mode(mode);
56 gc->set_stream_analog_level(stream_analog_level);
57 gc->set_target_level_dbfs(target_level_dbfs);
58 gc->set_compression_gain_db(compression_gain_db);
59 gc->enable_limiter(enable_limiter);
60 gc->set_analog_level_limits(analog_level_min, analog_level_max);
61}
62
63void RunBitExactnessTest(int sample_rate_hz,
64 size_t num_channels,
65 GainControl::Mode mode,
66 int target_level_dbfs,
67 int stream_analog_level,
68 int compression_gain_db,
69 bool enable_limiter,
70 int analog_level_min,
71 int analog_level_max,
72 int achieved_stream_analog_level_reference,
73 rtc::ArrayView<const float> output_reference) {
Sam Zackrissonf0d1c032019-03-27 13:28:08 +010074 GainControlImpl gain_controller;
peah57d5a2e2016-03-29 09:48:36 -070075 SetupComponent(sample_rate_hz, mode, target_level_dbfs, stream_analog_level,
76 compression_gain_db, enable_limiter, analog_level_min,
77 analog_level_max, &gain_controller);
78
79 const int samples_per_channel = rtc::CheckedDivExact(sample_rate_hz, 100);
Henrik Lundin64253a92022-02-04 09:02:48 +000080 const StreamConfig render_config(sample_rate_hz, num_channels);
peah57d5a2e2016-03-29 09:48:36 -070081 AudioBuffer render_buffer(
Per Åhgrend47941e2019-08-22 11:51:13 +020082 render_config.sample_rate_hz(), render_config.num_channels(),
83 render_config.sample_rate_hz(), 1, render_config.sample_rate_hz(), 1);
peah57d5a2e2016-03-29 09:48:36 -070084 test::InputAudioFile render_file(
85 test::GetApmRenderTestVectorFileName(sample_rate_hz));
86 std::vector<float> render_input(samples_per_channel * num_channels);
87
Henrik Lundin64253a92022-02-04 09:02:48 +000088 const StreamConfig capture_config(sample_rate_hz, num_channels);
peah57d5a2e2016-03-29 09:48:36 -070089 AudioBuffer capture_buffer(
Per Åhgrend47941e2019-08-22 11:51:13 +020090 capture_config.sample_rate_hz(), capture_config.num_channels(),
91 capture_config.sample_rate_hz(), 1, capture_config.sample_rate_hz(), 1);
peah57d5a2e2016-03-29 09:48:36 -070092 test::InputAudioFile capture_file(
93 test::GetApmCaptureTestVectorFileName(sample_rate_hz));
94 std::vector<float> capture_input(samples_per_channel * num_channels);
95
96 for (int frame_no = 0; frame_no < kNumFramesToProcess; ++frame_no) {
97 ReadFloatSamplesFromStereoFile(samples_per_channel, num_channels,
98 &render_file, render_input);
99 ReadFloatSamplesFromStereoFile(samples_per_channel, num_channels,
100 &capture_file, capture_input);
101
102 test::CopyVectorToAudioBuffer(render_config, render_input, &render_buffer);
103 test::CopyVectorToAudioBuffer(capture_config, capture_input,
104 &capture_buffer);
105
106 ProcessOneFrame(sample_rate_hz, &render_buffer, &capture_buffer,
107 &gain_controller);
108 }
109
110 // Extract and verify the test results.
111 std::vector<float> capture_output;
112 test::ExtractVectorFromAudioBuffer(capture_config, &capture_buffer,
113 &capture_output);
114
115 EXPECT_EQ(achieved_stream_analog_level_reference,
116 gain_controller.stream_analog_level());
117
118 // Compare the output with the reference. Only the first values of the output
119 // from last frame processed are compared in order not having to specify all
120 // preceeding frames as testvectors. As the algorithm being tested has a
121 // memory, testing only the last frame implicitly also tests the preceeding
122 // frames.
peah7ea928e2016-03-30 08:13:57 -0700123 const float kElementErrorBound = 1.0f / 32768.0f;
124 EXPECT_TRUE(test::VerifyDeinterleavedArray(
peah57d5a2e2016-03-29 09:48:36 -0700125 capture_config.num_frames(), capture_config.num_channels(),
peah7ea928e2016-03-30 08:13:57 -0700126 output_reference, capture_output, kElementErrorBound));
peah57d5a2e2016-03-29 09:48:36 -0700127}
128
129} // namespace
130
peah51fbdd62016-03-30 14:58:32 -0700131// TODO(peah): Activate all these tests for ARM and ARM64 once the issue on the
132// Chromium ARM and ARM64 boths have been identified. This is tracked in the
133// issue https://bugs.chromium.org/p/webrtc/issues/detail?id=5711.
134
135#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
136 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700137TEST(GainControlBitExactnessTest,
peah57d5a2e2016-03-29 09:48:36 -0700138 Mono16kHz_AdaptiveAnalog_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700139#else
140TEST(GainControlBitExactnessTest,
141 DISABLED_Mono16kHz_AdaptiveAnalog_Tl10_SL50_CG5_Lim_AL0_100) {
142#endif
peah57d5a2e2016-03-29 09:48:36 -0700143 const int kStreamAnalogLevelReference = 50;
144 const float kOutputReference[] = {-0.006561f, -0.004608f, -0.002899f};
145 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveAnalog, 10, 50, 5,
146 true, 0, 100, kStreamAnalogLevelReference,
147 kOutputReference);
148}
149
peah51fbdd62016-03-30 14:58:32 -0700150#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
151 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700152TEST(GainControlBitExactnessTest,
153 Stereo16kHz_AdaptiveAnalog_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700154#else
155TEST(GainControlBitExactnessTest,
156 DISABLED_Stereo16kHz_AdaptiveAnalog_Tl10_SL50_CG5_Lim_AL0_100) {
157#endif
peah57d5a2e2016-03-29 09:48:36 -0700158 const int kStreamAnalogLevelReference = 50;
159 const float kOutputReference[] = {-0.027313f, -0.015900f, -0.028107f,
160 -0.027313f, -0.015900f, -0.028107f};
161 RunBitExactnessTest(16000, 2, 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 Mono32kHz_AdaptiveAnalog_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700170#else
171TEST(GainControlBitExactnessTest,
172 DISABLED_Mono32kHz_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.010162f, -0.009155f, -0.008301f};
176 RunBitExactnessTest(32000, 1, GainControl::Mode::kAdaptiveAnalog, 10, 50, 5,
177 true, 0, 100, kStreamAnalogLevelReference,
178 kOutputReference);
179}
180
peah51fbdd62016-03-30 14:58:32 -0700181#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
182 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700183TEST(GainControlBitExactnessTest,
184 Mono48kHz_AdaptiveAnalog_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700185#else
186TEST(GainControlBitExactnessTest,
187 DISABLED_Mono48kHz_AdaptiveAnalog_Tl10_SL50_CG5_Lim_AL0_100) {
188#endif
peah57d5a2e2016-03-29 09:48:36 -0700189 const int kStreamAnalogLevelReference = 50;
190 const float kOutputReference[] = {-0.010162f, -0.009155f, -0.008301f};
191 RunBitExactnessTest(32000, 1, GainControl::Mode::kAdaptiveAnalog, 10, 50, 5,
192 true, 0, 100, kStreamAnalogLevelReference,
193 kOutputReference);
194}
195
peah51fbdd62016-03-30 14:58:32 -0700196#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
197 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700198TEST(GainControlBitExactnessTest,
peah57d5a2e2016-03-29 09:48:36 -0700199 Mono16kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700200#else
201TEST(GainControlBitExactnessTest,
202 DISABLED_Mono16kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) {
203#endif
peah57d5a2e2016-03-29 09:48:36 -0700204 const int kStreamAnalogLevelReference = 50;
peah12986c42016-10-22 02:38:32 -0700205 const float kOutputReference[] = {-0.003967f, -0.002777f, -0.001770f};
peah57d5a2e2016-03-29 09:48:36 -0700206 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveDigital, 10, 50, 5,
207 true, 0, 100, kStreamAnalogLevelReference,
208 kOutputReference);
209}
210
peah51fbdd62016-03-30 14:58:32 -0700211#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
212 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700213TEST(GainControlBitExactnessTest,
214 Stereo16kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700215#else
216TEST(GainControlBitExactnessTest,
217 DISABLED_Stereo16kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) {
218#endif
peah57d5a2e2016-03-29 09:48:36 -0700219 const int kStreamAnalogLevelReference = 50;
minyuefd634c42016-06-17 04:36:10 -0700220 const float kOutputReference[] = {-0.015411f, -0.008972f, -0.015839f,
221 -0.015411f, -0.008972f, -0.015839f};
peah57d5a2e2016-03-29 09:48:36 -0700222 RunBitExactnessTest(16000, 2, 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 Mono32kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700231#else
232TEST(GainControlBitExactnessTest,
233 DISABLED_Mono32kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) {
234#endif
peah57d5a2e2016-03-29 09:48:36 -0700235 const int kStreamAnalogLevelReference = 50;
Per Åhgren77dc1992019-11-23 00:14:31 +0100236 const float kOutputReference[] = {-0.006134f, -0.005524f, -0.005005f};
peah57d5a2e2016-03-29 09:48:36 -0700237 RunBitExactnessTest(32000, 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 Mono48kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700246#else
247TEST(GainControlBitExactnessTest,
248 DISABLED_Mono48kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) {
249#endif
peah57d5a2e2016-03-29 09:48:36 -0700250 const int kStreamAnalogLevelReference = 50;
Per Åhgren77dc1992019-11-23 00:14:31 +0100251 const float kOutputReference[] = {-0.006134f, -0.005524f, -0.005005};
peah57d5a2e2016-03-29 09:48:36 -0700252 RunBitExactnessTest(32000, 1, GainControl::Mode::kAdaptiveDigital, 10, 50, 5,
253 true, 0, 100, kStreamAnalogLevelReference,
254 kOutputReference);
255}
256
peah51fbdd62016-03-30 14:58:32 -0700257#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
258 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700259TEST(GainControlBitExactnessTest,
peah57d5a2e2016-03-29 09:48:36 -0700260 Mono16kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700261#else
262TEST(GainControlBitExactnessTest,
263 DISABLED_Mono16kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) {
264#endif
peah57d5a2e2016-03-29 09:48:36 -0700265 const int kStreamAnalogLevelReference = 50;
peah12986c42016-10-22 02:38:32 -0700266 const float kOutputReference[] = {-0.011749f, -0.008270f, -0.005219f};
peah57d5a2e2016-03-29 09:48:36 -0700267 RunBitExactnessTest(16000, 1, GainControl::Mode::kFixedDigital, 10, 50, 5,
268 true, 0, 100, kStreamAnalogLevelReference,
269 kOutputReference);
270}
271
peah51fbdd62016-03-30 14:58:32 -0700272#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
273 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700274TEST(GainControlBitExactnessTest,
275 Stereo16kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700276#else
277TEST(GainControlBitExactnessTest,
278 DISABLED_Stereo16kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) {
279#endif
peah57d5a2e2016-03-29 09:48:36 -0700280 const int kStreamAnalogLevelReference = 50;
Per Åhgren77dc1992019-11-23 00:14:31 +0100281 const float kOutputReference[] = {-0.048896f, -0.028479f, -0.050345f,
282 -0.048896f, -0.028479f, -0.050345f};
peah57d5a2e2016-03-29 09:48:36 -0700283 RunBitExactnessTest(16000, 2, GainControl::Mode::kFixedDigital, 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 Mono32kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700292#else
293TEST(GainControlBitExactnessTest,
294 DISABLED_Mono32kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) {
295#endif
peah57d5a2e2016-03-29 09:48:36 -0700296 const int kStreamAnalogLevelReference = 50;
Per Åhgren77dc1992019-11-23 00:14:31 +0100297 const float kOutputReference[] = {-0.018158f, -0.016357f, -0.014832f};
peah57d5a2e2016-03-29 09:48:36 -0700298 RunBitExactnessTest(32000, 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 Mono48kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700307#else
308TEST(GainControlBitExactnessTest,
309 DISABLED_Mono48kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) {
310#endif
peah57d5a2e2016-03-29 09:48:36 -0700311 const int kStreamAnalogLevelReference = 50;
Per Åhgren77dc1992019-11-23 00:14:31 +0100312 const float kOutputReference[] = {-0.018158f, -0.016357f, -0.014832f};
peah57d5a2e2016-03-29 09:48:36 -0700313 RunBitExactnessTest(32000, 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 Mono16kHz_AdaptiveAnalog_Tl10_SL10_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700322#else
323TEST(GainControlBitExactnessTest,
324 DISABLED_Mono16kHz_AdaptiveAnalog_Tl10_SL10_CG5_Lim_AL0_100) {
325#endif
peah57d5a2e2016-03-29 09:48:36 -0700326 const int kStreamAnalogLevelReference = 12;
327 const float kOutputReference[] = {-0.006561f, -0.004608f, -0.002899f};
328 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveAnalog, 10, 10, 5,
329 true, 0, 100, kStreamAnalogLevelReference,
330 kOutputReference);
331}
332
peah51fbdd62016-03-30 14:58:32 -0700333#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
334 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700335TEST(GainControlBitExactnessTest,
336 Mono16kHz_AdaptiveAnalog_Tl10_SL100_CG5_Lim_AL70_80) {
peah51fbdd62016-03-30 14:58:32 -0700337#else
338TEST(GainControlBitExactnessTest,
339 DISABLED_Mono16kHz_AdaptiveAnalog_Tl10_SL100_CG5_Lim_AL70_80) {
340#endif
peah57d5a2e2016-03-29 09:48:36 -0700341 const int kStreamAnalogLevelReference = 100;
peah12986c42016-10-22 02:38:32 -0700342 const float kOutputReference[] = {-0.003998f, -0.002808f, -0.001770f};
peah57d5a2e2016-03-29 09:48:36 -0700343 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveAnalog, 10, 100, 5,
344 true, 70, 80, kStreamAnalogLevelReference,
345 kOutputReference);
346}
347
peah51fbdd62016-03-30 14:58:32 -0700348#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
349 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700350TEST(GainControlBitExactnessTest,
351 Mono16kHz_AdaptiveDigital_Tl10_SL100_CG5_NoLim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700352#else
353TEST(GainControlBitExactnessTest,
354 DISABLED_Mono16kHz_AdaptiveDigital_Tl10_SL100_CG5_NoLim_AL0_100) {
355#endif
peah57d5a2e2016-03-29 09:48:36 -0700356 const int kStreamAnalogLevelReference = 100;
peah12986c42016-10-22 02:38:32 -0700357 const float kOutputReference[] = {-0.004028f, -0.002838f, -0.001770f};
peah57d5a2e2016-03-29 09:48:36 -0700358 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveDigital, 10, 100, 5,
359 false, 0, 100, kStreamAnalogLevelReference,
360 kOutputReference);
361}
362
peah51fbdd62016-03-30 14:58:32 -0700363#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
364 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700365TEST(GainControlBitExactnessTest,
366 Mono16kHz_AdaptiveDigital_Tl40_SL100_CG5_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700367#else
368TEST(GainControlBitExactnessTest,
369 DISABLED_Mono16kHz_AdaptiveDigital_Tl40_SL100_CG5_Lim_AL0_100) {
370#endif
peah57d5a2e2016-03-29 09:48:36 -0700371 const int kStreamAnalogLevelReference = 100;
peah12986c42016-10-22 02:38:32 -0700372 const float kOutputReference[] = {-0.008728f, -0.006134f, -0.003845f};
peah57d5a2e2016-03-29 09:48:36 -0700373 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveDigital, 40, 100, 5,
374 true, 0, 100, kStreamAnalogLevelReference,
375 kOutputReference);
376}
377
peah51fbdd62016-03-30 14:58:32 -0700378#if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
379 defined(WEBRTC_ANDROID))
peah57d5a2e2016-03-29 09:48:36 -0700380TEST(GainControlBitExactnessTest,
381 Mono16kHz_AdaptiveDigital_Tl10_SL100_CG30_Lim_AL0_100) {
peah51fbdd62016-03-30 14:58:32 -0700382#else
383TEST(GainControlBitExactnessTest,
384 DISABLED_Mono16kHz_AdaptiveDigital_Tl10_SL100_CG30_Lim_AL0_100) {
385#endif
peah57d5a2e2016-03-29 09:48:36 -0700386 const int kStreamAnalogLevelReference = 100;
peah12986c42016-10-22 02:38:32 -0700387 const float kOutputReference[] = {-0.005859f, -0.004120f, -0.002594f};
peah57d5a2e2016-03-29 09:48:36 -0700388 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveDigital, 10, 100,
389 30, true, 0, 100, kStreamAnalogLevelReference,
390 kOutputReference);
391}
392
393} // namespace webrtc