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

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: 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 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 <array>
14
15 #include "webrtc/modules/audio_processing/aec3/aec3_constants.h"
16 #include "webrtc/test/gtest.h"
17
18 namespace webrtc {
19
20 // Verifies that the switching between the signals in the output works as
21 // intended.
22 TEST(OutputSelector, ProperSwitching) {
23 OutputSelector selector;
24
25 constexpr int kNumBlocksToSwitch = 15;
26
27 std::array<float, kBlockSize> weaker;
28 std::array<float, kBlockSize> stronger;
29 std::array<float, kBlockSize> y;
30 std::array<float, kBlockSize> e;
31 weaker.fill(10.f);
32 stronger.fill(20.f);
33
34 bool y_is_weakest = false;
35
36 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.
37 if (y_equals_weaker) {
38 std::copy(weaker.begin(), weaker.end(), y.begin());
39 std::copy(stronger.begin(), stronger.end(), e.begin());
40 } else {
41 std::copy(stronger.begin(), stronger.end(), y.begin());
42 std::copy(weaker.begin(), weaker.end(), e.begin());
43 }
44 };
45
46 for (int k = 0; k < 30; ++k) {
47 // Verify that it takes a while for the signals transition to take effect.
48 for (int j = 0; j < kNumBlocksToSwitch; ++j) {
49 form_e_and_y(y_is_weakest);
50 selector.FormLinearOutput(e, y);
51 EXPECT_EQ(stronger, y);
52 EXPECT_EQ(selector.UseSubtractorOutput(), y_is_weakest);
53 }
54
55 // Verify that the transition block is a mix between the signals.
56 form_e_and_y(y_is_weakest);
57 selector.FormLinearOutput(e, y);
58 EXPECT_NE(weaker, y);
59 EXPECT_NE(stronger, y);
60 EXPECT_EQ(selector.UseSubtractorOutput(), !y_is_weakest);
61
62 y_is_weakest = !y_is_weakest;
63 }
64 }
65
66 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698