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

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

Issue 2678423005: Finalization of the first version of EchoCanceller 3 (Closed)
Patch Set: Fixed compilation error Created 3 years, 9 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) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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/echo_canceller3.h" 11 #include "webrtc/modules/audio_processing/aec3/echo_canceller3.h"
12 12
13 #include <deque> 13 #include <deque>
14 #include <memory> 14 #include <memory>
15 #include <sstream> 15 #include <sstream>
16 #include <string> 16 #include <string>
17 #include <utility> 17 #include <utility>
18 #include <vector> 18 #include <vector>
19 19
20 #include "webrtc/modules/audio_processing/aec3/aec3_constants.h" 20 #include "webrtc/modules/audio_processing/aec3/aec3_common.h"
21 #include "webrtc/modules/audio_processing/aec3/block_processor.h" 21 #include "webrtc/modules/audio_processing/aec3/block_processor.h"
22 #include "webrtc/modules/audio_processing/aec3/frame_blocker.h" 22 #include "webrtc/modules/audio_processing/aec3/frame_blocker.h"
23 #include "webrtc/modules/audio_processing/aec3/mock/mock_block_processor.h" 23 #include "webrtc/modules/audio_processing/aec3/mock/mock_block_processor.h"
24 #include "webrtc/modules/audio_processing/audio_buffer.h" 24 #include "webrtc/modules/audio_processing/audio_buffer.h"
25 #include "webrtc/test/gmock.h" 25 #include "webrtc/test/gmock.h"
26 #include "webrtc/test/gtest.h" 26 #include "webrtc/test/gtest.h"
27 27
28 namespace webrtc { 28 namespace webrtc {
29 namespace { 29 namespace {
30 30
(...skipping 10 matching lines...) Expand all
41 float* const* frame, 41 float* const* frame,
42 int offset) { 42 int offset) {
43 for (size_t k = 0; k < num_bands; ++k) { 43 for (size_t k = 0; k < num_bands; ++k) {
44 for (size_t i = 0; i < frame_length; ++i) { 44 for (size_t i = 0; i < frame_length; ++i) {
45 float value = static_cast<int>(frame_index * frame_length + i) + offset; 45 float value = static_cast<int>(frame_index * frame_length + i) + offset;
46 frame[k][i] = (value > 0 ? 5000 * k + value : 0); 46 frame[k][i] = (value > 0 ? 5000 * k + value : 0);
47 } 47 }
48 } 48 }
49 } 49 }
50 50
51 // Populates the frame with linearly increasing sample values.
52 void PopulateInputFrame(size_t frame_length,
53 size_t frame_index,
54 float* frame,
55 int offset) {
56 for (size_t i = 0; i < frame_length; ++i) {
57 float value = static_cast<int>(frame_index * frame_length + i) + offset;
58 frame[i] = std::max(value, 0.f);
59 }
60 }
61
51 // Verifies the that samples in the output frame are identical to the samples 62 // Verifies the that samples in the output frame are identical to the samples
52 // that were produced for the input frame, with an offset in order to compensate 63 // that were produced for the input frame, with an offset in order to compensate
53 // for buffering delays. 64 // for buffering delays.
54 bool VerifyOutputFrameBitexactness(size_t frame_length, 65 bool VerifyOutputFrameBitexactness(size_t frame_length,
55 size_t num_bands, 66 size_t num_bands,
56 size_t frame_index, 67 size_t frame_index,
57 const float* const* frame, 68 const float* const* frame,
58 int offset) { 69 int offset) {
59 float reference_frame_data[kMaxNumBands][2 * kSubFrameLength]; 70 float reference_frame_data[kMaxNumBands][2 * kSubFrameLength];
60 float* reference_frame[kMaxNumBands]; 71 float* reference_frame[kMaxNumBands];
61 for (size_t k = 0; k < num_bands; ++k) { 72 for (size_t k = 0; k < num_bands; ++k) {
62 reference_frame[k] = &reference_frame_data[k][0]; 73 reference_frame[k] = &reference_frame_data[k][0];
63 } 74 }
64 75
65 PopulateInputFrame(frame_length, num_bands, frame_index, reference_frame, 76 PopulateInputFrame(frame_length, num_bands, frame_index, reference_frame,
66 offset); 77 offset);
67 for (size_t k = 0; k < num_bands; ++k) { 78 for (size_t k = 0; k < num_bands; ++k) {
68 for (size_t i = 0; i < frame_length; ++i) { 79 for (size_t i = 0; i < frame_length; ++i) {
69 if (reference_frame[k][i] != frame[k][i]) { 80 if (reference_frame[k][i] != frame[k][i]) {
70 return false; 81 return false;
71 } 82 }
72 } 83 }
73 } 84 }
74 85
75 return true; 86 return true;
76 } 87 }
77 88
89 // Verifies the that samples in the output frame are identical to the samples
90 // that were produced for the input frame, with an offset in order to compensate
91 // for buffering delays.
92 bool VerifyOutputFrameBitexactness(size_t frame_length,
93 size_t frame_index,
94 const float* const* frame,
95 int offset) {
96 float reference_frame[480];
97
98 PopulateInputFrame(frame_length, frame_index, reference_frame, offset);
99 for (size_t i = 0; i < frame_length; ++i) {
100 if (reference_frame[i] != frame[0][i]) {
101 return false;
102 }
103 }
104
105 return true;
106 }
107
78 // Class for testing that the capture data is properly received by the block 108 // Class for testing that the capture data is properly received by the block
79 // processor and that the processor data is properly passed to the 109 // processor and that the processor data is properly passed to the
80 // EchoCanceller3 output. 110 // EchoCanceller3 output.
81 class CaptureTransportVerificationProcessor : public BlockProcessor { 111 class CaptureTransportVerificationProcessor : public BlockProcessor {
82 public: 112 public:
83 explicit CaptureTransportVerificationProcessor(size_t num_bands) {} 113 explicit CaptureTransportVerificationProcessor(size_t num_bands) {}
84 ~CaptureTransportVerificationProcessor() override = default; 114 ~CaptureTransportVerificationProcessor() override = default;
85 115
86 void ProcessCapture(bool level_change, 116 void ProcessCapture(bool level_change,
87 bool saturated_microphone_signal, 117 bool saturated_microphone_signal,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 sample_rate_hz_, false, 182 sample_rate_hz_, false,
153 std::unique_ptr<BlockProcessor>( 183 std::unique_ptr<BlockProcessor>(
154 new CaptureTransportVerificationProcessor(num_bands_))); 184 new CaptureTransportVerificationProcessor(num_bands_)));
155 185
156 for (size_t frame_index = 0; frame_index < kNumFramesToProcess; 186 for (size_t frame_index = 0; frame_index < kNumFramesToProcess;
157 ++frame_index) { 187 ++frame_index) {
158 aec3.AnalyzeCapture(&capture_buffer_); 188 aec3.AnalyzeCapture(&capture_buffer_);
159 OptionalBandSplit(); 189 OptionalBandSplit();
160 PopulateInputFrame(frame_length_, num_bands_, frame_index, 190 PopulateInputFrame(frame_length_, num_bands_, frame_index,
161 &capture_buffer_.split_bands_f(0)[0], 0); 191 &capture_buffer_.split_bands_f(0)[0], 0);
162 PopulateInputFrame(frame_length_, num_bands_, frame_index, 192 PopulateInputFrame(frame_length_, frame_index,
163 &render_buffer_.split_bands_f(0)[0], 100); 193 &render_buffer_.channels_f()[0][0], 0);
164 194
165 EXPECT_TRUE(aec3.AnalyzeRender(&render_buffer_)); 195 EXPECT_TRUE(aec3.AnalyzeRender(&render_buffer_));
166 aec3.ProcessCapture(&capture_buffer_, false); 196 aec3.ProcessCapture(&capture_buffer_, false);
167 EXPECT_TRUE(VerifyOutputFrameBitexactness( 197 EXPECT_TRUE(VerifyOutputFrameBitexactness(
168 frame_length_, num_bands_, frame_index, 198 frame_length_, num_bands_, frame_index,
169 &capture_buffer_.split_bands_f(0)[0], -64)); 199 &capture_buffer_.split_bands_f(0)[0], -64));
170 } 200 }
171 } 201 }
172 202
173 // Test method for testing that the render data is properly received by the 203 // Test method for testing that the render data is properly received by the
174 // block processor. 204 // block processor.
175 void RunRenderTransportVerificationTest() { 205 void RunRenderTransportVerificationTest() {
176 EchoCanceller3 aec3( 206 EchoCanceller3 aec3(
177 sample_rate_hz_, false, 207 sample_rate_hz_, false,
178 std::unique_ptr<BlockProcessor>( 208 std::unique_ptr<BlockProcessor>(
179 new RenderTransportVerificationProcessor(num_bands_))); 209 new RenderTransportVerificationProcessor(num_bands_)));
180 210
181 for (size_t frame_index = 0; frame_index < kNumFramesToProcess; 211 for (size_t frame_index = 0; frame_index < kNumFramesToProcess;
182 ++frame_index) { 212 ++frame_index) {
183 aec3.AnalyzeCapture(&capture_buffer_); 213 aec3.AnalyzeCapture(&capture_buffer_);
184 OptionalBandSplit(); 214 OptionalBandSplit();
185 PopulateInputFrame(frame_length_, num_bands_, frame_index, 215 PopulateInputFrame(frame_length_, num_bands_, frame_index,
186 &capture_buffer_.split_bands_f(0)[0], 100); 216 &capture_buffer_.split_bands_f(0)[0], 100);
187 PopulateInputFrame(frame_length_, num_bands_, frame_index, 217 PopulateInputFrame(frame_length_, frame_index,
188 &render_buffer_.split_bands_f(0)[0], 0); 218 &render_buffer_.channels_f()[0][0], 0);
189 219
190 EXPECT_TRUE(aec3.AnalyzeRender(&render_buffer_)); 220 EXPECT_TRUE(aec3.AnalyzeRender(&render_buffer_));
191 aec3.ProcessCapture(&capture_buffer_, false); 221 aec3.ProcessCapture(&capture_buffer_, false);
192 EXPECT_TRUE(VerifyOutputFrameBitexactness( 222 EXPECT_TRUE(VerifyOutputFrameBitexactness(
193 frame_length_, num_bands_, frame_index, 223 frame_length_, frame_index, &capture_buffer_.split_bands_f(0)[0],
194 &capture_buffer_.split_bands_f(0)[0], -64)); 224 -64));
195 } 225 }
196 } 226 }
197 227
198 // Verifies that information about echo path changes are properly propagated 228 // Verifies that information about echo path changes are properly propagated
199 // to the block processor. 229 // to the block processor.
200 // The cases tested are: 230 // The cases tested are:
201 // -That no set echo path change flags are received when there is no echo path 231 // -That no set echo path change flags are received when there is no echo path
202 // change. 232 // change.
203 // -That set echo path change flags are received and continues to be received 233 // -That set echo path change flags are received and continues to be received
204 // as long as echo path changes are flagged. 234 // as long as echo path changes are flagged.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 echo_path_change = true; 286 echo_path_change = true;
257 } 287 }
258 break; 288 break;
259 } 289 }
260 290
261 aec3.AnalyzeCapture(&capture_buffer_); 291 aec3.AnalyzeCapture(&capture_buffer_);
262 OptionalBandSplit(); 292 OptionalBandSplit();
263 293
264 PopulateInputFrame(frame_length_, num_bands_, frame_index, 294 PopulateInputFrame(frame_length_, num_bands_, frame_index,
265 &capture_buffer_.split_bands_f(0)[0], 0); 295 &capture_buffer_.split_bands_f(0)[0], 0);
266 PopulateInputFrame(frame_length_, num_bands_, frame_index, 296 PopulateInputFrame(frame_length_, frame_index,
267 &render_buffer_.split_bands_f(0)[0], 0); 297 &render_buffer_.channels_f()[0][0], 0);
268 298
269 EXPECT_TRUE(aec3.AnalyzeRender(&render_buffer_)); 299 EXPECT_TRUE(aec3.AnalyzeRender(&render_buffer_));
270 aec3.ProcessCapture(&capture_buffer_, echo_path_change); 300 aec3.ProcessCapture(&capture_buffer_, echo_path_change);
271 } 301 }
272 } 302 }
273 303
274 // Test for verifying that echo leakage information is being properly passed 304 // Test for verifying that echo leakage information is being properly passed
275 // to the processor. 305 // to the processor.
276 // The cases tested are: 306 // The cases tested are:
277 // -That no method calls are received when they should not. 307 // -That no method calls are received when they should not.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 aec3.UpdateEchoLeakageStatus(false); 377 aec3.UpdateEchoLeakageStatus(false);
348 } 378 }
349 break; 379 break;
350 } 380 }
351 381
352 aec3.AnalyzeCapture(&capture_buffer_); 382 aec3.AnalyzeCapture(&capture_buffer_);
353 OptionalBandSplit(); 383 OptionalBandSplit();
354 384
355 PopulateInputFrame(frame_length_, num_bands_, frame_index, 385 PopulateInputFrame(frame_length_, num_bands_, frame_index,
356 &capture_buffer_.split_bands_f(0)[0], 0); 386 &capture_buffer_.split_bands_f(0)[0], 0);
357 PopulateInputFrame(frame_length_, num_bands_, frame_index, 387 PopulateInputFrame(frame_length_, frame_index,
358 &render_buffer_.split_bands_f(0)[0], 0); 388 &render_buffer_.channels_f()[0][0], 0);
359 389
360 EXPECT_TRUE(aec3.AnalyzeRender(&render_buffer_)); 390 EXPECT_TRUE(aec3.AnalyzeRender(&render_buffer_));
361 aec3.ProcessCapture(&capture_buffer_, false); 391 aec3.ProcessCapture(&capture_buffer_, false);
362 } 392 }
363 } 393 }
364 394
365 // This verifies that saturation information is properly passed to the 395 // This verifies that saturation information is properly passed to the
366 // BlockProcessor. 396 // BlockProcessor.
367 // The cases tested are: 397 // The cases tested are:
368 // -That no saturation event is passed to the processor if there is no 398 // -That no saturation event is passed to the processor if there is no
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 testing::InSequence s; 437 testing::InSequence s;
408 EXPECT_CALL(*block_processor_mock, ProcessCapture(_, true, _)) 438 EXPECT_CALL(*block_processor_mock, ProcessCapture(_, true, _))
409 .Times(num_full_blocks_per_frame); 439 .Times(num_full_blocks_per_frame);
410 EXPECT_CALL(*block_processor_mock, ProcessCapture(_, false, _)) 440 EXPECT_CALL(*block_processor_mock, ProcessCapture(_, false, _))
411 .Times(expected_num_block_to_process - num_full_blocks_per_frame); 441 .Times(expected_num_block_to_process - num_full_blocks_per_frame);
412 } break; 442 } break;
413 } 443 }
414 444
415 EchoCanceller3 aec3(sample_rate_hz_, false, 445 EchoCanceller3 aec3(sample_rate_hz_, false,
416 std::move(block_processor_mock)); 446 std::move(block_processor_mock));
417
418 for (size_t frame_index = 0; frame_index < kNumFramesToProcess; 447 for (size_t frame_index = 0; frame_index < kNumFramesToProcess;
419 ++frame_index) { 448 ++frame_index) {
420 for (int k = 0; k < fullband_frame_length_; ++k) { 449 for (int k = 0; k < fullband_frame_length_; ++k) {
421 capture_buffer_.channels_f()[0][k] = 0.f; 450 capture_buffer_.channels_f()[0][k] = 0.f;
422 } 451 }
423 switch (saturation_variant) { 452 switch (saturation_variant) {
424 case SaturationTestVariant::kNone: 453 case SaturationTestVariant::kNone:
425 break; 454 break;
426 case SaturationTestVariant::kOneNegative: 455 case SaturationTestVariant::kOneNegative:
427 if (frame_index == 0) { 456 if (frame_index == 0) {
428 capture_buffer_.channels_f()[0][10] = -32768.f; 457 capture_buffer_.channels_f()[0][10] = -32768.f;
429 } 458 }
430 break; 459 break;
431 case SaturationTestVariant::kOnePositive: 460 case SaturationTestVariant::kOnePositive:
432 if (frame_index == 0) { 461 if (frame_index == 0) {
433 capture_buffer_.channels_f()[0][10] = 32767.f; 462 capture_buffer_.channels_f()[0][10] = 32767.f;
434 } 463 }
435 break; 464 break;
436 } 465 }
437 466
438 aec3.AnalyzeCapture(&capture_buffer_); 467 aec3.AnalyzeCapture(&capture_buffer_);
439 OptionalBandSplit(); 468 OptionalBandSplit();
440 469
441 PopulateInputFrame(frame_length_, num_bands_, frame_index, 470 PopulateInputFrame(frame_length_, num_bands_, frame_index,
442 &capture_buffer_.split_bands_f(0)[0], 0); 471 &capture_buffer_.split_bands_f(0)[0], 0);
443 PopulateInputFrame(frame_length_, num_bands_, frame_index, 472 PopulateInputFrame(frame_length_, frame_index,
444 &render_buffer_.split_bands_f(0)[0], 0); 473 &render_buffer_.channels_f()[0][0], 0);
445 474
446 EXPECT_TRUE(aec3.AnalyzeRender(&render_buffer_)); 475 EXPECT_TRUE(aec3.AnalyzeRender(&render_buffer_));
447 aec3.ProcessCapture(&capture_buffer_, false); 476 aec3.ProcessCapture(&capture_buffer_, false);
448 } 477 }
449 } 478 }
450 479
451 // This test verifies that the swapqueue is able to handle jitter in the 480 // This test verifies that the swapqueue is able to handle jitter in the
452 // capture and render API calls. 481 // capture and render API calls.
453 void RunRenderSwapQueueVerificationTest() { 482 void RunRenderSwapQueueVerificationTest() {
454 EchoCanceller3 aec3( 483 EchoCanceller3 aec3(
455 sample_rate_hz_, false, 484 sample_rate_hz_, false,
456 std::unique_ptr<BlockProcessor>( 485 std::unique_ptr<BlockProcessor>(
457 new RenderTransportVerificationProcessor(num_bands_))); 486 new RenderTransportVerificationProcessor(num_bands_)));
458 487
459 constexpr size_t kSwapQueueLength = 30; 488 constexpr size_t kSwapQueueLength = 30;
460 for (size_t frame_index = 0; frame_index < kSwapQueueLength; 489 for (size_t frame_index = 0; frame_index < kSwapQueueLength;
461 ++frame_index) { 490 ++frame_index) {
462 if (sample_rate_hz_ > 16000) { 491 if (sample_rate_hz_ > 16000) {
463 render_buffer_.SplitIntoFrequencyBands(); 492 render_buffer_.SplitIntoFrequencyBands();
464 } 493 }
465 PopulateInputFrame(frame_length_, num_bands_, frame_index, 494 PopulateInputFrame(frame_length_, frame_index,
466 &render_buffer_.split_bands_f(0)[0], 0); 495 &render_buffer_.channels_f()[0][0], 0);
467 496
468 EXPECT_TRUE(aec3.AnalyzeRender(&render_buffer_)); 497 EXPECT_TRUE(aec3.AnalyzeRender(&render_buffer_));
469 } 498 }
470 499
471 for (size_t frame_index = 0; frame_index < kSwapQueueLength; 500 for (size_t frame_index = 0; frame_index < kSwapQueueLength;
472 ++frame_index) { 501 ++frame_index) {
473 aec3.AnalyzeCapture(&capture_buffer_); 502 aec3.AnalyzeCapture(&capture_buffer_);
474 if (sample_rate_hz_ > 16000) { 503 if (sample_rate_hz_ > 16000) {
475 capture_buffer_.SplitIntoFrequencyBands(); 504 capture_buffer_.SplitIntoFrequencyBands();
476 } 505 }
477 506
478 PopulateInputFrame(frame_length_, num_bands_, frame_index, 507 PopulateInputFrame(frame_length_, num_bands_, frame_index,
479 &capture_buffer_.split_bands_f(0)[0], 0); 508 &capture_buffer_.split_bands_f(0)[0], 0);
480 509
481 aec3.ProcessCapture(&capture_buffer_, false); 510 aec3.ProcessCapture(&capture_buffer_, false);
482 EXPECT_TRUE(VerifyOutputFrameBitexactness( 511 EXPECT_TRUE(VerifyOutputFrameBitexactness(
483 frame_length_, num_bands_, frame_index, 512 frame_length_, frame_index, &capture_buffer_.split_bands_f(0)[0],
484 &capture_buffer_.split_bands_f(0)[0], -64)); 513 -64));
485 } 514 }
486 } 515 }
487 516
488 // This test verifies that a buffer overrun in the render swapqueue is 517 // This test verifies that a buffer overrun in the render swapqueue is
489 // properly reported. 518 // properly reported.
490 void RunRenderPipelineSwapQueueOverrunReturnValueTest() { 519 void RunRenderPipelineSwapQueueOverrunReturnValueTest() {
491 EchoCanceller3 aec3(sample_rate_hz_, false); 520 EchoCanceller3 aec3(sample_rate_hz_, false);
492 521
493 constexpr size_t kSwapQueueLength = 30; 522 constexpr size_t kSwapQueueLength = 30;
494 for (size_t k = 0; k < 2; ++k) { 523 for (size_t k = 0; k < 2; ++k) {
495 for (size_t frame_index = 0; frame_index < kSwapQueueLength; 524 for (size_t frame_index = 0; frame_index < kSwapQueueLength;
496 ++frame_index) { 525 ++frame_index) {
497 if (sample_rate_hz_ > 16000) { 526 if (sample_rate_hz_ > 16000) {
498 render_buffer_.SplitIntoFrequencyBands(); 527 render_buffer_.SplitIntoFrequencyBands();
499 } 528 }
500 PopulateInputFrame(frame_length_, num_bands_, frame_index, 529 PopulateInputFrame(frame_length_, frame_index,
501 &render_buffer_.split_bands_f(0)[0], 0); 530 &render_buffer_.channels_f()[0][0], 0);
502 531
503 if (k == 0) { 532 if (k == 0) {
504 EXPECT_TRUE(aec3.AnalyzeRender(&render_buffer_)); 533 EXPECT_TRUE(aec3.AnalyzeRender(&render_buffer_));
505 } else { 534 } else {
506 EXPECT_FALSE(aec3.AnalyzeRender(&render_buffer_)); 535 EXPECT_FALSE(aec3.AnalyzeRender(&render_buffer_));
507 } 536 }
508 } 537 }
509 } 538 }
510 } 539 }
511 540
512 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) 541 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
513 // Verifies the that the check for the number of bands in the AnalyzeRender 542 // Verifies the that the check for the number of bands in the AnalyzeRender
514 // input is correct by adjusting the sample rates of EchoCanceller3 and the 543 // input is correct by adjusting the sample rates of EchoCanceller3 and the
515 // input AudioBuffer to have a different number of bands. 544 // input AudioBuffer to have a different number of bands.
516 void RunAnalyzeRenderNumBandsCheckVerification() { 545 void RunAnalyzeRenderNumBandsCheckVerification() {
517 // Set aec3_sample_rate_hz to be different from sample_rate_hz_ in such a 546 // Set aec3_sample_rate_hz to be different from sample_rate_hz_ in such a
518 // way that the number of bands for the rates are different. 547 // way that the number of bands for the rates are different.
519 const int aec3_sample_rate_hz = sample_rate_hz_ == 48000 ? 32000 : 48000; 548 const int aec3_sample_rate_hz = sample_rate_hz_ == 48000 ? 32000 : 48000;
520 EchoCanceller3 aec3(aec3_sample_rate_hz, false); 549 EchoCanceller3 aec3(aec3_sample_rate_hz, false);
521 PopulateInputFrame(frame_length_, num_bands_, 0, 550 PopulateInputFrame(frame_length_, 0, &render_buffer_.channels_f()[0][0], 0);
522 &render_buffer_.split_bands_f(0)[0], 0);
523 551
524 EXPECT_DEATH(aec3.AnalyzeRender(&render_buffer_), ""); 552 EXPECT_DEATH(aec3.AnalyzeRender(&render_buffer_), "");
525 } 553 }
526 554
527 // Verifies the that the check for the number of bands in the ProcessCapture 555 // Verifies the that the check for the number of bands in the ProcessCapture
528 // input is correct by adjusting the sample rates of EchoCanceller3 and the 556 // input is correct by adjusting the sample rates of EchoCanceller3 and the
529 // input AudioBuffer to have a different number of bands. 557 // input AudioBuffer to have a different number of bands.
530 void RunProcessCaptureNumBandsCheckVerification() { 558 void RunProcessCaptureNumBandsCheckVerification() {
531 // Set aec3_sample_rate_hz to be different from sample_rate_hz_ in such a 559 // Set aec3_sample_rate_hz to be different from sample_rate_hz_ in such a
532 // way that the number of bands for the rates are different. 560 // way that the number of bands for the rates are different.
533 const int aec3_sample_rate_hz = sample_rate_hz_ == 48000 ? 32000 : 48000; 561 const int aec3_sample_rate_hz = sample_rate_hz_ == 48000 ? 32000 : 48000;
534 EchoCanceller3 aec3(aec3_sample_rate_hz, false); 562 EchoCanceller3 aec3(aec3_sample_rate_hz, false);
535 PopulateInputFrame(frame_length_, num_bands_, 0, 563 PopulateInputFrame(frame_length_, num_bands_, 0,
536 &capture_buffer_.split_bands_f(0)[0], 100); 564 &capture_buffer_.split_bands_f(0)[0], 100);
537 EXPECT_DEATH(aec3.ProcessCapture(&capture_buffer_, false), ""); 565 EXPECT_DEATH(aec3.ProcessCapture(&capture_buffer_, false), "");
538 } 566 }
539 567
540 // Verifies the that the check for the frame length in the AnalyzeRender input 568 // Verifies the that the check for the frame length in the AnalyzeRender input
541 // is correct by adjusting the sample rates of EchoCanceller3 and the input 569 // is correct by adjusting the sample rates of EchoCanceller3 and the input
542 // AudioBuffer to have a different frame lengths. 570 // AudioBuffer to have a different frame lengths.
543 void RunAnalyzeRenderFrameLengthCheckVerification() { 571 void RunAnalyzeRenderFrameLengthCheckVerification() {
544 // Set aec3_sample_rate_hz to be different from sample_rate_hz_ in such a 572 // Set aec3_sample_rate_hz to be different from sample_rate_hz_ in such a
545 // way that the band frame lengths are different. 573 // way that the band frame lengths are different.
546 const int aec3_sample_rate_hz = sample_rate_hz_ == 8000 ? 16000 : 8000; 574 const int aec3_sample_rate_hz = sample_rate_hz_ == 8000 ? 16000 : 8000;
547 EchoCanceller3 aec3(aec3_sample_rate_hz, false); 575 EchoCanceller3 aec3(aec3_sample_rate_hz, false);
548 576
549 OptionalBandSplit(); 577 OptionalBandSplit();
550 PopulateInputFrame(frame_length_, num_bands_, 0, 578 PopulateInputFrame(frame_length_, 0, &render_buffer_.channels_f()[0][0], 0);
551 &render_buffer_.split_bands_f(0)[0], 0);
552 579
553 EXPECT_DEATH(aec3.AnalyzeRender(&render_buffer_), ""); 580 EXPECT_DEATH(aec3.AnalyzeRender(&render_buffer_), "");
554 } 581 }
555 582
556 // Verifies the that the check for the frame length in the AnalyzeRender input 583 // Verifies the that the check for the frame length in the AnalyzeRender input
557 // is correct by adjusting the sample rates of EchoCanceller3 and the input 584 // is correct by adjusting the sample rates of EchoCanceller3 and the input
558 // AudioBuffer to have a different frame lengths. 585 // AudioBuffer to have a different frame lengths.
559 void RunProcessCaptureFrameLengthCheckVerification() { 586 void RunProcessCaptureFrameLengthCheckVerification() {
560 // Set aec3_sample_rate_hz to be different from sample_rate_hz_ in such a 587 // Set aec3_sample_rate_hz to be different from sample_rate_hz_ in such a
561 // way that the band frame lengths are different. 588 // way that the band frame lengths are different.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 EchoCanceller3Tester::EchoLeakageTestVariant::kTrueNonSticky}; 693 EchoCanceller3Tester::EchoLeakageTestVariant::kTrueNonSticky};
667 for (auto rate : {8000, 16000, 32000, 48000}) { 694 for (auto rate : {8000, 16000, 32000, 48000}) {
668 for (auto variant : variants) { 695 for (auto variant : variants) {
669 SCOPED_TRACE(ProduceDebugText(rate, static_cast<int>(variant))); 696 SCOPED_TRACE(ProduceDebugText(rate, static_cast<int>(variant)));
670 EchoCanceller3Tester(rate).RunEchoLeakageVerificationTest(variant); 697 EchoCanceller3Tester(rate).RunEchoLeakageVerificationTest(variant);
671 } 698 }
672 } 699 }
673 } 700 }
674 701
675 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) 702 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
676 TEST(EchoCanceller3InputCheck, WrongRenderNumBandsCheckVerification) {
677 for (auto rate : {8000, 16000, 32000, 48000}) {
678 SCOPED_TRACE(ProduceDebugText(rate));
679 EchoCanceller3Tester(rate).RunAnalyzeRenderNumBandsCheckVerification();
680 }
681 }
682 703
683 TEST(EchoCanceller3InputCheck, WrongCaptureNumBandsCheckVerification) { 704 TEST(EchoCanceller3InputCheck, WrongCaptureNumBandsCheckVerification) {
684 for (auto rate : {8000, 16000, 32000, 48000}) { 705 for (auto rate : {8000, 16000, 32000, 48000}) {
685 SCOPED_TRACE(ProduceDebugText(rate)); 706 SCOPED_TRACE(ProduceDebugText(rate));
686 EchoCanceller3Tester(rate).RunProcessCaptureNumBandsCheckVerification(); 707 EchoCanceller3Tester(rate).RunProcessCaptureNumBandsCheckVerification();
687 } 708 }
688 } 709 }
689 710
690 TEST(EchoCanceller3InputCheck, WrongRenderFrameLengthCheckVerification) { 711 // TODO(peah): Re-enable the test once the issue with memory leaks during DEATH
712 // tests on test bots has been fixed.
713 TEST(EchoCanceller3InputCheck,
714 DISABLED_WrongRenderFrameLengthCheckVerification) {
691 for (auto rate : {8000, 16000}) { 715 for (auto rate : {8000, 16000}) {
692 SCOPED_TRACE(ProduceDebugText(rate)); 716 SCOPED_TRACE(ProduceDebugText(rate));
693 EchoCanceller3Tester(rate).RunAnalyzeRenderFrameLengthCheckVerification(); 717 EchoCanceller3Tester(rate).RunAnalyzeRenderFrameLengthCheckVerification();
694 } 718 }
695 } 719 }
696 720
697 TEST(EchoCanceller3InputCheck, WrongCaptureFrameLengthCheckVerification) { 721 TEST(EchoCanceller3InputCheck, WrongCaptureFrameLengthCheckVerification) {
698 for (auto rate : {8000, 16000}) { 722 for (auto rate : {8000, 16000}) {
699 SCOPED_TRACE(ProduceDebugText(rate)); 723 SCOPED_TRACE(ProduceDebugText(rate));
700 EchoCanceller3Tester(rate).RunProcessCaptureFrameLengthCheckVerification(); 724 EchoCanceller3Tester(rate).RunProcessCaptureFrameLengthCheckVerification();
(...skipping 20 matching lines...) Expand all
721 745
722 // Verifies the check for correct sample rate. 746 // Verifies the check for correct sample rate.
723 TEST(EchoCanceller3InputCheck, WrongSampleRate) { 747 TEST(EchoCanceller3InputCheck, WrongSampleRate) {
724 ApmDataDumper data_dumper(0); 748 ApmDataDumper data_dumper(0);
725 EXPECT_DEATH(EchoCanceller3(8001, false), ""); 749 EXPECT_DEATH(EchoCanceller3(8001, false), "");
726 } 750 }
727 751
728 #endif 752 #endif
729 753
730 } // namespace webrtc 754 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698