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

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

Issue 2886733002: Transparency increasing tuning for AEC3 (Closed)
Patch Set: Fixed memory issue Created 3 years, 7 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
1 /* 1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/audio_processing/aec3/erle_estimator.h" 11 #include "webrtc/modules/audio_processing/aec3/erle_estimator.h"
12 #include "webrtc/test/gtest.h" 12 #include "webrtc/test/gtest.h"
13 13
14 namespace webrtc { 14 namespace webrtc {
15 15
16 namespace { 16 namespace {
17 17
18 constexpr int kLowFrequencyLimit = kFftLengthBy2 / 2;
19
18 void VerifyErle(const std::array<float, kFftLengthBy2Plus1>& erle, 20 void VerifyErle(const std::array<float, kFftLengthBy2Plus1>& erle,
19 float reference) { 21 float reference_lf,
20 std::for_each(erle.begin(), erle.end(), 22 float reference_hf) {
21 [reference](float a) { EXPECT_NEAR(reference, a, 0.001); }); 23 std::for_each(
24 erle.begin(), erle.begin() + kLowFrequencyLimit,
25 [reference_lf](float a) { EXPECT_NEAR(reference_lf, a, 0.001); });
26 std::for_each(
27 erle.begin() + kLowFrequencyLimit, erle.end(),
28 [reference_hf](float a) { EXPECT_NEAR(reference_hf, a, 0.001); });
22 } 29 }
23 30
24 } // namespace 31 } // namespace
25 32
26 // Verifies that the correct ERLE estimates are achieved. 33 // Verifies that the correct ERLE estimates are achieved.
27 TEST(ErleEstimator, Estimates) { 34 TEST(ErleEstimator, Estimates) {
28 std::array<float, kFftLengthBy2Plus1> X2; 35 std::array<float, kFftLengthBy2Plus1> X2;
29 std::array<float, kFftLengthBy2Plus1> E2; 36 std::array<float, kFftLengthBy2Plus1> E2;
30 std::array<float, kFftLengthBy2Plus1> Y2; 37 std::array<float, kFftLengthBy2Plus1> Y2;
31 38
32 ErleEstimator estimator; 39 ErleEstimator estimator;
33 40
34 // Verifies that the ERLE estimate is properley increased to higher values. 41 // Verifies that the ERLE estimate is properley increased to higher values.
35 X2.fill(500 * 1000.f * 1000.f); 42 X2.fill(500 * 1000.f * 1000.f);
36 E2.fill(1000.f * 1000.f); 43 E2.fill(1000.f * 1000.f);
37 Y2.fill(10 * E2[0]); 44 Y2.fill(10 * E2[0]);
38 for (size_t k = 0; k < 200; ++k) { 45 for (size_t k = 0; k < 200; ++k) {
39 estimator.Update(X2, Y2, E2); 46 estimator.Update(X2, Y2, E2);
40 } 47 }
41 VerifyErle(estimator.Erle(), 8.f); 48 VerifyErle(estimator.Erle(), 8.f, 1.5f);
42 49
43 // Verifies that the ERLE is not immediately decreased when the ERLE in the 50 // Verifies that the ERLE is not immediately decreased when the ERLE in the
44 // data decreases. 51 // data decreases.
45 Y2.fill(0.1f * E2[0]); 52 Y2.fill(0.1f * E2[0]);
46 for (size_t k = 0; k < 98; ++k) { 53 for (size_t k = 0; k < 98; ++k) {
47 estimator.Update(X2, Y2, E2); 54 estimator.Update(X2, Y2, E2);
48 } 55 }
49 VerifyErle(estimator.Erle(), 8.f); 56 VerifyErle(estimator.Erle(), 8.f, 1.5f);
50 57
51 // Verifies that the minimum ERLE is eventually achieved. 58 // Verifies that the minimum ERLE is eventually achieved.
52 for (size_t k = 0; k < 1000; ++k) { 59 for (size_t k = 0; k < 1000; ++k) {
53 estimator.Update(X2, Y2, E2); 60 estimator.Update(X2, Y2, E2);
54 } 61 }
55 VerifyErle(estimator.Erle(), 1.f); 62 VerifyErle(estimator.Erle(), 1.f, 1.f);
56 63
57 // Verifies that the ERLE estimate is is not updated for low-level render 64 // Verifies that the ERLE estimate is is not updated for low-level render
58 // signals. 65 // signals.
59 X2.fill(1000.f * 1000.f); 66 X2.fill(1000.f * 1000.f);
60 Y2.fill(10 * E2[0]); 67 Y2.fill(10 * E2[0]);
61 for (size_t k = 0; k < 200; ++k) { 68 for (size_t k = 0; k < 200; ++k) {
62 estimator.Update(X2, Y2, E2); 69 estimator.Update(X2, Y2, E2);
63 } 70 }
64 VerifyErle(estimator.Erle(), 1.f); 71 VerifyErle(estimator.Erle(), 1.f, 1.f);
65 } 72 }
66 } // namespace webrtc 73 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/aec3/erle_estimator.cc ('k') | webrtc/modules/audio_processing/aec3/suppression_gain.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698