Correction of the AEC3 underrun behavior and minor other corrections

This CL corrects the behavior during buffer underruns.

Furthermore, it increases the tolerance for API call jitter, and
removes the minimum value for the comfort noise.

BUG=webrtc:6018

Review-Url: https://codereview.webrtc.org/2787123003
Cr-Commit-Position: refs/heads/master@{#17576}
This commit is contained in:
peah 2017-04-06 16:33:06 -07:00 committed by Commit bot
parent 86afe9d661
commit 4b572d048a
3 changed files with 32 additions and 27 deletions

View File

@ -63,7 +63,7 @@ constexpr float kFixedEchoPathGain = 100;
constexpr size_t kRenderDelayBufferSize =
(3 * kDownsampledRenderBufferSize) / (4 * kSubBlockSize);
constexpr size_t kMaxApiCallsJitterBlocks = 10;
constexpr size_t kMaxApiCallsJitterBlocks = 20;
constexpr size_t kRenderTransferQueueSize = kMaxApiCallsJitterBlocks / 2;
static_assert(2 * kRenderTransferQueueSize >= kMaxApiCallsJitterBlocks,
"Requirement to ensure buffer overflow detection");

View File

@ -101,34 +101,34 @@ void BlockProcessorImpl::ProcessCapture(
// been a render buffer overrun as the buffer alignment may be noncausal.
delay_controller_->Reset();
render_buffer_->Reset();
} else {
// Update the render buffers with new render data, filling the buffers with
// empty blocks when there is no render data available.
render_buffer_underrun = !render_buffer_->UpdateBuffers();
// Compute and and apply the render delay required to achieve proper signal
// alignment.
const size_t old_delay = render_buffer_->Delay();
const size_t new_delay = delay_controller_->GetDelay(
render_buffer_->GetDownsampledRenderBuffer(), (*capture_block)[0]);
render_buffer_->SetDelay(new_delay);
const size_t achieved_delay = render_buffer_->Delay();
// Inform the delay controller of the actually set delay to allow it to
// properly react to a non-feasible delay.
delay_controller_->SetDelay(achieved_delay);
// Remove the echo from the capture signal.
echo_remover_->ProcessCapture(
delay_controller_->AlignmentHeadroomSamples(),
EchoPathVariability(echo_path_gain_change,
old_delay != achieved_delay ||
old_delay != new_delay ||
render_buffer_overrun_occurred_),
capture_signal_saturation, render_buffer_->GetRenderBuffer(),
capture_block);
}
// Update the render buffers with new render data, filling the buffers with
// empty blocks when there is no render data available.
render_buffer_underrun = !render_buffer_->UpdateBuffers();
// Compute and and apply the render delay required to achieve proper signal
// alignment.
const size_t old_delay = render_buffer_->Delay();
const size_t new_delay = delay_controller_->GetDelay(
render_buffer_->GetDownsampledRenderBuffer(), (*capture_block)[0]);
render_buffer_->SetDelay(new_delay);
const size_t achieved_delay = render_buffer_->Delay();
// Inform the delay controller of the actually set delay to allow it to
// properly react to a non-feasible delay.
delay_controller_->SetDelay(achieved_delay);
// Remove the echo from the capture signal.
echo_remover_->ProcessCapture(
delay_controller_->AlignmentHeadroomSamples(),
EchoPathVariability(echo_path_gain_change,
old_delay != achieved_delay ||
old_delay != new_delay ||
render_buffer_overrun_occurred_),
capture_signal_saturation, render_buffer_->GetRenderBuffer(),
capture_block);
// Update the metrics.
metrics_.UpdateCapture(render_buffer_underrun);

View File

@ -124,6 +124,11 @@ void RenderDelayBufferImpl::Reset() {
downsampled_render_buffer_.buffer.fill(0.f);
fft_buffer_.Clear();
api_call_jitter_buffer_.Reset();
for (auto& c : buffer_) {
for (auto& b : c) {
std::fill(b.begin(), b.end(), 0.f);
}
}
}
bool RenderDelayBufferImpl::Insert(