From 68e750905d1ede809013fd7fd2a93764f9897fc7 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 6 May 2025 21:23:11 +0530 Subject: [PATCH 1/3] Fix for 3GPP issue 1449: OMASA Complexity measurement crashes Link #1449 --- lib_enc/ivas_masa_enc_fx.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index ceb5dec1d..9d0579d12 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -2463,19 +2463,23 @@ static void reduce_metadata_further_fx( } /* Determine if to merge over frequency instead of time */ - meanRatio = 0; - move32(); + W_tmp = 0; + move64(); FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) { FOR( band = 0; band < numCodingBands; band++ ) { - meanRatio = L_add( meanRatio, Mpy_32_32( hqmetadata->q_direction[0].band_data[band].energy_ratio_fx[sf], energy[sf][band] ) ); // hMasa->data.q_energy - 1 + W_tmp = W_mac_32_16( W_tmp, Mpy_32_32( hqmetadata->q_direction[0].band_data[band].energy_ratio_fx[sf], energy[sf][band] ), 1 ); // hMasa->data.q_energy } } + shift = W_norm( W_tmp ); + meanRatio = W_extract_h( W_shl( W_tmp, shift ) ); // Q:sub( add( hMasa->data.q_energy, shift ), 32 ) + shift = sub( 31, sub( add( hMasa->data.q_energy, shift ), 32 ) ); + IF( totalEnergySum != 0 ) { meanRatio = BASOP_Util_Divide3232_Scale_newton( meanRatio, totalEnergySum, &exp ); - exp = add( add( exp, 1 ), tmp2 ); // 31 - (hMasa->data.q_energy - 1) - 31 - hMasa->data.q_energy - tmp2 => 1 + tmp2 + exp = add( exp, sub( shift, sub( 31, add( hMasa->data.q_energy, tmp2 ) ) ) ); // exp + (shift - (31 - hMasa->data.q_energy - tmp2)) => 1 + tmp2 } ELSE { -- GitLab From 4fc3bd03def4d5cfdc82c15b2772ec97bf5f2c65 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 7 May 2025 10:23:34 +0530 Subject: [PATCH 2/3] Fix for crash in acelp path --- lib_enc/set_impulse_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/set_impulse_fx.c b/lib_enc/set_impulse_fx.c index 9ad5f4a2c..d4dd73abe 100644 --- a/lib_enc/set_impulse_fx.c +++ b/lib_enc/set_impulse_fx.c @@ -285,10 +285,10 @@ static void convolve_tc_fx( L_sum = L_mult( g[0], h[n] ); /* Qx */ FOR( i = 1; i < len; i++ ) { - L_sum = L_mac( L_sum, g[i], h[n - i] ); /* Qx + 16 */ + L_sum = L_mac_sat( L_sum, g[i], h[n - i] ); /* Qx + 16 */ } - y[n] = round_fx( L_sum ); /* Qx */ + y[n] = round_fx_sat( L_sum ); /* Qx */ } } /*-------------------------------------------------------------------* -- GitLab From e123cac9ebda717c88eb823b15af0d206d4a6e34 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 7 May 2025 16:54:37 +0530 Subject: [PATCH 3/3] Fix for decoder crash --- lib_dec/swb_tbe_dec_fx.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 890e0e5c8..a541ebf7b 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -618,6 +618,7 @@ void ivas_wb_tbe_dec_fx( move16(); Word32 dummy2[HILBERT_MEM_SIZE]; Word16 f, inc; + Word64 W_tmp; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -853,17 +854,20 @@ void ivas_wb_tbe_dec_fx( move16(); /* restrict this to 21 due to the Q factor requireemnt of the random number generator (keep 1 bit headroom) */ } - prev_pow = 0; - move32(); + W_tmp = 0; + move64(); IF( st_fx->element_mode > EVS_MONO ) { tmp = sub( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 31 + 16 ); - prev_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ + W_tmp = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ } FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) { - prev_pow = L_mac0( prev_pow, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ + W_tmp = W_mac_16_16( W_tmp, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /*Q(2*(st_fx->prev_Q_bwe_exc-16 + 1))*/ } + exp = W_norm( W_tmp ); + prev_pow = W_extract_h( W_shl( W_tmp, exp ) ); + exp = sub( add( add( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 1 ), exp ), 32 ); rescale_genWB_mem( st_fx, sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ) ); @@ -901,7 +905,7 @@ void ivas_wb_tbe_dec_fx( } Lscale = root_a_over_b_fx( curr_pow, shl_r( Q_bwe_exc_ext, 1 ), prev_pow, - shl_r( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), &exp ); + exp, &exp ); FOR( i = 0; i < L_SHB_LAHEAD / 4 - 1; i++ ) { -- GitLab