Chromium Code Reviews

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

Issue 3003733002: Utilizing the AEC3 config struct for constants. (Closed)
Patch Set: Added copy assignment Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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
(...skipping 22 matching lines...)
33 std::array<float, kBlockSize> x_old; 33 std::array<float, kBlockSize> x_old;
34 SubtractorOutput output; 34 SubtractorOutput output;
35 RenderBuffer render_buffer(Aec3Optimization::kNone, 3, kAdaptiveFilterLength, 35 RenderBuffer render_buffer(Aec3Optimization::kNone, 3, kAdaptiveFilterLength,
36 std::vector<size_t>(1, kAdaptiveFilterLength)); 36 std::vector<size_t>(1, kAdaptiveFilterLength));
37 RenderSignalAnalyzer render_signal_analyzer; 37 RenderSignalAnalyzer render_signal_analyzer;
38 Random random_generator(42U); 38 Random random_generator(42U);
39 Aec3Fft fft; 39 Aec3Fft fft;
40 std::array<float, kFftLengthBy2Plus1> Y2; 40 std::array<float, kFftLengthBy2Plus1> Y2;
41 std::array<float, kFftLengthBy2Plus1> E2_main; 41 std::array<float, kFftLengthBy2Plus1> E2_main;
42 std::array<float, kFftLengthBy2Plus1> E2_shadow; 42 std::array<float, kFftLengthBy2Plus1> E2_shadow;
43 AecState aec_state(0.f); 43 AecState aec_state(AudioProcessing::Config::EchoCanceller3{});
44 x_old.fill(0.f); 44 x_old.fill(0.f);
45 Y2.fill(0.f); 45 Y2.fill(0.f);
46 E2_main.fill(0.f); 46 E2_main.fill(0.f);
47 E2_shadow.fill(0.f); 47 E2_shadow.fill(0.f);
48 48
49 DelayBuffer<float> delay_buffer(delay_samples); 49 DelayBuffer<float> delay_buffer(delay_samples);
50 for (int k = 0; k < num_blocks_to_process; ++k) { 50 for (int k = 0; k < num_blocks_to_process; ++k) {
51 RandomizeSampleVector(&random_generator, x[0]); 51 RandomizeSampleVector(&random_generator, x[0]);
52 if (uncorrelated_inputs) { 52 if (uncorrelated_inputs) {
53 RandomizeSampleVector(&random_generator, y); 53 RandomizeSampleVector(&random_generator, y);
(...skipping 48 matching lines...)
102 // TODO(peah): Re-enable the test once the issue with memory leaks during DEATH 102 // TODO(peah): Re-enable the test once the issue with memory leaks during DEATH
103 // tests on test bots has been fixed. 103 // tests on test bots has been fixed.
104 TEST(Subtractor, DISABLED_NullOutput) { 104 TEST(Subtractor, DISABLED_NullOutput) {
105 ApmDataDumper data_dumper(42); 105 ApmDataDumper data_dumper(42);
106 Subtractor subtractor(&data_dumper, DetectOptimization()); 106 Subtractor subtractor(&data_dumper, DetectOptimization());
107 RenderBuffer render_buffer(Aec3Optimization::kNone, 3, kAdaptiveFilterLength, 107 RenderBuffer render_buffer(Aec3Optimization::kNone, 3, kAdaptiveFilterLength,
108 std::vector<size_t>(1, kAdaptiveFilterLength)); 108 std::vector<size_t>(1, kAdaptiveFilterLength));
109 RenderSignalAnalyzer render_signal_analyzer; 109 RenderSignalAnalyzer render_signal_analyzer;
110 std::vector<float> y(kBlockSize, 0.f); 110 std::vector<float> y(kBlockSize, 0.f);
111 111
112 EXPECT_DEATH(subtractor.Process(render_buffer, y, render_signal_analyzer, 112 EXPECT_DEATH(
113 AecState(0.f), nullptr), 113 subtractor.Process(render_buffer, y, render_signal_analyzer,
114 ""); 114 AecState(AudioProcessing::Config::EchoCanceller3{}),
115 nullptr),
116 "");
115 } 117 }
116 118
117 // Verifies the check for the capture signal size. 119 // Verifies the check for the capture signal size.
118 TEST(Subtractor, WrongCaptureSize) { 120 TEST(Subtractor, WrongCaptureSize) {
119 ApmDataDumper data_dumper(42); 121 ApmDataDumper data_dumper(42);
120 Subtractor subtractor(&data_dumper, DetectOptimization()); 122 Subtractor subtractor(&data_dumper, DetectOptimization());
121 RenderBuffer render_buffer(Aec3Optimization::kNone, 3, kAdaptiveFilterLength, 123 RenderBuffer render_buffer(Aec3Optimization::kNone, 3, kAdaptiveFilterLength,
122 std::vector<size_t>(1, kAdaptiveFilterLength)); 124 std::vector<size_t>(1, kAdaptiveFilterLength));
123 RenderSignalAnalyzer render_signal_analyzer; 125 RenderSignalAnalyzer render_signal_analyzer;
124 std::vector<float> y(kBlockSize - 1, 0.f); 126 std::vector<float> y(kBlockSize - 1, 0.f);
125 SubtractorOutput output; 127 SubtractorOutput output;
126 128
127 EXPECT_DEATH(subtractor.Process(render_buffer, y, render_signal_analyzer, 129 EXPECT_DEATH(
128 AecState(0.f), &output), 130 subtractor.Process(render_buffer, y, render_signal_analyzer,
129 ""); 131 AecState(AudioProcessing::Config::EchoCanceller3{}),
132 &output),
133 "");
130 } 134 }
131 135
132 #endif 136 #endif
133 137
134 // Verifies that the subtractor is able to converge on correlated data. 138 // Verifies that the subtractor is able to converge on correlated data.
135 TEST(Subtractor, Convergence) { 139 TEST(Subtractor, Convergence) {
136 std::vector<int> blocks_with_echo_path_changes; 140 std::vector<int> blocks_with_echo_path_changes;
137 for (size_t delay_samples : {0, 64, 150, 200, 301}) { 141 for (size_t delay_samples : {0, 64, 150, 200, 301}) {
138 SCOPED_TRACE(ProduceDebugText(delay_samples)); 142 SCOPED_TRACE(ProduceDebugText(delay_samples));
139 143
(...skipping 23 matching lines...)
163 for (size_t delay_samples : {0, 64, 150, 200, 301}) { 167 for (size_t delay_samples : {0, 64, 150, 200, 301}) {
164 SCOPED_TRACE(ProduceDebugText(delay_samples)); 168 SCOPED_TRACE(ProduceDebugText(delay_samples));
165 169
166 float echo_to_nearend_power = RunSubtractorTest( 170 float echo_to_nearend_power = RunSubtractorTest(
167 100, delay_samples, false, blocks_with_echo_path_changes); 171 100, delay_samples, false, blocks_with_echo_path_changes);
168 EXPECT_NEAR(1.f, echo_to_nearend_power, 0.0000001f); 172 EXPECT_NEAR(1.f, echo_to_nearend_power, 0.0000001f);
169 } 173 }
170 } 174 }
171 175
172 } // namespace webrtc 176 } // namespace webrtc
OLDNEW

Powered by Google App Engine