From ce078ea0b9ebeba5c29716e3015d3f011c06076a Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Sun, 29 Sep 2024 23:40:49 +0530 Subject: [PATCH] LTV crash fix - 1 [x] Fix for the crash [ltv-2 ISM with metadata at 64 kbps, 48 kHz in, 32 kHz out, 5_1 out] --- lib_enc/igf_enc.c | 11 ++++++++++- lib_enc/ivas_core_enc.c | 2 +- lib_enc/tcx_utils_enc_fx.c | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index 6a8f3f3f9..1440ecb4b 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -1151,7 +1151,16 @@ static void IGF_CalculateEnvelope_ivas_fx( hPrivateData->sfb_tb_e[sfb] = BASOP_Util_Add_MantExp( tmp_tb, tmp_tb_e, x1, x1_e, &hPrivateData->SFM_tb_fx[sfb] ); // hPrivateData->sfb_sb_e[sfb] hPrivateData->SFM_tb_fx[sfb] = extract_l( L_min( L_shl( 22118 /*2.7f Q13*/, sub( 2, hPrivateData->sfb_tb_e[sfb] ) ), hPrivateData->SFM_tb_fx[sfb] ) ); hPrivateData->sfb_sb_e[sfb] = BASOP_Util_Add_MantExp( tmp_sb, tmp_sb_e, x2, x2_e, &hPrivateData->SFM_sb_fx[sfb] ); // hPrivateData->sfb_tb_e[sfb] - hPrivateData->SFM_sb_fx[sfb] = extract_l( L_min( L_shl( 22118 /*2.7f Q13*/, sub( 2, hPrivateData->sfb_sb_e[sfb] ) ), hPrivateData->SFM_sb_fx[sfb] ) ); + IF( LT_16( hPrivateData->sfb_sb_e[sfb], 2 ) ) + { + hPrivateData->SFM_sb_fx[sfb] = extract_l( L_min( 22118 /*2.7f Q13*/, L_shr( hPrivateData->SFM_sb_fx[sfb], sub( 2, hPrivateData->sfb_sb_e[sfb] ) ) ) ); + hPrivateData->sfb_sb_e[sfb] = 2; + move16(); + } + ELSE + { + hPrivateData->SFM_sb_fx[sfb] = extract_l( L_min( L_shl( 22118 /*2.7f Q13*/, sub( 2, hPrivateData->sfb_sb_e[sfb] ) ), hPrivateData->SFM_sb_fx[sfb] ) ); + } move16(); move16(); move16(); diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index f75c8db80..c3b4beaae 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -687,7 +687,7 @@ ivas_error ivas_core_enc( { FOR( i = 0; i < L_FRAME32k; i++ ) { - st->hTcxEnc->old_out_fx[i] = (Word16) st->hTcxEnc->old_out[i] * ( 1 << 0 ); + st->hTcxEnc->old_out_fx[i] = float_to_fix16_thrld( st->hTcxEnc->old_out[i], 0 ); } } diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 1ff363360..e94b19229 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -2489,7 +2489,7 @@ void tcx_encoder_memory_update_ivas_fx( { /* Update weighted synthesis */ Residu3_fx( Ai + imult1616( sub( st->nb_subfr, 1 ), ( M + 1 ) ), synth + sub( L_frame_glob, 1 ), &tmp, 1, 0 ); - LPDmem->mem_w0 = sub( wsig[sub( L_frame_glob, 1 )], tmp ); + LPDmem->mem_w0 = sub_sat( wsig[sub( L_frame_glob, 1 )], tmp ); move16(); } -- GitLab