From 836a7a2e4d56b815697e5a5c8cd4e0bfbf972473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20de=20Vicente=20Pe=C3=B1a?= Date: Fri, 31 Aug 2018 15:03:04 +0200 Subject: [PATCH] AEC3: option for using the stationarity estimator at render from the beginning of the call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:9697 Change-Id: I2427e9e62505d27b0942fd6b2e38eee6d720f4f3 Reviewed-on: https://webrtc-review.googlesource.com/97081 Reviewed-by: Per Åhgren Commit-Queue: Per Åhgren Cr-Commit-Position: refs/heads/master@{#24513} --- api/audio/echo_canceller3_config.h | 1 + modules/audio_processing/aec3/aec_state.cc | 2 ++ modules/audio_processing/aec3/echo_audibility.cc | 5 +++-- modules/audio_processing/aec3/echo_audibility.h | 3 ++- modules/audio_processing/test/audio_processing_simulator.cc | 2 ++ 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/api/audio/echo_canceller3_config.h b/api/audio/echo_canceller3_config.h index f4ba8e9a8e..4cb9fe6329 100644 --- a/api/audio/echo_canceller3_config.h +++ b/api/audio/echo_canceller3_config.h @@ -106,6 +106,7 @@ struct EchoCanceller3Config { float audibility_threshold_mf = 10; float audibility_threshold_hf = 10; bool use_stationary_properties = true; + bool use_stationarity_properties_at_init = false; } echo_audibility; struct RenderLevels { diff --git a/modules/audio_processing/aec3/aec_state.cc b/modules/audio_processing/aec3/aec_state.cc index 62232ac104..ffd81b3c11 100644 --- a/modules/audio_processing/aec3/aec_state.cc +++ b/modules/audio_processing/aec3/aec_state.cc @@ -131,6 +131,8 @@ AecState::AecState(const EchoCanceller3Config& config) blocks_since_converged_filter_(kBlocksSinceConvergencedFilterInit), active_blocks_since_consistent_filter_estimate_( kBlocksSinceConsistentEstimateInit), + echo_audibility_( + config.echo_audibility.use_stationarity_properties_at_init), reverb_model_estimator_(config) {} AecState::~AecState() = default; diff --git a/modules/audio_processing/aec3/echo_audibility.cc b/modules/audio_processing/aec3/echo_audibility.cc index 567873b181..fa123de351 100644 --- a/modules/audio_processing/aec3/echo_audibility.cc +++ b/modules/audio_processing/aec3/echo_audibility.cc @@ -20,7 +20,8 @@ namespace webrtc { -EchoAudibility::EchoAudibility() { +EchoAudibility::EchoAudibility(bool use_render_stationarity_at_init) + : use_render_stationarity_at_init_(use_render_stationarity_at_init) { Reset(); } @@ -34,7 +35,7 @@ void EchoAudibility::Update(const RenderBuffer& render_buffer, render_buffer.GetBlockBuffer(), external_delay_seen); - if (external_delay_seen) { + if (external_delay_seen || use_render_stationarity_at_init_) { UpdateRenderStationarityFlags(render_buffer, delay_blocks, reverb_decay); } } diff --git a/modules/audio_processing/aec3/echo_audibility.h b/modules/audio_processing/aec3/echo_audibility.h index 4650fa5386..03bcd71865 100644 --- a/modules/audio_processing/aec3/echo_audibility.h +++ b/modules/audio_processing/aec3/echo_audibility.h @@ -31,7 +31,7 @@ class ApmDataDumper; class EchoAudibility { public: - EchoAudibility(); + explicit EchoAudibility(bool use_render_stationarity_at_init); ~EchoAudibility(); // Feed new render data to the echo audibility estimator. @@ -78,6 +78,7 @@ class EchoAudibility { absl::optional render_spectrum_write_prev_; int render_block_write_prev_; bool non_zero_render_seen_; + const bool use_render_stationarity_at_init_; StationarityEstimator render_stationarity_; RTC_DISALLOW_COPY_AND_ASSIGN(EchoAudibility); }; diff --git a/modules/audio_processing/test/audio_processing_simulator.cc b/modules/audio_processing/test/audio_processing_simulator.cc index 5e092ff9c4..40479d0cb6 100644 --- a/modules/audio_processing/test/audio_processing_simulator.cc +++ b/modules/audio_processing/test/audio_processing_simulator.cc @@ -293,6 +293,8 @@ class Aec3ParametersParser { &cfg.echo_audibility.audibility_threshold_hf); ReadParam(section, "use_stationary_properties", &cfg.echo_audibility.use_stationary_properties); + ReadParam(section, "use_stationary_properties_at_init", + &cfg.echo_audibility.use_stationarity_properties_at_init); } if (rtc::GetValueFromJsonObject(root, "echo_removal_control", §ion)) {