| OLD | NEW |
| 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 |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 aec3.ProcessCapture(&capture_buffer_, false); | 488 aec3.ProcessCapture(&capture_buffer_, false); |
| 489 EXPECT_TRUE(VerifyOutputFrameBitexactness( | 489 EXPECT_TRUE(VerifyOutputFrameBitexactness( |
| 490 frame_length_, num_bands_, frame_index, | 490 frame_length_, num_bands_, frame_index, |
| 491 &capture_buffer_.split_bands_f(0)[0], -64)); | 491 &capture_buffer_.split_bands_f(0)[0], -64)); |
| 492 } | 492 } |
| 493 } | 493 } |
| 494 | 494 |
| 495 // This test verifies that a buffer overrun in the render swapqueue is | 495 // This test verifies that a buffer overrun in the render swapqueue is |
| 496 // properly reported. | 496 // properly reported. |
| 497 void RunRenderPipelineSwapQueueOverrunReturnValueTest() { | 497 void RunRenderPipelineSwapQueueOverrunReturnValueTest() { |
| 498 EchoCanceller3 aec3(sample_rate_hz_, false); | 498 EchoCanceller3 aec3(AudioProcessing::Config::EchoCanceller3(), |
| 499 sample_rate_hz_, false); |
| 499 | 500 |
| 500 constexpr size_t kRenderTransferQueueSize = 30; | 501 constexpr size_t kRenderTransferQueueSize = 30; |
| 501 for (size_t k = 0; k < 2; ++k) { | 502 for (size_t k = 0; k < 2; ++k) { |
| 502 for (size_t frame_index = 0; frame_index < kRenderTransferQueueSize; | 503 for (size_t frame_index = 0; frame_index < kRenderTransferQueueSize; |
| 503 ++frame_index) { | 504 ++frame_index) { |
| 504 if (sample_rate_hz_ > 16000) { | 505 if (sample_rate_hz_ > 16000) { |
| 505 render_buffer_.SplitIntoFrequencyBands(); | 506 render_buffer_.SplitIntoFrequencyBands(); |
| 506 } | 507 } |
| 507 PopulateInputFrame(frame_length_, frame_index, | 508 PopulateInputFrame(frame_length_, frame_index, |
| 508 &render_buffer_.channels_f()[0][0], 0); | 509 &render_buffer_.channels_f()[0][0], 0); |
| 509 | 510 |
| 510 if (k == 0) { | 511 if (k == 0) { |
| 511 aec3.AnalyzeRender(&render_buffer_); | 512 aec3.AnalyzeRender(&render_buffer_); |
| 512 } else { | 513 } else { |
| 513 aec3.AnalyzeRender(&render_buffer_); | 514 aec3.AnalyzeRender(&render_buffer_); |
| 514 } | 515 } |
| 515 } | 516 } |
| 516 } | 517 } |
| 517 } | 518 } |
| 518 | 519 |
| 519 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) | 520 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
| 520 // Verifies the that the check for the number of bands in the AnalyzeRender | 521 // Verifies the that the check for the number of bands in the AnalyzeRender |
| 521 // input is correct by adjusting the sample rates of EchoCanceller3 and the | 522 // input is correct by adjusting the sample rates of EchoCanceller3 and the |
| 522 // input AudioBuffer to have a different number of bands. | 523 // input AudioBuffer to have a different number of bands. |
| 523 void RunAnalyzeRenderNumBandsCheckVerification() { | 524 void RunAnalyzeRenderNumBandsCheckVerification() { |
| 524 // Set aec3_sample_rate_hz to be different from sample_rate_hz_ in such a | 525 // Set aec3_sample_rate_hz to be different from sample_rate_hz_ in such a |
| 525 // way that the number of bands for the rates are different. | 526 // way that the number of bands for the rates are different. |
| 526 const int aec3_sample_rate_hz = sample_rate_hz_ == 48000 ? 32000 : 48000; | 527 const int aec3_sample_rate_hz = sample_rate_hz_ == 48000 ? 32000 : 48000; |
| 527 EchoCanceller3 aec3(aec3_sample_rate_hz, false); | 528 EchoCanceller3 aec3(AudioProcessing::Config::EchoCanceller3(), |
| 529 aec3_sample_rate_hz, false); |
| 528 PopulateInputFrame(frame_length_, 0, &render_buffer_.channels_f()[0][0], 0); | 530 PopulateInputFrame(frame_length_, 0, &render_buffer_.channels_f()[0][0], 0); |
| 529 | 531 |
| 530 EXPECT_DEATH(aec3.AnalyzeRender(&render_buffer_), ""); | 532 EXPECT_DEATH(aec3.AnalyzeRender(&render_buffer_), ""); |
| 531 } | 533 } |
| 532 | 534 |
| 533 // Verifies the that the check for the number of bands in the ProcessCapture | 535 // Verifies the that the check for the number of bands in the ProcessCapture |
| 534 // input is correct by adjusting the sample rates of EchoCanceller3 and the | 536 // input is correct by adjusting the sample rates of EchoCanceller3 and the |
| 535 // input AudioBuffer to have a different number of bands. | 537 // input AudioBuffer to have a different number of bands. |
| 536 void RunProcessCaptureNumBandsCheckVerification() { | 538 void RunProcessCaptureNumBandsCheckVerification() { |
| 537 // Set aec3_sample_rate_hz to be different from sample_rate_hz_ in such a | 539 // Set aec3_sample_rate_hz to be different from sample_rate_hz_ in such a |
| 538 // way that the number of bands for the rates are different. | 540 // way that the number of bands for the rates are different. |
| 539 const int aec3_sample_rate_hz = sample_rate_hz_ == 48000 ? 32000 : 48000; | 541 const int aec3_sample_rate_hz = sample_rate_hz_ == 48000 ? 32000 : 48000; |
| 540 EchoCanceller3 aec3(aec3_sample_rate_hz, false); | 542 EchoCanceller3 aec3(AudioProcessing::Config::EchoCanceller3(), |
| 543 aec3_sample_rate_hz, false); |
| 541 PopulateInputFrame(frame_length_, num_bands_, 0, | 544 PopulateInputFrame(frame_length_, num_bands_, 0, |
| 542 &capture_buffer_.split_bands_f(0)[0], 100); | 545 &capture_buffer_.split_bands_f(0)[0], 100); |
| 543 EXPECT_DEATH(aec3.ProcessCapture(&capture_buffer_, false), ""); | 546 EXPECT_DEATH(aec3.ProcessCapture(&capture_buffer_, false), ""); |
| 544 } | 547 } |
| 545 | 548 |
| 546 // Verifies the that the check for the frame length in the AnalyzeRender input | 549 // Verifies the that the check for the frame length in the AnalyzeRender input |
| 547 // is correct by adjusting the sample rates of EchoCanceller3 and the input | 550 // is correct by adjusting the sample rates of EchoCanceller3 and the input |
| 548 // AudioBuffer to have a different frame lengths. | 551 // AudioBuffer to have a different frame lengths. |
| 549 void RunAnalyzeRenderFrameLengthCheckVerification() { | 552 void RunAnalyzeRenderFrameLengthCheckVerification() { |
| 550 // Set aec3_sample_rate_hz to be different from sample_rate_hz_ in such a | 553 // Set aec3_sample_rate_hz to be different from sample_rate_hz_ in such a |
| 551 // way that the band frame lengths are different. | 554 // way that the band frame lengths are different. |
| 552 const int aec3_sample_rate_hz = sample_rate_hz_ == 8000 ? 16000 : 8000; | 555 const int aec3_sample_rate_hz = sample_rate_hz_ == 8000 ? 16000 : 8000; |
| 553 EchoCanceller3 aec3(aec3_sample_rate_hz, false); | 556 EchoCanceller3 aec3(AudioProcessing::Config::EchoCanceller3(), |
| 557 aec3_sample_rate_hz, false); |
| 554 | 558 |
| 555 OptionalBandSplit(); | 559 OptionalBandSplit(); |
| 556 PopulateInputFrame(frame_length_, 0, &render_buffer_.channels_f()[0][0], 0); | 560 PopulateInputFrame(frame_length_, 0, &render_buffer_.channels_f()[0][0], 0); |
| 557 | 561 |
| 558 EXPECT_DEATH(aec3.AnalyzeRender(&render_buffer_), ""); | 562 EXPECT_DEATH(aec3.AnalyzeRender(&render_buffer_), ""); |
| 559 } | 563 } |
| 560 | 564 |
| 561 // Verifies the that the check for the frame length in the AnalyzeRender input | 565 // Verifies the that the check for the frame length in the AnalyzeRender input |
| 562 // is correct by adjusting the sample rates of EchoCanceller3 and the input | 566 // is correct by adjusting the sample rates of EchoCanceller3 and the input |
| 563 // AudioBuffer to have a different frame lengths. | 567 // AudioBuffer to have a different frame lengths. |
| 564 void RunProcessCaptureFrameLengthCheckVerification() { | 568 void RunProcessCaptureFrameLengthCheckVerification() { |
| 565 // Set aec3_sample_rate_hz to be different from sample_rate_hz_ in such a | 569 // Set aec3_sample_rate_hz to be different from sample_rate_hz_ in such a |
| 566 // way that the band frame lengths are different. | 570 // way that the band frame lengths are different. |
| 567 const int aec3_sample_rate_hz = sample_rate_hz_ == 8000 ? 16000 : 8000; | 571 const int aec3_sample_rate_hz = sample_rate_hz_ == 8000 ? 16000 : 8000; |
| 568 EchoCanceller3 aec3(aec3_sample_rate_hz, false); | 572 EchoCanceller3 aec3(AudioProcessing::Config::EchoCanceller3(), |
| 573 aec3_sample_rate_hz, false); |
| 569 | 574 |
| 570 OptionalBandSplit(); | 575 OptionalBandSplit(); |
| 571 PopulateInputFrame(frame_length_, num_bands_, 0, | 576 PopulateInputFrame(frame_length_, num_bands_, 0, |
| 572 &capture_buffer_.split_bands_f(0)[0], 100); | 577 &capture_buffer_.split_bands_f(0)[0], 100); |
| 573 | 578 |
| 574 EXPECT_DEATH(aec3.ProcessCapture(&capture_buffer_, false), ""); | 579 EXPECT_DEATH(aec3.ProcessCapture(&capture_buffer_, false), ""); |
| 575 } | 580 } |
| 576 | 581 |
| 577 #endif | 582 #endif |
| 578 | 583 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 EchoCanceller3Tester::EchoLeakageTestVariant::kTrueSticky, | 675 EchoCanceller3Tester::EchoLeakageTestVariant::kTrueSticky, |
| 671 EchoCanceller3Tester::EchoLeakageTestVariant::kTrueNonSticky}; | 676 EchoCanceller3Tester::EchoLeakageTestVariant::kTrueNonSticky}; |
| 672 for (auto rate : {8000, 16000, 32000, 48000}) { | 677 for (auto rate : {8000, 16000, 32000, 48000}) { |
| 673 for (auto variant : variants) { | 678 for (auto variant : variants) { |
| 674 SCOPED_TRACE(ProduceDebugText(rate, static_cast<int>(variant))); | 679 SCOPED_TRACE(ProduceDebugText(rate, static_cast<int>(variant))); |
| 675 EchoCanceller3Tester(rate).RunEchoLeakageVerificationTest(variant); | 680 EchoCanceller3Tester(rate).RunEchoLeakageVerificationTest(variant); |
| 676 } | 681 } |
| 677 } | 682 } |
| 678 } | 683 } |
| 679 | 684 |
| 685 TEST(EchoCanceller3, ConfigValidation) { |
| 686 AudioProcessing::Config::EchoCanceller3 config; |
| 687 |
| 688 config.echo_decay = 0.f; |
| 689 EXPECT_TRUE(EchoCanceller3::Validate(config)); |
| 690 config.echo_decay = 0.9f; |
| 691 EXPECT_TRUE(EchoCanceller3::Validate(config)); |
| 692 config.echo_decay = -0.1f; |
| 693 EXPECT_FALSE(EchoCanceller3::Validate(config)); |
| 694 config.echo_decay = 1.0f; |
| 695 EXPECT_FALSE(EchoCanceller3::Validate(config)); |
| 696 config.echo_decay = 1.1f; |
| 697 EXPECT_FALSE(EchoCanceller3::Validate(config)); |
| 698 } |
| 699 |
| 680 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) | 700 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
| 681 | 701 |
| 682 TEST(EchoCanceller3InputCheck, WrongCaptureNumBandsCheckVerification) { | 702 TEST(EchoCanceller3InputCheck, WrongCaptureNumBandsCheckVerification) { |
| 683 for (auto rate : {8000, 16000, 32000, 48000}) { | 703 for (auto rate : {8000, 16000, 32000, 48000}) { |
| 684 SCOPED_TRACE(ProduceDebugText(rate)); | 704 SCOPED_TRACE(ProduceDebugText(rate)); |
| 685 EchoCanceller3Tester(rate).RunProcessCaptureNumBandsCheckVerification(); | 705 EchoCanceller3Tester(rate).RunProcessCaptureNumBandsCheckVerification(); |
| 686 } | 706 } |
| 687 } | 707 } |
| 688 | 708 |
| 689 // TODO(peah): Re-enable the test once the issue with memory leaks during DEATH | 709 // TODO(peah): Re-enable the test once the issue with memory leaks during DEATH |
| 690 // tests on test bots has been fixed. | 710 // tests on test bots has been fixed. |
| 691 TEST(EchoCanceller3InputCheck, | 711 TEST(EchoCanceller3InputCheck, |
| 692 DISABLED_WrongRenderFrameLengthCheckVerification) { | 712 DISABLED_WrongRenderFrameLengthCheckVerification) { |
| 693 for (auto rate : {8000, 16000}) { | 713 for (auto rate : {8000, 16000}) { |
| 694 SCOPED_TRACE(ProduceDebugText(rate)); | 714 SCOPED_TRACE(ProduceDebugText(rate)); |
| 695 EchoCanceller3Tester(rate).RunAnalyzeRenderFrameLengthCheckVerification(); | 715 EchoCanceller3Tester(rate).RunAnalyzeRenderFrameLengthCheckVerification(); |
| 696 } | 716 } |
| 697 } | 717 } |
| 698 | 718 |
| 699 TEST(EchoCanceller3InputCheck, WrongCaptureFrameLengthCheckVerification) { | 719 TEST(EchoCanceller3InputCheck, WrongCaptureFrameLengthCheckVerification) { |
| 700 for (auto rate : {8000, 16000}) { | 720 for (auto rate : {8000, 16000}) { |
| 701 SCOPED_TRACE(ProduceDebugText(rate)); | 721 SCOPED_TRACE(ProduceDebugText(rate)); |
| 702 EchoCanceller3Tester(rate).RunProcessCaptureFrameLengthCheckVerification(); | 722 EchoCanceller3Tester(rate).RunProcessCaptureFrameLengthCheckVerification(); |
| 703 } | 723 } |
| 704 } | 724 } |
| 705 | 725 |
| 706 // Verifiers that the verification for null input to the render analysis api | 726 // Verifiers that the verification for null input to the render analysis api |
| 707 // call works. | 727 // call works. |
| 708 TEST(EchoCanceller3InputCheck, NullRenderAnalysisParameter) { | 728 TEST(EchoCanceller3InputCheck, NullRenderAnalysisParameter) { |
| 709 EXPECT_DEATH(EchoCanceller3(8000, false).AnalyzeRender(nullptr), ""); | 729 EXPECT_DEATH( |
| 730 EchoCanceller3(AudioProcessing::Config::EchoCanceller3(), 8000, false) |
| 731 .AnalyzeRender(nullptr), |
| 732 ""); |
| 710 } | 733 } |
| 711 | 734 |
| 712 // Verifiers that the verification for null input to the capture analysis api | 735 // Verifiers that the verification for null input to the capture analysis api |
| 713 // call works. | 736 // call works. |
| 714 TEST(EchoCanceller3InputCheck, NullCaptureAnalysisParameter) { | 737 TEST(EchoCanceller3InputCheck, NullCaptureAnalysisParameter) { |
| 715 EXPECT_DEATH(EchoCanceller3(8000, false).AnalyzeCapture(nullptr), ""); | 738 EXPECT_DEATH( |
| 739 EchoCanceller3(AudioProcessing::Config::EchoCanceller3(), 8000, false) |
| 740 .AnalyzeCapture(nullptr), |
| 741 ""); |
| 716 } | 742 } |
| 717 | 743 |
| 718 // Verifiers that the verification for null input to the capture processing api | 744 // Verifiers that the verification for null input to the capture processing api |
| 719 // call works. | 745 // call works. |
| 720 TEST(EchoCanceller3InputCheck, NullCaptureProcessingParameter) { | 746 TEST(EchoCanceller3InputCheck, NullCaptureProcessingParameter) { |
| 721 EXPECT_DEATH(EchoCanceller3(8000, false).ProcessCapture(nullptr, false), ""); | 747 EXPECT_DEATH( |
| 748 EchoCanceller3(AudioProcessing::Config::EchoCanceller3(), 8000, false) |
| 749 .ProcessCapture(nullptr, false), |
| 750 ""); |
| 722 } | 751 } |
| 723 | 752 |
| 724 // Verifies the check for correct sample rate. | 753 // Verifies the check for correct sample rate. |
| 725 // TODO(peah): Re-enable the test once the issue with memory leaks during DEATH | 754 // TODO(peah): Re-enable the test once the issue with memory leaks during DEATH |
| 726 // tests on test bots has been fixed. | 755 // tests on test bots has been fixed. |
| 727 TEST(EchoCanceller3InputCheck, DISABLED_WrongSampleRate) { | 756 TEST(EchoCanceller3InputCheck, DISABLED_WrongSampleRate) { |
| 728 ApmDataDumper data_dumper(0); | 757 ApmDataDumper data_dumper(0); |
| 729 EXPECT_DEATH(EchoCanceller3(8001, false), ""); | 758 EXPECT_DEATH( |
| 759 EchoCanceller3(AudioProcessing::Config::EchoCanceller3(), 8001, false), |
| 760 ""); |
| 730 } | 761 } |
| 731 | 762 |
| 732 #endif | 763 #endif |
| 733 | 764 |
| 734 } // namespace webrtc | 765 } // namespace webrtc |
| OLD | NEW |