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

Side by Side Diff: webrtc/modules/audio_processing/aec3/aec_state_unittest.cc

Issue 2967603002: Added the ability to adjust the AEC3 performance for large rooms (Closed)
Patch Set: Changes in response to reviewer commments Created 3 years, 5 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) 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 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 "webrtc/modules/audio_processing/aec3/aec_state.h" 11 #include "webrtc/modules/audio_processing/aec3/aec_state.h"
12 12
13 #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h" 13 #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h"
14 #include "webrtc/test/gtest.h" 14 #include "webrtc/test/gtest.h"
15 15
16 namespace webrtc { 16 namespace webrtc {
17 17
18 // Verify the general functionality of AecState 18 // Verify the general functionality of AecState
19 TEST(AecState, NormalUsage) { 19 TEST(AecState, NormalUsage) {
20 ApmDataDumper data_dumper(42); 20 ApmDataDumper data_dumper(42);
21 AecState state; 21 AecState state(0.f);
22 RenderBuffer render_buffer(Aec3Optimization::kNone, 3, 30, 22 RenderBuffer render_buffer(Aec3Optimization::kNone, 3, 30,
23 std::vector<size_t>(1, 30)); 23 std::vector<size_t>(1, 30));
24 std::array<float, kFftLengthBy2Plus1> E2_main = {}; 24 std::array<float, kFftLengthBy2Plus1> E2_main = {};
25 std::array<float, kFftLengthBy2Plus1> Y2 = {}; 25 std::array<float, kFftLengthBy2Plus1> Y2 = {};
26 std::vector<std::vector<float>> x(3, std::vector<float>(kBlockSize, 0.f)); 26 std::vector<std::vector<float>> x(3, std::vector<float>(kBlockSize, 0.f));
27 EchoPathVariability echo_path_variability(false, false); 27 EchoPathVariability echo_path_variability(false, false);
28 28
29 std::vector<std::array<float, kFftLengthBy2Plus1>> 29 std::vector<std::array<float, kFftLengthBy2Plus1>>
30 converged_filter_frequency_response(10); 30 converged_filter_frequency_response(10);
31 for (auto& v : converged_filter_frequency_response) { 31 for (auto& v : converged_filter_frequency_response) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 141 }
142 for (size_t k = kLowFrequencyLimit; k < erle.size() - 1; ++k) { 142 for (size_t k = kLowFrequencyLimit; k < erle.size() - 1; ++k) {
143 EXPECT_NEAR(k % 2 == 0 ? 1.5f : 1.f, erle[k], 0.1); 143 EXPECT_NEAR(k % 2 == 0 ? 1.5f : 1.f, erle[k], 0.1);
144 } 144 }
145 EXPECT_EQ(erle[erle.size() - 2], erle[erle.size() - 1]); 145 EXPECT_EQ(erle[erle.size() - 2], erle[erle.size() - 1]);
146 } 146 }
147 } 147 }
148 148
149 // Verifies the a non-significant delay is correctly identified. 149 // Verifies the a non-significant delay is correctly identified.
150 TEST(AecState, NonSignificantDelay) { 150 TEST(AecState, NonSignificantDelay) {
151 AecState state; 151 AecState state(0.f);
152 RenderBuffer render_buffer(Aec3Optimization::kNone, 3, 30, 152 RenderBuffer render_buffer(Aec3Optimization::kNone, 3, 30,
153 std::vector<size_t>(1, 30)); 153 std::vector<size_t>(1, 30));
154 std::array<float, kFftLengthBy2Plus1> E2_main; 154 std::array<float, kFftLengthBy2Plus1> E2_main;
155 std::array<float, kFftLengthBy2Plus1> Y2; 155 std::array<float, kFftLengthBy2Plus1> Y2;
156 std::array<float, kBlockSize> x; 156 std::array<float, kBlockSize> x;
157 EchoPathVariability echo_path_variability(false, false); 157 EchoPathVariability echo_path_variability(false, false);
158 x.fill(0.f); 158 x.fill(0.f);
159 159
160 std::vector<std::array<float, kFftLengthBy2Plus1>> frequency_response(30); 160 std::vector<std::array<float, kFftLengthBy2Plus1>> frequency_response(30);
161 for (auto& v : frequency_response) { 161 for (auto& v : frequency_response) {
162 v.fill(0.01f); 162 v.fill(0.01f);
163 } 163 }
164 164
165 // Verify that a non-significant filter delay is identified correctly. 165 // Verify that a non-significant filter delay is identified correctly.
166 state.HandleEchoPathChange(echo_path_variability); 166 state.HandleEchoPathChange(echo_path_variability);
167 state.Update(frequency_response, rtc::Optional<size_t>(), render_buffer, 167 state.Update(frequency_response, rtc::Optional<size_t>(), render_buffer,
168 E2_main, Y2, x, false); 168 E2_main, Y2, x, false);
169 EXPECT_FALSE(state.FilterDelay()); 169 EXPECT_FALSE(state.FilterDelay());
170 } 170 }
171 171
172 // Verifies the delay for a converged filter is correctly identified. 172 // Verifies the delay for a converged filter is correctly identified.
173 TEST(AecState, ConvergedFilterDelay) { 173 TEST(AecState, ConvergedFilterDelay) {
174 constexpr int kFilterLength = 10; 174 constexpr int kFilterLength = 10;
175 AecState state; 175 AecState state(0.f);
176 RenderBuffer render_buffer(Aec3Optimization::kNone, 3, 30, 176 RenderBuffer render_buffer(Aec3Optimization::kNone, 3, 30,
177 std::vector<size_t>(1, 30)); 177 std::vector<size_t>(1, 30));
178 std::array<float, kFftLengthBy2Plus1> E2_main; 178 std::array<float, kFftLengthBy2Plus1> E2_main;
179 std::array<float, kFftLengthBy2Plus1> Y2; 179 std::array<float, kFftLengthBy2Plus1> Y2;
180 std::array<float, kBlockSize> x; 180 std::array<float, kBlockSize> x;
181 EchoPathVariability echo_path_variability(false, false); 181 EchoPathVariability echo_path_variability(false, false);
182 x.fill(0.f); 182 x.fill(0.f);
183 183
184 std::vector<std::array<float, kFftLengthBy2Plus1>> frequency_response( 184 std::vector<std::array<float, kFftLengthBy2Plus1>> frequency_response(
185 kFilterLength); 185 kFilterLength);
(...skipping 10 matching lines...) Expand all
196 E2_main, Y2, x, false); 196 E2_main, Y2, x, false);
197 EXPECT_TRUE(k == (kFilterLength - 1) || state.FilterDelay()); 197 EXPECT_TRUE(k == (kFilterLength - 1) || state.FilterDelay());
198 if (k != (kFilterLength - 1)) { 198 if (k != (kFilterLength - 1)) {
199 EXPECT_EQ(k, state.FilterDelay()); 199 EXPECT_EQ(k, state.FilterDelay());
200 } 200 }
201 } 201 }
202 } 202 }
203 203
204 // Verify that the externally reported delay is properly reported and converted. 204 // Verify that the externally reported delay is properly reported and converted.
205 TEST(AecState, ExternalDelay) { 205 TEST(AecState, ExternalDelay) {
206 AecState state; 206 AecState state(0.f);
207 std::array<float, kFftLengthBy2Plus1> E2_main; 207 std::array<float, kFftLengthBy2Plus1> E2_main;
208 std::array<float, kFftLengthBy2Plus1> E2_shadow; 208 std::array<float, kFftLengthBy2Plus1> E2_shadow;
209 std::array<float, kFftLengthBy2Plus1> Y2; 209 std::array<float, kFftLengthBy2Plus1> Y2;
210 std::array<float, kBlockSize> x; 210 std::array<float, kBlockSize> x;
211 E2_main.fill(0.f); 211 E2_main.fill(0.f);
212 E2_shadow.fill(0.f); 212 E2_shadow.fill(0.f);
213 Y2.fill(0.f); 213 Y2.fill(0.f);
214 x.fill(0.f); 214 x.fill(0.f);
215 RenderBuffer render_buffer(Aec3Optimization::kNone, 3, 30, 215 RenderBuffer render_buffer(Aec3Optimization::kNone, 3, 30,
216 std::vector<size_t>(1, 30)); 216 std::vector<size_t>(1, 30));
(...skipping 12 matching lines...) Expand all
229 229
230 // Verify that the externally reported delay is properly unset when it is no 230 // Verify that the externally reported delay is properly unset when it is no
231 // longer present. 231 // longer present.
232 state.HandleEchoPathChange(EchoPathVariability(false, false)); 232 state.HandleEchoPathChange(EchoPathVariability(false, false));
233 state.Update(frequency_response, rtc::Optional<size_t>(), render_buffer, 233 state.Update(frequency_response, rtc::Optional<size_t>(), render_buffer,
234 E2_main, Y2, x, false); 234 E2_main, Y2, x, false);
235 EXPECT_FALSE(state.ExternalDelay()); 235 EXPECT_FALSE(state.ExternalDelay());
236 } 236 }
237 237
238 } // namespace webrtc 238 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/aec3/aec_state.cc ('k') | webrtc/modules/audio_processing/aec3/block_processor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698