From 2e84f3f4edf07e2040c83909dc09457d43a326f4 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 17 Jun 2025 12:41:36 +0530 Subject: [PATCH 1/2] Fix for 3GPP issue 986: Stereo decoding, 16-20 kHz difference Link #986 Differences existed due to an addition with a factor (0.001f) missing in fixed point code. Changes added to address the same. --- lib_com/swb_tbe_com_fx.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index e4d84ef23..fcd4e12ee 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6935,7 +6935,10 @@ void synthesise_fb_high_band_fx( Word32 temp1; Word32 ratio2; Word32 L_tmp; - Word16 tmp3, tmp1, tmp2, exp, exp2, exp_tmp; + Word16 tmp3, tmp1, tmp2, exp, exp2, exp_tmp, sft, t_Q /* to store temporary Q for computations */; + Word64 P_ONE = 33; /* 0.001f in Q15 */ + move64(); + Word64 W_temp; /* Interpolate the white energy shaped gaussian excitation from 16 kHz to 48 kHz with zeros */ j = 0; @@ -6982,17 +6985,28 @@ void synthesise_fb_high_band_fx( elliptic_bpf_48k_generic_fx( excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_1_fx ); #endif } + /* temp1 = sum2_f( tmp, L_FRAME48k ) + 0.001f */ temp1 = sum2_fx_mod( tmp, L_FRAME48k ); + t_Q = sub( shl( exp_tmp, 1 ), 8 ); + P_ONE = W_shl( P_ONE, sub( t_Q, 15 ) ); + + W_temp = W_add( P_ONE, temp1 ); + + sft = W_norm( W_temp ); + W_temp = W_shl( W_temp, sft ); + + temp1 = W_extract_h( W_temp ); + t_Q = sub( add( t_Q, sft ), 32 ); + L_tmp = L_max( 1, fb_exc_energy ); /*Q(2*Q_fb_exc + 1)*/ exp = norm_l( L_tmp ); tmp3 = extract_h( L_shl( L_tmp, exp ) ); tmp1 = sub( add( Q_fb_exc, Q_fb_exc ), 8 ); /* 1-9*/ exp = sub( sub( 31, tmp1 ), exp ); - exp2 = norm_l( temp1 ); - tmp2 = extract_h( L_shl( temp1, exp2 ) ); - exp2 = sub( sub( 31, sub( shl( exp_tmp, 1 ), 8 ) ), exp2 ); /* in Q15 (temp1 in Q9)*/ + tmp2 = extract_h( temp1 ); + exp2 = sub( 31, t_Q ); exp = sub( exp2, exp ); /* Denormalize and substract */ IF( GT_16( tmp2, tmp3 ) ) -- GitLab From b3c03a1f9dde36299e6a4b6e6fcf14033cdac69a Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 17 Jun 2025 17:09:22 +0530 Subject: [PATCH 2/2] EVS bit exactness fix --- lib_com/swb_tbe_com_fx.c | 45 +++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index fcd4e12ee..2cb51ae93 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6935,10 +6935,7 @@ void synthesise_fb_high_band_fx( Word32 temp1; Word32 ratio2; Word32 L_tmp; - Word16 tmp3, tmp1, tmp2, exp, exp2, exp_tmp, sft, t_Q /* to store temporary Q for computations */; - Word64 P_ONE = 33; /* 0.001f in Q15 */ - move64(); - Word64 W_temp; + Word16 tmp3, tmp1, tmp2, exp, exp2, exp_tmp; /* Interpolate the white energy shaped gaussian excitation from 16 kHz to 48 kHz with zeros */ j = 0; @@ -6988,25 +6985,39 @@ void synthesise_fb_high_band_fx( /* temp1 = sum2_f( tmp, L_FRAME48k ) + 0.001f */ temp1 = sum2_fx_mod( tmp, L_FRAME48k ); - t_Q = sub( shl( exp_tmp, 1 ), 8 ); - P_ONE = W_shl( P_ONE, sub( t_Q, 15 ) ); - - W_temp = W_add( P_ONE, temp1 ); - - sft = W_norm( W_temp ); - W_temp = W_shl( W_temp, sft ); - - temp1 = W_extract_h( W_temp ); - t_Q = sub( add( t_Q, sft ), 32 ); - L_tmp = L_max( 1, fb_exc_energy ); /*Q(2*Q_fb_exc + 1)*/ exp = norm_l( L_tmp ); tmp3 = extract_h( L_shl( L_tmp, exp ) ); tmp1 = sub( add( Q_fb_exc, Q_fb_exc ), 8 ); /* 1-9*/ exp = sub( sub( 31, tmp1 ), exp ); - tmp2 = extract_h( temp1 ); - exp2 = sub( 31, t_Q ); + IF( element_mode != EVS_MONO ) + { + Word16 sft, t_Q; + Word64 P_ONE = 33; /* 0.001f in Q15 */ + move64(); + Word64 W_temp; + + t_Q = sub( shl( exp_tmp, 1 ), 8 ); + P_ONE = W_shl( P_ONE, sub( t_Q, 15 ) ); + + W_temp = W_add( P_ONE, temp1 ); + + sft = W_norm( W_temp ); + W_temp = W_shl( W_temp, sft ); + + temp1 = W_extract_h( W_temp ); + t_Q = sub( add( t_Q, sft ), 32 ); + + tmp2 = extract_h( temp1 ); + exp2 = sub( 31, t_Q ); + } + ELSE + { + exp2 = norm_l( temp1 ); + tmp2 = extract_h( L_shl( temp1, exp2 ) ); + exp2 = sub( sub( 31, sub( shl( exp_tmp, 1 ), 8 ) ), exp2 ); /* in Q15 (temp1 in Q9)*/ + } exp = sub( exp2, exp ); /* Denormalize and substract */ IF( GT_16( tmp2, tmp3 ) ) -- GitLab