From a589ca07a188fe0952335e4897057e45ff1deb5e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 23 Feb 2024 19:41:34 +0530 Subject: [PATCH] Updates to fix few LTV test crash issues. [x] Decrease the headroom passed for input buffer in TCX_MDST_Inverse(). [x] Added logic to prevent overflow due to left shift. [x] Used saturation basop for rounding function in ITF_detect_ivas_fx to prevent overflow. --- lib_com/tns_base.c | 2 +- lib_dec/dec_tcx.c | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c index 500938994..200bf1a78 100644 --- a/lib_com/tns_base.c +++ b/lib_com/tns_base.c @@ -600,7 +600,7 @@ Word16 ITF_Detect_ivas_fx( assert(n < (Word16)(sizeof(tmpbuf)/sizeof(Word16))); FOR (i = 0; i < n; i++) { - tmpbuf[i] = round_fx(L_shl(pSpectrum[iStartLine+i-IGF_START_MN], shift)); + tmpbuf[i] = round_fx_o(L_shl(pSpectrum[iStartLine+i-IGF_START_MN], shift), &Overflow); } FOR (lag = 0; lag <= maxOrder; lag++) diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 46ed2dd33..f011ec80c 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -360,7 +360,7 @@ void IMDCT_flt( Word32 x_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; Word16 win_fx[810] = { 0 }; Word16 q_x = Q16, q_win, x_e_hdrm; - x_e_hdrm = sub(q_x, 13); + x_e_hdrm = sub(q_x, 15); q_win = q_x + x_e_hdrm - 16; for ( int k = 0; k < L_ola + L_win; k++ ) { @@ -2125,12 +2125,17 @@ void decoder_tcx_imdct_fx( Word16 s = getScaleFactor32(x_fx, s_max(endLine, shr(L, 1))); s = sub(s, 2); - FOR(j = 0; j < s_max(endLine, shr(L, 1)); j++) + IF(s <= 0) { - x_fx[j] = L_shl(x_fx[j], s); - move32(); + FOR(j = 0; j < s_max(endLine, shr(L, 1)); j++) + { + x_fx[j] = L_shl(x_fx[j], s); + move32(); + } + x_e = sub(x_e, s); + } ELSE { + s = 0; } - x_e = sub(x_e, s); ITF_Apply_fx( x_fx, startLine, endLine, A_itf_fx, q_a_itf, curr_order ); -- GitLab