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

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

Issue 2678423005: Finalization of the first version of EchoCanceller 3 (Closed)
Patch Set: Fixed compilation error 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/erl_estimator.h"
12
13 #include "webrtc/test/gtest.h"
14
15 namespace webrtc {
16
17 namespace {
18
19 void VerifyErl(const std::array<float, kFftLengthBy2Plus1>& erl,
20 float reference) {
21 std::for_each(erl.begin(), erl.end(),
22 [reference](float a) { EXPECT_NEAR(reference, a, 0.001); });
23 }
24
25 } // namespace
26
27 // Verifies that the correct ERL estimates are achieved.
28 TEST(ErlEstimator, Estimates) {
29 std::array<float, kFftLengthBy2Plus1> X2;
30 std::array<float, kFftLengthBy2Plus1> Y2;
31
32 ErlEstimator estimator;
33
34 // Verifies that the ERL estimate is properly reduced to lower values.
35 X2.fill(500 * 1000.f * 1000.f);
36 Y2.fill(10 * X2[0]);
37 for (size_t k = 0; k < 200; ++k) {
38 estimator.Update(X2, Y2);
39 }
40 VerifyErl(estimator.Erl(), 10.f);
41
42 // Verifies that the ERL is not immediately increased when the ERL in the data
43 // increases.
44 Y2.fill(10000 * X2[0]);
45 for (size_t k = 0; k < 998; ++k) {
46 estimator.Update(X2, Y2);
47 }
48 VerifyErl(estimator.Erl(), 10.f);
49
50 // Verifies that the rate of increase is 3 dB.
51 estimator.Update(X2, Y2);
52 VerifyErl(estimator.Erl(), 20.f);
53
54 // Verifies that the maximum ERL is achieved when there are no low RLE
55 // estimates.
56 for (size_t k = 0; k < 1000; ++k) {
57 estimator.Update(X2, Y2);
58 }
59 VerifyErl(estimator.Erl(), 1000.f);
60
61 // Verifies that the ERL estimate is is not updated for low-level signals
62 X2.fill(1000.f * 1000.f);
63 Y2.fill(10 * X2[0]);
64 for (size_t k = 0; k < 200; ++k) {
65 estimator.Update(X2, Y2);
66 }
67 VerifyErl(estimator.Erl(), 1000.f);
68 }
69
70 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698