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

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

Issue 2678423005: Finalization of the first version of EchoCanceller 3 (Closed)
Patch Set: Created 3 years, 10 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
new file mode 100644
index 0000000000000000000000000000000000000000..8890e19a8fa7e7d7fb68c784eb7eae1077bb5054
--- /dev/null
+++ b/webrtc/modules/audio_processing/aec3/output_selector_unittest.cc
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/modules/audio_processing/aec3/output_selector.h"
+
+#include <array>
+
+#include "webrtc/modules/audio_processing/aec3/aec3_constants.h"
+#include "webrtc/test/gtest.h"
+
+namespace webrtc {
+
+// Verifies that the switching between the signals in the output works as
+// intended.
+TEST(OutputSelector, ProperSwitching) {
+ OutputSelector selector;
+
+ constexpr int kNumBlocksToSwitch = 15;
+
+ 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);
+
+ bool y_is_weakest = false;
+
+ auto form_e_and_y = [&](bool y_equals_weaker) {
aleloi 2017/02/13 16:44:51 const auto
peah-webrtc 2017/02/20 07:37:17 Done.
+ 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());
+ }
+ };
+
+ for (int k = 0; k < 30; ++k) {
+ // Verify that it takes a while for the signals transition to take effect.
+ for (int j = 0; j < kNumBlocksToSwitch; ++j) {
+ form_e_and_y(y_is_weakest);
+ selector.FormLinearOutput(e, y);
+ EXPECT_EQ(stronger, y);
+ EXPECT_EQ(selector.UseSubtractorOutput(), y_is_weakest);
+ }
+
+ // 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(selector.UseSubtractorOutput(), !y_is_weakest);
+
+ y_is_weakest = !y_is_weakest;
+ }
+}
+
+} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698