Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Unified Diff: webrtc/modules/audio_processing/aec3/residual_echo_estimator.cc

Issue 2974883002: Robustification of the AEC3 echo removal in the first part of the call (Closed)
Patch Set: Rebase Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/audio_processing/aec3/residual_echo_estimator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_processing/aec3/residual_echo_estimator.cc
diff --git a/webrtc/modules/audio_processing/aec3/residual_echo_estimator.cc b/webrtc/modules/audio_processing/aec3/residual_echo_estimator.cc
index d17afa6906d2e49ee74ca721168d7b869f64e04f..61208118c7aeacb586e00711cab6b36f82dccead 100644
--- a/webrtc/modules/audio_processing/aec3/residual_echo_estimator.cc
+++ b/webrtc/modules/audio_processing/aec3/residual_echo_estimator.cc
@@ -136,9 +136,7 @@ void ResidualEchoEstimator::Estimate(
X2.begin(), X2.end(), X2_noise_floor_.begin(), X2.begin(),
[](float a, float b) { return std::max(0.f, a - 10.f * b); });
- NonLinearEstimate(
- aec_state.HeadsetDetected() ? kHeadsetEchoPathGain : kFixedEchoPathGain,
- X2, Y2, R2);
+ NonLinearEstimate(aec_state.HeadsetDetected(), X2, Y2, R2);
AddEchoReverb(*R2, aec_state.SaturatedEcho(),
std::min(static_cast<size_t>(kAdaptiveFilterLength),
delay.value_or(kAdaptiveFilterLength)),
@@ -184,13 +182,27 @@ void ResidualEchoEstimator::LinearEstimate(
}
void ResidualEchoEstimator::NonLinearEstimate(
- float echo_path_gain,
+ bool headset_detected,
const std::array<float, kFftLengthBy2Plus1>& X2,
const std::array<float, kFftLengthBy2Plus1>& Y2,
std::array<float, kFftLengthBy2Plus1>* R2) {
+ // Choose gains.
+ const float echo_path_gain_lf = headset_detected ? kHeadsetEchoPathGain : 100;
+ const float echo_path_gain_mf =
+ headset_detected ? kHeadsetEchoPathGain : 1000;
+ const float echo_path_gain_hf =
+ headset_detected ? kHeadsetEchoPathGain : 5000;
+
// Compute preliminary residual echo.
- std::transform(X2.begin(), X2.end(), R2->begin(),
- [echo_path_gain](float a) { return a * echo_path_gain; });
+ std::transform(
+ X2.begin(), X2.begin() + 12, R2->begin(),
+ [echo_path_gain_lf](float a) { return a * echo_path_gain_lf; });
+ std::transform(
+ X2.begin() + 12, X2.begin() + 25, R2->begin() + 12,
+ [echo_path_gain_mf](float a) { return a * echo_path_gain_mf; });
+ std::transform(
+ X2.begin() + 25, X2.end(), R2->begin() + 25,
+ [echo_path_gain_hf](float a) { return a * echo_path_gain_hf; });
for (size_t k = 0; k < R2->size(); ++k) {
// Update hold counter.
« no previous file with comments | « webrtc/modules/audio_processing/aec3/residual_echo_estimator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698