OLD | NEW |
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 Loading... |
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, &high_bands_gain, nullptr), | 36 1, false, &high_bands_gain, nullptr), |
37 ""); | 37 ""); |
38 } | 38 } |
39 | 39 |
40 #endif | 40 #endif |
41 | 41 |
42 #if defined(WEBRTC_ARCH_X86_FAMILY) | 42 #if defined(WEBRTC_ARCH_X86_FAMILY) |
43 // Verifies that the optimized methods are bitexact to their reference | 43 // Verifies that the optimized methods are bitexact to their reference |
44 // counterparts. | 44 // counterparts. |
45 TEST(SuppressionGain, TestOptimizations) { | 45 TEST(SuppressionGain, TestOptimizations) { |
46 if (WebRtc_GetCPUInfo(kSSE2) != 0) { | 46 if (WebRtc_GetCPUInfo(kSSE2) != 0) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 std::array<float, kFftLengthBy2Plus1> R2; | 121 std::array<float, kFftLengthBy2Plus1> R2; |
122 std::array<float, kFftLengthBy2Plus1> N2; | 122 std::array<float, kFftLengthBy2Plus1> N2; |
123 std::array<float, kFftLengthBy2Plus1> g; | 123 std::array<float, kFftLengthBy2Plus1> g; |
124 std::vector<std::vector<float>> x(1, std::vector<float>(kBlockSize, 0.f)); | 124 std::vector<std::vector<float>> x(1, std::vector<float>(kBlockSize, 0.f)); |
125 | 125 |
126 // Ensure that a strong noise is detected to mask any echoes. | 126 // Ensure that a strong noise is detected to mask any echoes. |
127 E2.fill(10.f); | 127 E2.fill(10.f); |
128 R2.fill(0.1f); | 128 R2.fill(0.1f); |
129 N2.fill(100.f); | 129 N2.fill(100.f); |
130 for (int k = 0; k < 10; ++k) { | 130 for (int k = 0; k < 10; ++k) { |
131 suppression_gain.GetGain(E2, R2, N2, false, x, 1, &high_bands_gain, &g); | 131 suppression_gain.GetGain(E2, R2, N2, false, x, 1, false, &high_bands_gain, |
| 132 &g); |
132 } | 133 } |
133 std::for_each(g.begin(), g.end(), | 134 std::for_each(g.begin(), g.end(), |
134 [](float a) { EXPECT_NEAR(1.f, a, 0.001); }); | 135 [](float a) { EXPECT_NEAR(1.f, a, 0.001); }); |
135 | 136 |
136 // Ensure that a strong nearend is detected to mask any echoes. | 137 // Ensure that a strong nearend is detected to mask any echoes. |
137 E2.fill(100.f); | 138 E2.fill(100.f); |
138 R2.fill(0.1f); | 139 R2.fill(0.1f); |
139 N2.fill(0.f); | 140 N2.fill(0.f); |
140 for (int k = 0; k < 10; ++k) { | 141 for (int k = 0; k < 10; ++k) { |
141 suppression_gain.GetGain(E2, R2, N2, false, x, 1, &high_bands_gain, &g); | 142 suppression_gain.GetGain(E2, R2, N2, false, x, 1, false, &high_bands_gain, |
| 143 &g); |
142 } | 144 } |
143 std::for_each(g.begin(), g.end(), | 145 std::for_each(g.begin(), g.end(), |
144 [](float a) { EXPECT_NEAR(1.f, a, 0.001); }); | 146 [](float a) { EXPECT_NEAR(1.f, a, 0.001); }); |
145 | 147 |
146 // Ensure that a strong echo is suppressed. | 148 // Ensure that a strong echo is suppressed. |
147 E2.fill(0.1f); | 149 E2.fill(0.1f); |
148 R2.fill(100.f); | 150 R2.fill(100.f); |
149 N2.fill(0.f); | 151 N2.fill(0.f); |
150 for (int k = 0; k < 10; ++k) { | 152 for (int k = 0; k < 10; ++k) { |
151 suppression_gain.GetGain(E2, R2, N2, false, x, 1, &high_bands_gain, &g); | 153 suppression_gain.GetGain(E2, R2, N2, false, x, 1, false, &high_bands_gain, |
| 154 &g); |
152 } | 155 } |
153 std::for_each(g.begin(), g.end(), | 156 std::for_each(g.begin(), g.end(), |
154 [](float a) { EXPECT_NEAR(0.f, a, 0.001); }); | 157 [](float a) { EXPECT_NEAR(0.f, a, 0.001); }); |
| 158 |
| 159 // Verify the functionality for forcing a zero gain. |
| 160 suppression_gain.GetGain(E2, R2, N2, false, x, 1, true, &high_bands_gain, &g); |
| 161 std::for_each(g.begin(), g.end(), [](float a) { EXPECT_FLOAT_EQ(0.f, a); }); |
| 162 EXPECT_FLOAT_EQ(0.f, high_bands_gain); |
155 } | 163 } |
156 | 164 |
157 } // namespace aec3 | 165 } // namespace aec3 |
158 } // namespace webrtc | 166 } // namespace webrtc |
OLD | NEW |