From c940b16812a64fcae3c7d609f7e9783604495c59 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 22 Jul 2024 21:53:23 +0530 Subject: [PATCH] Fix for LTV crash occuring in ivas_swb_tbe_dec_fx --- lib_dec/swb_tbe_dec.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c index 0bd0bb8b7..870b656fa 100644 --- a/lib_dec/swb_tbe_dec.c +++ b/lib_dec/swb_tbe_dec.c @@ -1972,8 +1972,11 @@ void ivas_swb_tbe_dec_fx( #endif } } - ener_fx = s_max( 1, round_fx( L_shl( L_ener, sub( 18, shl( Q_bwe_exc, 1 ) ) ) ) ); /* Q2: 2*Q_bwe_exc+18-2*Q_bwe_exc-16 */ - +#ifdef BASOP_NOGLOB /* Saturation fix taken from EVS*/ + ener_fx = s_max( 1, round_fx_sat( L_shl_sat( L_ener, sub( 18, shl( Q_bwe_exc, 1 ) ) ) ) ); /* Q2: 2*Q_bwe_exc+18-2*Q_bwe_exc-16 */ +#else + ener_fx = s_max( 1, round_fx( L_shl( L_ener, sub( 18, shl( Q_bwe_exc, 1 ) ) ) ) ); /* Q2: 2*Q_bwe_exc+18-2*Q_bwe_exc-16 */ +#endif /* WB/SWB bandwidth switching */ IF( st->bws_cnt > 0 ) { @@ -2653,7 +2656,11 @@ void ivas_swb_tbe_dec_fx( tmp = div_s( 16384, tmp ); L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); +#ifdef BASOP_NOGLOB /* Saturation fix taken from EVS*/ + st->prev_ener_shb_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ +#else st->prev_ener_shb_fx = round_fx( L_shl( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ +#endif move16(); } @@ -2671,7 +2678,11 @@ void ivas_swb_tbe_dec_fx( tmp = div_s( 16384, tmp ); L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); - tmp = round_fx( L_shl( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ +#ifdef BASOP_NOGLOB /* Saturation fix taken from EVS*/ + tmp = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ +#else + tmp = round_fx( L_shl( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ +#endif } set16_fx( st->prev_SWB_fenv_fx, tmp, SWB_FENV ); /* Q1 */ } -- GitLab