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

Side by Side Diff: webrtc/modules/audio_processing/aec3/output_selector_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
(Empty)
1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/modules/audio_processing/aec3/output_selector.h"
12
13 #include <algorithm>
14 #include <array>
15
16 #include "webrtc/modules/audio_processing/aec3/aec3_common.h"
17 #include "webrtc/test/gtest.h"
18
19 namespace webrtc {
20
21 // Verifies that the switching between the signals in the output works as
22 // intended.
23 TEST(OutputSelector, ProperSwitching) {
24 OutputSelector selector;
25
26 constexpr int kNumBlocksToSwitchToSubtractor = 3;
27 constexpr int kNumBlocksToSwitchFromSubtractor = 10;
28
29 std::array<float, kBlockSize> weaker;
30 std::array<float, kBlockSize> stronger;
31 std::array<float, kBlockSize> y;
32 std::array<float, kBlockSize> e;
33 weaker.fill(10.f);
34 stronger.fill(20.f);
35
36 bool y_is_weakest = false;
37
38 const auto form_e_and_y = [&](bool y_equals_weaker) {
39 if (y_equals_weaker) {
40 std::copy(weaker.begin(), weaker.end(), y.begin());
41 std::copy(stronger.begin(), stronger.end(), e.begin());
42 } else {
43 std::copy(stronger.begin(), stronger.end(), y.begin());
44 std::copy(weaker.begin(), weaker.end(), e.begin());
45 }
46 };
47
48 for (int k = 0; k < 30; ++k) {
49 // Verify that it takes a while for the signals transition to take effect.
50 const int num_blocks_to_switch = y_is_weakest
51 ? kNumBlocksToSwitchFromSubtractor
52 : kNumBlocksToSwitchToSubtractor;
53 for (int j = 0; j < num_blocks_to_switch; ++j) {
54 form_e_and_y(y_is_weakest);
55 selector.FormLinearOutput(e, y);
56 EXPECT_EQ(stronger, y);
57 EXPECT_EQ(y_is_weakest, selector.UseSubtractorOutput());
58 }
59
60 // Verify that the transition block is a mix between the signals.
61 form_e_and_y(y_is_weakest);
62 selector.FormLinearOutput(e, y);
63 EXPECT_NE(weaker, y);
64 EXPECT_NE(stronger, y);
65 EXPECT_EQ(!y_is_weakest, selector.UseSubtractorOutput());
66
67 y_is_weakest = !y_is_weakest;
68 }
69 }
70
71 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698