From d80b5ea123605a6e959539370ccab5f1be076e88 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 25 Apr 2025 14:27:46 +0530 Subject: [PATCH] Fix for 3GPP issue 1516: BASOP encoder crash with OSBA with 4 objects Link #1516 --- lib_enc/bw_detect_fx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index 30382cfba..050adbf01 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -48,7 +48,7 @@ void bw_detect_fx( const Word16 mct_on, /* i : flag MCT mode */ const Word16 Q_spec ) { - Word16 Q_dct; + Word16 Q_dct, E_spect_bin, tmp_1; Word16 i, j, k, bw_max, bin_width, n_bins; Word16 max_NB, max_WB, max_SWB, max_FB, mean_NB, mean_WB, mean_SWB, mean_FB; /* Q11*/ const Word16 *pt, *pt1; @@ -324,6 +324,7 @@ void bw_detect_fx( set16_fx( spect_bin, 1, n_bins ); Q_dct = shl( Q_dct, 1 ); + E_spect_bin = sub( Q31, Q_dct ); FOR( k = 0; k <= bw_max; k++ ) { @@ -336,9 +337,9 @@ void bw_detect_fx( sum32 = L_mac0_o( sum32, *pt1, *pt1, &Overflow ); pt1++; } + tmp_1 = BASOP_Util_Cmp_Mant32Exp( sum32, E_spect_bin, MAX_32, Q31 - 41 ); /* Any sum32 in Q_dct if it is less than MAX_32 in Q41 will be less than 0.001 */ test(); - test(); - IF( st->element_mode != EVS_MONO && EQ_32( sum32, MAX_32 ) && GT_16( Q_dct, 41 ) /* Any Q-value greater than Q41 for MAX_32 will be less than 0.001*/ ) + IF( st->element_mode != EVS_MONO && tmp_1 < 0 ) { spect_bin[i] = -6144; /* log10f( 0.00100000005 ) in Q11 */ move16(); -- GitLab