Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Unified Diff: webrtc/modules/audio_processing/utility/delay_estimator.cc

Issue 1967033002: Corrected the delay agnostic AEC behavior during periods of silent farend signal. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Updated the unittest reference file for mac with a new standard deviation value obtained from APM w… Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « data/audio_processing/output_data_mac.pb ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_processing/utility/delay_estimator.cc
diff --git a/webrtc/modules/audio_processing/utility/delay_estimator.cc b/webrtc/modules/audio_processing/utility/delay_estimator.cc
index 15a67472b176a0cd549c73db302bdc9b73eb3162..56bdde890c9348a0e2874950b15177a00ed72d0f 100644
--- a/webrtc/modules/audio_processing/utility/delay_estimator.cc
+++ b/webrtc/modules/audio_processing/utility/delay_estimator.cc
@@ -13,6 +13,7 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
+#include <algorithm>
// 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 ?
« no previous file with comments | « data/audio_processing/output_data_mac.pb ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698