From 5eeee2c07cf0852aaf714c9ab6ca5cd1bfefb3af Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 1 Oct 2024 12:05:52 +0530 Subject: [PATCH] BASOP optimizations [x] sum_32_fx 64-bit operator usage [x] MAC basop usage in TNSAnalysisStereo --- lib_com/swb_bwe_com_fx.c | 6 +++--- lib_com/tools_fx.c | 20 ++++++++++---------- lib_enc/cod_tcx.c | 4 ++-- lib_enc/ivas_core_pre_proc_front.c | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index 29662510a..0025812db 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -543,7 +543,7 @@ void calc_normal_length_fx( pit++; } - L_tmp = L_mult0( peak, add( 15, THRES ) ); /*Q_syn */ + L_tmp = L_mult0( peak, 15 + THRES ); /*Q_syn */ IF( EQ_16( THRES, 8 ) ) { L_tmp1 = L_shl( Mpy_32_16_1( L_mean, 32767 ), 3 ); @@ -877,7 +877,7 @@ void calc_norm_envelop_fx( } envelope[env_index] = L_tmp; move32(); - env_index = add( env_index, 1 ); + env_index++; } i = 0; @@ -896,7 +896,7 @@ void calc_norm_envelop_fx( } envelope[env_index] = L_tmp; move32(); - env_index = add( env_index, 1 ); + env_index++; i = add( i, 1 ); } diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index e65652e03..88f0a896f 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -423,22 +423,22 @@ Word32 sum_32_fx( const Word16 lvec, /* i : length of input vector */ Word16 *e ) { - Word16 i; - Word32 tmp; + Word16 i, shift; + Word64 tmp = 0; + move64(); + Word32 ans; - tmp = 0; - Word16 exp = 0; - move32(); - move16(); FOR( i = 0; i < lvec; i++ ) { - tmp = BASOP_Util_Add_Mant32Exp( tmp, exp, vec[i], *e, &exp ); + tmp = W_add( tmp, vec[i] ); // e } - - *e = exp; + shift = W_norm( tmp ); + tmp = W_shl( tmp, shift ); // shift + (31 - e) + ans = W_extract_h( tmp ); // shift + (31 - e) - 32 + *e = add( sub( *e, shift ), 32 ); move16(); - return tmp; + return ans; } Word32 sum2_fx_mod( /* o : sum of all squared vector elements Q(2x+1 -5)*/ diff --git a/lib_enc/cod_tcx.c b/lib_enc/cod_tcx.c index 2acc3bab6..4508bfb64 100644 --- a/lib_enc/cod_tcx.c +++ b/lib_enc/cod_tcx.c @@ -278,8 +278,8 @@ void TNSAnalysisStereo_fx( * both filters for the decision */ - meanPredictionGain_fx = add( shr( pFilter[0]->predictionGain, 1 ), shr( pFilter[1]->predictionGain, 1 ) ); // Q7 - maxPredictionGain_fx = s_max( maxPredictionGain_fx, meanPredictionGain_fx ); // Q7 + meanPredictionGain_fx = mac_r( L_mult( pFilter[0]->predictionGain, 16384 ), pFilter[1]->predictionGain, 16384 ); // Q7 + maxPredictionGain_fx = s_max( maxPredictionGain_fx, meanPredictionGain_fx ); // Q7 test(); test(); diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 72d95d33d..115f1aae3 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -2073,7 +2073,7 @@ ivas_error pre_proc_front_ivas_fx( Word16 stab_fac_fx; Word16 Q_new_loc; Word16 Q_r[2] = { 0 }; - Word16 A_loc_fx[NB_SUBFR16k * ( M + 1 )]; + Word16 A_loc_fx[NB_SUBFR16k * ( M + 1 )] = { 0 }; Word16 epsP_l_loc[M + 1]; Word16 epsP_h_loc[M + 1]; Word32 ener_fx; -- GitLab