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

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

Issue 3007833002: Further utilizing the AEC3 config struct for constants (Closed)
Patch Set: Created 3 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) 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 19 matching lines...) Expand all
30 return ss.str(); 30 return ss.str();
31 } 31 }
32 32
33 } // namespace 33 } // namespace
34 34
35 // Verifies that the basic API calls work. 35 // Verifies that the basic API calls work.
36 TEST(EchoPathDelayEstimator, BasicApiCalls) { 36 TEST(EchoPathDelayEstimator, BasicApiCalls) {
37 ApmDataDumper data_dumper(0); 37 ApmDataDumper data_dumper(0);
38 std::unique_ptr<RenderDelayBuffer> render_delay_buffer( 38 std::unique_ptr<RenderDelayBuffer> render_delay_buffer(
39 RenderDelayBuffer::Create(3)); 39 RenderDelayBuffer::Create(3));
40 EchoPathDelayEstimator estimator(&data_dumper); 40 EchoPathDelayEstimator estimator(&data_dumper,
41 AudioProcessing::Config::EchoCanceller3());
41 std::vector<std::vector<float>> render(3, std::vector<float>(kBlockSize)); 42 std::vector<std::vector<float>> render(3, std::vector<float>(kBlockSize));
42 std::vector<float> capture(kBlockSize); 43 std::vector<float> capture(kBlockSize);
43 for (size_t k = 0; k < 100; ++k) { 44 for (size_t k = 0; k < 100; ++k) {
44 render_delay_buffer->Insert(render); 45 render_delay_buffer->Insert(render);
45 estimator.EstimateDelay(render_delay_buffer->GetDownsampledRenderBuffer(), 46 estimator.EstimateDelay(render_delay_buffer->GetDownsampledRenderBuffer(),
46 capture); 47 capture);
47 } 48 }
48 } 49 }
49 50
50 // Verifies that the delay estimator produces correct delay for artificially 51 // Verifies that the delay estimator produces correct delay for artificially
51 // delayed signals. 52 // delayed signals.
52 TEST(EchoPathDelayEstimator, DelayEstimation) { 53 TEST(EchoPathDelayEstimator, DelayEstimation) {
53 Random random_generator(42U); 54 Random random_generator(42U);
54 std::vector<std::vector<float>> render(3, std::vector<float>(kBlockSize)); 55 std::vector<std::vector<float>> render(3, std::vector<float>(kBlockSize));
55 std::vector<float> capture(kBlockSize); 56 std::vector<float> capture(kBlockSize);
56 ApmDataDumper data_dumper(0); 57 ApmDataDumper data_dumper(0);
57 for (size_t delay_samples : {15, 64, 150, 200, 800, 4000}) { 58 for (size_t delay_samples : {15, 64, 150, 200, 800, 4000}) {
58 SCOPED_TRACE(ProduceDebugText(delay_samples)); 59 SCOPED_TRACE(ProduceDebugText(delay_samples));
59 std::unique_ptr<RenderDelayBuffer> render_delay_buffer( 60 std::unique_ptr<RenderDelayBuffer> render_delay_buffer(
60 RenderDelayBuffer::Create(3)); 61 RenderDelayBuffer::Create(3));
61 DelayBuffer<float> signal_delay_buffer(delay_samples); 62 DelayBuffer<float> signal_delay_buffer(delay_samples);
62 EchoPathDelayEstimator estimator(&data_dumper); 63 EchoPathDelayEstimator estimator(&data_dumper,
64 AudioProcessing::Config::EchoCanceller3());
63 65
64 rtc::Optional<size_t> estimated_delay_samples; 66 rtc::Optional<size_t> estimated_delay_samples;
65 for (size_t k = 0; k < (100 + delay_samples / kBlockSize); ++k) { 67 for (size_t k = 0; k < (100 + delay_samples / kBlockSize); ++k) {
66 RandomizeSampleVector(&random_generator, render[0]); 68 RandomizeSampleVector(&random_generator, render[0]);
67 signal_delay_buffer.Delay(render[0], capture); 69 signal_delay_buffer.Delay(render[0], capture);
68 render_delay_buffer->Insert(render); 70 render_delay_buffer->Insert(render);
69 render_delay_buffer->UpdateBuffers(); 71 render_delay_buffer->UpdateBuffers();
70 estimated_delay_samples = estimator.EstimateDelay( 72 estimated_delay_samples = estimator.EstimateDelay(
71 render_delay_buffer->GetDownsampledRenderBuffer(), capture); 73 render_delay_buffer->GetDownsampledRenderBuffer(), capture);
72 } 74 }
(...skipping 11 matching lines...) Expand all
84 // Verifies that the delay estimator does not produce delay estimates too 86 // Verifies that the delay estimator does not produce delay estimates too
85 // quickly. 87 // quickly.
86 TEST(EchoPathDelayEstimator, NoInitialDelayestimates) { 88 TEST(EchoPathDelayEstimator, NoInitialDelayestimates) {
87 Random random_generator(42U); 89 Random random_generator(42U);
88 std::vector<std::vector<float>> render(3, std::vector<float>(kBlockSize)); 90 std::vector<std::vector<float>> render(3, std::vector<float>(kBlockSize));
89 std::vector<float> capture(kBlockSize); 91 std::vector<float> capture(kBlockSize);
90 ApmDataDumper data_dumper(0); 92 ApmDataDumper data_dumper(0);
91 std::unique_ptr<RenderDelayBuffer> render_delay_buffer( 93 std::unique_ptr<RenderDelayBuffer> render_delay_buffer(
92 RenderDelayBuffer::Create(3)); 94 RenderDelayBuffer::Create(3));
93 95
94 EchoPathDelayEstimator estimator(&data_dumper); 96 EchoPathDelayEstimator estimator(&data_dumper,
97 AudioProcessing::Config::EchoCanceller3());
95 for (size_t k = 0; k < 19; ++k) { 98 for (size_t k = 0; k < 19; ++k) {
96 RandomizeSampleVector(&random_generator, render[0]); 99 RandomizeSampleVector(&random_generator, render[0]);
97 std::copy(render[0].begin(), render[0].end(), capture.begin()); 100 std::copy(render[0].begin(), render[0].end(), capture.begin());
98 render_delay_buffer->Insert(render); 101 render_delay_buffer->Insert(render);
99 render_delay_buffer->UpdateBuffers(); 102 render_delay_buffer->UpdateBuffers();
100 EXPECT_FALSE(estimator.EstimateDelay( 103 EXPECT_FALSE(estimator.EstimateDelay(
101 render_delay_buffer->GetDownsampledRenderBuffer(), capture)); 104 render_delay_buffer->GetDownsampledRenderBuffer(), capture));
102 } 105 }
103 } 106 }
104 107
105 // Verifies that the delay estimator does not produce delay estimates for render 108 // Verifies that the delay estimator does not produce delay estimates for render
106 // signals of low level. 109 // signals of low level.
107 TEST(EchoPathDelayEstimator, NoDelayEstimatesForLowLevelRenderSignals) { 110 TEST(EchoPathDelayEstimator, NoDelayEstimatesForLowLevelRenderSignals) {
108 Random random_generator(42U); 111 Random random_generator(42U);
109 std::vector<std::vector<float>> render(3, std::vector<float>(kBlockSize)); 112 std::vector<std::vector<float>> render(3, std::vector<float>(kBlockSize));
110 std::vector<float> capture(kBlockSize); 113 std::vector<float> capture(kBlockSize);
111 ApmDataDumper data_dumper(0); 114 ApmDataDumper data_dumper(0);
112 EchoPathDelayEstimator estimator(&data_dumper); 115 EchoPathDelayEstimator estimator(&data_dumper,
116 AudioProcessing::Config::EchoCanceller3());
113 std::unique_ptr<RenderDelayBuffer> render_delay_buffer( 117 std::unique_ptr<RenderDelayBuffer> render_delay_buffer(
114 RenderDelayBuffer::Create(3)); 118 RenderDelayBuffer::Create(3));
115 for (size_t k = 0; k < 100; ++k) { 119 for (size_t k = 0; k < 100; ++k) {
116 RandomizeSampleVector(&random_generator, render[0]); 120 RandomizeSampleVector(&random_generator, render[0]);
117 for (auto& render_k : render[0]) { 121 for (auto& render_k : render[0]) {
118 render_k *= 100.f / 32767.f; 122 render_k *= 100.f / 32767.f;
119 } 123 }
120 std::copy(render[0].begin(), render[0].end(), capture.begin()); 124 std::copy(render[0].begin(), render[0].end(), capture.begin());
121 render_delay_buffer->Insert(render); 125 render_delay_buffer->Insert(render);
122 render_delay_buffer->UpdateBuffers(); 126 render_delay_buffer->UpdateBuffers();
123 EXPECT_FALSE(estimator.EstimateDelay( 127 EXPECT_FALSE(estimator.EstimateDelay(
124 render_delay_buffer->GetDownsampledRenderBuffer(), capture)); 128 render_delay_buffer->GetDownsampledRenderBuffer(), capture));
125 } 129 }
126 } 130 }
127 131
128 // Verifies that the delay estimator does not produce delay estimates for 132 // Verifies that the delay estimator does not produce delay estimates for
129 // uncorrelated signals. 133 // uncorrelated signals.
130 TEST(EchoPathDelayEstimator, NoDelayEstimatesForUncorrelatedSignals) { 134 TEST(EchoPathDelayEstimator, NoDelayEstimatesForUncorrelatedSignals) {
131 Random random_generator(42U); 135 Random random_generator(42U);
132 std::vector<std::vector<float>> render(3, std::vector<float>(kBlockSize)); 136 std::vector<std::vector<float>> render(3, std::vector<float>(kBlockSize));
133 std::vector<float> capture(kBlockSize); 137 std::vector<float> capture(kBlockSize);
134 ApmDataDumper data_dumper(0); 138 ApmDataDumper data_dumper(0);
135 EchoPathDelayEstimator estimator(&data_dumper); 139 EchoPathDelayEstimator estimator(&data_dumper,
140 AudioProcessing::Config::EchoCanceller3());
136 std::unique_ptr<RenderDelayBuffer> render_delay_buffer( 141 std::unique_ptr<RenderDelayBuffer> render_delay_buffer(
137 RenderDelayBuffer::Create(3)); 142 RenderDelayBuffer::Create(3));
138 for (size_t k = 0; k < 100; ++k) { 143 for (size_t k = 0; k < 100; ++k) {
139 RandomizeSampleVector(&random_generator, render[0]); 144 RandomizeSampleVector(&random_generator, render[0]);
140 RandomizeSampleVector(&random_generator, capture); 145 RandomizeSampleVector(&random_generator, capture);
141 render_delay_buffer->Insert(render); 146 render_delay_buffer->Insert(render);
142 render_delay_buffer->UpdateBuffers(); 147 render_delay_buffer->UpdateBuffers();
143 EXPECT_FALSE(estimator.EstimateDelay( 148 EXPECT_FALSE(estimator.EstimateDelay(
144 render_delay_buffer->GetDownsampledRenderBuffer(), capture)); 149 render_delay_buffer->GetDownsampledRenderBuffer(), capture));
145 } 150 }
146 } 151 }
147 152
148 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) 153 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
149 154
150 // Verifies the check for the render blocksize. 155 // Verifies the check for the render blocksize.
151 // TODO(peah): Re-enable the test once the issue with memory leaks during DEATH 156 // TODO(peah): Re-enable the test once the issue with memory leaks during DEATH
152 // tests on test bots has been fixed. 157 // tests on test bots has been fixed.
153 TEST(EchoPathDelayEstimator, DISABLED_WrongRenderBlockSize) { 158 TEST(EchoPathDelayEstimator, DISABLED_WrongRenderBlockSize) {
154 ApmDataDumper data_dumper(0); 159 ApmDataDumper data_dumper(0);
155 EchoPathDelayEstimator estimator(&data_dumper); 160 EchoPathDelayEstimator estimator(&data_dumper,
161 AudioProcessing::Config::EchoCanceller3());
156 std::unique_ptr<RenderDelayBuffer> render_delay_buffer( 162 std::unique_ptr<RenderDelayBuffer> render_delay_buffer(
157 RenderDelayBuffer::Create(3)); 163 RenderDelayBuffer::Create(3));
158 std::vector<float> capture(kBlockSize); 164 std::vector<float> capture(kBlockSize);
159 EXPECT_DEATH(estimator.EstimateDelay( 165 EXPECT_DEATH(estimator.EstimateDelay(
160 render_delay_buffer->GetDownsampledRenderBuffer(), capture), 166 render_delay_buffer->GetDownsampledRenderBuffer(), capture),
161 ""); 167 "");
162 } 168 }
163 169
164 // Verifies the check for the capture blocksize. 170 // Verifies the check for the capture blocksize.
165 // TODO(peah): Re-enable the test once the issue with memory leaks during DEATH 171 // TODO(peah): Re-enable the test once the issue with memory leaks during DEATH
166 // tests on test bots has been fixed. 172 // tests on test bots has been fixed.
167 TEST(EchoPathDelayEstimator, WrongCaptureBlockSize) { 173 TEST(EchoPathDelayEstimator, WrongCaptureBlockSize) {
168 ApmDataDumper data_dumper(0); 174 ApmDataDumper data_dumper(0);
169 EchoPathDelayEstimator estimator(&data_dumper); 175 EchoPathDelayEstimator estimator(&data_dumper,
176 AudioProcessing::Config::EchoCanceller3());
170 std::unique_ptr<RenderDelayBuffer> render_delay_buffer( 177 std::unique_ptr<RenderDelayBuffer> render_delay_buffer(
171 RenderDelayBuffer::Create(3)); 178 RenderDelayBuffer::Create(3));
172 std::vector<float> capture(std::vector<float>(kBlockSize - 1)); 179 std::vector<float> capture(std::vector<float>(kBlockSize - 1));
173 EXPECT_DEATH(estimator.EstimateDelay( 180 EXPECT_DEATH(estimator.EstimateDelay(
174 render_delay_buffer->GetDownsampledRenderBuffer(), capture), 181 render_delay_buffer->GetDownsampledRenderBuffer(), capture),
175 ""); 182 "");
176 } 183 }
177 184
178 // Verifies the check for non-null data dumper. 185 // Verifies the check for non-null data dumper.
179 TEST(EchoPathDelayEstimator, NullDataDumper) { 186 TEST(EchoPathDelayEstimator, NullDataDumper) {
180 EXPECT_DEATH(EchoPathDelayEstimator(nullptr), ""); 187 EXPECT_DEATH(EchoPathDelayEstimator(
188 nullptr, AudioProcessing::Config::EchoCanceller3()),
189 "");
181 } 190 }
182 191
183 #endif 192 #endif
184 193
185 } // namespace webrtc 194 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698