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

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

Powered by Google App Engine
This is Rietveld 408576698