From a31c149eb178bd9c5938164fb31a67c5343ed6ab Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 30 May 2025 18:10:18 +0530 Subject: [PATCH] Fix for 3GPP issue 1123: MLD in the range of 5 to 12 between signals decoded from 256kbps encoded SBA bitstreams at input level -16LKFS Link #1123 --- lib_enc/tcx_utils_enc_fx.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 680a69fa5..2d3c7ce47 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1392,25 +1392,33 @@ void tcx_scalar_quantization_ivas_fx( s = sub( add( x_e, gain_e ), 15 ); } - /* substract 0x8000 to affect the mac_r in the following loop - so it acts like extract_h. the 0x4000 will be multiplied by 2 - by the mac_r to get to 0x8000 and disable the round. */ - offset = sub( offset, 0x4000 ); - FOR( ; i >= 0; i-- ) { - offs32 = Mpy_32_16_1( L_abs( x[i] ), gain ); /* multiply */ - offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ - tmp16 = mac_r_sat( offs32, offset, 1 ); /* add offset and truncate */ - IF( x[i] < 0 ) + offs32 = Mpy_32_16_1( x[i], gain ); /* multiply */ + offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ + IF( x[i] > 0 ) { - tmp16 = negate( tmp16 ); /* restore sign */ + offs32 = L_add_sat( offs32, L_shl( offset, 1 ) ); + tmp16 = extract_h( offs32 ); + IF( GT_32( L_deposit_h( tmp16 ), offs32 ) ) + { + tmp16 = sub( tmp16, 1 ); + } + } + ELSE + { + offs32 = L_add_sat( offs32, L_shl( negate( offset ), 1 ) ); + tmp16 = extract_h( offs32 ); + IF( LT_32( L_deposit_h( tmp16 ), offs32 ) ) + { + tmp16 = add( tmp16, 1 ); + } } - xq[i] = tmp16; move16(); } + IF( alfe_flag == 0 ) { AdaptLowFreqEmph_fx( x, x_e, xq, gain, gain_e, -- GitLab