From ddb82a6b5f97fb141a097f70e9b653c6d8256eaa Mon Sep 17 00:00:00 2001 From: Gustaf Ullberg Date: Tue, 11 Sep 2018 12:55:23 +0200 Subject: [PATCH] AEC3: Fix filter output transition when input and output is the same array MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL fixes a bug in the filter output transition when the 'from' input points to the same array as the output. It also includes a slight improvement to the transition by starting one sample earlier than previously. Bug: webrtc:9741,chromium:882789 Change-Id: Ifd5f16c1ac88a74d93499e7f4b4c0e5cb3e4976f Reviewed-on: https://webrtc-review.googlesource.com/99540 Reviewed-by: Per Ã…hgren Commit-Queue: Gustaf Ullberg Cr-Commit-Position: refs/heads/master@{#24683} --- modules/audio_processing/aec3/echo_remover.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/audio_processing/aec3/echo_remover.cc b/modules/audio_processing/aec3/echo_remover.cc index 86f3300a13..8fef71c600 100644 --- a/modules/audio_processing/aec3/echo_remover.cc +++ b/modules/audio_processing/aec3/echo_remover.cc @@ -62,15 +62,15 @@ void SignalTransition(rtc::ArrayView from, rtc::ArrayView to, rtc::ArrayView out) { constexpr size_t kTransitionSize = 30; - constexpr float kOneByTransitionSize = 1.f / kTransitionSize; + constexpr float kOneByTransitionSizePlusOne = 1.f / (kTransitionSize + 1); RTC_DCHECK_EQ(from.size(), to.size()); RTC_DCHECK_EQ(from.size(), out.size()); RTC_DCHECK_LE(kTransitionSize, out.size()); for (size_t k = 0; k < kTransitionSize; ++k) { - out[k] = k * kOneByTransitionSize * to[k]; - out[k] += (kTransitionSize - k) * kOneByTransitionSize * from[k]; + float a = (k + 1) * kOneByTransitionSizePlusOne; + out[k] = a * to[k] + (1.f - a) * from[k]; } std::copy(to.begin() + kTransitionSize, to.end(),