Chromium Code Reviews| 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. | |
|
peah-webrtc
2017/04/06 13:39:08
This limit caused the comfort noise in very silent
| |
| 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 | |
| 202 // Choose N2 estimate to use. | 191 // Choose N2 estimate to use. |
| 203 const std::array<float, kFftLengthBy2Plus1>& N2 = | 192 const std::array<float, kFftLengthBy2Plus1>& N2 = |
| 204 N2_initial_ ? *N2_initial_ : N2_; | 193 N2_initial_ ? *N2_initial_ : N2_; |
| 205 | 194 |
| 206 switch (optimization_) { | 195 switch (optimization_) { |
| 207 #if defined(WEBRTC_ARCH_X86_FAMILY) | 196 #if defined(WEBRTC_ARCH_X86_FAMILY) |
| 208 case Aec3Optimization::kSse2: | 197 case Aec3Optimization::kSse2: |
| 209 aec3::EstimateComfortNoise_SSE2(N2, &seed_, lower_band_noise, | 198 aec3::EstimateComfortNoise_SSE2(N2, &seed_, lower_band_noise, |
| 210 upper_band_noise); | 199 upper_band_noise); |
| 211 break; | 200 break; |
| 212 #endif | 201 #endif |
| 213 default: | 202 default: |
| 214 aec3::EstimateComfortNoise(N2, &seed_, lower_band_noise, | 203 aec3::EstimateComfortNoise(N2, &seed_, lower_band_noise, |
| 215 upper_band_noise); | 204 upper_band_noise); |
| 216 } | 205 } |
| 217 } | 206 } |
| 218 | 207 |
| 219 } // namespace webrtc | 208 } // namespace webrtc |
| OLD | NEW |