From b1fc54d33e109b9bab10114b3aa0d47eb90b799d Mon Sep 17 00:00:00 2001 From: peah Date: Thu, 12 May 2016 05:08:45 -0700 Subject: [PATCH] Corrected the delay agnostic AEC behavior during periods of silent farend signal. Added conditional updating of the statistics and the delay estimate so that updates are only done when the farend is non-stationary. The reason for this is that all the values that go into the updating of the statistics, and that in turn are also used to update the delay, are frozen when the farend signal is non-stationary. Therefore, when the farend signal is silent (stationary), the last estimates present before the silent (stationary) period began are used to continue to update the statistics. This is a problem as the updating is done in a manner that assumes that the estimates continue to be updated. This CL conditions the updating based on stationarity instead of silence as both are treated in the same manner in the delay agnostic AEC. This makes sense theoretically as the delay agnostic AEC operates on analyzing power deviations (in bands) from a slowly updated average power and therefore for a stationary signal will have no such deviations to base its analysis on. BUG=webrtc:5875, chromium:576624 NOTRY=True Review-Url: https://codereview.webrtc.org/1967033002 Cr-Commit-Position: refs/heads/master@{#12700} --- data/audio_processing/output_data_float.pb | Bin 2054 -> 2054 bytes data/audio_processing/output_data_mac.pb | Bin 2054 -> 2054 bytes .../utility/delay_estimator.cc | 21 +++++++++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/data/audio_processing/output_data_float.pb b/data/audio_processing/output_data_float.pb index 18a206eacb76d1e7db59bc040e648983054c1162..aff94fa9f6518bd628fdac2ec70d0686b4f36253 100644 GIT binary patch delta 158 zcmZn@XcL(5c=CD{mCfvoC5(&=lWUlC*kuJ|C1e$3C$DExWR{SSo;;sTYVunqRjlIS l%m{IRcCh-*%bCwIVNq<4MNDe4GCPI=lb16qPoBnJ002YpBDw$o delta 160 zcmZn@XcL(5m{Dr-1{USb?2ILhj2x3|m~`0X1mq;-6yzqaXHsOAl#rb~pG|7=TP9Vk y;^EAy?D7Kg67mZ2ll|EhnWZG;HZNyB%Y;R-Jr*&k$;#{)225VgtUP%ddjSAz$|Dm1 diff --git a/data/audio_processing/output_data_mac.pb b/data/audio_processing/output_data_mac.pb index a6a88f9fb2d30a672c661ee36efeddfbd64a2cbd..78d0e10965fdbb364d3626814202e077e6517a70 100644 GIT binary patch delta 158 zcmZn@XcL(5c=CD{mCfvoC5(&=lWUlC*kuJ|C1e$3C$DExWR{SSo;;sTYVunqRjlIS l%m{IRcCh-*%bCwIVNq<4MNDe4GCPI=lb16qPoBnJ002YpBDw$o delta 160 zcmZn@XcL(5m{Dr-1{USb?2ILhj2x3|m~`0X1mq;-6yzqaXHsOAl#rb~pG|7=TP9Vk y;^EAy?D7Kg67mZ2ll|EhnWZG;HZNyB%Y;R-Jr*&k$;#{)225VgtUP%ddjSAz$|Dm1 diff --git a/webrtc/modules/audio_processing/utility/delay_estimator.cc b/webrtc/modules/audio_processing/utility/delay_estimator.cc index 15a67472b1..56bdde890c 100644 --- a/webrtc/modules/audio_processing/utility/delay_estimator.cc +++ b/webrtc/modules/audio_processing/utility/delay_estimator.cc @@ -13,6 +13,7 @@ #include #include #include +#include // Number of right shifts for scaling is linearly depending on number of bits in // the far-end binary spectrum. @@ -618,15 +619,29 @@ int WebRtc_ProcessBinarySpectrum(BinaryDelayEstimator* self, ((value_best_candidate < self->minimum_probability) || (value_best_candidate < self->last_delay_probability))); - UpdateRobustValidationStatistics(self, candidate_delay, valley_depth, - value_best_candidate); + // Check for nonstationary farend signal. + const bool non_stationary_farend = + std::any_of(self->farend->far_bit_counts, + self->farend->far_bit_counts + self->history_size, + [](int a) { return a > 0; }); + + if (non_stationary_farend) { + // Only update the validation statistics when the farend is nonstationary + // as the underlying estimates are otherwise frozen. + UpdateRobustValidationStatistics(self, candidate_delay, valley_depth, + value_best_candidate); + } + if (self->robust_validation_enabled) { int is_histogram_valid = HistogramBasedValidation(self, candidate_delay); valid_candidate = RobustValidation(self, candidate_delay, valid_candidate, is_histogram_valid); } - if (valid_candidate) { + + // Only update the delay estimate when the farend is nonstationary and when + // a valid delay candidate is available. + if (non_stationary_farend && valid_candidate) { if (candidate_delay != self->last_delay) { self->last_delay_histogram = (self->histogram[candidate_delay] > kLastHistogramMax ?