From 54667d2dfd07af5f296fb224a888b6941e7d8b6f Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 23 Dec 2024 14:17:31 +0530 Subject: [PATCH] Fix for 3GPP issue 1132: crash stereo_tca_enc_fx() for stereo encoder Link #1132 --- lib_com/options.h | 1 + lib_enc/ivas_stereo_switching_enc.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 68c2542f2..89a69290b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -104,4 +104,5 @@ #define FIX_1100_REMOVE_LPC_RESCALING /* VA: Remove the rescaling of LPC coefficient to Q12 as residu and syn-filt are already taking care of it*/ #define FIX_ISSUE_1122 /* Ittiam: Fix issue 1122: corrected incorrect scaling of a buffer leading to incorrect metadata bits */ +#define FIX_1132_STACK_CORRUPTION /* Stack corruption issue due of extending index access*/ #endif diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc.c index ba84be1a2..63a44ab5e 100644 --- a/lib_enc/ivas_stereo_switching_enc.c +++ b/lib_enc/ivas_stereo_switching_enc.c @@ -241,7 +241,16 @@ ivas_error stereo_memory_enc_fx( test(); IF( hCPE->hStereoTCA != NULL && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) ) { +#ifdef FIX_1132_STACK_CORRUPTION + Word16 tmp = extract_h( abs( hCPE->hStereoDft->hItd->itd_fx[1] ) ); + if ( hCPE->hStereoDft->hItd->itd_fx[1] < 0 ) + { + tmp = negate( tmp ); + } + set16_fx( hCPE->hStereoTCA->prevCorrLagStats, tmp, 3 ); +#else set16_fx( hCPE->hStereoTCA->prevCorrLagStats, extract_h( hCPE->hStereoDft->hItd->itd_fx[1] ), 3 ); +#endif IF( hCPE->hStereoDft->hItd->itd_fx[1] >= 0 ) { hCPE->hStereoTCA->prevRefChanIndx = L_CH_INDX; -- GitLab