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 18 matching lines...) Expand all Loading... |
29 } | 29 } |
30 | 30 |
31 } // namespace | 31 } // namespace |
32 | 32 |
33 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) | 33 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
34 | 34 |
35 TEST(ComfortNoiseGenerator, NullLowerBandNoise) { | 35 TEST(ComfortNoiseGenerator, NullLowerBandNoise) { |
36 std::array<float, kFftLengthBy2Plus1> N2; | 36 std::array<float, kFftLengthBy2Plus1> N2; |
37 FftData noise; | 37 FftData noise; |
38 EXPECT_DEATH(ComfortNoiseGenerator(DetectOptimization()) | 38 EXPECT_DEATH(ComfortNoiseGenerator(DetectOptimization()) |
39 .Compute(AecState(0.f), N2, nullptr, &noise), | 39 .Compute(AecState(AudioProcessing::Config::EchoCanceller3{}), |
| 40 N2, nullptr, &noise), |
40 ""); | 41 ""); |
41 } | 42 } |
42 | 43 |
43 TEST(ComfortNoiseGenerator, NullUpperBandNoise) { | 44 TEST(ComfortNoiseGenerator, NullUpperBandNoise) { |
44 std::array<float, kFftLengthBy2Plus1> N2; | 45 std::array<float, kFftLengthBy2Plus1> N2; |
45 FftData noise; | 46 FftData noise; |
46 EXPECT_DEATH(ComfortNoiseGenerator(DetectOptimization()) | 47 EXPECT_DEATH(ComfortNoiseGenerator(DetectOptimization()) |
47 .Compute(AecState(0.f), N2, &noise, nullptr), | 48 .Compute(AecState(AudioProcessing::Config::EchoCanceller3{}), |
| 49 N2, &noise, nullptr), |
48 ""); | 50 ""); |
49 } | 51 } |
50 | 52 |
51 #endif | 53 #endif |
52 | 54 |
53 #if defined(WEBRTC_ARCH_X86_FAMILY) | 55 #if defined(WEBRTC_ARCH_X86_FAMILY) |
54 // Verifies that the optimized methods are bitexact to their reference | 56 // Verifies that the optimized methods are bitexact to their reference |
55 // counterparts. | 57 // counterparts. |
56 TEST(ComfortNoiseGenerator, TestOptimizations) { | 58 TEST(ComfortNoiseGenerator, TestOptimizations) { |
57 if (WebRtc_GetCPUInfo(kSSE2) != 0) { | 59 if (WebRtc_GetCPUInfo(kSSE2) != 0) { |
(...skipping 26 matching lines...) Expand all Loading... |
84 0.00001f); | 86 0.00001f); |
85 } | 87 } |
86 } | 88 } |
87 } | 89 } |
88 } | 90 } |
89 | 91 |
90 #endif | 92 #endif |
91 | 93 |
92 TEST(ComfortNoiseGenerator, CorrectLevel) { | 94 TEST(ComfortNoiseGenerator, CorrectLevel) { |
93 ComfortNoiseGenerator cng(DetectOptimization()); | 95 ComfortNoiseGenerator cng(DetectOptimization()); |
94 AecState aec_state(0.f); | 96 AecState aec_state(AudioProcessing::Config::EchoCanceller3{}); |
95 | 97 |
96 std::array<float, kFftLengthBy2Plus1> N2; | 98 std::array<float, kFftLengthBy2Plus1> N2; |
97 N2.fill(1000.f * 1000.f); | 99 N2.fill(1000.f * 1000.f); |
98 | 100 |
99 FftData n_lower; | 101 FftData n_lower; |
100 FftData n_upper; | 102 FftData n_upper; |
101 n_lower.re.fill(0.f); | 103 n_lower.re.fill(0.f); |
102 n_lower.im.fill(0.f); | 104 n_lower.im.fill(0.f); |
103 n_upper.re.fill(0.f); | 105 n_upper.re.fill(0.f); |
104 n_upper.im.fill(0.f); | 106 n_upper.im.fill(0.f); |
105 | 107 |
106 // Ensure instantaneous updata to nonzero noise. | 108 // Ensure instantaneous updata to nonzero noise. |
107 cng.Compute(aec_state, N2, &n_lower, &n_upper); | 109 cng.Compute(aec_state, N2, &n_lower, &n_upper); |
108 EXPECT_LT(0.f, Power(n_lower)); | 110 EXPECT_LT(0.f, Power(n_lower)); |
109 EXPECT_LT(0.f, Power(n_upper)); | 111 EXPECT_LT(0.f, Power(n_upper)); |
110 | 112 |
111 for (int k = 0; k < 10000; ++k) { | 113 for (int k = 0; k < 10000; ++k) { |
112 cng.Compute(aec_state, N2, &n_lower, &n_upper); | 114 cng.Compute(aec_state, N2, &n_lower, &n_upper); |
113 } | 115 } |
114 EXPECT_NEAR(N2[0], Power(n_lower), N2[0] / 10.f); | 116 EXPECT_NEAR(N2[0], Power(n_lower), N2[0] / 10.f); |
115 EXPECT_NEAR(N2[0], Power(n_upper), N2[0] / 10.f); | 117 EXPECT_NEAR(N2[0], Power(n_upper), N2[0] / 10.f); |
116 } | 118 } |
117 | 119 |
118 } // namespace aec3 | 120 } // namespace aec3 |
119 } // namespace webrtc | 121 } // namespace webrtc |
OLD | NEW |