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

Unified Diff: webrtc/modules/audio_processing/aec3/output_selector_unittest.cc

Issue 2782423003: Major updates to the echo removal functionality in AEC3 (Closed)
Patch Set: Added initialization of uninitialized vector Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/aec3/output_selector_unittest.cc
diff --git a/webrtc/modules/audio_processing/aec3/output_selector_unittest.cc b/webrtc/modules/audio_processing/aec3/output_selector_unittest.cc
index 49f671d2b1edd6fc485856d32089777be9d0b580..717f631bae927fc712ead3d8b7032e4c5a087282 100644
--- a/webrtc/modules/audio_processing/aec3/output_selector_unittest.cc
+++ b/webrtc/modules/audio_processing/aec3/output_selector_unittest.cc
@@ -23,49 +23,47 @@ namespace webrtc {
TEST(OutputSelector, ProperSwitching) {
OutputSelector selector;
- constexpr int kNumBlocksToSwitchToSubtractor = 3;
- constexpr int kNumBlocksToSwitchFromSubtractor = 10;
-
- std::array<float, kBlockSize> weaker;
- std::array<float, kBlockSize> stronger;
std::array<float, kBlockSize> y;
std::array<float, kBlockSize> e;
- weaker.fill(10.f);
- stronger.fill(20.f);
+ std::array<float, kBlockSize> e_ref;
+ std::array<float, kBlockSize> y_ref;
+ auto init_blocks = [](std::array<float, kBlockSize>* e,
+ std::array<float, kBlockSize>* y) {
+ e->fill(10.f);
+ y->fill(20.f);
+ };
- bool y_is_weakest = false;
+ init_blocks(&e_ref, &y_ref);
- const auto form_e_and_y = [&](bool y_equals_weaker) {
- if (y_equals_weaker) {
- std::copy(weaker.begin(), weaker.end(), y.begin());
- std::copy(stronger.begin(), stronger.end(), e.begin());
- } else {
- std::copy(stronger.begin(), stronger.end(), y.begin());
- std::copy(weaker.begin(), weaker.end(), e.begin());
- }
- };
+ init_blocks(&e, &y);
+ selector.FormLinearOutput(false, e, y);
+ EXPECT_EQ(y_ref, y);
+
+ init_blocks(&e, &y);
+ selector.FormLinearOutput(true, e, y);
+ EXPECT_NE(e_ref, y);
+ EXPECT_NE(y_ref, y);
+
+ init_blocks(&e, &y);
+ selector.FormLinearOutput(true, e, y);
+ EXPECT_EQ(e_ref, y);
+
+ init_blocks(&e, &y);
+ selector.FormLinearOutput(true, e, y);
+ EXPECT_EQ(e_ref, y);
- for (int k = 0; k < 30; ++k) {
- // Verify that it takes a while for the signals transition to take effect.
- const int num_blocks_to_switch = y_is_weakest
- ? kNumBlocksToSwitchFromSubtractor
- : kNumBlocksToSwitchToSubtractor;
- for (int j = 0; j < num_blocks_to_switch; ++j) {
- form_e_and_y(y_is_weakest);
- selector.FormLinearOutput(e, y);
- EXPECT_EQ(stronger, y);
- EXPECT_EQ(y_is_weakest, selector.UseSubtractorOutput());
- }
+ init_blocks(&e, &y);
+ selector.FormLinearOutput(false, e, y);
+ EXPECT_NE(e_ref, y);
+ EXPECT_NE(y_ref, y);
- // Verify that the transition block is a mix between the signals.
- form_e_and_y(y_is_weakest);
- selector.FormLinearOutput(e, y);
- EXPECT_NE(weaker, y);
- EXPECT_NE(stronger, y);
- EXPECT_EQ(!y_is_weakest, selector.UseSubtractorOutput());
+ init_blocks(&e, &y);
+ selector.FormLinearOutput(false, e, y);
+ EXPECT_EQ(y_ref, y);
- y_is_weakest = !y_is_weakest;
- }
+ init_blocks(&e, &y);
+ selector.FormLinearOutput(false, e, y);
+ EXPECT_EQ(y_ref, y);
}
} // namespace webrtc
« no previous file with comments | « webrtc/modules/audio_processing/aec3/output_selector.cc ('k') | webrtc/modules/audio_processing/aec3/power_echo_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698