From 8447e91429708d32f11ec56a919c59d90ba0b031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=85hgren?= Date: Wed, 28 Feb 2018 13:28:34 +0100 Subject: [PATCH] Add a hysteresis for the API call skew detection to better handle jittery platforms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:8954,chromium:817313 Change-Id: I940d52ac96e5bddf886d47be089a1991ae24b51b Reviewed-on: https://webrtc-review.googlesource.com/58640 Commit-Queue: Per Ã…hgren Reviewed-by: Gustaf Ullberg Cr-Commit-Position: refs/heads/master@{#22228} --- api/audio/echo_canceller3_config.h | 1 + modules/audio_processing/aec3/render_delay_controller.cc | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/api/audio/echo_canceller3_config.h b/api/audio/echo_canceller3_config.h index 6bd3a95ea7..1acb26fa89 100644 --- a/api/audio/echo_canceller3_config.h +++ b/api/audio/echo_canceller3_config.h @@ -28,6 +28,7 @@ struct EchoCanceller3Config { size_t delay_headroom_blocks = 2; size_t hysteresis_limit_1_blocks = 1; size_t hysteresis_limit_2_blocks = 1; + size_t skew_hysteresis_blocks = 1; } delay; struct Filter { diff --git a/modules/audio_processing/aec3/render_delay_controller.cc b/modules/audio_processing/aec3/render_delay_controller.cc index e97386efe0..db00b9bc94 100644 --- a/modules/audio_processing/aec3/render_delay_controller.cc +++ b/modules/audio_processing/aec3/render_delay_controller.cc @@ -48,6 +48,7 @@ class RenderDelayControllerImpl final : public RenderDelayController { const int delay_headroom_blocks_; const int hysteresis_limit_1_blocks_; const int hysteresis_limit_2_blocks_; + const int skew_hysteresis_blocks_; rtc::Optional delay_; EchoPathDelayEstimator delay_estimator_; std::vector delay_buf_; @@ -115,6 +116,8 @@ RenderDelayControllerImpl::RenderDelayControllerImpl( static_cast(config.delay.hysteresis_limit_1_blocks)), hysteresis_limit_2_blocks_( static_cast(config.delay.hysteresis_limit_2_blocks)), + skew_hysteresis_blocks_( + static_cast(config.delay.skew_hysteresis_blocks)), delay_estimator_(data_dumper_.get(), config), delay_buf_(kBlockSize * non_causal_offset, 0.f), skew_estimator_(kSkewHistorySizeLog2) { @@ -199,7 +202,9 @@ rtc::Optional RenderDelayControllerImpl::GetDelay( delay_samples_->quality == DelayEstimate::Quality::kRefined) { // Compute the skew offset and add a margin. offset_blocks = *skew_ - *skew; - if (offset_blocks != 0 && soft_reset_counter_ > 10 * kNumBlocksPerSecond) { + if (abs(offset_blocks) <= skew_hysteresis_blocks_) { + offset_blocks = 0; + } else if (soft_reset_counter_ > 10 * kNumBlocksPerSecond) { // Soft reset the delay estimator if there is a significant offset // detected. delay_estimator_.Reset(true);