From 2d2d72145471d80f47eb7c3e44552b958c1d690c Mon Sep 17 00:00:00 2001 From: Anjaneyulu Sana Date: Wed, 16 Apr 2025 17:04:44 +0530 Subject: [PATCH] Fix for 3GPP issue 1491: [regression] Encoder crash for MCT-MC 5.1 at 32kHz/SWB in bw_detect_fx() --- lib_enc/bw_detect_fx.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index 8a150d514..30382cfba 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -336,24 +336,33 @@ void bw_detect_fx( sum32 = L_mac0_o( sum32, *pt1, *pt1, &Overflow ); pt1++; } - - IF( LE_32( sum32, 1 ) ) + 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*/ ) { - /*deal with zero spectrum*/ - spect_bin[i] = -1; + spect_bin[i] = -6144; /* log10f( 0.00100000005 ) in Q11 */ move16(); } ELSE { - /* spect_bin[i] = (float)log10(spect_bin[i]); - = log2(spect_bin[i])*log10(2); */ - e_tmp = norm_l( sum32 ); - L_tmp = L_shl( sum32, e_tmp ); - f_tmp = Log2_norm_lc( L_tmp ); - e_tmp = sub( sub( 30, e_tmp ), Q_dct ); - L_tmp = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */ - spect_bin[i] = round_fx( L_shl( L_tmp, 11 ) ); /* Q11 */ - move16(); + IF( LE_32( sum32, 1 ) ) + { + /*deal with zero spectrum*/ + spect_bin[i] = -1; + move16(); + } + ELSE + { + /* spect_bin[i] = (float)log10(spect_bin[i]); + = log2(spect_bin[i])*log10(2); */ + e_tmp = norm_l( sum32 ); + L_tmp = L_shl( sum32, e_tmp ); + f_tmp = Log2_norm_lc( L_tmp ); + e_tmp = sub( sub( 30, e_tmp ), Q_dct ); + L_tmp = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */ + spect_bin[i] = round_fx( L_shl( L_tmp, 11 ) ); /* Q11 */ + move16(); + } } } } -- GitLab