From 52caa0ef58c658c15bb6684cc36bd7b1dd8cc09c Mon Sep 17 00:00:00 2001 From: Gustaf Ullberg Date: Thu, 11 Apr 2019 14:43:17 +0200 Subject: [PATCH] AEC3: Configuration parameter for disabling linear filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The configuration parameter filter.use_linear_filter can be used to disable the linear filtering. Disabling the linear filter is equivalent to runing in non-linear mode. Bug: b/130016532 Change-Id: I8ffdf474822888b9915444bba6cc1c25ec1efe5a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132552 Reviewed-by: Per Ã…hgren Commit-Queue: Gustaf Ullberg Cr-Commit-Position: refs/heads/master@{#27566} --- api/audio/echo_canceller3_config.h | 1 + api/audio/echo_canceller3_config_json.cc | 4 ++++ modules/audio_processing/aec3/aec_state.cc | 4 +++- modules/audio_processing/aec3/aec_state.h | 6 ++++-- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/api/audio/echo_canceller3_config.h b/api/audio/echo_canceller3_config.h index c19226e9e9..d8e6f24668 100644 --- a/api/audio/echo_canceller3_config.h +++ b/api/audio/echo_canceller3_config.h @@ -76,6 +76,7 @@ struct RTC_EXPORT EchoCanceller3Config { float initial_state_seconds = 2.5f; bool conservative_initial_phase = false; bool enable_shadow_filter_output_usage = true; + bool use_linear_filter = true; } filter; struct Erle { diff --git a/api/audio/echo_canceller3_config_json.cc b/api/audio/echo_canceller3_config_json.cc index 07c4e52447..9c4824c94d 100644 --- a/api/audio/echo_canceller3_config_json.cc +++ b/api/audio/echo_canceller3_config_json.cc @@ -167,6 +167,9 @@ void Aec3ConfigFromJsonString(absl::string_view json_string, ReadParam(subsection, "converged", &cfg.delay.delay_selection_thresholds.converged); } + + ReadParam(section, "use_external_delay_estimator", + &cfg.delay.use_external_delay_estimator); } if (rtc::GetValueFromJsonObject(aec3_root, "filter", §ion)) { @@ -182,6 +185,7 @@ void Aec3ConfigFromJsonString(absl::string_view json_string, &cfg.filter.conservative_initial_phase); ReadParam(section, "enable_shadow_filter_output_usage", &cfg.filter.enable_shadow_filter_output_usage); + ReadParam(section, "use_linear_filter", &cfg.filter.use_linear_filter); } if (rtc::GetValueFromJsonObject(aec3_root, "erle", §ion)) { diff --git a/modules/audio_processing/aec3/aec_state.cc b/modules/audio_processing/aec3/aec_state.cc index 99791a7302..6a5b6e5266 100644 --- a/modules/audio_processing/aec3/aec_state.cc +++ b/modules/audio_processing/aec3/aec_state.cc @@ -118,7 +118,9 @@ void AecState::Update( // Estimate the direct path delay of the filter. delay_state_.Update(filter_analyzer_, external_delay, - strong_not_saturated_render_blocks_); + config_.filter.use_linear_filter + ? strong_not_saturated_render_blocks_ + : 0); const std::vector& aligned_render_block = render_buffer.Block(-delay_state_.DirectPathFilterDelay())[0]; diff --git a/modules/audio_processing/aec3/aec_state.h b/modules/audio_processing/aec3/aec_state.h index e323b2c6b1..1887492f8a 100644 --- a/modules/audio_processing/aec3/aec_state.h +++ b/modules/audio_processing/aec3/aec_state.h @@ -45,12 +45,14 @@ class AecState { // Returns whether the echo subtractor can be used to determine the residual // echo. bool UsableLinearEstimate() const { - return filter_quality_state_.LinearFilterUsable(); + return filter_quality_state_.LinearFilterUsable() && + config_.filter.use_linear_filter; } // Returns whether the echo subtractor output should be used as output. bool UseLinearFilterOutput() const { - return filter_quality_state_.LinearFilterUsable(); + return filter_quality_state_.LinearFilterUsable() && + config_.filter.use_linear_filter; } // Returns the estimated echo path gain.