From 8166502969e261270d098146c3fcae37d92d3c50 Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Fri, 29 Jun 2018 16:33:30 +0200 Subject: Prevent overflow in usac filters Bug: 112663886 Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc Change-Id: Ie7af65a1a556afb141ea5272f70bfea11881ac30 --- libAACdec/src/usacdec_fac.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'libAACdec/src/usacdec_fac.cpp') diff --git a/libAACdec/src/usacdec_fac.cpp b/libAACdec/src/usacdec_fac.cpp index 71ce4a9..f349ede 100644 --- a/libAACdec/src/usacdec_fac.cpp +++ b/libAACdec/src/usacdec_fac.cpp @@ -191,13 +191,11 @@ static void Syn_filt_zero(const FIXP_LPC a[], const INT a_exp, INT length, L_tmp = (FIXP_DBL)0; for (j = 0; j < fMin(i, M_LP_FILTER_ORDER); j++) { - L_tmp -= fMultDiv2(a[j], x[i - (j + 1)]); + L_tmp -= fMultDiv2(a[j], x[i - (j + 1)]) >> (LP_FILTER_SCALE - 1); } - L_tmp = scaleValue(L_tmp, a_exp + 1); - - x[i] = scaleValueSaturate((x[i] >> 1) + (L_tmp >> 1), - 1); /* Avoid overflow issues and saturate. */ + L_tmp = scaleValue(L_tmp, a_exp + LP_FILTER_SCALE); + x[i] = fAddSaturate(x[i], L_tmp); } } -- cgit v1.2.3