Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: webrtc/modules/audio_processing/level_controller/level_controller_unittest.cc

Issue 2337083002: Reland of added functionality for specifying the initial signal level to use for the gain estimation (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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) {
36 level_controller.SetInitialLevel(*initial_level);
the sun 2016/09/14 10:00:59 Why not use ApplyConfig?
peah-webrtc 2016/09/16 07:11:07 Done.
37 }
33 38
34 int samples_per_channel = rtc::CheckedDivExact(sample_rate_hz, 100); 39 int samples_per_channel = rtc::CheckedDivExact(sample_rate_hz, 100);
35 const StreamConfig capture_config(sample_rate_hz, num_channels, false); 40 const StreamConfig capture_config(sample_rate_hz, num_channels, false);
36 AudioBuffer capture_buffer( 41 AudioBuffer capture_buffer(
37 capture_config.num_frames(), capture_config.num_channels(), 42 capture_config.num_frames(), capture_config.num_channels(),
38 capture_config.num_frames(), capture_config.num_channels(), 43 capture_config.num_frames(), capture_config.num_channels(),
39 capture_config.num_frames()); 44 capture_config.num_frames());
40 test::InputAudioFile capture_file( 45 test::InputAudioFile capture_file(
41 test::GetApmCaptureTestVectorFileName(sample_rate_hz)); 46 test::GetApmCaptureTestVectorFileName(sample_rate_hz));
42 std::vector<float> capture_input(samples_per_channel * num_channels); 47 std::vector<float> capture_input(samples_per_channel * num_channels);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 88 }
84 89
85 TEST(LevelControlConfigTest, DefaultValue) { 90 TEST(LevelControlConfigTest, DefaultValue) {
86 AudioProcessing::Config config; 91 AudioProcessing::Config config;
87 EXPECT_FALSE(config.level_controller.enabled); 92 EXPECT_FALSE(config.level_controller.enabled);
88 } 93 }
89 94
90 TEST(LevelControlBitExactnessTest, DISABLED_Mono8kHz) { 95 TEST(LevelControlBitExactnessTest, DISABLED_Mono8kHz) {
91 const float kOutputReference[] = {-0.013939f, -0.012154f, -0.009054f}; 96 const float kOutputReference[] = {-0.013939f, -0.012154f, -0.009054f};
92 RunBitexactnessTest(AudioProcessing::kSampleRate8kHz, 1, 97 RunBitexactnessTest(AudioProcessing::kSampleRate8kHz, 1,
93 kOutputReference); 98 rtc::Optional<float>(), kOutputReference);
94 } 99 }
95 100
96 TEST(LevelControlBitExactnessTest, DISABLED_Mono16kHz) { 101 TEST(LevelControlBitExactnessTest, DISABLED_Mono16kHz) {
97 const float kOutputReference[] = {-0.013706f, -0.013215f, -0.013018f}; 102 const float kOutputReference[] = {-0.013706f, -0.013215f, -0.013018f};
98 RunBitexactnessTest(AudioProcessing::kSampleRate16kHz, 1, 103 RunBitexactnessTest(AudioProcessing::kSampleRate16kHz, 1,
99 kOutputReference); 104 rtc::Optional<float>(), kOutputReference);
100 } 105 }
101 106
102 TEST(LevelControlBitExactnessTest, DISABLED_Mono32kHz) { 107 TEST(LevelControlBitExactnessTest, DISABLED_Mono32kHz) {
103 const float kOutputReference[] = {-0.014495f, -0.016425f, -0.016085f}; 108 const float kOutputReference[] = {-0.014495f, -0.016425f, -0.016085f};
104 RunBitexactnessTest(AudioProcessing::kSampleRate32kHz, 1, 109 RunBitexactnessTest(AudioProcessing::kSampleRate32kHz, 1,
105 kOutputReference); 110 rtc::Optional<float>(), kOutputReference);
106 } 111 }
107 112
108 // TODO(peah): Investigate why this particular testcase differ between Android 113 // TODO(peah): Investigate why this particular testcase differ between Android
109 // and the rest of the platforms. 114 // and the rest of the platforms.
110 TEST(LevelControlBitExactnessTest, DISABLED_Mono48kHz) { 115 TEST(LevelControlBitExactnessTest, DISABLED_Mono48kHz) {
111 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ 116 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \
112 defined(WEBRTC_ANDROID)) 117 defined(WEBRTC_ANDROID))
113 const float kOutputReference[] = {-0.014277f, -0.015180f, -0.017437f}; 118 const float kOutputReference[] = {-0.014277f, -0.015180f, -0.017437f};
114 #else 119 #else
115 const float kOutputReference[] = {-0.015949f, -0.016957f, -0.019478f}; 120 const float kOutputReference[] = {-0.015949f, -0.016957f, -0.019478f};
116 #endif 121 #endif
117 RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 1, 122 RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 1,
118 kOutputReference); 123 rtc::Optional<float>(), kOutputReference);
119 } 124 }
120 125
121 TEST(LevelControlBitExactnessTest, DISABLED_Stereo8kHz) { 126 TEST(LevelControlBitExactnessTest, DISABLED_Stereo8kHz) {
122 const float kOutputReference[] = {-0.014063f, -0.008450f, -0.012159f, 127 const float kOutputReference[] = {-0.014063f, -0.008450f, -0.012159f,
123 -0.051967f, -0.023202f, -0.047858f}; 128 -0.051967f, -0.023202f, -0.047858f};
124 RunBitexactnessTest(AudioProcessing::kSampleRate8kHz, 2, 129 RunBitexactnessTest(AudioProcessing::kSampleRate8kHz, 2,
125 kOutputReference); 130 rtc::Optional<float>(), kOutputReference);
126 } 131 }
127 132
128 TEST(LevelControlBitExactnessTest, DISABLED_Stereo16kHz) { 133 TEST(LevelControlBitExactnessTest, DISABLED_Stereo16kHz) {
129 const float kOutputReference[] = {-0.012714f, -0.005896f, -0.012220f, 134 const float kOutputReference[] = {-0.012714f, -0.005896f, -0.012220f,
130 -0.053306f, -0.024549f, -0.051527f}; 135 -0.053306f, -0.024549f, -0.051527f};
131 RunBitexactnessTest(AudioProcessing::kSampleRate16kHz, 2, 136 RunBitexactnessTest(AudioProcessing::kSampleRate16kHz, 2,
132 kOutputReference); 137 rtc::Optional<float>(), kOutputReference);
133 } 138 }
134 139
135 TEST(LevelControlBitExactnessTest, DISABLED_Stereo32kHz) { 140 TEST(LevelControlBitExactnessTest, DISABLED_Stereo32kHz) {
136 const float kOutputReference[] = {-0.011737f, -0.007018f, -0.013446f, 141 const float kOutputReference[] = {-0.011737f, -0.007018f, -0.013446f,
137 -0.053505f, -0.026292f, -0.056221f}; 142 -0.053505f, -0.026292f, -0.056221f};
138 RunBitexactnessTest(AudioProcessing::kSampleRate32kHz, 2, 143 RunBitexactnessTest(AudioProcessing::kSampleRate32kHz, 2,
139 kOutputReference); 144 rtc::Optional<float>(), kOutputReference);
140 } 145 }
141 146
142 TEST(LevelControlBitExactnessTest, DISABLED_Stereo48kHz) { 147 TEST(LevelControlBitExactnessTest, DISABLED_Stereo48kHz) {
143 const float kOutputReference[] = {-0.010643f, -0.006334f, -0.011377f, 148 const float kOutputReference[] = {-0.010643f, -0.006334f, -0.011377f,
144 -0.049088f, -0.023600f, -0.050465f}; 149 -0.049088f, -0.023600f, -0.050465f};
145 RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 2, 150 RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 2,
146 kOutputReference); 151 rtc::Optional<float>(), kOutputReference);
152 }
153
154 TEST(LevelControlBitExactnessTest, DISABLED_MonoInitial48kHz) {
155 const float kOutputReference[] = {-0.013753f, -0.014623f, -0.016797f};
156 RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 1,
157 rtc::Optional<float>(2000), kOutputReference);
147 } 158 }
148 159
149 160
150 161
151 } // namespace webrtc 162 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698