From a4a26f8cb09e240a365b8d4b474ed2cc173bbe73 Mon Sep 17 00:00:00 2001 From: Hiromi Sekine Date: Fri, 25 Apr 2025 09:43:33 +0900 Subject: [PATCH 1/3] =?UTF-8?q?Enhanced=20accuracy=20by=20renormalization?= =?UTF-8?q?=20in=20the=20frequency=20domain.=E3=80=80=20Added=20WMOPS=20co?= =?UTF-8?q?unter=20#estimate=5Fitd=5Fwnd=5Ffft=5Ffx,#calc=5Fpoc=5Ffx,#find?= =?UTF-8?q?=5Fpoc=5Fpeak=5Ffx,#estimate=5Fitd=5Ffx,#weighted=5Fave=5Ffx,#c?= =?UTF-8?q?alc=5Fenergy=5Ffx,#adapt=5Fgain=5Ffx,#create=5FM=5Fsignal=5Ffx,?= =?UTF-8?q?#stereo=5Fdmx=5Fevs=5Fenc=5Ffx.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib_com/options.h | 12 +-- lib_enc/ivas_stereo_dmx_evs_fx.c | 147 +++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2f1e82de8..b297f0d1a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -53,12 +53,12 @@ #define SUPPORT_JBM_TRACEFILE /* Support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */ -/*#define WMOPS*/ /* Activate complexity and memory counters */ +#define WMOPS /* Activate complexity and memory counters */ #ifdef WMOPS -/*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ -/*#define WMOPS_DETAIL*/ /* Output detailed complexity printout for every function. Increases runtime overhead */ -/*#define WMOPS_WC_FRAME_ANALYSIS*/ /* Output detailed complexity analysis for the worst-case frame */ -/*#define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */ +#define WMOPS_PER_FRAME /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ +#define WMOPS_DETAIL /* Output detailed complexity printout for every function. Increases runtime overhead */ +#define WMOPS_WC_FRAME_ANALYSIS /* Output detailed complexity analysis for the worst-case frame */ +/*define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */ #endif /* #################### End DEBUGGING switches ############################ */ @@ -94,6 +94,8 @@ #define FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 /*FhG: reduces WMOPS*/ #define FIX_1481_HARDCODE_DIV /* FhG: hardcode division results in stereo_dmx_evs_init_encoder_fx() */ #define FIX_1486_IND_SHB_RES /* VA: Fix for issue 1486: align the usage of IND_SHB_RES_GS indices with float code */ +#define FIX_1511_RENORM +#define FIX_1511_WMOPS #define TEST_HR #define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions, ACELP low-band decoder */ diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index 13ecbba00..21f5f48aa 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -223,6 +223,10 @@ void estimate_itd_wnd_fft_fx( Word16 step, bias; Word16 rshift; +#ifdef FIX_1511_WMOPS + push_wmops("estimate_itd_wnd_fft_fx"); +#endif + n0 = shr( input_frame, 1 ); IF( EQ_16( input_frame, L_FRAME16k ) ) { @@ -269,6 +273,10 @@ void estimate_itd_wnd_fft_fx( speci[n0] = 0; move32(); +#ifdef FIX_1511_WMOPS + pop_wmops(); +#endif + return; } @@ -322,6 +330,10 @@ static void calc_poc_fx( Word64 W_tmp; Word16 W_tmp_q; +#ifdef FIX_1511_WMOPS + push_wmops("calc_poc_fx"); +#endif + /* Initialization */ // iN = 1.0f / (float) input_frame; s = hPOC->sin_fx; @@ -412,6 +424,23 @@ static void calc_poc_fx( Rr = L_add( L_add( specRr[i], Mpy_32_32_r( specLr[i], eps_cos ) ), Mpy_32_32_r( specLi[i], eps_sin ) ); Ri = L_add( L_sub( specRi[i], Mpy_32_32_r( specLr[i], eps_sin ) ), Mpy_32_32_r( specLi[i], eps_cos ) ); +#ifdef FIX_1511_RENORM + { + Word32 TH1 = 65536 * 512; + Word16 SHIFT1 = 4; + IF((LT_32(L_abs(Lr), TH1)) && + (LT_32(L_abs(Li), TH1)) && + (LT_32(L_abs(Rr), TH1)) && + (LT_32(L_abs(Ri), TH1))) + { + Lr = L_shl(Lr, SHIFT1); + Li = L_shl(Li, SHIFT1); + Rr = L_shl(Rr, SHIFT1); + Ri = L_shl(Ri, SHIFT1); + } + } +#endif + specPOr[i] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); specPOi[i] = L_sub( Mpy_32_32_r( Lr, Ri ), Mpy_32_32_r( Li, Rr ) ); // 2*spec_e @@ -424,6 +453,23 @@ static void calc_poc_fx( Rr = L_add( L_sub( specRr[j], Mpy_32_32_r( specLr[j], eps_cos ) ), Mpy_32_32_r( specLi[j], eps_sin ) ); Ri = L_sub( L_sub( specRi[j], Mpy_32_32_r( specLr[j], eps_sin ) ), Mpy_32_32_r( specLi[j], eps_cos ) ); +#ifdef FIX_1511_RENORM + { + Word32 TH1 = 65536 * 512; + Word16 SHIFT1 = 4; + IF((LT_32(L_abs(Lr), TH1)) && + (LT_32(L_abs(Li), TH1)) && + (LT_32(L_abs(Rr), TH1)) && + (LT_32(L_abs(Ri), TH1))) + { + Lr = L_shl(Lr, SHIFT1); + Li = L_shl(Li, SHIFT1); + Rr = L_shl(Rr, SHIFT1); + Ri = L_shl(Ri, SHIFT1); + } + } +#endif + specPOr[j] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); specPOi[j] = L_sub( Mpy_32_32_r( Lr, Ri ), Mpy_32_32_r( Li, Rr ) ); // 2*spec_e @@ -444,6 +490,24 @@ static void calc_poc_fx( Li = L_add( L_sub( specLi[i], Mpy_32_32_r( specRr[i], eps_sin ) ), Mpy_32_32_r( specRi[i], eps_cos ) ); Rr = L_add( L_add( specRr[i], Mpy_32_32_r( specLr[i], eps_cos ) ), Mpy_32_32_r( specLi[i], eps_sin ) ); Ri = L_add( L_sub( specRi[i], Mpy_32_32_r( specLr[i], eps_sin ) ), Mpy_32_32_r( specLi[i], eps_cos ) ); + +#ifdef FIX_1511_RENORM + { + Word32 TH1 = 65536 * 512; + Word16 SHIFT1 = 4; + IF((LT_32(L_abs(Lr), TH1)) && + (LT_32(L_abs(Li), TH1)) && + (LT_32(L_abs(Rr), TH1)) && + (LT_32(L_abs(Ri), TH1))) + { + Lr = L_shl(Lr, SHIFT1); + Li = L_shl(Li, SHIFT1); + Rr = L_shl(Rr, SHIFT1); + Ri = L_shl(Ri, SHIFT1); + } + } +#endif + specPOr[i] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); specPOi[i] = L_sub( Mpy_32_32_r( Lr, Ri ), Mpy_32_32_r( Li, Rr ) ); // 2*spec_e @@ -454,6 +518,24 @@ static void calc_poc_fx( Li = L_sub( L_sub( specLi[j], Mpy_32_32_r( specRr[j], eps_sin ) ), Mpy_32_32_r( specRi[j], eps_cos ) ); Rr = L_add( L_sub( specRr[j], Mpy_32_32_r( specLr[j], eps_cos ) ), Mpy_32_32_r( specLi[j], eps_sin ) ); Ri = L_sub( L_sub( specRi[j], Mpy_32_32_r( specLr[j], eps_sin ) ), Mpy_32_32_r( specLi[j], eps_cos ) ); + +#ifdef FIX_1511_RENORM + { + Word32 TH1 = 65536 * 512; + Word16 SHIFT1 = 4; + IF((LT_32(L_abs(Lr), TH1)) && + (LT_32(L_abs(Li), TH1)) && + (LT_32(L_abs(Rr), TH1)) && + (LT_32(L_abs(Ri), TH1))) + { + Lr = L_shl(Lr, SHIFT1); + Li = L_shl(Li, SHIFT1); + Rr = L_shl(Rr, SHIFT1); + Ri = L_shl(Ri, SHIFT1); + } + } +#endif + specPOr[j] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); specPOi[j] = L_sub( Mpy_32_32_r( Lr, Ri ), Mpy_32_32_r( Li, Rr ) ); // 2*spec_e @@ -1125,6 +1207,10 @@ static void calc_poc_fx( } } +#ifdef FIX_1511_WMOPS + pop_wmops(); +#endif + return; } @@ -1144,6 +1230,11 @@ static Word32 find_poc_peak_fx( Word16 itd_cand[CPE_CHANNELS], i, n, cnt[CPE_CHANNELS], Lh, peak_range, *on, *itdLR, prev_off[CPE_CHANNELS], eps_fx; Word32 Q_fx[CPE_CHANNELS], aQ_fx[CPE_CHANNELS], cQ_fx[CPE_CHANNELS], width_fx, *peak_width_fx, *peakQ_fx, cconfidence_fx, *P_fx, tmpf_fx, eps2_fx; Word16 tmpf_e = 0, eps2_e = 0, Q_e[CPE_CHANNELS], eps_e = 15, peakQ_e[CPE_CHANNELS]; + +#ifdef FIX_1511_WMOPS + push_wmops("find_poc_peak_fx"); +#endif + move16(); move16(); move16(); @@ -1434,6 +1525,10 @@ static Word32 find_poc_peak_fx( hPOC->confidence_fx = L_add( cconfidence_var1, L_shl( cconfidence_var2, 1 ) ); // Q31 move32(); +#ifdef FIX_1511_WMOPS + pop_wmops(); +#endif + return hPOC->confidence_fx; } @@ -1459,6 +1554,10 @@ static ivas_error estimate_itd_fx( Word16 rfft_coef_step; ivas_error error; +#ifdef FIX_1511_WMOPS + push_wmops("estimate_itd_fx"); +#endif + error = IVAS_ERR_OK; move32(); @@ -1515,6 +1614,10 @@ static ivas_error estimate_itd_fx( *corr = round_fx( find_poc_peak_fx( hPOC, itd, input_frame, STEREO_DMX_EVS_POC_W_FORGETTING_FX ) ); move16(); +#ifdef FIX_1511_WMOPS + pop_wmops(); +#endif + return error; } @@ -1535,6 +1638,11 @@ static void weighted_ave_fx( { Word16 i, len; Word32 gain_tmp_fx = 0, gain_sub_fx; + +#ifdef FIX_1511_WMOPS + push_wmops("weighted_ave_fx"); +#endif + move32(); len = shr( input_frame, 4 ); gain_sub_fx = L_sub( gain_fx, old_gain_fx ); @@ -1550,6 +1658,10 @@ static void weighted_ave_fx( move32(); } +#ifdef FIX_1511_WMOPS + pop_wmops(); +#endif + return; } /*-------------------------------------------------------------------* @@ -1569,6 +1681,11 @@ static void calc_energy_fx( Word32 E_32_fx, wnd_fx, wnd_diff_fx; Word16 i, adaptlen; Word64 E_fx; + +#ifdef FIX_1511_WMOPS + push_wmops("calc_energy_fx"); +#endif + /* Initialization */ E_fx = 0; move32(); @@ -1630,6 +1747,11 @@ static void calc_energy_fx( // *energy = *energy * ratio_float + ( E / (float) input_frame ) * ( 1.0f - ratio_float ); *energy_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( *energy_fx, ratio_float_fx ), *energy_fx_e, Mpy_32_32( temp32, L_sub( MAX_32, ratio_float_fx ) ), sub( 31, q_temp32 ), energy_fx_e ); move32(); + +#ifdef FIX_1511_WMOPS + pop_wmops(); +#endif + return; } @@ -1650,6 +1772,10 @@ static void adapt_gain_fx( Word16 i, len; Word32 gain_tmp_fx, gain_sub_fx; +#ifdef FIX_1511_WMOPS + push_wmops("adapt_gain_fx"); +#endif + len = shr( input_frame, 4 ); // gain_sub = gain - old_gain; gain_sub_fx = L_sub( gain_fx, old_gain_fx ); // Q31 @@ -1668,6 +1794,10 @@ static void adapt_gain_fx( move32(); } +#ifdef FIX_1511_WMOPS + pop_wmops(); +#endif + return; } @@ -1696,6 +1826,11 @@ static void create_M_signal_fx( Word32 temp32_1, temp32_2; Word16 temp_e; Word16 temp_e_1, temp_e_2; + +#ifdef FIX_1511_WMOPS + push_wmops("create_M_signal_fx"); +#endif + /* Initialization */ eps_fx = 1024; // 1024.0f in Q0 move32(); @@ -1761,6 +1896,10 @@ static void create_M_signal_fx( w_prev_fx[2] = amp_mod_fx[1]; move32(); +#ifdef FIX_1511_WMOPS + pop_wmops(); +#endif + return; } @@ -1799,6 +1938,10 @@ void stereo_dmx_evs_enc_fx( Word64 W_tmp; Word16 W_tmp_q; +#ifdef FIX_1511_WMOPS + push_wmops("stereo_dmx_evs_enc_fx"); +#endif + if ( is_binaural ) { /* use of is_binaural flag is to be considered */ @@ -2150,6 +2293,10 @@ void stereo_dmx_evs_enc_fx( Copy_Scale_sig32_16( p_dmx_data, data, n_samples, 5 ); // Q26->Q15 +#ifdef FIX_1511_WMOPS + pop_wmops(); +#endif + return; } -- GitLab From 9aa816c470adf5b4a65d64f6c13edb2637f67f78 Mon Sep 17 00:00:00 2001 From: Arnaud Lefort Date: Mon, 12 May 2025 15:13:34 +0200 Subject: [PATCH 2/3] Fix 1511 - POC renorm cleaned and tuned. --- lib_com/options.h | 3 +- lib_enc/ivas_stereo_dmx_evs_fx.c | 189 ++++++++++--------------------- 2 files changed, 58 insertions(+), 134 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1ca29ab76..fb32b2240 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -95,8 +95,7 @@ #define FIX_1481_HARDCODE_DIV /* FhG: hardcode division results in stereo_dmx_evs_init_encoder_fx() */ #define VEC_ARITH_OPT_v1 #define FIX_1486_IND_SHB_RES /* VA: Fix for issue 1486: align the usage of IND_SHB_RES_GS indices with float code */ -#define FIX_1511_RENORM -#define FIX_1511_WMOPS +#define FIX_1511_POC_RENORM /* NTT: Fix for issue 1511: Renorm for POC. */ #define TEST_HR #define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions, ACELP low-band decoder */ diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index 21f5f48aa..36315d2ed 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -98,6 +98,11 @@ #define STEREO_DMX_EVS_TRNS_EGY_FORGETTING_Q15 24576 +#ifdef FIX_1511_POC_RENORM +#define STEREO_DMX_EVS_POC_RENORM_TH 33554432 // 65536 << 9 +#define STEREO_DMX_EVS_POC_RENORM_SHIFT 3 +#endif + const Word32 ipd_ff_Q31[STEREO_DMX_EVS_NB_SUBBAND_MAX] = { 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, @@ -223,10 +228,6 @@ void estimate_itd_wnd_fft_fx( Word16 step, bias; Word16 rshift; -#ifdef FIX_1511_WMOPS - push_wmops("estimate_itd_wnd_fft_fx"); -#endif - n0 = shr( input_frame, 1 ); IF( EQ_16( input_frame, L_FRAME16k ) ) { @@ -273,10 +274,6 @@ void estimate_itd_wnd_fft_fx( speci[n0] = 0; move32(); -#ifdef FIX_1511_WMOPS - pop_wmops(); -#endif - return; } @@ -330,10 +327,6 @@ static void calc_poc_fx( Word64 W_tmp; Word16 W_tmp_q; -#ifdef FIX_1511_WMOPS - push_wmops("calc_poc_fx"); -#endif - /* Initialization */ // iN = 1.0f / (float) input_frame; s = hPOC->sin_fx; @@ -424,22 +417,18 @@ static void calc_poc_fx( Rr = L_add( L_add( specRr[i], Mpy_32_32_r( specLr[i], eps_cos ) ), Mpy_32_32_r( specLi[i], eps_sin ) ); Ri = L_add( L_sub( specRi[i], Mpy_32_32_r( specLr[i], eps_sin ) ), Mpy_32_32_r( specLi[i], eps_cos ) ); -#ifdef FIX_1511_RENORM - { - Word32 TH1 = 65536 * 512; - Word16 SHIFT1 = 4; - IF((LT_32(L_abs(Lr), TH1)) && - (LT_32(L_abs(Li), TH1)) && - (LT_32(L_abs(Rr), TH1)) && - (LT_32(L_abs(Ri), TH1))) - { - Lr = L_shl(Lr, SHIFT1); - Li = L_shl(Li, SHIFT1); - Rr = L_shl(Rr, SHIFT1); - Ri = L_shl(Ri, SHIFT1); - } - } -#endif +#ifdef FIX_1511_POC_RENORM + IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Ri ), STEREO_DMX_EVS_POC_RENORM_TH ) ) ) + { + Lr = L_shl( Lr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Li = L_shl( Li, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + } +#endif specPOr[i] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); @@ -453,22 +442,18 @@ static void calc_poc_fx( Rr = L_add( L_sub( specRr[j], Mpy_32_32_r( specLr[j], eps_cos ) ), Mpy_32_32_r( specLi[j], eps_sin ) ); Ri = L_sub( L_sub( specRi[j], Mpy_32_32_r( specLr[j], eps_sin ) ), Mpy_32_32_r( specLi[j], eps_cos ) ); -#ifdef FIX_1511_RENORM - { - Word32 TH1 = 65536 * 512; - Word16 SHIFT1 = 4; - IF((LT_32(L_abs(Lr), TH1)) && - (LT_32(L_abs(Li), TH1)) && - (LT_32(L_abs(Rr), TH1)) && - (LT_32(L_abs(Ri), TH1))) - { - Lr = L_shl(Lr, SHIFT1); - Li = L_shl(Li, SHIFT1); - Rr = L_shl(Rr, SHIFT1); - Ri = L_shl(Ri, SHIFT1); - } - } -#endif +#ifdef FIX_1511_POC_RENORM + IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Ri ), STEREO_DMX_EVS_POC_RENORM_TH ) ) ) + { + Lr = L_shl( Lr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Li = L_shl( Li, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + } +#endif specPOr[j] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); @@ -491,22 +476,18 @@ static void calc_poc_fx( Rr = L_add( L_add( specRr[i], Mpy_32_32_r( specLr[i], eps_cos ) ), Mpy_32_32_r( specLi[i], eps_sin ) ); Ri = L_add( L_sub( specRi[i], Mpy_32_32_r( specLr[i], eps_sin ) ), Mpy_32_32_r( specLi[i], eps_cos ) ); -#ifdef FIX_1511_RENORM - { - Word32 TH1 = 65536 * 512; - Word16 SHIFT1 = 4; - IF((LT_32(L_abs(Lr), TH1)) && - (LT_32(L_abs(Li), TH1)) && - (LT_32(L_abs(Rr), TH1)) && - (LT_32(L_abs(Ri), TH1))) - { - Lr = L_shl(Lr, SHIFT1); - Li = L_shl(Li, SHIFT1); - Rr = L_shl(Rr, SHIFT1); - Ri = L_shl(Ri, SHIFT1); - } - } -#endif +#ifdef FIX_1511_POC_RENORM + IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Ri ), STEREO_DMX_EVS_POC_RENORM_TH ) ) ) + { + Lr = L_shl( Lr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Li = L_shl( Li, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + } +#endif specPOr[i] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); @@ -519,22 +500,18 @@ static void calc_poc_fx( Rr = L_add( L_sub( specRr[j], Mpy_32_32_r( specLr[j], eps_cos ) ), Mpy_32_32_r( specLi[j], eps_sin ) ); Ri = L_sub( L_sub( specRi[j], Mpy_32_32_r( specLr[j], eps_sin ) ), Mpy_32_32_r( specLi[j], eps_cos ) ); -#ifdef FIX_1511_RENORM - { - Word32 TH1 = 65536 * 512; - Word16 SHIFT1 = 4; - IF((LT_32(L_abs(Lr), TH1)) && - (LT_32(L_abs(Li), TH1)) && - (LT_32(L_abs(Rr), TH1)) && - (LT_32(L_abs(Ri), TH1))) - { - Lr = L_shl(Lr, SHIFT1); - Li = L_shl(Li, SHIFT1); - Rr = L_shl(Rr, SHIFT1); - Ri = L_shl(Ri, SHIFT1); - } - } -#endif +#ifdef FIX_1511_POC_RENORM + IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Ri ), STEREO_DMX_EVS_POC_RENORM_TH ) ) ) + { + Lr = L_shl( Lr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Li = L_shl( Li, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + } +#endif specPOr[j] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); @@ -1207,10 +1184,6 @@ static void calc_poc_fx( } } -#ifdef FIX_1511_WMOPS - pop_wmops(); -#endif - return; } @@ -1231,10 +1204,6 @@ static Word32 find_poc_peak_fx( Word32 Q_fx[CPE_CHANNELS], aQ_fx[CPE_CHANNELS], cQ_fx[CPE_CHANNELS], width_fx, *peak_width_fx, *peakQ_fx, cconfidence_fx, *P_fx, tmpf_fx, eps2_fx; Word16 tmpf_e = 0, eps2_e = 0, Q_e[CPE_CHANNELS], eps_e = 15, peakQ_e[CPE_CHANNELS]; -#ifdef FIX_1511_WMOPS - push_wmops("find_poc_peak_fx"); -#endif - move16(); move16(); move16(); @@ -1525,10 +1494,6 @@ static Word32 find_poc_peak_fx( hPOC->confidence_fx = L_add( cconfidence_var1, L_shl( cconfidence_var2, 1 ) ); // Q31 move32(); -#ifdef FIX_1511_WMOPS - pop_wmops(); -#endif - return hPOC->confidence_fx; } @@ -1554,10 +1519,6 @@ static ivas_error estimate_itd_fx( Word16 rfft_coef_step; ivas_error error; -#ifdef FIX_1511_WMOPS - push_wmops("estimate_itd_fx"); -#endif - error = IVAS_ERR_OK; move32(); @@ -1614,10 +1575,6 @@ static ivas_error estimate_itd_fx( *corr = round_fx( find_poc_peak_fx( hPOC, itd, input_frame, STEREO_DMX_EVS_POC_W_FORGETTING_FX ) ); move16(); -#ifdef FIX_1511_WMOPS - pop_wmops(); -#endif - return error; } @@ -1639,10 +1596,6 @@ static void weighted_ave_fx( Word16 i, len; Word32 gain_tmp_fx = 0, gain_sub_fx; -#ifdef FIX_1511_WMOPS - push_wmops("weighted_ave_fx"); -#endif - move32(); len = shr( input_frame, 4 ); gain_sub_fx = L_sub( gain_fx, old_gain_fx ); @@ -1658,10 +1611,6 @@ static void weighted_ave_fx( move32(); } -#ifdef FIX_1511_WMOPS - pop_wmops(); -#endif - return; } /*-------------------------------------------------------------------* @@ -1682,10 +1631,6 @@ static void calc_energy_fx( Word16 i, adaptlen; Word64 E_fx; -#ifdef FIX_1511_WMOPS - push_wmops("calc_energy_fx"); -#endif - /* Initialization */ E_fx = 0; move32(); @@ -1748,10 +1693,6 @@ static void calc_energy_fx( *energy_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( *energy_fx, ratio_float_fx ), *energy_fx_e, Mpy_32_32( temp32, L_sub( MAX_32, ratio_float_fx ) ), sub( 31, q_temp32 ), energy_fx_e ); move32(); -#ifdef FIX_1511_WMOPS - pop_wmops(); -#endif - return; } @@ -1772,10 +1713,6 @@ static void adapt_gain_fx( Word16 i, len; Word32 gain_tmp_fx, gain_sub_fx; -#ifdef FIX_1511_WMOPS - push_wmops("adapt_gain_fx"); -#endif - len = shr( input_frame, 4 ); // gain_sub = gain - old_gain; gain_sub_fx = L_sub( gain_fx, old_gain_fx ); // Q31 @@ -1794,10 +1731,6 @@ static void adapt_gain_fx( move32(); } -#ifdef FIX_1511_WMOPS - pop_wmops(); -#endif - return; } @@ -1827,10 +1760,6 @@ static void create_M_signal_fx( Word16 temp_e; Word16 temp_e_1, temp_e_2; -#ifdef FIX_1511_WMOPS - push_wmops("create_M_signal_fx"); -#endif - /* Initialization */ eps_fx = 1024; // 1024.0f in Q0 move32(); @@ -1896,10 +1825,6 @@ static void create_M_signal_fx( w_prev_fx[2] = amp_mod_fx[1]; move32(); -#ifdef FIX_1511_WMOPS - pop_wmops(); -#endif - return; } @@ -1938,8 +1863,8 @@ void stereo_dmx_evs_enc_fx( Word64 W_tmp; Word16 W_tmp_q; -#ifdef FIX_1511_WMOPS - push_wmops("stereo_dmx_evs_enc_fx"); +#ifdef FIX_1511_POC_RENORM + push_wmops( "stereo_dmx_evs_enc_fx" ); #endif if ( is_binaural ) @@ -2293,8 +2218,8 @@ void stereo_dmx_evs_enc_fx( Copy_Scale_sig32_16( p_dmx_data, data, n_samples, 5 ); // Q26->Q15 -#ifdef FIX_1511_WMOPS - pop_wmops(); +#ifdef FIX_1511_POC_RENORM + pop_wmops(); #endif return; -- GitLab From e6ee6c58dfcd22133883e20609e6e3834bcaa9bc Mon Sep 17 00:00:00 2001 From: Arnaud Lefort Date: Tue, 13 May 2025 12:17:33 +0200 Subject: [PATCH 3/3] clang formatted. --- lib_debug/debug.c | 2 +- lib_debug/wmc_auto.c | 8 ++--- lib_debug/wmc_auto.h | 52 +++++++++++++++++--------------- lib_enc/ivas_stereo_dmx_evs_fx.c | 1 + 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/lib_debug/debug.c b/lib_debug/debug.c index aafc1b663..ee6040faf 100644 --- a/lib_debug/debug.c +++ b/lib_debug/debug.c @@ -788,7 +788,7 @@ char *fname( #ifdef DEBUG_FORCE_DIR size_t len; len = strlen( tmp_fname ); - if (tmp_fname[len - 1] != '/' && tmp_fname[len - 1] != '\\' ) + if ( tmp_fname[len - 1] != '/' && tmp_fname[len - 1] != '\\' ) { /* add trailing '/' slash */ strcat( tmp_fname, "/" ); diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index d357c03dd..9a4b371fc 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -1018,7 +1018,7 @@ int push_stack( const char *filename, const char *fctname ) } /* Check, if This is the New Worst-Case RAM (stack + heap) */ - current_stack_size = ( int32_t )( ( ( ptr_base_stack - ptr_current_stack ) * sizeof( int16_t ) ) ); + current_stack_size = (int32_t) ( ( ( ptr_base_stack - ptr_current_stack ) * sizeof( int16_t ) ) ); if ( current_stack_size < 0 ) { @@ -1226,7 +1226,7 @@ void *mem_alloc( current_heap_size += ptr_record->block_size; /* Check, if this is the new Worst-Case RAM (stack + heap) */ - current_stack_size = ( int32_t )( ( ( ptr_base_stack - ptr_current_stack ) * sizeof( int16_t ) ) ); + current_stack_size = (int32_t) ( ( ( ptr_base_stack - ptr_current_stack ) * sizeof( int16_t ) ) ); if ( current_stack_size + current_heap_size > wc_ram_size ) { wc_ram_size = current_stack_size + current_heap_size; @@ -2416,7 +2416,7 @@ int EQ_64( long long int L64_var1, long long int L64_var2 ) #endif return F_ret; } -int NE_64( long long int L64_var1, long long int L64_var2 ) +int NE_64( long long int L64_var1, long long int L64_var2 ) { int F_ret = 0; @@ -2503,7 +2503,7 @@ void Reset_BASOP_WMOPS_counter( unsigned int counterId ) /* reset the current BASOP operation counter */ ptr = (unsigned int *) &multiCounter[counterId]; - for ( i = 0; i < (int) (sizeof(BASIC_OP) / sizeof(unsigned int)); i++ ) + for ( i = 0; i < (int) ( sizeof( BASIC_OP ) / sizeof( unsigned int ) ); i++ ) { *ptr++ = 0; } diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index 59bbc5bbf..8c6396313 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -34,7 +34,7 @@ #define ENH_64_BIT_OPERATOR #define ENH_U_32_BIT_OPERATOR #define COMPLEX_OPERATOR -#define CONTROL_CODE_OPS /* enable control code operators such as LT_16, GT_16, ... */ +#define CONTROL_CODE_OPS /* enable control code operators such as LT_16, GT_16, ... */ #define WMOPS_DISABLE_FCN_CALL_PENALIZATION /* do not count the complexity of function calls */ #ifdef WMOPS @@ -258,7 +258,7 @@ void update_mem( void ); { \ ops_cnt += ( 2 * _TRANS_C * ( x ) ); \ inst_cnt[_TRANS] += ( x ); \ - } + } #else @@ -335,29 +335,29 @@ extern int cntr_push_pop; #endif /* Define all Macros without '{' & '}' (None of these should be called externally!) */ -#define ABS_( x ) OP_COUNT_( _ABS, ( x ) ) -#define ADD_( x ) OP_COUNT_( _ADD, ( x ) ) -#define MULT_( x ) OP_COUNT_( _MULT, ( x ) ) -#define MAC_( x ) OP_COUNT_( _MAC, ( x ) ) -#define MOVE_( x ) OP_COUNT_( _MOVE, ( x ) ) -#define STORE_( x ) OP_COUNT_( _STORE, ( x ) ) -#define LOGIC_( x ) OP_COUNT_( _LOGIC, ( x ) ) -#define SHIFT_( x ) OP_COUNT_( _SHIFT, ( x ) ) -#define BRANCH_( x ) OP_COUNT_( _BRANCH, ( x ) ) -#define DIV_( x ) OP_COUNT_( _DIV, ( x ) ) -#define SQRT_( x ) OP_COUNT_( _SQRT, ( x ) ) -#define TRANS_( x ) OP_COUNT_( _TRANS, ( x ) ) +#define ABS_( x ) OP_COUNT_( _ABS, ( x ) ) +#define ADD_( x ) OP_COUNT_( _ADD, ( x ) ) +#define MULT_( x ) OP_COUNT_( _MULT, ( x ) ) +#define MAC_( x ) OP_COUNT_( _MAC, ( x ) ) +#define MOVE_( x ) OP_COUNT_( _MOVE, ( x ) ) +#define STORE_( x ) OP_COUNT_( _STORE, ( x ) ) +#define LOGIC_( x ) OP_COUNT_( _LOGIC, ( x ) ) +#define SHIFT_( x ) OP_COUNT_( _SHIFT, ( x ) ) +#define BRANCH_( x ) OP_COUNT_( _BRANCH, ( x ) ) +#define DIV_( x ) OP_COUNT_( _DIV, ( x ) ) +#define SQRT_( x ) OP_COUNT_( _SQRT, ( x ) ) +#define TRANS_( x ) OP_COUNT_( _TRANS, ( x ) ) #define POWER_( x ) TRANS_( x ) #define LOG_( x ) TRANS_( x ) -#define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) ) -#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) ) -#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) ) +#define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) ) +#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) ) +#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) ) #ifdef WMOPS_DISABLE_FCN_CALL_PENALIZATION -#define FUNC_( x ) ( x ) +#define FUNC_( x ) ( x ) #else -#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) ), OP_COUNT_( _FUNC, 1 ) ) +#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) ), OP_COUNT_( _FUNC, 1 ) ) #endif -#define MISC_( x ) ABS_( x ) +#define MISC_( x ) ABS_( x ) /* Math Operations */ #define abs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), abs ) @@ -401,8 +401,8 @@ extern int cntr_push_pop; #define frexp_ OP_COUNT_WRAPPER1_( MISC_( 2 ), frexp ) #define frexpf_ OP_COUNT_WRAPPER1_( MISC_( 2 ), frexpf ) -/* the macros below are instrumented versions of user-defined macros that might be used in the source code - representing some well-known and recognized mathematical operations (that are not defined in math.h) +/* the macros below are instrumented versions of user-defined macros that might be used in the source code + representing some well-known and recognized mathematical operations (that are not defined in math.h) Note: the 'wmc_flag_=wmc_flag_' is used to avoid warning: left-hand operand of comma expression has no effect with gcc */ #define min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), min( ( a ), ( b ) ) ) @@ -928,7 +928,7 @@ typedef struct unsigned int Madd_32_32_r; /* Complexity Weight of 1 */ unsigned int Msub_32_32; /* Complexity Weight of 1 */ unsigned int Msub_32_32_r; /* Complexity Weight of 1 */ -#endif /* #ifdef ENH_32_BIT_OPERATOR */ +#endif /* #ifdef ENH_32_BIT_OPERATOR */ #ifdef ENH_U_32_BIT_OPERATOR unsigned int UL_addNs; /* Complexity Weight of 1 */ @@ -938,7 +938,7 @@ typedef struct unsigned int Mpy_32_16_uu; /* Complexity Weight of 2 */ unsigned int norm_ul_float; /* Complexity Weight of 1 */ unsigned int UL_deposit_l; /* Complexity Weight of 1 */ -#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ +#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ #ifdef CONTROL_CODE_OPS unsigned int LT_16; /* Complexity Weight of 1 */ @@ -1095,7 +1095,9 @@ void incrIf( const char *func_name ); #ifndef WMOPS #define ELSE else #else /* ifndef WMOPS */ -#define ELSE else if ( incrElse( __func__ ), 0 ); else +#define ELSE \ + else if ( incrElse( __func__ ), 0 ); \ + else void incrElse( const char *func_name ); #endif /* ifndef WMOPS */ diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index 793f204d8..f84f90e46 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -2214,6 +2214,7 @@ void stereo_dmx_evs_enc_fx( } Copy_Scale_sig32_16( p_dmx_data, data, n_samples, 5 ); // Q26->Q15 + pop_wmops(); return; -- GitLab