Division by zero in RNN-VAD.

Bug: webrtc:9450, chromium:861557
Change-Id: I00ddda1fe0e088b983707420acf1b9a6763a3535
Reviewed-on: https://webrtc-review.googlesource.com/87841
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23999}
This commit is contained in:
Alex Loiko
2018-07-16 13:38:32 +02:00
committed by Commit Bot
parent 9eec01c5e0
commit 684b401016

View File

@ -12,6 +12,7 @@
#include <algorithm>
#include <array>
#include <cmath>
#include <numeric>
#include "rtc_base/checks.h"
@ -61,6 +62,13 @@ void ComputeInitialInverseFilterCoefficients(
reflection_coeff += lpc_coeffs[j] * auto_corr[i - j];
}
reflection_coeff += auto_corr[i + 1];
// Avoid division by numbers close to zero.
constexpr float kMinErrorMagnitude = 1e-6f;
if (std::fabs(error) < kMinErrorMagnitude) {
error = std::copysign(kMinErrorMagnitude, error);
}
reflection_coeff /= -error;
// Update LPC coefficients and total error.
lpc_coeffs[i] = reflection_coeff;