Improving the speed of the delay estimator in AEC3

This CL significantly improves the response time
of the AEC3 delay estimator to audio buffer issues.

The CL adds ensures that the delay estimator
correlators reacts to buffer issues from the
zero state which is much faster than if it has already
achieved a state matching a previous alignment.

The CL has been extensively tested on offline
recordings.

Bug: webrtc:9023, chromium:822245
Change-Id: Ic149b9429e592d4c3535eb8432582f435a1b4745
Reviewed-on: https://webrtc-review.googlesource.com/62081
Commit-Queue: Per Åhgren <peah@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22461}
This commit is contained in:
Per Åhgren
2018-03-15 16:31:27 +01:00
committed by Commit Bot
parent 1d037ae704
commit 895ae9a0cd
3 changed files with 22 additions and 1 deletions

View File

@ -48,6 +48,8 @@ void EchoPathDelayEstimator::Reset(bool soft_reset) {
matched_filter_lag_aggregator_.Reset();
}
matched_filter_.Reset();
old_aggregated_lag_ = rtc::nullopt;
consistent_estimate_counter_ = 0;
}
rtc::Optional<DelayEstimate> EchoPathDelayEstimator::EstimateDelay(
@ -84,6 +86,19 @@ rtc::Optional<DelayEstimate> EchoPathDelayEstimator::EstimateDelay(
if (aggregated_matched_filter_lag) {
aggregated_matched_filter_lag->delay *= down_sampling_factor_;
}
if (old_aggregated_lag_ && aggregated_matched_filter_lag &&
old_aggregated_lag_->delay == aggregated_matched_filter_lag->delay) {
++consistent_estimate_counter_;
} else {
consistent_estimate_counter_ = 0;
}
old_aggregated_lag_ = aggregated_matched_filter_lag;
constexpr size_t kNumBlocksPerSecondBy2 = kNumBlocksPerSecond / 2;
if (consistent_estimate_counter_ > kNumBlocksPerSecondBy2) {
Reset(true);
}
return aggregated_matched_filter_lag;
}

View File

@ -55,6 +55,8 @@ class EchoPathDelayEstimator {
Decimator capture_decimator_;
MatchedFilter matched_filter_;
MatchedFilterLagAggregator matched_filter_lag_aggregator_;
rtc::Optional<DelayEstimate> old_aggregated_lag_;
size_t consistent_estimate_counter_ = 0;
RTC_DISALLOW_COPY_AND_ASSIGN(EchoPathDelayEstimator);
};

View File

@ -84,8 +84,12 @@ TEST(EchoPathDelayEstimator, DelayEstimation) {
render_delay_buffer->PrepareCaptureProcessing();
estimated_delay_samples = estimator.EstimateDelay(
auto estimate = estimator.EstimateDelay(
render_delay_buffer->GetDownsampledRenderBuffer(), capture);
if (estimate) {
estimated_delay_samples = estimate;
}
}
if (estimated_delay_samples) {