From 7015bb410da9f42a291db0b2f3f6ab76c9c3a6f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20de=20Vicente=20Pe=C3=B1a?= Date: Wed, 29 Aug 2018 11:15:30 +0200 Subject: [PATCH] AEC3: Reset the ERLE estimation after a delay change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:9685 Change-Id: I3c920bbb07aef513ea14bd0573ac4fd4b278ec89 Reviewed-on: https://webrtc-review.googlesource.com/96681 Reviewed-by: Per Ã…hgren Commit-Queue: Jesus de Vicente Pena Cr-Commit-Position: refs/heads/master@{#24480} --- modules/audio_processing/aec3/aec_state.cc | 9 +++++++++ modules/audio_processing/aec3/aec_state.h | 1 + modules/audio_processing/aec3/erle_estimator.cc | 9 +++++++-- modules/audio_processing/aec3/erle_estimator.h | 3 +++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/modules/audio_processing/aec3/aec_state.cc b/modules/audio_processing/aec3/aec_state.cc index 634df68818..a3fd67997c 100644 --- a/modules/audio_processing/aec3/aec_state.cc +++ b/modules/audio_processing/aec3/aec_state.cc @@ -73,6 +73,11 @@ bool UseEarlyLimiterDeactivation() { "WebRTC-Aec3EarlyLimiterDeactivationKillSwitch"); } +bool ResetErleAfterEchoPathChanges() { + return !field_trial::IsEnabled( + "WebRTC-Aec3ResetErleAfterEchoPathChangesKillSwitch"); +} + float UncertaintyBeforeConvergence() { if (LowUncertaintyBeforeConvergence()) { return 1.f; @@ -117,6 +122,7 @@ AecState::AecState(const EchoCanceller3Config& config) uncertainty_before_convergence_(UncertaintyBeforeConvergence()), early_entry_to_converged_mode_(EarlyEntryToConvergedMode()), early_limiter_deactivation_(UseEarlyLimiterDeactivation()), + reset_erle_after_echo_path_changes_(ResetErleAfterEchoPathChanges()), erle_estimator_(config.erle.min, config.erle.max_l, config.erle.max_h), max_render_(config_.filter.main.length_blocks, 0.f), gain_rampup_increase_(ComputeGainRampupIncrease(config_)), @@ -147,6 +153,9 @@ void AecState::HandleEchoPathChange( suppression_gain_limiter_.Reset(); blocks_since_converged_filter_ = kBlocksSinceConvergencedFilterInit; diverged_blocks_ = 0; + if (reset_erle_after_echo_path_changes_) { + erle_estimator_.Reset(); + } }; // TODO(peah): Refine the reset scheme according to the type of gain and diff --git a/modules/audio_processing/aec3/aec_state.h b/modules/audio_processing/aec3/aec_state.h index 9171f0b8ff..772ed90938 100644 --- a/modules/audio_processing/aec3/aec_state.h +++ b/modules/audio_processing/aec3/aec_state.h @@ -179,6 +179,7 @@ class AecState { const float uncertainty_before_convergence_; const bool early_entry_to_converged_mode_; const bool early_limiter_deactivation_; + const bool reset_erle_after_echo_path_changes_; ErlEstimator erl_estimator_; ErleEstimator erle_estimator_; size_t capture_block_counter_ = 0; diff --git a/modules/audio_processing/aec3/erle_estimator.cc b/modules/audio_processing/aec3/erle_estimator.cc index 317f00a38c..b02245c859 100644 --- a/modules/audio_processing/aec3/erle_estimator.cc +++ b/modules/audio_processing/aec3/erle_estimator.cc @@ -35,6 +35,13 @@ ErleEstimator::ErleEstimator(float min_erle, max_erle_hf_(max_erle_hf), erle_freq_inst_(kPointsToAccumulate), erle_time_inst_(kPointsToAccumulate) { + Reset(); +} + +ErleEstimator::~ErleEstimator() = default; + +void ErleEstimator::Reset() { + erle_time_inst_.Reset(); erle_.fill(min_erle_); erle_onsets_.fill(min_erle_); hold_counters_.fill(0); @@ -43,8 +50,6 @@ ErleEstimator::ErleEstimator(float min_erle, hold_counter_time_domain_ = 0; } -ErleEstimator::~ErleEstimator() = default; - ErleEstimator::ErleTimeInstantaneous::ErleTimeInstantaneous( int points_to_accumulate) : points_to_accumulate_(points_to_accumulate) { diff --git a/modules/audio_processing/aec3/erle_estimator.h b/modules/audio_processing/aec3/erle_estimator.h index 32550f64df..8160dbecba 100644 --- a/modules/audio_processing/aec3/erle_estimator.h +++ b/modules/audio_processing/aec3/erle_estimator.h @@ -27,6 +27,9 @@ class ErleEstimator { ErleEstimator(float min_erle, float max_erle_lf, float max_erle_hf); ~ErleEstimator(); + // Reset the ERLE estimator. + void Reset(); + // Updates the ERLE estimate. void Update(rtc::ArrayView render_spectrum, rtc::ArrayView capture_spectrum,