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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 [](float a, float b) { return std::max(0.f, a - 10.f * b); }); | 137 [](float a, float b) { return std::max(0.f, a - 10.f * b); }); |
138 | 138 |
139 NonLinearEstimate(aec_state.HeadsetDetected(), X2, Y2, R2); | 139 NonLinearEstimate(aec_state.HeadsetDetected(), X2, Y2, R2); |
140 AddEchoReverb(*R2, aec_state.SaturatedEcho(), | 140 AddEchoReverb(*R2, aec_state.SaturatedEcho(), |
141 std::min(static_cast<size_t>(kAdaptiveFilterLength), | 141 std::min(static_cast<size_t>(kAdaptiveFilterLength), |
142 delay.value_or(kAdaptiveFilterLength)), | 142 delay.value_or(kAdaptiveFilterLength)), |
143 aec_state.ReverbDecay(), R2); | 143 aec_state.ReverbDecay(), R2); |
144 } | 144 } |
145 | 145 |
146 // If the echo is deemed inaudible, set the residual echo to zero. | 146 // If the echo is deemed inaudible, set the residual echo to zero. |
147 if (aec_state.InaudibleEcho()) { | 147 if (aec_state.InaudibleEcho() && |
| 148 (aec_state.ExternalDelay() || aec_state.HeadsetDetected())) { |
148 R2->fill(0.f); | 149 R2->fill(0.f); |
149 } | 150 } |
150 | 151 |
151 // If the echo is saturated, estimate the echo power as the maximum echo power | 152 // If the echo is saturated, estimate the echo power as the maximum echo power |
152 // with a leakage factor. | 153 // with a leakage factor. |
153 if (aec_state.SaturatedEcho()) { | 154 if (aec_state.SaturatedEcho()) { |
154 R2->fill((*std::max_element(R2->begin(), R2->end())) * 100.f); | 155 R2->fill((*std::max_element(R2->begin(), R2->end())) * 100.f); |
155 } | 156 } |
156 | 157 |
157 std::copy(R2->begin(), R2->end(), R2_old_.begin()); | 158 std::copy(R2->begin(), R2->end(), R2_old_.begin()); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 } else { | 252 } else { |
252 std::copy(S2.begin(), S2.end(), S2_old_[S2_old_index_].begin()); | 253 std::copy(S2.begin(), S2.end(), S2_old_[S2_old_index_].begin()); |
253 } | 254 } |
254 | 255 |
255 // Add the power of the echo reverb to the residual echo power. | 256 // Add the power of the echo reverb to the residual echo power. |
256 std::transform(R2->begin(), R2->end(), R2_reverb_.begin(), R2->begin(), | 257 std::transform(R2->begin(), R2->end(), R2_reverb_.begin(), R2->begin(), |
257 std::plus<float>()); | 258 std::plus<float>()); |
258 } | 259 } |
259 | 260 |
260 } // namespace webrtc | 261 } // namespace webrtc |
OLD | NEW |