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

Side by Side Diff: webrtc/modules/audio_processing/aec3/residual_echo_estimator_unittest.cc

Issue 2678423005: Finalization of the first version of EchoCanceller 3 (Closed)
Patch Set: Fixed failing unittest 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/residual_echo_estimator.h"
12
13 #include "webrtc/base/random.h"
14 #include "webrtc/modules/audio_processing/aec3/aec_state.h"
15 #include "webrtc/modules/audio_processing/aec3/aec3_fft.h"
16 #include "webrtc/modules/audio_processing/test/echo_canceller_test_tools.h"
17 #include "webrtc/test/gtest.h"
18
19 namespace webrtc {
20 namespace {} // namespace
hlundin-webrtc 2017/02/21 16:34:02 Why?
peah-webrtc 2017/02/21 23:00:41 Done.
21
22 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
23
24 // Verifies that the check for non-null output gains works.
25 TEST(ResidualEchoEstimator, NullOutputGains) {
26 AecState aec_state;
27 FftBuffer X_buffer(Aec3Optimization::kNone, 10, std::vector<size_t>(1, 10));
28 std::vector<std::array<float, kFftLengthBy2Plus1>> H2;
29 std::array<float, kFftLengthBy2Plus1> E2_main;
30 std::array<float, kFftLengthBy2Plus1> E2_shadow;
31 std::array<float, kFftLengthBy2Plus1> S2_linear;
32 std::array<float, kFftLengthBy2Plus1> S2_fallback;
33 std::array<float, kFftLengthBy2Plus1> Y2;
34
35 EXPECT_DEATH(ResidualEchoEstimator().Estimate(true, aec_state, X_buffer, H2,
36 E2_main, E2_shadow, S2_linear,
37 S2_fallback, Y2, nullptr),
38 "");
39 }
40
41 #endif
42
43 TEST(ResidualEchoEstimator, BasicTest) {
44 ResidualEchoEstimator estimator;
45 AecState aec_state;
46 FftBuffer X_buffer(Aec3Optimization::kNone, 10, std::vector<size_t>(1, 10));
47 std::array<float, kFftLengthBy2Plus1> E2_main;
48 std::array<float, kFftLengthBy2Plus1> E2_shadow;
49 std::array<float, kFftLengthBy2Plus1> S2_linear;
50 std::array<float, kFftLengthBy2Plus1> S2_fallback;
51 std::array<float, kFftLengthBy2Plus1> Y2;
52 std::array<float, kFftLengthBy2Plus1> R2;
53 EchoPathVariability echo_path_variability(false, false);
54 std::array<float, kBlockSize> x;
55 std::vector<std::array<float, kFftLengthBy2Plus1>> H2(10);
56 Random random_generator(42U);
57 FftData X;
58 std::array<float, kBlockSize> x_old;
59 Aec3Fft fft;
60
61 for (auto& H2_k : H2) {
62 H2_k.fill(0.01f);
63 }
64 H2[2].fill(10.f);
65
66 constexpr float kLevel = 10.f;
67 E2_shadow.fill(kLevel);
68 E2_main.fill(kLevel);
69 S2_linear.fill(kLevel);
70 S2_fallback.fill(kLevel);
71 Y2.fill(kLevel);
72
73 for (int k = 0; k < 100; ++k) {
74 RandomizeSampleVector(&random_generator, x);
75 fft.PaddedFft(x, x_old, &X);
76 X_buffer.Insert(X);
77
78 aec_state.Update(H2, rtc::Optional<size_t>(2), X_buffer, E2_main, E2_shadow,
79 Y2, x, echo_path_variability, false);
80
81 estimator.Estimate(true, aec_state, X_buffer, H2, E2_main, E2_shadow,
82 S2_linear, S2_fallback, Y2, &R2);
83 }
84 std::for_each(R2.begin(), R2.end(),
85 [&](float a) { EXPECT_NEAR(kLevel, a, 0.1f); });
86 }
87
88 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698