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

Side by Side Diff: webrtc/modules/audio_processing/aec3/suppression_gain_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
« no previous file with comments | « webrtc/modules/audio_processing/aec3/suppression_gain.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 15 matching lines...) Expand all
26 std::array<float, kFftLengthBy2Plus1> R2; 26 std::array<float, kFftLengthBy2Plus1> R2;
27 std::array<float, kFftLengthBy2Plus1> N2; 27 std::array<float, kFftLengthBy2Plus1> N2;
28 E2.fill(0.f); 28 E2.fill(0.f);
29 R2.fill(0.f); 29 R2.fill(0.f);
30 N2.fill(0.f); 30 N2.fill(0.f);
31 float high_bands_gain; 31 float high_bands_gain;
32 EXPECT_DEATH(SuppressionGain(DetectOptimization()) 32 EXPECT_DEATH(SuppressionGain(DetectOptimization())
33 .GetGain(E2, R2, N2, false, 33 .GetGain(E2, R2, N2, false,
34 std::vector<std::vector<float>>( 34 std::vector<std::vector<float>>(
35 3, std::vector<float>(kBlockSize, 0.f)), 35 3, std::vector<float>(kBlockSize, 0.f)),
36 1, false, &high_bands_gain, nullptr), 36 false, &high_bands_gain, nullptr),
37 ""); 37 "");
38 } 38 }
39 39
40 #endif 40 #endif
41 41
42 // Does a sanity check that the gains are correctly computed. 42 // Does a sanity check that the gains are correctly computed.
43 TEST(SuppressionGain, BasicGainComputation) { 43 TEST(SuppressionGain, BasicGainComputation) {
44 SuppressionGain suppression_gain(DetectOptimization()); 44 SuppressionGain suppression_gain(DetectOptimization());
45 float high_bands_gain; 45 float high_bands_gain;
46 std::array<float, kFftLengthBy2Plus1> E2; 46 std::array<float, kFftLengthBy2Plus1> E2;
47 std::array<float, kFftLengthBy2Plus1> R2; 47 std::array<float, kFftLengthBy2Plus1> R2;
48 std::array<float, kFftLengthBy2Plus1> N2; 48 std::array<float, kFftLengthBy2Plus1> N2;
49 std::array<float, kFftLengthBy2Plus1> g; 49 std::array<float, kFftLengthBy2Plus1> g;
50 std::vector<std::vector<float>> x(1, std::vector<float>(kBlockSize, 0.f)); 50 std::vector<std::vector<float>> x(1, std::vector<float>(kBlockSize, 0.f));
51 51
52 // Ensure that a strong noise is detected to mask any echoes. 52 // Ensure that a strong noise is detected to mask any echoes.
53 E2.fill(10.f); 53 E2.fill(10.f);
54 R2.fill(0.1f); 54 R2.fill(0.1f);
55 N2.fill(100.f); 55 N2.fill(100.f);
56 for (int k = 0; k < 10; ++k) { 56 for (int k = 0; k < 10; ++k) {
57 suppression_gain.GetGain(E2, R2, N2, false, x, 1, false, &high_bands_gain, 57 suppression_gain.GetGain(E2, R2, N2, false, x, false, &high_bands_gain, &g);
58 &g);
59 } 58 }
60 std::for_each(g.begin(), g.end(), 59 std::for_each(g.begin(), g.end(),
61 [](float a) { EXPECT_NEAR(1.f, a, 0.001); }); 60 [](float a) { EXPECT_NEAR(1.f, a, 0.001); });
62 61
63 // Ensure that a strong nearend is detected to mask any echoes. 62 // Ensure that a strong nearend is detected to mask any echoes.
64 E2.fill(100.f); 63 E2.fill(100.f);
65 R2.fill(0.1f); 64 R2.fill(0.1f);
66 N2.fill(0.f); 65 N2.fill(0.f);
67 for (int k = 0; k < 10; ++k) { 66 for (int k = 0; k < 10; ++k) {
68 suppression_gain.GetGain(E2, R2, N2, false, x, 1, false, &high_bands_gain, 67 suppression_gain.GetGain(E2, R2, N2, false, x, false, &high_bands_gain, &g);
69 &g);
70 } 68 }
71 std::for_each(g.begin(), g.end(), 69 std::for_each(g.begin(), g.end(),
72 [](float a) { EXPECT_NEAR(1.f, a, 0.001); }); 70 [](float a) { EXPECT_NEAR(1.f, a, 0.001); });
73 71
74 // Ensure that a strong echo is suppressed. 72 // Ensure that a strong echo is suppressed.
75 E2.fill(0.1f); 73 E2.fill(1000000000.f);
76 R2.fill(100.f); 74 R2.fill(10000000000000.f);
77 N2.fill(0.f); 75 N2.fill(0.f);
78 for (int k = 0; k < 10; ++k) { 76 for (int k = 0; k < 10; ++k) {
79 suppression_gain.GetGain(E2, R2, N2, false, x, 1, false, &high_bands_gain, 77 suppression_gain.GetGain(E2, R2, N2, false, x, false, &high_bands_gain, &g);
80 &g);
81 } 78 }
82 std::for_each(g.begin(), g.end(), 79 std::for_each(g.begin(), g.end(),
83 [](float a) { EXPECT_NEAR(0.f, a, 0.001); }); 80 [](float a) { EXPECT_NEAR(0.f, a, 0.001); });
84 81
85 // Verify the functionality for forcing a zero gain. 82 // Verify the functionality for forcing a zero gain.
86 suppression_gain.GetGain(E2, R2, N2, false, x, 1, true, &high_bands_gain, &g); 83 suppression_gain.GetGain(E2, R2, N2, false, x, true, &high_bands_gain, &g);
87 std::for_each(g.begin(), g.end(), [](float a) { EXPECT_FLOAT_EQ(0.f, a); }); 84 std::for_each(g.begin(), g.end(), [](float a) { EXPECT_FLOAT_EQ(0.f, a); });
88 EXPECT_FLOAT_EQ(0.f, high_bands_gain); 85 EXPECT_FLOAT_EQ(0.f, high_bands_gain);
89 } 86 }
90 87
91 } // namespace aec3 88 } // namespace aec3
92 } // namespace webrtc 89 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/aec3/suppression_gain.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698