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

Side by Side Diff: webrtc/modules/audio_processing/aec3/echo_remover_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
(...skipping 27 matching lines...) Expand all
38 ss << ", Delay: " << delay; 38 ss << ", Delay: " << delay;
39 return ss.str(); 39 return ss.str();
40 } 40 }
41 41
42 } // namespace 42 } // namespace
43 43
44 // Verifies the basic API call sequence 44 // Verifies the basic API call sequence
45 TEST(EchoRemover, BasicApiCalls) { 45 TEST(EchoRemover, BasicApiCalls) {
46 for (auto rate : {8000, 16000, 32000, 48000}) { 46 for (auto rate : {8000, 16000, 32000, 48000}) {
47 SCOPED_TRACE(ProduceDebugText(rate)); 47 SCOPED_TRACE(ProduceDebugText(rate));
48 std::unique_ptr<EchoRemover> remover(EchoRemover::Create(rate)); 48 std::unique_ptr<EchoRemover> remover(
49 EchoRemover::Create(AudioProcessing::Config::EchoCanceller3(), rate));
49 std::unique_ptr<RenderDelayBuffer> render_buffer( 50 std::unique_ptr<RenderDelayBuffer> render_buffer(
50 RenderDelayBuffer::Create(NumBandsForRate(rate))); 51 RenderDelayBuffer::Create(NumBandsForRate(rate)));
51 52
52 std::vector<std::vector<float>> render(NumBandsForRate(rate), 53 std::vector<std::vector<float>> render(NumBandsForRate(rate),
53 std::vector<float>(kBlockSize, 0.f)); 54 std::vector<float>(kBlockSize, 0.f));
54 std::vector<std::vector<float>> capture( 55 std::vector<std::vector<float>> capture(
55 NumBandsForRate(rate), std::vector<float>(kBlockSize, 0.f)); 56 NumBandsForRate(rate), std::vector<float>(kBlockSize, 0.f));
56 for (size_t k = 0; k < 100; ++k) { 57 for (size_t k = 0; k < 100; ++k) {
57 EchoPathVariability echo_path_variability(k % 3 == 0 ? true : false, 58 EchoPathVariability echo_path_variability(k % 3 == 0 ? true : false,
58 k % 5 == 0 ? true : false); 59 k % 5 == 0 ? true : false);
59 rtc::Optional<size_t> echo_path_delay_samples = 60 rtc::Optional<size_t> echo_path_delay_samples =
60 (k % 6 == 0 ? rtc::Optional<size_t>(k * 10) 61 (k % 6 == 0 ? rtc::Optional<size_t>(k * 10)
61 : rtc::Optional<size_t>()); 62 : rtc::Optional<size_t>());
62 render_buffer->Insert(render); 63 render_buffer->Insert(render);
63 render_buffer->UpdateBuffers(); 64 render_buffer->UpdateBuffers();
64 remover->ProcessCapture(echo_path_delay_samples, echo_path_variability, 65 remover->ProcessCapture(echo_path_delay_samples, echo_path_variability,
65 k % 2 == 0 ? true : false, 66 k % 2 == 0 ? true : false,
66 render_buffer->GetRenderBuffer(), &capture); 67 render_buffer->GetRenderBuffer(), &capture);
67 } 68 }
68 } 69 }
69 } 70 }
70 71
71 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) 72 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
72 73
73 // Verifies the check for the samplerate. 74 // Verifies the check for the samplerate.
74 // TODO(peah): Re-enable the test once the issue with memory leaks during DEATH 75 // TODO(peah): Re-enable the test once the issue with memory leaks during DEATH
75 // tests on test bots has been fixed. 76 // tests on test bots has been fixed.
76 TEST(EchoRemover, DISABLED_WrongSampleRate) { 77 TEST(EchoRemover, DISABLED_WrongSampleRate) {
77 EXPECT_DEATH(std::unique_ptr<EchoRemover>(EchoRemover::Create(8001)), ""); 78 EXPECT_DEATH(std::unique_ptr<EchoRemover>(EchoRemover::Create(
79 AudioProcessing::Config::EchoCanceller3(), 8001)),
80 "");
78 } 81 }
79 82
80 // Verifies the check for the capture block size. 83 // Verifies the check for the capture block size.
81 TEST(EchoRemover, WrongCaptureBlockSize) { 84 TEST(EchoRemover, WrongCaptureBlockSize) {
82 for (auto rate : {8000, 16000, 32000, 48000}) { 85 for (auto rate : {8000, 16000, 32000, 48000}) {
83 SCOPED_TRACE(ProduceDebugText(rate)); 86 SCOPED_TRACE(ProduceDebugText(rate));
84 std::unique_ptr<EchoRemover> remover(EchoRemover::Create(rate)); 87 std::unique_ptr<EchoRemover> remover(
88 EchoRemover::Create(AudioProcessing::Config::EchoCanceller3(), rate));
85 std::unique_ptr<RenderDelayBuffer> render_buffer( 89 std::unique_ptr<RenderDelayBuffer> render_buffer(
86 RenderDelayBuffer::Create(NumBandsForRate(rate))); 90 RenderDelayBuffer::Create(NumBandsForRate(rate)));
87 std::vector<std::vector<float>> capture( 91 std::vector<std::vector<float>> capture(
88 NumBandsForRate(rate), std::vector<float>(kBlockSize - 1, 0.f)); 92 NumBandsForRate(rate), std::vector<float>(kBlockSize - 1, 0.f));
89 EchoPathVariability echo_path_variability(false, false); 93 EchoPathVariability echo_path_variability(false, false);
90 rtc::Optional<size_t> echo_path_delay_samples; 94 rtc::Optional<size_t> echo_path_delay_samples;
91 EXPECT_DEATH(remover->ProcessCapture( 95 EXPECT_DEATH(remover->ProcessCapture(
92 echo_path_delay_samples, echo_path_variability, false, 96 echo_path_delay_samples, echo_path_variability, false,
93 render_buffer->GetRenderBuffer(), &capture), 97 render_buffer->GetRenderBuffer(), &capture),
94 ""); 98 "");
95 } 99 }
96 } 100 }
97 101
98 // Verifies the check for the number of capture bands. 102 // Verifies the check for the number of capture bands.
99 // TODO(peah): Re-enable the test once the issue with memory leaks during DEATH 103 // TODO(peah): Re-enable the test once the issue with memory leaks during DEATH
100 // tests on test bots has been fixed.c 104 // tests on test bots has been fixed.c
101 TEST(EchoRemover, DISABLED_WrongCaptureNumBands) { 105 TEST(EchoRemover, DISABLED_WrongCaptureNumBands) {
102 for (auto rate : {16000, 32000, 48000}) { 106 for (auto rate : {16000, 32000, 48000}) {
103 SCOPED_TRACE(ProduceDebugText(rate)); 107 SCOPED_TRACE(ProduceDebugText(rate));
104 std::unique_ptr<EchoRemover> remover(EchoRemover::Create(rate)); 108 std::unique_ptr<EchoRemover> remover(
109 EchoRemover::Create(AudioProcessing::Config::EchoCanceller3(), rate));
105 std::unique_ptr<RenderDelayBuffer> render_buffer( 110 std::unique_ptr<RenderDelayBuffer> render_buffer(
106 RenderDelayBuffer::Create(NumBandsForRate(rate))); 111 RenderDelayBuffer::Create(NumBandsForRate(rate)));
107 std::vector<std::vector<float>> capture( 112 std::vector<std::vector<float>> capture(
108 NumBandsForRate(rate == 48000 ? 16000 : rate + 16000), 113 NumBandsForRate(rate == 48000 ? 16000 : rate + 16000),
109 std::vector<float>(kBlockSize, 0.f)); 114 std::vector<float>(kBlockSize, 0.f));
110 EchoPathVariability echo_path_variability(false, false); 115 EchoPathVariability echo_path_variability(false, false);
111 rtc::Optional<size_t> echo_path_delay_samples; 116 rtc::Optional<size_t> echo_path_delay_samples;
112 EXPECT_DEATH(remover->ProcessCapture( 117 EXPECT_DEATH(remover->ProcessCapture(
113 echo_path_delay_samples, echo_path_variability, false, 118 echo_path_delay_samples, echo_path_variability, false,
114 render_buffer->GetRenderBuffer(), &capture), 119 render_buffer->GetRenderBuffer(), &capture),
115 ""); 120 "");
116 } 121 }
117 } 122 }
118 123
119 // Verifies the check for non-null capture block. 124 // Verifies the check for non-null capture block.
120 TEST(EchoRemover, NullCapture) { 125 TEST(EchoRemover, NullCapture) {
121 std::unique_ptr<EchoRemover> remover(EchoRemover::Create(8000)); 126 std::unique_ptr<EchoRemover> remover(
127 EchoRemover::Create(AudioProcessing::Config::EchoCanceller3(), 8000));
122 std::unique_ptr<RenderDelayBuffer> render_buffer( 128 std::unique_ptr<RenderDelayBuffer> render_buffer(
123 RenderDelayBuffer::Create(3)); 129 RenderDelayBuffer::Create(3));
124 EchoPathVariability echo_path_variability(false, false); 130 EchoPathVariability echo_path_variability(false, false);
125 rtc::Optional<size_t> echo_path_delay_samples; 131 rtc::Optional<size_t> echo_path_delay_samples;
126 EXPECT_DEATH( 132 EXPECT_DEATH(
127 remover->ProcessCapture(echo_path_delay_samples, echo_path_variability, 133 remover->ProcessCapture(echo_path_delay_samples, echo_path_variability,
128 false, render_buffer->GetRenderBuffer(), nullptr), 134 false, render_buffer->GetRenderBuffer(), nullptr),
129 ""); 135 "");
130 } 136 }
131 137
132 #endif 138 #endif
133 139
134 // Performs a sanity check that the echo_remover is able to properly 140 // Performs a sanity check that the echo_remover is able to properly
135 // remove echoes. 141 // remove echoes.
136 TEST(EchoRemover, BasicEchoRemoval) { 142 TEST(EchoRemover, BasicEchoRemoval) {
137 constexpr int kNumBlocksToProcess = 500; 143 constexpr int kNumBlocksToProcess = 500;
138 Random random_generator(42U); 144 Random random_generator(42U);
139 for (auto rate : {8000, 16000, 32000, 48000}) { 145 for (auto rate : {8000, 16000, 32000, 48000}) {
140 std::vector<std::vector<float>> x(NumBandsForRate(rate), 146 std::vector<std::vector<float>> x(NumBandsForRate(rate),
141 std::vector<float>(kBlockSize, 0.f)); 147 std::vector<float>(kBlockSize, 0.f));
142 std::vector<std::vector<float>> y(NumBandsForRate(rate), 148 std::vector<std::vector<float>> y(NumBandsForRate(rate),
143 std::vector<float>(kBlockSize, 0.f)); 149 std::vector<float>(kBlockSize, 0.f));
144 EchoPathVariability echo_path_variability(false, false); 150 EchoPathVariability echo_path_variability(false, false);
145 for (size_t delay_samples : {0, 64, 150, 200, 301}) { 151 for (size_t delay_samples : {0, 64, 150, 200, 301}) {
146 SCOPED_TRACE(ProduceDebugText(rate, delay_samples)); 152 SCOPED_TRACE(ProduceDebugText(rate, delay_samples));
147 std::unique_ptr<EchoRemover> remover(EchoRemover::Create(rate)); 153 std::unique_ptr<EchoRemover> remover(
154 EchoRemover::Create(AudioProcessing::Config::EchoCanceller3(), rate));
148 std::unique_ptr<RenderDelayBuffer> render_buffer( 155 std::unique_ptr<RenderDelayBuffer> render_buffer(
149 RenderDelayBuffer::Create(NumBandsForRate(rate))); 156 RenderDelayBuffer::Create(NumBandsForRate(rate)));
150 std::vector<std::unique_ptr<DelayBuffer<float>>> delay_buffers(x.size()); 157 std::vector<std::unique_ptr<DelayBuffer<float>>> delay_buffers(x.size());
151 for (size_t j = 0; j < x.size(); ++j) { 158 for (size_t j = 0; j < x.size(); ++j) {
152 delay_buffers[j].reset(new DelayBuffer<float>(delay_samples)); 159 delay_buffers[j].reset(new DelayBuffer<float>(delay_samples));
153 } 160 }
154 161
155 float input_energy = 0.f; 162 float input_energy = 0.f;
156 float output_energy = 0.f; 163 float output_energy = 0.f;
157 for (int k = 0; k < kNumBlocksToProcess; ++k) { 164 for (int k = 0; k < kNumBlocksToProcess; ++k) {
(...skipping 28 matching lines...) Expand all
186 y[j].begin(), output_energy); 193 y[j].begin(), output_energy);
187 } 194 }
188 } 195 }
189 } 196 }
190 EXPECT_GT(input_energy, 10.f * output_energy); 197 EXPECT_GT(input_energy, 10.f * output_energy);
191 } 198 }
192 } 199 }
193 } 200 }
194 201
195 } // namespace webrtc 202 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698