Merge "Prevent overflow in usac filters"

am: 4053380094

Change-Id: If0b450840199cde16e10e9a7911c7a8d331b7caa
This commit is contained in:
Jean-Michel Trivi 2018-12-26 17:59:40 -08:00 committed by android-build-merger
commit eaad782db3
3 changed files with 9 additions and 10 deletions

View File

@ -579,11 +579,11 @@ void Syn_filt(const FIXP_LPC a[], /* (i) : a[m] prediction coefficients Q12 */
L_tmp = (FIXP_DBL)0; L_tmp = (FIXP_DBL)0;
for (j = 0; j < M_LP_FILTER_ORDER; j++) { 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); L_tmp = scaleValue(L_tmp, a_exp + LP_FILTER_SCALE);
y[i] = L_tmp + x[i]; y[i] = fAddSaturate(L_tmp, x[i]);
} }
return; 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; s = (FIXP_DBL)0;
for (j = 0; j < M_LP_FILTER_ORDER; j++) { 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]); y[i] = fAddSaturate(s, x[i]);
} }

View File

@ -115,6 +115,7 @@ amm-info@iis.fraunhofer.de
/* definitions which are independent of coreCoderFrameLength */ /* definitions which are independent of coreCoderFrameLength */
#define M_LP_FILTER_ORDER 16 /* LP filter order */ #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_MIN_12k8 34 /* Minimum pitch lag with resolution 1/4 */
#define PIT_MAX_12k8 231 /* Maximum pitch lag for fs=12.8kHz */ #define PIT_MAX_12k8 231 /* Maximum pitch lag for fs=12.8kHz */

View File

@ -191,13 +191,11 @@ static void Syn_filt_zero(const FIXP_LPC a[], const INT a_exp, INT length,
L_tmp = (FIXP_DBL)0; L_tmp = (FIXP_DBL)0;
for (j = 0; j < fMin(i, M_LP_FILTER_ORDER); j++) { 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); L_tmp = scaleValue(L_tmp, a_exp + LP_FILTER_SCALE);
x[i] = fAddSaturate(x[i], L_tmp);
x[i] = scaleValueSaturate((x[i] >> 1) + (L_tmp >> 1),
1); /* Avoid overflow issues and saturate. */
} }
} }