From 2ce640fada9d045f3161b122cab9fff50f256da8 Mon Sep 17 00:00:00 2001 From: peah Date: Fri, 7 Apr 2017 03:57:48 -0700 Subject: [PATCH] Fixing sample-rate dependent band-split filter issues in AEC3 This CL ensures that the number of bands for the render side matches that for the capture side when AEC3 is active. Without this, there was problems when the render rate is different from the capture rate. BUG=webrtc:6018 Review-Url: https://codereview.webrtc.org/2800033003 Cr-Commit-Position: refs/heads/master@{#17586} --- .../modules/audio_processing/aec3/aec3_common.h | 1 + .../audio_processing/audio_processing_impl.cc | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/webrtc/modules/audio_processing/aec3/aec3_common.h b/webrtc/modules/audio_processing/aec3/aec3_common.h index f03a7e33d2..dbfc4ed0d6 100644 --- a/webrtc/modules/audio_processing/aec3/aec3_common.h +++ b/webrtc/modules/audio_processing/aec3/aec3_common.h @@ -68,6 +68,7 @@ constexpr size_t kRenderTransferQueueSize = kMaxApiCallsJitterBlocks / 2; static_assert(2 * kRenderTransferQueueSize >= kMaxApiCallsJitterBlocks, "Requirement to ensure buffer overflow detection"); +// TODO(peah): Integrate this with how it is done inside audio_processing_impl. constexpr size_t NumBandsForRate(int sample_rate_hz) { return static_cast(sample_rate_hz == 8000 ? 1 : sample_rate_hz / 16000); diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc index f9cc98faa0..636d6ca5f0 100644 --- a/webrtc/modules/audio_processing/audio_processing_impl.cc +++ b/webrtc/modules/audio_processing/audio_processing_impl.cc @@ -562,11 +562,17 @@ int AudioProcessingImpl::InitializeLocked(const ProcessingConfig& config) { capture_nonlocked_.capture_processing_format = StreamConfig(capture_processing_rate); - int render_processing_rate = FindNativeProcessRateToUse( - std::min(formats_.api_format.reverse_input_stream().sample_rate_hz(), - formats_.api_format.reverse_output_stream().sample_rate_hz()), - submodule_states_.CaptureMultiBandSubModulesActive() || - submodule_states_.RenderMultiBandSubModulesActive()); + int render_processing_rate; + if (!config_.echo_canceller3.enabled) { + render_processing_rate = FindNativeProcessRateToUse( + std::min(formats_.api_format.reverse_input_stream().sample_rate_hz(), + formats_.api_format.reverse_output_stream().sample_rate_hz()), + submodule_states_.CaptureMultiBandSubModulesActive() || + submodule_states_.RenderMultiBandSubModulesActive()); + } else { + render_processing_rate = capture_processing_rate; + } + // TODO(aluebs): Remove this restriction once we figure out why the 3-band // splitting filter degrades the AEC performance. if (render_processing_rate > kSampleRate32kHz && @@ -575,6 +581,7 @@ int AudioProcessingImpl::InitializeLocked(const ProcessingConfig& config) { ? kSampleRate32kHz : kSampleRate16kHz; } + // If the forward sample rate is 8 kHz, the render stream is also processed // at this rate. if (capture_nonlocked_.capture_processing_format.sample_rate_hz() ==