| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 N2_initial_.reset(); | 181 N2_initial_.reset(); |
| 182 } else { | 182 } else { |
| 183 // Compute the N2_initial from N2. | 183 // Compute the N2_initial from N2. |
| 184 std::transform( | 184 std::transform( |
| 185 N2_.begin(), N2_.end(), N2_initial_->begin(), N2_initial_->begin(), | 185 N2_.begin(), N2_.end(), N2_initial_->begin(), N2_initial_->begin(), |
| 186 [](float a, float b) { return a > b ? b + 0.001f * (a - b) : a; }); | 186 [](float a, float b) { return a > b ? b + 0.001f * (a - b) : a; }); |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 | 190 |
| 191 // Limit the noise to a floor of -96 dBFS. |
| 192 constexpr float kNoiseFloor = 440.f; |
| 193 for (auto& n : N2_) { |
| 194 n = std::max(n, kNoiseFloor); |
| 195 } |
| 196 if (N2_initial_) { |
| 197 for (auto& n : *N2_initial_) { |
| 198 n = std::max(n, kNoiseFloor); |
| 199 } |
| 200 } |
| 201 |
| 191 // Choose N2 estimate to use. | 202 // Choose N2 estimate to use. |
| 192 const std::array<float, kFftLengthBy2Plus1>& N2 = | 203 const std::array<float, kFftLengthBy2Plus1>& N2 = |
| 193 N2_initial_ ? *N2_initial_ : N2_; | 204 N2_initial_ ? *N2_initial_ : N2_; |
| 194 | 205 |
| 195 switch (optimization_) { | 206 switch (optimization_) { |
| 196 #if defined(WEBRTC_ARCH_X86_FAMILY) | 207 #if defined(WEBRTC_ARCH_X86_FAMILY) |
| 197 case Aec3Optimization::kSse2: | 208 case Aec3Optimization::kSse2: |
| 198 aec3::EstimateComfortNoise_SSE2(N2, &seed_, lower_band_noise, | 209 aec3::EstimateComfortNoise_SSE2(N2, &seed_, lower_band_noise, |
| 199 upper_band_noise); | 210 upper_band_noise); |
| 200 break; | 211 break; |
| 201 #endif | 212 #endif |
| 202 default: | 213 default: |
| 203 aec3::EstimateComfortNoise(N2, &seed_, lower_band_noise, | 214 aec3::EstimateComfortNoise(N2, &seed_, lower_band_noise, |
| 204 upper_band_noise); | 215 upper_band_noise); |
| 205 } | 216 } |
| 206 } | 217 } |
| 207 | 218 |
| 208 } // namespace webrtc | 219 } // namespace webrtc |
| OLD | NEW |