From 1482c15cd4abb42977c4544e295535c277e76a55 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Sat, 2 Mar 2024 22:28:15 +0530 Subject: [PATCH] Fix for crash issue 689 [x] Added fix for write access violation happening in save_synthesis_hq_fec_fx(). [x] Fixes crash in stereo_dft_dec function. --- lib_dec/init_dec.c | 5 ++--- lib_dec/ivas_cpe_dec_fx.c | 3 ++- lib_dec/ivas_stereo_switching_dec.c | 6 +++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c index 1d9fe75ca..10e4d9f69 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -607,11 +607,10 @@ ivas_error init_decoder( set_f( st->hTcxDec->FBTCXdelayBuf_float, 0.0f, 111 ); st->hTcxDec->old_synthFB = st->hTcxDec->synth_history + NS2SA( st->output_Fs, PH_ECU_MEM_NS ); -#ifdef IVAS_FLOAT_FIXED - st->hTcxDec->old_synthFB_fx = st->hTcxDec->synth_history_fx + NS2SA( st->output_Fs, PH_ECU_MEM_NS ); -#endif st->hTcxDec->prev_good_synth = st->hTcxDec->old_synthFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ); #ifdef IVAS_FLOAT_FIXED + set32_fx(st->hTcxDec->FBTCXdelayBuf, 0, 111); + st->hTcxDec->old_synthFB_fx = st->hTcxDec->synth_history_fx + NS2SA( st->output_Fs, PH_ECU_MEM_NS ); st->hTcxDec->prev_good_synth_fx = st->hTcxDec->old_synthFB_fx + NS2SA(st->output_Fs, PH_ECU_LOOKAHEAD_NS); #endif } diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index 653581bd6..79a7c789a 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -527,7 +527,7 @@ ivas_error ivas_cpe_dec_fx( } } i_max_val_psd = (int)max_val; - sts[0]->hFdCngDec->q_smoothed_psd = norm_l(i_max_val_psd) - Q9; + sts[0]->hFdCngDec->q_smoothed_psd = norm_l(i_max_val_psd) - Q4; max_val = 0.0; for (int ii = 0; ii < sizeof(DFT) / sizeof(DFT[0]); ii++) { @@ -545,6 +545,7 @@ ivas_error ivas_cpe_dec_fx( { hCPE->hStereoDft->q_dft = Q15; } + hCPE->hStereoDft->q_dft = s_min(hCPE->hStereoDft->q_dft, sts[0]->hFdCngDec->q_smoothed_psd); IF (EQ_16(hCPE->hStereoDft->first_frame, 1)) { hCPE->hStereoDft->q_smoothed_nrg = hCPE->hStereoDft->q_dft; diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index e972bc7d8..ec9d619f5 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -768,7 +768,11 @@ ivas_error stereo_memory_dec( set_f( st->hTcxDec->FBTCXdelayBuf_float, 0.0f, 111 ); st->hTcxDec->old_synthFB = st->hTcxDec->synth_history + NS2SA( st->output_Fs, PH_ECU_MEM_NS ); st->hTcxDec->prev_good_synth = st->hTcxDec->old_synthFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ); - +#ifdef IVAS_FLOAT_FIXED + set32_fx(st->hTcxDec->FBTCXdelayBuf, 0, 111); + st->hTcxDec->old_synthFB_fx = st->hTcxDec->synth_history_fx + NS2SA(st->output_Fs, PH_ECU_MEM_NS); + st->hTcxDec->prev_good_synth_fx = st->hTcxDec->old_synthFB_fx + NS2SA(st->output_Fs, PH_ECU_LOOKAHEAD_NS); +#endif /* allocate and initialize MDCT stereo structure */ if ( ( hCPE->hStereoMdct = (STEREO_MDCT_DEC_DATA_HANDLE) malloc( sizeof( STEREO_MDCT_DEC_DATA ) ) ) == NULL ) { -- GitLab