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