OLD | NEW |
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...) Expand all Loading... |
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; | 43 AecState aec_state(0.f); |
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...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // tests on test bots has been fixed. | 102 // tests on test bots has been fixed. |
103 TEST(Subtractor, DISABLED_NullOutput) { | 103 TEST(Subtractor, DISABLED_NullOutput) { |
104 ApmDataDumper data_dumper(42); | 104 ApmDataDumper data_dumper(42); |
105 Subtractor subtractor(&data_dumper, DetectOptimization()); | 105 Subtractor subtractor(&data_dumper, DetectOptimization()); |
106 RenderBuffer render_buffer(Aec3Optimization::kNone, 3, kAdaptiveFilterLength, | 106 RenderBuffer render_buffer(Aec3Optimization::kNone, 3, kAdaptiveFilterLength, |
107 std::vector<size_t>(1, kAdaptiveFilterLength)); | 107 std::vector<size_t>(1, kAdaptiveFilterLength)); |
108 RenderSignalAnalyzer render_signal_analyzer; | 108 RenderSignalAnalyzer render_signal_analyzer; |
109 std::vector<float> y(kBlockSize, 0.f); | 109 std::vector<float> y(kBlockSize, 0.f); |
110 | 110 |
111 EXPECT_DEATH(subtractor.Process(render_buffer, y, render_signal_analyzer, | 111 EXPECT_DEATH(subtractor.Process(render_buffer, y, render_signal_analyzer, |
112 AecState(), nullptr), | 112 AecState(0.f), nullptr), |
113 ""); | 113 ""); |
114 } | 114 } |
115 | 115 |
116 // Verifies the check for the capture signal size. | 116 // Verifies the check for the capture signal size. |
117 TEST(Subtractor, WrongCaptureSize) { | 117 TEST(Subtractor, WrongCaptureSize) { |
118 ApmDataDumper data_dumper(42); | 118 ApmDataDumper data_dumper(42); |
119 Subtractor subtractor(&data_dumper, DetectOptimization()); | 119 Subtractor subtractor(&data_dumper, DetectOptimization()); |
120 RenderBuffer render_buffer(Aec3Optimization::kNone, 3, kAdaptiveFilterLength, | 120 RenderBuffer render_buffer(Aec3Optimization::kNone, 3, kAdaptiveFilterLength, |
121 std::vector<size_t>(1, kAdaptiveFilterLength)); | 121 std::vector<size_t>(1, kAdaptiveFilterLength)); |
122 RenderSignalAnalyzer render_signal_analyzer; | 122 RenderSignalAnalyzer render_signal_analyzer; |
123 std::vector<float> y(kBlockSize - 1, 0.f); | 123 std::vector<float> y(kBlockSize - 1, 0.f); |
124 SubtractorOutput output; | 124 SubtractorOutput output; |
125 | 125 |
126 EXPECT_DEATH(subtractor.Process(render_buffer, y, render_signal_analyzer, | 126 EXPECT_DEATH(subtractor.Process(render_buffer, y, render_signal_analyzer, |
127 AecState(), &output), | 127 AecState(0.f), &output), |
128 ""); | 128 ""); |
129 } | 129 } |
130 | 130 |
131 #endif | 131 #endif |
132 | 132 |
133 // Verifies that the subtractor is able to converge on correlated data. | 133 // Verifies that the subtractor is able to converge on correlated data. |
134 TEST(Subtractor, Convergence) { | 134 TEST(Subtractor, Convergence) { |
135 std::vector<int> blocks_with_echo_path_changes; | 135 std::vector<int> blocks_with_echo_path_changes; |
136 for (size_t delay_samples : {0, 64, 150, 200, 301}) { | 136 for (size_t delay_samples : {0, 64, 150, 200, 301}) { |
137 SCOPED_TRACE(ProduceDebugText(delay_samples)); | 137 SCOPED_TRACE(ProduceDebugText(delay_samples)); |
(...skipping 24 matching lines...) Expand all Loading... |
162 for (size_t delay_samples : {0, 64, 150, 200, 301}) { | 162 for (size_t delay_samples : {0, 64, 150, 200, 301}) { |
163 SCOPED_TRACE(ProduceDebugText(delay_samples)); | 163 SCOPED_TRACE(ProduceDebugText(delay_samples)); |
164 | 164 |
165 float echo_to_nearend_power = RunSubtractorTest( | 165 float echo_to_nearend_power = RunSubtractorTest( |
166 100, delay_samples, false, blocks_with_echo_path_changes); | 166 100, delay_samples, false, blocks_with_echo_path_changes); |
167 EXPECT_NEAR(1.f, echo_to_nearend_power, 0.0000001f); | 167 EXPECT_NEAR(1.f, echo_to_nearend_power, 0.0000001f); |
168 } | 168 } |
169 } | 169 } |
170 | 170 |
171 } // namespace webrtc | 171 } // namespace webrtc |
OLD | NEW |