From 35e6a02a833f6ca70218074e7b8b6cb48964e2d0 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 22 Oct 2024 20:59:09 +0530 Subject: [PATCH] Fix for 3gpp issue 926: Usage of L_shl(), L_shl_o(), L_shl_sat() and L_shr(), L_shr_o(), L_shr_sat() --- lib_com/ivas_spar_com.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index fb5cb5792..31e787a78 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -2077,6 +2077,7 @@ static void ivas_calc_p_coeffs_per_band_fx( Word32 cov_dd_re[IVAS_SPAR_MAX_CH - 1][IVAS_SPAR_MAX_CH - 1]; Word32 cov_uu_re[IVAS_SPAR_MAX_CH - 1][IVAS_SPAR_MAX_CH - 1]; Word16 b_ts_idx; + Word16 tmp; b_ts_idx = add( band_idx, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) ); @@ -2230,7 +2231,7 @@ static void ivas_calc_p_coeffs_per_band_fx( Word16 factor_exp = 0; move16(); factor = BASOP_Util_Divide3232_Scale( L_shl( 1, q_postpred_cov_re ), factor, &factor_exp ); - factor = L_shl_sat( factor, factor_exp ); + tmp = sub( 15, factor_exp ); /* normalise Hermitian (except for rounding) cov_uu */ FOR( i = num_dmx; i < num_ch; i++ ) @@ -2240,7 +2241,7 @@ static void ivas_calc_p_coeffs_per_band_fx( IF( EQ_16( i, j ) ) { /* force diagonal to be real */ - cov_uu_re[sub( i, num_dmx )][sub( j, num_dmx )] = W_extract_l( W_shr( W_mult0_32_32( cov_uu_re[sub( i, num_dmx )][sub( j, num_dmx )], factor ), 15 ) ); + cov_uu_re[sub( i, num_dmx )][sub( j, num_dmx )] = W_extract_l( W_shr( W_mult0_32_32( cov_uu_re[sub( i, num_dmx )][sub( j, num_dmx )], factor ), tmp ) ); move32(); } ELSE @@ -3736,7 +3737,8 @@ void ivas_get_spar_md_from_dirac_fx( } - en_ratio_fac_fx = L_sub( ONE_IN_Q31, L_shl_sat( diffuseness_fx[band], 1 ) ); // assuming q of dissusion 30 + en_ratio_fac_fx = L_shl( L_sub( ONE_IN_Q30 - EPSILON_FX /* Guard to prevent overflow if diffuseness_fx is 0 */, diffuseness_fx[band] ), 1 ); // assuming q of dissusion 30 + en_ratio_fac_fx = L_max( en_ratio_fac_fx, 0 ); FOR( i = 0; i < num_ch; i++ ) { -- GitLab