Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit fa29279

Browse files
Sam ZackrissonCommit Bot
authored andcommitted
AEC3: Re-add delay headroom when precise alignment is needed
This CL adds delay headroom when an external delay estimator is used. Tested: audioproc_f --aec=1 is bitexact on a large number of aecdumps Bug: b/158455753 Change-Id: I56de44e841bb8162e302181c6c386ad7fbb00dee Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/186703 Commit-Queue: Sam Zackrisson <[email protected]> Reviewed-by: Per Åhgren <[email protected]> Reviewed-by: Gustaf Ullberg <[email protected]> Cr-Commit-Position: refs/heads/master@{#32323}
1 parent cf04e06 commit fa29279

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

modules/audio_processing/aec3/aec_state.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,9 @@ void AecState::InitialState::InitialState::Update(bool active_render,
350350

351351
AecState::FilterDelay::FilterDelay(const EchoCanceller3Config& config,
352352
size_t num_capture_channels)
353-
: delay_headroom_samples_(config.delay.delay_headroom_samples),
354-
filter_delays_blocks_(num_capture_channels, 0) {}
353+
: delay_headroom_blocks_(config.delay.delay_headroom_samples / kBlockSize),
354+
filter_delays_blocks_(num_capture_channels, delay_headroom_blocks_),
355+
min_filter_delay_(delay_headroom_blocks_) {}
355356

356357
void AecState::FilterDelay::Update(
357358
rtc::ArrayView<const int> analyzer_filter_delay_estimates_blocks,
@@ -369,7 +370,7 @@ void AecState::FilterDelay::Update(
369370
const bool delay_estimator_may_not_have_converged =
370371
blocks_with_proper_filter_adaptation < 2 * kNumBlocksPerSecond;
371372
if (delay_estimator_may_not_have_converged && external_delay_) {
372-
int delay_guess = delay_headroom_samples_ / kBlockSize;
373+
const int delay_guess = delay_headroom_blocks_;
373374
std::fill(filter_delays_blocks_.begin(), filter_delays_blocks_.end(),
374375
delay_guess);
375376
} else {

modules/audio_processing/aec3/aec_state.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ class AecState {
211211
size_t blocks_with_proper_filter_adaptation);
212212

213213
private:
214-
const int delay_headroom_samples_;
214+
const int delay_headroom_blocks_;
215215
bool external_delay_reported_ = false;
216216
std::vector<int> filter_delays_blocks_;
217-
int min_filter_delay_ = 0;
217+
int min_filter_delay_;
218218
absl::optional<DelayEstimate> external_delay_;
219219
} delay_state_;
220220

modules/audio_processing/aec3/render_delay_buffer.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,11 @@ void RenderDelayBufferImpl::ApplyTotalDelay(int delay) {
385385
void RenderDelayBufferImpl::AlignFromExternalDelay() {
386386
RTC_DCHECK(config_.delay.use_external_delay_estimator);
387387
if (external_audio_buffer_delay_) {
388-
int64_t delay = render_call_counter_ - capture_call_counter_ +
389-
*external_audio_buffer_delay_;
390-
ApplyTotalDelay(delay);
388+
const int64_t delay = render_call_counter_ - capture_call_counter_ +
389+
*external_audio_buffer_delay_;
390+
const int64_t delay_with_headroom =
391+
delay - config_.delay.delay_headroom_samples / kBlockSize;
392+
ApplyTotalDelay(delay_with_headroom);
391393
}
392394
}
393395

0 commit comments

Comments
 (0)