From e994058eb1397ad18523067408ebeb9117e25a25 Mon Sep 17 00:00:00 2001 From: Alex Loiko Date: Thu, 25 Jan 2018 13:27:53 +0100 Subject: [PATCH] NaNs in Echo Canceller. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A coherence vector cohxd is computed in WebRtcAec_ComputeCoherence. The coherence values should theoretically be 0 <= x <= 1. Due to the way they are computed that is not always the case. The coherence values are used to update an error signal estimate hNl in webrtc::EchoSuppression. 'hNl[i]' should contain an error magnitude for frequency 'i'. The error magnitudes are used as a basis for exponentiation. If a magnitude is negative, the result is NaN. The NaNs will then spread to the output signal. This change caps the hNl values at 0. I considered capping the coherence values at 1. The coherence values are calculated differently for MIPS, NEON and SSE. Therefore it's simpler to cap the hNl values instead. The issue was found by the AudioProcessing fuzzer. Bug: chromium:804634 Change-Id: I8ebaa441d77c3f79d9c194a850cb2b9eed1c2024 Reviewed-on: https://webrtc-review.googlesource.com/43740 Commit-Queue: Alex Loiko Reviewed-by: Per Ã…hgren Cr-Commit-Position: refs/heads/master@{#21761} --- modules/audio_processing/aec/aec_core.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/audio_processing/aec/aec_core.cc b/modules/audio_processing/aec/aec_core.cc index c9bd7d3685..43949292b3 100644 --- a/modules/audio_processing/aec/aec_core.cc +++ b/modules/audio_processing/aec/aec_core.cc @@ -1095,6 +1095,7 @@ static void FormSuppressionGain(AecCore* aec, } else { for (int i = 0; i < PART_LEN1; ++i) { hNl[i] = 1 - cohxd[i]; + hNl[i] = std::max(hNl[i], 0.f); } hNlFb = hNlXdAvg; hNlFbLow = hNlXdAvg; @@ -1109,6 +1110,7 @@ static void FormSuppressionGain(AecCore* aec, aec->echoState = 1; for (int i = 0; i < PART_LEN1; ++i) { hNl[i] = WEBRTC_SPL_MIN(cohde[i], 1 - cohxd[i]); + hNl[i] = std::max(hNl[i], 0.f); } // Select an order statistic from the preferred bands.