| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 bool saturated_echo, | 151 bool saturated_echo, |
| 152 const std::array<float, kFftLengthBy2Plus1>& nearend, | 152 const std::array<float, kFftLengthBy2Plus1>& nearend, |
| 153 const std::array<float, kFftLengthBy2Plus1>& echo, | 153 const std::array<float, kFftLengthBy2Plus1>& echo, |
| 154 const std::array<float, kFftLengthBy2Plus1>& masker, | 154 const std::array<float, kFftLengthBy2Plus1>& masker, |
| 155 const std::array<float, kFftLengthBy2Plus1>& min_gain, | 155 const std::array<float, kFftLengthBy2Plus1>& min_gain, |
| 156 const std::array<float, kFftLengthBy2Plus1>& max_gain, | 156 const std::array<float, kFftLengthBy2Plus1>& max_gain, |
| 157 const std::array<float, kFftLengthBy2Plus1>& one_by_echo, | 157 const std::array<float, kFftLengthBy2Plus1>& one_by_echo, |
| 158 std::array<float, kFftLengthBy2Plus1>* gain) { | 158 std::array<float, kFftLengthBy2Plus1>* gain) { |
| 159 constexpr float kEchoMaskingMargin = 1.f / 100.f; | 159 constexpr float kEchoMaskingMargin = 1.f / 100.f; |
| 160 const float nearend_masking_margin = | 160 const float nearend_masking_margin = |
| 161 low_noise_render ? 2.f : (saturated_echo ? 0.001f : 0.01f); | 161 low_noise_render ? 0.1f : (saturated_echo ? 0.001f : 0.01f); |
| 162 | 162 |
| 163 for (size_t k = 0; k < gain->size(); ++k) { | 163 for (size_t k = 0; k < gain->size(); ++k) { |
| 164 RTC_DCHECK_LE(0.f, nearend_masking_margin * nearend[k]); | 164 RTC_DCHECK_LE(0.f, nearend_masking_margin * nearend[k]); |
| 165 if (echo[k] <= nearend_masking_margin * nearend[k]) { | 165 if (echo[k] <= nearend_masking_margin * nearend[k]) { |
| 166 (*gain)[k] = 1.f; | 166 (*gain)[k] = 1.f; |
| 167 } else { | 167 } else { |
| 168 (*gain)[k] = kEchoMaskingMargin * masker[k] * one_by_echo[k]; | 168 (*gain)[k] = kEchoMaskingMargin * masker[k] * one_by_echo[k]; |
| 169 } | 169 } |
| 170 | 170 |
| 171 (*gain)[k] = std::min(std::max((*gain)[k], min_gain[k]), max_gain[k]); | 171 (*gain)[k] = std::min(std::max((*gain)[k], min_gain[k]), max_gain[k]); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 } | 303 } |
| 304 | 304 |
| 305 constexpr float kThreshold = 50.f * 50.f * 64.f; | 305 constexpr float kThreshold = 50.f * 50.f * 64.f; |
| 306 const bool low_noise_render = | 306 const bool low_noise_render = |
| 307 average_power_ < kThreshold && x2_max < 3 * average_power_; | 307 average_power_ < kThreshold && x2_max < 3 * average_power_; |
| 308 average_power_ = average_power_ * 0.9f + x2_sum * 0.1f; | 308 average_power_ = average_power_ * 0.9f + x2_sum * 0.1f; |
| 309 return low_noise_render; | 309 return low_noise_render; |
| 310 } | 310 } |
| 311 | 311 |
| 312 } // namespace webrtc | 312 } // namespace webrtc |
| OLD | NEW |