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/erle_estimator.h" | |
12 #include "webrtc/test/gtest.h" | |
13 | |
14 namespace webrtc { | |
15 | |
16 // Verifies that the correct ERLE estimates are achieved. | |
17 TEST(ErleEstimator, Estimates) { | |
18 std::array<float, kFftLengthBy2Plus1> X2; | |
19 std::array<float, kFftLengthBy2Plus1> E2; | |
20 std::array<float, kFftLengthBy2Plus1> Y2; | |
21 | |
22 ErleEstimator estimator; | |
23 | |
24 // Verifies that the ERLE estimate is properley increased to higher values. | |
25 X2.fill(500 * 1000.f * 1000.f); | |
26 E2.fill(1000.f * 1000.f); | |
27 Y2.fill(10 * E2[0]); | |
28 for (size_t k = 0; k < 200; ++k) { | |
29 estimator.Update(X2, Y2, E2); | |
30 } | |
31 { | |
ivoc
2017/02/10 13:52:35
These lines reoccur a few times, it might be a goo
peah-webrtc
2017/02/20 07:37:17
Done.
| |
32 const std::array<float, kFftLengthBy2Plus1>& erle = estimator.Erle(); | |
33 std::for_each(erle.begin(), erle.end(), | |
34 [](float a) { EXPECT_NEAR(8.f, a, 0.001); }); | |
35 } | |
36 | |
37 // Verifies that the ERLE is not immediately decreased when the ERLE in the | |
38 // data decreases. | |
39 Y2.fill(0.1f * E2[0]); | |
40 for (size_t k = 0; k < 148; ++k) { | |
41 estimator.Update(X2, Y2, E2); | |
42 } | |
43 { | |
44 const std::array<float, kFftLengthBy2Plus1>& erle = estimator.Erle(); | |
45 std::for_each(erle.begin(), erle.end(), | |
46 [](float a) { EXPECT_NEAR(8.f, a, 0.001); }); | |
47 } | |
48 | |
49 // Verifies that the minimum ERLE is eventually achieved. | |
50 for (size_t k = 0; k < 1000; ++k) { | |
51 estimator.Update(X2, Y2, E2); | |
52 } | |
53 { | |
54 const std::array<float, kFftLengthBy2Plus1>& erle = estimator.Erle(); | |
55 std::for_each(erle.begin(), erle.end(), | |
56 [](float a) { EXPECT_NEAR(1.f, a, 0.001); }); | |
57 } | |
58 | |
59 // Verifies that the ERLE estimate is is not updated for low-level render | |
60 // signals. | |
61 X2.fill(1000.f * 1000.f); | |
62 Y2.fill(10 * E2[0]); | |
63 for (size_t k = 0; k < 200; ++k) { | |
64 estimator.Update(X2, Y2, E2); | |
65 } | |
66 { | |
67 const std::array<float, kFftLengthBy2Plus1>& erle = estimator.Erle(); | |
68 std::for_each(erle.begin(), erle.end(), | |
69 [](float a) { EXPECT_NEAR(1.f, a, 0.001); }); | |
70 } | |
71 } | |
72 } // namespace webrtc | |
OLD | NEW |