diff options
author | Jean-Michel Trivi <jmtrivi@google.com> | 2018-12-26 18:07:50 -0800 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-12-26 18:07:50 -0800 |
commit | 18d4dcf2551245c887962e34130cb24414b0b969 (patch) | |
tree | c85f22e09e179d9293d4c9e813b94157af297e1b /libAACdec | |
parent | 350e4ffea2b756a40a124db5ba341257299f1e3f (diff) | |
parent | eaad782db3d81611164cc195587c53a6b51b0922 (diff) | |
download | fdk-aac-18d4dcf2551245c887962e34130cb24414b0b969.tar.gz fdk-aac-18d4dcf2551245c887962e34130cb24414b0b969.tar.bz2 fdk-aac-18d4dcf2551245c887962e34130cb24414b0b969.zip |
Merge "Prevent overflow in usac filters" am: 4053380094
am: eaad782db3
Change-Id: I86ee269643f3247138c71ffe88a2a589bfce0357
Diffstat (limited to 'libAACdec')
-rw-r--r-- | libAACdec/src/usacdec_acelp.cpp | 10 | ||||
-rw-r--r-- | libAACdec/src/usacdec_const.h | 1 | ||||
-rw-r--r-- | libAACdec/src/usacdec_fac.cpp | 8 |
3 files changed, 9 insertions, 10 deletions
diff --git a/libAACdec/src/usacdec_acelp.cpp b/libAACdec/src/usacdec_acelp.cpp index af1f488..9fecebf 100644 --- a/libAACdec/src/usacdec_acelp.cpp +++ b/libAACdec/src/usacdec_acelp.cpp @@ -579,11 +579,11 @@ void Syn_filt(const FIXP_LPC a[], /* (i) : a[m] prediction coefficients Q12 */ L_tmp = (FIXP_DBL)0; for (j = 0; j < M_LP_FILTER_ORDER; j++) { - L_tmp -= fMultDiv2(a[j], y[i - (j + 1)]); + L_tmp -= fMultDiv2(a[j], y[i - (j + 1)]) >> (LP_FILTER_SCALE - 1); } - L_tmp = scaleValue(L_tmp, a_exp + 1); - y[i] = L_tmp + x[i]; + L_tmp = scaleValue(L_tmp, a_exp + LP_FILTER_SCALE); + y[i] = fAddSaturate(L_tmp, x[i]); } return; @@ -631,10 +631,10 @@ void E_UTIL_residu(const FIXP_LPC *a, const INT a_exp, FIXP_DBL *x, FIXP_DBL *y, s = (FIXP_DBL)0; for (j = 0; j < M_LP_FILTER_ORDER; j++) { - s += fMultDiv2(a[j], x[i - j - 1]); + s += fMultDiv2(a[j], x[i - j - 1]) >> (LP_FILTER_SCALE - 1); } - s = scaleValue(s, a_exp + 1); + s = scaleValue(s, a_exp + LP_FILTER_SCALE); y[i] = fAddSaturate(s, x[i]); } diff --git a/libAACdec/src/usacdec_const.h b/libAACdec/src/usacdec_const.h index c7dbae7..f68e808 100644 --- a/libAACdec/src/usacdec_const.h +++ b/libAACdec/src/usacdec_const.h @@ -115,6 +115,7 @@ amm-info@iis.fraunhofer.de /* definitions which are independent of coreCoderFrameLength */ #define M_LP_FILTER_ORDER 16 /* LP filter order */ +#define LP_FILTER_SCALE 4 /* LP filter scale */ #define PIT_MIN_12k8 34 /* Minimum pitch lag with resolution 1/4 */ #define PIT_MAX_12k8 231 /* Maximum pitch lag for fs=12.8kHz */ diff --git a/libAACdec/src/usacdec_fac.cpp b/libAACdec/src/usacdec_fac.cpp index 25d3119..c10a3fe 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); } } |