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 61 matching lines...) Loading... |
72 } | 72 } |
73 } | 73 } |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 // Assume a minimum echo path gain of -33 dB for headsets. | 77 // Assume a minimum echo path gain of -33 dB for headsets. |
78 constexpr float kHeadsetEchoPathGain = 0.0005f; | 78 constexpr float kHeadsetEchoPathGain = 0.0005f; |
79 | 79 |
80 } // namespace | 80 } // namespace |
81 | 81 |
82 ResidualEchoEstimator::ResidualEchoEstimator() { | 82 ResidualEchoEstimator::ResidualEchoEstimator( |
| 83 const AudioProcessing::Config::EchoCanceller3& config) |
| 84 : config_(config) { |
83 Reset(); | 85 Reset(); |
84 } | 86 } |
85 | 87 |
86 ResidualEchoEstimator::~ResidualEchoEstimator() = default; | 88 ResidualEchoEstimator::~ResidualEchoEstimator() = default; |
87 | 89 |
88 void ResidualEchoEstimator::Estimate( | 90 void ResidualEchoEstimator::Estimate( |
89 bool using_subtractor_output, | 91 bool using_subtractor_output, |
90 const AecState& aec_state, | 92 const AecState& aec_state, |
91 const RenderBuffer& render_buffer, | 93 const RenderBuffer& render_buffer, |
92 const std::array<float, kFftLengthBy2Plus1>& S2_linear, | 94 const std::array<float, kFftLengthBy2Plus1>& S2_linear, |
(...skipping 88 matching lines...) Loading... |
181 return b / a; | 183 return b / a; |
182 }); | 184 }); |
183 } | 185 } |
184 | 186 |
185 void ResidualEchoEstimator::NonLinearEstimate( | 187 void ResidualEchoEstimator::NonLinearEstimate( |
186 bool headset_detected, | 188 bool headset_detected, |
187 const std::array<float, kFftLengthBy2Plus1>& X2, | 189 const std::array<float, kFftLengthBy2Plus1>& X2, |
188 const std::array<float, kFftLengthBy2Plus1>& Y2, | 190 const std::array<float, kFftLengthBy2Plus1>& Y2, |
189 std::array<float, kFftLengthBy2Plus1>* R2) { | 191 std::array<float, kFftLengthBy2Plus1>* R2) { |
190 // Choose gains. | 192 // Choose gains. |
191 const float echo_path_gain_lf = headset_detected ? kHeadsetEchoPathGain : 100; | 193 const float echo_path_gain_lf = |
| 194 headset_detected ? kHeadsetEchoPathGain : config_.param.ep_strength.lf; |
192 const float echo_path_gain_mf = | 195 const float echo_path_gain_mf = |
193 headset_detected ? kHeadsetEchoPathGain : 1000; | 196 headset_detected ? kHeadsetEchoPathGain : config_.param.ep_strength.mf; |
194 const float echo_path_gain_hf = | 197 const float echo_path_gain_hf = |
195 headset_detected ? kHeadsetEchoPathGain : 5000; | 198 headset_detected ? kHeadsetEchoPathGain : config_.param.ep_strength.hf; |
196 | 199 |
197 // Compute preliminary residual echo. | 200 // Compute preliminary residual echo. |
198 std::transform( | 201 std::transform( |
199 X2.begin(), X2.begin() + 12, R2->begin(), | 202 X2.begin(), X2.begin() + 12, R2->begin(), |
200 [echo_path_gain_lf](float a) { return a * echo_path_gain_lf; }); | 203 [echo_path_gain_lf](float a) { return a * echo_path_gain_lf; }); |
201 std::transform( | 204 std::transform( |
202 X2.begin() + 12, X2.begin() + 25, R2->begin() + 12, | 205 X2.begin() + 12, X2.begin() + 25, R2->begin() + 12, |
203 [echo_path_gain_mf](float a) { return a * echo_path_gain_mf; }); | 206 [echo_path_gain_mf](float a) { return a * echo_path_gain_mf; }); |
204 std::transform( | 207 std::transform( |
205 X2.begin() + 25, X2.end(), R2->begin() + 25, | 208 X2.begin() + 25, X2.end(), R2->begin() + 25, |
(...skipping 46 matching lines...) Loading... |
252 } else { | 255 } else { |
253 std::copy(S2.begin(), S2.end(), S2_old_[S2_old_index_].begin()); | 256 std::copy(S2.begin(), S2.end(), S2_old_[S2_old_index_].begin()); |
254 } | 257 } |
255 | 258 |
256 // Add the power of the echo reverb to the residual echo power. | 259 // Add the power of the echo reverb to the residual echo power. |
257 std::transform(R2->begin(), R2->end(), R2_reverb_.begin(), R2->begin(), | 260 std::transform(R2->begin(), R2->end(), R2_reverb_.begin(), R2->begin(), |
258 std::plus<float>()); | 261 std::plus<float>()); |
259 } | 262 } |
260 | 263 |
261 } // namespace webrtc | 264 } // namespace webrtc |
OLD | NEW |