OLD | NEW |
---|---|
(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 // Verifies that the correct ERL estimates are achieved. | |
18 TEST(ErlEstimator, Estimates) { | |
19 std::array<float, kFftLengthBy2Plus1> X2; | |
20 std::array<float, kFftLengthBy2Plus1> Y2; | |
21 | |
22 ErlEstimator estimator; | |
23 | |
24 // Verifies that the ERL estimate is properly reduced to lower values. | |
25 X2.fill(500 * 1000.f * 1000.f); | |
26 Y2.fill(10 * X2[0]); | |
27 for (size_t k = 0; k < 200; ++k) { | |
28 estimator.Update(X2, Y2); | |
29 } | |
30 { | |
ivoc
2017/02/10 13:52:34
These lines reoccur a few times, you can consider
peah-webrtc
2017/02/20 07:37:16
Good suggestion!
Done.
| |
31 const std::array<float, kFftLengthBy2Plus1>& erl = estimator.Erl(); | |
32 std::for_each(erl.begin(), erl.end(), | |
33 [](float a) { EXPECT_NEAR(10.f, a, 0.001); }); | |
34 } | |
35 | |
36 // Verifies that the ERL is not immediately increased when the ERL in the data | |
37 // increases. | |
38 Y2.fill(10000 * X2[0]); | |
39 for (size_t k = 0; k < 998; ++k) { | |
40 estimator.Update(X2, Y2); | |
41 } | |
42 { | |
43 const std::array<float, kFftLengthBy2Plus1>& erl = estimator.Erl(); | |
44 std::for_each(erl.begin(), erl.end(), | |
45 [](float a) { EXPECT_NEAR(10.f, a, 0.001); }); | |
46 } | |
47 | |
48 // Verifies that the rate of increase is 3 dB. | |
49 estimator.Update(X2, Y2); | |
50 { | |
51 const std::array<float, kFftLengthBy2Plus1>& erl = estimator.Erl(); | |
52 std::for_each(erl.begin(), erl.end(), | |
53 [](float a) { EXPECT_NEAR(20.f, a, 0.001); }); | |
54 } | |
55 | |
56 // Verifies that the maximum ERL is achieved when there are no low RLE | |
57 // estimates. | |
58 for (size_t k = 0; k < 1000; ++k) { | |
59 estimator.Update(X2, Y2); | |
60 } | |
61 { | |
62 const std::array<float, kFftLengthBy2Plus1>& erl = estimator.Erl(); | |
63 std::for_each(erl.begin(), erl.end(), | |
64 [](float a) { EXPECT_NEAR(1000.f, a, 0.001); }); | |
65 } | |
66 | |
67 // Verifies that the ERL estimate is is not updated for low-level signals | |
68 X2.fill(1000.f * 1000.f); | |
69 Y2.fill(10 * X2[0]); | |
70 for (size_t k = 0; k < 200; ++k) { | |
71 estimator.Update(X2, Y2); | |
72 } | |
73 { | |
74 const std::array<float, kFftLengthBy2Plus1>& erl = estimator.Erl(); | |
75 std::for_each(erl.begin(), erl.end(), | |
76 [](float a) { EXPECT_NEAR(1000.f, a, 0.001); }); | |
77 } | |
78 } | |
79 | |
80 } // namespace webrtc | |
OLD | NEW |