From 5d13d6119391e538eb42168058262407054feb15 Mon Sep 17 00:00:00 2001 From: Alessio Bazzica Date: Wed, 21 Oct 2020 13:30:55 +0200 Subject: [PATCH] RNN VAD: LP residual optimized (part 1) Use hard-coded constants previously computed at runtime within a loop in `ComputeAndPostProcessLpcCoefficients`. Note that the `RnnVadTest.LpResidualPipelineBitExactness` unit test is still passing. Bug: webrtc:10480 Change-Id: Iaec178c56937449c3fe9af881354d19cc8c47c7d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/189961 Commit-Queue: Alessio Bazzica Reviewed-by: Karl Wiberg Cr-Commit-Position: refs/heads/master@{#32462} --- .../agc2/rnn_vad/lp_residual.cc | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/audio_processing/agc2/rnn_vad/lp_residual.cc b/modules/audio_processing/agc2/rnn_vad/lp_residual.cc index 1a124a3493..dabe507202 100644 --- a/modules/audio_processing/agc2/rnn_vad/lp_residual.cc +++ b/modules/audio_processing/agc2/rnn_vad/lp_residual.cc @@ -101,17 +101,17 @@ void ComputeAndPostProcessLpcCoefficients( ComputeInitialInverseFilterCoefficients(auto_corr, lpc_coeffs_pre); // LPC coefficients post-processing. // TODO(bugs.webrtc.org/9076): Consider removing these steps. - float c1 = 1.f; - for (size_t i = 0; i < kNumLpcCoefficients - 1; ++i) { - c1 *= 0.9f; - lpc_coeffs_pre[i] *= c1; - } - const float c2 = 0.8f; - lpc_coeffs[0] = lpc_coeffs_pre[0] + c2; - lpc_coeffs[1] = lpc_coeffs_pre[1] + c2 * lpc_coeffs_pre[0]; - lpc_coeffs[2] = lpc_coeffs_pre[2] + c2 * lpc_coeffs_pre[1]; - lpc_coeffs[3] = lpc_coeffs_pre[3] + c2 * lpc_coeffs_pre[2]; - lpc_coeffs[4] = c2 * lpc_coeffs_pre[3]; + lpc_coeffs_pre[0] *= 0.9f; + lpc_coeffs_pre[1] *= 0.9f * 0.9f; + lpc_coeffs_pre[2] *= 0.9f * 0.9f * 0.9f; + lpc_coeffs_pre[3] *= 0.9f * 0.9f * 0.9f * 0.9f; + constexpr float kC = 0.8f; + lpc_coeffs[0] = lpc_coeffs_pre[0] + kC; + lpc_coeffs[1] = lpc_coeffs_pre[1] + kC * lpc_coeffs_pre[0]; + lpc_coeffs[2] = lpc_coeffs_pre[2] + kC * lpc_coeffs_pre[1]; + lpc_coeffs[3] = lpc_coeffs_pre[3] + kC * lpc_coeffs_pre[2]; + lpc_coeffs[4] = kC * lpc_coeffs_pre[3]; + static_assert(kNumLpcCoefficients == 5, "Update `lpc_coeffs(_pre)`."); } void ComputeLpResidual(