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)) {