From d5ae7514ef6128e7da5ff89d80a5a9cf260c3101 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 21 Nov 2024 10:32:46 +0100 Subject: [PATCH 01/21] removal of control.] --- lib_com/basop32.c | 284 +------- lib_com/basop32.h | 80 --- lib_com/basop_util.c | 1 - lib_com/cnst.h | 8 +- lib_com/complex_basop.c | 10 - lib_com/complex_basop.h | 2 - lib_com/control.c | 284 -------- lib_com/control.h | 367 ----------- lib_com/count.c | 270 ++------ lib_com/count.h | 370 +---------- lib_com/enh1632.c | 16 +- lib_com/enh1632.h | 9 - lib_com/enh32.c | 19 +- lib_com/enh40.c | 91 +-- lib_com/enh40.h | 4 - lib_com/enh64.c | 92 +-- lib_com/enh64.h | 2 - lib_com/enhUL32.c | 60 +- lib_com/enhUL32.h | 5 - lib_com/ivas_cnst.h | 1 + lib_com/ivas_fb_mixer.c | 5 +- lib_com/move.h | 7 - lib_com/options.h | 11 +- lib_com/rom_com.h | 1 + lib_com/rom_com_fx.h | 3 + lib_com/stl.h | 12 - lib_com/vlpc_2st_com_fx.c | 1 - lib_debug/wmc_auto.c | 407 +++++++++++- lib_debug/wmc_auto.h | 643 ++++++++++++++++++- lib_dec/dec_tcx_fx.c | 1 + lib_dec/ivas_agc_dec_fx.c | 6 +- lib_dec/ivas_init_dec.c | 7 +- lib_dec/ivas_ism_param_dec.c | 1 + lib_dec/ivas_masa_dec.c | 5 +- lib_dec/ivas_mc_paramupmix_dec.c | 3 +- lib_dec/ivas_sba_dec.c | 1 + lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 1 + lib_dec/ivas_spar_decoder.c | 1 + lib_dec/ivas_stereo_mdct_stereo_dec.c | 3 +- lib_dec/jbm_pcmdsp_similarityestimation.c | 1 + lib_dec/jbm_pcmdsp_window.c | 2 + lib_dec/lib_dec_fx.c | 9 +- lib_dec/rom_dec.h | 1 + lib_enc/ivas_agc_enc.c | 5 +- lib_enc/ivas_core_pre_proc_front.c | 1 - lib_enc/ivas_cpe_enc.c | 1 - lib_enc/lib_enc.c | 2 - lib_enc/nelp_enc_fx.c | 1 - lib_enc/vlpc_1st_cod_fx.c | 1 - lib_enc/vlpc_2st_cod_fx.c | 1 - lib_rend/ivas_crend.c | 1 - lib_rend/ivas_dirac_dec_binaural_functions.c | 4 +- lib_rend/ivas_reverb_filter_design.c | 1 - 53 files changed, 1132 insertions(+), 1993 deletions(-) delete mode 100644 lib_com/control.c delete mode 100644 lib_com/control.h diff --git a/lib_com/basop32.c b/lib_com/basop32.c index 2a813e15c..c4822bfbe 100644 --- a/lib_com/basop32.c +++ b/lib_com/basop32.c @@ -159,10 +159,8 @@ HISTORY: #include #include -#include "stl.h" -#ifdef BASOP_NOGLOB #include -#endif /* BASOP_NOGLOB */ +#include "stl.h" #define WMC_TOOL_SKIP @@ -170,19 +168,12 @@ HISTORY: #pragma warning( disable : 4310 ) #endif -#ifdef WMOPS -extern BASIC_OP multiCounter[MAXCOUNTERS]; -extern int currCounter; -#endif - /*___________________________________________________________________________ | | | Local Functions | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB static Word16 saturate_o( Word32 L_var1, Flag *Overflow ); -#endif /* BASOP_NOGLOB */ static Word16 saturate( Word32 L_var1 ); @@ -191,7 +182,6 @@ static Word16 saturate( Word32 L_var1 ); | Constants and Globals | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB #ifdef BASOP_PRINT_ON_WARNING #include @@ -418,10 +408,6 @@ Flag get_carry( const Flag *carry ) #undef B_HELPER_SET_GLOBAL #undef B_HELPER_GET_GLOBAL -#else /* BASOP_NOGLOB */ -Flag Overflow = 0; -Flag Carry = 0; -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -458,30 +444,18 @@ Flag Carry = 0; | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -static Word16 saturate( Word32 L_var1 ) -#else /* BASOP_NOGLOB */ static Word16 saturate_o( Word32 L_var1, Flag *Overflow ) -#endif /* BASOP_NOGLOB */ { Word16 var_out; if ( L_var1 > 0X00007fffL ) { -#ifndef BASOP_NOGLOB - Overflow = 1; -#else /* BASOP_NOGLOB */ *Overflow = 1; -#endif /* BASOP_NOGLOB */ var_out = MAX_16; } else if ( L_var1 < (Word32) 0xffff8000L ) { -#ifndef BASOP_NOGLOB - Overflow = 1; -#else /* BASOP_NOGLOB */ *Overflow = 1; -#endif /* BASOP_NOGLOB */ var_out = MIN_16; } else @@ -497,7 +471,6 @@ static Word16 saturate_o( Word32 L_var1, Flag *Overflow ) return ( var_out ); } -#ifdef BASOP_NOGLOB static Word16 saturate( Word32 L_var1 ) { Word16 var_out; @@ -524,7 +497,6 @@ static Word16 saturate( Word32 L_var1 ) return ( var_out ); } -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -559,7 +531,6 @@ static Word16 saturate( Word32 L_var1 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word16 add_o( Word16 var1, Word16 var2, Flag *Overflow ) { Word16 var_out; @@ -574,7 +545,6 @@ Word16 add_o( Word16 var1, Word16 var2, Flag *Overflow ) return ( var_out ); } -#endif /* BASOP_NOGLOB */ Word16 add( Word16 var1, Word16 var2 ) { Word16 var_out; @@ -588,13 +558,11 @@ Word16 add( Word16 var1, Word16 var2 ) #endif return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 add_sat( Word16 var1, Word16 var2 ) { Flag Overflow; return add_o( var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : sub | @@ -628,7 +596,6 @@ Word16 add_sat( Word16 var1, Word16 var2 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word16 sub_o( Word16 var1, Word16 var2, Flag *Overflow ) { Word16 var_out; @@ -643,7 +610,6 @@ Word16 sub_o( Word16 var1, Word16 var2, Flag *Overflow ) return ( var_out ); } -#endif /* BASOP_NOGLOB */ Word16 sub( Word16 var1, Word16 var2 ) { Word16 var_out; @@ -657,13 +623,11 @@ Word16 sub( Word16 var1, Word16 var2 ) #endif return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 sub_sat( Word16 var1, Word16 var2 ) { Flag Overflow; return sub_o( var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : abs_s | @@ -755,11 +719,7 @@ Word16 abs_s( Word16 var1 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word16 shl( Word16 var1, Word16 var2 ) -#else /* BASOP_NOGLOB */ Word16 shl_o( Word16 var1, Word16 var2, Flag *Overflow ) -#endif /* BASOP_NOGLOB */ { Word16 var_out; Word32 result; @@ -781,11 +741,7 @@ Word16 shl_o( Word16 var1, Word16 var2, Flag *Overflow ) if ( ( var2 > 15 && var1 != 0 ) || ( result != (Word32) ( (Word16) result ) ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; -#else /* BASOP_NOGLOB */ *Overflow = 1; -#endif /* BASOP_NOGLOB */ var_out = ( var1 > 0 ) ? MAX_16 : MIN_16; } else @@ -808,7 +764,6 @@ Word16 shl_o( Word16 var1, Word16 var2, Flag *Overflow ) return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 shl( Word16 var1, Word16 var2 ) { Word16 var_out; @@ -858,7 +813,6 @@ Word16 shl_sat( Word16 var1, Word16 var2 ) Flag Overflow; return shl_o( var1, var2, &Overflow ); } -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -894,11 +848,7 @@ Word16 shl_sat( Word16 var1, Word16 var2 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word16 shr_o( Word16 var1, Word16 var2, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word16 shr( Word16 var1, Word16 var2 ) -#endif /* BASOP_NOGLOB */ { Word16 var_out; @@ -907,11 +857,7 @@ Word16 shr( Word16 var1, Word16 var2 ) if ( var2 < -16 ) var2 = -16; var2 = -var2; -#ifdef BASOP_NOGLOB var_out = shl_o( var1, var2, Overflow ); -#else /* BASOP_NOGLOB */ - var_out = shl( var1, var2 ); -#endif /* BASOP_NOGLOB */ #ifdef WMOPS multiCounter[currCounter].shl--; @@ -945,7 +891,6 @@ Word16 shr( Word16 var1, Word16 var2 ) return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 shr( Word16 var1, Word16 var2 ) { return shr_o( var1, var2, NULL ); @@ -955,7 +900,6 @@ Word16 shr_sat( Word16 var1, Word16 var2 ) Flag Overflow; return shr_o( var1, var2, &Overflow ); } -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ @@ -992,11 +936,7 @@ Word16 shr_sat( Word16 var1, Word16 var2 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word16 mult_o( Word16 var1, Word16 var2, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word16 mult( Word16 var1, Word16 var2 ) -#endif /* BASOP_NOGLOB */ { Word16 var_out; Word32 L_product; @@ -1008,11 +948,7 @@ Word16 mult( Word16 var1, Word16 var2 ) if ( L_product & (Word32) 0x00010000L ) L_product = L_product | (Word32) 0xffff0000L; -#ifdef BASOP_NOGLOB var_out = saturate_o( L_product, Overflow ); -#else /* BASOP_NOGLOB */ - var_out = saturate( L_product ); -#endif /* BASOP_NOGLOB */ #ifdef WMOPS multiCounter[currCounter].mult++; @@ -1021,7 +957,6 @@ Word16 mult( Word16 var1, Word16 var2 ) BASOP_CHECK(); return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 mult( Word16 var1, Word16 var2 ) { Word16 var_out; @@ -1048,7 +983,6 @@ Word16 mult_sat( Word16 var1, Word16 var2 ) return mult_o( var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | @@ -1084,11 +1018,7 @@ Word16 mult_sat( Word16 var1, Word16 var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word32 L_mult( Word16 var1, Word16 var2 ) -#else /* BASOP_NOGLOB */ Word32 L_mult_o( Word16 var1, Word16 var2, Flag *Overflow ) -#endif /* BASOP_NOGLOB */ { Word32 L_var_out; @@ -1100,11 +1030,7 @@ Word32 L_mult_o( Word16 var1, Word16 var2, Flag *Overflow ) } else { -#ifndef BASOP_NOGLOB - Overflow = 1; -#else /* BASOP_NOGLOB */ *Overflow = 1; -#endif /* BASOP_NOGLOB */ L_var_out = MAX_32; } @@ -1117,7 +1043,6 @@ Word32 L_mult_o( Word16 var1, Word16 var2, Flag *Overflow ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_mult( Word16 var1, Word16 var2 ) { Word32 L_var_out; @@ -1148,7 +1073,6 @@ Word32 L_mult_sat( Word16 var1, Word16 var2 ) Flag Overflow; return L_mult_o( var1, var2, &Overflow ); } -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -1314,7 +1238,6 @@ Word16 extract_l( Word32 L_var1 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word16 round_fx_o( Word32 L_var1, Flag *Overflow ) { Word16 var_out; @@ -1336,7 +1259,6 @@ Word16 round_fx_o( Word32 L_var1, Flag *Overflow ) return ( var_out ); } -#endif /* BASOP_NOGLOB */ Word16 round_fx( Word32 L_var1 ) { Word16 var_out; @@ -1356,13 +1278,11 @@ Word16 round_fx( Word32 L_var1 ) return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 round_fx_sat( Word32 L_var1 ) { Flag Overflow; return round_fx_o( L_var1, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : L_mac | @@ -1399,7 +1319,6 @@ Word16 round_fx_sat( Word32 L_var1 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word32 L_mac_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) { Word32 L_var_out; @@ -1417,7 +1336,6 @@ Word32 L_mac_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) return ( L_var_out ); } -#endif /* BASOP_NOGLOB */ Word32 L_mac( Word32 L_var3, Word16 var1, Word16 var2 ) { Word32 L_var_out; @@ -1435,13 +1353,11 @@ Word32 L_mac( Word32 L_var3, Word16 var1, Word16 var2 ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_mac_sat( Word32 L_var3, Word16 var1, Word16 var2 ) { Flag Overflow; return L_mac_o( L_var3, var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : L_msu | @@ -1478,7 +1394,6 @@ Word32 L_mac_sat( Word32 L_var3, Word16 var1, Word16 var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word32 L_msu_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) { Word32 L_var_out; @@ -1496,7 +1411,6 @@ Word32 L_msu_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) return ( L_var_out ); } -#endif /* BASOP_NOGLOB */ Word32 L_msu( Word32 L_var3, Word16 var1, Word16 var2 ) { Word32 L_var_out; @@ -1514,13 +1428,11 @@ Word32 L_msu( Word32 L_var3, Word16 var1, Word16 var2 ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_msu_sat( Word32 L_var3, Word16 var1, Word16 var2 ) { Flag Overflow; return L_msu_o( L_var3, var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : L_macNs | @@ -1567,7 +1479,6 @@ Word32 L_msu_sat( Word32 L_var3, Word16 var1, Word16 var2 ) | operators which take into account its value. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word32 DEPR_L_macNs( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry ) { Word32 L_var_out; @@ -1584,25 +1495,14 @@ Word32 DEPR_L_macNs( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry ) /* BASOP_CHECK(); Do not check for overflow here, function produces the carry bit instead */ return ( L_var_out ); } -#endif -#ifdef BASOP_NOGLOB Word32 L_macNs_co( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word32 L_macNs( Word32 L_var3, Word16 var1, Word16 var2 ) -#endif /* BASOP_NOGLOB */ { Word32 L_var_out; -#ifdef BASOP_NOGLOB L_var_out = L_mult_o( var1, var2, Overflow ); L_var_out = L_add_co( L_var3, L_var_out, Carry, Overflow ); -#else /* BASOP_NOGLOB */ - L_var_out = L_mult( var1, var2 ); - L_var_out = L_add_c( L_var3, L_var_out ); -#endif /* BASOP_NOGLOB */ return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_macNs( Word32 L_var3, Word16 var1, Word16 var2 ) { return L_macNs_co( L_var3, var1, var2, NULL, NULL ); @@ -1612,7 +1512,6 @@ Word32 L_macNs_sat( Word32 L_var3, Word16 var1, Word16 var2 ) Flag Carry, Overflow; return L_macNs_co( L_var3, var1, var2, &Carry, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : L_msuNs | @@ -1659,20 +1558,12 @@ Word32 L_macNs_sat( Word32 L_var3, Word16 var1, Word16 var2 ) | operators which take into account its value. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word32 L_msuNs( Word32 L_var3, Word16 var1, Word16 var2 ) -#else /* BASOP_NOGLOB */ Word32 DEPR_L_msuNs( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry ) -#endif /* BASOP_NOGLOB */ { Word32 L_var_out; L_var_out = L_mult( var1, var2 ); -#ifndef BASOP_NOGLOB - L_var_out = L_sub_c( L_var3, L_var_out ); -#else /* BASOP_NOGLOB */ L_var_out = DEPR_L_sub_c( L_var3, L_var_out, Carry ); -#endif /* BASOP_NOGLOB */ #ifdef WMOPS multiCounter[currCounter].L_mult--; @@ -1685,7 +1576,6 @@ Word32 DEPR_L_msuNs( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_msuNs_co( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry, Flag *Overflow ) { Word32 L_var_out; @@ -1706,7 +1596,6 @@ Word32 L_msuNs_sat( Word32 L_var3, Word16 var1, Word16 var2 ) Flag Carry, Overflow; return L_msuNs_co( L_var3, var1, var2, &Carry, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : L_add | @@ -1738,11 +1627,7 @@ Word32 L_msuNs_sat( Word32 L_var3, Word16 var1, Word16 var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word32 L_add( Word32 L_var1, Word32 L_var2 ) -#else /* BASOP_NOGLOB */ Word32 L_add_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) -#endif /* BASOP_NOGLOB */ { Word32 L_var_out; @@ -1753,11 +1638,7 @@ Word32 L_add_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) if ( ( L_var_out ^ L_var1 ) & MIN_32 ) { L_var_out = ( L_var1 < 0 ) ? MIN_32 : MAX_32; -#ifndef BASOP_NOGLOB - Overflow = 1; -#else /* BASOP_NOGLOB */ *Overflow = 1; -#endif /* BASOP_NOGLOB */ } } @@ -1771,7 +1652,6 @@ Word32 L_add_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_add( Word32 L_var1, Word32 L_var2 ) { Word32 L_var_out; @@ -1797,7 +1677,6 @@ Word32 L_add_sat( Word32 L_var1, Word32 L_var2 ) Flag Overflow; return L_add_o( L_var1, L_var2, &Overflow ); } -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -1830,11 +1709,7 @@ Word32 L_add_sat( Word32 L_var1, Word32 L_var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word32 L_sub( Word32 L_var1, Word32 L_var2 ) -#else /* BASOP_NOGLOB */ Word32 L_sub_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) -#endif /* BASOP_NOGLOB */ { Word32 L_var_out; @@ -1845,11 +1720,7 @@ Word32 L_sub_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) if ( ( L_var_out ^ L_var1 ) & MIN_32 ) { L_var_out = ( L_var1 < 0L ) ? MIN_32 : MAX_32; -#ifndef BASOP_NOGLOB - Overflow = 1; -#else /* BASOP_NOGLOB */ *Overflow = 1; -#endif /* BASOP_NOGLOB */ } } @@ -1862,7 +1733,6 @@ Word32 L_sub_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_sub( Word32 L_var1, Word32 L_var2 ) { Word32 L_var_out; @@ -1890,7 +1760,6 @@ Word32 L_sub_sat( Word32 L_var1, Word32 L_var2 ) Flag Overflow; return L_sub_o( L_var1, L_var2, &Overflow ); } -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -1937,29 +1806,18 @@ Word32 L_sub_sat( Word32 L_var1, Word32 L_var2 ) | operators which take into account its value. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word32 L_add_c( Word32 L_var1, Word32 L_var2 ) -#else /* BASOP_NOGLOB */ Word32 DEPR_L_add_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) -#endif /* BASOP_NOGLOB */ { Word32 L_var_out; Word32 L_test; Flag carry_int = 0; -#ifndef BASOP_NOGLOB - L_var_out = L_var1 + L_var2 + Carry; -#else /* BASOP_NOGLOB */ L_var_out = L_var1 + L_var2 + *Carry; -#endif /* BASOP_NOGLOB */ L_test = L_var1 + L_var2; if ( ( L_var1 > 0 ) && ( L_var2 > 0 ) && ( L_test < 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; -#endif /* ! BASOP_NOGLOB */ carry_int = 0; } else @@ -1968,16 +1826,10 @@ Word32 DEPR_L_add_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) { if ( L_test >= 0 ) { -#ifndef BASOP_NOGLOB - Overflow = 1; -#endif /* ! BASOP_NOGLOB */ carry_int = 1; } else { -#ifndef BASOP_NOGLOB - Overflow = 0; -#endif /* ! BASOP_NOGLOB */ carry_int = 1; } } @@ -1985,63 +1837,36 @@ Word32 DEPR_L_add_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) { if ( ( ( L_var1 ^ L_var2 ) < 0 ) && ( L_test >= 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 0; -#endif /* ! BASOP_NOGLOB */ carry_int = 1; } else { -#ifndef BASOP_NOGLOB - Overflow = 0; -#endif /* ! BASOP_NOGLOB */ carry_int = 0; } } } -#ifndef BASOP_NOGLOB - if ( Carry ) -#else /* BASOP_NOGLOB */ if ( *Carry ) -#endif /* BASOP_NOGLOB */ { if ( L_test == MAX_32 ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - Carry = carry_int; -#else /* BASOP_NOGLOB */ *Carry = carry_int; -#endif /* BASOP_NOGLOB */ } else { if ( L_test == (Word32) 0xFFFFFFFFL ) { -#ifndef BASOP_NOGLOB - Carry = 1; -#else /* BASOP_NOGLOB */ *Carry = 1; -#endif /* BASOP_NOGLOB */ } else { -#ifndef BASOP_NOGLOB - Carry = carry_int; -#else /* BASOP_NOGLOB */ *Carry = carry_int; -#endif /* BASOP_NOGLOB */ } } } else { -#ifndef BASOP_NOGLOB - Carry = carry_int; -#else /* BASOP_NOGLOB */ *Carry = carry_int; -#endif /* BASOP_NOGLOB */ } #ifdef WMOPS @@ -2053,7 +1878,6 @@ Word32 DEPR_L_add_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_add_co( Word32 L_var1, Word32 L_var2, Flag *Carry, Flag *Overflow ) { Word32 L_var_out; @@ -2129,7 +1953,6 @@ Word32 L_add_c( Word32 L_var1, Word32 L_var2 ) { return L_add_co( L_var1, L_var2, NULL, NULL ); } -#endif /*___________________________________________________________________________ | | | Function Name : L_sub_c | @@ -2175,34 +1998,18 @@ Word32 L_add_c( Word32 L_var1, Word32 L_var2 ) | operators which take into account its value. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word32 L_sub_c( Word32 L_var1, Word32 L_var2 ) -#else /* BASOP_NOGLOB */ Word32 DEPR_L_sub_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) -#endif /* BASOP_NOGLOB */ { Word32 L_var_out; Word32 L_test; Flag carry_int = 0; -#ifndef BASOP_NOGLOB - if ( Carry ) -#else /* BASOP_NOGLOB */ if ( *Carry ) -#endif /* BASOP_NOGLOB */ { -#ifndef BASOP_NOGLOB - Carry = 0; -#else /* BASOP_NOGLOB */ *Carry = 0; -#endif /* BASOP_NOGLOB */ if ( L_var2 != MIN_32 ) { -#ifndef BASOP_NOGLOB - L_var_out = L_add_c( L_var1, -L_var2 ); -#else /* BASOP_NOGLOB */ L_var_out = DEPR_L_add_c( L_var1, -L_var2, Carry ); -#endif /* BASOP_NOGLOB */ #ifdef WMOPS multiCounter[currCounter].L_add_c--; #endif @@ -2212,12 +2019,7 @@ Word32 DEPR_L_sub_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) L_var_out = L_var1 - L_var2; if ( L_var1 > 0L ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - Carry = 0; -#else /* BASOP_NOGLOB */ *Carry = 0; -#endif /* BASOP_NOGLOB */ } } } @@ -2228,41 +2030,23 @@ Word32 DEPR_L_sub_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) if ( ( L_test < 0 ) && ( L_var1 > 0 ) && ( L_var2 < 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; -#endif /* ! BASOP_NOGLOB */ carry_int = 0; } else if ( ( L_test > 0 ) && ( L_var1 < 0 ) && ( L_var2 > 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; -#endif /* ! BASOP_NOGLOB */ carry_int = 1; } else if ( ( L_test > 0 ) && ( ( L_var1 ^ L_var2 ) > 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 0; -#endif /* ! BASOP_NOGLOB */ carry_int = 1; } if ( L_test == MIN_32 ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - Carry = carry_int; -#else /* BASOP_NOGLOB */ *Carry = carry_int; -#endif /* BASOP_NOGLOB */ } else { -#ifndef BASOP_NOGLOB - Carry = carry_int; -#else /* BASOP_NOGLOB */ *Carry = carry_int; -#endif /* BASOP_NOGLOB */ } } @@ -2275,7 +2059,6 @@ Word32 DEPR_L_sub_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_sub_co( Word32 L_var1, Word32 L_var2, Flag *Carry, Flag *Overflow ) { Word32 L_var_out; @@ -2331,7 +2114,6 @@ Word32 L_sub_c( Word32 L_var1, Word32 L_var2 ) { return L_sub_co( L_var1, L_var2, NULL, NULL ); } -#endif /*___________________________________________________________________________ | | | Function Name : L_negate | @@ -2409,7 +2191,6 @@ Word32 L_negate( Word32 L_var1 ) | range : 0x8000 <= var_out <= 0x7fff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word16 mult_ro( Word16 var1, Word16 var2, Flag *Overflow ) { Word16 var_out; @@ -2433,7 +2214,6 @@ Word16 mult_ro( Word16 var1, Word16 var2, Flag *Overflow ) return ( var_out ); } -#endif /* BASOP_NOGLOB */ Word16 mult_r( Word16 var1, Word16 var2 ) { Word16 var_out; @@ -2456,13 +2236,11 @@ Word16 mult_r( Word16 var1, Word16 var2 ) return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 mult_r_sat( Word16 var1, Word16 var2 ) { Flag Overflow; return mult_ro( var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : L_shl | @@ -2496,11 +2274,7 @@ Word16 mult_r_sat( Word16 var1, Word16 var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word32 L_shl( Word32 L_var1, Word16 var2 ) -#else /* BASOP_NOGLOB */ Word32 L_shl_o( Word32 L_var1, Word16 var2, Flag *Overflow ) -#endif /* BASOP_NOGLOB */ { Word32 L_var_out = 0L; @@ -2521,11 +2295,7 @@ Word32 L_shl_o( Word32 L_var1, Word16 var2, Flag *Overflow ) { if ( L_var1 > (Word32) 0X3fffffffL ) { -#ifndef BASOP_NOGLOB - Overflow = 1; -#else /* BASOP_NOGLOB */ *Overflow = 1; -#endif /* BASOP_NOGLOB */ L_var_out = MAX_32; break; } @@ -2533,11 +2303,7 @@ Word32 L_shl_o( Word32 L_var1, Word16 var2, Flag *Overflow ) { if ( L_var1 < (Word32) 0xc0000000L ) { -#ifndef BASOP_NOGLOB - Overflow = 1; -#else /* BASOP_NOGLOB */ *Overflow = 1; -#endif /* BASOP_NOGLOB */ L_var_out = MIN_32; break; } @@ -2557,7 +2323,6 @@ Word32 L_shl_o( Word32 L_var1, Word16 var2, Flag *Overflow ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_shl( Word32 L_var1, Word16 var2 ) { @@ -2612,7 +2377,6 @@ Word32 L_shl_sat( Word32 L_var1, Word16 var2 ) return L_shl_o( L_var1, var2, &Overflow ); } -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | | Function Name : L_shr | @@ -2646,7 +2410,6 @@ Word32 L_shl_sat( Word32 L_var1, Word16 var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word32 L_shr_o( Word32 L_var1, Word16 var2, Flag *Overflow ) { Word32 L_var_out; @@ -2690,7 +2453,6 @@ Word32 L_shr_o( Word32 L_var1, Word16 var2, Flag *Overflow ) return ( L_var_out ); } -#endif /* BASOP_NOGLOB */ Word32 L_shr( Word32 L_var1, Word16 var2 ) { Word32 L_var_out; @@ -2732,13 +2494,11 @@ Word32 L_shr( Word32 L_var1, Word16 var2 ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_shr_sat( Word32 L_var1, Word16 var2 ) { Flag Overflow; return L_shr_o( L_var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : shr_r | @@ -2812,7 +2572,6 @@ Word16 shr_r( Word16 var1, Word16 var2 ) return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 shr_ro( Word16 var1, Word16 var2, Flag *Overflow ) { Word16 var_out; @@ -2840,7 +2599,6 @@ Word16 shr_r_sat( Word16 var1, Word16 var2 ) Flag Overflow; return shr_ro( var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : mac_r | @@ -2879,7 +2637,6 @@ Word16 shr_r_sat( Word16 var1, Word16 var2 ) | range : 0x0000 8000 <= L_var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word16 mac_ro( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) { Word16 var_out; @@ -2901,7 +2658,6 @@ Word16 mac_ro( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) return ( var_out ); } -#endif /* BASOP_NOGLOB */ Word16 mac_r( Word32 L_var3, Word16 var1, Word16 var2 ) { Word16 var_out; @@ -2922,13 +2678,11 @@ Word16 mac_r( Word32 L_var3, Word16 var1, Word16 var2 ) return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 mac_r_sat( Word32 L_var3, Word16 var1, Word16 var2 ) { Flag Overflow; return mac_ro( L_var3, var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : msu_r | @@ -2967,7 +2721,6 @@ Word16 mac_r_sat( Word32 L_var3, Word16 var1, Word16 var2 ) | range : 0x0000 8000 <= L_var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word16 msu_ro( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) { Word16 var_out; @@ -2987,7 +2740,6 @@ Word16 msu_ro( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) return ( var_out ); } -#endif /* BASOP_NOGLOB */ Word16 msu_r( Word32 L_var3, Word16 var1, Word16 var2 ) { Word16 var_out; @@ -3006,13 +2758,11 @@ Word16 msu_r( Word32 L_var3, Word16 var1, Word16 var2 ) return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 msu_r_sat( Word32 L_var3, Word16 var1, Word16 var2 ) { Flag Overflow; return msu_ro( L_var3, var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : L_deposit_h | @@ -3177,7 +2927,6 @@ Word32 L_shr_r( Word32 L_var1, Word16 var2 ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_shr_ro( Word32 L_var1, Word16 var2, Flag *Overflow ) { Word32 L_var_out; @@ -3205,7 +2954,6 @@ Word32 L_shr_r_sat( Word32 L_var1, Word16 var2 ) Flag Overflow = 0; return L_shr_ro( L_var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | | Function Name : L_abs | @@ -3295,11 +3043,7 @@ Word32 L_abs( Word32 L_var1 ) | range : 0x8000 0000 <= var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word32 L_sat( Word32 L_var1 ) -#else /* BASOP_NOGLOB */ Word32 DEPR_L_sat_co( Word32 L_var1, Flag Overflow, Flag Carry ) -#endif /* BASOP_NOGLOB */ { Word32 L_var_out; @@ -3316,11 +3060,6 @@ Word32 DEPR_L_sat_co( Word32 L_var1, Flag Overflow, Flag Carry ) { L_var_out = MAX_32; } -#ifndef BASOP_NOGLOB - - Carry = 0; - Overflow = 0; -#endif /* ! BASOP_NOGLOB */ } #ifdef WMOPS @@ -3332,7 +3071,6 @@ Word32 DEPR_L_sat_co( Word32 L_var1, Flag Overflow, Flag Carry ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_sat_co( Word32 L_var1, Flag Carry, Flag Overflow ) { Word32 L_var_out; @@ -3359,7 +3097,6 @@ Word32 L_sat( Word32 L_var1 ) assert( 0 ); /* Overflow and Carry are no longer global, must be passed as parameters */ return L_sat_co( L_var1, 0, 0 ); } -#endif /*___________________________________________________________________________ | | | Function Name : norm_s | @@ -3649,7 +3386,6 @@ Word16 norm_l( Word32 L_var1 ) | | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word32 L_mls_o( Word32 Lv, Word16 v, Flag *Overflow ) { Word32 Temp; @@ -3671,7 +3407,6 @@ Word32 L_mls_o( Word32 Lv, Word16 v, Flag *Overflow ) return Temp; } -#endif /* BASOP_NOGLOB */ Word32 L_mls( Word32 Lv, Word16 v ) { Word32 Temp; @@ -3692,13 +3427,11 @@ Word32 L_mls( Word32 Lv, Word16 v ) return Temp; } -#ifdef BASOP_NOGLOB Word32 L_mls_sat( Word32 Lv, Word16 v ) { Flag Overflow; return L_mls_o( Lv, v, &Overflow ); } -#endif /*__________________________________________________________________________ | | @@ -3836,11 +3569,7 @@ Word16 div_l( Word32 L_num, Word16 den ) | are performed if ORIGINAL_G7231 is defined. | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word16 i_mult( Word16 a, Word16 b ) -#else /* BASOP_NOGLOB */ Word16 DEPR_i_mult( Word16 a, Word16 b ) -#endif /* BASOP_NOGLOB */ { #ifdef ORIGINAL_G7231 return a * b; @@ -3853,7 +3582,6 @@ Word16 DEPR_i_mult( Word16 a, Word16 b ) #endif } -#ifdef BASOP_NOGLOB Word16 i_mult_o( Word16 a, Word16 b, Flag *Overflow ) { #ifdef ORIGINAL_G7231 @@ -3872,7 +3600,6 @@ Word16 i_mult_sat( Word16 a, Word16 b ) Flag Overflow; return i_mult_o( a, b, &Overflow ); } -#endif /* ****************************************************************************** * The following three operators are not part of the original @@ -3952,7 +3679,6 @@ Word32 L_mult0( Word16 var1, Word16 var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |___________________________________________________________________________ */ -#ifdef BASOP_NOGLOB Word32 L_mac0_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) { Word32 L_var_out; @@ -3972,7 +3698,6 @@ Word32 L_mac0_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) return ( L_var_out ); } -#endif /* BASOP_NOGLOB */ Word32 L_mac0( Word32 L_var3, Word16 var1, Word16 var2 ) { Word32 L_var_out; @@ -3992,13 +3717,11 @@ Word32 L_mac0( Word32 L_var3, Word16 var1, Word16 var2 ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_mac0_sat( Word32 L_var3, Word16 var1, Word16 var2 ) { Flag Overflow; return L_mac0_o( L_var3, var1, var2, &Overflow ); } -#endif /*___________________________________________________________________________ | | Function Name : L_msu0 @@ -4029,7 +3752,6 @@ Word32 L_mac0_sat( Word32 L_var3, Word16 var1, Word16 var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |___________________________________________________________________________ */ -#ifdef BASOP_NOGLOB Word32 L_msu0_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) { Word32 L_var_out; @@ -4049,7 +3771,6 @@ Word32 L_msu0_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) return ( L_var_out ); } -#endif /* BASOP_NOGLOB */ Word32 L_msu0( Word32 L_var3, Word16 var1, Word16 var2 ) { Word32 L_var_out; @@ -4069,12 +3790,11 @@ Word32 L_msu0( Word32 L_var3, Word16 var1, Word16 var2 ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_msu0_sat( Word32 L_var3, Word16 var1, Word16 var2 ) { Flag Overflow; return L_msu0_o( L_var3, var1, var2, &Overflow ); } -#endif #undef WMC_TOOL_SKIP +/*AddedByWMC_Tool*/ int PROM_Size_Func( basop32 ) { return 273; } diff --git a/lib_com/basop32.h b/lib_com/basop32.h index 785a4bf56..32c108d9e 100644 --- a/lib_com/basop32.h +++ b/lib_com/basop32.h @@ -86,17 +86,11 @@ | Constants and Globals | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -extern Flag Overflow, Overflow2; -extern Flag Carry; - -#else /* BASOP_NOGLOB */ /* DISABLED TO AVOID GLOBAL VARIABLES */ /* extern Flag BASOP_Overflow, BASOP_Overflow2; extern Flag BASOP_Carry; */ -#endif /* BASOP_NOGLOB */ #define BASOP_SATURATE_WARNING_ON_EVS #define BASOP_SATURATE_WARNING_OFF_EVS #define BASOP_SATURATE_ERROR_ON_EVS @@ -114,36 +108,17 @@ extern Flag BASOP_Carry; #define MAX_16 (Word16) 0x7fff #define MIN_16 (Word16) 0x8000 -#ifdef BASOP_NOGLOB void set_overflow( Flag *overflow ); void unset_overflow( Flag *overflow ); void set_carry( Flag *carry ); void unset_carry( Flag *carry ); Flag get_carry( const Flag *carry ); -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | | Prototypes for basic arithmetic operators | |___________________________________________________________________________| */ -#ifndef BASOP_NOGLOB -Word16 add( Word16 var1, Word16 var2 ); /* Short add, 1 */ -Word16 sub( Word16 var1, Word16 var2 ); /* Short sub, 1 */ -Word16 abs_s( Word16 var1 ); /* Short abs, 1 */ -Word16 shl( Word16 var1, Word16 var2 ); /* Short shift left, 1 */ -Word16 shr( Word16 var1, Word16 var2 ); /* Short shift right, 1 */ -Word16 mult( Word16 var1, Word16 var2 ); /* Short mult, 1 */ -Word32 L_mult( Word16 var1, Word16 var2 ); /* Long mult, 1 */ -Word16 negate( Word16 var1 ); /* Short negate, 1 */ -Word16 extract_h( Word32 L_var1 ); /* Extract high, 1 */ -Word16 extract_l( Word32 L_var1 ); /* Extract low, 1 */ -Word16 round_fx( Word32 L_var1 ); /* Round, 1 */ -Word32 L_mac( Word32 L_var3, Word16 var1, Word16 var2 ); /* Mac, 1 */ -Word32 L_msu( Word32 L_var3, Word16 var1, Word16 var2 ); /* Msu, 1 */ -Word32 L_macNs( Word32 L_var3, Word16 var1, Word16 var2 ); /* Mac without - sat, 1 */ -#else /* BASOP_NOGLOB */ Word16 add( Word16 var1, Word16 var2 ); /* Short add, 1 */ Word16 sub( Word16 var1, Word16 var2 ); /* Short sub, 1 */ Word16 abs_s( Word16 var1 ); /* Short abs, 1 */ @@ -166,27 +141,9 @@ Word32 L_sub_co( Word32 L_var1, Word32 L_var2, Flag *Carry, Flag *Overflow ); Word32 L_add_c( Word32 L_var1, Word32 L_var2 ); /* Long add with c, 2 */ Word32 L_sub_c( Word32 L_var1, Word32 L_var2 ); /* Long sub with c, 2 */ -#endif /* BASOP_NOGLOB */ -#ifndef BASOP_NOGLOB -Word32 L_msuNs( Word32 L_var3, Word16 var1, Word16 var2 ); /* Msu without - sat, 1 */ -#else /* BASOP_NOGLOB */ Word32 DEPR_L_msuNs( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry ); /* Msu without sat, 1 */ -#endif /* BASOP_NOGLOB */ -#ifndef BASOP_NOGLOB -Word32 L_add( Word32 L_var1, Word32 L_var2 ); /* Long add, 1 */ -Word32 L_sub( Word32 L_var1, Word32 L_var2 ); /* Long sub, 1 */ -Word32 L_add_c( Word32 L_var1, Word32 L_var2 ); /* Long add with c, 2 */ -Word32 L_sub_c( Word32 L_var1, Word32 L_var2 ); /* Long sub with c, 2 */ -Word32 L_negate( Word32 L_var1 ); /* Long negate, 1 */ -Word16 mult_r( Word16 var1, Word16 var2 ); /* Mult with round, 1 */ -Word32 L_shl( Word32 L_var1, Word16 var2 ); /* Long shift left, 1 */ -Word32 L_shr( Word32 L_var1, Word16 var2 ); /* Long shift right, 1 */ -Word16 shr_r( Word16 var1, Word16 var2 ); /* Shift right with - round, 2 */ -#else /* BASOP_NOGLOB */ Word32 L_add( Word32 L_var1, Word32 L_var2 ); /* Long add, 1 */ Word32 L_sub( Word32 L_var1, Word32 L_var2 ); /* Long sub, 1 */ Word32 DEPR_L_add_c( Word32 L_var1, Word32 L_var2, Flag *Carry ); /* Long add with c, 2 */ @@ -197,44 +154,16 @@ Word32 L_shl( Word32 L_var1, Word16 var2 ); /* Word32 L_shr( Word32 L_var1, Word16 var2 ); /* Long shift right, 1 */ Word16 shr_r( Word16 var1, Word16 var2 ); /* Shift right with round, 2 */ -#endif /* BASOP_NOGLOB */ -#ifndef BASOP_NOGLOB -Word16 mac_r( Word32 L_var3, Word16 var1, Word16 var2 ); /* Mac with - rounding, 1 */ -#else /* BASOP_NOGLOB */ Word16 mac_r( Word32 L_var3, Word16 var1, Word16 var2 ); /* Mac with rounding, 1 */ -#endif /* BASOP_NOGLOB */ -#ifndef BASOP_NOGLOB -Word16 msu_r( Word32 L_var3, Word16 var1, Word16 var2 ); /* Msu with - rounding, 1 */ -#else /* BASOP_NOGLOB */ Word16 msu_r( Word32 L_var3, Word16 var1, Word16 var2 ); /* Msu with rounding, 1 */ -#endif /* BASOP_NOGLOB */ -#ifndef BASOP_NOGLOB -Word32 L_deposit_h( Word16 var1 ); /* 16 bit var1 -> MSB, 1 */ -Word32 L_deposit_l( Word16 var1 ); /* 16 bit var1 -> LSB, 1 */ -#else /* BASOP_NOGLOB */ Word32 L_deposit_h( Word16 var1 ); /* 16 bit var1 -> MSB, 1 */ Word32 L_deposit_l( Word16 var1 ); /* 16 bit var1 -> LSB, 1 */ -#endif /* BASOP_NOGLOB */ -#ifndef BASOP_NOGLOB -Word32 L_shr_r( Word32 L_var1, Word16 var2 ); /* Long shift right with - round, 3 */ -#else /* BASOP_NOGLOB */ Word32 L_shr_r( Word32 L_var1, Word16 var2 ); /* Long shift right with round, 3 */ -#endif /* BASOP_NOGLOB */ -#ifndef BASOP_NOGLOB -Word32 L_abs( Word32 L_var1 ); /* Long abs, 1 */ -Word32 L_sat( Word32 L_var1 ); /* Long saturation, 4 */ -Word16 norm_s( Word16 var1 ); /* Short norm, 1 */ -Word16 div_s( Word16 var1, Word16 var2 ); /* Short division, 18 */ -Word16 norm_l( Word32 L_var1 ); /* Long norm, 1 */ -#else /* BASOP_NOGLOB */ Word32 L_abs( Word32 L_var1 ); /* Long abs, 1 */ Word32 DEPR_L_sat_co( Word32 L_var1, Flag Overflow, Flag Carry ); /* Long saturation, 4 */ Word16 norm_s( Word16 var1 ); /* Short norm, 1 */ @@ -242,22 +171,15 @@ Word16 div_s( Word16 var1, Word16 var2 ); /* Word32 div_w( Word32 L_num, Word32 L_den ); Word16 norm_l( Word32 L_var1 ); /* Long norm, 1 */ Word32 L_sat( Word32 L_var1 ); /* Long saturation, 4 */ -#endif /* BASOP_NOGLOB */ /* * Additional G.723.1 operators */ -#ifndef BASOP_NOGLOB -Word32 L_mls( Word32, Word16 ); /* Weight FFS; currently assigned 5 */ -Word16 div_l( Word32, Word16 ); /* Weight FFS; currently assigned 32 */ -Word16 i_mult( Word16 a, Word16 b ); /* Weight FFS; currently assigned 3 */ -#else /* BASOP_NOGLOB */ Word32 L_mls( Word32, Word16 ); /* Weight FFS; currently assigned 5 */ Word16 div_l( Word32, Word16 ); /* Weight FFS; currently assigned 32 */ Word16 i_mult( Word16 a, Word16 b ); /* Weight FFS; currently assigned 3 */ Word16 DEPR_i_mult( Word16 a, Word16 b ); /* Weight FFS; currently assigned 3 */ -#endif /* BASOP_NOGLOB */ /* * New shiftless operators, not used in G.729/G.723.1 @@ -265,7 +187,6 @@ Word16 DEPR_i_mult( Word16 a, Word16 b ); /* Weight FFS; currently assigned 3 */ Word32 L_mult0( Word16 v1, Word16 v2 ); /* 32-bit Multiply w/o shift 1 */ Word32 L_mac0( Word32 L_v3, Word16 v1, Word16 v2 ); /* 32-bit Mac w/o shift 1 */ Word32 L_msu0( Word32 L_v3, Word16 v1, Word16 v2 ); /* 32-bit Msu w/o shift 1 */ -#ifdef BASOP_NOGLOB /* * Overflowing operators @@ -296,7 +217,6 @@ Word32 L_shr_ro( Word32 L_var1, Word16 var2, Flag *Overflow ); Word32 L_macNs_co( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry, Flag *Overflow ); Word32 L_msuNs_co( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry, Flag *Overflow ); -#endif /* BASOP_NOGLOB */ /* * Saturating operators diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index c465428fc..fb4cf1517 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -43,7 +43,6 @@ #include "rom_com.h" #include "rom_basic_math.h" #include "basop_settings.h" -#include "control.h" #include "cnst.h" diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 2f886ed1e..4b38a9a03 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -39,7 +39,6 @@ #include #include "options.h" -#include "stl.h" /* clang-format off */ #ifdef IVAS_FLOAT_FIXED @@ -258,8 +257,6 @@ enum{ #define SBA_AGC_FORCE_DISABLE 0 #define SBA_AGC_DEFAULT -1 -extern const Word16 Idx2Freq_Tbl[]; - /*----------------------------------------------------------------------------------* * Layers *----------------------------------------------------------------------------------*/ @@ -3065,10 +3062,7 @@ enum #define G192_BIN1 (UWord16) 0x0081 /* binary "1" according to ITU-T G.192 */ #define DEGREE_180 (Word32)(180.0 *ONE_IN_Q23) #define DEGREE_360 (Word32)(360.0 *ONE_IN_Q23) -extern const Word16 Idx2Freq_Tbl[]; -#if 0 -//TO do add in rom_com -#endif + #define chk_fs(fs) /* 'x' is converted to Q6, 'Freq_Tbl'/1000 in Q9 */ /* only works for 'fs' = [8000,12800,16000,25600,32000,48000] (unpredictable otherwise) */ diff --git a/lib_com/complex_basop.c b/lib_com/complex_basop.c index ffe56d475..c086ed349 100644 --- a/lib_com/complex_basop.c +++ b/lib_com/complex_basop.c @@ -9,20 +9,10 @@ *****************************************************************************/ -#include "typedef.h" -#include "basop32.h" - -#include "complex_basop.h" - #include "stl.h" - #ifdef WMOPS - -extern BASIC_OP multiCounter[MAXCOUNTERS]; - extern int currCounter; - #endif /* if WMOPS */ diff --git a/lib_com/complex_basop.h b/lib_com/complex_basop.h index 117ba400e..bf1641e74 100644 --- a/lib_com/complex_basop.h +++ b/lib_com/complex_basop.h @@ -10,8 +10,6 @@ #ifndef _COMPLEX_BASIC_OP_H #define _COMPLEX_BASIC_OP_H -#include "typedef.h" -#include "basop32.h" #include "stl.h" #ifdef COMPLEX_OPERATOR diff --git a/lib_com/control.c b/lib_com/control.c deleted file mode 100644 index 20865de23..000000000 --- a/lib_com/control.c +++ /dev/null @@ -1,284 +0,0 @@ -/* - =========================================================================== - File: CONTROL.C v.2.3 - 30.Nov.2009 - =========================================================================== - - ITU-T STL BASIC OPERATORS - - CONTROL FLOW OPERATOR INTERNAL VARIABLE DECLARATIONS - - History: - 07 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control - operators for the ITU-T Standard Tool Library as - described in Geneva, 20-30 January 2004 WP 3/16 Q10/16 - TD 11 document and subsequent discussions on the - wp3audio@yahoogroups.com email reflector. - March 06 v2.1 Changed to improve portability. - - ============================================================================ -*/ - -#include "stl.h" - -#ifdef WMOPS -int funcId_where_last_call_to_else_occurred; -long funcid_total_wmops_at_last_call_to_else; -int call_occurred = 1; -#endif - -#ifdef CONTROL_CODE_OPS - -Flag LT_16( Word16 var1, Word16 var2 ) -{ - Flag F_ret = 0; - - if ( var1 < var2 ) - { - F_ret = 1; - } -#ifdef WMOPS - multiCounter[currCounter].LT_16++; -#endif - return F_ret; -} - -Flag GT_16( Word16 var1, Word16 var2 ) -{ - Flag F_ret = 0; - - if ( var1 > var2 ) - { - F_ret = 1; - } -#ifdef WMOPS - multiCounter[currCounter].GT_16++; -#endif - return F_ret; -} - -Flag LE_16( Word16 var1, Word16 var2 ) -{ - Flag F_ret = 0; - - if ( var1 <= var2 ) - { - F_ret = 1; - } -#ifdef WMOPS - multiCounter[currCounter].LE_16++; -#endif - return F_ret; -} - -Flag GE_16( Word16 var1, Word16 var2 ) -{ - Flag F_ret = 0; - - if ( var1 >= var2 ) - { - F_ret = 1; - } -#ifdef WMOPS - multiCounter[currCounter].GE_16++; -#endif - return F_ret; -} - -Flag EQ_16( Word16 var1, Word16 var2 ) -{ - Flag F_ret = 0; - - if ( var1 == var2 ) - { - F_ret = 1; - } -#ifdef WMOPS - multiCounter[currCounter].EQ_16++; -#endif - return F_ret; -} - -Flag NE_16( Word16 var1, Word16 var2 ) -{ - Flag F_ret = 0; - - if ( var1 != var2 ) - { - F_ret = 1; - } -#ifdef WMOPS - multiCounter[currCounter].NE_16++; -#endif - return F_ret; -} - -Flag LT_32( Word32 L_var1, Word32 L_var2 ) -{ - Flag F_ret = 0; - - if ( L_var1 < L_var2 ) - { - F_ret = 1; - } -#ifdef WMOPS - multiCounter[currCounter].LT_32++; -#endif - return F_ret; -} - -Flag GT_32( Word32 L_var1, Word32 L_var2 ) -{ - Flag F_ret = 0; - - if ( L_var1 > L_var2 ) - { - F_ret = 1; - } -#ifdef WMOPS - multiCounter[currCounter].GT_32++; -#endif - return F_ret; -} - -Flag LE_32( Word32 L_var1, Word32 L_var2 ) -{ - Flag F_ret = 0; - - if ( L_var1 <= L_var2 ) - { - F_ret = 1; - } -#ifdef WMOPS - multiCounter[currCounter].LE_32++; -#endif - return F_ret; -} - -Flag GE_32( Word32 L_var1, Word32 L_var2 ) -{ - Flag F_ret = 0; - - if ( L_var1 >= L_var2 ) - { - F_ret = 1; - } -#ifdef WMOPS - multiCounter[currCounter].GE_32++; -#endif - return F_ret; -} - -Flag EQ_32( Word32 L_var1, Word32 L_var2 ) -{ - Flag F_ret = 0; - - if ( L_var1 == L_var2 ) - { - F_ret = 1; - } -#ifdef WMOPS - multiCounter[currCounter].EQ_32++; -#endif - return F_ret; -} - -Flag NE_32( Word32 L_var1, Word32 L_var2 ) -{ - Flag F_ret = 0; - - if ( L_var1 != L_var2 ) - { - F_ret = 1; - } -#ifdef WMOPS - multiCounter[currCounter].NE_32++; -#endif - return F_ret; -} - -Flag LT_64( Word64 L64_var1, Word64 L64_var2 ) -{ - Flag F_ret = 0; - - if ( L64_var1 < L64_var2 ) - { - F_ret = 1; - } -#ifdef WMOPS - multiCounter[currCounter].LT_64++; -#endif - return F_ret; -} - -Flag GT_64( Word64 L64_var1, Word64 L64_var2 ) -{ - Flag F_ret = 0; - - if ( L64_var1 > L64_var2 ) - { - F_ret = 1; - } -#ifdef WMOPS - multiCounter[currCounter].GT_64++; -#endif - return F_ret; -} - -Flag LE_64( Word64 L64_var1, Word64 L64_var2 ) -{ - Flag F_ret = 0; - - if ( L64_var1 <= L64_var2 ) - { - F_ret = 1; - } -#ifdef WMOPS - multiCounter[currCounter].LE_64++; -#endif - return F_ret; -} -Flag GE_64( Word64 L64_var1, Word64 L64_var2 ) -{ - Flag F_ret = 0; - - if ( L64_var1 >= L64_var2 ) - { - F_ret = 1; - } -#ifdef WMOPS - multiCounter[currCounter].GE_64++; -#endif - return F_ret; -} - -Flag EQ_64( Word64 L64_var1, Word64 L64_var2 ) -{ - Flag F_ret = 0; - - if ( L64_var1 == L64_var2 ) - { - F_ret = 1; - } -#ifdef WMOPS - multiCounter[currCounter].EQ_64++; -#endif - return F_ret; -} -Flag NE_64( Word64 L64_var1, Word64 L64_var2 ) -{ - Flag F_ret = 0; - - if ( L64_var1 != L64_var2 ) - { - F_ret = 1; - } -#ifdef WMOPS - multiCounter[currCounter].NE_64++; -#endif - return F_ret; -} - -#endif /* #ifdef CONTROL_CODE_OPS */ - - -/* end of file */ diff --git a/lib_com/control.h b/lib_com/control.h deleted file mode 100644 index ad1e5ae69..000000000 --- a/lib_com/control.h +++ /dev/null @@ -1,367 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#ifndef _CONTROL_H -#define _CONTROL_H - -#include "stl.h" - - -/***************************************************************************** - * - * Constants and Globals - * - *****************************************************************************/ -#ifdef WMOPS -extern BASIC_OP multiCounter[MAXCOUNTERS]; -extern int currCounter; - -/* Technical note : - * The following 3 variables are only used for correct complexity - * evaluation of the following structure : - * IF{ - * ... - * } ELSE IF { - * ... - * } ELSE IF { - * ... - * } - * ... - * } ELSE { - * ... - * } - */ -extern int funcId_where_last_call_to_else_occurred; -extern long funcid_total_wmops_at_last_call_to_else; -extern int call_occurred; -#endif /* ifdef WMOPS */ - - -/***************************************************************************** - * - * Function Macros - * - *****************************************************************************/ - -/***************************************************************************** - * - * Function Name : FOR - * - * Purpose : - * - * The macro FOR should be used instead of the 'for' C statement. - * The complexity is independent of the number of loop iterations that are - * performed. - * - * Complexity weight : 3 (regardless of number of iterations). - * - *****************************************************************************/ -#ifndef WMOPS -#define FOR( a ) for ( a ) - -#else /* ifndef WMOPS */ -#define FOR( a ) \ - if ( incrFor(), 0 ) \ - ; \ - else \ - for ( a ) - -static __inline void incrFor( void ) -{ - multiCounter[currCounter].For++; -} -#endif /* ifndef WMOPS */ - - -/***************************************************************************** - * - * Function Name : WHILE - * - * Purpose : - * - * The macro WHILE should be used instead of the 'while' C statement. - * The complexity is proportional to the number of loop iterations that - * are performed. - * - * Complexity weight : 4 x 'number of loop iterations'. - * - *****************************************************************************/ -#ifndef WMOPS -#define WHILE( a ) while ( a ) - -#else /* ifndef WMOPS */ -#define WHILE( a ) while ( incrWhile(), a ) - -static __inline void incrWhile( void ) -{ - multiCounter[currCounter].While++; -} -#endif /* ifndef WMOPS */ - - -/***************************************************************************** - * - * Function Name : DO - * - * Purpose : - * - * The macro DO should be used instead of the 'do' C statement. - * - * Complexity weight : 0 (complexity counted by WHILE macro). - * - *****************************************************************************/ -#ifndef WMOPS -#define DO do - -#else /* ifndef WMOPS */ -#define DO do - -#endif /* ifndef WMOPS */ - - -/***************************************************************************** - * - * Function Name : IF - * - * Purpose : - * - * The macro IF should : - * - * - not be used when : - * - the 'if' structure does not have any 'else if' nor 'else' statement - * - and it conditions only one DSP basic operations. - * - * - be used instead of the 'if' C statement in every other case : - * - when there is an 'else' or 'else if' statement, - * - or when the 'if' conditions several DSP basic operations, - * - or when the 'if' conditions a function call. - * - * Complexity weight : 4 - * - *****************************************************************************/ -#ifndef WMOPS -#define IF( a ) if ( a ) - -#else /* ifndef WMOPS */ -#define IF( a ) if ( incrIf(), a ) - -static __inline void incrIf( void ) -{ - /* Technical note : - * If the "IF" operator comes just after an "ELSE", its counter - * must not be incremented. - */ - if ( ( currCounter != funcId_where_last_call_to_else_occurred ) || ( TotalWeightedOperation() != funcid_total_wmops_at_last_call_to_else ) || ( call_occurred == 1 ) ) - multiCounter[currCounter].If++; - - call_occurred = 0; - funcId_where_last_call_to_else_occurred = MAXCOUNTERS; -} -#endif /* ifndef WMOPS */ - - -/***************************************************************************** - * - * Function Name : ELSE - * - * Purpose : - * - * The macro ELSE should be used instead of the 'else' C statement. - * - * Complexity weight : 4 - * - *****************************************************************************/ -#ifndef WMOPS -#define ELSE else - -#else /* ifndef WMOPS */ -#define ELSE \ - else if ( incrElse(), 0 ); \ - else - -static __inline void incrElse( void ) -{ - multiCounter[currCounter].If++; - - /* We keep track of the funcId of the last function which used ELSE {...} structure. */ - funcId_where_last_call_to_else_occurred = currCounter; - - /* We keep track of the number of WMOPS of this funcId when the ELSE macro was called. */ - funcid_total_wmops_at_last_call_to_else = TotalWeightedOperation(); - - /* call_occurred is set to 0, in order to count the next IF (if necessary) */ - call_occurred = 0; -} -#endif /* ifndef WMOPS */ - - -/***************************************************************************** - * - * Function Name : SWITCH - * - * Purpose : - * - * The macro SWITCH should be used instead of the 'switch' C statement. - * - * Complexity weight : 8 - * - *****************************************************************************/ -#ifndef WMOPS -#define SWITCH( a ) switch ( a ) - -#else /* ifndef WMOPS */ -#define SWITCH( a ) switch ( incrSwitch(), a ) - -static __inline void incrSwitch( void ) -{ - multiCounter[currCounter].Switch++; -} -#endif /* ifndef WMOPS */ - - -/***************************************************************************** - * - * Function Name : CONTINUE - * - * Purpose : - * - * The macro CONTINUE should be used instead of the 'continue' C statement. - * - * Complexity weight : 4 - * - *****************************************************************************/ -#ifndef WMOPS -#define CONTINUE continue - -#else /* ifndef WMOPS */ -#define CONTINUE \ - if ( incrContinue(), 0 ) \ - ; \ - else \ - continue - -static __inline void incrContinue( void ) -{ - multiCounter[currCounter].Continue++; -} -#endif /* ifndef WMOPS */ - - -/***************************************************************************** - * - * Function Name : BREAK - * - * Purpose : - * - * The macro BREAK should be used instead of the 'break' C statement. - * - * Complexity weight : 4 - * - *****************************************************************************/ -#ifndef WMOPS -#define BREAK break - -#else /* ifndef WMOPS */ -#define BREAK \ - if ( incrBreak(), 0 ) \ - ; \ - else \ - break - -static __inline void incrBreak( void ) -{ - multiCounter[currCounter].Break++; -} -#endif /* ifndef WMOPS */ - - -/***************************************************************************** - * - * Function Name : GOTO - * - * Purpose : - * - * The macro GOTO should be used instead of the 'goto' C statement. - * - * Complexity weight : 4 - * - *****************************************************************************/ -#ifndef WMOPS -#define GOTO goto - -#else /* ifndef WMOPS */ -#define GOTO \ - if ( incrGoto(), 0 ) \ - ; \ - else \ - goto - -static __inline void incrGoto( void ) -{ - multiCounter[currCounter].Goto++; -} -#endif /* ifndef WMOPS */ - - -/* - * New control code basops - */ -#ifdef CONTROL_CODE_OPS - -Flag LT_16( Word16 var1, Word16 var2 ); -Flag GT_16( Word16 var1, Word16 var2 ); -Flag LE_16( Word16 var1, Word16 var2 ); -Flag GE_16( Word16 var1, Word16 var2 ); -Flag EQ_16( Word16 var1, Word16 var2 ); -Flag NE_16( Word16 var1, Word16 var2 ); - -Flag LT_32( Word32 L_var1, Word32 L_var2 ); -Flag GT_32( Word32 L_var1, Word32 L_var2 ); -Flag LE_32( Word32 L_var1, Word32 L_var2 ); -Flag GE_32( Word32 L_var1, Word32 L_var2 ); -Flag EQ_32( Word32 L_var1, Word32 L_var2 ); -Flag NE_32( Word32 L_var1, Word32 L_var2 ); - -Flag LT_64( Word64 L64_var1, Word64 L64_var2 ); -Flag GT_64( Word64 L64_var1, Word64 L64_var2 ); -Flag LE_64( Word64 L64_var1, Word64 L64_var2 ); -Flag GE_64( Word64 L64_var1, Word64 L64_var2 ); -Flag EQ_64( Word64 L64_var1, Word64 L64_var2 ); -Flag NE_64( Word64 L64_var1, Word64 L64_var2 ); - - -#endif /* #ifdef CONTROL_CODE_OPS */ - -#endif /* _CONTROL_H */ - - -/* end of file */ diff --git a/lib_com/count.c b/lib_com/count.c index eaf6f04f4..dba2201df 100644 --- a/lib_com/count.c +++ b/lib_com/count.c @@ -47,8 +47,9 @@ #include #include #include -#include "stl.h" #include "options.h" +#include "stl.h" +#include "count.h" #include "wmc_auto.h" #ifndef WMOPS @@ -57,7 +58,9 @@ #define WMC_TOOL_SKIP -#ifdef WMOPS + + + static double frameRate = FRAME_RATE; /* default value : 10 ms */ #define MAX_RECORDS 1024 @@ -91,7 +94,6 @@ static int sum_stack[MAX_STACK]; /* Global counter variable for calculation of complexity weight */ /* Some enhancement written by Vail., GJR and M.Mul. during EVS time */ -BASIC_OP multiCounter[MAXCOUNTERS]; BASIC_OP glob_multiCounter; int currCounter = 0; /* Zero equals global counter */ @@ -104,6 +106,7 @@ void setFrameRate( int samplingFreq, int frameLength ) return; } +int lookup_table[MAX_HASH_TABLE_SIZE]; /* * Below list is used for displaying the code profiling information in @@ -174,69 +177,6 @@ char *BasicOperationList[] = { }; -const BASIC_OP op_weight = { - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 2, 2, 1, - 1, 1, 1, 2, 1, - - 1, 1, 1, 2, 1, - 1, 1, 18, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 2, 2, 2, 2, 1, - - 1, 1, 1, 1, 1, - 1, 1, 1, 2, - 1, 2, 2, 2, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 3, - 3, 3, 3, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 3, 2, - 2, 6, 3, 3, 2, - - 1, 32, 1 - -/* New complex basops */ -#ifdef COMPLEX_OPERATOR - , - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1 - - , - 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1 - -#endif /* #ifdef COMPLEX_OPERATOR */ - -#ifdef ENH_64_BIT_OPERATOR - /* Weights of new 64 bit basops */ - , - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 -#endif /* #ifdef ENH_64_BIT_OPERATOR */ - -#ifdef ENH_32_BIT_OPERATOR - , - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 -#endif /* #ifdef ENH_32_BIT_OPERATOR */ - -#ifdef ENH_U_32_BIT_OPERATOR - , - 1, 1, 1, 2, 2, 1, 1 -#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ - -#ifdef CONTROL_CODE_OPS - , - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 -#endif /* #ifdef CONTROL_CODE_OPS */ -}; -#endif /* ifdef WMOPS */ - - -Word32 TotalWeightedOperation( void ); -Word32 DeltaWeightedOperation( void ); #ifdef WMOPS @@ -257,8 +197,6 @@ static Word16 fwc_corr[MAXCOUNTERS + 1]; static long int nbTimeObjectIsCalled[MAXCOUNTERS + 1]; -#define NbFuncMax ( 4096 ) - /** funcid: current function call for each counter @@ -276,10 +214,9 @@ static long int nbTimeObjectIsCalled[MAXCOUNTERS + 1]; LastWOper: values used for WMOPS deltas */ -static Word32 funcid[MAXCOUNTERS], nbframe[MAXCOUNTERS], nbcalls[MAXCOUNTERS]; -static Word32 glob_bc[MAXCOUNTERS], glob_wc[MAXCOUNTERS], bc[MAXCOUNTERS][NbFuncMax], wc[MAXCOUNTERS][NbFuncMax]; +static Word32 nbframe[MAXCOUNTERS], nbcalls[MAXCOUNTERS]; +static Word32 glob_bc[MAXCOUNTERS], glob_wc[MAXCOUNTERS]; static float total_wmops[MAXCOUNTERS]; -static Word32 LastWOper[MAXCOUNTERS]; /* FROM_EVS_DEV */ static float total_sum[MAXCOUNTERS]; static Word16 call_tree[MAXCOUNTERS][MAXCOUNTERS]; @@ -322,6 +259,18 @@ static char *my_strdup( const char *s ) return strcpy( dup, s ); } + +int calc_hash( const char *str ) +{ + /* A simple hash function (might be good to replace with a better one) */ + int hash_value = 0; + for ( int i = 0; str[i]; i++ ) + { + hash_value += str[i]; + } + return hash_value % MAX_HASH_TABLE_SIZE; +} + #endif /* ifdef WMOPS */ @@ -426,7 +375,7 @@ static Word32 WMOPS_frameStat( void ) #ifdef WMOPS static void WMOPS_clearMultiCounter( void ) { - Word16 i; + Word32 i; Word32 *ptr = (Word32 *) &multiCounter[currCounter]; for ( i = 0; i < (Word16) ( sizeof( multiCounter[currCounter] ) / sizeof( Word32 ) ); i++ ) @@ -440,7 +389,7 @@ static void WMOPS_clearMultiCounter( void ) void ClearNbTimeObjectsAreCalled() { #ifdef WMOPS - Word16 i; + Word32 i; for ( i = 0; i < (Word16) ( sizeof( multiCounter[currCounter] ) / sizeof( Word32 ) ); i++ ) { @@ -449,50 +398,13 @@ void ClearNbTimeObjectsAreCalled() #endif /* ifdef WMOPS */ } -Word32 TotalWeightedOperation() -{ -#ifdef WMOPS - Word16 i; - Word32 tot, *ptr; - const Word32 *ptr2; - - tot = 0; - ptr = (Word32 *) &multiCounter[currCounter]; - ptr2 = (const Word32 *) &op_weight; - for ( i = 0; i < (Word16) ( sizeof( multiCounter[currCounter] ) / sizeof( Word32 ) ); i++ ) - { - tot += ( ( *ptr++ ) * ( *ptr2++ ) ); - } - - return ( (Word32) tot ); - -#else /* ifdef WMOPS */ - return 0; /* Dummy */ - -#endif /* ifdef WMOPS */ -} - -Word32 DeltaWeightedOperation() -{ -#ifdef WMOPS - Word32 NewWOper, delta; - NewWOper = TotalWeightedOperation(); - delta = NewWOper - LastWOper[currCounter]; - LastWOper[currCounter] = NewWOper; - return ( delta ); - -#else /* ifdef WMOPS */ - return 0; /* Dummy */ - -#endif /* ifdef WMOPS */ -} void Init_WMOPS_counter( void ) { #ifdef WMOPS - Word16 i; + Word32 i; /* reset function weight operation counter variable */ @@ -561,37 +473,12 @@ Word32 Reset_WMOPS_counter( void ) } -Word32 fwc( void ) -{ -/* function worst case */ -#ifdef WMOPS - Word32 tot; - - tot = DeltaWeightedOperation(); - if ( tot > wc[currCounter][funcid[currCounter]] ) - wc[currCounter][funcid[currCounter]] = tot; - if ( tot < bc[currCounter][funcid[currCounter]] ) - bc[currCounter][funcid[currCounter]] = tot; - - funcid[currCounter]++; - - /*make sure that BASOP_frame_update(); is put at the end of the main loop*/ - if ( funcid[currCounter] >= NbFuncMax ) - { - printf( "to many function calls\n" ); - } - assert( funcid[currCounter] < NbFuncMax ); - return ( tot ); -#else - return 0; -#endif /* ifdef WMOPS */ -} void WMOPS_output( Word16 dtx_mode ) { #ifdef WMOPS - Word16 i; + Word32 i; Word32 tot, tot_wm, tot_wc; /* get operations since last reset (or init), but do not update the counters (except the glob_wc[] maximum) @@ -626,7 +513,7 @@ void WMOPS_output( Word16 dtx_mode ) void WMOPS_output_avg( Word16 dtx_mode, Word32 *tot_wm, Word32 *num_frames ) { #ifdef WMOPS - Word16 i; + Word32 i; Word32 tot, tot_wc; /* get operations since last reset (or init), but do not update the counters (except the glob_wc[] maximum) @@ -663,7 +550,7 @@ void generic_WMOPS_output( Word16 dtx_mode, char *test_file_name ) { #ifdef WMOPS int saved_value; - Word16 i; + Word32 i; Word32 tot, tot_wm, tot_wc, *ptr; const Word32 *ptr2; Word40 grand_total; @@ -952,27 +839,28 @@ void printStack( char *text, char *Id ) #ifdef WMOPS void BASOP_push_wmops( const char *label ) { - int new_flag, prev_counter; + int prev_counter; int i, j; - /* Check if new counter label */ - new_flag = 1; - for ( i = 1; i <= maxCounter; i++ ) + int label_hash; + label_hash = calc_hash( label ); + + /* check, if string matches (get new entry, if not) */ + i = lookup_table[label_hash]; + while ( i != -1 && strcmp( objectName[i], label ) != 0 ) { - if ( strcmp( objectName[i], label ) == 0 ) - { - new_flag = 0; - break; - } + i = lookup_table[++label_hash]; } prev_counter = readCounterId(); - /* Configure new record */ - if ( new_flag ) + if ( i == -1 ) { + /* create new entry */ i = (int) getCounterId( label ); - setCounter( i ); + lookup_table[label_hash] = i; + + setCounter( maxCounter ); Init_WMOPS_counter(); } else @@ -1147,46 +1035,8 @@ void WMOPS_output_all( Word16 dtx_mode ) frameRate * glob_wc[0], ( nbframe[0] == 0 ) ? 0 : ops_cnt / nbframe[0] ); } -#if 0 - { - char *sfmtt = "%20s %4s %15s\n"; - char *dfmtt = "%20s %4d "; - - fprintf (stderr, "\nCall Tree:\n\n"); - fprintf (stderr, sfmtt, " function", "num", "called by: "); - fprintf (stderr, sfmtt, "---------------", "---", "--------------"); - for (i = 1; i <= maxCounter; i++) - { - int j; - - fprintf (stderr, dfmtt, objectName[i], i); - for (j = 0; call_tree[i][j] != -1; j++) - { - if (j != 0) - { - fprintf (stderr, ", "); - } - fprintf (stderr, "%s", objectName[call_tree[i][j]]); - } - fprintf (stderr, "\n"); - - } - fprintf (stderr, sfmtt, "---------------", "---", "--------------"); - fprintf (stderr, "\n\n"); - } -#endif - -#if 0 - fprintf (stderr, "\n\n"); - for (i=1; i<=maxCounter; i++) - { - setCounter(i); - WMOPS_output(dtx_mode); - } -#else (void) dtx_mode; -#endif #if MAX_CALLERS_SAVED_FRAMES for ( i = 1; i <= MAX_CALLERS_SAVED_FRAMES; i++ ) @@ -1280,8 +1130,8 @@ void WMOPS_output_all_std( Word16 dtx_mode ) ( glob_bc[i] == MAX_32 ) ? 0 : frameRate * (float) glob_bc[i], ( glob_wc[i] == 0 ) ? 0 : frameRate * (float) glob_wc[i], ( nbframe[i] == 0 ) ? 0 : (float) total_wmops[i] / (float) nbframe[i], - frameRate * ( glob_sum_bc[i] ), - frameRate * ( glob_sum_wc[i] ), + ( glob_sum_bc[i] == MAX_32 ) ? 0 : frameRate * ( glob_sum_bc[i] ), + ( glob_sum_wc[i] == 0 ) ? 0 : frameRate * ( glob_sum_wc[i] ), ( nbframe[i] == 0 ) ? 0 : (float) ( ( total_sum[i] ) / (float) nbframe[i] ) ); /* frameRate*(glob_bc[i]+wmops_children_bc[i]), */ /* frameRate*(glob_wc[i]+wmops_children_wc[i]), */ @@ -1299,46 +1149,8 @@ void WMOPS_output_all_std( Word16 dtx_mode ) frameRate * glob_wc[0], ( nbframe[0] == 0 ) ? 0 : ops_cnt / nbframe[0] ); } -#if 0 - { - char *sfmtt = "%20s %4s %15s\n"; - char *dfmtt = "%20s %4d "; - - fprintf (stdout, "\nCall Tree:\n\n"); - fprintf (stdout, sfmtt, " function", "num", "called by: "); - fprintf (stdout, sfmtt, "---------------", "---", "--------------"); - for (i = 1; i <= maxCounter; i++) - { - int j; - - fprintf (stdout, dfmtt, objectName[i], i); - for (j = 0; call_tree[i][j] != -1; j++) - { - if (j != 0) - { - fprintf (stdout, ", "); - } - fprintf (stdout, "%s", objectName[call_tree[i][j]]); - } - fprintf (stdout, "\n"); - - } - fprintf (stdout, sfmtt, "---------------", "---", "--------------"); - fprintf (stdout, "\n\n"); - } -#endif - -#if 0 - fprintf (stdout, "\n\n"); - for (i=1; i<=maxCounter; i++) - { - setCounter(i); - WMOPS_output(dtx_mode); - } -#else (void) dtx_mode; -#endif WMOPS_destroy(); diff --git a/lib_com/count.h b/lib_com/count.h index 10e96e44f..b32733882 100644 --- a/lib_com/count.h +++ b/lib_com/count.h @@ -62,9 +62,7 @@ #include - -#define MAXCOUNTERS ( 512 ) -#define MAX_CALLERS_SAVED_FRAMES 5 /* # of Frame for which WMOPS Complexity Details will be saved, 0 = Disabled */ +int calc_hash( const char *str ); int getCounterId( const char *objectName ); /* @@ -145,17 +143,7 @@ void WMOPS_output_avg( Word16 dtx_mode, Word32 *tot_wm, Word32 *num_frames ); */ -Word32 fwc( void ); -/* - * worst worst case counter. - * - * This function calculates the worst possible case that can be reached. - * - * This is done by calling this function for each subpart of the calculations - * for a frame. This function then stores the maximum wMOPS for each part. - * - * The WMOPS_output function add together all parts and presents the sum. - */ + void setFrameRate( int samplingFreq, int frameLength ); /* @@ -164,299 +152,10 @@ void setFrameRate( int samplingFreq, int frameLength ); */ -#define WMOPS_DATA_FILENAME "wmops_data.txt" -/* - * WMOPS_DATA_FILENAME is the macro defining the name of the file - * where the Weighted Million of Operations per Second (wMOPS) - * are appended, function group by function group. - */ - -#define CODE_PROFILE_FILENAME "code_profile.txt" -/* - * CODE_PROFILE_FILENAME is the macro defining the name of the file - * where the Weighted Million of Operations per Second (WMOPS) - * are appended, basic operation by basic operation. - */ - - -#define WMOPS_TOTAL_FILENAME "wmops_total.txt" -/* - * WMOPS_TOTAL_FILENAME is the macro defining the name of the file - * where the Weighted Million of Operations per Second (WMOPS) - * are printed, globally for the application. - */ - - -#define FRAME_RATE ( 0.0001F ) /* in this version frame_rate can be overwriten online by the new setFrameRate function */ -/* FRAME_RATE of 0.000025 is corresponding to 40ms frame.*/ -/* FRAME_RATE of 0.00005 is corresponding to 20ms frame.*/ -/* FRAME_RATE of 0.0001 is corresponding to 10ms frame.*/ -/* - * FRAME_RATE is the macro defining the calling rate of the - * application to benchmark. - */ /* Global counter variable for calculation of complexity weight */ -typedef struct -{ - UWord32 add; /* Complexity Weight of 1 */ - UWord32 sub; /* Complexity Weight of 1 */ - UWord32 abs_s; /* Complexity Weight of 1 */ - UWord32 shl; /* Complexity Weight of 1 */ - UWord32 shr; /* Complexity Weight of 1 */ - - UWord32 extract_h; /* Complexity Weight of 1 */ - UWord32 extract_l; /* Complexity Weight of 1 */ - UWord32 mult; /* Complexity Weight of 1 */ - UWord32 L_mult; /* Complexity Weight of 1 */ - UWord32 negate; /* Complexity Weight of 1 */ - - UWord32 round; /* Complexity Weight of 1 */ - UWord32 L_mac; /* Complexity Weight of 1 */ - UWord32 L_msu; /* Complexity Weight of 1 */ - UWord32 L_macNs; /* Complexity Weight of 1 */ - UWord32 L_msuNs; /* Complexity Weight of 1 */ - - UWord32 L_add; /* Complexity Weight of 1 */ - UWord32 L_sub; /* Complexity Weight of 1 */ - UWord32 L_add_c; /* Complexity Weight of 2 */ - UWord32 L_sub_c; /* Complexity Weight of 2 */ - UWord32 L_negate; /* Complexity Weight of 1 */ - - UWord32 L_shl; /* Complexity Weight of 1 */ - UWord32 L_shr; /* Complexity Weight of 1 */ - UWord32 mult_r; /* Complexity Weight of 1 */ - UWord32 shr_r; /* Complexity Weight of 3 */ - UWord32 mac_r; /* Complexity Weight of 1 */ - - UWord32 msu_r; /* Complexity Weight of 1 */ - UWord32 L_deposit_h; /* Complexity Weight of 1 */ - UWord32 L_deposit_l; /* Complexity Weight of 1 */ - UWord32 L_shr_r; /* Complexity Weight of 3 */ - UWord32 L_abs; /* Complexity Weight of 1 */ - - UWord32 L_sat; /* Complexity Weight of 4 */ - UWord32 norm_s; /* Complexity Weight of 1 */ - UWord32 div_s; /* Complexity Weight of 18 */ - UWord32 norm_l; /* Complexity Weight of 1 */ - UWord32 move16; /* Complexity Weight of 1 */ - - UWord32 move32; /* Complexity Weight of 2 */ - UWord32 Logic16; /* Complexity Weight of 1 */ - UWord32 Logic32; /* Complexity Weight of 2 */ - UWord32 Test; /* Complexity Weight of 2 */ - UWord32 s_max; /* Complexity Weight of 1 */ - - UWord32 s_min; /* Complexity Weight of 1 */ - UWord32 L_max; /* Complexity Weight of 1 */ - UWord32 L_min; /* Complexity Weight of 1 */ - UWord32 L40_max; /* Complexity Weight of 1 */ - UWord32 L40_min; /* Complexity Weight of 1 */ - - UWord32 shl_r; /* Complexity Weight of 2 */ - UWord32 L_shl_r; /* Complexity Weight of 2 */ - UWord32 L40_shr_r; /* Complexity Weight of 2 */ - UWord32 L40_shl_r; /* Complexity Weight of 2 */ - UWord32 norm_L40; /* Complexity Weight of 1 */ - - UWord32 L40_shl; /* Complexity Weight of 1 */ - UWord32 L40_shr; /* Complexity Weight of 1 */ - UWord32 L40_negate; /* Complexity Weight of 1 */ - UWord32 L40_add; /* Complexity Weight of 1 */ - UWord32 L40_sub; /* Complexity Weight of 1 */ - - UWord32 L40_abs; /* Complexity Weight of 1 */ - UWord32 L40_mult; /* Complexity Weight of 1 */ - UWord32 L40_mac; /* Complexity Weight of 1 */ - UWord32 mac_r40; /* Complexity Weight of 2 */ - - UWord32 L40_msu; /* Complexity Weight of 1 */ - UWord32 msu_r40; /* Complexity Weight of 2 */ - UWord32 Mpy_32_16_ss; /* Complexity Weight of 2 */ - UWord32 Mpy_32_32_ss; /* Complexity Weight of 2 */ - UWord32 L_mult0; /* Complexity Weight of 1 */ - - UWord32 L_mac0; /* Complexity Weight of 1 */ - UWord32 L_msu0; /* Complexity Weight of 1 */ - UWord32 lshl; /* Complexity Weight of 1 */ - UWord32 lshr; /* Complexity Weight of 1 */ - UWord32 L_lshl; /* Complexity Weight of 1 */ - - UWord32 L_lshr; /* Complexity Weight of 1 */ - UWord32 L40_lshl; /* Complexity Weight of 1 */ - UWord32 L40_lshr; /* Complexity Weight of 1 */ - UWord32 s_and; /* Complexity Weight of 1 */ - UWord32 s_or; /* Complexity Weight of 1 */ - - UWord32 s_xor; /* Complexity Weight of 1 */ - UWord32 L_and; /* Complexity Weight of 1 */ - UWord32 L_or; /* Complexity Weight of 1 */ - UWord32 L_xor; /* Complexity Weight of 1 */ - UWord32 rotl; /* Complexity Weight of 3 */ - - UWord32 rotr; /* Complexity Weight of 3 */ - UWord32 L_rotl; /* Complexity Weight of 3 */ - UWord32 L_rotr; /* Complexity Weight of 3 */ - UWord32 L40_set; /* Complexity Weight of 1 */ - UWord32 L40_deposit_h; /* Complexity Weight of 1 */ - - UWord32 L40_deposit_l; /* Complexity Weight of 1 */ - UWord32 L40_deposit32; /* Complexity Weight of 1 */ - UWord32 Extract40_H; /* Complexity Weight of 1 */ - UWord32 Extract40_L; /* Complexity Weight of 1 */ - UWord32 L_Extract40; /* Complexity Weight of 1 */ - - UWord32 L40_round; /* Complexity Weight of 1 */ - UWord32 L_saturate40; /* Complexity Weight of 1 */ - UWord32 round40; /* Complexity Weight of 1 */ - UWord32 If; /* Complexity Weight of 3 */ - UWord32 Goto; /* Complexity Weight of 2 */ - - UWord32 Break; /* Complexity Weight of 2 */ - UWord32 Switch; /* Complexity Weight of 6 */ - UWord32 For; /* Complexity Weight of 3 */ - UWord32 While; /* Complexity Weight of 3 */ - UWord32 Continue; /* Complexity Weight of 2 */ - - UWord32 L_mls; /* Complexity Weight of 1 */ - UWord32 div_l; /* Complexity Weight of 32 */ - UWord32 i_mult; /* Complexity Weight of 1 */ - -/* New complex basic operators */ -#ifdef COMPLEX_OPERATOR - UWord32 CL_shr; /* Complexity Weight of 1 */ - UWord32 CL_shl; /* Complexity Weight of 1 */ - UWord32 CL_add; /* Complexity Weight of 1 */ - UWord32 CL_sub; /* Complexity Weight of 1 */ - UWord32 CL_scale; /* Complexity Weight of 1 */ - UWord32 CL_dscale; /* Complexity Weight of 1 */ - UWord32 CL_msu_j; /* Complexity Weight of 1 */ - UWord32 CL_mac_j; /* Complexity Weight of 1 */ - UWord32 CL_move; /* Complexity Weight of 1 */ - UWord32 CL_Extract_real; /* Complexity Weight of 1 */ - UWord32 CL_Extract_imag; /* Complexity Weight of 1 */ - UWord32 CL_form; /* Complexity Weight of 1 */ - UWord32 CL_multr_32x16; /* Complexity Weight of 2 */ - UWord32 CL_negate; /* Complexity Weight of 1 */ - UWord32 CL_conjugate; /* Complexity Weight of 1 */ - UWord32 CL_mul_j; /* Complexity Weight of 1 */ - UWord32 CL_swap_real_imag; /* Complexity Weight of 1 */ - UWord32 C_add; /* Complexity Weight of 1 */ - UWord32 C_sub; /* Complexity Weight of 1 */ - UWord32 C_mul_j; /* Complexity Weight of 1 */ - UWord32 C_multr; /* Complexity Weight of 2 */ - UWord32 C_form; /* Complexity Weight of 1 */ - - UWord32 C_scale; /* Complexity Weight of 1 */ - UWord32 CL_round32_16; /* Complexity Weight of 1 */ - UWord32 CL_scale_32; /* Complexity Weight of 1 */ - UWord32 CL_dscale_32; /* Complexity Weight of 1 */ - UWord32 CL_multr_32x32; /* Complexity Weight of 2 */ - UWord32 C_mac_r; /* Complexity Weight of 2 */ - UWord32 C_msu_r; /* Complexity Weight of 2 */ - UWord32 C_Extract_real; /* Complexity Weight of 1 */ - UWord32 C_Extract_imag; /* Complexity Weight of 1 */ - UWord32 C_negate; /* Complexity Weight of 1 */ - UWord32 C_conjugate; /* Complexity Weight of 1 */ - UWord32 C_shr; /* Complexity Weight of 1 */ - UWord32 C_shl; /* Complexity Weight of 1 */ - -#endif /* #ifdef COMPLEX_OPERATOR */ - -/* New 64 bit basops */ -#ifdef ENH_64_BIT_OPERATOR - UWord32 move64; /* Complexity Weight of 1 */ - UWord32 W_add_nosat; /* Complexity Weight of 1 */ - UWord32 W_sub_nosat; /* Complexity Weight of 1 */ - UWord32 W_shl; /* Complexity Weight of 1 */ - UWord32 W_shr; /* Complexity Weight of 1 */ - UWord32 W_shl_nosat; /* Complexity Weight of 1 */ - UWord32 W_shr_nosat; /* Complexity Weight of 1 */ - UWord32 W_mac_32_16; /* Complexity Weight of 1 */ - UWord32 W_msu_32_16; /* Complexity Weight of 1 */ - UWord32 W_mult_32_16; /* Complexity Weight of 1 */ - UWord32 W_mult0_16_16; /* Complexity Weight of 1 */ - UWord32 W_mac0_16_16; /* Complexity Weight of 1 */ - UWord32 W_msu0_16_16; /* Complexity Weight of 1 */ - UWord32 W_mult_16_16; /* Complexity Weight of 1 */ - UWord32 W_mac_16_16; /* Complexity Weight of 1 */ - UWord32 W_msu_16_16; /* Complexity Weight of 1 */ - UWord32 W_shl_sat_l; /* Complexity Weight of 1 */ - UWord32 W_sat_l; /* Complexity Weight of 1 */ - UWord32 W_sat_m; /* Complexity Weight of 1 */ - UWord32 W_deposit32_l; /* Complexity Weight of 1 */ - UWord32 W_deposit32_h; /* Complexity Weight of 1 */ - UWord32 W_extract_l; /* Complexity Weight of 1 */ - UWord32 W_extract_h; /* Complexity Weight of 1 */ - UWord32 W_round48_L; /* Complexity Weight of 1 */ - UWord32 W_round32_s; /* Complexity Weight of 1 */ - UWord32 W_norm; /* Complexity Weight of 1 */ - - UWord32 W_add; /* Complexity Weight of 1 */ - UWord32 W_sub; /* Complexity Weight of 1 */ - UWord32 W_neg; /* Complexity Weight of 1 */ - UWord32 W_abs; /* Complexity Weight of 1 */ - UWord32 W_mult_32_32; /* Complexity Weight of 1 */ - UWord32 W_mult0_32_32; /* Complexity Weight of 1 */ - UWord32 W_lshl; /* Complexity Weight of 1 */ - UWord32 W_lshr; /* Complexity Weight of 1 */ - UWord32 W_round64_L; /* Complexity Weight of 1 */ - -#endif /* #ifdef ENH_64_BIT_OPERATOR */ - -#ifdef ENH_32_BIT_OPERATOR - UWord32 Mpy_32_16_1; /* Complexity Weight of 1 */ - UWord32 Mpy_32_16_r; /* Complexity Weight of 1 */ - UWord32 Mpy_32_32; /* Complexity Weight of 1 */ - UWord32 Mpy_32_32_r; /* Complexity Weight of 1 */ - UWord32 Madd_32_16; /* Complexity Weight of 1 */ - UWord32 Madd_32_16_r; /* Complexity Weight of 1 */ - UWord32 Msub_32_16; /* Complexity Weight of 1 */ - UWord32 Msub_32_16_r; /* Complexity Weight of 1 */ - UWord32 Madd_32_32; /* Complexity Weight of 1 */ - UWord32 Madd_32_32_r; /* Complexity Weight of 1 */ - UWord32 Msub_32_32; /* Complexity Weight of 1 */ - UWord32 Msub_32_32_r; /* Complexity Weight of 1 */ -#endif /* #ifdef ENH_32_BIT_OPERATOR */ - -#ifdef ENH_U_32_BIT_OPERATOR - UWord32 UL_addNs; /* Complexity Weight of 1 */ - UWord32 UL_subNs; /* Complexity Weight of 1 */ - UWord32 UL_Mpy_32_32; /* Complexity Weight of 1 */ - UWord32 Mpy_32_32_uu; /* Complexity Weight of 2 */ - UWord32 Mpy_32_16_uu; /* Complexity Weight of 2 */ - UWord32 norm_ul_float; /* Complexity Weight of 1 */ - UWord32 UL_deposit_l; /* Complexity Weight of 1 */ -#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ - -#ifdef CONTROL_CODE_OPS - UWord32 LT_16; /* Complexity Weight of 1 */ - UWord32 GT_16; /* Complexity Weight of 1 */ - UWord32 LE_16; /* Complexity Weight of 1 */ - UWord32 GE_16; /* Complexity Weight of 1 */ - UWord32 EQ_16; /* Complexity Weight of 1 */ - UWord32 NE_16; /* Complexity Weight of 1 */ - UWord32 LT_32; /* Complexity Weight of 1 */ - UWord32 GT_32; /* Complexity Weight of 1 */ - UWord32 LE_32; /* Complexity Weight of 1 */ - UWord32 GE_32; /* Complexity Weight of 1 */ - UWord32 EQ_32; /* Complexity Weight of 1 */ - UWord32 NE_32; /* Complexity Weight of 1 */ - UWord32 LT_64; /* Complexity Weight of 1 */ - UWord32 GT_64; /* Complexity Weight of 1 */ - UWord32 LE_64; /* Complexity Weight of 1 */ - UWord32 GE_64; /* Complexity Weight of 1 */ - UWord32 EQ_64; /* Complexity Weight of 1 */ - UWord32 NE_64; /* Complexity Weight of 1 */ - -#endif /* #ifdef CONTROL_CODE_OPS */ -} BASIC_OP; - - -Word32 TotalWeightedOperation( void ); -Word32 DeltaWeightedOperation( void ); void generic_WMOPS_output( Word16 notPrintWorstWorstCase, char *test_file_name ); @@ -487,56 +186,6 @@ void WMOPS_output_all_std( Word16 dtx_mode ); * free all allocated counter memory */ void WMOPS_destroy( void ); -#if 0 -/* - * Example of how count.h could be used. - * - * In the example below it is assumed that the init_OBJECT functions - * does not use any calls to counter.h or basic_op.h. If this is the case - * a call to the function Reset_WMOPS_counter() must be done after each call - * to init_OBJECT if these operations is not to be included in the statistics. - */ - -int main () { - int spe1Id, spe2Id, cheId; - - /* initiate counters and objects */ - spe1Id = getCounterId ("Spe 5k8"); - setCounter (spe1Id); - Init_WMOPS_counter (); - init_spe1 ( ...); - - spe2Id = getCounterId ("Spe 12k2"); - setCounter (spe2Id); - Init_WMOPS_counter (); - init_spe2 ( ...); - - cheId = getCounterId ("Channel encoder"); - setCounter (cheId); - Init_WMOPS_counter (); - init_che ( ...); - ... while (data) { - test (); /* Note this call to test(); */ - if (useSpe1) - setCounter (spe1Id); - else - setCounter (spe2Id); - Reset_WMOPS_counter (); - speEncode ( ...); - WMOPS_output (0); /* Normal routine for displaying WMOPS info */ - - setCounter (cheId); - Reset_WMOPS_counter (); - preChannelInter ( ...); - fwc (); /* Note the call to fwc() for each part */ - convolve ( ...); - fwc (); /* of the channel encoder. */ - interleave ( ...); - fwc (); - WMOPS_output (0); /* Normal routine for displaying WMOPS info */ - } -} -#endif /* #if 0 */ /* jdr 20120117: add FLC similar functions */ /* mul 20130729: set BASOP_COUNT_SUBROUTINES to count on a per-BASOP_sub_start()/BASOP_sub_end() base; @@ -545,21 +194,6 @@ int main () { void BASOP_push_wmops( const char *label ); Word32 BASOP_pop_wmops( void ); -#define BASOP_init \ - { \ - setFrameRate( 32000, 640 ); \ - Init_WMOPS_counter(); /* 20ms frames */ \ - } -#define BASOP_end \ - { \ - WMOPS_output_all_std( 0 ); \ - } -/*#define BASOP_end { WMOPS_output_all(0); }*/ -#define BASOP_end_noprint \ - { \ - WMOPS_destroy(); \ - } - #ifdef BASOP_COUNT_SUBROUTINES #define BASOP_sub_start( label ) \ { \ diff --git a/lib_com/enh1632.c b/lib_com/enh1632.c index 1e6c41a0e..d4e9f9b59 100644 --- a/lib_com/enh1632.c +++ b/lib_com/enh1632.c @@ -59,7 +59,6 @@ #define WMC_TOOL_SKIP #ifdef WMOPS -extern BASIC_OP multiCounter[MAXCOUNTERS]; extern int currCounter; #endif /* ifdef WMOPS */ @@ -382,21 +381,13 @@ Word32 L_lshr( Word32 L_var1, Word16 var2 ) * the range : 0xffff 8000 <= var_out <= 0x0000 7fff. * *****************************************************************************/ -#ifdef BASOP_NOGLOB Word16 shl_ro( Word16 var1, Word16 var2, Flag *Overflow ) -#else -Word16 shl_r( Word16 var1, Word16 var2 ) -#endif { Word16 var_out; if ( var2 >= 0 ) { -#ifdef BASOP_NOGLOB var_out = shl_o( var1, var2, Overflow ); -#else - var_out = shl( var1, var2 ); -#endif #ifdef WMOPS multiCounter[currCounter].shl--; #endif /* ifdef WMOPS */ @@ -404,11 +395,7 @@ Word16 shl_r( Word16 var1, Word16 var2 ) else { var2 = -var2; -#ifdef BASOP_NOGLOB var_out = shr_ro( var1, var2, Overflow ); -#else - var_out = shr_r( var1, var2 ); -#endif #ifdef WMOPS multiCounter[currCounter].shr_r--; #endif /* ifdef WMOPS */ @@ -420,12 +407,10 @@ Word16 shl_r( Word16 var1, Word16 var2 ) return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 shl_r( Word16 var1, Word16 var2 ) { return shl_ro( var1, var2, NULL ); } -#endif /***************************************************************************** * * Function Name : L_shl_r @@ -690,3 +675,4 @@ Word32 L_rotl( Word32 L_var1, Word16 var2, Word16 *var3 ) #undef WMC_TOOL_SKIP /* end of file */ +/*AddedByWMC_Tool*/ int PROM_Size_Func( enh1632 ) { return 39; } diff --git a/lib_com/enh1632.h b/lib_com/enh1632.h index 1477c6c80..755523a40 100644 --- a/lib_com/enh1632.h +++ b/lib_com/enh1632.h @@ -36,21 +36,12 @@ #include "stl.h" -#ifdef WMOPS -#include "count.h" -extern BASIC_OP multiCounter[MAXCOUNTERS]; -extern int currCounter; -#endif /* ifdef WMOPS */ - - /***************************************************************************** * * Prototypes for enhanced 16/32 bit arithmetic operators * *****************************************************************************/ -#ifdef BASOP_NOGLOB Word16 shl_ro( Word16 var1, Word16 var2, Flag *Overflow ); -#endif Word16 shl_r( Word16 var1, Word16 var2 ); Word32 L_shl_r( Word32 L_var1, Word16 var2 ); diff --git a/lib_com/enh32.c b/lib_com/enh32.c index d2466ce64..7706935b2 100644 --- a/lib_com/enh32.c +++ b/lib_com/enh32.c @@ -21,15 +21,11 @@ *****************************************************************************/ #include #include +#include "stl.h" #include "enh32.h" #define WMC_TOOL_SKIP -#ifdef WMOPS -extern BASIC_OP multiCounter[MAXCOUNTERS]; -extern int currCounter; -#endif /* if WMOPS */ - #ifdef ENH_32_BIT_OPERATOR /***************************************************************************** * @@ -81,11 +77,7 @@ Word32 Mpy_32_32( Word32 L_var1, Word32 L_var2 ) #endif L64_var1 = ( (Word64) L_var1 * L_var2 ); -#ifdef BASOP_NOGLOB L64_var1 = W_shl_o( L64_var1, 1, &Overflow ); -#else /* BASOP_NOGLOB */ - L64_var1 = W_shl( L64_var1, 1 ); -#endif /* BASOP_NOGLOB */ L_var_out = W_extract_h( L64_var1 ); #ifdef WMOPS multiCounter[currCounter].Mpy_32_32++; @@ -119,11 +111,7 @@ Word32 Madd_32_16( Word32 L_var3, Word32 L_var1, Word16 var2 ) #endif L_var_out = Mpy_32_16_1( L_var1, var2 ); -#ifdef BASOP_NOGLOB L_var_out = L_add_o( L_var3, L_var_out, &Overflow ); -#else /* BASOP_NOGLOB */ - L_var_out = L_add( L_var3, L_var_out ); -#endif /* BASOP_NOGLOB */ #ifdef WMOPS multiCounter[currCounter].Mpy_32_16_1--; @@ -156,11 +144,7 @@ Word32 Msub_32_16( Word32 L_var3, Word32 L_var1, Word16 var2 ) #endif L_var_out = Mpy_32_16_1( L_var1, var2 ); -#ifdef BASOP_NOGLOB L_var_out = L_sub_o( L_var3, L_var_out, &Overflow ); -#else /* BASOP_NOGLOB */ - L_var_out = L_sub( L_var3, L_var_out ); -#endif #ifdef WMOPS multiCounter[currCounter].Mpy_32_16_1--; @@ -249,3 +233,4 @@ Word32 Msub_32_32_r( Word32 L_var3, Word32 L_var1, Word32 L_var2 ) #undef WMC_TOOL_SKIP /* end of file */ +/*AddedByWMC_Tool*/ int PROM_Size_Func( enh32 ) { return 18; } diff --git a/lib_com/enh40.c b/lib_com/enh40.c index 929e3a950..acd3db0d2 100644 --- a/lib_com/enh40.c +++ b/lib_com/enh40.c @@ -96,9 +96,7 @@ #include #include #include "stl.h" -#ifdef BASOP_NOGLOB #include -#endif /* BASOP_NOGLOB */ #define WMC_TOOL_SKIP @@ -160,11 +158,7 @@ * the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************/ -#ifndef BASOP_NOGLOB -Word40 L40_shl( Word40 L40_var1, Word16 var2 ) -#else /* BASOP_NOGLOB */ Word40 L40_shl_o( Word40 L40_var1, Word16 var2, Flag *Overflow ) -#endif /* BASOP_NOGLOB */ { Word40 L40_var_out; @@ -194,27 +188,15 @@ Word40 L40_shl_o( Word40 L40_var1, Word16 var2, Flag *Overflow ) if ( L40_var_out > 0x003fffffffffLL ) #endif { -#ifndef BASOP_NOGLOB - Overflow = 1; - exit( 1 ); - /* L40_var_out = L40_OVERFLOW_OCCURED( L40_var_out); */ -#else /* BASOP_NOGLOB */ *Overflow = 1; L40_var_out = MAX_40; -#endif /* BASOP_NOGLOB */ break; } else if ( L40_var_out < L40_constant ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - exit( 2 ); - /* L40_var_out = L40_UNDERFLOW_OCCURED( L40_var_out); */ -#else /* BASOP_NOGLOB */ *Overflow = 1; L40_var_out = MIN_40; -#endif /* BASOP_NOGLOB */ break; } @@ -234,7 +216,6 @@ Word40 L40_shl_o( Word40 L40_var1, Word16 var2, Flag *Overflow ) return ( L40_var_out ); } -#ifdef BASOP_NOGLOB Word40 L40_shl( Word40 L40_var1, Word16 var2 ) { @@ -293,7 +274,6 @@ Word40 L40_shl( Word40 L40_var1, Word16 var2 ) return ( L40_var_out ); } -#endif /* BASOP_NOGLOB */ /***************************************************************************** * @@ -422,7 +402,6 @@ Word40 L40_negate( Word40 L40_var1 ) * the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************/ -#ifdef BASOP_NOGLOB Word40 L40_add_o( Word40 L40_var1, Word40 L40_var2, Flag *Overflow ) { @@ -465,7 +444,6 @@ Word40 L40_add_o( Word40 L40_var1, Word40 L40_var2, Flag *Overflow ) return ( L40_var_out ); } -#endif /* BASOP_NOGLOB */ Word40 L40_add( Word40 L40_var1, Word40 L40_var2 ) { Word40 L40_var_out; @@ -475,48 +453,24 @@ Word40 L40_add( Word40 L40_var1, Word40 L40_var2 ) #if defined( _MSC_VER ) && ( _MSC_VER <= 1200 ) if ( ( ( ( L40_var1 & 0x8000000000 ) >> 39 ) != 0 ) && ( ( ( L40_var2 & 0x8000000000 ) >> 39 ) != 0 ) && ( ( ( L40_var_out & 0x8000000000 ) >> 39 ) == 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - exit( 2 ); - /* L40_var_out = L40_UNDERFLOW_OCCURED( L40_var_out); */ -#else /* BASOP_NOGLOB */ assert( 0 ); L40_var_out = MIN_40; -#endif /* BASOP_NOGLOB */ } else if ( ( ( ( L40_var1 & 0x8000000000 ) >> 39 ) == 0 ) && ( ( ( L40_var2 & 0x8000000000 ) >> 39 ) == 0 ) && ( ( ( L40_var_out & 0x8000000000 ) >> 39 ) != 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - exit( 1 ); - /* L40_var_out = L40_OVERFLOW_OCCURED( L40_var_out); */ -#else /* BASOP_NOGLOB */ assert( 0 ); L40_var_out = MAX_40; -#endif /* BASOP_NOGLOB */ } #else if ( ( ( ( L40_var1 & 0x8000000000LL ) >> 39 ) != 0 ) && ( ( ( L40_var2 & 0x8000000000LL ) >> 39 ) != 0 ) && ( ( ( L40_var_out & 0x8000000000LL ) >> 39 ) == 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - exit( 2 ); - /* L40_var_out = L40_UNDERFLOW_OCCURED( L40_var_out); */ -#else /* BASOP_NOGLOB */ assert( 0 ); L40_var_out = MIN_40; -#endif /* BASOP_NOGLOB */ } else if ( ( ( ( L40_var1 & 0x8000000000LL ) >> 39 ) == 0 ) && ( ( ( L40_var2 & 0x8000000000LL ) >> 39 ) == 0 ) && ( ( ( L40_var_out & 0x8000000000LL ) >> 39 ) != 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - exit( 1 ); - /* L40_var_out = L40_OVERFLOW_OCCURED( L40_var_out); */ -#else /* BASOP_NOGLOB */ assert( 0 ); L40_var_out = MAX_40; -#endif /* BASOP_NOGLOB */ } #endif @@ -561,11 +515,7 @@ Word40 L40_add( Word40 L40_var1, Word40 L40_var2 ) * the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************/ -#ifndef BASOP_NOGLOB -Word40 L40_sub( Word40 L40_var1, Word40 L40_var2 ) -#else /* BASOP_NOGLOB */ Word40 L40_sub_o( Word40 L40_var1, Word40 L40_var2, Flag *Overflow ) -#endif /* BASOP_NOGLOB */ { Word40 L40_var_out; @@ -574,48 +524,24 @@ Word40 L40_sub_o( Word40 L40_var1, Word40 L40_var2, Flag *Overflow ) #if defined( _MSC_VER ) && ( _MSC_VER <= 1200 ) if ( ( ( ( L40_var1 & 0x8000000000 ) >> 39 ) != 0 ) && ( ( ( L40_var2 & 0x8000000000 ) >> 39 ) == 0 ) && ( ( ( L40_var_out & 0x8000000000 ) >> 39 ) == 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - exit( 2 ); - /* L40_var_out = L40_UNDERFLOW_OCCURED( L40_var_out); */ -#else /* BASOP_NOGLOB */ *Overflow = 1; L40_var_out = MIN_40; -#endif /* BASOP_NOGLOB */ } else if ( ( ( ( L40_var1 & 0x8000000000 ) >> 39 ) == 0 ) && ( ( ( L40_var2 & 0x8000000000 ) >> 39 ) != 0 ) && ( ( ( L40_var_out & 0x8000000000 ) >> 39 ) != 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - exit( 1 ); - /* L40_var_out = L40_OVERFLOW_OCCURED( L40_var_out); */ -#else /* BASOP_NOGLOB */ *Overflow = 1; L40_var_out = MAX_40; -#endif /* BASOP_NOGLOB */ } #else if ( ( ( ( L40_var1 & 0x8000000000LL ) >> 39 ) != 0 ) && ( ( ( L40_var2 & 0x8000000000LL ) >> 39 ) == 0 ) && ( ( ( L40_var_out & 0x8000000000LL ) >> 39 ) == 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - exit( 2 ); - /* L40_var_out = L40_UNDERFLOW_OCCURED( L40_var_out); */ -#else /* BASOP_NOGLOB */ *Overflow = 1; L40_var_out = MIN_40; -#endif /* BASOP_NOGLOB */ } else if ( ( ( ( L40_var1 & 0x8000000000LL ) >> 39 ) == 0 ) && ( ( ( L40_var2 & 0x8000000000LL ) >> 39 ) != 0 ) && ( ( ( L40_var_out & 0x8000000000LL ) >> 39 ) != 0 ) ) { -#ifndef BASOP_NOGLOB - Overflow = 1; - exit( 1 ); - /* L40_var_out = L40_OVERFLOW_OCCURED( L40_var_out); */ -#else /* BASOP_NOGLOB */ *Overflow = 1; L40_var_out = MAX_40; -#endif /* BASOP_NOGLOB */ } #endif @@ -629,7 +555,6 @@ Word40 L40_sub_o( Word40 L40_var1, Word40 L40_var2, Flag *Overflow ) return ( L40_var_out ); } -#ifdef BASOP_NOGLOB Word40 L40_sub( Word40 L40_var1, Word40 L40_var2 ) { Word40 L40_var_out; @@ -669,7 +594,6 @@ Word40 L40_sub( Word40 L40_var1, Word40 L40_var2 ) return ( L40_var_out ); } -#endif /* BASOP_NOGLOB */ /***************************************************************************** * @@ -838,12 +762,8 @@ Word40 L40_min( Word40 L40_var1, Word40 L40_var2 ) * the range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. * *****************************************************************************/ -#ifndef BASOP_NOGLOB -Word32 L_saturate40( Word40 L40_var1 ) -#else /* BASOP_NOGLOB */ Word32 L_saturate40_o( Word40 L40_var1, Flag *Overflow ) -#endif /* BASOP_NOGLOB */ { Word32 L_var_out; @@ -853,21 +773,13 @@ Word32 L_saturate40_o( Word40 L40_var1, Flag *Overflow ) if ( L40_var1 < UNDER_L40_var2 ) { L40_var1 = UNDER_L40_var2; -#ifndef BASOP_NOGLOB - Overflow = 1; -#else /* BASOP_NOGLOB */ *Overflow = 1; -#endif /* BASOP_NOGLOB */ } if ( L40_var1 > OVER_L40_var2 ) { L40_var1 = OVER_L40_var2; -#ifndef BASOP_NOGLOB - Overflow = 1; -#else /* BASOP_NOGLOB */ *Overflow = 1; -#endif /* BASOP_NOGLOB */ } L_var_out = L_Extract40( L40_var1 ); @@ -882,7 +794,6 @@ Word32 L_saturate40_o( Word40 L40_var1, Flag *Overflow ) return ( L_var_out ); } -#ifdef BASOP_NOGLOB Word32 L_saturate40( Word40 L40_var1 ) { Word32 L_var_out; @@ -913,7 +824,6 @@ Word32 L_saturate40( Word40 L40_var1 ) return ( L_var_out ); } -#endif /* BASOP_NOGLOB */ /***************************************************************************** * @@ -1393,3 +1303,4 @@ Word40 L40_shl_r( Word40 L40_var1, Word16 var2 ) #undef WMC_TOOL_SKIP +/*AddedByWMC_Tool*/ int PROM_Size_Func( enh40 ) { return 110; } diff --git a/lib_com/enh40.h b/lib_com/enh40.h index ca78cb33e..ff1a86b92 100644 --- a/lib_com/enh40.h +++ b/lib_com/enh40.h @@ -56,10 +56,8 @@ #include "stl.h" -#if defined( BASOP_NOGLOB ) || defined( _MSC_VER ) #define MAX_40 ( 0x0000007fffffffff ) #define MIN_40 ( 0xffffff8000000000 ) -#endif #define L40_OVERFLOW_OCCURED( L40_var1 ) ( Overflow = 1, exit( 1 ), L40_var1 ) #define L40_UNDERFLOW_OCCURED( L40_var1 ) ( Overflow = 1, exit( 2 ), L40_var1 ) @@ -111,7 +109,6 @@ Word40 L40_max( Word40 L40_var1, Word40 L40_var2 ); Word40 L40_min( Word40 L40_var1, Word40 L40_var2 ); Word32 L_saturate40( Word40 L40_var1 ); Word16 norm_L40( Word40 L40_var1 ); -#ifdef BASOP_NOGLOB /* * Overflowing operators */ @@ -119,7 +116,6 @@ Word40 L40_shl_o( Word40 L40_var1, Word16 var2, Flag *Overflow ); Word40 L40_add_o( Word40 L40_var1, Word40 L40_var2, Flag *Overflow ); Word40 L40_sub_o( Word40 L40_var1, Word40 L40_var2, Flag *Overflow ); Word32 L_saturate40_o( Word40 L40_var1, Flag *Overflow ); -#endif /* BASOP_NOGLOB */ /*#ifdef _MSC_VER*/ static __inline Word40 L40_set( Word40 L40_var1 ) { diff --git a/lib_com/enh64.c b/lib_com/enh64.c index a5c0879c0..b6bf268a6 100644 --- a/lib_com/enh64.c +++ b/lib_com/enh64.c @@ -16,16 +16,11 @@ *****************************************************************************/ #include #include +#include "stl.h" #include "enh64.h" #define WMC_TOOL_SKIP -#ifdef WMOPS -extern BASIC_OP multiCounter[MAXCOUNTERS]; -extern int currCounter; -#endif /* if WMOPS */ - - /***************************************************************************** * * Local Functions @@ -167,11 +162,7 @@ Word64 W_sub_nosat( Word64 L64_var1, Word64 L64_var2 ) | range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word64 W_shl_o( Word64 L64_var1, Word16 var2, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word64 W_shl( Word64 L64_var1, Word16 var2 ) -#endif /* BASOP_NOGLOB */ { Word64 L64_var_out = 0LL; @@ -189,11 +180,7 @@ Word64 W_shl( Word64 L64_var1, Word16 var2 ) { if ( L64_var1 > (Word64) 0X3fffffffffffffffLL ) { -#ifdef BASOP_NOGLOB set_overflow( Overflow ); -#else /* BASOP_NOGLOB */ - Overflow = 1; -#endif /* BASOP_NOGLOB */ L64_var_out = (Word64) 0X7fffffffffffffffLL; break; } @@ -201,11 +188,7 @@ Word64 W_shl( Word64 L64_var1, Word16 var2 ) { if ( L64_var1 < (Word64) 0xc000000000000000LL ) { -#ifdef BASOP_NOGLOB set_overflow( Overflow ); -#else /* BASOP_NOGLOB */ - Overflow = 1; -#endif /* BASOP_NOGLOB */ L64_var_out = (Word64) 0x8000000000000000LL; break; } @@ -223,12 +206,10 @@ Word64 W_shl( Word64 L64_var1, Word16 var2 ) return ( L64_var_out ); } -#ifdef BASOP_NOGLOB Word64 W_shl( Word64 L64_var1, Word16 var2 ) { return W_shl_o( L64_var1, var2, NULL ); } -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ @@ -1191,11 +1172,7 @@ Word32 W_shl_sat_l( Word64 L64_var, Word16 n ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |__________________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word32 W_round48_L_o( Word64 L64_var1, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word32 W_round48_L( Word64 L64_var1 ) -#endif /* BASOP_NOGLOB */ { Word64 L64_var_out; Word32 L_result; @@ -1213,11 +1190,7 @@ Word32 W_round48_L( Word64 L64_var1 ) if ( ( L64_var_out ^ L64_var1 ) & L64_MIN ) { L64_var_out = ( L64_var1 < 0 ) ? L64_MIN : L64_MAX; -#ifdef BASOP_NOGLOB set_overflow( Overflow ); -#else /* BASOP_NOGLOB */ - Overflow = 1; -#endif /* BASOP_NOGLOB */ } } L_result = W_extract_h( L64_var_out ); @@ -1230,12 +1203,10 @@ Word32 W_round48_L( Word64 L64_var1 ) return ( L_result ); } -#ifdef BASOP_NOGLOB Word32 W_round48_L( Word64 L64_var1 ) { return W_round48_L_o( L64_var1, NULL ); } -#endif /* BASOP_NOGLOB */ /*__________________________________________________________________________________ | | @@ -1264,11 +1235,7 @@ Word32 W_round48_L( Word64 L64_var1 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |__________________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word16 W_round32_s_o( Word64 L64_var1, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word16 W_round32_s( Word64 L64_var1 ) -#endif /* BASOP_NOGLOB */ { Word64 L64_var_out; Word32 L_var; @@ -1287,11 +1254,7 @@ Word16 W_round32_s( Word64 L64_var1 ) if ( ( L64_var_out ^ L64_var1 ) & L64_MIN ) { L64_var_out = ( L64_var1 < 0 ) ? L64_MIN : L64_MAX; -#ifdef BASOP_NOGLOB set_overflow( Overflow ); -#else /* BASOP_NOGLOB */ - Overflow = 1; -#endif /* BASOP_NOGLOB */ } } L_var = W_extract_h( L64_var_out ); @@ -1306,12 +1269,10 @@ Word16 W_round32_s( Word64 L64_var1 ) return ( var_out ); } -#ifdef BASOP_NOGLOB Word16 W_round32_s( Word64 L64_var1 ) { return W_round32_s_o( L64_var1, NULL ); } -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -1404,11 +1365,7 @@ Word16 W_norm( Word64 L64_var1 ) | range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | |_______________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word64 W_add_o( Word64 L64_var1, Word64 L64_var2, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word64 W_add( Word64 L64_var1, Word64 L64_var2 ) -#endif /* BASOP_NOGLOB */ { Word64 L64_var_out; @@ -1419,11 +1376,7 @@ Word64 W_add( Word64 L64_var1, Word64 L64_var2 ) if ( ( L64_var_out ^ L64_var1 ) & MIN_64 ) { L64_var_out = ( L64_var1 < 0 ) ? MIN_64 : MAX_64; -#ifdef BASOP_NOGLOB set_overflow( Overflow ); -#else /* BASOP_NOGLOB */ - Overflow = 1; -#endif /* BASOP_NOGLOB */ } } @@ -1433,12 +1386,10 @@ Word64 W_add( Word64 L64_var1, Word64 L64_var2 ) return L64_var_out; } -#ifdef BASOP_NOGLOB Word64 W_add( Word64 L64_var1, Word64 L64_var2 ) { return W_add_o( L64_var1, L64_var2, NULL ); } -#endif /* BASOP_NOGLOB */ /*______________________________________________________________________________ | | @@ -1471,11 +1422,7 @@ Word64 W_add( Word64 L64_var1, Word64 L64_var2 ) | range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | |_______________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word64 W_sub_o( Word64 L64_var1, Word64 L64_var2, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word64 W_sub( Word64 L64_var1, Word64 L64_var2 ) -#endif /* BASOP_NOGLOB */ { Word64 L64_var_out; @@ -1486,11 +1433,7 @@ Word64 W_sub( Word64 L64_var1, Word64 L64_var2 ) if ( ( L64_var_out ^ L64_var1 ) & MIN_64 ) { L64_var_out = ( L64_var1 < 0 ) ? MIN_64 : MAX_64; -#ifdef BASOP_NOGLOB set_overflow( Overflow ); -#else /* BASOP_NOGLOB */ - Overflow = 1; -#endif /* BASOP_NOGLOB */ } } @@ -1500,12 +1443,10 @@ Word64 W_sub( Word64 L64_var1, Word64 L64_var2 ) return L64_var_out; } -#ifdef BASOP_NOGLOB Word64 W_sub( Word64 L64_var1, Word64 L64_var2 ) { return W_sub_o( L64_var1, L64_var2, NULL ); } -#endif /* BASOP_NOGLOB */ /*______________________________________________________________________________ @@ -1535,22 +1476,14 @@ Word64 W_sub( Word64 L64_var1, Word64 L64_var2 ) | range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | |_______________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word64 W_neg_o( Word64 L64_var1, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word64 W_neg( Word64 L64_var1 ) -#endif /* BASOP_NOGLOB */ { Word64 L64_var_out; if ( L64_var1 == MIN_64 ) { L64_var_out = MAX_64; -#ifdef BASOP_NOGLOB set_overflow( Overflow ); -#else /* BASOP_NOGLOB */ - Overflow = 1; -#endif /* BASOP_NOGLOB */ } else { @@ -1564,12 +1497,10 @@ Word64 W_neg( Word64 L64_var1 ) return ( L64_var_out ); } -#ifdef BASOP_NOGLOB Word64 W_neg( Word64 L64_var1 ) { return W_neg_o( L64_var1, NULL ); } -#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ @@ -1599,22 +1530,14 @@ Word64 W_neg( Word64 L64_var1 ) | range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | |___________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word64 W_abs_o( Word64 L64_var1, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word64 W_abs( Word64 L64_var1 ) -#endif /* BASOP_NOGLOB */ { Word64 L64_var_out; if ( L64_var1 == MIN_64 ) { L64_var_out = MAX_64; -#ifdef BASOP_NOGLOB set_overflow( Overflow ); -#else /* BASOP_NOGLOB */ - Overflow = 1; -#endif /* BASOP_NOGLOB */ } else { @@ -1635,12 +1558,10 @@ Word64 W_abs( Word64 L64_var1 ) return ( L64_var_out ); } -#ifdef BASOP_NOGLOB Word64 W_abs( Word64 L64_var1 ) { return W_abs_o( L64_var1, NULL ); } -#endif /* BASOP_NOGLOB */ /*_________________________________________________________________________________________________ | | @@ -1674,22 +1595,14 @@ Word64 W_abs( Word64 L64_var1 ) | range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | |_________________________________________________________________________________________________| */ -#ifdef BASOP_NOGLOB Word64 W_mult_32_32_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) -#else /* BASOP_NOGLOB */ -Word64 W_mult_32_32( Word32 L_var1, Word32 L_var2 ) -#endif /* BASOP_NOGLOB */ { Word64 L64_var_out; if ( ( L_var1 == MIN_32 ) && ( L_var2 == MIN_32 ) ) { L64_var_out = MAX_64; -#ifdef BASOP_NOGLOB set_overflow( Overflow ); -#else /* BASOP_NOGLOB */ - Overflow = 1; -#endif /* BASOP_NOGLOB */ } else { @@ -1702,12 +1615,10 @@ Word64 W_mult_32_32( Word32 L_var1, Word32 L_var2 ) return L64_var_out; } -#ifdef BASOP_NOGLOB Word64 W_mult_32_32( Word32 L_var1, Word32 L_var2 ) { return W_mult_32_32_o( L_var1, L_var2, NULL ); } -#endif /* BASOP_NOGLOB */ /*_________________________________________________________________________________________________ | | @@ -1909,3 +1820,4 @@ Word32 W_round64_L( Word64 L64_var1 ) #undef WMC_TOOL_SKIP /* end of file */ +/*AddedByWMC_Tool*/ int PROM_Size_Func( enh64 ) { return 74; } diff --git a/lib_com/enh64.h b/lib_com/enh64.h index 8aed870a6..c3896bb0d 100644 --- a/lib_com/enh64.h +++ b/lib_com/enh64.h @@ -65,7 +65,6 @@ UWord64 W_lshl( UWord64 L64_var1, Word16 var2 ); UWord64 W_lshr( UWord64 L64_var1, Word16 var2 ); Word32 W_round64_L( Word64 L64_var1 ); -#ifdef BASOP_NOGLOB /* * Overflowing operators */ @@ -77,7 +76,6 @@ Word64 W_sub_o( Word64 L64_var1, Word64 L64_var2, Flag *Overflow ); Word64 W_neg_o( Word64 L64_var1, Flag *Overflow ); Word64 W_abs_o( Word64 L64_var1, Flag *Overflow ); Word64 W_mult_32_32_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ); -#endif /* BASOP_NOGLOB */ #endif /* #ifdef ENH_64_BIT_OPERATOR */ diff --git a/lib_com/enhUL32.c b/lib_com/enhUL32.c index 0fe4c304b..cc3f8065a 100644 --- a/lib_com/enhUL32.c +++ b/lib_com/enhUL32.c @@ -29,12 +29,6 @@ #define WMC_TOOL_SKIP -#ifdef WMOPS -extern BASIC_OP multiCounter[MAXCOUNTERS]; -extern int currCounter; -#endif /* if WMOPS */ - - /***************************************************************************** * * Constants and Globals @@ -69,59 +63,6 @@ UWord32 UL_deposit_l( UWord16 uvar ) #endif return ( UL_result ); } -#if 0 -/*_____________________________________________________________________________ - | | - | Function Name : norm_ul_float | - | | - | Purpose : | - | | - | Produces the number of left shifts needed to normalize the 32 bit varia- | - | ble UL_var1 for positive values on the interval with minimum of | - | 0 and maximum of 0xffffffff, ; in order to normalize the | - | result, the following operation must be done : | - | | - | norm_UL_var1 = UL_lshl(UL_var1, norm_ul_float(UL_var1)). | - | | - | Complexity weight : 1 | - | | - | Inputs : | - | | - | UL_var1 | - | 32 bit long unsigned integer (UWord32) whose value falls in the | - | range : 0x0000 0000 <= var1 <= 0xffff ffff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | var_out | - | 16 bit short signed integer (Word16) whose value falls in the | - | range : 0x0000 0000 <= var_out <= 0x0000 001f. (0..31d) | - |_____________________________________________________________________________| -*/ -Word16 norm_ul_float (UWord32 UL_var1) { - Word16 var_out; - - if (UL_var1 == 0) { - var_out = 0; - } - else { - /* simply test shift up until highest bit is set */ - for (var_out = 0; UL_var1 < (UWord32) 0x80000000U; var_out++) { - UL_var1 <<= 1; - } - } - -#ifdef WMOPS - multiCounter[currCounter].norm_ul_float++; -#endif - - return (var_out); -} -#endif /*___________________________________________________________________________ | | | Function Name : UL_addNs | @@ -422,3 +363,4 @@ UWord32 UL_addNsD( UWord32 UL_var1, UWord32 UL_var2 ) #undef WMC_TOOL_SKIP /* end of file */ +/*AddedByWMC_Tool*/ int PROM_Size_Func( enhUL32 ) { return 26; } diff --git a/lib_com/enhUL32.h b/lib_com/enhUL32.h index 39a79d700..284d84a24 100644 --- a/lib_com/enhUL32.h +++ b/lib_com/enhUL32.h @@ -24,11 +24,6 @@ #define UWord64 unsigned long long /* for local use inside UL_Mpy_32_* */ #endif -#ifdef WMOPS -#include "count.h" -extern BASIC_OP multiCounter[MAXCOUNTERS]; /* existing signed counters are reused for unsigedn operators */ -extern int currCounter; -#endif /* if WMOPS */ /***************************************************************************** * diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 4f3aa5ae1..4898e9e00 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -36,6 +36,7 @@ #include #include "options.h" #include "cnst.h" +#include "typedef.h" /* clang-format off */ diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 93ea0528d..0fd62f006 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -31,12 +31,13 @@ *******************************************************************************************************/ #include -#include "options.h" +#include #include +#include "options.h" #include "prot.h" #include "ivas_prot.h" +#include "rom_com.h" #include "ivas_rom_com.h" -#include #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "prot_fx.h" diff --git a/lib_com/move.h b/lib_com/move.h index a6f5b353e..5c325fb1d 100644 --- a/lib_com/move.h +++ b/lib_com/move.h @@ -36,13 +36,6 @@ #ifndef _MOVE_H #define _MOVE_H -#include "stl.h" -/* BASOP -> FLC brigde: data move counting */ - -#ifdef WMOPS -extern BASIC_OP multiCounter[MAXCOUNTERS]; -extern int currCounter; -#endif /* ifdef WMOPS */ static __inline void move16( void ) { diff --git a/lib_com/options.h b/lib_com/options.h index 095c183e8..ef08dee7c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -54,7 +54,7 @@ #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 MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */ @@ -62,6 +62,15 @@ /* #################### End DEBUGGING switches ############################ */ +#define ENH_U_32_BIT_OPERATOR +#define COMPLEX_OPERATOR +#define CONTROL_CODE_OPS +#define ENH_32_BIT_OPERATOR +#define ENH_64_BIT_OPERATOR +#if !defined BASOP_NOGLOB_DEV_USE_GLOBALS +#define BASOP_NOGLOB_DECLARE_LOCAL +#endif + /* ################### Start FIXES switches ########################### */ #define NON_BE_FIX_1048_THRESHOLD_COH_BASOP /* Nokia: Fix 1048 replace comparison with 0 with comparison to threshold, to align with BASOP*/ diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index 833ae46b6..3deeab63d 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -1275,6 +1275,7 @@ extern const UWord32 intLimCDivInvDQ31[68]; // Q0 extern const UWord8 obtainEnergyQuantizerDensity_f[57]; // Q0 extern const Word16 lim_neg_inv_tbl_fx[11]; // Q0 extern const Word16 fg_inv_tbl_fx[13]; // Q0 +extern const Word16 Idx2Freq_Tbl[]; /* functions and tables for pvq_indexing */ extern const UWord32 exactdivodd[ODD_DIV_SIZE]; // Q0 diff --git a/lib_com/rom_com_fx.h b/lib_com/rom_com_fx.h index 4ab4bf819..5c30ad5da 100644 --- a/lib_com/rom_com_fx.h +++ b/lib_com/rom_com_fx.h @@ -40,6 +40,9 @@ #ifndef ROM_COM_FX_H #define ROM_COM_FX_H + +#include "typedef.h" + /*------------------------------------------------------------------------------* * FFT transform *------------------------------------------------------------------------------*/ diff --git a/lib_com/stl.h b/lib_com/stl.h index 77e55b866..6643f5948 100644 --- a/lib_com/stl.h +++ b/lib_com/stl.h @@ -57,23 +57,11 @@ #ifndef _STL_H #define _STL_H -#define ENH_U_32_BIT_OPERATOR -#define COMPLEX_OPERATOR -#define CONTROL_CODE_OPS -#define ENH_32_BIT_OPERATOR -#define ENH_64_BIT_OPERATOR -#define BASOP_NOGLOB -#if defined BASOP_NOGLOB && !defined BASOP_NOGLOB_DEV_USE_GLOBALS -#define BASOP_NOGLOB_DECLARE_LOCAL -#endif - #include "options.h" /* note: needed until BASOP_NOGLOB is accepted */ #include "typedef.h" #include "basop32.h" -#include "count.h" #include "wmc_auto.h" #include "move.h" -#include "control.h" #include "oper_32b.h" #include "enh1632.h" #include "enh40.h" diff --git a/lib_com/vlpc_2st_com_fx.c b/lib_com/vlpc_2st_com_fx.c index 3f06d3508..3fcdf144d 100644 --- a/lib_com/vlpc_2st_com_fx.c +++ b/lib_com/vlpc_2st_com_fx.c @@ -6,7 +6,6 @@ #include "options.h" #include "cnst.h" #include "prot_fx.h" -#include "control.h" #include "basop_util.h" diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index e37fecf2e..8d038b7b3 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -28,13 +28,15 @@ #include "options.h" #include "wmc_auto.h" - #include "typedef.h" #include "count.h" - #define WMC_TOOL_SKIP /* Skip the instrumentation of this file, if invoked by accident */ +#ifndef WMOPS +int cntr_push_pop = 0; /* global counter for checking balanced push_wmops()/pop_wmops() pairs when WMOPS is not activated */ +#endif + #ifdef WMOPS /*-------------------------------------------------------------------* * Complexity counting tool @@ -89,6 +91,13 @@ static long fnum_cnt_wc; static int *wmops_caller_stack = NULL, wmops_caller_stack_index, max_wmops_caller_stack_index = 0; static int *heap_allocation_call_tree = NULL, heap_allocation_call_tree_size = 0, heap_allocation_call_tree_max_size = 0; +int funcId_where_last_call_to_else_occurred; +long funcid_total_wmops_at_last_call_to_else; +int call_occurred = 1; +long LastWOper[MAXCOUNTERS]; /* !!!!! shall be replaced with wmops.LastWOper !!!!! */ +Word32 bc[MAXCOUNTERS][NbFuncMax], wc[MAXCOUNTERS][NbFuncMax]; +Word32 funcid[MAXCOUNTERS]; +BASIC_OP multiCounter[MAXCOUNTERS]; void reset_wmops( void ) { @@ -105,7 +114,7 @@ void reset_wmops( void ) start_cnt = 0.0; ops_cnt_wmc = 0.0; - /* allocate the list of wmops records */ + /* allocate the list of WMOPS records */ if ( wmops == NULL ) { wmops = (wmops_record *) malloc( max_num_wmops_records * sizeof( wmops_record ) ); @@ -117,7 +126,7 @@ void reset_wmops( void ) exit( -1 ); } - /* allocate the BASOP WMOPS counter */ + /* allocate the list of BASOP WMOPS records */ //if ( multiCounter == NULL ) //{ // multiCounter = (BASIC_OP *) malloc( max_num_wmops_records * sizeof( BASIC_OP ) ); @@ -129,7 +138,16 @@ void reset_wmops( void ) // exit( -1 ); //} - BASOP_init + //BASOP_init + + setFrameRate( 32000, 640 ); + Init_WMOPS_counter(); /* 20ms frames */ + + + for ( i = 0; i < MAX_HASH_TABLE_SIZE; i++ ) + { + lookup_table[i] = -1; + } /* initilize the list of WMOPS records */ /* initilize the BASOP WMOPS counters */ @@ -2128,6 +2146,381 @@ void print_mem( ROM_Size_Lookup_Table Const_Data_PROM_Table[] ) #endif /* WMOPS */ -#ifndef WMOPS -int cntr_push_pop = 0; /* global counter for checking balanced push_wmops()/pop_wmops() pairs when WMOPS is not activated */ +const BASIC_OP op_weight = { + 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, + 1, 1, 2, 2, 1, + 1, 1, 1, 2, 1, + + 1, 1, 1, 2, 1, + 1, 1, 18, 1, 1, + 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, + 2, 2, 2, 2, 1, + + 1, 1, 1, 1, 1, + 1, 1, 1, 2, + 1, 2, 2, 2, 1, + 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 3, + 3, 3, 3, 1, 1, + 1, 1, 1, 1, 1, + 1, 1, 1, 3, 2, + 2, 6, 3, 3, 2, + + 1, 32, 1 + +/* New complex basops */ +#ifdef COMPLEX_OPERATOR + , + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1 + + , + 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1 + +#endif /* #ifdef COMPLEX_OPERATOR */ + +#ifdef ENH_64_BIT_OPERATOR + /* Weights of new 64 bit basops */ + , + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 +#endif /* #ifdef ENH_64_BIT_OPERATOR */ + +#ifdef ENH_32_BIT_OPERATOR + , + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 +#endif /* #ifdef ENH_32_BIT_OPERATOR */ + +#ifdef ENH_U_32_BIT_OPERATOR + , + 1, 1, 1, 2, 2, 1, 1 +#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ + +#ifdef CONTROL_CODE_OPS + , + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 +#endif /* #ifdef CONTROL_CODE_OPS */ +}; + +#ifdef CONTROL_CODE_OPS + +Flag LT_16( Word16 var1, Word16 var2 ) +{ + Flag F_ret = 0; + + if ( var1 < var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].LT_16++; +#endif + return F_ret; +} + +Flag GT_16( Word16 var1, Word16 var2 ) +{ + Flag F_ret = 0; + + if ( var1 > var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].GT_16++; +#endif + return F_ret; +} + +Flag LE_16( Word16 var1, Word16 var2 ) +{ + Flag F_ret = 0; + + if ( var1 <= var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].LE_16++; #endif + return F_ret; +} + +Flag GE_16( Word16 var1, Word16 var2 ) +{ + Flag F_ret = 0; + + if ( var1 >= var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].GE_16++; +#endif + return F_ret; +} + +Flag EQ_16( Word16 var1, Word16 var2 ) +{ + Flag F_ret = 0; + + if ( var1 == var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].EQ_16++; +#endif + return F_ret; +} + +Flag NE_16( Word16 var1, Word16 var2 ) +{ + Flag F_ret = 0; + + if ( var1 != var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].NE_16++; +#endif + return F_ret; +} + +Flag LT_32( Word32 L_var1, Word32 L_var2 ) +{ + Flag F_ret = 0; + + if ( L_var1 < L_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].LT_32++; +#endif + return F_ret; +} + +Flag GT_32( Word32 L_var1, Word32 L_var2 ) +{ + Flag F_ret = 0; + + if ( L_var1 > L_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].GT_32++; +#endif + return F_ret; +} + +Flag LE_32( Word32 L_var1, Word32 L_var2 ) +{ + Flag F_ret = 0; + + if ( L_var1 <= L_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].LE_32++; +#endif + return F_ret; +} + +Flag GE_32( Word32 L_var1, Word32 L_var2 ) +{ + Flag F_ret = 0; + + if ( L_var1 >= L_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].GE_32++; +#endif + return F_ret; +} + +Flag EQ_32( Word32 L_var1, Word32 L_var2 ) +{ + Flag F_ret = 0; + + if ( L_var1 == L_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].EQ_32++; +#endif + return F_ret; +} + +Flag NE_32( Word32 L_var1, Word32 L_var2 ) +{ + Flag F_ret = 0; + + if ( L_var1 != L_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].NE_32++; +#endif + return F_ret; +} + +Flag LT_64( Word64 L64_var1, Word64 L64_var2 ) +{ + Flag F_ret = 0; + + if ( L64_var1 < L64_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].LT_64++; +#endif + return F_ret; +} + +Flag GT_64( Word64 L64_var1, Word64 L64_var2 ) +{ + Flag F_ret = 0; + + if ( L64_var1 > L64_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].GT_64++; +#endif + return F_ret; +} + +Flag LE_64( Word64 L64_var1, Word64 L64_var2 ) +{ + Flag F_ret = 0; + + if ( L64_var1 <= L64_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].LE_64++; +#endif + return F_ret; +} +Flag GE_64( Word64 L64_var1, Word64 L64_var2 ) +{ + Flag F_ret = 0; + + if ( L64_var1 >= L64_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].GE_64++; +#endif + return F_ret; +} + +Flag EQ_64( Word64 L64_var1, Word64 L64_var2 ) +{ + Flag F_ret = 0; + + if ( L64_var1 == L64_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].EQ_64++; +#endif + return F_ret; +} +Flag NE_64( Word64 L64_var1, Word64 L64_var2 ) +{ + Flag F_ret = 0; + + if ( L64_var1 != L64_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].NE_64++; +#endif + return F_ret; +} + +#endif /* #ifdef CONTROL_CODE_OPS */ + +long TotalWeightedOperation() +{ +#ifdef WMOPS + Word32 i; + Word32 tot, *ptr; + const Word32 *ptr2; + + tot = 0; + ptr = (Word32 *) &multiCounter[currCounter]; + ptr2 = (const Word32 *) &op_weight; + for ( i = 0; i < ( Word16 )( sizeof( multiCounter[currCounter] ) / sizeof( Word32 ) ); i++ ) + { + tot += ( ( *ptr++ ) * ( *ptr2++ ) ); + } + + return ( (Word32) tot ); + +#else /* ifdef WMOPS */ + return 0; /* Dummy */ + +#endif /* ifdef WMOPS */ +} + +long DeltaWeightedOperation() +{ +#ifdef WMOPS + Word32 NewWOper, delta; + + NewWOper = TotalWeightedOperation(); + delta = NewWOper - LastWOper[currCounter]; + LastWOper[currCounter] = NewWOper; + return ( delta ); + +#else /* ifdef WMOPS */ + return 0; /* Dummy */ + +#endif /* ifdef WMOPS */ +} + +long fwc( void ) +{ +/* function worst case */ +#ifdef WMOPS + Word32 tot; + + tot = DeltaWeightedOperation(); + if ( tot > wc[currCounter][funcid[currCounter]] ) + wc[currCounter][funcid[currCounter]] = tot; + + if ( tot < bc[currCounter][funcid[currCounter]] ) + bc[currCounter][funcid[currCounter]] = tot; + + funcid[currCounter]++; + + /*make sure that BASOP_frame_update(); is put at the end of the main loop*/ + if ( funcid[currCounter] >= NbFuncMax ) + { + printf( "to many function calls\n" ); + } + assert( funcid[currCounter] < NbFuncMax ); + return ( tot ); +#else + return 0; +#endif /* ifdef WMOPS */ +} \ No newline at end of file diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index 5f5d6d975..7f3092370 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -24,6 +24,7 @@ #endif #include "options.h" +#include "typedef.h" /* To Prevent "warning: '$' in identifier or number" message under GCC */ #ifdef __GNUC__ @@ -32,6 +33,43 @@ #define FRAMES_PER_SECOND 50.0 #define PROM_INST_SIZE 32 /* number of bits of each program instruction when stored in the PROM memory (applied only when the user selects reporting in bytes) */ +#define MAXCOUNTERS ( 1024 ) /* may need to be increased if the total number of instrumented functions exceeds the limit */ +#define MAX_HASH_TABLE_SIZE 1000000 /* may need to be increased if there are too many conflicts in calc_hash() */ +#define MAX_CALLERS_SAVED_FRAMES 5 /* # of Frame for which WMOPS Complexity Details will be saved, 0 = Disabled */ +#define NbFuncMax ( 80000 ) /* may need to be increased if the total number of function calls exceeds the limit */ + +#define WMOPS_DATA_FILENAME "wmops_data.txt" +/* + * WMOPS_DATA_FILENAME is the macro defining the name of the file + * where the Weighted Million of Operations per Second (wMOPS) + * are appended, function group by function group. + */ + + +#define CODE_PROFILE_FILENAME "code_profile.txt" +/* + * CODE_PROFILE_FILENAME is the macro defining the name of the file + * where the Weighted Million of Operations per Second (WMOPS) + * are appended, basic operation by basic operation. + */ + + +#define WMOPS_TOTAL_FILENAME "wmops_total.txt" +/* + * WMOPS_TOTAL_FILENAME is the macro defining the name of the file + * where the Weighted Million of Operations per Second (WMOPS) + * are printed, globally for the application. + */ + +#define FRAME_RATE ( 0.0001F ) /* in this version frame_rate can be overwriten online by the new setFrameRate function */ +/* FRAME_RATE of 0.000025 is corresponding to 40ms frame.*/ +/* FRAME_RATE of 0.00005 is corresponding to 20ms frame.*/ +/* FRAME_RATE of 0.0001 is corresponding to 10ms frame.*/ +/* + * FRAME_RATE is the macro defining the calling rate of the + * application to benchmark. + */ + #ifdef WMOPS enum instructions @@ -995,18 +1033,6 @@ typedef enum USE_32BITS = 2 } Counting_Size; -#if ( defined( _WIN32 ) && ( _MSC_VER <= 1800 ) && ( _MSC_VER >= 1300 ) ) -#define __func__ __FUNCTION__ -#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ < 199901L -#if ( __GNUC__ >= 2 ) -#define __func__ __FUNCTION__ -#else -#define __func__ "" -#endif -#elif defined( __GNUC__ ) -#define __func__ __extension__ __FUNCTION__ -#endif - #ifdef WMOPS @@ -1024,11 +1050,11 @@ int push_stack( const char *filename, const char *fctname ); int pop_stack( const char *filename, const char *fctname ); #ifdef WMOPS_DETAIL -#define STACK_DEPTH_FCT_CALL ( push_wmops( __FUNCTION__ ), push_stack( __FILE__, __FUNCTION__ ) ) /* add push_wmops() in all function calls */ -#define STACK_DEPTH_FCT_RETURN ( pop_wmops(), pop_stack( __FILE__, __FUNCTION__ ) ) /* add pop_wmops() in all function returns */ +#define STACK_DEPTH_FCT_CALL ( push_wmops( __func__, "[WMC_AUTO]" ), push_stack( __FILE__, __func__ ) ) /* add push_wmops() in all function calls */ +#define STACK_DEPTH_FCT_RETURN ( pop_wmops(), pop_stack( __FILE__, __func__ ) ) /* add pop_wmops() in all function returns */ #else -#define STACK_DEPTH_FCT_CALL push_stack( __FILE__, __FUNCTION__ ) -#define STACK_DEPTH_FCT_RETURN pop_stack( __FILE__, __FUNCTION__ ) +#define STACK_DEPTH_FCT_CALL push_stack( __FILE__, __func__ ) +#define STACK_DEPTH_FCT_RETURN pop_stack( __FILE__, __func__ ) #endif void reset_stack( void ); @@ -1048,4 +1074,589 @@ void reset_stack( void ); #endif +/* Global counter variable for calculation of complexity weight */ +typedef struct +{ + UWord32 add; /* Complexity Weight of 1 */ + UWord32 sub; /* Complexity Weight of 1 */ + UWord32 abs_s; /* Complexity Weight of 1 */ + UWord32 shl; /* Complexity Weight of 1 */ + UWord32 shr; /* Complexity Weight of 1 */ + + UWord32 extract_h; /* Complexity Weight of 1 */ + UWord32 extract_l; /* Complexity Weight of 1 */ + UWord32 mult; /* Complexity Weight of 1 */ + UWord32 L_mult; /* Complexity Weight of 1 */ + UWord32 negate; /* Complexity Weight of 1 */ + + UWord32 round; /* Complexity Weight of 1 */ + UWord32 L_mac; /* Complexity Weight of 1 */ + UWord32 L_msu; /* Complexity Weight of 1 */ + UWord32 L_macNs; /* Complexity Weight of 1 */ + UWord32 L_msuNs; /* Complexity Weight of 1 */ + + UWord32 L_add; /* Complexity Weight of 1 */ + UWord32 L_sub; /* Complexity Weight of 1 */ + UWord32 L_add_c; /* Complexity Weight of 2 */ + UWord32 L_sub_c; /* Complexity Weight of 2 */ + UWord32 L_negate; /* Complexity Weight of 1 */ + + UWord32 L_shl; /* Complexity Weight of 1 */ + UWord32 L_shr; /* Complexity Weight of 1 */ + UWord32 mult_r; /* Complexity Weight of 1 */ + UWord32 shr_r; /* Complexity Weight of 3 */ + UWord32 mac_r; /* Complexity Weight of 1 */ + + UWord32 msu_r; /* Complexity Weight of 1 */ + UWord32 L_deposit_h; /* Complexity Weight of 1 */ + UWord32 L_deposit_l; /* Complexity Weight of 1 */ + UWord32 L_shr_r; /* Complexity Weight of 3 */ + UWord32 L_abs; /* Complexity Weight of 1 */ + + UWord32 L_sat; /* Complexity Weight of 4 */ + UWord32 norm_s; /* Complexity Weight of 1 */ + UWord32 div_s; /* Complexity Weight of 18 */ + UWord32 norm_l; /* Complexity Weight of 1 */ + UWord32 move16; /* Complexity Weight of 1 */ + + UWord32 move32; /* Complexity Weight of 2 */ + UWord32 Logic16; /* Complexity Weight of 1 */ + UWord32 Logic32; /* Complexity Weight of 2 */ + UWord32 Test; /* Complexity Weight of 2 */ + UWord32 s_max; /* Complexity Weight of 1 */ + + UWord32 s_min; /* Complexity Weight of 1 */ + UWord32 L_max; /* Complexity Weight of 1 */ + UWord32 L_min; /* Complexity Weight of 1 */ + UWord32 L40_max; /* Complexity Weight of 1 */ + UWord32 L40_min; /* Complexity Weight of 1 */ + + UWord32 shl_r; /* Complexity Weight of 2 */ + UWord32 L_shl_r; /* Complexity Weight of 2 */ + UWord32 L40_shr_r; /* Complexity Weight of 2 */ + UWord32 L40_shl_r; /* Complexity Weight of 2 */ + UWord32 norm_L40; /* Complexity Weight of 1 */ + + UWord32 L40_shl; /* Complexity Weight of 1 */ + UWord32 L40_shr; /* Complexity Weight of 1 */ + UWord32 L40_negate; /* Complexity Weight of 1 */ + UWord32 L40_add; /* Complexity Weight of 1 */ + UWord32 L40_sub; /* Complexity Weight of 1 */ + + UWord32 L40_abs; /* Complexity Weight of 1 */ + UWord32 L40_mult; /* Complexity Weight of 1 */ + UWord32 L40_mac; /* Complexity Weight of 1 */ + UWord32 mac_r40; /* Complexity Weight of 2 */ + + UWord32 L40_msu; /* Complexity Weight of 1 */ + UWord32 msu_r40; /* Complexity Weight of 2 */ + UWord32 Mpy_32_16_ss; /* Complexity Weight of 2 */ + UWord32 Mpy_32_32_ss; /* Complexity Weight of 2 */ + UWord32 L_mult0; /* Complexity Weight of 1 */ + + UWord32 L_mac0; /* Complexity Weight of 1 */ + UWord32 L_msu0; /* Complexity Weight of 1 */ + UWord32 lshl; /* Complexity Weight of 1 */ + UWord32 lshr; /* Complexity Weight of 1 */ + UWord32 L_lshl; /* Complexity Weight of 1 */ + + UWord32 L_lshr; /* Complexity Weight of 1 */ + UWord32 L40_lshl; /* Complexity Weight of 1 */ + UWord32 L40_lshr; /* Complexity Weight of 1 */ + UWord32 s_and; /* Complexity Weight of 1 */ + UWord32 s_or; /* Complexity Weight of 1 */ + + UWord32 s_xor; /* Complexity Weight of 1 */ + UWord32 L_and; /* Complexity Weight of 1 */ + UWord32 L_or; /* Complexity Weight of 1 */ + UWord32 L_xor; /* Complexity Weight of 1 */ + UWord32 rotl; /* Complexity Weight of 3 */ + + UWord32 rotr; /* Complexity Weight of 3 */ + UWord32 L_rotl; /* Complexity Weight of 3 */ + UWord32 L_rotr; /* Complexity Weight of 3 */ + UWord32 L40_set; /* Complexity Weight of 1 */ + UWord32 L40_deposit_h; /* Complexity Weight of 1 */ + + UWord32 L40_deposit_l; /* Complexity Weight of 1 */ + UWord32 L40_deposit32; /* Complexity Weight of 1 */ + UWord32 Extract40_H; /* Complexity Weight of 1 */ + UWord32 Extract40_L; /* Complexity Weight of 1 */ + UWord32 L_Extract40; /* Complexity Weight of 1 */ + + UWord32 L40_round; /* Complexity Weight of 1 */ + UWord32 L_saturate40; /* Complexity Weight of 1 */ + UWord32 round40; /* Complexity Weight of 1 */ + UWord32 If; /* Complexity Weight of 3 */ + UWord32 Goto; /* Complexity Weight of 2 */ + + UWord32 Break; /* Complexity Weight of 2 */ + UWord32 Switch; /* Complexity Weight of 6 */ + UWord32 For; /* Complexity Weight of 3 */ + UWord32 While; /* Complexity Weight of 3 */ + UWord32 Continue; /* Complexity Weight of 2 */ + + UWord32 L_mls; /* Complexity Weight of 1 */ + UWord32 div_l; /* Complexity Weight of 32 */ + UWord32 i_mult; /* Complexity Weight of 1 */ + +/* New complex basic operators */ +#ifdef COMPLEX_OPERATOR + UWord32 CL_shr; /* Complexity Weight of 1 */ + UWord32 CL_shl; /* Complexity Weight of 1 */ + UWord32 CL_add; /* Complexity Weight of 1 */ + UWord32 CL_sub; /* Complexity Weight of 1 */ + UWord32 CL_scale; /* Complexity Weight of 1 */ + UWord32 CL_dscale; /* Complexity Weight of 1 */ + UWord32 CL_msu_j; /* Complexity Weight of 1 */ + UWord32 CL_mac_j; /* Complexity Weight of 1 */ + UWord32 CL_move; /* Complexity Weight of 1 */ + UWord32 CL_Extract_real; /* Complexity Weight of 1 */ + UWord32 CL_Extract_imag; /* Complexity Weight of 1 */ + UWord32 CL_form; /* Complexity Weight of 1 */ + UWord32 CL_multr_32x16; /* Complexity Weight of 2 */ + UWord32 CL_negate; /* Complexity Weight of 1 */ + UWord32 CL_conjugate; /* Complexity Weight of 1 */ + UWord32 CL_mul_j; /* Complexity Weight of 1 */ + UWord32 CL_swap_real_imag; /* Complexity Weight of 1 */ + UWord32 C_add; /* Complexity Weight of 1 */ + UWord32 C_sub; /* Complexity Weight of 1 */ + UWord32 C_mul_j; /* Complexity Weight of 1 */ + UWord32 C_multr; /* Complexity Weight of 2 */ + UWord32 C_form; /* Complexity Weight of 1 */ + + UWord32 C_scale; /* Complexity Weight of 1 */ + UWord32 CL_round32_16; /* Complexity Weight of 1 */ + UWord32 CL_scale_32; /* Complexity Weight of 1 */ + UWord32 CL_dscale_32; /* Complexity Weight of 1 */ + UWord32 CL_multr_32x32; /* Complexity Weight of 2 */ + UWord32 C_mac_r; /* Complexity Weight of 2 */ + UWord32 C_msu_r; /* Complexity Weight of 2 */ + UWord32 C_Extract_real; /* Complexity Weight of 1 */ + UWord32 C_Extract_imag; /* Complexity Weight of 1 */ + UWord32 C_negate; /* Complexity Weight of 1 */ + UWord32 C_conjugate; /* Complexity Weight of 1 */ + UWord32 C_shr; /* Complexity Weight of 1 */ + UWord32 C_shl; /* Complexity Weight of 1 */ + +#endif /* #ifdef COMPLEX_OPERATOR */ + +/* New 64 bit basops */ +#ifdef ENH_64_BIT_OPERATOR + UWord32 move64; /* Complexity Weight of 1 */ + UWord32 W_add_nosat; /* Complexity Weight of 1 */ + UWord32 W_sub_nosat; /* Complexity Weight of 1 */ + UWord32 W_shl; /* Complexity Weight of 1 */ + UWord32 W_shr; /* Complexity Weight of 1 */ + UWord32 W_shl_nosat; /* Complexity Weight of 1 */ + UWord32 W_shr_nosat; /* Complexity Weight of 1 */ + UWord32 W_mac_32_16; /* Complexity Weight of 1 */ + UWord32 W_msu_32_16; /* Complexity Weight of 1 */ + UWord32 W_mult_32_16; /* Complexity Weight of 1 */ + UWord32 W_mult0_16_16; /* Complexity Weight of 1 */ + UWord32 W_mac0_16_16; /* Complexity Weight of 1 */ + UWord32 W_msu0_16_16; /* Complexity Weight of 1 */ + UWord32 W_mult_16_16; /* Complexity Weight of 1 */ + UWord32 W_mac_16_16; /* Complexity Weight of 1 */ + UWord32 W_msu_16_16; /* Complexity Weight of 1 */ + UWord32 W_shl_sat_l; /* Complexity Weight of 1 */ + UWord32 W_sat_l; /* Complexity Weight of 1 */ + UWord32 W_sat_m; /* Complexity Weight of 1 */ + UWord32 W_deposit32_l; /* Complexity Weight of 1 */ + UWord32 W_deposit32_h; /* Complexity Weight of 1 */ + UWord32 W_extract_l; /* Complexity Weight of 1 */ + UWord32 W_extract_h; /* Complexity Weight of 1 */ + UWord32 W_round48_L; /* Complexity Weight of 1 */ + UWord32 W_round32_s; /* Complexity Weight of 1 */ + UWord32 W_norm; /* Complexity Weight of 1 */ + + UWord32 W_add; /* Complexity Weight of 1 */ + UWord32 W_sub; /* Complexity Weight of 1 */ + UWord32 W_neg; /* Complexity Weight of 1 */ + UWord32 W_abs; /* Complexity Weight of 1 */ + UWord32 W_mult_32_32; /* Complexity Weight of 1 */ + UWord32 W_mult0_32_32; /* Complexity Weight of 1 */ + UWord32 W_lshl; /* Complexity Weight of 1 */ + UWord32 W_lshr; /* Complexity Weight of 1 */ + UWord32 W_round64_L; /* Complexity Weight of 1 */ + +#endif /* #ifdef ENH_64_BIT_OPERATOR */ + +#ifdef ENH_32_BIT_OPERATOR + UWord32 Mpy_32_16_1; /* Complexity Weight of 1 */ + UWord32 Mpy_32_16_r; /* Complexity Weight of 1 */ + UWord32 Mpy_32_32; /* Complexity Weight of 1 */ + UWord32 Mpy_32_32_r; /* Complexity Weight of 1 */ + UWord32 Madd_32_16; /* Complexity Weight of 1 */ + UWord32 Madd_32_16_r; /* Complexity Weight of 1 */ + UWord32 Msub_32_16; /* Complexity Weight of 1 */ + UWord32 Msub_32_16_r; /* Complexity Weight of 1 */ + UWord32 Madd_32_32; /* Complexity Weight of 1 */ + UWord32 Madd_32_32_r; /* Complexity Weight of 1 */ + UWord32 Msub_32_32; /* Complexity Weight of 1 */ + UWord32 Msub_32_32_r; /* Complexity Weight of 1 */ +#endif /* #ifdef ENH_32_BIT_OPERATOR */ + +#ifdef ENH_U_32_BIT_OPERATOR + UWord32 UL_addNs; /* Complexity Weight of 1 */ + UWord32 UL_subNs; /* Complexity Weight of 1 */ + UWord32 UL_Mpy_32_32; /* Complexity Weight of 1 */ + UWord32 Mpy_32_32_uu; /* Complexity Weight of 2 */ + UWord32 Mpy_32_16_uu; /* Complexity Weight of 2 */ + UWord32 norm_ul_float; /* Complexity Weight of 1 */ + UWord32 UL_deposit_l; /* Complexity Weight of 1 */ +#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ + +#ifdef CONTROL_CODE_OPS + UWord32 LT_16; /* Complexity Weight of 1 */ + UWord32 GT_16; /* Complexity Weight of 1 */ + UWord32 LE_16; /* Complexity Weight of 1 */ + UWord32 GE_16; /* Complexity Weight of 1 */ + UWord32 EQ_16; /* Complexity Weight of 1 */ + UWord32 NE_16; /* Complexity Weight of 1 */ + UWord32 LT_32; /* Complexity Weight of 1 */ + UWord32 GT_32; /* Complexity Weight of 1 */ + UWord32 LE_32; /* Complexity Weight of 1 */ + UWord32 GE_32; /* Complexity Weight of 1 */ + UWord32 EQ_32; /* Complexity Weight of 1 */ + UWord32 NE_32; /* Complexity Weight of 1 */ + UWord32 LT_64; /* Complexity Weight of 1 */ + UWord32 GT_64; /* Complexity Weight of 1 */ + UWord32 LE_64; /* Complexity Weight of 1 */ + UWord32 GE_64; /* Complexity Weight of 1 */ + UWord32 EQ_64; /* Complexity Weight of 1 */ + UWord32 NE_64; /* Complexity Weight of 1 */ + +#endif /* #ifdef CONTROL_CODE_OPS */ +} BASIC_OP; + +#ifdef WMOPS +extern BASIC_OP multiCounter[MAXCOUNTERS]; +extern int currCounter; +extern int lookup_table[]; + + + +/* Technical note : + * The following 3 variables are only used for correct complexity + * evaluation of the following structure : + * IF{ + * ... + * } ELSE IF { + * ... + * } ELSE IF { + * ... + * } + * ... + * } ELSE { + * ... + * } + */ +extern int funcId_where_last_call_to_else_occurred; +extern long funcid_total_wmops_at_last_call_to_else; +extern int call_occurred; +extern long LastWOper[MAXCOUNTERS]; +extern Word32 bc[MAXCOUNTERS][NbFuncMax], wc[MAXCOUNTERS][NbFuncMax]; +extern Word32 funcid[MAXCOUNTERS]; + +extern const BASIC_OP op_weight; + +extern long TotalWeightedOperation( void ); +extern long DeltaWeightedOperation( void ); +extern long fwc( void ); + +//void Set_BASOP_WMOPS_counter( int counterId ); +//void Reset_BASOP_WMOPS_counter( void ); + +/***************************************************************************** + * + * Function Name : FOR + * + * Purpose : + * + * The macro FOR should be used instead of the 'for' C statement. + * The complexity is independent of the number of loop iterations that are + * performed. + * + * Complexity weight : 3 (regardless of number of iterations). + * + *****************************************************************************/ +#ifndef WMOPS +#define FOR( a ) for ( a ) + +#else /* ifndef WMOPS */ +#define FOR( a ) \ + if ( incrFor(), 0 ) \ + ; \ + else \ + for ( a ) + +static __inline void incrFor( void ) +{ + multiCounter[currCounter].For++; +} +#endif /* ifndef WMOPS */ + + +/***************************************************************************** + * + * Function Name : WHILE + * + * Purpose : + * + * The macro WHILE should be used instead of the 'while' C statement. + * The complexity is proportional to the number of loop iterations that + * are performed. + * + * Complexity weight : 4 x 'number of loop iterations'. + * + *****************************************************************************/ +#ifndef WMOPS +#define WHILE( a ) while ( a ) + +#else /* ifndef WMOPS */ +#define WHILE( a ) while ( incrWhile(), a ) + +static __inline void incrWhile( void ) +{ + multiCounter[currCounter].While++; +} +#endif /* ifndef WMOPS */ + + +/***************************************************************************** + * + * Function Name : DO + * + * Purpose : + * + * The macro DO should be used instead of the 'do' C statement. + * + * Complexity weight : 0 (complexity counted by WHILE macro). + * + *****************************************************************************/ +#ifndef WMOPS +#define DO do + +#else /* ifndef WMOPS */ +#define DO do + +#endif /* ifndef WMOPS */ + + +/***************************************************************************** + * + * Function Name : IF + * + * Purpose : + * + * The macro IF should : + * + * - not be used when : + * - the 'if' structure does not have any 'else if' nor 'else' statement + * - and it conditions only one DSP basic operations. + * + * - be used instead of the 'if' C statement in every other case : + * - when there is an 'else' or 'else if' statement, + * - or when the 'if' conditions several DSP basic operations, + * - or when the 'if' conditions a function call. + * + * Complexity weight : 4 + * + *****************************************************************************/ +#ifndef WMOPS +#define IF( a ) if ( a ) + +#else /* ifndef WMOPS */ +#define IF( a ) if ( incrIf(), a ) + +static __inline void incrIf( void ) +{ + /* Technical note : + * If the "IF" operator comes just after an "ELSE", its counter + * must not be incremented. + */ + if ( ( currCounter != funcId_where_last_call_to_else_occurred ) || ( TotalWeightedOperation() != funcid_total_wmops_at_last_call_to_else ) || ( call_occurred == 1 ) ) + multiCounter[currCounter].If++; + + call_occurred = 0; + funcId_where_last_call_to_else_occurred = MAXCOUNTERS; +} +#endif /* ifndef WMOPS */ + + +/***************************************************************************** + * + * Function Name : ELSE + * + * Purpose : + * + * The macro ELSE should be used instead of the 'else' C statement. + * + * Complexity weight : 4 + * + *****************************************************************************/ +#ifndef WMOPS +#define ELSE else + +#else /* ifndef WMOPS */ +#define ELSE \ + else if ( incrElse(), 0 ); \ + else + +static __inline void incrElse( void ) +{ + multiCounter[currCounter].If++; + + /* We keep track of the funcId of the last function which used ELSE {...} structure. */ + funcId_where_last_call_to_else_occurred = currCounter; + + /* We keep track of the number of WMOPS of this funcId when the ELSE macro was called. */ + funcid_total_wmops_at_last_call_to_else = TotalWeightedOperation(); + + /* call_occurred is set to 0, in order to count the next IF (if necessary) */ + call_occurred = 0; +} +#endif /* ifndef WMOPS */ + + +/***************************************************************************** + * + * Function Name : SWITCH + * + * Purpose : + * + * The macro SWITCH should be used instead of the 'switch' C statement. + * + * Complexity weight : 8 + * + *****************************************************************************/ +#ifndef WMOPS +#define SWITCH( a ) switch ( a ) + +#else /* ifndef WMOPS */ +#define SWITCH( a ) switch ( incrSwitch(), a ) + +static __inline void incrSwitch( void ) +{ + multiCounter[currCounter].Switch++; +} +#endif /* ifndef WMOPS */ + + +/***************************************************************************** + * + * Function Name : CONTINUE + * + * Purpose : + * + * The macro CONTINUE should be used instead of the 'continue' C statement. + * + * Complexity weight : 4 + * + *****************************************************************************/ +#ifndef WMOPS +#define CONTINUE continue + +#else /* ifndef WMOPS */ +#define CONTINUE \ + if ( incrContinue(), 0 ) \ + ; \ + else \ + continue + +static __inline void incrContinue( void ) +{ + multiCounter[currCounter].Continue++; +} +#endif /* ifndef WMOPS */ + + +/***************************************************************************** + * + * Function Name : BREAK + * + * Purpose : + * + * The macro BREAK should be used instead of the 'break' C statement. + * + * Complexity weight : 4 + * + *****************************************************************************/ +#ifndef WMOPS +#define BREAK break + +#else /* ifndef WMOPS */ +#define BREAK \ + if ( incrBreak(), 0 ) \ + ; \ + else \ + break + +static __inline void incrBreak( void ) +{ + multiCounter[currCounter].Break++; +} +#endif /* ifndef WMOPS */ + + +/***************************************************************************** + * + * Function Name : GOTO + * + * Purpose : + * + * The macro GOTO should be used instead of the 'goto' C statement. + * + * Complexity weight : 4 + * + *****************************************************************************/ +#ifndef WMOPS +#define GOTO goto + +#else /* ifndef WMOPS */ +#define GOTO \ + if ( incrGoto(), 0 ) \ + ; \ + else \ + goto + +static __inline void incrGoto( void ) +{ + multiCounter[currCounter].Goto++; +} +#endif /* ifndef WMOPS */ + + +/* + * New control code basops + */ +#ifdef CONTROL_CODE_OPS + +Flag LT_16( Word16 var1, Word16 var2 ); +Flag GT_16( Word16 var1, Word16 var2 ); +Flag LE_16( Word16 var1, Word16 var2 ); +Flag GE_16( Word16 var1, Word16 var2 ); +Flag EQ_16( Word16 var1, Word16 var2 ); +Flag NE_16( Word16 var1, Word16 var2 ); + +Flag LT_32( Word32 L_var1, Word32 L_var2 ); +Flag GT_32( Word32 L_var1, Word32 L_var2 ); +Flag LE_32( Word32 L_var1, Word32 L_var2 ); +Flag GE_32( Word32 L_var1, Word32 L_var2 ); +Flag EQ_32( Word32 L_var1, Word32 L_var2 ); +Flag NE_32( Word32 L_var1, Word32 L_var2 ); + +Flag LT_64( Word64 L64_var1, Word64 L64_var2 ); +Flag GT_64( Word64 L64_var1, Word64 L64_var2 ); +Flag LE_64( Word64 L64_var1, Word64 L64_var2 ); +Flag GE_64( Word64 L64_var1, Word64 L64_var2 ); +Flag EQ_64( Word64 L64_var1, Word64 L64_var2 ); +Flag NE_64( Word64 L64_var1, Word64 L64_var2 ); + + +#endif /* #ifdef CONTROL_CODE_OPS */ + +#endif + #endif /* WMOPS_H */ diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 100b49de8..bbcb743d1 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -13,6 +13,7 @@ #include "math.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" +#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" #ifdef IVAS_FLOAT_FIXED diff --git a/lib_dec/ivas_agc_dec_fx.c b/lib_dec/ivas_agc_dec_fx.c index f620f59f3..85b7ff382 100644 --- a/lib_dec/ivas_agc_dec_fx.c +++ b/lib_dec/ivas_agc_dec_fx.c @@ -33,13 +33,13 @@ #include #include "options.h" #ifdef IVAS_FLOAT_FIXED - +#include +#include #include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include -#include +#include "rom_com.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 1206d0ed1..8a4f3619e 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -30,16 +30,17 @@ *******************************************************************************************************/ +#include +#include +#include #include "options.h" #include "ivas_cnst.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" +#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "prot.h" -#include -#include -#include #include "wmc_auto.h" #ifdef IVAS_FLOAT_FIXED #include "prot_fx.h" diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 19fa6bc62..68368365f 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -37,6 +37,7 @@ #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "prot.h" +#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index da6d2360e..2f072065a 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -31,16 +31,17 @@ *******************************************************************************************************/ #include -#include "options.h" #include +#include +#include "options.h" #include "ivas_cnst.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" +#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_stat_dec.h" #include "prot.h" #include "prot_fx.h" -#include #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index a492fcf65..c490bd65f 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -31,8 +31,8 @@ *******************************************************************************************************/ #include -#include "options.h" #include +#include "options.h" #include "cnst.h" #include "prot.h" #ifdef IVAS_FLOAT_FIXED @@ -42,6 +42,7 @@ #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" +#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "math.h" diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 2b91f3811..9ed201878 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -38,6 +38,7 @@ #include "prot.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" +#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 787646041..a135f306b 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -37,6 +37,7 @@ #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" +#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" #include "ivas_rom_dec.h" diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 6089012bc..22f4f6496 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -39,6 +39,7 @@ #include "string.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" +#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "ivas_stat_com.h" diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index 91c192c5b..516edae59 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -32,11 +32,12 @@ #include #include -#include "options.h" #include +#include "options.h" #include "ivas_cnst.h" #include "ivas_prot.h" #include "prot.h" +#include "rom_com.h" #include "wmc_auto.h" #ifdef IVAS_FLOAT_FIXED #include "prot_fx.h" diff --git a/lib_dec/jbm_pcmdsp_similarityestimation.c b/lib_dec/jbm_pcmdsp_similarityestimation.c index 6bf8c5c90..2f8a3b2a2 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "options.h" #include "wmc_auto.h" #include "basop_util.h" diff --git a/lib_dec/jbm_pcmdsp_window.c b/lib_dec/jbm_pcmdsp_window.c index 8df52a83e..4126a1151 100644 --- a/lib_dec/jbm_pcmdsp_window.c +++ b/lib_dec/jbm_pcmdsp_window.c @@ -40,7 +40,9 @@ #include "options.h" #include "jbm_pcmdsp_window.h" #include "cnst.h" +#include "basop_util.h" #include "wmc_auto.h" + #ifndef IVAS_FLOAT_FIXED /*-----------------------------------------------------------------------* * hannWindow() diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 77cc8710f..5ee3a1770 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -29,23 +29,26 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ + #include "lib_dec.h" #ifdef IVAS_FLOAT_FIXED +#include +#include +#include #include "ivas_cnst.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" +#include "rom_com.h" #include "jbm_jb4sb.h" #include "jbm_pcmdsp_apa.h" #include "jbm_pcmdsp_fifo.h" -#include -#include -#include #include "wmc_auto.h" #define INV_1000_Q31 2147484 /*1/1000 IN Q31*/ + /*---------------------------------------------------------------------* * Local structs *---------------------------------------------------------------------*/ diff --git a/lib_dec/rom_dec.h b/lib_dec/rom_dec.h index 44f45905e..9e5daaefb 100644 --- a/lib_dec/rom_dec.h +++ b/lib_dec/rom_dec.h @@ -40,6 +40,7 @@ #include #include "options.h" #include "cnst.h" +#include "typedef.h" #ifndef IVAS_FLOAT_FIXED extern const float h_low[]; /* LP filter for filtering periodic part of excitation in artificial onset construction after FEC */ diff --git a/lib_enc/ivas_agc_enc.c b/lib_enc/ivas_agc_enc.c index 17bc8c2fe..ab42855b7 100644 --- a/lib_enc/ivas_agc_enc.c +++ b/lib_enc/ivas_agc_enc.c @@ -32,11 +32,12 @@ #include +#include +#include #include "options.h" #include "ivas_prot.h" #include "prot.h" -#include -#include +#include "rom_com.h" #include "wmc_auto.h" #ifdef IVAS_FLOAT_FIXED #include "prot_fx.h" diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 648cc744d..068247dd8 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -81,7 +81,6 @@ static Word16 get_zero_flag( Word32 arr[], Word16 len ) IF( arr[j] != 0 ) { return 1; - BREAK; } } return 0; diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 9f9b7ad8d..a57bb497e 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -465,7 +465,6 @@ ivas_error ivas_cpe_enc_fx( IF( !( EQ_32( ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) ) { #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - Word16 q_inp; f2me_buf_16( sts[n]->input, sts[n]->input_fx, &q_inp, input_frame ); q_inp = 15 - q_inp; #endif diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 7d7617431..8fb276f93 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -385,7 +385,6 @@ ivas_error IVAS_ENC_ConfigureForMASAObjects( BREAK; default: return IVAS_ERR_INVALID_MASA_CONFIG; - BREAK; } st_ivas = hIvasEnc->st_ivas; @@ -743,7 +742,6 @@ ivas_error IVAS_ENC_ConfigureForMasa( BREAK; default: return IVAS_ERR_INVALID_MASA_CONFIG; - BREAK; } hIvasEnc->maxBandwidthUser = max_bwidth_user; diff --git a/lib_enc/nelp_enc_fx.c b/lib_enc/nelp_enc_fx.c index 9df21a200..259987bba 100644 --- a/lib_enc/nelp_enc_fx.c +++ b/lib_enc/nelp_enc_fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include -#include "control.h" #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ #include "prot.h" /* Function prototypes */ diff --git a/lib_enc/vlpc_1st_cod_fx.c b/lib_enc/vlpc_1st_cod_fx.c index cc9592739..deddb5023 100644 --- a/lib_enc/vlpc_1st_cod_fx.c +++ b/lib_enc/vlpc_1st_cod_fx.c @@ -4,7 +4,6 @@ #include #include "options.h" -#include "control.h" #include "cnst.h" //#include "prot_fx.h" #include "rom_com_fx.h" diff --git a/lib_enc/vlpc_2st_cod_fx.c b/lib_enc/vlpc_2st_cod_fx.c index 0785e9e6e..6334684d2 100644 --- a/lib_enc/vlpc_2st_cod_fx.c +++ b/lib_enc/vlpc_2st_cod_fx.c @@ -7,7 +7,6 @@ #include "cnst.h" #include "options.h" //#include "prot_fx.h" -#include "control.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 95ab75f93..5b3a313ea 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -47,7 +47,6 @@ #endif #ifdef IVAS_FLOAT_FIXED -#include "control.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #define float_to_fix( n, factor ) ( round( n * ( 1 << factor ) ) ) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 6ff9685bf..6c8eb9c75 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -31,9 +31,9 @@ *******************************************************************************************************/ #include -#include "options.h" #include #include +#include "options.h" #include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" @@ -42,11 +42,11 @@ #include "ivas_rom_binauralRenderer.h" #include "ivas_rom_binaural_crend_head.h" #include "ivas_rom_rend.h" +#include "rom_com.h" #include "ivas_rom_com.h" #ifdef IVAS_FLOAT_FIXED #include "ivas_prot_fx.h" #endif - #include "wmc_auto.h" #ifdef IVAS_FLOAT_FIXED diff --git a/lib_rend/ivas_reverb_filter_design.c b/lib_rend/ivas_reverb_filter_design.c index c0d147123..f2a489420 100644 --- a/lib_rend/ivas_reverb_filter_design.c +++ b/lib_rend/ivas_reverb_filter_design.c @@ -39,7 +39,6 @@ #include #include #include "wmc_auto.h" -#include "control.h" /*------------------------------------------------------------------------------------------* -- GitLab From a6e61ec22f04b72cd927f0c35e5ce91437b2b0bc Mon Sep 17 00:00:00 2001 From: malenov Date: Thu, 21 Nov 2024 13:54:41 +0100 Subject: [PATCH 02/21] remove count.h and count.c --- lib_com/complex_basop.c | 5 - lib_com/count.c | 1207 --------------------------------- lib_com/count.h | 227 ------- lib_com/enh1632.c | 5 - lib_com/hq2_noise_inject_fx.c | 1 - lib_com/options.h | 1 - lib_debug/wmc_auto.c | 583 ++++++++-------- lib_debug/wmc_auto.h | 591 ++++++++-------- lib_dec/rom_dec.c | 1 + lib_enc/core_enc_init_fx.c | 3 +- lib_enc/rom_enc.c | 1 + 11 files changed, 557 insertions(+), 2068 deletions(-) delete mode 100644 lib_com/count.c delete mode 100644 lib_com/count.h diff --git a/lib_com/complex_basop.c b/lib_com/complex_basop.c index c086ed349..0d641ded6 100644 --- a/lib_com/complex_basop.c +++ b/lib_com/complex_basop.c @@ -11,11 +11,6 @@ #include "stl.h" -#ifdef WMOPS -extern int currCounter; -#endif /* if WMOPS */ - - #ifdef COMPLEX_OPERATOR /* ================================ New Complex Basops ========================= */ diff --git a/lib_com/count.c b/lib_com/count.c deleted file mode 100644 index dba2201df..000000000 --- a/lib_com/count.c +++ /dev/null @@ -1,1207 +0,0 @@ -/* - =========================================================================== - File: COUNT.C v.2.3 - 30.Nov.2009 - =========================================================================== - - ITU-T STL BASIC OPERATORS - - COMPLEXITY EVALUATION FUNCTIONS - - History: - 03 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control - operators for the ITU-T Standard Tool Library as - described in Geneva, 20-30 January 2004 WP 3/16 Q10/16 - TD 11 document and subsequent discussions on the - wp3audio@yahoogroups.com email reflector. - norm_s() weight reduced from 15 to 1. - norm_l() weight reduced from 30 to 1. - L_abs() weight reduced from 2 to 1. - L_add() weight reduced from 2 to 1. - L_negate() weight reduced from 2 to 1. - L_shl() weight reduced from 2 to 1. - L_shr() weight reduced from 2 to 1. - L_sub() weight reduced from 2 to 1. - mac_r() weight reduced from 2 to 1. - msu_r() weight reduced from 2 to 1. - mult_r() weight reduced from 2 to 1. - L_deposit_h() weight reduced from 2 to 1. - L_deposit_l() weight reduced from 2 to 1. - March 06 v2.1 Changed to improve portability. - Dec 06 v2.2 Changed to specify frame rate using setFrameRate() - Adding WMOPS_output_avg() for global average computation - L_mls() weight of 5. - div_l() weight of 32. - i_mult() weight of 3. - ============================================================================ -*/ - - -/***************************************************************************** - * - * This file contains functions for the automatic complexity calculation - * - *****************************************************************************/ - - -#include -#include -#include -#include -#include "options.h" -#include "stl.h" -#include "count.h" -#include "wmc_auto.h" - -#ifndef WMOPS -#include "options_warnings.h" -#endif - -#define WMC_TOOL_SKIP - - - - -static double frameRate = FRAME_RATE; /* default value : 10 ms */ - -#define MAX_RECORDS 1024 -#define MAX_STACK 64 -#define MAX_CHAR 64 - -// struct wmops_record -//{ -// char label[MAX_CHAR]; -// long call_number; -// long update_cnt; -// int call_tree[MAX_RECORDS]; -// double start_selfcnt; -// double current_selfcnt; -// double max_selfcnt; -// double min_selfcnt; -// double tot_selfcnt; -// double start_cnt; /* The following take into account the decendants */ -// double current_cnt; -// double max_cnt; -// double min_cnt; -// double tot_cnt; -// }; -// -// static struct wmops_record wmops[MAX_RECORDS]; - -static int stack[MAX_STACK]; -static int sptr; -static int sum_stack[MAX_STACK]; - -/* Global counter variable for calculation of complexity weight */ -/* Some enhancement written by Vail., GJR and M.Mul. during EVS time */ - -BASIC_OP glob_multiCounter; -int currCounter = 0; /* Zero equals global counter */ - -void setFrameRate( int samplingFreq, int frameLength ) -{ - if ( frameLength > 0 ) - { - frameRate = samplingFreq / 1000000.0 / frameLength; - } - return; -} - -int lookup_table[MAX_HASH_TABLE_SIZE]; - -/* - * Below list is used for displaying the code profiling information in - * the file which name is defined by CODE_PROFILE_FILENAME. - * For further details see generic_WMOPS_output() function. - * Attention, the ordering in this table must be kept in synchronisation - * with the structure definition BASIC_OP. - */ -char *BasicOperationList[] = { - "add", "sub", "abs_s", "shl", "shr", - "extract_h", "extract_l", "mult", "L_mult", "negate", - "round", "L_mac", "L_msu", "L_macNs", "L_msuNs", - "L_add", "L_sub", "L_add_c", "L_sub_c", "L_negate", - "L_shl", "L_shr", "mult_r", "shr_r", "mac_r", - - "msu_r", "L_deposit_h", "L_deposit_l", "L_shr_r", "L_abs", - "L_sat", "norm_s", "div_s", "norm_l", "move16", - "move32", "Logic16", "Logic32", "Test", "s_max", - "s_min", "L_max", "L_min", "L40_max", "L40_min", - "shl_r", "L_shl_r", "L40_shr_r", "L40_shl_r", "norm_L40", - - "L40_shl", "L40_shr", "L40_negate", "L40_add", "L40_sub", - "L40_abs", "L40_mult", "L40_mac", "mac_r40", - "L40_msu", "msu_r40", "Mpy_32_16_ss", "Mpy_32_32_ss", "L_mult0", - "L_mac0", "L_msu0", "lshl", "lshr", "L_lshl", - "L_lshr", "L40_lshl", "L40_lshr", "s_and", "s_or", - - "s_xor", "L_and", "L_or", "L_xor", "rotl", - "rotr", "L_rotl", "L_rotr", "L40_set", "L40_deposit_h", - "L40_deposit_l", "L40_deposit32", "Extract40_H", "Extract40_L", "L_Extract40", - "L40_round", "L_saturate40", "round40", "IF", "GOTO", - "BREAK", "SWITCH", "FOR", "WHILE", "CONTINUE", - - "L_mls", "div_l", "i_mult" - -/* New complex basops */ -#ifdef COMPLEX_OPERATOR - , - "CL_shr", "CL_shl", "CL_add", "CL_sub", "CL_scale", "CL_dscale", "CL_msu_j", "CL_mac_j", "CL_move", "CL_Extract_real", "CL_Extract_imag", "CL_form", "CL_multr_32x16", "CL_negate", "CL_conjugate", "CL_mul_j", "CL_swap_real_imag", "C_add", "C_sub", "C_mul_j", "C_multr", "C_form" - - , - "C_scale", "CL_round32_16", "CL_scale_32", "CL_dscale_32", "CL_multr_32x32", "C_mac_r", "C_msu_r", "C_Extract_real", "C_Extract_imag", "C_negate", "C_conjugate", "C_shr", "C_shl" - -#endif /* #ifdef COMPLEX_OPERATOR */ - -/* New 64 bit basops */ -#ifdef ENH_64_BIT_OPERATOR - , - "move64", "W_add_nosat", "W_sub_nosat", "W_shl", "W_shr", "W_shl_nosat", "W_shr_nosat", "W_mac_32_16", "W_msu_32_16", "W_mult_32_16", "W_mult0_16_16", "W_mac0_16_16", "W_msu0_16_16", "W_mult_16_16", "W_mac_16_16", "W_msu_16_16", "W_shl_sat_l", "W_sat_l", "W_sat_m", "W_deposit32_l", "W_deposit32_h", "W_extract_l", "W_extract_h", "W_round48_L", "W_round32_s", "W_norm", "W_add", "W_sub", "W_neg", "W_abs", "W_mult_32_32", "W_mult0_32_32", "W_lshl", "W_lshr", "W_round64_L" - -#endif /* #ifdef ENH_64_BIT_OPERATOR */ - -#ifdef ENH_32_BIT_OPERATOR - , - "Mpy_32_16_1", "Mpy_32_16_r", "Mpy_32_32", "Mpy_32_32_r", "Madd_32_16", "Madd_32_16_r", "Msub_32_16", "Msub_32_16_r", "Madd_32_32", "Madd_32_32_r", "Msub_32_32", "Msub_32_32_r" -#endif /* #ifdef ENH_32_BIT_OPERATOR */ - -#ifdef ENH_U_32_BIT_OPERATOR - , - "UL_addNs", "UL_subNs", "UL_Mpy_32_32", "Mpy_32_32_uu", "Mpy_32_16_uu", "norm_ul_float", "UL_deposit_l" -#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ - -#ifdef CONTROL_CODE_OPS - , - "LT_16", "GT_16", "LE_16", "GE_16", "EQ_16", "NE_16", "LT_32", "GT_32", "LE_32", "GE_32", "EQ_32", "NE_32", "LT_64", "GT_64", "LE_64", "GE_64", "EQ_64", "NE_64" -#endif /* #ifdef CONTROL_CODE_OPS */ - -}; - - - - -#ifdef WMOPS -/* Counters for separating counting for different objects */ - -/* FROM_EVS_DEV */ -/** -maxCounter: current number of counters. Each scope initialized with BASOP_sub_start() gets a own counter assigned. -objectName: Name of each counter passed to BASOP_sub_start(). -fwc_corr: -nbTimeObjectIsCalled: number of times a counter (object) is referenced in the current frame. -*/ - -static int maxCounter = 0; -static char *objectName[MAXCOUNTERS + 1]; - -static Word16 fwc_corr[MAXCOUNTERS + 1]; -static long int nbTimeObjectIsCalled[MAXCOUNTERS + 1]; - - - -/** - funcid: current function call for each counter - bc : best case for each counter and function call - wc : worst case for each counter and function call - nbframe: number of frames for each counter. - glob_bc: global best case self time for each counter for current frame. - glob_wc: global worst case self time for each counter for current frame. - glob_sum_curr: global cummulative time for each counter for current frame. - glob_sum_bc: global best case cummulative time for each counter for current frame. - glob_sum_wc: global worst case cummulative time for each counter for current frame. - - total_wmops: total wmops self time for each counter for current frame. - total_sum: total wmops cummulative time for each counter for current frame. - LastWOper: values used for WMOPS deltas - */ - -static Word32 nbframe[MAXCOUNTERS], nbcalls[MAXCOUNTERS]; -static Word32 glob_bc[MAXCOUNTERS], glob_wc[MAXCOUNTERS]; -static float total_wmops[MAXCOUNTERS]; -/* FROM_EVS_DEV */ -static float total_sum[MAXCOUNTERS]; -static Word16 call_tree[MAXCOUNTERS][MAXCOUNTERS]; -static int sum_curr[MAXCOUNTERS + 1]; -static int sum_bc[MAXCOUNTERS + 1]; -static int sum_wc[MAXCOUNTERS + 1]; -static int glob_sum_curr[MAXCOUNTERS + 1]; -static int glob_sum_bc[MAXCOUNTERS + 1]; -static int glob_sum_wc[MAXCOUNTERS + 1]; -#if MAX_CALLERS_SAVED_FRAMES -#define MAX_CALLERS_PRINT 20 -static float callers_frames[MAX_CALLERS_SAVED_FRAMES + 1][MAXCOUNTERS + 1]; -static int callers_frames_nos[MAX_CALLERS_SAVED_FRAMES]; -static float callers_totals[MAX_CALLERS_SAVED_FRAMES]; -#endif - -#endif /* ifdef WMOPS */ - - -#ifdef WMOPS -static char *my_strdup( const char *s ) -{ - /* - * duplicates UNIX function strdup() which is not ANSI standard: - * -- malloc() memory area big enough to hold the string s - * -- copy string into new area - * -- return pointer to new area - * - * returns NULL if either s==NULL or malloc() fails - */ - char *dup; - - if ( s == NULL ) - return NULL; - - /* allocate memory for copy of ID string (including string terminator) */ - /* NOTE: the ID strings will never be deallocated because there is no way to "destroy" a counter that is not longer needed */ - if ( ( dup = (char *) malloc( strlen( s ) + 1 ) ) == NULL ) - return NULL; - - return strcpy( dup, s ); -} - -int calc_hash( const char *str ) -{ - /* A simple hash function (might be good to replace with a better one) */ - int hash_value = 0; - for ( int i = 0; str[i]; i++ ) - { - hash_value += str[i]; - } - return hash_value % MAX_HASH_TABLE_SIZE; -} - -#endif /* ifdef WMOPS */ - - -int getCounterId( const char *objectNameArg ) -{ -#ifdef WMOPS - if ( maxCounter >= MAXCOUNTERS - 1 ) - return 0; - objectName[++maxCounter] = my_strdup( objectNameArg ); - return maxCounter; - -#else /* ifdef WMOPS */ - (void) objectNameArg; - return 0; /* Dummy */ - -#endif /* ifdef WMOPS */ -} - - -#ifdef WMOPS -int readCounterId() -{ - return currCounter; -} -#endif /* ifdef WMOPS */ - - -#ifdef WMOPS -char *readCounterIdName() -{ - return objectName[currCounter]; -} -#endif /* ifdef WMOPS */ - -void setCounter( int counterId ) -{ -#ifdef WMOPS - if ( ( counterId > maxCounter ) || ( counterId < 0 ) ) - { - currCounter = 0; - return; - } - currCounter = counterId; - call_occurred = 1; -#else - (void) counterId; -#endif /* ifdef WMOPS */ -} - - -void incrementNbTimeObjectIsCalled( int counterId ) -{ -#ifdef WMOPS - if ( ( counterId > maxCounter ) || ( counterId < 0 ) ) - { - nbTimeObjectIsCalled[0]++; - return; - } - nbTimeObjectIsCalled[counterId]++; -#else - (void) counterId; -#endif /* ifdef WMOPS */ -} - - -#ifdef WMOPS -static Word32 WMOPS_frameStat( void ) -{ - /* calculate the WMOPS seen so far and update the global - per-frame maximum (glob_wc) - */ - Word32 tot; - - tot = TotalWeightedOperation(); - if ( tot > glob_wc[currCounter] ) - { - glob_wc[currCounter] = tot; - } - - if ( tot < glob_bc[currCounter] ) - { - glob_bc[currCounter] = tot; - } - /* check if fwc() was forgotten at end of last frame */ - if ( tot > LastWOper[currCounter] ) - { - if ( !fwc_corr[currCounter] ) - { - fprintf( stderr, - "count: operations counted after last fwc() for '%s'; " - "-> fwc() called\n", - objectName[currCounter] ? objectName[currCounter] : "" ); - } - fwc(); - } - - return tot; -} -#endif /* ifdef WMOPS */ - - -#ifdef WMOPS -static void WMOPS_clearMultiCounter( void ) -{ - Word32 i; - - Word32 *ptr = (Word32 *) &multiCounter[currCounter]; - for ( i = 0; i < (Word16) ( sizeof( multiCounter[currCounter] ) / sizeof( Word32 ) ); i++ ) - { - *ptr++ = 0; - } -} -#endif /* ifdef WMOPS */ - - -void ClearNbTimeObjectsAreCalled() -{ -#ifdef WMOPS - Word32 i; - - for ( i = 0; i < (Word16) ( sizeof( multiCounter[currCounter] ) / sizeof( Word32 ) ); i++ ) - { - nbTimeObjectIsCalled[i] = 0; - } -#endif /* ifdef WMOPS */ -} - - - - -void Init_WMOPS_counter( void ) -{ -#ifdef WMOPS - Word32 i; - - /* reset function weight operation counter variable */ - - for ( i = 0; i < NbFuncMax; i++ ) - wc[currCounter][i] = (Word32) 0; - glob_wc[currCounter] = 0; - nbframe[currCounter] = 0; - total_wmops[currCounter] = 0.0; - for ( i = 0; i < NbFuncMax; i++ ) - { - bc[currCounter][i] = (Word32) MAX_32; - } - glob_bc[currCounter] = MAX_32; - nbcalls[currCounter] = 0; - total_sum[currCounter] = 0.0; - - /* initially clear all counters */ - WMOPS_clearMultiCounter(); - LastWOper[currCounter] = 0; - funcid[currCounter] = 0; - - /* Following line is useful for incrIf(), see control.h */ - call_occurred = 1; - funcId_where_last_call_to_else_occurred = MAXCOUNTERS; - - sum_bc[currCounter] = MAX_32; - sum_wc[currCounter] = 0; - sum_curr[currCounter] = 0; - for ( i = 0; i < MAXCOUNTERS; i++ ) - { - call_tree[currCounter][i] = -1; - } - - glob_sum_curr[currCounter] = 0; - glob_sum_wc[currCounter] = 0; - glob_sum_bc[currCounter] = MAX_32; - -#endif /* ifdef WMOPS */ -} - - -Word32 Reset_WMOPS_counter( void ) -{ -#ifdef WMOPS - Word32 tot = WMOPS_frameStat(); - - /* increase the frame counter --> a frame is counted WHEN IT BEGINS */ - nbframe[currCounter]++; - /* Call counter */ - nbcalls[currCounter] += funcid[currCounter]; - /* add wmops used in last frame to count, then reset counter (in first frame, this is a no-op */ - total_wmops[currCounter] += (float) ( tot * frameRate ); - total_sum[currCounter] += (float) ( ( glob_sum_curr[currCounter] ) * frameRate ); - - /* clear counter before new frame starts */ - WMOPS_clearMultiCounter(); - LastWOper[currCounter] = 0; - funcid[currCounter] = 0; /* new frame, set function id to zero */ - - glob_sum_curr[currCounter] = 0; - sum_curr[currCounter] = 0; - return tot; -#else - return 0; -#endif /* ifdef WMOPS */ -} - - - - -void WMOPS_output( Word16 dtx_mode ) -{ -#ifdef WMOPS - Word32 i; - Word32 tot, tot_wm, tot_wc; - - /* get operations since last reset (or init), but do not update the counters (except the glob_wc[] maximum) - so output CAN be called in each frame without problems. The frame counter is NOT updated! */ - tot = WMOPS_frameStat(); - tot_wm = (Word32) ( total_wmops[currCounter] + ( (float) tot ) * frameRate ); - - fprintf( stdout, - "%10s:WMOPS=%.3f", objectName[currCounter] ? objectName[currCounter] : "", - ( (float) tot ) * frameRate ); - - if ( nbframe[currCounter] != 0 ) - { - fprintf( stdout, " Average=%.3f", tot_wm / (float) nbframe[currCounter] ); - } - fprintf( stdout, " WorstCase=%.3f", ( (float) glob_wc[currCounter] ) * frameRate ); - - /* Worst worst case printed only when not in DTX mode */ - if ( dtx_mode == 0 ) - { - tot_wc = 0L; - for ( i = 0; i < funcid[currCounter]; i++ ) - tot_wc += wc[currCounter][i]; - fprintf( stdout, " WorstWC=%.3f", ( (float) tot_wc ) * frameRate ); - } - fprintf( stdout, " (%d frames)\n", nbframe[currCounter] ); -#else - (void) dtx_mode; -#endif /* ifdef WMOPS */ -} - -void WMOPS_output_avg( Word16 dtx_mode, Word32 *tot_wm, Word32 *num_frames ) -{ -#ifdef WMOPS - Word32 i; - Word32 tot, tot_wc; - - /* get operations since last reset (or init), but do not update the counters (except the glob_wc[] maximum) - so output CAN be called in each frame without problems. The frame counter is NOT updated! */ - tot = WMOPS_frameStat(); - *tot_wm = (Word32) ( total_wmops[currCounter] + ( (float) tot ) * frameRate ); - *num_frames = nbframe[currCounter]; - - fprintf( stdout, "%10s:WMOPS=%.3f", objectName[currCounter] ? objectName[currCounter] : "", ( (float) tot ) * frameRate ); - - if ( nbframe[currCounter] != 0 ) - { - fprintf( stdout, " Average=%.3f", *tot_wm / (float) nbframe[currCounter] ); - } - fprintf( stdout, " WorstCase=%.3f", ( (float) glob_wc[currCounter] ) * frameRate ); - - /* Worst worst case printed only when not in DTX mode */ - if ( dtx_mode == 0 ) - { - tot_wc = 0L; - for ( i = 0; i < funcid[currCounter]; i++ ) - tot_wc += wc[currCounter][i]; - fprintf( stdout, " WorstWC=%.3f", ( (float) tot_wc ) * frameRate ); - } - fprintf( stdout, " (%d frames)\n", nbframe[currCounter] ); -#else - (void) dtx_mode; - (void) tot_wm; - (void) num_frames; -#endif /* ifdef WMOPS */ -} - -void generic_WMOPS_output( Word16 dtx_mode, char *test_file_name ) -{ -#ifdef WMOPS - int saved_value; - Word32 i; - Word32 tot, tot_wm, tot_wc, *ptr; - const Word32 *ptr2; - Word40 grand_total; - FILE *WMOPS_file; - - saved_value = currCounter; - - /* Count the grand_total WMOPS so that % ratio per function group can be displayed. */ - grand_total = 0; - for ( currCounter = 0; currCounter <= maxCounter; currCounter++ ) - { - tot = WMOPS_frameStat(); - grand_total += tot; - } - - - if ( ( WMOPS_file = fopen( WMOPS_DATA_FILENAME, "a" ) ) != NULL ) - { - - printf( "opened file %s in order to print WMOPS for each function group.\n", WMOPS_DATA_FILENAME ); - - /* Print the file header line. */ - fprintf( WMOPS_file, "Test file name\tFunction Name \tFrame\tNb Times Called\tWMOPS\t%% versus grand total" ); - - if ( nbframe[saved_value] != 0 ) - fprintf( WMOPS_file, "\tAverage" ); - - fprintf( WMOPS_file, "\tWorstCase" ); - - /* Worst worst case printed only when not in DTX mode */ - if ( dtx_mode == 0 ) - fprintf( WMOPS_file, "\tWorstWC" ); - - fprintf( WMOPS_file, "\n" ); - - /* Print the WMOPS for each Function Group by scanning all the function groups with currCounter index. */ - for ( currCounter = 0; currCounter <= maxCounter; currCounter++ ) - { - - fprintf( WMOPS_file, "%s", test_file_name ); - fprintf( WMOPS_file, "\t%s", objectName[currCounter] ? objectName[currCounter] : "" ); - fprintf( WMOPS_file, "\t%d", nbframe[currCounter] ); - - tot = WMOPS_frameStat(); - tot_wm = (Word32) ( total_wmops[currCounter] + ( (float) tot ) * frameRate ); - - fprintf( WMOPS_file, "\t\t%ld", nbTimeObjectIsCalled[currCounter] ); - fprintf( WMOPS_file, "\t%.6f", ( (float) tot ) * frameRate ); - fprintf( WMOPS_file, "\t%.3f", ( (float) tot ) / grand_total * 100 ); - - if ( nbframe[currCounter] != 0 ) - fprintf( WMOPS_file, "\t%.3f", tot_wm / (float) nbframe[currCounter] ); - - fprintf( WMOPS_file, "\t%.3f", ( (float) glob_wc[currCounter] ) * frameRate ); - - /* Worst worst case printed only when not in DTX mode */ - if ( dtx_mode == 0 ) - { - tot_wc = 0L; - for ( i = 0; i < funcid[currCounter]; i++ ) - tot_wc += wc[currCounter][i]; - fprintf( WMOPS_file, "\t%.3f", ( (float) tot_wc ) * frameRate ); - } - fprintf( WMOPS_file, "\n" ); - } - - /* Print the file Grand Total line */ - fprintf( WMOPS_file, "%s", test_file_name ); - fprintf( WMOPS_file, "\tGrand Total" ); - fprintf( WMOPS_file, "\t%d", nbframe[saved_value] ); - fprintf( WMOPS_file, "\t\t%.6f", ( (float) grand_total ) * frameRate ); - fprintf( WMOPS_file, "\t100.000" ); - fprintf( WMOPS_file, "\n" ); - fclose( WMOPS_file ); - } - else - printf( "Can not open file %s for WMOPS editing\n", WMOPS_DATA_FILENAME ); - - - if ( ( WMOPS_file = fopen( WMOPS_TOTAL_FILENAME, "a" ) ) != NULL ) - { - printf( "opened file %s in order to print application's total WMOPS.\n", WMOPS_TOTAL_FILENAME ); - fprintf( WMOPS_file, "%s", test_file_name ); - fprintf( WMOPS_file, "\tframe=%d", nbframe[currCounter] ); - fprintf( WMOPS_file, "\tWMOPS=%.6f", ( (float) grand_total ) * frameRate ); - fprintf( WMOPS_file, "\n" ); - fclose( WMOPS_file ); - } - else - printf( "Can not open file %s for WMOPS editing.\n", WMOPS_TOTAL_FILENAME ); - - - if ( ( WMOPS_file = fopen( CODE_PROFILE_FILENAME, "a" ) ) != NULL ) - { - - printf( "opened file %s in order to print basic operation distribution statistics.\n", CODE_PROFILE_FILENAME ); - - /* Print the file header line. */ - fprintf( WMOPS_file, "Test file name\tBasic Operation Name\tframe\tWMOPS\t\t%% versus grand total\n" ); - - /* Print the WMOPS for each Basic Operation across all the defined */ - /* Function Groups. */ - for ( i = 0; i < (Word16) ( sizeof( op_weight ) / sizeof( Word32 ) ); i++ ) - { - fprintf( WMOPS_file, "%-16s", test_file_name ); - fprintf( WMOPS_file, "\t%s", BasicOperationList[i] ); - fprintf( WMOPS_file, "\t%d", nbframe[0] ); - - tot = 0; - ptr = (Word32 *) &multiCounter[0] + i; - ptr2 = (const Word32 *) &op_weight + i; - for ( currCounter = 0; currCounter <= maxCounter; currCounter++ ) - { - tot += ( ( *ptr ) * ( *ptr2 ) ); - ptr += ( sizeof( op_weight ) / sizeof( Word32 ) ); - } - - fprintf( WMOPS_file, "\t%.6f", ( (float) tot ) * frameRate ); - fprintf( WMOPS_file, "\t%.3f", ( (float) tot ) / grand_total * 100 ); - fprintf( WMOPS_file, "\n" ); - } - - /* Print the file Grand Total line */ - fprintf( WMOPS_file, "%s", test_file_name ); - fprintf( WMOPS_file, "\tGrand Total" ); - fprintf( WMOPS_file, "\t%d", nbframe[saved_value] ); - fprintf( WMOPS_file, "\t%.6f", ( (float) grand_total ) * frameRate ); - fprintf( WMOPS_file, "\t100.000" ); - fprintf( WMOPS_file, "\n" ); - fclose( WMOPS_file ); - } - else - printf( "Can not open file %s for basic operations distribution statistic editing\n", CODE_PROFILE_FILENAME ); - - currCounter = saved_value; - -#else - (void) dtx_mode; - (void) test_file_name; -#endif /* ifdef WMOPS */ -} -/* FROM_EVS_DEV */ - - -/* jdr 20120117: add FLC similar functions */ -void BASOP_frame_update( void ) -{ -#ifdef WMOPS - int i, current; -#if MAX_CALLERS_SAVED_FRAMES - int k; -#endif - float total = 0.0f; - -#ifdef DEBUG - { - static int sptr_target = -2; - - if ( sptr_target == -2 ) - { - sptr_target = sptr; - } - else - { - if ( sptr_target != sptr ) - { - fprintf( stderr, "BASOP_sub_start/BASOP_sub_end imbalance detected!!!\n" ); - sptr_target = sptr; - } - } - } -#endif - - /* Get current counter */ - current = readCounterId(); - - /* Update global operation counters */ - for ( i = 1; i <= maxCounter; i++ ) - { - int j; - - for ( j = 0; j < (int) ( sizeof( BASIC_OP ) / sizeof( UWord32 ) ); j++ ) - { - ( (UWord32 *) &glob_multiCounter )[j] += ( (UWord32 *) &multiCounter[i] )[j]; - } - } - -#if MAX_CALLERS_SAVED_FRAMES - /* Reset all counters */ - for ( i = 1; i <= maxCounter; i++ ) - { - callers_frames[0][i] = 0.0f; - } -#endif - /* Reset all counters */ - for ( i = 1; i <= maxCounter; i++ ) - { - if ( current != i && funcid[i] > 0 ) - { - setCounter( i ); - - glob_sum_curr[currCounter] += sum_curr[currCounter]; - - if ( glob_sum_curr[currCounter] > glob_sum_wc[currCounter] ) - { - glob_sum_wc[currCounter] = glob_sum_curr[currCounter]; - } - if ( glob_sum_curr[currCounter] < glob_sum_bc[currCounter] ) - { - glob_sum_bc[currCounter] = glob_sum_curr[currCounter]; - } -#if MAX_CALLERS_SAVED_FRAMES - /* Keep a Copy before it is Reset */ - callers_frames[0][currCounter] = (float) Reset_WMOPS_counter(); - total += callers_frames[0][currCounter]; -#else - total += (float) Reset_WMOPS_counter(); -#endif - } - } - -#if MAX_CALLERS_SAVED_FRAMES - /* Keep Callers for this Worst Case Frame */ - /* Select Slot to Use (Slot 0 is the Current) */ - k = 0; - for ( i = k + 1; i < MAX_CALLERS_SAVED_FRAMES; i++ ) - { - /* Is it the Min? */ - if ( callers_totals[i] < callers_totals[k] ) - { /* Yes */ - k = i; - } - } - /* Current Greater than the Min? */ - if ( total > callers_totals[k] ) - { - k += 1; - /* Save Info of Callers */ - for ( i = 1; i <= maxCounter; i++ ) - { - callers_frames[k][i] = callers_frames[0][i]; - } - if ( i < MAXCOUNTERS ) - callers_frames[k][i] = -1; - /* Save Total */ - callers_totals[k - 1] = total; - /* Save Frame Number */ - callers_frames_nos[k - 1] = nbframe[0]; - } -#endif - if ( total < glob_bc[0] ) - { - glob_bc[0] = (Word32) total; - } - if ( total > glob_wc[0] ) - { - glob_wc[0] = (Word32) total; - } - /* Restore current counter */ - setCounter( current ); - - nbframe[0]++; -#endif /* if WMOPS */ -} - -void printStack( char *text, char *Id ) -{ -#ifdef WMOPS - int i; - if ( !Id ) - return; - if ( !strcmp( "*", Id ) || ( !strcmp( Id, objectName[currCounter] ) ) ) - { - printf( "%s %s", text, objectName[currCounter] ); - for ( i = sptr - 1; i > 0; i-- ) - { - printf( " <- %s", objectName[stack[i]] ); - } - printf( "\n" ); - } -#else - printf( "%s %s\n", text, Id ? Id : "(no name)" ); -#endif -} - -#ifdef WMOPS -void BASOP_push_wmops( const char *label ) -{ - int prev_counter; - int i, j; - - int label_hash; - label_hash = calc_hash( label ); - - /* check, if string matches (get new entry, if not) */ - i = lookup_table[label_hash]; - while ( i != -1 && strcmp( objectName[i], label ) != 0 ) - { - i = lookup_table[++label_hash]; - } - - prev_counter = readCounterId(); - - if ( i == -1 ) - { - /* create new entry */ - i = (int) getCounterId( label ); - lookup_table[label_hash] = i; - - setCounter( maxCounter ); - Init_WMOPS_counter(); - } - else - { - setCounter( i ); - } - - - /* Push current context onto stack */ - if ( currCounter >= 0 ) - { - if ( sptr >= MAX_STACK ) - { - fprintf( stderr, "\r push_wmops(): stack exceeded, try inreasing MAX_STACK\n" ); - exit( -1 ); - } - stack[sptr++] = prev_counter; - - /* Reset accumulated WMOPS */ - sum_stack[sptr] = 0; - - /* update call tree */ - for ( j = 0; j < MAXCOUNTERS; j++ ) - { - if ( call_tree[i][j] == prev_counter ) - { - break; - } - else if ( call_tree[i][j] == -1 ) - { - call_tree[i][j] = (Word16) prev_counter; - break; - } - } - } - - /*wmops[currCounter].start_selfcnt = ops_cnt; - wmops[currCounter].start_cnt = ops_cnt; - nbTimeObjectIsCalled[currCounter]++;*/ - - incrementNbTimeObjectIsCalled( currCounter ); - - sum_curr[currCounter] = 0; - -#ifdef DEBUG_COUNTER - printf( "Entering: %s\n", readCounterIdName() ); -#endif -} -#endif - -Word32 BASOP_pop_wmops( void ) -{ -#ifdef WMOPS - Word32 ops_cnt; - -#ifdef DEBUG_COUNTER - printf( "Exiting: %s\n", readCounterIdName() ); -#endif - - ops_cnt = fwc(); - - /* Get back previous context from stack */ - if ( sptr > 0 ) - { - int prevCounter; - - sum_stack[sptr] += ops_cnt; - prevCounter = currCounter; - setCounter( stack[--sptr] ); - sum_stack[sptr] += sum_stack[sptr + 1]; - sum_curr[prevCounter] += sum_stack[sptr + 1]; - } - else - { - /* current_record = -1; */ - setCounter( 0 ); - } - - if ( sum_curr[currCounter] > sum_wc[currCounter] ) - { - sum_wc[currCounter] = sum_curr[currCounter]; - } - if ( sum_curr[currCounter] < sum_bc[currCounter] ) - { - sum_bc[currCounter] = sum_curr[currCounter]; - } - - return ops_cnt; -#else /* if WMOPS */ - return 0; -#endif /* if WMOPS */ -} - -Word32 BASOP_get_wops( void ) -{ - return BASOP_pop_wmops(); -} - - -void WMOPS_destroy( void ) -{ -#ifdef WMOPS - int i; - - /* release the memory allocated for the objectName array */ - for ( i = 0; i < MAXCOUNTERS + 1; i++ ) - { - if ( NULL != objectName[i] ) - { - free( objectName[i] ); - objectName[i] = NULL; - } - } - - maxCounter = 0; -#endif - - return; -} - - -void WMOPS_output_all( Word16 dtx_mode ) -{ -#ifdef WMOPS - float ops_cnt = 0.0f; - int i; - - char *sfmts = "%-40s %8s %8s %7s %7s\n"; - char *dfmts = "%-40s %8.2f %8.3f %7.3f %7.3f\n"; - char *sfmt = "%-40s %8s %8s %7s %7s %7s %7s %7s\n"; - char *dfmt = "%-40s %8.2f %8.3f %7.3f %7.3f %7.3f %7.3f %7.3f\n"; - - /*fprintf (stderr, "\nInstruction Type Analysis (for worst case frame):\n\n");*/ - fprintf( stderr, "\nInstruction Type Analysis (for worst case frame number %ld):\n\n", (long int) nbframe[0] ); /* added -- JPA */ - for ( i = 0; i < (int) ( sizeof( BasicOperationList ) / sizeof( char * ) ); i++ ) - { - if ( ( (UWord32 *) &glob_multiCounter )[i] > 0 ) - fprintf( stderr, "\t%16s: %12d\n", BasicOperationList[i], ( (UWord32 *) &glob_multiCounter )[i] ); - } - - fprintf( stderr, "\n\nWeighted MOPS Analysis:\n" ); - fprintf( stderr, "%74s %23s\n", "|------ SELF ------|", "|--- CUMULATIVE ---|" ); - fprintf( stderr, sfmt, " routine", " calls", " min ", " max ", " avg ", " min ", " max ", " avg " ); - fprintf( stderr, sfmt, " ------------------------", " ------", "------", "------", "------", "------", "------", "------" ); - for ( i = 1; i <= maxCounter; i++ ) - { - if ( nbcalls[i] > 0 ) - { - fprintf( stderr, dfmt, - objectName[i], - ( nbframe[i] == 0 ) ? 0 : (float) nbcalls[i] / (float) nbframe[0], - ( glob_bc[i] == 0 ) ? 0 : frameRate * (float) glob_bc[i], - ( glob_wc[i] == 0 ) ? 0 : frameRate * (float) glob_wc[i], - ( nbframe[i] == 0 ) ? 0 : (float) total_wmops[i] / (float) nbframe[i], - frameRate * ( glob_sum_bc[i] ), - frameRate * ( glob_sum_wc[i] ), - ( nbframe[i] == 0 ) ? 0 : (float) ( total_sum[i] / (float) nbframe[i] ) ); - /* frameRate*(glob_bc[i]+wmops_children_bc[i]), */ - /* frameRate*(glob_wc[i]+wmops_children_wc[i]), */ - /* (nbframe[i] == 0) ? 0 : (float)((total_wmops[i] + total_wmops_children[i]) /(float)nbframe[i])); */ - } - ops_cnt += total_wmops[i]; - } - - fprintf( stderr, sfmts, " -----------------", " ------", "------", "------", "------" ); - if ( nbframe[i] > 0 ) - { - fprintf( stderr, dfmts, - "total", - (double) nbframe[0], - frameRate * glob_bc[0], - frameRate * glob_wc[0], - ( nbframe[0] == 0 ) ? 0 : ops_cnt / nbframe[0] ); - } - - (void) dtx_mode; - -#if MAX_CALLERS_SAVED_FRAMES - for ( i = 1; i <= MAX_CALLERS_SAVED_FRAMES; i++ ) - { - int j, k, l, m; - const char *frame_rank[] = { "st", "nd", "rd", "th" }; - float current; - - k = 0; - for ( j = k + 1; j < MAX_CALLERS_SAVED_FRAMES; j++ ) - { - /* Is it the Max? */ - if ( callers_totals[j] > callers_totals[k] ) - { /* Yes */ - k = j; - } - } - k += 1; - - fprintf( stderr, "\nActive Callers Report for %i%s Worst Case Frame #: %i\n", - i, i <= 3 ? frame_rank[i - 1] : frame_rank[3], - callers_frames_nos[k - 1] ); - /* Print up to 'MAX_CALLERS_PRINT' Callers */ - current = 0.0f; - for ( l = 0; l < MAX_CALLERS_PRINT; l++ ) - { - /* Find Highest Complexity */ - m = 1; - for ( j = m + 1; j <= maxCounter; j++ ) - { - if ( callers_frames[k][j] < 0 ) - break; - if ( callers_frames[k][j] > callers_frames[k][m] ) - m = j; - } - /* Done ? */ - if ( callers_frames[k][m] == 0 ) - break; - fprintf( stderr, " %-52s %10.3f\n", objectName[m], callers_frames[k][m] * frameRate ); - /* Count it */ - current += callers_frames[k][m]; - /* Mark as Done */ - callers_frames[k][m] = 0.0f; - } - /* Check if All Printed */ - if ( current + 0.001f < callers_totals[k - 1] ) - { - fprintf( stderr, " Only first %i Callers have been Printed!\n", MAX_CALLERS_PRINT ); - fprintf( stderr, " %-52s %10.3f\n", "Total for non Printed", ( callers_totals[k - 1] - current ) * frameRate ); - } - fprintf( stderr, " %-52s %10.3f\n", "Total", callers_totals[k - 1] * frameRate ); - /* Mark as Done */ - callers_totals[k - 1] = 0.0f; - } -#endif - WMOPS_destroy(); -#else - UNUSED_PARAM( dtx_mode ); -#endif /* if WMOPS */ -} -void WMOPS_output_all_std( Word16 dtx_mode ) -{ -#ifdef WMOPS - float ops_cnt = 0.0f; - int i; - - char *sfmts = "%-40s %8s %8s %7s %7s\n"; - char *dfmts = "%-40s %8.2f %8.3f %7.3f %7.3f\n"; - char *sfmt = "%-40s %8s %8s %7s %7s %7s %7s %7s\n"; - char *dfmt = "%-40s %8.2f %8.3f %7.3f %7.3f %7.3f %7.3f %7.3f\n"; - - /*fprintf (stdout, "\nInstruction Type Analysis (for worst case frame):\n\n");*/ - fprintf( stdout, "\nInstruction Type Analysis (for worst case frame number %ld):\n\n", (long int) nbframe[0] ); /* added -- JPA */ - if ( nbframe[0] > 0 ) - { - for ( i = 0; i < (int) ( sizeof( BasicOperationList ) / sizeof( char * ) ); i++ ) - { - if ( ( (UWord32 *) &glob_multiCounter )[i] > 0 ) - fprintf( stdout, "\t%16s: %12d\n", BasicOperationList[i], ( (UWord32 *) &glob_multiCounter )[i] ); - } - } - fprintf( stdout, "\n\nWeighted MOPS Analysis:\n" ); - fprintf( stdout, "%74s %23s\n", "|------ SELF ------|", "|--- CUMULATIVE ---|" ); - fprintf( stdout, sfmt, " routine", "calls/fr", " min ", " max ", " avg ", " min ", " max ", " avg " ); - fprintf( stdout, sfmt, " ------------------------", " ------", "------", "------", "------", "------", "------", "------" ); - for ( i = 1; i <= maxCounter; i++ ) - { - fprintf( stdout, dfmt, - objectName[i], - ( nbframe[i] == 0 ) ? 0 : (float) nbcalls[i] / (float) nbframe[0], - ( glob_bc[i] == MAX_32 ) ? 0 : frameRate * (float) glob_bc[i], - ( glob_wc[i] == 0 ) ? 0 : frameRate * (float) glob_wc[i], - ( nbframe[i] == 0 ) ? 0 : (float) total_wmops[i] / (float) nbframe[i], - ( glob_sum_bc[i] == MAX_32 ) ? 0 : frameRate * ( glob_sum_bc[i] ), - ( glob_sum_wc[i] == 0 ) ? 0 : frameRate * ( glob_sum_wc[i] ), - ( nbframe[i] == 0 ) ? 0 : (float) ( ( total_sum[i] ) / (float) nbframe[i] ) ); - /* frameRate*(glob_bc[i]+wmops_children_bc[i]), */ - /* frameRate*(glob_wc[i]+wmops_children_wc[i]), */ - /* (nbframe[i] == 0) ? 0 : (float)((total_sum[i]) /(float)nbframe[i])); */ - ops_cnt += total_wmops[i]; - } - - fprintf( stdout, sfmts, " -----------------", " ------", "------", "------", "------" ); - if ( nbframe[0] > 0 ) - { - fprintf( stdout, dfmts, - "total", - (double) nbframe[0], - frameRate * glob_bc[0], - frameRate * glob_wc[0], - ( nbframe[0] == 0 ) ? 0 : ops_cnt / nbframe[0] ); - } - - (void) dtx_mode; - - - WMOPS_destroy(); - -#else - UNUSED_PARAM( dtx_mode ); -#endif /* if WMOPS */ -} - - -void Reset_all_WMOPS_counter( void ) -{ -#ifdef WMOPS - int i; - int currCounterSave; - - currCounterSave = currCounter; - - for ( i = 2; i <= maxCounter; i++ ) - { - setCounter( i ); - Init_WMOPS_counter(); - objectName[i] = 0; - } - - currCounter = currCounterSave; - maxCounter = 1; -#endif /* if WMOPS */ -} - -/* Returns the total min/max/avg WMOPS values like printed in BASOP_end(). */ -void BASOP_get_total_wmops( double *min, double *max, double *avg ) -{ -#ifdef WMOPS - if ( min != NULL ) - *min = frameRate * glob_bc[0]; - if ( max != NULL ) - *max = frameRate * glob_wc[0]; - if ( avg != NULL ) - { - int i; - double ops_cnt = 0; - for ( i = 1; i <= maxCounter; i++ ) - ops_cnt += total_wmops[i]; - *avg = ( nbframe[0] == 0 ) ? 0 : ops_cnt / nbframe[0]; - } -#else - UNUSED_PARAM( min ); - UNUSED_PARAM( max ); - UNUSED_PARAM( avg ); -#endif /* if WMOPS */ -} -/* end of file */ -#undef WMC_TOOL_SKIP diff --git a/lib_com/count.h b/lib_com/count.h deleted file mode 100644 index b32733882..000000000 --- a/lib_com/count.h +++ /dev/null @@ -1,227 +0,0 @@ -/* - =========================================================================== - File: COUNT.H v.2.3 - 30.Nov.2009 - =========================================================================== - - ITU-T STL BASIC OPERATORS - - PROTOTYPES & DEFINITION FOR COUNTING OPERATIONS - - History - 09.Aug.1999 V1.0.0 Input to UGST from ETSI AMR (count.h); - - 26.Jan.2000 V1.1.0 Added counter entries for G.723.1's - L_mls(), div_l(), i_mult() [from basop32.c] - - 05.Jul.2000 V1.2.0 Added counter entries for 32bit shiftless - operators L_mult0(), L_mac0(), L_msu0() - - 03 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control - operators for the ITU-T Standard Tool Library as - described in Geneva, 20-30 January 2004 WP 3/16 Q10/16 - TD 11 document and subsequent discussions on the - wp3audio@yahoogroups.com email reflector. - March 06 v2.1 Changed to improve portability. - Dec 06 v2.2 Changed to specify frame rate using setFrameRate() - Adding WMOPS_output_avg() for global average computation - L_mls() weight of 5. - div_l() weight of 32. - i_mult() weight of 3. - ============================================================================ -*/ - - -/****************************************************************************** - * Functions for counting operations. - * - * These functions make it possible to measure the wMOPS of a codec. - * - * All functions in this file, and in other *.h files, update a structure so - * that it will be possible to track how many calls to add(), sub(), L_mult() - * ... was made by the code and to estimate the wMOPS (and MIPS) for a certain - * part of the code. - * - * It is also possible to measure the wMOPS separatly for different parts - * of the codec. - * - * This is done by creating a counter group (getCounterId) for each part of - * the code that one wants a seperate measure for. Before a part of the code - * is executed a call to the "setCounter" function is needed to identify - * which counter group to use. - * - * Currently there is a limit of 255 different counter groups. - * - * In the end of this file, there is a piece of code illustrating how the - * functions can be used. - * - ******************************************************************************/ - - -#ifndef _COUNT_H -#define _COUNT_H "$Id$" - -#include - -int calc_hash( const char *str ); - -int getCounterId( const char *objectName ); -/* - * Create a counter group, the "objectname" will be used when printing - * statistics for this counter group. - * - * Returns 0 if no more counter groups are available. - */ - - -int readCounterId( void ); -/* - * Returns the current CounterId. - */ - - -void setCounter( int counterId ); -/* - * Defines which counter group to use, default is zero. - */ - - -char *readCounterIdName( void ); -/* - * Returns the current CounterId name. - */ -void printStack( char *text, char *Id ); -/* - * print stack - * text: Any text to print initially - * Id: NULL, if no prints are wanted - * "*", if all prints are wanted (default) - * "pitch_ol" or any other function name - */ - -void incrementNbTimeObjectIsCalled( int counterId ); -/* - * This function enables to increment by 1 a counter - * tracking the number of times the application enters a groups of functions. - * If the counterId is not refering to a defined function counter group, then it is - * the default function group (0) which is impacted. - * - */ - - -void ClearNbTimeObjectsAreCalled( void ); -/* - * This function enables to clear to 0 all the counters enabling to - * track the number of times the application enters any groups of functions. - */ - - -void Init_WMOPS_counter( void ); -/* - * Initiates the current counter group. - */ - - -Word32 Reset_WMOPS_counter( void ); -/* - * Resets the current counter group. - */ - - -void WMOPS_output( Word16 notPrintWorstWorstCase ); -/* - * Prints the statistics to the screen, if the argument is non zero - * the statistics for worst worst case will not be printed. This is typically - * done for dtx frames. - * - */ - -void WMOPS_output_avg( Word16 dtx_mode, Word32 *tot_wm, Word32 *num_frames ); -/* - * same as WMOPS_output + returns the total wmops counter and the number of frames - * to support the computation of global average. - * - */ - - - - -void setFrameRate( int samplingFreq, int frameLength ); -/* - * This function can overwrite the value of the frameRate variable that is - * initialized by the FRAME_RATE constant. - */ - - - - - -/* Global counter variable for calculation of complexity weight */ - - -void generic_WMOPS_output( Word16 notPrintWorstWorstCase, char *test_file_name ); -/* - * This function enable to append : - * - to WMOPS_DATA_FILENAME file, the WMOPS information related - * to the execution of the application, function group by function - * group. - * - to CODE_PROFILE_FILENAME file, the WMOPS information related - * to the execution of the application, basic operation by basic - * operation. - * - to WMOPS_TOTAL_FILENAME file, the total WMOPS information related - * to the execution of the application. - * - * Note that : - * if the files exists, the data will be written at the end of file. - * - * test_file_name : Is a character string referencing each calls to - * generic_WMOPS_output(). Usually, it is the name of a test - * sequence file. - * - * notPrintWorstWorstCase : Same usage as in WMOPS_output(). - */ -void WMOPS_output_all( Word16 dtx_mode ); -void WMOPS_output_all_std( Word16 dtx_mode ); - -/* - * free all allocated counter memory - */ -void WMOPS_destroy( void ); - -/* jdr 20120117: add FLC similar functions */ -/* mul 20130729: set BASOP_COUNT_SUBROUTINES to count on a per-BASOP_sub_start()/BASOP_sub_end() base; - otherwise, count only between BASOP_push_wmops(), BASOP_push_wmops() */ -#define BASOP_COUNT_SUBROUTINES -void BASOP_push_wmops( const char *label ); -Word32 BASOP_pop_wmops( void ); - -#ifdef BASOP_COUNT_SUBROUTINES -#define BASOP_sub_start( label ) \ - { \ - BASOP_push_wmops( label ); \ - } -#define BASOP_sub_end() \ - { \ - BASOP_pop_wmops(); \ - } -#else -#define BASOP_sub_start( label ) -#define BASOP_sub_end() -#endif - -void BASOP_frame_update( void ); -void Reset_all_WMOPS_counter( void ); - -Word32 BASOP_get_wops( void ); - -/*! Returns the total min/max/avg WMOPS values like printed in BASOP_end(). */ -void BASOP_get_total_wmops( double *min, double *max, double *avg ); - - -#define SUB_WMOPS_INIT( label ) BASOP_sub_start( label ) -#define END_SUB_WMOPS BASOP_sub_end() - - -#endif /* _COUNT_H */ - - -/* end of file */ diff --git a/lib_com/enh1632.c b/lib_com/enh1632.c index d4e9f9b59..859562c94 100644 --- a/lib_com/enh1632.c +++ b/lib_com/enh1632.c @@ -58,11 +58,6 @@ #define WMC_TOOL_SKIP -#ifdef WMOPS -extern int currCounter; -#endif /* ifdef WMOPS */ - - /***************************************************************************** * * Constants and Globals diff --git a/lib_com/hq2_noise_inject_fx.c b/lib_com/hq2_noise_inject_fx.c index 12bedd1fb..c37ae1236 100644 --- a/lib_com/hq2_noise_inject_fx.c +++ b/lib_com/hq2_noise_inject_fx.c @@ -35,7 +35,6 @@ #include "prot_fx.h" #include "oper_32b.h" #include "move.h" -#include "count.h" /*--------------------------------------------------------------------------* * hq2_noise_inject() diff --git a/lib_com/options.h b/lib_com/options.h index ef08dee7c..75c508d36 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -64,7 +64,6 @@ #define ENH_U_32_BIT_OPERATOR #define COMPLEX_OPERATOR -#define CONTROL_CODE_OPS #define ENH_32_BIT_OPERATOR #define ENH_64_BIT_OPERATOR #if !defined BASOP_NOGLOB_DEV_USE_GLOBALS diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index 8d038b7b3..fa2b6f4a5 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -28,8 +28,6 @@ #include "options.h" #include "wmc_auto.h" -#include "typedef.h" -#include "count.h" #define WMC_TOOL_SKIP /* Skip the instrumentation of this file, if invoked by accident */ @@ -79,7 +77,7 @@ double ops_cnt_wmc; double prom_cnt_wmc; double inst_cnt[NUM_INST]; -static wmops_record* wmops = NULL; +static wmops_record *wmops = NULL; static int num_wmops_records, max_num_wmops_records; static int current_record; static long update_cnt; @@ -91,18 +89,16 @@ static long fnum_cnt_wc; static int *wmops_caller_stack = NULL, wmops_caller_stack_index, max_wmops_caller_stack_index = 0; static int *heap_allocation_call_tree = NULL, heap_allocation_call_tree_size = 0, heap_allocation_call_tree_max_size = 0; +BASIC_OP *multiCounter = NULL; +int currCounter = 0; int funcId_where_last_call_to_else_occurred; long funcid_total_wmops_at_last_call_to_else; int call_occurred = 1; -long LastWOper[MAXCOUNTERS]; /* !!!!! shall be replaced with wmops.LastWOper !!!!! */ -Word32 bc[MAXCOUNTERS][NbFuncMax], wc[MAXCOUNTERS][NbFuncMax]; -Word32 funcid[MAXCOUNTERS]; -BASIC_OP multiCounter[MAXCOUNTERS]; void reset_wmops( void ) { int i, j; - //unsigned int *ptr; + unsigned int *ptr; num_wmops_records = 0; max_num_wmops_records = MAX_NUM_RECORDS; @@ -127,27 +123,27 @@ void reset_wmops( void ) } /* allocate the list of BASOP WMOPS records */ - //if ( multiCounter == NULL ) - //{ - // multiCounter = (BASIC_OP *) malloc( max_num_wmops_records * sizeof( BASIC_OP ) ); - //} + if ( multiCounter == NULL ) + { + multiCounter = (BASIC_OP *) malloc( max_num_wmops_records * sizeof( BASIC_OP ) ); + } - //if ( multiCounter == NULL ) - //{ - // fprintf( stderr, "Error: Unable to Allocate the BASOP WMOPS counter!" ); - // exit( -1 ); - //} + if ( multiCounter == NULL ) + { + fprintf( stderr, "Error: Unable to Allocate the BASOP WMOPS counter!" ); + exit( -1 ); + } //BASOP_init - setFrameRate( 32000, 640 ); - Init_WMOPS_counter(); /* 20ms frames */ + //setFrameRate( 32000, 640 ); + //Init_WMOPS_counter(); /* 20ms frames */ - for ( i = 0; i < MAX_HASH_TABLE_SIZE; i++ ) - { - lookup_table[i] = -1; - } + //for ( i = 0; i < MAX_HASH_TABLE_SIZE; i++ ) + //{ + // lookup_table[i] = -1; + //} /* initilize the list of WMOPS records */ /* initilize the BASOP WMOPS counters */ @@ -178,11 +174,11 @@ void reset_wmops( void ) #endif /* clear all BASOP operation counters */ - //ptr = (unsigned int *) &multiCounter[i]; - //for ( j = 0; j < (int) ( sizeof( BASIC_OP ) / sizeof( unsigned int ) ); j++ ) - //{ - // *ptr++ = 0; - //} + ptr = (unsigned int *) &multiCounter[i]; + for ( j = 0; j < (int) ( sizeof( BASIC_OP ) / sizeof( unsigned int ) ); j++ ) + { + *ptr++ = 0; + } wmops[i].LastWOper = 0; } @@ -206,8 +202,8 @@ void reset_wmops( void ) } /* initialize auxiliary BASOP WMOPS variables */ - //call_occurred = 1; - //funcId_where_last_call_to_else_occurred = INT_MAX; + call_occurred = 1; + funcId_where_last_call_to_else_occurred = INT_MAX; return; } @@ -216,7 +212,7 @@ void push_wmops_fct( const char *label, ... ) { int new_flag; int i, j, index_record; - //unsigned int *ptr; + unsigned int *ptr; va_list arg; char func_name[MAX_FUNCTION_NAME_LENGTH] = ""; @@ -249,7 +245,7 @@ void push_wmops_fct( const char *label, ... ) /* There is no room for a new WMOPS record -> reallocate the list */ max_num_wmops_records += MAX_NUM_RECORDS_REALLOC_STEP; wmops = realloc( wmops, max_num_wmops_records * sizeof( wmops_record ) ); - //multiCounter = realloc( multiCounter, max_num_wmops_records * sizeof( BASIC_OP ) ); + multiCounter = realloc( multiCounter, max_num_wmops_records * sizeof( BASIC_OP ) ); /* initilize newly created WMOPS records */ for ( i = num_wmops_records; i < max_num_wmops_records; i++ ) @@ -279,11 +275,11 @@ void push_wmops_fct( const char *label, ... ) #endif /* initialize BASOP WMOPS counters */ - //ptr = (unsigned int *) &multiCounter[i]; - //for ( j = 0; j < (int) ( sizeof( BASIC_OP ) / sizeof( unsigned int ) ); j++ ) - //{ - // *ptr++ = 0; - //} + ptr = (unsigned int *) &multiCounter[i]; + for ( j = 0; j < (int) ( sizeof( BASIC_OP ) / sizeof( unsigned int ) ); j++ ) + { + *ptr++ = 0; + } wmops[i].LastWOper = 0; } } @@ -332,9 +328,7 @@ void push_wmops_fct( const char *label, ... ) #endif /* set the ID of BASOP functions counters */ - //Set_BASOP_WMOPS_counter( index_record ); - - BASOP_push_wmops( func_name ); + Set_BASOP_WMOPS_counter( index_record ); return; } @@ -342,7 +336,7 @@ void push_wmops_fct( const char *label, ... ) void pop_wmops( void ) { - //long tot; + long tot; /* Check for underflow */ if ( current_record < 0 ) @@ -352,8 +346,8 @@ void pop_wmops( void ) } /* add the BASOP complexity to the counter */ - //tot = DeltaWeightedOperation(); - //ops_cnt_wmc += tot; + tot = DeltaWeightedOperation(); + ops_cnt_wmc += tot; /* update count of current record */ wmops[current_record].current_selfcnt += ops_cnt_wmc - wmops[current_record].start_selfcnt; @@ -366,15 +360,13 @@ void pop_wmops( void ) wmops[current_record].start_selfcnt = ops_cnt_wmc; /* set the ID of the previous BASOP counter */ - //Set_BASOP_WMOPS_counter( current_record ); + Set_BASOP_WMOPS_counter( current_record ); } else { current_record = -1; } - BASOP_pop_wmops(); - return; } @@ -467,8 +459,8 @@ void update_wmops( void ) #endif /* update the WC of all BASOP counters */ - //Set_BASOP_WMOPS_counter( i ); - //Reset_BASOP_WMOPS_counter(); + Set_BASOP_WMOPS_counter( i ); + Reset_BASOP_WMOPS_counter(); } current_cnt = ops_cnt_wmc - start_cnt; @@ -499,187 +491,181 @@ void update_wmops( void ) /* increment frame counter */ update_cnt++; - BASOP_frame_update(); - return; } void print_wmops( void ) { - //int i, label_len, max_label_len; + int i, label_len, max_label_len; - //char *sfmts = "%*s %8s %8s %7s %7s\n"; - //char *dfmts = "%*s %8.2f %8.3f %7.3f %7.3f\n"; - //char *sfmt = "%*s %8s %8s %7s %7s %7s %7s %7s\n"; - //char *dfmt = "%*s %8.2f %8.3f %7.3f %7.3f %7.3f %7.3f %7.3f\n"; + char *sfmts = "%*s %8s %8s %7s %7s\n"; + char *dfmts = "%*s %8.2f %8.3f %7.3f %7.3f\n"; + char *sfmt = "%*s %8s %8s %7s %7s %7s %7s %7s\n"; + char *dfmt = "%*s %8.2f %8.3f %7.3f %7.3f %7.3f %7.3f %7.3f\n"; - WMOPS_output_all_std( 0 ); - WMOPS_destroy(); - return; +#ifdef WMOPS_WC_FRAME_ANALYSIS + int j; + char *sfmtt = "%20s %4s %15s\n"; + char *dfmtt = "%20s %4d "; +#endif + + /* calculate maximum label length for compact prinout */ + max_label_len = 0; + for ( i = 0; i < num_wmops_records; i++ ) + { + label_len = strlen( wmops[i].label ); + if ( label_len > max_label_len ) + { + max_label_len = label_len; + } + } + max_label_len += 4; + + fprintf( stdout, "\n\n --- Complexity analysis [WMOPS] --- \n\n" ); + + fprintf( stdout, "%*s %33s %23s\n", max_label_len, "", "|------ SELF ------|", "|--- CUMULATIVE ---|" ); + fprintf( stdout, sfmt, max_label_len, " routine", " calls", " min ", " max ", " avg ", " min ", " max ", " avg " ); + fprintf( stdout, sfmt, max_label_len, "---------------", "------", "------", "------", "------", "------", "------", "------" ); + + for ( i = 0; i < num_wmops_records; i++ ) + { + fprintf( stdout, dfmt, max_label_len, wmops[i].label, update_cnt == 0 ? 0 : (float) wmops[i].call_number / update_cnt, + wmops[i].min_selfcnt == DOUBLE_MAX ? 0 : FAC * wmops[i].min_selfcnt, + FAC * wmops[i].max_selfcnt, + wmops[i].update_cnt == 0 ? 0 : FAC * wmops[i].tot_selfcnt / wmops[i].update_cnt, + wmops[i].min_cnt == DOUBLE_MAX ? 0 : FAC * wmops[i].min_cnt, + FAC * wmops[i].max_cnt, + wmops[i].update_cnt == 0 ? 0 : FAC * wmops[i].tot_cnt / wmops[i].update_cnt ); + } -//#ifdef WMOPS_WC_FRAME_ANALYSIS -// int j; -// char *sfmtt = "%20s %4s %15s\n"; -// char *dfmtt = "%20s %4d "; -//#endif - -// /* calculate maximum label length for compact prinout */ -// max_label_len = 0; -// for ( i = 0; i < num_wmops_records; i++ ) -// { -// label_len = strlen( wmops[i].label ); -// if ( label_len > max_label_len ) -// { -// max_label_len = label_len; -// } -// } -// max_label_len += 4; -// -// fprintf( stdout, "\n\n --- Complexity analysis [WMOPS] --- \n\n" ); -// -// fprintf( stdout, "%*s %33s %23s\n", max_label_len, "", "|------ SELF ------|", "|--- CUMULATIVE ---|" ); -// fprintf( stdout, sfmt, max_label_len, " routine", " calls", " min ", " max ", " avg ", " min ", " max ", " avg " ); -// fprintf( stdout, sfmt, max_label_len, "---------------", "------", "------", "------", "------", "------", "------", "------" ); -// -// for ( i = 0; i < num_wmops_records; i++ ) -// { -// fprintf( stdout, dfmt, max_label_len, wmops[i].label, update_cnt == 0 ? 0 : (float) wmops[i].call_number / update_cnt, -// wmops[i].min_selfcnt == DOUBLE_MAX ? 0 : FAC * wmops[i].min_selfcnt, -// FAC * wmops[i].max_selfcnt, -// wmops[i].update_cnt == 0 ? 0 : FAC * wmops[i].tot_selfcnt / wmops[i].update_cnt, -// wmops[i].min_cnt == DOUBLE_MAX ? 0 : FAC * wmops[i].min_cnt, -// FAC * wmops[i].max_cnt, -// wmops[i].update_cnt == 0 ? 0 : FAC * wmops[i].tot_cnt / wmops[i].update_cnt ); -// } -// -// fprintf( stdout, sfmts, max_label_len, "---------------", "------", "------", "------", "------" ); -// fprintf( stdout, dfmts, max_label_len, "total", (float) update_cnt, update_cnt == 0 ? 0 : FAC * min_cnt, FAC * max_cnt, update_cnt == 0 ? 0 : FAC * ops_cnt_wmc / update_cnt ); -// fprintf( stdout, "\n" ); -// -//#ifdef WMOPS_WC_FRAME_ANALYSIS -// fprintf( stdout, "\nComplexity analysis for the worst-case frame %ld:\n\n", fnum_cnt_wc ); -// fprintf( stdout, "%*s %8s %10s %12s\n", max_label_len, " routine", " calls", " SELF", " CUMULATIVE" ); -// fprintf( stdout, "%*s %8s %10s %10s\n", max_label_len, "---------------", "------", "------", "----------" ); -// -// for ( i = 0; i < num_wmops_records; i++ ) -// { -// if ( wmops[i].wc_call_number > 0 ) -// { -// fprintf( stdout, "%*s %8d %10.3f %12.3f\n", max_label_len, wmops[i].label, wmops[i].wc_call_number, FAC * wmops[i].wc_selfcnt, FAC * wmops[i].wc_cnt ); -// } -// } -// -// fprintf( stdout, "\nCall tree for the worst-case frame %ld:\n\n", fnum_cnt_wc ); -// fprintf( stdout, sfmtt, " function", "num", "called by " ); -// fprintf( stdout, sfmtt, "---------------", "---", "--------------" ); -// -// for ( i = 0; i < num_wmops_records; i++ ) -// { -// if ( wmops[i].wc_call_number > 0 ) -// { -// fprintf( stdout, dfmtt, wmops[i].label, i ); -// for ( j = 0; wmops[i].call_tree[j] != -1 && j < MAX_CALL_TREE_DEPTH; j++ ) -// { -// if ( j != 0 ) -// { -// fprintf( stdout, ", " ); -// } -// fprintf( stdout, "%d", wmops[i].call_tree[j] ); -// } -// fprintf( stdout, "\n" ); -// } -// } -// -// fprintf( stdout, "\n\n" ); -// -// fprintf( stdout, "\nInstruction type analysis for the worst-case frame %ld:\n\n", fnum_cnt_wc ); -// for ( i = 0; i < NUM_INST; i++ ) -// { -// switch ( (enum instructions) i ) -// { -// case _ADD: -// fprintf( stdout, "\tAdds: %12.1f\n", inst_cnt_wc[i] ); -// break; -// case _ABS: -// fprintf( stdout, "\tAbsolutes: %12.1f\n", inst_cnt_wc[i] ); -// break; -// case _MULT: -// fprintf( stdout, "\tMultiplies: %12.1f\n", inst_cnt_wc[i] ); -// break; -// case _MAC: -// fprintf( stdout, "\tMACs: %12.1f\n", inst_cnt_wc[i] ); -// break; -// case _MOVE: -// fprintf( stdout, "\tMoves: %12.1f\n", inst_cnt_wc[i] ); -// break; -// case _STORE: -// fprintf( stdout, "\tStores: %12.1f\n", inst_cnt_wc[i] ); -// break; -// case _LOGIC: -// fprintf( stdout, "\tLogicals: %12.1f\n", inst_cnt_wc[i] ); -// break; -// case _SHIFT: -// fprintf( stdout, "\tShifts: %12.1f\n", inst_cnt_wc[i] ); -// break; -// case _BRANCH: -// fprintf( stdout, "\tBranches: %12.1f\n", inst_cnt_wc[i] ); -// break; -// case _DIV: -// fprintf( stdout, "\tDivisions: %12.1f\n", inst_cnt_wc[i] ); -// break; -// case _SQRT: -// fprintf( stdout, "\tSquare Root: %12.1f\n", inst_cnt_wc[i] ); -// break; -// case _TRANS: -// fprintf( stdout, "\tTrans: %12.1f\n", inst_cnt_wc[i] ); -// break; -// case _FUNC: -// fprintf( stdout, "\tFunc Call: %12.1f\n", inst_cnt_wc[i] ); -// break; -// case _LOOP: -// fprintf( stdout, "\tLoop Init: %12.1f\n", inst_cnt_wc[i] ); -// break; -// case _INDIRECT: -// fprintf( stdout, "\tIndirect Addr: %12.1f\n", inst_cnt_wc[i] ); -// break; -// case _PTR_INIT: -// fprintf( stdout, "\tPointer Init: %12.1f\n", inst_cnt_wc[i] ); -// break; -// case _TEST: -// fprintf( stdout, "\tExtra condit.: %12.1f\n", inst_cnt_wc[i] ); -// break; -// case _POWER: -// fprintf( stdout, "\tExponential: %12.1f\n", inst_cnt_wc[i] ); -// break; -// case _LOG: -// fprintf( stdout, "\tLogarithm: %12.1f\n", inst_cnt_wc[i] ); -// break; -// case _MISC: -// fprintf( stdout, "\tAll other op.: %12.1f\n", inst_cnt_wc[i] ); -// break; -// default: -// fprintf( stdout, "\tERROR: Invalid instruction type: %d\n\n", i ); -// } -// } -//#endif -// -// /* De-allocate the list of wmops record */ -// if ( wmops != NULL ) -// { -// free( wmops ); -// } -// -// /* De-allocate the list of wmops caller functions */ -// if ( wmops_caller_stack != NULL ) -// { -// free( wmops_caller_stack ); -// } -// -// /* De-allocate the BASOP WMOPS counter */ -// //if ( multiCounter != NULL ) -// //{ -// // free( multiCounter ); -// //} + fprintf( stdout, sfmts, max_label_len, "---------------", "------", "------", "------", "------" ); + fprintf( stdout, dfmts, max_label_len, "total", (float) update_cnt, update_cnt == 0 ? 0 : FAC * min_cnt, FAC * max_cnt, update_cnt == 0 ? 0 : FAC * ops_cnt_wmc / update_cnt ); + fprintf( stdout, "\n" ); + +#ifdef WMOPS_WC_FRAME_ANALYSIS + fprintf( stdout, "\nComplexity analysis for the worst-case frame %ld:\n\n", fnum_cnt_wc ); + fprintf( stdout, "%*s %8s %10s %12s\n", max_label_len, " routine", " calls", " SELF", " CUMULATIVE" ); + fprintf( stdout, "%*s %8s %10s %10s\n", max_label_len, "---------------", "------", "------", "----------" ); + + for ( i = 0; i < num_wmops_records; i++ ) + { + if ( wmops[i].wc_call_number > 0 ) + { + fprintf( stdout, "%*s %8d %10.3f %12.3f\n", max_label_len, wmops[i].label, wmops[i].wc_call_number, FAC * wmops[i].wc_selfcnt, FAC * wmops[i].wc_cnt ); + } + } + + fprintf( stdout, "\nCall tree for the worst-case frame %ld:\n\n", fnum_cnt_wc ); + fprintf( stdout, sfmtt, " function", "num", "called by " ); + fprintf( stdout, sfmtt, "---------------", "---", "--------------" ); + + for ( i = 0; i < num_wmops_records; i++ ) + { + if ( wmops[i].wc_call_number > 0 ) + { + fprintf( stdout, dfmtt, wmops[i].label, i ); + for ( j = 0; wmops[i].call_tree[j] != -1 && j < MAX_CALL_TREE_DEPTH; j++ ) + { + if ( j != 0 ) + { + fprintf( stdout, ", " ); + } + fprintf( stdout, "%d", wmops[i].call_tree[j] ); + } + fprintf( stdout, "\n" ); + } + } + + fprintf( stdout, "\n\n" ); + + fprintf( stdout, "\nInstruction type analysis for the worst-case frame %ld:\n\n", fnum_cnt_wc ); + for ( i = 0; i < NUM_INST; i++ ) + { + switch ( (enum instructions) i ) + { + case _ADD: + fprintf( stdout, "\tAdds: %12.1f\n", inst_cnt_wc[i] ); + break; + case _ABS: + fprintf( stdout, "\tAbsolutes: %12.1f\n", inst_cnt_wc[i] ); + break; + case _MULT: + fprintf( stdout, "\tMultiplies: %12.1f\n", inst_cnt_wc[i] ); + break; + case _MAC: + fprintf( stdout, "\tMACs: %12.1f\n", inst_cnt_wc[i] ); + break; + case _MOVE: + fprintf( stdout, "\tMoves: %12.1f\n", inst_cnt_wc[i] ); + break; + case _STORE: + fprintf( stdout, "\tStores: %12.1f\n", inst_cnt_wc[i] ); + break; + case _LOGIC: + fprintf( stdout, "\tLogicals: %12.1f\n", inst_cnt_wc[i] ); + break; + case _SHIFT: + fprintf( stdout, "\tShifts: %12.1f\n", inst_cnt_wc[i] ); + break; + case _BRANCH: + fprintf( stdout, "\tBranches: %12.1f\n", inst_cnt_wc[i] ); + break; + case _DIV: + fprintf( stdout, "\tDivisions: %12.1f\n", inst_cnt_wc[i] ); + break; + case _SQRT: + fprintf( stdout, "\tSquare Root: %12.1f\n", inst_cnt_wc[i] ); + break; + case _TRANS: + fprintf( stdout, "\tTrans: %12.1f\n", inst_cnt_wc[i] ); + break; + case _FUNC: + fprintf( stdout, "\tFunc Call: %12.1f\n", inst_cnt_wc[i] ); + break; + case _LOOP: + fprintf( stdout, "\tLoop Init: %12.1f\n", inst_cnt_wc[i] ); + break; + case _INDIRECT: + fprintf( stdout, "\tIndirect Addr: %12.1f\n", inst_cnt_wc[i] ); + break; + case _PTR_INIT: + fprintf( stdout, "\tPointer Init: %12.1f\n", inst_cnt_wc[i] ); + break; + case _TEST: + fprintf( stdout, "\tExtra condit.: %12.1f\n", inst_cnt_wc[i] ); + break; + case _POWER: + fprintf( stdout, "\tExponential: %12.1f\n", inst_cnt_wc[i] ); + break; + case _LOG: + fprintf( stdout, "\tLogarithm: %12.1f\n", inst_cnt_wc[i] ); + break; + case _MISC: + fprintf( stdout, "\tAll other op.: %12.1f\n", inst_cnt_wc[i] ); + break; + default: + fprintf( stdout, "\tERROR: Invalid instruction type: %d\n\n", i ); + } + } +#endif + + /* De-allocate the list of wmops record */ + if ( wmops != NULL ) + { + free( wmops ); + } + + /* De-allocate the list of wmops caller functions */ + if ( wmops_caller_stack != NULL ) + { + free( wmops_caller_stack ); + } + + /* De-allocate the BASOP WMOPS counter */ + if ( multiCounter != NULL ) + { + free( multiCounter ); + } return; } @@ -719,8 +705,8 @@ void print_wmops( void ) #define MAGIC_VALUE_OOB 0x12A534F0 /* Signature value which is inserted before and after each allocated memory block, used to detect out-of-bound access */ #define MAGIC_VALUE_USED ( ~MAGIC_VALUE_OOB ) /* Value used to pre-fill allocated memory blocks, used to calculate actual memory usage */ -#define OOB_START 0x1 /* Flag indicating out-of-bounds access before memory block */ -#define OOB_END 0x2 /* Flag indicating out-of-bounds access after memory block */ +#define OOB_START 0x1 /* int indicating out-of-bounds access before memory block */ +#define OOB_END 0x2 /* int indicating out-of-bounds access after memory block */ #define ROUND_BLOCK_SIZE( n ) ( ( ( n ) + BLOCK_ROUNDING - 1 ) & ~( BLOCK_ROUNDING - 1 ) ) #define IS_CALLOC( str ) ( str[0] == 'c' ) @@ -2146,7 +2132,7 @@ void print_mem( ROM_Size_Lookup_Table Const_Data_PROM_Table[] ) #endif /* WMOPS */ -const BASIC_OP op_weight = { +BASIC_OP op_weight = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -2207,9 +2193,9 @@ const BASIC_OP op_weight = { #ifdef CONTROL_CODE_OPS -Flag LT_16( Word16 var1, Word16 var2 ) +int LT_16( short var1, short var2 ) { - Flag F_ret = 0; + int F_ret = 0; if ( var1 < var2 ) { @@ -2221,9 +2207,9 @@ Flag LT_16( Word16 var1, Word16 var2 ) return F_ret; } -Flag GT_16( Word16 var1, Word16 var2 ) +int GT_16( short var1, short var2 ) { - Flag F_ret = 0; + int F_ret = 0; if ( var1 > var2 ) { @@ -2235,9 +2221,9 @@ Flag GT_16( Word16 var1, Word16 var2 ) return F_ret; } -Flag LE_16( Word16 var1, Word16 var2 ) +int LE_16( short var1, short var2 ) { - Flag F_ret = 0; + int F_ret = 0; if ( var1 <= var2 ) { @@ -2249,9 +2235,9 @@ Flag LE_16( Word16 var1, Word16 var2 ) return F_ret; } -Flag GE_16( Word16 var1, Word16 var2 ) +int GE_16( short var1, short var2 ) { - Flag F_ret = 0; + int F_ret = 0; if ( var1 >= var2 ) { @@ -2263,9 +2249,9 @@ Flag GE_16( Word16 var1, Word16 var2 ) return F_ret; } -Flag EQ_16( Word16 var1, Word16 var2 ) +int EQ_16( short var1, short var2 ) { - Flag F_ret = 0; + int F_ret = 0; if ( var1 == var2 ) { @@ -2277,9 +2263,9 @@ Flag EQ_16( Word16 var1, Word16 var2 ) return F_ret; } -Flag NE_16( Word16 var1, Word16 var2 ) +int NE_16( short var1, short var2 ) { - Flag F_ret = 0; + int F_ret = 0; if ( var1 != var2 ) { @@ -2291,9 +2277,9 @@ Flag NE_16( Word16 var1, Word16 var2 ) return F_ret; } -Flag LT_32( Word32 L_var1, Word32 L_var2 ) +int LT_32( int L_var1, int L_var2 ) { - Flag F_ret = 0; + int F_ret = 0; if ( L_var1 < L_var2 ) { @@ -2305,9 +2291,9 @@ Flag LT_32( Word32 L_var1, Word32 L_var2 ) return F_ret; } -Flag GT_32( Word32 L_var1, Word32 L_var2 ) +int GT_32( int L_var1, int L_var2 ) { - Flag F_ret = 0; + int F_ret = 0; if ( L_var1 > L_var2 ) { @@ -2319,9 +2305,9 @@ Flag GT_32( Word32 L_var1, Word32 L_var2 ) return F_ret; } -Flag LE_32( Word32 L_var1, Word32 L_var2 ) +int LE_32( int L_var1, int L_var2 ) { - Flag F_ret = 0; + int F_ret = 0; if ( L_var1 <= L_var2 ) { @@ -2333,9 +2319,9 @@ Flag LE_32( Word32 L_var1, Word32 L_var2 ) return F_ret; } -Flag GE_32( Word32 L_var1, Word32 L_var2 ) +int GE_32( int L_var1, int L_var2 ) { - Flag F_ret = 0; + int F_ret = 0; if ( L_var1 >= L_var2 ) { @@ -2347,9 +2333,9 @@ Flag GE_32( Word32 L_var1, Word32 L_var2 ) return F_ret; } -Flag EQ_32( Word32 L_var1, Word32 L_var2 ) +int EQ_32( int L_var1, int L_var2 ) { - Flag F_ret = 0; + int F_ret = 0; if ( L_var1 == L_var2 ) { @@ -2361,9 +2347,9 @@ Flag EQ_32( Word32 L_var1, Word32 L_var2 ) return F_ret; } -Flag NE_32( Word32 L_var1, Word32 L_var2 ) +int NE_32( int L_var1, int L_var2 ) { - Flag F_ret = 0; + int F_ret = 0; if ( L_var1 != L_var2 ) { @@ -2375,9 +2361,9 @@ Flag NE_32( Word32 L_var1, Word32 L_var2 ) return F_ret; } -Flag LT_64( Word64 L64_var1, Word64 L64_var2 ) +int LT_64( long long int L64_var1, long long int L64_var2 ) { - Flag F_ret = 0; + int F_ret = 0; if ( L64_var1 < L64_var2 ) { @@ -2389,9 +2375,9 @@ Flag LT_64( Word64 L64_var1, Word64 L64_var2 ) return F_ret; } -Flag GT_64( Word64 L64_var1, Word64 L64_var2 ) +int GT_64( long long int L64_var1, long long int L64_var2 ) { - Flag F_ret = 0; + int F_ret = 0; if ( L64_var1 > L64_var2 ) { @@ -2403,9 +2389,9 @@ Flag GT_64( Word64 L64_var1, Word64 L64_var2 ) return F_ret; } -Flag LE_64( Word64 L64_var1, Word64 L64_var2 ) +int LE_64( long long int L64_var1, long long int L64_var2 ) { - Flag F_ret = 0; + int F_ret = 0; if ( L64_var1 <= L64_var2 ) { @@ -2416,9 +2402,9 @@ Flag LE_64( Word64 L64_var1, Word64 L64_var2 ) #endif return F_ret; } -Flag GE_64( Word64 L64_var1, Word64 L64_var2 ) +int GE_64( long long int L64_var1, long long int L64_var2 ) { - Flag F_ret = 0; + int F_ret = 0; if ( L64_var1 >= L64_var2 ) { @@ -2430,9 +2416,9 @@ Flag GE_64( Word64 L64_var1, Word64 L64_var2 ) return F_ret; } -Flag EQ_64( Word64 L64_var1, Word64 L64_var2 ) +int EQ_64( long long int L64_var1, long long int L64_var2 ) { - Flag F_ret = 0; + int F_ret = 0; if ( L64_var1 == L64_var2 ) { @@ -2443,9 +2429,9 @@ Flag EQ_64( Word64 L64_var1, Word64 L64_var2 ) #endif return F_ret; } -Flag NE_64( Word64 L64_var1, Word64 L64_var2 ) +int NE_64( long long int L64_var1, long long int L64_var2 ) { - Flag F_ret = 0; + int F_ret = 0; if ( L64_var1 != L64_var2 ) { @@ -2461,66 +2447,63 @@ Flag NE_64( Word64 L64_var1, Word64 L64_var2 ) long TotalWeightedOperation() { -#ifdef WMOPS - Word32 i; - Word32 tot, *ptr; - const Word32 *ptr2; + int i; + unsigned int *ptr, *ptr2; + long tot; tot = 0; - ptr = (Word32 *) &multiCounter[currCounter]; - ptr2 = (const Word32 *) &op_weight; - for ( i = 0; i < ( Word16 )( sizeof( multiCounter[currCounter] ) / sizeof( Word32 ) ); i++ ) + ptr = (unsigned int *) &multiCounter[currCounter]; + ptr2 = (unsigned int *) &op_weight; + + for ( i = 0; i < (int) ( sizeof( multiCounter[currCounter] ) / sizeof( unsigned int ) ); i++ ) { tot += ( ( *ptr++ ) * ( *ptr2++ ) ); } - return ( (Word32) tot ); - -#else /* ifdef WMOPS */ - return 0; /* Dummy */ - -#endif /* ifdef WMOPS */ + return ( tot ); } -long DeltaWeightedOperation() +long DeltaWeightedOperation( void ) { -#ifdef WMOPS - Word32 NewWOper, delta; + long NewWOper, delta; NewWOper = TotalWeightedOperation(); - delta = NewWOper - LastWOper[currCounter]; - LastWOper[currCounter] = NewWOper; - return ( delta ); -#else /* ifdef WMOPS */ - return 0; /* Dummy */ + delta = NewWOper - wmops[currCounter].LastWOper; + wmops[currCounter].LastWOper = NewWOper; -#endif /* ifdef WMOPS */ + return ( delta ); } -long fwc( void ) +/* Set the counter group to use, default is zero */ +void Set_BASOP_WMOPS_counter( int counterId ) { -/* function worst case */ -#ifdef WMOPS - Word32 tot; + if ( ( counterId > num_wmops_records ) || ( counterId < 0 ) ) + { + currCounter = 0; + return; + } - tot = DeltaWeightedOperation(); - if ( tot > wc[currCounter][funcid[currCounter]] ) - wc[currCounter][funcid[currCounter]] = tot; + currCounter = counterId; + call_occurred = 1; - if ( tot < bc[currCounter][funcid[currCounter]] ) - bc[currCounter][funcid[currCounter]] = tot; + return; +} - funcid[currCounter]++; +/* Resets the current BASOP WMOPS counter */ +void Reset_BASOP_WMOPS_counter( void ) +{ + int i; + long *ptr; - /*make sure that BASOP_frame_update(); is put at the end of the main loop*/ - if ( funcid[currCounter] >= NbFuncMax ) + /* clear the current BASOP operation counter before new frame begins */ + ptr = (long *) &multiCounter[currCounter]; + for ( i = 0; i < (int) ( sizeof( multiCounter[currCounter] ) / sizeof( long ) ); i++ ) { - printf( "to many function calls\n" ); + *ptr++ = 0; } - assert( funcid[currCounter] < NbFuncMax ); - return ( tot ); -#else - return 0; -#endif /* ifdef WMOPS */ + + wmops[currCounter].LastWOper = 0; + + return; } \ No newline at end of file diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index 7f3092370..6847be681 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -24,52 +24,20 @@ #endif #include "options.h" -#include "typedef.h" /* To Prevent "warning: '$' in identifier or number" message under GCC */ #ifdef __GNUC__ #pragma GCC system_header #endif -#define FRAMES_PER_SECOND 50.0 -#define PROM_INST_SIZE 32 /* number of bits of each program instruction when stored in the PROM memory (applied only when the user selects reporting in bytes) */ -#define MAXCOUNTERS ( 1024 ) /* may need to be increased if the total number of instrumented functions exceeds the limit */ -#define MAX_HASH_TABLE_SIZE 1000000 /* may need to be increased if there are too many conflicts in calc_hash() */ -#define MAX_CALLERS_SAVED_FRAMES 5 /* # of Frame for which WMOPS Complexity Details will be saved, 0 = Disabled */ -#define NbFuncMax ( 80000 ) /* may need to be increased if the total number of function calls exceeds the limit */ - -#define WMOPS_DATA_FILENAME "wmops_data.txt" -/* - * WMOPS_DATA_FILENAME is the macro defining the name of the file - * where the Weighted Million of Operations per Second (wMOPS) - * are appended, function group by function group. - */ - - -#define CODE_PROFILE_FILENAME "code_profile.txt" -/* - * CODE_PROFILE_FILENAME is the macro defining the name of the file - * where the Weighted Million of Operations per Second (WMOPS) - * are appended, basic operation by basic operation. - */ +#ifndef INT_MAX +#define INT_MAX 32767 +#endif +#define CONTROL_CODE_OPS /* enable control code operators such as LT_16, GT_16, ... */ -#define WMOPS_TOTAL_FILENAME "wmops_total.txt" -/* - * WMOPS_TOTAL_FILENAME is the macro defining the name of the file - * where the Weighted Million of Operations per Second (WMOPS) - * are printed, globally for the application. - */ - -#define FRAME_RATE ( 0.0001F ) /* in this version frame_rate can be overwriten online by the new setFrameRate function */ -/* FRAME_RATE of 0.000025 is corresponding to 40ms frame.*/ -/* FRAME_RATE of 0.00005 is corresponding to 20ms frame.*/ -/* FRAME_RATE of 0.0001 is corresponding to 10ms frame.*/ -/* - * FRAME_RATE is the macro defining the calling rate of the - * application to benchmark. - */ - +#define FRAMES_PER_SECOND 50.0 +#define PROM_INST_SIZE 32 /* number of bits of each program instruction when stored in the PROM memory (applied only when the user selects reporting in bytes) */ #ifdef WMOPS enum instructions @@ -686,7 +654,7 @@ static double *ops_cnt_ptr = &ops_cnt_wmc; /* file prevent the addition of a 'C' file to the Project. */ /******************************************************************/ -/* General Purpose Global Flag */ +/* General Purpose Global int */ static int wmc_flag_ = 0; /* Operation Counter Wrappers */ @@ -1077,296 +1045,279 @@ void reset_stack( void ); /* Global counter variable for calculation of complexity weight */ typedef struct { - UWord32 add; /* Complexity Weight of 1 */ - UWord32 sub; /* Complexity Weight of 1 */ - UWord32 abs_s; /* Complexity Weight of 1 */ - UWord32 shl; /* Complexity Weight of 1 */ - UWord32 shr; /* Complexity Weight of 1 */ - - UWord32 extract_h; /* Complexity Weight of 1 */ - UWord32 extract_l; /* Complexity Weight of 1 */ - UWord32 mult; /* Complexity Weight of 1 */ - UWord32 L_mult; /* Complexity Weight of 1 */ - UWord32 negate; /* Complexity Weight of 1 */ - - UWord32 round; /* Complexity Weight of 1 */ - UWord32 L_mac; /* Complexity Weight of 1 */ - UWord32 L_msu; /* Complexity Weight of 1 */ - UWord32 L_macNs; /* Complexity Weight of 1 */ - UWord32 L_msuNs; /* Complexity Weight of 1 */ - - UWord32 L_add; /* Complexity Weight of 1 */ - UWord32 L_sub; /* Complexity Weight of 1 */ - UWord32 L_add_c; /* Complexity Weight of 2 */ - UWord32 L_sub_c; /* Complexity Weight of 2 */ - UWord32 L_negate; /* Complexity Weight of 1 */ - - UWord32 L_shl; /* Complexity Weight of 1 */ - UWord32 L_shr; /* Complexity Weight of 1 */ - UWord32 mult_r; /* Complexity Weight of 1 */ - UWord32 shr_r; /* Complexity Weight of 3 */ - UWord32 mac_r; /* Complexity Weight of 1 */ - - UWord32 msu_r; /* Complexity Weight of 1 */ - UWord32 L_deposit_h; /* Complexity Weight of 1 */ - UWord32 L_deposit_l; /* Complexity Weight of 1 */ - UWord32 L_shr_r; /* Complexity Weight of 3 */ - UWord32 L_abs; /* Complexity Weight of 1 */ - - UWord32 L_sat; /* Complexity Weight of 4 */ - UWord32 norm_s; /* Complexity Weight of 1 */ - UWord32 div_s; /* Complexity Weight of 18 */ - UWord32 norm_l; /* Complexity Weight of 1 */ - UWord32 move16; /* Complexity Weight of 1 */ - - UWord32 move32; /* Complexity Weight of 2 */ - UWord32 Logic16; /* Complexity Weight of 1 */ - UWord32 Logic32; /* Complexity Weight of 2 */ - UWord32 Test; /* Complexity Weight of 2 */ - UWord32 s_max; /* Complexity Weight of 1 */ - - UWord32 s_min; /* Complexity Weight of 1 */ - UWord32 L_max; /* Complexity Weight of 1 */ - UWord32 L_min; /* Complexity Weight of 1 */ - UWord32 L40_max; /* Complexity Weight of 1 */ - UWord32 L40_min; /* Complexity Weight of 1 */ - - UWord32 shl_r; /* Complexity Weight of 2 */ - UWord32 L_shl_r; /* Complexity Weight of 2 */ - UWord32 L40_shr_r; /* Complexity Weight of 2 */ - UWord32 L40_shl_r; /* Complexity Weight of 2 */ - UWord32 norm_L40; /* Complexity Weight of 1 */ - - UWord32 L40_shl; /* Complexity Weight of 1 */ - UWord32 L40_shr; /* Complexity Weight of 1 */ - UWord32 L40_negate; /* Complexity Weight of 1 */ - UWord32 L40_add; /* Complexity Weight of 1 */ - UWord32 L40_sub; /* Complexity Weight of 1 */ - - UWord32 L40_abs; /* Complexity Weight of 1 */ - UWord32 L40_mult; /* Complexity Weight of 1 */ - UWord32 L40_mac; /* Complexity Weight of 1 */ - UWord32 mac_r40; /* Complexity Weight of 2 */ - - UWord32 L40_msu; /* Complexity Weight of 1 */ - UWord32 msu_r40; /* Complexity Weight of 2 */ - UWord32 Mpy_32_16_ss; /* Complexity Weight of 2 */ - UWord32 Mpy_32_32_ss; /* Complexity Weight of 2 */ - UWord32 L_mult0; /* Complexity Weight of 1 */ - - UWord32 L_mac0; /* Complexity Weight of 1 */ - UWord32 L_msu0; /* Complexity Weight of 1 */ - UWord32 lshl; /* Complexity Weight of 1 */ - UWord32 lshr; /* Complexity Weight of 1 */ - UWord32 L_lshl; /* Complexity Weight of 1 */ - - UWord32 L_lshr; /* Complexity Weight of 1 */ - UWord32 L40_lshl; /* Complexity Weight of 1 */ - UWord32 L40_lshr; /* Complexity Weight of 1 */ - UWord32 s_and; /* Complexity Weight of 1 */ - UWord32 s_or; /* Complexity Weight of 1 */ - - UWord32 s_xor; /* Complexity Weight of 1 */ - UWord32 L_and; /* Complexity Weight of 1 */ - UWord32 L_or; /* Complexity Weight of 1 */ - UWord32 L_xor; /* Complexity Weight of 1 */ - UWord32 rotl; /* Complexity Weight of 3 */ - - UWord32 rotr; /* Complexity Weight of 3 */ - UWord32 L_rotl; /* Complexity Weight of 3 */ - UWord32 L_rotr; /* Complexity Weight of 3 */ - UWord32 L40_set; /* Complexity Weight of 1 */ - UWord32 L40_deposit_h; /* Complexity Weight of 1 */ - - UWord32 L40_deposit_l; /* Complexity Weight of 1 */ - UWord32 L40_deposit32; /* Complexity Weight of 1 */ - UWord32 Extract40_H; /* Complexity Weight of 1 */ - UWord32 Extract40_L; /* Complexity Weight of 1 */ - UWord32 L_Extract40; /* Complexity Weight of 1 */ - - UWord32 L40_round; /* Complexity Weight of 1 */ - UWord32 L_saturate40; /* Complexity Weight of 1 */ - UWord32 round40; /* Complexity Weight of 1 */ - UWord32 If; /* Complexity Weight of 3 */ - UWord32 Goto; /* Complexity Weight of 2 */ - - UWord32 Break; /* Complexity Weight of 2 */ - UWord32 Switch; /* Complexity Weight of 6 */ - UWord32 For; /* Complexity Weight of 3 */ - UWord32 While; /* Complexity Weight of 3 */ - UWord32 Continue; /* Complexity Weight of 2 */ - - UWord32 L_mls; /* Complexity Weight of 1 */ - UWord32 div_l; /* Complexity Weight of 32 */ - UWord32 i_mult; /* Complexity Weight of 1 */ + unsigned int add; /* Complexity Weight of 1 */ + unsigned int sub; /* Complexity Weight of 1 */ + unsigned int abs_s; /* Complexity Weight of 1 */ + unsigned int shl; /* Complexity Weight of 1 */ + unsigned int shr; /* Complexity Weight of 1 */ + + unsigned int extract_h; /* Complexity Weight of 1 */ + unsigned int extract_l; /* Complexity Weight of 1 */ + unsigned int mult; /* Complexity Weight of 1 */ + unsigned int L_mult; /* Complexity Weight of 1 */ + unsigned int negate; /* Complexity Weight of 1 */ + + unsigned int round; /* Complexity Weight of 1 */ + unsigned int L_mac; /* Complexity Weight of 1 */ + unsigned int L_msu; /* Complexity Weight of 1 */ + unsigned int L_macNs; /* Complexity Weight of 1 */ + unsigned int L_msuNs; /* Complexity Weight of 1 */ + + unsigned int L_add; /* Complexity Weight of 1 */ + unsigned int L_sub; /* Complexity Weight of 1 */ + unsigned int L_add_c; /* Complexity Weight of 2 */ + unsigned int L_sub_c; /* Complexity Weight of 2 */ + unsigned int L_negate; /* Complexity Weight of 1 */ + + unsigned int L_shl; /* Complexity Weight of 1 */ + unsigned int L_shr; /* Complexity Weight of 1 */ + unsigned int mult_r; /* Complexity Weight of 1 */ + unsigned int shr_r; /* Complexity Weight of 3 */ + unsigned int mac_r; /* Complexity Weight of 1 */ + + unsigned int msu_r; /* Complexity Weight of 1 */ + unsigned int L_deposit_h; /* Complexity Weight of 1 */ + unsigned int L_deposit_l; /* Complexity Weight of 1 */ + unsigned int L_shr_r; /* Complexity Weight of 3 */ + unsigned int L_abs; /* Complexity Weight of 1 */ + + unsigned int L_sat; /* Complexity Weight of 4 */ + unsigned int norm_s; /* Complexity Weight of 1 */ + unsigned int div_s; /* Complexity Weight of 18 */ + unsigned int norm_l; /* Complexity Weight of 1 */ + unsigned int move16; /* Complexity Weight of 1 */ + + unsigned int move32; /* Complexity Weight of 2 */ + unsigned int Logic16; /* Complexity Weight of 1 */ + unsigned int Logic32; /* Complexity Weight of 2 */ + unsigned int Test; /* Complexity Weight of 2 */ + unsigned int s_max; /* Complexity Weight of 1 */ + + unsigned int s_min; /* Complexity Weight of 1 */ + unsigned int L_max; /* Complexity Weight of 1 */ + unsigned int L_min; /* Complexity Weight of 1 */ + unsigned int L40_max; /* Complexity Weight of 1 */ + unsigned int L40_min; /* Complexity Weight of 1 */ + + unsigned int shl_r; /* Complexity Weight of 2 */ + unsigned int L_shl_r; /* Complexity Weight of 2 */ + unsigned int L40_shr_r; /* Complexity Weight of 2 */ + unsigned int L40_shl_r; /* Complexity Weight of 2 */ + unsigned int norm_L40; /* Complexity Weight of 1 */ + + unsigned int L40_shl; /* Complexity Weight of 1 */ + unsigned int L40_shr; /* Complexity Weight of 1 */ + unsigned int L40_negate; /* Complexity Weight of 1 */ + unsigned int L40_add; /* Complexity Weight of 1 */ + unsigned int L40_sub; /* Complexity Weight of 1 */ + + unsigned int L40_abs; /* Complexity Weight of 1 */ + unsigned int L40_mult; /* Complexity Weight of 1 */ + unsigned int L40_mac; /* Complexity Weight of 1 */ + unsigned int mac_r40; /* Complexity Weight of 2 */ + + unsigned int L40_msu; /* Complexity Weight of 1 */ + unsigned int msu_r40; /* Complexity Weight of 2 */ + unsigned int Mpy_32_16_ss; /* Complexity Weight of 2 */ + unsigned int Mpy_32_32_ss; /* Complexity Weight of 2 */ + unsigned int L_mult0; /* Complexity Weight of 1 */ + + unsigned int L_mac0; /* Complexity Weight of 1 */ + unsigned int L_msu0; /* Complexity Weight of 1 */ + unsigned int lshl; /* Complexity Weight of 1 */ + unsigned int lshr; /* Complexity Weight of 1 */ + unsigned int L_lshl; /* Complexity Weight of 1 */ + + unsigned int L_lshr; /* Complexity Weight of 1 */ + unsigned int L40_lshl; /* Complexity Weight of 1 */ + unsigned int L40_lshr; /* Complexity Weight of 1 */ + unsigned int s_and; /* Complexity Weight of 1 */ + unsigned int s_or; /* Complexity Weight of 1 */ + + unsigned int s_xor; /* Complexity Weight of 1 */ + unsigned int L_and; /* Complexity Weight of 1 */ + unsigned int L_or; /* Complexity Weight of 1 */ + unsigned int L_xor; /* Complexity Weight of 1 */ + unsigned int rotl; /* Complexity Weight of 3 */ + + unsigned int rotr; /* Complexity Weight of 3 */ + unsigned int L_rotl; /* Complexity Weight of 3 */ + unsigned int L_rotr; /* Complexity Weight of 3 */ + unsigned int L40_set; /* Complexity Weight of 1 */ + unsigned int L40_deposit_h; /* Complexity Weight of 1 */ + + unsigned int L40_deposit_l; /* Complexity Weight of 1 */ + unsigned int L40_deposit32; /* Complexity Weight of 1 */ + unsigned int Extract40_H; /* Complexity Weight of 1 */ + unsigned int Extract40_L; /* Complexity Weight of 1 */ + unsigned int L_Extract40; /* Complexity Weight of 1 */ + + unsigned int L40_round; /* Complexity Weight of 1 */ + unsigned int L_saturate40; /* Complexity Weight of 1 */ + unsigned int round40; /* Complexity Weight of 1 */ + unsigned int If; /* Complexity Weight of 3 */ + unsigned int Goto; /* Complexity Weight of 2 */ + + unsigned int Break; /* Complexity Weight of 2 */ + unsigned int Switch; /* Complexity Weight of 6 */ + unsigned int For; /* Complexity Weight of 3 */ + unsigned int While; /* Complexity Weight of 3 */ + unsigned int Continue; /* Complexity Weight of 2 */ + + unsigned int L_mls; /* Complexity Weight of 1 */ + unsigned int div_l; /* Complexity Weight of 32 */ + unsigned int i_mult; /* Complexity Weight of 1 */ /* New complex basic operators */ #ifdef COMPLEX_OPERATOR - UWord32 CL_shr; /* Complexity Weight of 1 */ - UWord32 CL_shl; /* Complexity Weight of 1 */ - UWord32 CL_add; /* Complexity Weight of 1 */ - UWord32 CL_sub; /* Complexity Weight of 1 */ - UWord32 CL_scale; /* Complexity Weight of 1 */ - UWord32 CL_dscale; /* Complexity Weight of 1 */ - UWord32 CL_msu_j; /* Complexity Weight of 1 */ - UWord32 CL_mac_j; /* Complexity Weight of 1 */ - UWord32 CL_move; /* Complexity Weight of 1 */ - UWord32 CL_Extract_real; /* Complexity Weight of 1 */ - UWord32 CL_Extract_imag; /* Complexity Weight of 1 */ - UWord32 CL_form; /* Complexity Weight of 1 */ - UWord32 CL_multr_32x16; /* Complexity Weight of 2 */ - UWord32 CL_negate; /* Complexity Weight of 1 */ - UWord32 CL_conjugate; /* Complexity Weight of 1 */ - UWord32 CL_mul_j; /* Complexity Weight of 1 */ - UWord32 CL_swap_real_imag; /* Complexity Weight of 1 */ - UWord32 C_add; /* Complexity Weight of 1 */ - UWord32 C_sub; /* Complexity Weight of 1 */ - UWord32 C_mul_j; /* Complexity Weight of 1 */ - UWord32 C_multr; /* Complexity Weight of 2 */ - UWord32 C_form; /* Complexity Weight of 1 */ - - UWord32 C_scale; /* Complexity Weight of 1 */ - UWord32 CL_round32_16; /* Complexity Weight of 1 */ - UWord32 CL_scale_32; /* Complexity Weight of 1 */ - UWord32 CL_dscale_32; /* Complexity Weight of 1 */ - UWord32 CL_multr_32x32; /* Complexity Weight of 2 */ - UWord32 C_mac_r; /* Complexity Weight of 2 */ - UWord32 C_msu_r; /* Complexity Weight of 2 */ - UWord32 C_Extract_real; /* Complexity Weight of 1 */ - UWord32 C_Extract_imag; /* Complexity Weight of 1 */ - UWord32 C_negate; /* Complexity Weight of 1 */ - UWord32 C_conjugate; /* Complexity Weight of 1 */ - UWord32 C_shr; /* Complexity Weight of 1 */ - UWord32 C_shl; /* Complexity Weight of 1 */ + unsigned int CL_shr; /* Complexity Weight of 1 */ + unsigned int CL_shl; /* Complexity Weight of 1 */ + unsigned int CL_add; /* Complexity Weight of 1 */ + unsigned int CL_sub; /* Complexity Weight of 1 */ + unsigned int CL_scale; /* Complexity Weight of 1 */ + unsigned int CL_dscale; /* Complexity Weight of 1 */ + unsigned int CL_msu_j; /* Complexity Weight of 1 */ + unsigned int CL_mac_j; /* Complexity Weight of 1 */ + unsigned int CL_move; /* Complexity Weight of 1 */ + unsigned int CL_Extract_real; /* Complexity Weight of 1 */ + unsigned int CL_Extract_imag; /* Complexity Weight of 1 */ + unsigned int CL_form; /* Complexity Weight of 1 */ + unsigned int CL_multr_32x16; /* Complexity Weight of 2 */ + unsigned int CL_negate; /* Complexity Weight of 1 */ + unsigned int CL_conjugate; /* Complexity Weight of 1 */ + unsigned int CL_mul_j; /* Complexity Weight of 1 */ + unsigned int CL_swap_real_imag; /* Complexity Weight of 1 */ + unsigned int C_add; /* Complexity Weight of 1 */ + unsigned int C_sub; /* Complexity Weight of 1 */ + unsigned int C_mul_j; /* Complexity Weight of 1 */ + unsigned int C_multr; /* Complexity Weight of 2 */ + unsigned int C_form; /* Complexity Weight of 1 */ + + unsigned int C_scale; /* Complexity Weight of 1 */ + unsigned int CL_round32_16; /* Complexity Weight of 1 */ + unsigned int CL_scale_32; /* Complexity Weight of 1 */ + unsigned int CL_dscale_32; /* Complexity Weight of 1 */ + unsigned int CL_multr_32x32; /* Complexity Weight of 2 */ + unsigned int C_mac_r; /* Complexity Weight of 2 */ + unsigned int C_msu_r; /* Complexity Weight of 2 */ + unsigned int C_Extract_real; /* Complexity Weight of 1 */ + unsigned int C_Extract_imag; /* Complexity Weight of 1 */ + unsigned int C_negate; /* Complexity Weight of 1 */ + unsigned int C_conjugate; /* Complexity Weight of 1 */ + unsigned int C_shr; /* Complexity Weight of 1 */ + unsigned int C_shl; /* Complexity Weight of 1 */ #endif /* #ifdef COMPLEX_OPERATOR */ /* New 64 bit basops */ #ifdef ENH_64_BIT_OPERATOR - UWord32 move64; /* Complexity Weight of 1 */ - UWord32 W_add_nosat; /* Complexity Weight of 1 */ - UWord32 W_sub_nosat; /* Complexity Weight of 1 */ - UWord32 W_shl; /* Complexity Weight of 1 */ - UWord32 W_shr; /* Complexity Weight of 1 */ - UWord32 W_shl_nosat; /* Complexity Weight of 1 */ - UWord32 W_shr_nosat; /* Complexity Weight of 1 */ - UWord32 W_mac_32_16; /* Complexity Weight of 1 */ - UWord32 W_msu_32_16; /* Complexity Weight of 1 */ - UWord32 W_mult_32_16; /* Complexity Weight of 1 */ - UWord32 W_mult0_16_16; /* Complexity Weight of 1 */ - UWord32 W_mac0_16_16; /* Complexity Weight of 1 */ - UWord32 W_msu0_16_16; /* Complexity Weight of 1 */ - UWord32 W_mult_16_16; /* Complexity Weight of 1 */ - UWord32 W_mac_16_16; /* Complexity Weight of 1 */ - UWord32 W_msu_16_16; /* Complexity Weight of 1 */ - UWord32 W_shl_sat_l; /* Complexity Weight of 1 */ - UWord32 W_sat_l; /* Complexity Weight of 1 */ - UWord32 W_sat_m; /* Complexity Weight of 1 */ - UWord32 W_deposit32_l; /* Complexity Weight of 1 */ - UWord32 W_deposit32_h; /* Complexity Weight of 1 */ - UWord32 W_extract_l; /* Complexity Weight of 1 */ - UWord32 W_extract_h; /* Complexity Weight of 1 */ - UWord32 W_round48_L; /* Complexity Weight of 1 */ - UWord32 W_round32_s; /* Complexity Weight of 1 */ - UWord32 W_norm; /* Complexity Weight of 1 */ - - UWord32 W_add; /* Complexity Weight of 1 */ - UWord32 W_sub; /* Complexity Weight of 1 */ - UWord32 W_neg; /* Complexity Weight of 1 */ - UWord32 W_abs; /* Complexity Weight of 1 */ - UWord32 W_mult_32_32; /* Complexity Weight of 1 */ - UWord32 W_mult0_32_32; /* Complexity Weight of 1 */ - UWord32 W_lshl; /* Complexity Weight of 1 */ - UWord32 W_lshr; /* Complexity Weight of 1 */ - UWord32 W_round64_L; /* Complexity Weight of 1 */ + unsigned int move64; /* Complexity Weight of 1 */ + unsigned int W_add_nosat; /* Complexity Weight of 1 */ + unsigned int W_sub_nosat; /* Complexity Weight of 1 */ + unsigned int W_shl; /* Complexity Weight of 1 */ + unsigned int W_shr; /* Complexity Weight of 1 */ + unsigned int W_shl_nosat; /* Complexity Weight of 1 */ + unsigned int W_shr_nosat; /* Complexity Weight of 1 */ + unsigned int W_mac_32_16; /* Complexity Weight of 1 */ + unsigned int W_msu_32_16; /* Complexity Weight of 1 */ + unsigned int W_mult_32_16; /* Complexity Weight of 1 */ + unsigned int W_mult0_16_16; /* Complexity Weight of 1 */ + unsigned int W_mac0_16_16; /* Complexity Weight of 1 */ + unsigned int W_msu0_16_16; /* Complexity Weight of 1 */ + unsigned int W_mult_16_16; /* Complexity Weight of 1 */ + unsigned int W_mac_16_16; /* Complexity Weight of 1 */ + unsigned int W_msu_16_16; /* Complexity Weight of 1 */ + unsigned int W_shl_sat_l; /* Complexity Weight of 1 */ + unsigned int W_sat_l; /* Complexity Weight of 1 */ + unsigned int W_sat_m; /* Complexity Weight of 1 */ + unsigned int W_deposit32_l; /* Complexity Weight of 1 */ + unsigned int W_deposit32_h; /* Complexity Weight of 1 */ + unsigned int W_extract_l; /* Complexity Weight of 1 */ + unsigned int W_extract_h; /* Complexity Weight of 1 */ + unsigned int W_round48_L; /* Complexity Weight of 1 */ + unsigned int W_round32_s; /* Complexity Weight of 1 */ + unsigned int W_norm; /* Complexity Weight of 1 */ + + unsigned int W_add; /* Complexity Weight of 1 */ + unsigned int W_sub; /* Complexity Weight of 1 */ + unsigned int W_neg; /* Complexity Weight of 1 */ + unsigned int W_abs; /* Complexity Weight of 1 */ + unsigned int W_mult_32_32; /* Complexity Weight of 1 */ + unsigned int W_mult0_32_32; /* Complexity Weight of 1 */ + unsigned int W_lshl; /* Complexity Weight of 1 */ + unsigned int W_lshr; /* Complexity Weight of 1 */ + unsigned int W_round64_L; /* Complexity Weight of 1 */ #endif /* #ifdef ENH_64_BIT_OPERATOR */ #ifdef ENH_32_BIT_OPERATOR - UWord32 Mpy_32_16_1; /* Complexity Weight of 1 */ - UWord32 Mpy_32_16_r; /* Complexity Weight of 1 */ - UWord32 Mpy_32_32; /* Complexity Weight of 1 */ - UWord32 Mpy_32_32_r; /* Complexity Weight of 1 */ - UWord32 Madd_32_16; /* Complexity Weight of 1 */ - UWord32 Madd_32_16_r; /* Complexity Weight of 1 */ - UWord32 Msub_32_16; /* Complexity Weight of 1 */ - UWord32 Msub_32_16_r; /* Complexity Weight of 1 */ - UWord32 Madd_32_32; /* Complexity Weight of 1 */ - UWord32 Madd_32_32_r; /* Complexity Weight of 1 */ - UWord32 Msub_32_32; /* Complexity Weight of 1 */ - UWord32 Msub_32_32_r; /* Complexity Weight of 1 */ + unsigned int Mpy_32_16_1; /* Complexity Weight of 1 */ + unsigned int Mpy_32_16_r; /* Complexity Weight of 1 */ + unsigned int Mpy_32_32; /* Complexity Weight of 1 */ + unsigned int Mpy_32_32_r; /* Complexity Weight of 1 */ + unsigned int Madd_32_16; /* Complexity Weight of 1 */ + unsigned int Madd_32_16_r; /* Complexity Weight of 1 */ + unsigned int Msub_32_16; /* Complexity Weight of 1 */ + unsigned int Msub_32_16_r; /* Complexity Weight of 1 */ + unsigned int Madd_32_32; /* Complexity Weight of 1 */ + 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 */ #ifdef ENH_U_32_BIT_OPERATOR - UWord32 UL_addNs; /* Complexity Weight of 1 */ - UWord32 UL_subNs; /* Complexity Weight of 1 */ - UWord32 UL_Mpy_32_32; /* Complexity Weight of 1 */ - UWord32 Mpy_32_32_uu; /* Complexity Weight of 2 */ - UWord32 Mpy_32_16_uu; /* Complexity Weight of 2 */ - UWord32 norm_ul_float; /* Complexity Weight of 1 */ - UWord32 UL_deposit_l; /* Complexity Weight of 1 */ + unsigned int UL_addNs; /* Complexity Weight of 1 */ + unsigned int UL_subNs; /* Complexity Weight of 1 */ + unsigned int UL_Mpy_32_32; /* Complexity Weight of 1 */ + unsigned int Mpy_32_32_uu; /* Complexity Weight of 2 */ + 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 */ #ifdef CONTROL_CODE_OPS - UWord32 LT_16; /* Complexity Weight of 1 */ - UWord32 GT_16; /* Complexity Weight of 1 */ - UWord32 LE_16; /* Complexity Weight of 1 */ - UWord32 GE_16; /* Complexity Weight of 1 */ - UWord32 EQ_16; /* Complexity Weight of 1 */ - UWord32 NE_16; /* Complexity Weight of 1 */ - UWord32 LT_32; /* Complexity Weight of 1 */ - UWord32 GT_32; /* Complexity Weight of 1 */ - UWord32 LE_32; /* Complexity Weight of 1 */ - UWord32 GE_32; /* Complexity Weight of 1 */ - UWord32 EQ_32; /* Complexity Weight of 1 */ - UWord32 NE_32; /* Complexity Weight of 1 */ - UWord32 LT_64; /* Complexity Weight of 1 */ - UWord32 GT_64; /* Complexity Weight of 1 */ - UWord32 LE_64; /* Complexity Weight of 1 */ - UWord32 GE_64; /* Complexity Weight of 1 */ - UWord32 EQ_64; /* Complexity Weight of 1 */ - UWord32 NE_64; /* Complexity Weight of 1 */ + unsigned int LT_16; /* Complexity Weight of 1 */ + unsigned int GT_16; /* Complexity Weight of 1 */ + unsigned int LE_16; /* Complexity Weight of 1 */ + unsigned int GE_16; /* Complexity Weight of 1 */ + unsigned int EQ_16; /* Complexity Weight of 1 */ + unsigned int NE_16; /* Complexity Weight of 1 */ + unsigned int LT_32; /* Complexity Weight of 1 */ + unsigned int GT_32; /* Complexity Weight of 1 */ + unsigned int LE_32; /* Complexity Weight of 1 */ + unsigned int GE_32; /* Complexity Weight of 1 */ + unsigned int EQ_32; /* Complexity Weight of 1 */ + unsigned int NE_32; /* Complexity Weight of 1 */ + unsigned int LT_64; /* Complexity Weight of 1 */ + unsigned int GT_64; /* Complexity Weight of 1 */ + unsigned int LE_64; /* Complexity Weight of 1 */ + unsigned int GE_64; /* Complexity Weight of 1 */ + unsigned int EQ_64; /* Complexity Weight of 1 */ + unsigned int NE_64; /* Complexity Weight of 1 */ #endif /* #ifdef CONTROL_CODE_OPS */ } BASIC_OP; #ifdef WMOPS -extern BASIC_OP multiCounter[MAXCOUNTERS]; +extern BASIC_OP *multiCounter; extern int currCounter; -extern int lookup_table[]; - - - -/* Technical note : - * The following 3 variables are only used for correct complexity - * evaluation of the following structure : - * IF{ - * ... - * } ELSE IF { - * ... - * } ELSE IF { - * ... - * } - * ... - * } ELSE { - * ... - * } - */ extern int funcId_where_last_call_to_else_occurred; extern long funcid_total_wmops_at_last_call_to_else; extern int call_occurred; -extern long LastWOper[MAXCOUNTERS]; -extern Word32 bc[MAXCOUNTERS][NbFuncMax], wc[MAXCOUNTERS][NbFuncMax]; -extern Word32 funcid[MAXCOUNTERS]; -extern const BASIC_OP op_weight; +#define MAX_FUNCTION_NAME_LENGTH 200 /* Maximum length of the function name */ +#define MAX_PARAMS_LENGTH 200 /* Maximum length of the function parameter string */ +#define MAX_NUM_RECORDS 300 /* Initial maximum number of records -> might be increased during runtime, if needed */ +#define MAX_NUM_RECORDS_REALLOC_STEP 50 /* When re-allocating the list of records, increase the number of records by this number */ +#define MAX_CALL_TREE_DEPTH 100 /* maximum depth of the function call tree */ +#define DOUBLE_MAX 0x80000000 +#define FAC ( FRAMES_PER_SECOND / 1e6 ) -extern long TotalWeightedOperation( void ); -extern long DeltaWeightedOperation( void ); -extern long fwc( void ); +long TotalWeightedOperation( void ); +long DeltaWeightedOperation( void ); -//void Set_BASOP_WMOPS_counter( int counterId ); -//void Reset_BASOP_WMOPS_counter( void ); +void Set_BASOP_WMOPS_counter( int counterId ); +void Reset_BASOP_WMOPS_counter( void ); /***************************************************************************** * @@ -1480,7 +1431,7 @@ static __inline void incrIf( void ) multiCounter[currCounter].If++; call_occurred = 0; - funcId_where_last_call_to_else_occurred = MAXCOUNTERS; + funcId_where_last_call_to_else_occurred = INT_MAX; } #endif /* ifndef WMOPS */ @@ -1633,26 +1584,26 @@ static __inline void incrGoto( void ) */ #ifdef CONTROL_CODE_OPS -Flag LT_16( Word16 var1, Word16 var2 ); -Flag GT_16( Word16 var1, Word16 var2 ); -Flag LE_16( Word16 var1, Word16 var2 ); -Flag GE_16( Word16 var1, Word16 var2 ); -Flag EQ_16( Word16 var1, Word16 var2 ); -Flag NE_16( Word16 var1, Word16 var2 ); - -Flag LT_32( Word32 L_var1, Word32 L_var2 ); -Flag GT_32( Word32 L_var1, Word32 L_var2 ); -Flag LE_32( Word32 L_var1, Word32 L_var2 ); -Flag GE_32( Word32 L_var1, Word32 L_var2 ); -Flag EQ_32( Word32 L_var1, Word32 L_var2 ); -Flag NE_32( Word32 L_var1, Word32 L_var2 ); - -Flag LT_64( Word64 L64_var1, Word64 L64_var2 ); -Flag GT_64( Word64 L64_var1, Word64 L64_var2 ); -Flag LE_64( Word64 L64_var1, Word64 L64_var2 ); -Flag GE_64( Word64 L64_var1, Word64 L64_var2 ); -Flag EQ_64( Word64 L64_var1, Word64 L64_var2 ); -Flag NE_64( Word64 L64_var1, Word64 L64_var2 ); +extern int LT_16( short var1, short var2 ); +extern int GT_16( short var1, short var2 ); +extern int LE_16( short var1, short var2 ); +extern int GE_16( short var1, short var2 ); +extern int EQ_16( short var1, short var2 ); +extern int NE_16( short var1, short var2 ); + +extern int LT_32( int L_var1, int L_var2 ); +extern int GT_32( int L_var1, int L_var2 ); +extern int LE_32( int L_var1, int L_var2 ); +extern int GE_32( int L_var1, int L_var2 ); +extern int EQ_32( int L_var1, int L_var2 ); +extern int NE_32( int L_var1, int L_var2 ); + +extern int LT_64( long long int L64_var1, long long int L64_var2 ); +extern int GT_64( long long int L64_var1, long long int L64_var2 ); +extern int LE_64( long long int L64_var1, long long int L64_var2 ); +extern int GE_64( long long int L64_var1, long long int L64_var2 ); +extern int EQ_64( long long int L64_var1, long long int L64_var2 ); +extern int NE_64( long long int L64_var1, long long int L64_var2 ); #endif /* #ifdef CONTROL_CODE_OPS */ diff --git a/lib_dec/rom_dec.c b/lib_dec/rom_dec.c index a317678a4..743789330 100644 --- a/lib_dec/rom_dec.c +++ b/lib_dec/rom_dec.c @@ -37,6 +37,7 @@ #include #include "options.h" #include "cnst.h" +#include "typedef.h" #include "wmc_auto.h" /* clang-format off */ diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index 06eb4fc5b..8f6eb2d62 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -6,9 +6,8 @@ //#include "prot_fx.h" //#include "basop_mpy.h" #include "options.h" -#include "cnst.h" /* Common constants */ +#include "cnst.h" #include "stl.h" -#include "count.h" #include "basop_util.h" #include "rom_com_fx.h" #include "ivas_cnst.h" diff --git a/lib_enc/rom_enc.c b/lib_enc/rom_enc.c index 7e6b1cf11..7ce2fcae6 100644 --- a/lib_enc/rom_enc.c +++ b/lib_enc/rom_enc.c @@ -36,6 +36,7 @@ #include #include "options.h" +#include "typedef.h" #include "cnst.h" #include "wmc_auto.h" -- GitLab From 93cdb82c1898d9929a8ac8844b6e98b471d47c87 Mon Sep 17 00:00:00 2001 From: malenov Date: Thu, 21 Nov 2024 14:03:45 +0100 Subject: [PATCH 03/21] rename ops_cnt_wmc back to ops_cnt --- Workspace_msvc/lib_com.vcxproj | 2 - Workspace_msvc/lib_com.vcxproj.filters | 4 -- lib_debug/wmc_auto.c | 35 +++++------- lib_debug/wmc_auto.h | 74 ++++++++++++-------------- 4 files changed, 45 insertions(+), 70 deletions(-) diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index c6111a49f..430b10bdd 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -152,9 +152,7 @@ - - diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index 3f865d3ce..bd270696c 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -103,9 +103,6 @@ common_ivas_c - - common_all_c - common_all_c @@ -521,7 +518,6 @@ - diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index fa2b6f4a5..5f98b181f 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -73,7 +73,7 @@ typedef struct #endif } wmops_record; -double ops_cnt_wmc; +double ops_cnt; double prom_cnt_wmc; double inst_cnt[NUM_INST]; @@ -108,7 +108,7 @@ void reset_wmops( void ) max_cnt = 0.0; min_cnt = DOUBLE_MAX; start_cnt = 0.0; - ops_cnt_wmc = 0.0; + ops_cnt = 0.0; /* allocate the list of WMOPS records */ if ( wmops == NULL ) @@ -134,17 +134,6 @@ void reset_wmops( void ) exit( -1 ); } - //BASOP_init - - //setFrameRate( 32000, 640 ); - //Init_WMOPS_counter(); /* 20ms frames */ - - - //for ( i = 0; i < MAX_HASH_TABLE_SIZE; i++ ) - //{ - // lookup_table[i] = -1; - //} - /* initilize the list of WMOPS records */ /* initilize the BASOP WMOPS counters */ for ( i = 0; i < max_num_wmops_records; i++ ) @@ -301,7 +290,7 @@ void push_wmops_fct( const char *label, ... ) wmops_caller_stack[wmops_caller_stack_index++] = current_record; /* accumulate op counts */ - wmops[current_record].current_selfcnt += ops_cnt_wmc - wmops[current_record].start_selfcnt; + wmops[current_record].current_selfcnt += ops_cnt - wmops[current_record].start_selfcnt; /* update call tree */ for ( j = 0; j < MAX_CALL_TREE_DEPTH; j++ ) @@ -320,8 +309,8 @@ void push_wmops_fct( const char *label, ... ) /* update the current context info */ current_record = index_record; - wmops[index_record].start_selfcnt = ops_cnt_wmc; - wmops[index_record].start_cnt = ops_cnt_wmc; + wmops[index_record].start_selfcnt = ops_cnt; + wmops[index_record].start_cnt = ops_cnt; wmops[index_record].call_number++; #ifdef WMOPS_WC_FRAME_ANALYSIS wmops[index_record].current_call_number++; @@ -347,17 +336,17 @@ void pop_wmops( void ) /* add the BASOP complexity to the counter */ tot = DeltaWeightedOperation(); - ops_cnt_wmc += tot; + ops_cnt += tot; /* update count of current record */ - wmops[current_record].current_selfcnt += ops_cnt_wmc - wmops[current_record].start_selfcnt; - wmops[current_record].current_cnt += ops_cnt_wmc - wmops[current_record].start_cnt; + wmops[current_record].current_selfcnt += ops_cnt - wmops[current_record].start_selfcnt; + wmops[current_record].current_cnt += ops_cnt - wmops[current_record].start_cnt; /* Get back previous context from stack */ if ( wmops_caller_stack_index > 0 ) { current_record = wmops_caller_stack[--wmops_caller_stack_index]; - wmops[current_record].start_selfcnt = ops_cnt_wmc; + wmops[current_record].start_selfcnt = ops_cnt; /* set the ID of the previous BASOP counter */ Set_BASOP_WMOPS_counter( current_record ); @@ -463,7 +452,7 @@ void update_wmops( void ) Reset_BASOP_WMOPS_counter(); } - current_cnt = ops_cnt_wmc - start_cnt; + current_cnt = ops_cnt - start_cnt; if ( current_cnt > max_cnt ) { max_cnt = current_cnt; @@ -486,7 +475,7 @@ void update_wmops( void ) inst_cnt[i] = 0.0; } - start_cnt = ops_cnt_wmc; + start_cnt = ops_cnt; /* increment frame counter */ update_cnt++; @@ -539,7 +528,7 @@ void print_wmops( void ) } fprintf( stdout, sfmts, max_label_len, "---------------", "------", "------", "------", "------" ); - fprintf( stdout, dfmts, max_label_len, "total", (float) update_cnt, update_cnt == 0 ? 0 : FAC * min_cnt, FAC * max_cnt, update_cnt == 0 ? 0 : FAC * ops_cnt_wmc / update_cnt ); + fprintf( stdout, dfmts, max_label_len, "total", (float) update_cnt, update_cnt == 0 ? 0 : FAC * min_cnt, FAC * max_cnt, update_cnt == 0 ? 0 : FAC * ops_cnt / update_cnt ); fprintf( stdout, "\n" ); #ifdef WMOPS_WC_FRAME_ANALYSIS diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index 6847be681..f019dcc96 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -110,7 +110,7 @@ enum instructions #define ADD( x ) \ { \ { \ - ops_cnt_wmc += ( _ADD_C * ( x ) ); \ + ops_cnt += ( _ADD_C * ( x ) ); \ inst_cnt[_ADD] += ( x ); \ { \ static int pcnt; \ @@ -125,7 +125,7 @@ enum instructions #define ABS( x ) \ { \ { \ - ops_cnt_wmc += ( _ABS_C * ( x ) ); \ + ops_cnt += ( _ABS_C * ( x ) ); \ inst_cnt[_ABS] += ( x ); \ { \ static int pcnt; \ @@ -140,7 +140,7 @@ enum instructions #define MULT( x ) \ { \ { \ - ops_cnt_wmc += ( _MULT_C * ( x ) ); \ + ops_cnt += ( _MULT_C * ( x ) ); \ inst_cnt[_MULT] += ( x ); \ { \ static int pcnt; \ @@ -155,7 +155,7 @@ enum instructions #define MAC( x ) \ { \ { \ - ops_cnt_wmc += ( _MAC_C * ( x ) ); \ + ops_cnt += ( _MAC_C * ( x ) ); \ inst_cnt[_MAC] += ( x ); \ { \ static int pcnt; \ @@ -170,7 +170,7 @@ enum instructions #define MOVE( x ) \ { \ { \ - ops_cnt_wmc += ( _MOVE_C * ( x ) ); \ + ops_cnt += ( _MOVE_C * ( x ) ); \ inst_cnt[_MOVE] += ( x ); \ { \ static int pcnt; \ @@ -185,7 +185,7 @@ enum instructions #define STORE( x ) \ { \ { \ - ops_cnt_wmc += ( _STORE_C * ( x ) ); \ + ops_cnt += ( _STORE_C * ( x ) ); \ inst_cnt[_STORE] += ( x ); \ { \ static int pcnt; \ @@ -200,7 +200,7 @@ enum instructions #define LOGIC( x ) \ { \ { \ - ops_cnt_wmc += ( _LOGIC_C * ( x ) ); \ + ops_cnt += ( _LOGIC_C * ( x ) ); \ inst_cnt[_LOGIC] += ( x ); \ { \ static int pcnt; \ @@ -215,7 +215,7 @@ enum instructions #define SHIFT( x ) \ { \ { \ - ops_cnt_wmc += ( _SHIFT_C * ( x ) ); \ + ops_cnt += ( _SHIFT_C * ( x ) ); \ inst_cnt[_SHIFT] += ( x ); \ { \ static int pcnt; \ @@ -230,7 +230,7 @@ enum instructions #define BRANCH( x ) \ { \ { \ - ops_cnt_wmc += ( _BRANCH_C * ( x ) ); \ + ops_cnt += ( _BRANCH_C * ( x ) ); \ inst_cnt[_BRANCH] += ( x ); \ { \ static int pcnt; \ @@ -245,7 +245,7 @@ enum instructions #define DIV( x ) \ { \ { \ - ops_cnt_wmc += ( _DIV_C * ( x ) ); \ + ops_cnt += ( _DIV_C * ( x ) ); \ inst_cnt[_DIV] += ( x ); \ { \ static int pcnt; \ @@ -260,7 +260,7 @@ enum instructions #define SQRT( x ) \ { \ { \ - ops_cnt_wmc += ( _SQRT_C * ( x ) ); \ + ops_cnt += ( _SQRT_C * ( x ) ); \ inst_cnt[_SQRT] += ( x ); \ { \ static int pcnt; \ @@ -275,7 +275,7 @@ enum instructions #define TRANS( x ) \ { \ { \ - ops_cnt_wmc += ( _TRANS_C * ( x ) ); \ + ops_cnt += ( _TRANS_C * ( x ) ); \ inst_cnt[_TRANS] += ( x ); \ { \ static int pcnt; \ @@ -290,7 +290,7 @@ enum instructions #define LOOP( x ) \ { \ { \ - ops_cnt_wmc += ( _LOOP_C * ( x ) ); \ + ops_cnt += ( _LOOP_C * ( x ) ); \ inst_cnt[_LOOP] += ( x ); \ { \ static int pcnt; \ @@ -305,7 +305,7 @@ enum instructions #define INDIRECT( x ) \ { \ { \ - ops_cnt_wmc += ( _INDIRECT_C * ( x ) ); \ + ops_cnt += ( _INDIRECT_C * ( x ) ); \ inst_cnt[_INDIRECT] += ( x ); \ { \ static int pcnt; \ @@ -320,7 +320,7 @@ enum instructions #define PTR_INIT( x ) \ { \ { \ - ops_cnt_wmc += ( _PTR_INIT_C * ( x ) ); \ + ops_cnt += ( _PTR_INIT_C * ( x ) ); \ inst_cnt[_PTR_INIT] += ( x ); \ { \ static int pcnt; \ @@ -335,7 +335,7 @@ enum instructions #define TEST( x ) \ { \ { \ - ops_cnt_wmc += ( _TEST_C * ( x ) ); \ + ops_cnt += ( _TEST_C * ( x ) ); \ inst_cnt[_TEST] += ( x ); \ { \ static int pcnt; \ @@ -350,7 +350,7 @@ enum instructions #define POWER( x ) \ { \ { \ - ops_cnt_wmc += ( _POWER_C * ( x ) ); \ + ops_cnt += ( _POWER_C * ( x ) ); \ inst_cnt[_POWER] += ( x ); \ { \ static int pcnt; \ @@ -365,7 +365,7 @@ enum instructions #define LOG( x ) \ { \ { \ - ops_cnt_wmc += ( _LOG_C * ( x ) ); \ + ops_cnt += ( _LOG_C * ( x ) ); \ inst_cnt[_LOG] += ( x ); \ { \ static int pcnt; \ @@ -380,7 +380,7 @@ enum instructions #define MISC( x ) \ { \ { \ - ops_cnt_wmc += ( _MISC_C * ( x ) ); \ + ops_cnt += ( _MISC_C * ( x ) ); \ inst_cnt[_MISC] += ( x ); \ { \ static int pcnt; \ @@ -396,7 +396,7 @@ enum instructions #define FUNC( x ) \ { \ { \ - ops_cnt_wmc += ( _FUNC_C + _MOVE_C * ( x ) ); \ + ops_cnt += ( _FUNC_C + _MOVE_C * ( x ) ); \ inst_cnt[_FUNC]++; \ inst_cnt[_MOVE] += ( x ); \ { \ @@ -413,7 +413,7 @@ enum instructions #define DADD( x ) \ { \ { \ - ops_cnt_wmc += ( 2 * _ADD_C * ( x ) ); \ + ops_cnt += ( 2 * _ADD_C * ( x ) ); \ inst_cnt[_ADD] += ( x ); \ { \ static int pcnt; \ @@ -428,7 +428,7 @@ enum instructions #define DMULT( x ) \ { \ { \ - ops_cnt_wmc += ( 2 * _MULT_C * ( x ) ); \ + ops_cnt += ( 2 * _MULT_C * ( x ) ); \ inst_cnt[_MULT] += ( x ); \ { \ static int pcnt; \ @@ -443,7 +443,7 @@ enum instructions #define DMAC( x ) \ { \ { \ - ops_cnt_wmc += ( 2 * _MAC_C * ( x ) ); \ + ops_cnt += ( 2 * _MAC_C * ( x ) ); \ inst_cnt[_MAC] += ( x ); \ { \ static int pcnt; \ @@ -458,7 +458,7 @@ enum instructions #define DMOVE( x ) \ { \ { \ - ops_cnt_wmc += ( 2 * _MOVE_C * ( x ) ); \ + ops_cnt += ( 2 * _MOVE_C * ( x ) ); \ inst_cnt[_MOVE] += ( x ); \ { \ static int pcnt; \ @@ -473,7 +473,7 @@ enum instructions #define DSTORE( x ) \ { \ { \ - ops_cnt_wmc += ( 2 * _STORE_C * ( x ) ); \ + ops_cnt += ( 2 * _STORE_C * ( x ) ); \ inst_cnt[_STORE] += ( x ); \ { \ static int pcnt; \ @@ -488,7 +488,7 @@ enum instructions #define DLOGIC( x ) \ { \ { \ - ops_cnt_wmc += ( 2 * _LOGIC_C * ( x ) ); \ + ops_cnt += ( 2 * _LOGIC_C * ( x ) ); \ inst_cnt[_LOGIC] += ( x ); \ { \ static int pcnt; \ @@ -503,7 +503,7 @@ enum instructions #define DSHIFT( x ) \ { \ { \ - ops_cnt_wmc += ( 2 * _SHIFT_C * ( x ) ); \ + ops_cnt += ( 2 * _SHIFT_C * ( x ) ); \ inst_cnt[_SHIFT] += ( x ); \ { \ static int pcnt; \ @@ -518,7 +518,7 @@ enum instructions #define DDIV( x ) \ { \ { \ - ops_cnt_wmc += ( 2 * _DIV_C * ( x ) ); \ + ops_cnt += ( 2 * _DIV_C * ( x ) ); \ inst_cnt[_DIV] += ( x ); \ { \ static int pcnt; \ @@ -533,7 +533,7 @@ enum instructions #define DSQRT( x ) \ { \ { \ - ops_cnt_wmc += ( 2 * _SQRT_C * ( x ) ); \ + ops_cnt += ( 2 * _SQRT_C * ( x ) ); \ inst_cnt[_SQRT] += ( x ); \ { \ static int pcnt; \ @@ -548,7 +548,7 @@ enum instructions #define DTRANS( x ) \ { \ { \ - ops_cnt_wmc += ( 2 * _TRANS_C * ( x ) ); \ + ops_cnt += ( 2 * _TRANS_C * ( x ) ); \ inst_cnt[_TRANS] += ( x ); \ { \ static int pcnt; \ @@ -561,7 +561,7 @@ enum instructions } \ } -extern double ops_cnt_wmc; +extern double ops_cnt; extern double prom_cnt_wmc; extern double inst_cnt[NUM_INST]; @@ -640,8 +640,8 @@ extern int cntr_push_pop; #else -/* '*ops_cnt_ptr' is Used to Avoid: "warning: operation on 'ops_cnt_wmc' may be undefined" with Cygwin gcc Compiler */ -static double *ops_cnt_ptr = &ops_cnt_wmc; +/* '*ops_cnt_ptr' is Used to Avoid: "warning: operation on 'ops_cnt' may be undefined" with Cygwin gcc Compiler */ +static double *ops_cnt_ptr = &ops_cnt; #define OP_COUNT_( op, x ) ( *ops_cnt_ptr += ( op##_C * ( x ) ), inst_cnt[op] += ( x ) ) /******************************************************************/ @@ -1305,14 +1305,6 @@ extern int funcId_where_last_call_to_else_occurred; extern long funcid_total_wmops_at_last_call_to_else; extern int call_occurred; -#define MAX_FUNCTION_NAME_LENGTH 200 /* Maximum length of the function name */ -#define MAX_PARAMS_LENGTH 200 /* Maximum length of the function parameter string */ -#define MAX_NUM_RECORDS 300 /* Initial maximum number of records -> might be increased during runtime, if needed */ -#define MAX_NUM_RECORDS_REALLOC_STEP 50 /* When re-allocating the list of records, increase the number of records by this number */ -#define MAX_CALL_TREE_DEPTH 100 /* maximum depth of the function call tree */ -#define DOUBLE_MAX 0x80000000 -#define FAC ( FRAMES_PER_SECOND / 1e6 ) - long TotalWeightedOperation( void ); long DeltaWeightedOperation( void ); -- GitLab From 5b2fa6dddc9ef1e467eeea8e508b8b2e75f738ca Mon Sep 17 00:00:00 2001 From: malenov Date: Fri, 22 Nov 2024 14:21:40 +0100 Subject: [PATCH 04/21] fix discrepancy between Windows and Linux --- lib_com/enh1632.c | 4 ++ lib_com/options.h | 3 + lib_com/tools_fx.c | 20 +++++++ lib_debug/wmc_auto.c | 129 ++++++++++++++++++++++--------------------- lib_debug/wmc_auto.h | 12 ++-- 5 files changed, 96 insertions(+), 72 deletions(-) diff --git a/lib_com/enh1632.c b/lib_com/enh1632.c index 859562c94..822ea80b0 100644 --- a/lib_com/enh1632.c +++ b/lib_com/enh1632.c @@ -392,12 +392,16 @@ Word16 shl_ro( Word16 var1, Word16 var2, Flag *Overflow ) var2 = -var2; var_out = shr_ro( var1, var2, Overflow ); #ifdef WMOPS +#ifndef FIX_SHR_RO_COMPLEXITY multiCounter[currCounter].shr_r--; +#endif #endif /* ifdef WMOPS */ } #ifdef WMOPS +#ifndef FIX_SHR_RO_COMPLEXITY multiCounter[currCounter].shl_r++; +#endif #endif /* ifdef WMOPS */ return ( var_out ); diff --git a/lib_com/options.h b/lib_com/options.h index 75c508d36..1d56f4053 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,6 +84,9 @@ #define NON_BE_FIX_807_MASA_DTX_BRSW /* Nokia: adds fix to check existence of DTX encoder for secondary channel in TD mode */ #define FIX_BASOP_812_NAN_COHSNR /* FhG: BASOP issue 812: fix nan values in sparse frames for cohSNR value in ITD estimation*/ #define FIX_828_PORT_1152_FROM_FLT_REPO /* FhG: fix for issue 828 - fix uninitialized value used in BASOP */ +#define FIX_SHR_RO_COMPLEXITY /* VA: fix for issue 1049: incorrect counting of complexity in the shr_ro() function */ +#define FIX_IF_ELSE_CMPLX_DISCREPANCY /* fix IF-ELSE discpreancy within the Copy() function depending on memory locations of x[] and y[] */ + /* #################### End FIXES switches ############################ */ #define BASOP_NOGLOB /* Disable global symbols in BASOPs, Overflow/Carry in BASOPs disabled, additional BASOPs in case of Overflow */ diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 3580e632e..997dd8ec5 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -488,7 +488,12 @@ void Copy( move16(); } } + +#ifdef FIX_IF_ELSE_CMPLX_DISCREPANCY + IF( y >= x ) +#else ELSE +#endif { FOR( i = L - 1; i >= 0; i-- ) { @@ -517,7 +522,12 @@ void Copy64( move64(); } } + +#ifdef FIX_IF_ELSE_CMPLX_DISCREPANCY + IF( y >= x ) +#else ELSE +#endif { FOR( i = L - 1; i >= 0; i-- ) { @@ -561,7 +571,12 @@ void Copy_pword( move16(); } } + +#ifdef FIX_IF_ELSE_CMPLX_DISCREPANCY + IF( y >= x ) +#else ELSE +#endif { FOR( i = L - 1; i >= 0; i-- ) { @@ -592,7 +607,12 @@ void Copy32( move32(); } } + +#ifdef FIX_IF_ELSE_CMPLX_DISCREPANCY + IF( y >= x ) +#else ELSE +#endif { FOR( i = L - 1; i >= 0; i-- ) { diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index 5f98b181f..8aeb372eb 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -48,6 +48,9 @@ int cntr_push_pop = 0; /* global counter for checking balanced push_wmops()/pop_ #define DOUBLE_MAX 0x80000000 #define FAC ( FRAMES_PER_SECOND / 1e6 ) +#define FRAMES_PER_SECOND 50.0 +#define PROM_INST_SIZE 32 /* number of bits of each program instruction when stored in the PROM memory (applied only when the user selects reporting in bytes) */ + typedef struct { char label[MAX_FUNCTION_NAME_LENGTH]; @@ -89,6 +92,65 @@ static long fnum_cnt_wc; static int *wmops_caller_stack = NULL, wmops_caller_stack_index, max_wmops_caller_stack_index = 0; static int *heap_allocation_call_tree = NULL, heap_allocation_call_tree_size = 0, heap_allocation_call_tree_max_size = 0; +static BASIC_OP op_weight = { + 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, + 1, 1, 2, 2, 1, + 1, 1, 1, 2, 1, + + 1, 1, 1, 2, 1, + 1, 1, 18, 1, 1, + 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, + 2, 2, 2, 2, 1, + + 1, 1, 1, 1, 1, + 1, 1, 1, 2, + 1, 2, 2, 2, 1, + 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 3, + 3, 3, 3, 1, 1, + 1, 1, 1, 1, 1, + 1, 1, 1, 3, 2, + 2, 6, 3, 3, 2, + + 1, 32, 1 + +/* New complex basops */ +#ifdef COMPLEX_OPERATOR + , + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1 + + , + 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1 + +#endif /* #ifdef COMPLEX_OPERATOR */ + +#ifdef ENH_64_BIT_OPERATOR + /* Weights of new 64 bit basops */ + , + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 +#endif /* #ifdef ENH_64_BIT_OPERATOR */ + +#ifdef ENH_32_BIT_OPERATOR + , + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 +#endif /* #ifdef ENH_32_BIT_OPERATOR */ + +#ifdef ENH_U_32_BIT_OPERATOR + , + 1, 1, 1, 2, 2, 1, 1 +#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ + +#ifdef CONTROL_CODE_OPS + , + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 +#endif /* #ifdef CONTROL_CODE_OPS */ +}; + BASIC_OP *multiCounter = NULL; int currCounter = 0; int funcId_where_last_call_to_else_occurred; @@ -192,7 +254,7 @@ void reset_wmops( void ) /* initialize auxiliary BASOP WMOPS variables */ call_occurred = 1; - funcId_where_last_call_to_else_occurred = INT_MAX; + funcId_where_last_call_to_else_occurred = -100; return; } @@ -322,7 +384,6 @@ void push_wmops_fct( const char *label, ... ) return; } - void pop_wmops( void ) { long tot; @@ -447,7 +508,7 @@ void update_wmops( void ) wmops[i].current_call_number = 0; #endif - /* update the WC of all BASOP counters */ + /* reset the BASOP counter */ Set_BASOP_WMOPS_counter( i ); Reset_BASOP_WMOPS_counter(); } @@ -2120,66 +2181,6 @@ void print_mem( ROM_Size_Lookup_Table Const_Data_PROM_Table[] ) #endif /* WMOPS */ - -BASIC_OP op_weight = { - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 2, 2, 1, - 1, 1, 1, 2, 1, - - 1, 1, 1, 2, 1, - 1, 1, 18, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 2, 2, 2, 2, 1, - - 1, 1, 1, 1, 1, - 1, 1, 1, 2, - 1, 2, 2, 2, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 3, - 3, 3, 3, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 3, 2, - 2, 6, 3, 3, 2, - - 1, 32, 1 - -/* New complex basops */ -#ifdef COMPLEX_OPERATOR - , - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1 - - , - 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1 - -#endif /* #ifdef COMPLEX_OPERATOR */ - -#ifdef ENH_64_BIT_OPERATOR - /* Weights of new 64 bit basops */ - , - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 -#endif /* #ifdef ENH_64_BIT_OPERATOR */ - -#ifdef ENH_32_BIT_OPERATOR - , - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 -#endif /* #ifdef ENH_32_BIT_OPERATOR */ - -#ifdef ENH_U_32_BIT_OPERATOR - , - 1, 1, 1, 2, 2, 1, 1 -#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ - -#ifdef CONTROL_CODE_OPS - , - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 -#endif /* #ifdef CONTROL_CODE_OPS */ -}; - #ifdef CONTROL_CODE_OPS int LT_16( short var1, short var2 ) @@ -2418,7 +2419,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; diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index f019dcc96..fc0d9f5eb 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -30,14 +30,8 @@ #pragma GCC system_header #endif -#ifndef INT_MAX -#define INT_MAX 32767 -#endif - -#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 FRAMES_PER_SECOND 50.0 -#define PROM_INST_SIZE 32 /* number of bits of each program instruction when stored in the PROM memory (applied only when the user selects reporting in bytes) */ #ifdef WMOPS enum instructions @@ -1407,6 +1401,7 @@ static __inline void incrWhile( void ) * Complexity weight : 4 * *****************************************************************************/ + #ifndef WMOPS #define IF( a ) if ( a ) @@ -1423,7 +1418,7 @@ static __inline void incrIf( void ) multiCounter[currCounter].If++; call_occurred = 0; - funcId_where_last_call_to_else_occurred = INT_MAX; + funcId_where_last_call_to_else_occurred = -100; } #endif /* ifndef WMOPS */ @@ -1439,6 +1434,7 @@ static __inline void incrIf( void ) * Complexity weight : 4 * *****************************************************************************/ + #ifndef WMOPS #define ELSE else -- GitLab From aa521f401cbfebc06109d93f1df7f4afc67e4013 Mon Sep 17 00:00:00 2001 From: malenov Date: Tue, 26 Nov 2024 17:35:49 +0100 Subject: [PATCH 05/21] fix dicrepancy when WMOPS_DETAIL is activated --- apps/encoder.c | 6 ++--- lib_com/complex_basop.c | 2 ++ lib_com/enh32.c | 1 - lib_com/enh64.c | 1 - lib_com/enhUL32.c | 1 - lib_com/options.h | 16 +++++-------- lib_debug/wmc_auto.c | 46 +++++++++++++++++++++++++++++++++---- lib_debug/wmc_auto.h | 41 +++++++-------------------------- lib_enc/swb_bwe_enc_lr_fx.c | 2 +- 9 files changed, 62 insertions(+), 54 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index adf7a88af..b79827ce2 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -30,8 +30,9 @@ *******************************************************************************************************/ -#include "lib_enc.h" #include +#include "options.h" +#include "lib_enc.h" #include "cmdl_tools.h" #include "audio_file_reader.h" #include "bitstream_writer.h" @@ -39,7 +40,6 @@ #include "jbm_file_reader.h" #include "masa_file_reader.h" #include "wmc_auto.h" -#include "options.h" #include "stl.h" @@ -786,7 +786,7 @@ cleanup: #define IVAS_DEFAULT_AGC ( 0 ) static void initArgStruct( EncArguments *arg ) -{ +{ /* Set default values here */ arg->inputWavFilename = NULL; arg->outputBitstreamFilename = NULL; diff --git a/lib_com/complex_basop.c b/lib_com/complex_basop.c index 0d641ded6..cf3b40154 100644 --- a/lib_com/complex_basop.c +++ b/lib_com/complex_basop.c @@ -11,6 +11,8 @@ #include "stl.h" +#define WMC_TOOL_SKIP + #ifdef COMPLEX_OPERATOR /* ================================ New Complex Basops ========================= */ diff --git a/lib_com/enh32.c b/lib_com/enh32.c index 7706935b2..59312a314 100644 --- a/lib_com/enh32.c +++ b/lib_com/enh32.c @@ -22,7 +22,6 @@ #include #include #include "stl.h" -#include "enh32.h" #define WMC_TOOL_SKIP diff --git a/lib_com/enh64.c b/lib_com/enh64.c index b6bf268a6..1eb6c865f 100644 --- a/lib_com/enh64.c +++ b/lib_com/enh64.c @@ -17,7 +17,6 @@ #include #include #include "stl.h" -#include "enh64.h" #define WMC_TOOL_SKIP diff --git a/lib_com/enhUL32.c b/lib_com/enhUL32.c index cc3f8065a..6ee620ad4 100644 --- a/lib_com/enhUL32.c +++ b/lib_com/enhUL32.c @@ -25,7 +25,6 @@ #include #include #include "stl.h" -#include "enhUL32.h" #define WMC_TOOL_SKIP diff --git a/lib_com/options.h b/lib_com/options.h index 1d56f4053..ef4baf59f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -54,22 +54,16 @@ #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") */ #endif /* #################### End DEBUGGING switches ############################ */ -#define ENH_U_32_BIT_OPERATOR -#define COMPLEX_OPERATOR -#define ENH_32_BIT_OPERATOR -#define ENH_64_BIT_OPERATOR -#if !defined BASOP_NOGLOB_DEV_USE_GLOBALS -#define BASOP_NOGLOB_DECLARE_LOCAL -#endif - /* ################### Start FIXES switches ########################### */ #define NON_BE_FIX_1048_THRESHOLD_COH_BASOP /* Nokia: Fix 1048 replace comparison with 0 with comparison to threshold, to align with BASOP*/ @@ -90,7 +84,9 @@ /* #################### End FIXES switches ############################ */ #define BASOP_NOGLOB /* Disable global symbols in BASOPs, Overflow/Carry in BASOPs disabled, additional BASOPs in case of Overflow */ - +#ifndef BASOP_NOGLOB_DEV_USE_GLOBALS +#define BASOP_NOGLOB_DECLARE_LOCAL +#endif /* ################### Start BE switches ################################# */ /* only BE switches wrt selection floating point code */ diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index 8aeb372eb..50bbf6f4f 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -18,6 +18,7 @@ #include #include #include +#include #ifndef _MSC_VER #include @@ -156,6 +157,7 @@ int currCounter = 0; int funcId_where_last_call_to_else_occurred; long funcid_total_wmops_at_last_call_to_else; int call_occurred = 1; +char func_name_where_last_call_to_else_occurred[MAX_FUNCTION_NAME_LENGTH + 1]; void reset_wmops( void ) { @@ -288,7 +290,7 @@ void push_wmops_fct( const char *label, ... ) } index_record = i; - /* Create a new record in the list */ + /* Create a new WMOPS record in the list */ if ( new_flag ) { if ( num_wmops_records >= max_num_wmops_records ) @@ -297,9 +299,10 @@ void push_wmops_fct( const char *label, ... ) max_num_wmops_records += MAX_NUM_RECORDS_REALLOC_STEP; wmops = realloc( wmops, max_num_wmops_records * sizeof( wmops_record ) ); multiCounter = realloc( multiCounter, max_num_wmops_records * sizeof( BASIC_OP ) ); + } - /* initilize newly created WMOPS records */ - for ( i = num_wmops_records; i < max_num_wmops_records; i++ ) + /* initilize the new WMOPS record */ + //for ( i = num_wmops_records; i < max_num_wmops_records; i++ ) { strcpy( &wmops[i].label[0], "\0" ); wmops[i].call_number = 0; @@ -333,7 +336,6 @@ void push_wmops_fct( const char *label, ... ) } wmops[i].LastWOper = 0; } - } strcpy( wmops[index_record].label, func_name ); @@ -2435,6 +2437,36 @@ int NE_64( long long int L64_var1, long long int L64_var2 ) #endif /* #ifdef CONTROL_CODE_OPS */ +void incrIf( const char *func_name ) +{ + /* Technical note : + * If the "IF" operator comes just after an "ELSE", its counter + * must not be incremented. + */ + if ( ( currCounter != funcId_where_last_call_to_else_occurred ) || ( strncmp( func_name, func_name_where_last_call_to_else_occurred, MAX_FUNCTION_NAME_LENGTH ) != 0 ) || ( TotalWeightedOperation() != funcid_total_wmops_at_last_call_to_else ) || ( call_occurred == 1 ) ) + multiCounter[currCounter].If++; + + call_occurred = 0; + funcId_where_last_call_to_else_occurred = -100; +} + +void incrElse( const char *func_name ) +{ + multiCounter[currCounter].If++; + + /* We keep track of the funcId of the last function which used ELSE {...} structure. */ + funcId_where_last_call_to_else_occurred = currCounter; + + /* We keep track of the number of WMOPS of this funcId when the ELSE macro was called. */ + funcid_total_wmops_at_last_call_to_else = TotalWeightedOperation(); + + strncpy( func_name_where_last_call_to_else_occurred, func_name, MAX_FUNCTION_NAME_LENGTH ); + func_name_where_last_call_to_else_occurred[MAX_FUNCTION_NAME_LENGTH] = '\0'; + + /* call_occurred is set to 0, in order to count the next IF (if necessary) */ + call_occurred = 0; +} + long TotalWeightedOperation() { int i; @@ -2447,6 +2479,12 @@ long TotalWeightedOperation() for ( i = 0; i < (int) ( sizeof( multiCounter[currCounter] ) / sizeof( unsigned int ) ); i++ ) { + if ( *ptr == UINT_MAX ) + { + printf( "\nError in BASOP complexity counters: multiCounter[%d][%d] = %d !!!\n", currCounter, i, *ptr ); + exit( -1 ); + } + tot += ( ( *ptr++ ) * ( *ptr2++ ) ); } diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index fc0d9f5eb..268685826 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -30,6 +30,10 @@ #pragma GCC system_header #endif +#define ENH_U_32_BIT_OPERATOR +#define COMPLEX_OPERATOR +#define ENH_32_BIT_OPERATOR +#define ENH_64_BIT_OPERATOR #define CONTROL_CODE_OPS /* enable control code operators such as LT_16, GT_16, ... */ @@ -1404,22 +1408,9 @@ static __inline void incrWhile( void ) #ifndef WMOPS #define IF( a ) if ( a ) - #else /* ifndef WMOPS */ -#define IF( a ) if ( incrIf(), a ) - -static __inline void incrIf( void ) -{ - /* Technical note : - * If the "IF" operator comes just after an "ELSE", its counter - * must not be incremented. - */ - if ( ( currCounter != funcId_where_last_call_to_else_occurred ) || ( TotalWeightedOperation() != funcid_total_wmops_at_last_call_to_else ) || ( call_occurred == 1 ) ) - multiCounter[currCounter].If++; - - call_occurred = 0; - funcId_where_last_call_to_else_occurred = -100; -} +#define IF( a ) if ( incrIf( __func__ ), a ) +void incrIf( const char *func_name ); #endif /* ifndef WMOPS */ @@ -1437,25 +1428,9 @@ static __inline void incrIf( void ) #ifndef WMOPS #define ELSE else - #else /* ifndef WMOPS */ -#define ELSE \ - else if ( incrElse(), 0 ); \ - else - -static __inline void incrElse( void ) -{ - multiCounter[currCounter].If++; - - /* We keep track of the funcId of the last function which used ELSE {...} structure. */ - funcId_where_last_call_to_else_occurred = currCounter; - - /* We keep track of the number of WMOPS of this funcId when the ELSE macro was called. */ - funcid_total_wmops_at_last_call_to_else = TotalWeightedOperation(); - - /* call_occurred is set to 0, in order to count the next IF (if necessary) */ - call_occurred = 0; -} +#define ELSE else if ( incrElse( __func__ ), 0 ); else +void incrElse( const char *func_name ); #endif /* ifndef WMOPS */ diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index d43861d8b..50257b7d9 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -35,7 +35,7 @@ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "rom_com.h" -#include "enh32.h" +#include "stl.h" #include "prot.h" /*--------------------------------------------------------------------------* -- GitLab From a1e7d489c294668de85236ae86158c93b01c49a6 Mon Sep 17 00:00:00 2001 From: malenov Date: Tue, 26 Nov 2024 17:37:36 +0100 Subject: [PATCH 06/21] cleanup --- lib_debug/wmc_auto.c | 61 +++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index 50bbf6f4f..1f6117244 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -301,41 +301,38 @@ void push_wmops_fct( const char *label, ... ) multiCounter = realloc( multiCounter, max_num_wmops_records * sizeof( BASIC_OP ) ); } - /* initilize the new WMOPS record */ - //for ( i = num_wmops_records; i < max_num_wmops_records; i++ ) - { - strcpy( &wmops[i].label[0], "\0" ); - wmops[i].call_number = 0; - wmops[i].update_cnt = 0; - for ( j = 0; j < MAX_CALL_TREE_DEPTH; j++ ) - { - wmops[i].call_tree[j] = -1; - } - wmops[i].start_selfcnt = 0.0; - wmops[i].current_selfcnt = 0.0; - wmops[i].max_selfcnt = 0.0; - wmops[i].min_selfcnt = DOUBLE_MAX; - wmops[i].tot_selfcnt = 0.0; - wmops[i].start_cnt = 0.0; - wmops[i].current_cnt = 0.0; - wmops[i].max_cnt = 0.0; - wmops[i].min_cnt = DOUBLE_MAX; - wmops[i].tot_cnt = 0.0; + /* initilize the new WMOPS record */ + strcpy( &wmops[i].label[0], "\0" ); + wmops[i].call_number = 0; + wmops[i].update_cnt = 0; + for ( j = 0; j < MAX_CALL_TREE_DEPTH; j++ ) + { + wmops[i].call_tree[j] = -1; + } + wmops[i].start_selfcnt = 0.0; + wmops[i].current_selfcnt = 0.0; + wmops[i].max_selfcnt = 0.0; + wmops[i].min_selfcnt = DOUBLE_MAX; + wmops[i].tot_selfcnt = 0.0; + wmops[i].start_cnt = 0.0; + wmops[i].current_cnt = 0.0; + wmops[i].max_cnt = 0.0; + wmops[i].min_cnt = DOUBLE_MAX; + wmops[i].tot_cnt = 0.0; #ifdef WMOPS_WC_FRAME_ANALYSIS - wmops[i].wc_cnt = 0.0; - wmops[i].wc_selfcnt = 0.0; - wmops[i].current_call_number = 0; - wmops[i].wc_call_number = -1; + wmops[i].wc_cnt = 0.0; + wmops[i].wc_selfcnt = 0.0; + wmops[i].current_call_number = 0; + wmops[i].wc_call_number = -1; #endif - /* initialize BASOP WMOPS counters */ - ptr = (unsigned int *) &multiCounter[i]; - for ( j = 0; j < (int) ( sizeof( BASIC_OP ) / sizeof( unsigned int ) ); j++ ) - { - *ptr++ = 0; - } - wmops[i].LastWOper = 0; - } + /* initialize BASOP WMOPS counters */ + ptr = (unsigned int *) &multiCounter[i]; + for ( j = 0; j < (int) ( sizeof( BASIC_OP ) / sizeof( unsigned int ) ); j++ ) + { + *ptr++ = 0; + } + wmops[i].LastWOper = 0; strcpy( wmops[index_record].label, func_name ); -- GitLab From bd6cae01c4f0b2acdcfe5ea90179f7a25bbccedc Mon Sep 17 00:00:00 2001 From: malenov Date: Wed, 27 Nov 2024 12:22:04 +0100 Subject: [PATCH 07/21] cleanup --- lib_com/enh1632.c | 4 ++-- lib_com/options.h | 8 ++++---- lib_com/tools_fx.c | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib_com/enh1632.c b/lib_com/enh1632.c index 822ea80b0..124652b79 100644 --- a/lib_com/enh1632.c +++ b/lib_com/enh1632.c @@ -392,14 +392,14 @@ Word16 shl_ro( Word16 var1, Word16 var2, Flag *Overflow ) var2 = -var2; var_out = shr_ro( var1, var2, Overflow ); #ifdef WMOPS -#ifndef FIX_SHR_RO_COMPLEXITY +#ifndef FIX_1049_SHR_RO_COMPLEXITY multiCounter[currCounter].shr_r--; #endif #endif /* ifdef WMOPS */ } #ifdef WMOPS -#ifndef FIX_SHR_RO_COMPLEXITY +#ifndef FIX_1049_SHR_RO_COMPLEXITY multiCounter[currCounter].shl_r++; #endif #endif /* ifdef WMOPS */ diff --git a/lib_com/options.h b/lib_com/options.h index ef4baf59f..a59d5293e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -75,11 +75,11 @@ #define NON_BE_1055_RESET_LP_MEMORIES /* VA: issue 1055: Correctly reset LP filter MA and AR memories in bitrate switching */ #define NON_BE_FIX_1137_GSC_IVAS_FXFLT_DECODING /* VA: Add fix point bit allocation for special GSC mode such that float and fixed point have the same final bit allocation */ #define NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE /* VA: issue 1132: prevent division by extremely low energy value in SWB TBE */ -#define NON_BE_FIX_807_MASA_DTX_BRSW /* Nokia: adds fix to check existence of DTX encoder for secondary channel in TD mode */ +#define NON_BE_FIX_807_MASA_DTX_BRSW /* Nokia: adds fix to check existence of DTX encoder for secondary channel in TD mode */ #define FIX_BASOP_812_NAN_COHSNR /* FhG: BASOP issue 812: fix nan values in sparse frames for cohSNR value in ITD estimation*/ -#define FIX_828_PORT_1152_FROM_FLT_REPO /* FhG: fix for issue 828 - fix uninitialized value used in BASOP */ -#define FIX_SHR_RO_COMPLEXITY /* VA: fix for issue 1049: incorrect counting of complexity in the shr_ro() function */ -#define FIX_IF_ELSE_CMPLX_DISCREPANCY /* fix IF-ELSE discpreancy within the Copy() function depending on memory locations of x[] and y[] */ +#define FIX_828_PORT_1152_FROM_FLT_REPO /* FhG: fix for issue 828 - fix uninitialized value used in BASOP */ +#define FIX_1049_SHR_RO_COMPLEXITY /* VA: fix for issue 1049: incorrect counting of complexity in the shr_ro() function */ +#define FIX_1052_COPY_CMPLX_DISCREPANCY /* fix IF-ELSE discpreancy within the Copy() function depending on memory locations of x[] and y[] */ /* #################### End FIXES switches ############################ */ diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 997dd8ec5..6895083a8 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -489,7 +489,7 @@ void Copy( } } -#ifdef FIX_IF_ELSE_CMPLX_DISCREPANCY +#ifdef FIX_1052_COPY_CMPLX_DISCREPANCY IF( y >= x ) #else ELSE @@ -523,7 +523,7 @@ void Copy64( } } -#ifdef FIX_IF_ELSE_CMPLX_DISCREPANCY +#ifdef FIX_1052_COPY_CMPLX_DISCREPANCY IF( y >= x ) #else ELSE @@ -572,7 +572,7 @@ void Copy_pword( } } -#ifdef FIX_IF_ELSE_CMPLX_DISCREPANCY +#ifdef FIX_1052_COPY_CMPLX_DISCREPANCY IF( y >= x ) #else ELSE @@ -608,7 +608,7 @@ void Copy32( } } -#ifdef FIX_IF_ELSE_CMPLX_DISCREPANCY +#ifdef FIX_1052_COPY_CMPLX_DISCREPANCY IF( y >= x ) #else ELSE -- GitLab From ab20d2d3512d4a581a4b596ebfc000b0a8ab1cad Mon Sep 17 00:00:00 2001 From: malenov Date: Fri, 29 Nov 2024 16:50:04 +0100 Subject: [PATCH 08/21] resolve minor discrepancy in WMOPS numbers when WMOPS_DETAIL is used --- lib_debug/wmc_auto.c | 168 ++++++----- lib_debug/wmc_auto.h | 647 ++++++++++--------------------------------- 2 files changed, 234 insertions(+), 581 deletions(-) diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index 1f6117244..b209993bc 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -41,6 +41,7 @@ int cntr_push_pop = 0; /* global counter for checking balanced push_wmops()/pop_ * Complexity counting tool *--------------------------------------------------------------------*/ + #define MAX_FUNCTION_NAME_LENGTH 200 /* Maximum length of the function name */ #define MAX_PARAMS_LENGTH 200 /* Maximum length of the function parameter string */ #define MAX_NUM_RECORDS 300 /* Initial maximum number of records -> might be increased during runtime, if needed */ @@ -78,7 +79,6 @@ typedef struct } wmops_record; double ops_cnt; -double prom_cnt_wmc; double inst_cnt[NUM_INST]; static wmops_record *wmops = NULL; @@ -153,7 +153,7 @@ static BASIC_OP op_weight = { }; BASIC_OP *multiCounter = NULL; -int currCounter = 0; +unsigned int currCounter = 0; int funcId_where_last_call_to_else_occurred; long funcid_total_wmops_at_last_call_to_else; int call_occurred = 1; @@ -162,7 +162,6 @@ char func_name_where_last_call_to_else_occurred[MAX_FUNCTION_NAME_LENGTH + 1]; void reset_wmops( void ) { int i, j; - unsigned int *ptr; num_wmops_records = 0; max_num_wmops_records = MAX_NUM_RECORDS; @@ -199,7 +198,7 @@ void reset_wmops( void ) } /* initilize the list of WMOPS records */ - /* initilize the BASOP WMOPS counters */ + /* initilize BASOP operation counters */ for ( i = 0; i < max_num_wmops_records; i++ ) { strcpy( &wmops[i].label[0], "\0" ); @@ -226,13 +225,8 @@ void reset_wmops( void ) wmops[i].wc_call_number = -1; #endif - /* clear all BASOP operation counters */ - ptr = (unsigned int *) &multiCounter[i]; - for ( j = 0; j < (int) ( sizeof( BASIC_OP ) / sizeof( unsigned int ) ); j++ ) - { - *ptr++ = 0; - } - wmops[i].LastWOper = 0; + /* Reset BASOP operation counter */ + Reset_BASOP_WMOPS_counter( i ); } /* allocate the list of wmops callers to track the sequence of function calls */ @@ -254,7 +248,8 @@ void reset_wmops( void ) wmops_caller_stack[i] = -1; } - /* initialize auxiliary BASOP WMOPS variables */ + /* initialize auxiliary BASOP counter variables */ + currCounter = 0; /* Note: currCounter cannot be set to -1 because it's defined as unsigned int ! */ call_occurred = 1; funcId_where_last_call_to_else_occurred = -100; @@ -265,7 +260,7 @@ void push_wmops_fct( const char *label, ... ) { int new_flag; int i, j, index_record; - unsigned int *ptr; + long tot; va_list arg; char func_name[MAX_FUNCTION_NAME_LENGTH] = ""; @@ -302,44 +297,39 @@ void push_wmops_fct( const char *label, ... ) } /* initilize the new WMOPS record */ - strcpy( &wmops[i].label[0], "\0" ); - wmops[i].call_number = 0; - wmops[i].update_cnt = 0; + strcpy( &wmops[index_record].label[0], "\0" ); + wmops[index_record].call_number = 0; + wmops[index_record].update_cnt = 0; for ( j = 0; j < MAX_CALL_TREE_DEPTH; j++ ) { - wmops[i].call_tree[j] = -1; + wmops[index_record].call_tree[j] = -1; } - wmops[i].start_selfcnt = 0.0; - wmops[i].current_selfcnt = 0.0; - wmops[i].max_selfcnt = 0.0; - wmops[i].min_selfcnt = DOUBLE_MAX; - wmops[i].tot_selfcnt = 0.0; - wmops[i].start_cnt = 0.0; - wmops[i].current_cnt = 0.0; - wmops[i].max_cnt = 0.0; - wmops[i].min_cnt = DOUBLE_MAX; - wmops[i].tot_cnt = 0.0; + wmops[index_record].start_selfcnt = 0.0; + wmops[index_record].current_selfcnt = 0.0; + wmops[index_record].max_selfcnt = 0.0; + wmops[index_record].min_selfcnt = DOUBLE_MAX; + wmops[index_record].tot_selfcnt = 0.0; + wmops[index_record].start_cnt = 0.0; + wmops[index_record].current_cnt = 0.0; + wmops[index_record].max_cnt = 0.0; + wmops[index_record].min_cnt = DOUBLE_MAX; + wmops[index_record].tot_cnt = 0.0; #ifdef WMOPS_WC_FRAME_ANALYSIS - wmops[i].wc_cnt = 0.0; - wmops[i].wc_selfcnt = 0.0; - wmops[i].current_call_number = 0; - wmops[i].wc_call_number = -1; + wmops[index_record].wc_cnt = 0.0; + wmops[index_record].wc_selfcnt = 0.0; + wmops[index_record].current_call_number = 0; + wmops[index_record].wc_call_number = -1; #endif - /* initialize BASOP WMOPS counters */ - ptr = (unsigned int *) &multiCounter[i]; - for ( j = 0; j < (int) ( sizeof( BASIC_OP ) / sizeof( unsigned int ) ); j++ ) - { - *ptr++ = 0; - } - wmops[i].LastWOper = 0; + /* Reset BASOP operation counter */ + Reset_BASOP_WMOPS_counter( index_record ); strcpy( wmops[index_record].label, func_name ); num_wmops_records++; } - /* Push the current context info to the new record */ + /* Update the WMOPS context info of the old record before switching to the new one */ if ( current_record >= 0 ) { if ( wmops_caller_stack_index >= max_wmops_caller_stack_index ) @@ -350,7 +340,9 @@ void push_wmops_fct( const char *label, ... ) } wmops_caller_stack[wmops_caller_stack_index++] = current_record; - /* accumulate op counts */ + /* add the BASOP complexity to the counter and update the old WMOPS counter */ + tot = DeltaWeightedOperation( current_record ); + ops_cnt += tot; wmops[current_record].current_selfcnt += ops_cnt - wmops[current_record].start_selfcnt; /* update call tree */ @@ -368,7 +360,14 @@ void push_wmops_fct( const char *label, ... ) } } - /* update the current context info */ + /* Need to reset the BASOP operation counter of the 0th record in every push_wmops() */ + /* because currCounter can never be -1 */ + if ( current_record == -1 && index_record == 0 ) + { + wmops[index_record].LastWOper = TotalWeightedOperation( index_record ); + } + + /* switch to the new record */ current_record = index_record; wmops[index_record].start_selfcnt = ops_cnt; wmops[index_record].start_cnt = ops_cnt; @@ -377,8 +376,9 @@ void push_wmops_fct( const char *label, ... ) wmops[index_record].current_call_number++; #endif - /* set the ID of BASOP functions counters */ - Set_BASOP_WMOPS_counter( index_record ); + /* set the ID of the current BASOP operations counter */ + currCounter = index_record; + call_occurred = 1; return; } @@ -395,7 +395,7 @@ void pop_wmops( void ) } /* add the BASOP complexity to the counter */ - tot = DeltaWeightedOperation(); + tot = DeltaWeightedOperation( currCounter ); ops_cnt += tot; /* update count of current record */ @@ -407,15 +407,23 @@ void pop_wmops( void ) { current_record = wmops_caller_stack[--wmops_caller_stack_index]; wmops[current_record].start_selfcnt = ops_cnt; - - /* set the ID of the previous BASOP counter */ - Set_BASOP_WMOPS_counter( current_record ); } else { current_record = -1; } + /* set the ID of the previous BASOP operations counter */ + if ( current_record == -1 ) + { + currCounter = 0; /* Note: currCounter cannot be set to -1 because it's defined as unsigned int ! */ + } + else + { + currCounter = current_record; + } + call_occurred = 1; + return; } @@ -507,9 +515,9 @@ void update_wmops( void ) wmops[i].current_call_number = 0; #endif - /* reset the BASOP counter */ - Set_BASOP_WMOPS_counter( i ); - Reset_BASOP_WMOPS_counter(); + /* reset the BASOP operations counter */ + call_occurred = 1; + Reset_BASOP_WMOPS_counter( i ); } current_cnt = ops_cnt - start_cnt; @@ -2436,11 +2444,9 @@ int NE_64( long long int L64_var1, long long int L64_var2 ) void incrIf( const char *func_name ) { - /* Technical note : - * If the "IF" operator comes just after an "ELSE", its counter - * must not be incremented. - */ - if ( ( currCounter != funcId_where_last_call_to_else_occurred ) || ( strncmp( func_name, func_name_where_last_call_to_else_occurred, MAX_FUNCTION_NAME_LENGTH ) != 0 ) || ( TotalWeightedOperation() != funcid_total_wmops_at_last_call_to_else ) || ( call_occurred == 1 ) ) + /* Technical note: If the "IF" operator comes just after an "ELSE", its counter must not be incremented */ + /* The following auxiliary variables are used to check if the "IF" operator doesn't immediately follow an "ELSE" operator */ + if ( ( (int) currCounter != funcId_where_last_call_to_else_occurred ) || ( strncmp( func_name, func_name_where_last_call_to_else_occurred, MAX_FUNCTION_NAME_LENGTH ) != 0 ) || ( TotalWeightedOperation( currCounter) != funcid_total_wmops_at_last_call_to_else ) || ( call_occurred == 1 ) ) multiCounter[currCounter].If++; call_occurred = 0; @@ -2451,34 +2457,35 @@ void incrElse( const char *func_name ) { multiCounter[currCounter].If++; - /* We keep track of the funcId of the last function which used ELSE {...} structure. */ + /* Save the BASOP counter Id in the last function in which ELSE() has been called */ funcId_where_last_call_to_else_occurred = currCounter; - /* We keep track of the number of WMOPS of this funcId when the ELSE macro was called. */ - funcid_total_wmops_at_last_call_to_else = TotalWeightedOperation(); + /* Save the BASOP comeplxity in the last call of the ELSE() statement */ + funcid_total_wmops_at_last_call_to_else = TotalWeightedOperation( currCounter ); + /* Save the function name in the last call of the ELSE() statement */ strncpy( func_name_where_last_call_to_else_occurred, func_name, MAX_FUNCTION_NAME_LENGTH ); func_name_where_last_call_to_else_occurred[MAX_FUNCTION_NAME_LENGTH] = '\0'; - /* call_occurred is set to 0, in order to count the next IF (if necessary) */ + /* Set call_occurred to 0 to prevent counting of complexity of the next "immediate" IF statement */ call_occurred = 0; } -long TotalWeightedOperation() +long TotalWeightedOperation( unsigned int CounterId ) { int i; unsigned int *ptr, *ptr2; long tot; tot = 0; - ptr = (unsigned int *) &multiCounter[currCounter]; + ptr = (unsigned int *) &multiCounter[CounterId]; ptr2 = (unsigned int *) &op_weight; - for ( i = 0; i < (int) ( sizeof( multiCounter[currCounter] ) / sizeof( unsigned int ) ); i++ ) + for ( i = 0; i < (int) ( sizeof( multiCounter[CounterId] ) / sizeof( unsigned int ) ); i++ ) { if ( *ptr == UINT_MAX ) { - printf( "\nError in BASOP complexity counters: multiCounter[%d][%d] = %d !!!\n", currCounter, i, *ptr ); + printf( "\nError in BASOP complexity counters: multiCounter[%d][%d] = %d !!!\n", CounterId, i, *ptr ); exit( -1 ); } @@ -2488,47 +2495,32 @@ long TotalWeightedOperation() return ( tot ); } -long DeltaWeightedOperation( void ) +long DeltaWeightedOperation( unsigned int CounterId ) { long NewWOper, delta; - NewWOper = TotalWeightedOperation(); + NewWOper = TotalWeightedOperation( CounterId ); - delta = NewWOper - wmops[currCounter].LastWOper; - wmops[currCounter].LastWOper = NewWOper; + delta = NewWOper - wmops[CounterId].LastWOper; + wmops[CounterId].LastWOper = NewWOper; return ( delta ); } -/* Set the counter group to use, default is zero */ -void Set_BASOP_WMOPS_counter( int counterId ) -{ - if ( ( counterId > num_wmops_records ) || ( counterId < 0 ) ) - { - currCounter = 0; - return; - } - - currCounter = counterId; - call_occurred = 1; - - return; -} - -/* Resets the current BASOP WMOPS counter */ -void Reset_BASOP_WMOPS_counter( void ) +/* Resets BASOP operation counter */ +void Reset_BASOP_WMOPS_counter( unsigned int counterId ) { int i; long *ptr; - /* clear the current BASOP operation counter before new frame begins */ - ptr = (long *) &multiCounter[currCounter]; - for ( i = 0; i < (int) ( sizeof( multiCounter[currCounter] ) / sizeof( long ) ); i++ ) + /* reset the current BASOP operation counter */ + ptr = (long *) &multiCounter[counterId]; + for ( i = 0; i < (int) ( sizeof( multiCounter[counterId] ) / sizeof( long ) ); i++ ) { *ptr++ = 0; } - wmops[currCounter].LastWOper = 0; + wmops[counterId].LastWOper = 0; return; } \ No newline at end of file diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index 268685826..bd4135922 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -30,12 +30,11 @@ #pragma GCC system_header #endif -#define ENH_U_32_BIT_OPERATOR -#define COMPLEX_OPERATOR #define ENH_32_BIT_OPERATOR #define ENH_64_BIT_OPERATOR -#define CONTROL_CODE_OPS /* enable control code operators such as LT_16, GT_16, ... */ - +#define ENH_U_32_BIT_OPERATOR +#define COMPLEX_OPERATOR +#define CONTROL_CODE_OPS /* enable control code operators such as LT_16, GT_16, ... */ #ifdef WMOPS enum instructions @@ -63,6 +62,30 @@ enum instructions NUM_INST }; +extern double ops_cnt; +extern double inst_cnt[NUM_INST]; + +/******************************************************************/ +/* NOTES: */ +/* The 'wmc_flag_' flag is global to avoid declaration in every */ +/* function and 'static' to avoid clashing with other modules */ +/* that include this header file. */ +/* */ +/* The declarations of 'wmc_flag_' and 'wops_' in this header */ +/* file prevent the addition of a 'C' file to the Project. */ +/******************************************************************/ + +/* General Purpose Global int */ +static int wmc_flag_ = 0; + +#define push_wmops( ... ) push_wmops_fct( __VA_ARGS__, NULL ) +void push_wmops_fct( const char *label, ... ); +void pop_wmops( void ); +void reset_wmops( void ); +void print_wmops( void ); +void update_wmops( void ); +void update_mem( void ); + #define _ADD_C 1 #define _ABS_C 1 #define _MULT_C 1 @@ -84,492 +107,157 @@ enum instructions #define _LOG_C 25 #define _MISC_C 1 -#define _ADD_P 1 -#define _ABS_P 1 -#define _MULT_P 1 -#define _MAC_P 1 -#define _MOVE_P 1 -#define _STORE_P 0 -#define _LOGIC_P 1 -#define _SHIFT_P 1 -#define _BRANCH_P 2 -#define _DIV_P 2 -#define _SQRT_P 2 -#define _TRANS_P 2 -#define _FUNC_P 2 /* need to add number of arguments */ -#define _LOOP_P 1 -#define _INDIRECT_P 2 -#define _PTR_INIT_P 1 -#define _TEST_P 1 -#define _POWER_P 2 -#define _LOG_P 2 -#define _MISC_P 1 - -#define ADD( x ) \ - { \ - { \ - ops_cnt += ( _ADD_C * ( x ) ); \ - inst_cnt[_ADD] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _ADD_P * ( x ) ); \ - } \ - } \ - } \ - } -#define ABS( x ) \ - { \ - { \ - ops_cnt += ( _ABS_C * ( x ) ); \ - inst_cnt[_ABS] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _ABS_P * ( x ) ); \ - } \ - } \ - } \ +#define ADD( x ) \ + { \ + ops_cnt += ( _ADD_C * ( x ) ); \ + inst_cnt[_ADD] += ( x ); \ } -#define MULT( x ) \ - { \ - { \ - ops_cnt += ( _MULT_C * ( x ) ); \ - inst_cnt[_MULT] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _MULT_P * ( x ) ); \ - } \ - } \ - } \ +#define ABS( x ) \ + { \ + ops_cnt += ( _ABS_C * ( x ) ); \ + inst_cnt[_ABS] += ( x ); \ } -#define MAC( x ) \ - { \ - { \ - ops_cnt += ( _MAC_C * ( x ) ); \ - inst_cnt[_MAC] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _MAC_P * ( x ) ); \ - } \ - } \ - } \ +#define MULT( x ) \ + { \ + ops_cnt += ( _MULT_C * ( x ) ); \ + inst_cnt[_MULT] += ( x ); \ } -#define MOVE( x ) \ - { \ - { \ - ops_cnt += ( _MOVE_C * ( x ) ); \ - inst_cnt[_MOVE] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _MOVE_P * ( x ) ); \ - } \ - } \ - } \ +#define MAC( x ) \ + { \ + ops_cnt += ( _MAC_C * ( x ) ); \ + inst_cnt[_MAC] += ( x ); \ } -#define STORE( x ) \ - { \ - { \ - ops_cnt += ( _STORE_C * ( x ) ); \ - inst_cnt[_STORE] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _STORE_P * ( x ) ); \ - } \ - } \ - } \ +#define MOVE( x ) \ + { \ + ops_cnt += ( _MOVE_C * ( x ) ); \ + inst_cnt[_MOVE] += ( x ); \ } -#define LOGIC( x ) \ - { \ - { \ - ops_cnt += ( _LOGIC_C * ( x ) ); \ - inst_cnt[_LOGIC] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _LOGIC_P * ( x ) ); \ - } \ - } \ - } \ +#define STORE( x ) \ + { \ + ops_cnt += ( _STORE_C * ( x ) ); \ + inst_cnt[_STORE] += ( x ); \ } -#define SHIFT( x ) \ - { \ - { \ - ops_cnt += ( _SHIFT_C * ( x ) ); \ - inst_cnt[_SHIFT] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _SHIFT_P * ( x ) ); \ - } \ - } \ - } \ +#define LOGIC( x ) \ + { \ + ops_cnt += ( _LOGIC_C * ( x ) ); \ + inst_cnt[_LOGIC] += ( x ); \ } -#define BRANCH( x ) \ - { \ - { \ - ops_cnt += ( _BRANCH_C * ( x ) ); \ - inst_cnt[_BRANCH] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _BRANCH_P * ( x ) ); \ - } \ - } \ - } \ +#define SHIFT( x ) \ + { \ + ops_cnt += ( _SHIFT_C * ( x ) ); \ + inst_cnt[_SHIFT] += ( x ); \ } -#define DIV( x ) \ - { \ - { \ - ops_cnt += ( _DIV_C * ( x ) ); \ - inst_cnt[_DIV] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _DIV_P * ( x ) ); \ - } \ - } \ - } \ +#define BRANCH( x ) \ + { \ + ops_cnt += ( _BRANCH_C * ( x ) ); \ + inst_cnt[_BRANCH] += ( x ); \ } -#define SQRT( x ) \ - { \ - { \ - ops_cnt += ( _SQRT_C * ( x ) ); \ - inst_cnt[_SQRT] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _SQRT_P * ( x ) ); \ - } \ - } \ - } \ +#define DIV( x ) \ + { \ + ops_cnt += ( _DIV_C * ( x ) ); \ + inst_cnt[_DIV] += ( x ); \ } -#define TRANS( x ) \ - { \ - { \ - ops_cnt += ( _TRANS_C * ( x ) ); \ - inst_cnt[_TRANS] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _TRANS_P * ( x ) ); \ - } \ - } \ - } \ +#define SQRT( x ) \ + { \ + ops_cnt += ( _SQRT_C * ( x ) ); \ + inst_cnt[_SQRT] += ( x ); \ } -#define LOOP( x ) \ - { \ - { \ - ops_cnt += ( _LOOP_C * ( x ) ); \ - inst_cnt[_LOOP] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _LOOP_P * ( x ) ); \ - } \ - } \ - } \ +#define TRANS( x ) \ + { \ + ops_cnt += ( _TRANS_C * ( x ) ); \ + inst_cnt[_TRANS] += ( x ); \ } -#define INDIRECT( x ) \ - { \ - { \ - ops_cnt += ( _INDIRECT_C * ( x ) ); \ - inst_cnt[_INDIRECT] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _INDIRECT_P * ( x ) ); \ - } \ - } \ - } \ +#define LOOP( x ) \ + { \ + ops_cnt += ( _LOOP_C * ( x ) ); \ + inst_cnt[_LOOP] += ( x ); \ } -#define PTR_INIT( x ) \ - { \ - { \ - ops_cnt += ( _PTR_INIT_C * ( x ) ); \ - inst_cnt[_PTR_INIT] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _PTR_INIT_P * ( x ) ); \ - } \ - } \ - } \ +#define INDIRECT( x ) \ + { \ + ops_cnt += ( _INDIRECT_C * ( x ) ); \ + inst_cnt[_INDIRECT] += ( x ); \ } -#define TEST( x ) \ - { \ - { \ - ops_cnt += ( _TEST_C * ( x ) ); \ - inst_cnt[_TEST] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _TEST_P * ( x ) ); \ - } \ - } \ - } \ +#define PTR_INIT( x ) \ + { \ + ops_cnt += ( _PTR_INIT_C * ( x ) ); \ + inst_cnt[_PTR_INIT] += ( x ); \ } -#define POWER( x ) \ - { \ - { \ - ops_cnt += ( _POWER_C * ( x ) ); \ - inst_cnt[_POWER] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _POWER_P * ( x ) ); \ - } \ - } \ - } \ +#define TEST( x ) \ + { \ + ops_cnt += ( _TEST_C * ( x ) ); \ + inst_cnt[_TEST] += ( x ); \ } -#define LOG( x ) \ - { \ - { \ - ops_cnt += ( _LOG_C * ( x ) ); \ - inst_cnt[_LOG] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _LOG_P * ( x ) ); \ - } \ - } \ - } \ +#define POWER( x ) \ + { \ + ops_cnt += ( _POWER_C * ( x ) ); \ + inst_cnt[_POWER] += ( x ); \ } -#define MISC( x ) \ - { \ - { \ - ops_cnt += ( _MISC_C * ( x ) ); \ - inst_cnt[_MISC] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _MISC_P * ( x ) ); \ - } \ - } \ - } \ +#define LOG( x ) \ + { \ + ops_cnt += ( _LOG_C * ( x ) ); \ + inst_cnt[_LOG] += ( x ); \ } - -#define FUNC( x ) \ - { \ - { \ - ops_cnt += ( _FUNC_C + _MOVE_C * ( x ) ); \ - inst_cnt[_FUNC]++; \ - inst_cnt[_MOVE] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _FUNC_P + _MOVE_P * ( x ) ); \ - } \ - } \ - } \ +#define MISC( x ) \ + { \ + ops_cnt += ( _MISC_C * ( x ) ); \ + inst_cnt[_MISC] += ( x ); \ } - -#define DADD( x ) \ - { \ - { \ - ops_cnt += ( 2 * _ADD_C * ( x ) ); \ - inst_cnt[_ADD] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _ADD_P * ( x ) ); \ - } \ - } \ - } \ +#define FUNC( x ) \ + { \ + ops_cnt += ( _FUNC_C + _MOVE_C * ( x ) ); \ + inst_cnt[_FUNC]++; \ + inst_cnt[_MOVE] += ( x ); \ } -#define DMULT( x ) \ - { \ - { \ - ops_cnt += ( 2 * _MULT_C * ( x ) ); \ - inst_cnt[_MULT] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _MULT_P * ( x ) ); \ - } \ - } \ - } \ +#define DADD( x ) \ + { \ + ops_cnt += ( 2 * _ADD_C * ( x ) ); \ + inst_cnt[_ADD] += ( x ); \ } -#define DMAC( x ) \ - { \ - { \ - ops_cnt += ( 2 * _MAC_C * ( x ) ); \ - inst_cnt[_MAC] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _MAC_P * ( x ) ); \ - } \ - } \ - } \ +#define DMULT( x ) \ + { \ + ops_cnt += ( 2 * _MULT_C * ( x ) ); \ + inst_cnt[_MULT] += ( x ); \ } -#define DMOVE( x ) \ - { \ - { \ - ops_cnt += ( 2 * _MOVE_C * ( x ) ); \ - inst_cnt[_MOVE] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _MOVE_P * ( x ) ); \ - } \ - } \ - } \ +#define DMAC( x ) \ + { \ + ops_cnt += ( 2 * _MAC_C * ( x ) ); \ + inst_cnt[_MAC] += ( x ); \ } -#define DSTORE( x ) \ - { \ - { \ - ops_cnt += ( 2 * _STORE_C * ( x ) ); \ - inst_cnt[_STORE] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _STORE_P * ( x ) ); \ - } \ - } \ - } \ +#define DMOVE( x ) \ + { \ + ops_cnt += ( 2 * _MOVE_C * ( x ) ); \ + inst_cnt[_MOVE] += ( x ); \ } -#define DLOGIC( x ) \ - { \ - { \ - ops_cnt += ( 2 * _LOGIC_C * ( x ) ); \ - inst_cnt[_LOGIC] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _LOGIC_P * ( x ) ); \ - } \ - } \ - } \ +#define DSTORE( x ) \ + { \ + ops_cnt += ( 2 * _STORE_C * ( x ) ); \ + inst_cnt[_STORE] += ( x ); \ } -#define DSHIFT( x ) \ - { \ - { \ - ops_cnt += ( 2 * _SHIFT_C * ( x ) ); \ - inst_cnt[_SHIFT] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _SHIFT_P * ( x ) ); \ - } \ - } \ - } \ +#define DLOGIC( x ) \ + { \ + ops_cnt += ( 2 * _LOGIC_C * ( x ) ); \ + inst_cnt[_LOGIC] += ( x ); \ } -#define DDIV( x ) \ - { \ - { \ - ops_cnt += ( 2 * _DIV_C * ( x ) ); \ - inst_cnt[_DIV] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _DIV_P * ( x ) ); \ - } \ - } \ - } \ +#define DSHIFT( x ) \ + { \ + ops_cnt += ( 2 * _SHIFT_C * ( x ) ); \ + inst_cnt[_SHIFT] += ( x ); \ } -#define DSQRT( x ) \ - { \ - { \ - ops_cnt += ( 2 * _SQRT_C * ( x ) ); \ - inst_cnt[_SQRT] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _SQRT_P * ( x ) ); \ - } \ - } \ - } \ +#define DDIV( x ) \ + { \ + ops_cnt += ( 2 * _DIV_C * ( x ) ); \ + inst_cnt[_DIV] += ( x ); \ } -#define DTRANS( x ) \ - { \ - { \ - ops_cnt += ( 2 * _TRANS_C * ( x ) ); \ - inst_cnt[_TRANS] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt_wmc += ( _TRANS_P * ( x ) ); \ - } \ - } \ - } \ +#define DSQRT( x ) \ + { \ + ops_cnt += ( 2 * _SQRT_C * ( x ) ); \ + inst_cnt[_SQRT] += ( x ); \ } - -extern double ops_cnt; -extern double prom_cnt_wmc; -extern double inst_cnt[NUM_INST]; - -#define push_wmops( ... ) push_wmops_fct( __VA_ARGS__, NULL ) -void push_wmops_fct( const char *label, ... ); -void pop_wmops( void ); -void reset_wmops( void ); -void print_wmops( void ); -void update_wmops( void ); -void update_mem( void ); +#define DTRANS( x ) \ + { \ + ops_cnt += ( 2 * _TRANS_C * ( x ) ); \ + inst_cnt[_TRANS] += ( x ); \ + } #else @@ -615,14 +303,6 @@ extern int cntr_push_pop; #endif -/* mac & msu (Non Instrumented Versions) */ -#ifndef mac -#define mac( a, b, c ) ( ( a ) + ( b ) * ( c ) ) -#endif -#ifndef msu -#define msu( a, b, c ) ( ( a ) - ( b ) * ( c ) ) -#endif - #ifndef WMOPS /* DESACTIVATE the Counting Mechanism */ #define OP_COUNT_( op, n ) @@ -638,24 +318,8 @@ extern int cntr_push_pop; #else -/* '*ops_cnt_ptr' is Used to Avoid: "warning: operation on 'ops_cnt' may be undefined" with Cygwin gcc Compiler */ -static double *ops_cnt_ptr = &ops_cnt; -#define OP_COUNT_( op, x ) ( *ops_cnt_ptr += ( op##_C * ( x ) ), inst_cnt[op] += ( x ) ) - -/******************************************************************/ -/* NOTES: */ -/* The 'wmc_flag_' flag is global to avoid declaration in every */ -/* function and 'static' to avoid clashing with other modules */ -/* that include this header file. */ -/* */ -/* The declarations of 'wmc_flag_' and 'wops_' in this header */ -/* file prevent the addition of a 'C' file to the Project. */ -/******************************************************************/ - -/* General Purpose Global int */ -static int wmc_flag_ = 0; - /* Operation Counter Wrappers */ +#define OP_COUNT_( op, x ) ( ops_cnt += ( op##_C * ( x ) ), inst_cnt[op] += ( x ) ) #define OP_COUNT_WRAPPER1_( op, val ) ( op, val ) #define OP_COUNT_WRAPPER2_( expr ) \ if ( expr, 0 ) \ @@ -921,7 +585,6 @@ st: /* This Shouldn't Happen */ /* These are Used to Avoid: "warning: 'name' defined but not used" with Cygwin gcc Compiler */ wmc_flag_ = wmc_flag_; - ops_cnt_ptr = ops_cnt_ptr; fct( "" ); error: default: @@ -1298,16 +961,14 @@ typedef struct #ifdef WMOPS extern BASIC_OP *multiCounter; -extern int currCounter; +extern unsigned int currCounter; extern int funcId_where_last_call_to_else_occurred; extern long funcid_total_wmops_at_last_call_to_else; extern int call_occurred; -long TotalWeightedOperation( void ); -long DeltaWeightedOperation( void ); - -void Set_BASOP_WMOPS_counter( int counterId ); -void Reset_BASOP_WMOPS_counter( void ); +long TotalWeightedOperation( unsigned int counterId ); +long DeltaWeightedOperation( unsigned int counterId ); +void Reset_BASOP_WMOPS_counter( unsigned int counterId ); /***************************************************************************** * -- GitLab From 6e3ca961bec2b8d7e191d5ad3fe9e09ccc99743b Mon Sep 17 00:00:00 2001 From: malenov Date: Fri, 29 Nov 2024 16:52:48 +0100 Subject: [PATCH 09/21] comments --- lib_debug/wmc_auto.h | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index bd4135922..ed0d7579c 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -469,7 +469,6 @@ extern int cntr_push_pop; #define return_ \ OP_COUNT_WRAPPER2_( ( wmc_flag_ = stack_tree_level_, STACK_DEPTH_FCT_RETURN ) ) \ return - #define switch_ \ OP_COUNT_WRAPPER2_( ( BRANCH_( 1 ), wmc_flag_ = 1 ) ) \ switch @@ -1063,7 +1062,7 @@ static __inline void incrWhile( void ) * - or when the 'if' conditions several DSP basic operations, * - or when the 'if' conditions a function call. * - * Complexity weight : 4 + * Complexity weight : 3 * *****************************************************************************/ @@ -1083,7 +1082,7 @@ void incrIf( const char *func_name ); * * The macro ELSE should be used instead of the 'else' C statement. * - * Complexity weight : 4 + * Complexity weight : 3 * *****************************************************************************/ @@ -1103,7 +1102,7 @@ void incrElse( const char *func_name ); * * The macro SWITCH should be used instead of the 'switch' C statement. * - * Complexity weight : 8 + * Complexity weight : 6 * *****************************************************************************/ #ifndef WMOPS @@ -1127,7 +1126,7 @@ static __inline void incrSwitch( void ) * * The macro CONTINUE should be used instead of the 'continue' C statement. * - * Complexity weight : 4 + * Complexity weight : 2 * *****************************************************************************/ #ifndef WMOPS @@ -1155,7 +1154,7 @@ static __inline void incrContinue( void ) * * The macro BREAK should be used instead of the 'break' C statement. * - * Complexity weight : 4 + * Complexity weight : 2 * *****************************************************************************/ #ifndef WMOPS @@ -1183,7 +1182,7 @@ static __inline void incrBreak( void ) * * The macro GOTO should be used instead of the 'goto' C statement. * - * Complexity weight : 4 + * Complexity weight : 2 * *****************************************************************************/ #ifndef WMOPS @@ -1203,9 +1202,6 @@ static __inline void incrGoto( void ) #endif /* ifndef WMOPS */ -/* - * New control code basops - */ #ifdef CONTROL_CODE_OPS extern int LT_16( short var1, short var2 ); -- GitLab From 0daacbefaee3dbf7cf9eb72a806852fa640cdab8 Mon Sep 17 00:00:00 2001 From: malenov Date: Tue, 3 Dec 2024 14:03:58 +0100 Subject: [PATCH 10/21] fix #ifdef WMOPS ... #endif locations --- lib_debug/wmc_auto.c | 8 ++++++-- lib_debug/wmc_auto.h | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index b209993bc..37088a642 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -1,5 +1,5 @@ /* - * (C) 2022 copyright VoiceAge Corporation. All Rights Reserved. + * (C) 2024 copyright VoiceAge Corporation. All Rights Reserved. * * This software is protected by copyright law and by international treaties. The source code, and all of its derivations, * is provided by VoiceAge Corporation under the "ITU-T Software Tools' General Public License". Please, read the license file @@ -2442,6 +2442,8 @@ int NE_64( long long int L64_var1, long long int L64_var2 ) #endif /* #ifdef CONTROL_CODE_OPS */ +#ifdef WMOPS + void incrIf( const char *func_name ) { /* Technical note: If the "IF" operator comes just after an "ELSE", its counter must not be incremented */ @@ -2523,4 +2525,6 @@ void Reset_BASOP_WMOPS_counter( unsigned int counterId ) wmops[counterId].LastWOper = 0; return; -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index ed0d7579c..aea3702a0 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -1,5 +1,5 @@ /* - * (C) 2022 copyright VoiceAge Corporation. All Rights Reserved. + * (C) 2024 copyright VoiceAge Corporation. All Rights Reserved. * * This software is protected by copyright law and by international treaties. The source code, and all of its derivations, * is provided by VoiceAge Corporation under the "ITU-T Software Tools' General Public License". Please, read the license file @@ -969,6 +969,8 @@ long TotalWeightedOperation( unsigned int counterId ); long DeltaWeightedOperation( unsigned int counterId ); void Reset_BASOP_WMOPS_counter( unsigned int counterId ); +#endif + /***************************************************************************** * * Function Name : FOR @@ -1225,9 +1227,7 @@ extern int GE_64( long long int L64_var1, long long int L64_var2 ); extern int EQ_64( long long int L64_var1, long long int L64_var2 ); extern int NE_64( long long int L64_var1, long long int L64_var2 ); - #endif /* #ifdef CONTROL_CODE_OPS */ -#endif #endif /* WMOPS_H */ -- GitLab From 75543481b13af6a9e353c9b5166ad127c03c96b7 Mon Sep 17 00:00:00 2001 From: malenov Date: Tue, 3 Dec 2024 14:11:37 +0100 Subject: [PATCH 11/21] revert accidental push --- lib_com/basop32.c | 1 - lib_com/enh40.c | 1 - 2 files changed, 2 deletions(-) diff --git a/lib_com/basop32.c b/lib_com/basop32.c index c4822bfbe..297798428 100644 --- a/lib_com/basop32.c +++ b/lib_com/basop32.c @@ -3797,4 +3797,3 @@ Word32 L_msu0_sat( Word32 L_var3, Word16 var1, Word16 var2 ) } #undef WMC_TOOL_SKIP -/*AddedByWMC_Tool*/ int PROM_Size_Func( basop32 ) { return 273; } diff --git a/lib_com/enh40.c b/lib_com/enh40.c index acd3db0d2..89960030f 100644 --- a/lib_com/enh40.c +++ b/lib_com/enh40.c @@ -1303,4 +1303,3 @@ Word40 L40_shl_r( Word40 L40_var1, Word16 var2 ) #undef WMC_TOOL_SKIP -/*AddedByWMC_Tool*/ int PROM_Size_Func( enh40 ) { return 110; } -- GitLab From d0cf67b72179b647aa38690005b1d049e966db6b Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Tue, 3 Dec 2024 14:19:11 +0100 Subject: [PATCH 12/21] clang format --- apps/encoder.c | 2 +- lib_com/basop32.h | 34 +++++++++++++++++----------------- lib_enc/core_enc_init_fx.c | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index b79827ce2..56ec0b111 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -786,7 +786,7 @@ cleanup: #define IVAS_DEFAULT_AGC ( 0 ) static void initArgStruct( EncArguments *arg ) -{ +{ /* Set default values here */ arg->inputWavFilename = NULL; arg->outputBitstreamFilename = NULL; diff --git a/lib_com/basop32.h b/lib_com/basop32.h index 32c108d9e..d9cf0a9e5 100644 --- a/lib_com/basop32.h +++ b/lib_com/basop32.h @@ -138,8 +138,8 @@ Word32 L_macNs( Word32 L_var3, Word16 var1, Word16 var2 ); /* Word32 L_msuNs( Word32 L_var3, Word16 var1, Word16 var2 ); /* Msu without sat, 1 */ Word32 L_add_co( Word32 L_var1, Word32 L_var2, Flag *Carry, Flag *Overflow ); Word32 L_sub_co( Word32 L_var1, Word32 L_var2, Flag *Carry, Flag *Overflow ); -Word32 L_add_c( Word32 L_var1, Word32 L_var2 ); /* Long add with c, 2 */ -Word32 L_sub_c( Word32 L_var1, Word32 L_var2 ); /* Long sub with c, 2 */ +Word32 L_add_c( Word32 L_var1, Word32 L_var2 ); /* Long add with c, 2 */ +Word32 L_sub_c( Word32 L_var1, Word32 L_var2 ); /* Long sub with c, 2 */ Word32 DEPR_L_msuNs( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry ); /* Msu without @@ -155,22 +155,22 @@ Word32 L_shr( Word32 L_var1, Word16 var2 ); /* Word16 shr_r( Word16 var1, Word16 var2 ); /* Shift right with round, 2 */ -Word16 mac_r( Word32 L_var3, Word16 var1, Word16 var2 ); /* Mac with - rounding, 1 */ -Word16 msu_r( Word32 L_var3, Word16 var1, Word16 var2 ); /* Msu with - rounding, 1 */ -Word32 L_deposit_h( Word16 var1 ); /* 16 bit var1 -> MSB, 1 */ -Word32 L_deposit_l( Word16 var1 ); /* 16 bit var1 -> LSB, 1 */ - -Word32 L_shr_r( Word32 L_var1, Word16 var2 ); /* Long shift right with - round, 3 */ -Word32 L_abs( Word32 L_var1 ); /* Long abs, 1 */ -Word32 DEPR_L_sat_co( Word32 L_var1, Flag Overflow, Flag Carry ); /* Long saturation, 4 */ -Word16 norm_s( Word16 var1 ); /* Short norm, 1 */ -Word16 div_s( Word16 var1, Word16 var2 ); /* Short division, 18 */ +Word16 mac_r( Word32 L_var3, Word16 var1, Word16 var2 ); /* Mac with + rounding, 1 */ +Word16 msu_r( Word32 L_var3, Word16 var1, Word16 var2 ); /* Msu with + rounding, 1 */ +Word32 L_deposit_h( Word16 var1 ); /* 16 bit var1 -> MSB, 1 */ +Word32 L_deposit_l( Word16 var1 ); /* 16 bit var1 -> LSB, 1 */ + +Word32 L_shr_r( Word32 L_var1, Word16 var2 ); /* Long shift right with + round, 3 */ +Word32 L_abs( Word32 L_var1 ); /* Long abs, 1 */ +Word32 DEPR_L_sat_co( Word32 L_var1, Flag Overflow, Flag Carry ); /* Long saturation, 4 */ +Word16 norm_s( Word16 var1 ); /* Short norm, 1 */ +Word16 div_s( Word16 var1, Word16 var2 ); /* Short division, 18 */ Word32 div_w( Word32 L_num, Word32 L_den ); -Word16 norm_l( Word32 L_var1 ); /* Long norm, 1 */ -Word32 L_sat( Word32 L_var1 ); /* Long saturation, 4 */ +Word16 norm_l( Word32 L_var1 ); /* Long norm, 1 */ +Word32 L_sat( Word32 L_var1 ); /* Long saturation, 4 */ /* diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index 8f6eb2d62..b34c65d51 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -6,7 +6,7 @@ //#include "prot_fx.h" //#include "basop_mpy.h" #include "options.h" -#include "cnst.h" +#include "cnst.h" #include "stl.h" #include "basop_util.h" #include "rom_com_fx.h" -- GitLab From 3d511700c5e59950bb944a0dd06671d4b59c0ec5 Mon Sep 17 00:00:00 2001 From: malenov Date: Tue, 3 Dec 2024 16:50:14 +0100 Subject: [PATCH 13/21] revert accidental deletion of #ifdef BASOP_NO_GLOB --- lib_com/basop32.c | 283 ++++++++++++++++++++++++++++- lib_com/basop32.h | 110 ++++++++++-- lib_com/cnst.h | 8 +- lib_com/enh1632.c | 19 +- lib_com/enh1632.h | 3 +- lib_com/enh32.c | 13 +- lib_com/enh40.c | 90 ++++++++++ lib_com/enh40.h | 4 + lib_com/enh64.c | 85 ++++++++- lib_com/enh64.h | 2 + lib_com/enhUL32.c | 3 +- lib_com/enhUL32.h | 1 - lib_com/rom_com.h | 447 ++++++++++++++++++++++++++-------------------- 13 files changed, 848 insertions(+), 220 deletions(-) diff --git a/lib_com/basop32.c b/lib_com/basop32.c index 297798428..2a813e15c 100644 --- a/lib_com/basop32.c +++ b/lib_com/basop32.c @@ -159,8 +159,10 @@ HISTORY: #include #include -#include #include "stl.h" +#ifdef BASOP_NOGLOB +#include +#endif /* BASOP_NOGLOB */ #define WMC_TOOL_SKIP @@ -168,12 +170,19 @@ HISTORY: #pragma warning( disable : 4310 ) #endif +#ifdef WMOPS +extern BASIC_OP multiCounter[MAXCOUNTERS]; +extern int currCounter; +#endif + /*___________________________________________________________________________ | | | Local Functions | |___________________________________________________________________________| */ +#ifdef BASOP_NOGLOB static Word16 saturate_o( Word32 L_var1, Flag *Overflow ); +#endif /* BASOP_NOGLOB */ static Word16 saturate( Word32 L_var1 ); @@ -182,6 +191,7 @@ static Word16 saturate( Word32 L_var1 ); | Constants and Globals | |___________________________________________________________________________| */ +#ifdef BASOP_NOGLOB #ifdef BASOP_PRINT_ON_WARNING #include @@ -408,6 +418,10 @@ Flag get_carry( const Flag *carry ) #undef B_HELPER_SET_GLOBAL #undef B_HELPER_GET_GLOBAL +#else /* BASOP_NOGLOB */ +Flag Overflow = 0; +Flag Carry = 0; +#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -444,18 +458,30 @@ Flag get_carry( const Flag *carry ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ +#ifndef BASOP_NOGLOB +static Word16 saturate( Word32 L_var1 ) +#else /* BASOP_NOGLOB */ static Word16 saturate_o( Word32 L_var1, Flag *Overflow ) +#endif /* BASOP_NOGLOB */ { Word16 var_out; if ( L_var1 > 0X00007fffL ) { +#ifndef BASOP_NOGLOB + Overflow = 1; +#else /* BASOP_NOGLOB */ *Overflow = 1; +#endif /* BASOP_NOGLOB */ var_out = MAX_16; } else if ( L_var1 < (Word32) 0xffff8000L ) { +#ifndef BASOP_NOGLOB + Overflow = 1; +#else /* BASOP_NOGLOB */ *Overflow = 1; +#endif /* BASOP_NOGLOB */ var_out = MIN_16; } else @@ -471,6 +497,7 @@ static Word16 saturate_o( Word32 L_var1, Flag *Overflow ) return ( var_out ); } +#ifdef BASOP_NOGLOB static Word16 saturate( Word32 L_var1 ) { Word16 var_out; @@ -497,6 +524,7 @@ static Word16 saturate( Word32 L_var1 ) return ( var_out ); } +#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -531,6 +559,7 @@ static Word16 saturate( Word32 L_var1 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ +#ifdef BASOP_NOGLOB Word16 add_o( Word16 var1, Word16 var2, Flag *Overflow ) { Word16 var_out; @@ -545,6 +574,7 @@ Word16 add_o( Word16 var1, Word16 var2, Flag *Overflow ) return ( var_out ); } +#endif /* BASOP_NOGLOB */ Word16 add( Word16 var1, Word16 var2 ) { Word16 var_out; @@ -558,11 +588,13 @@ Word16 add( Word16 var1, Word16 var2 ) #endif return ( var_out ); } +#ifdef BASOP_NOGLOB Word16 add_sat( Word16 var1, Word16 var2 ) { Flag Overflow; return add_o( var1, var2, &Overflow ); } +#endif /*___________________________________________________________________________ | | | Function Name : sub | @@ -596,6 +628,7 @@ Word16 add_sat( Word16 var1, Word16 var2 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ +#ifdef BASOP_NOGLOB Word16 sub_o( Word16 var1, Word16 var2, Flag *Overflow ) { Word16 var_out; @@ -610,6 +643,7 @@ Word16 sub_o( Word16 var1, Word16 var2, Flag *Overflow ) return ( var_out ); } +#endif /* BASOP_NOGLOB */ Word16 sub( Word16 var1, Word16 var2 ) { Word16 var_out; @@ -623,11 +657,13 @@ Word16 sub( Word16 var1, Word16 var2 ) #endif return ( var_out ); } +#ifdef BASOP_NOGLOB Word16 sub_sat( Word16 var1, Word16 var2 ) { Flag Overflow; return sub_o( var1, var2, &Overflow ); } +#endif /*___________________________________________________________________________ | | | Function Name : abs_s | @@ -719,7 +755,11 @@ Word16 abs_s( Word16 var1 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ +#ifndef BASOP_NOGLOB +Word16 shl( Word16 var1, Word16 var2 ) +#else /* BASOP_NOGLOB */ Word16 shl_o( Word16 var1, Word16 var2, Flag *Overflow ) +#endif /* BASOP_NOGLOB */ { Word16 var_out; Word32 result; @@ -741,7 +781,11 @@ Word16 shl_o( Word16 var1, Word16 var2, Flag *Overflow ) if ( ( var2 > 15 && var1 != 0 ) || ( result != (Word32) ( (Word16) result ) ) ) { +#ifndef BASOP_NOGLOB + Overflow = 1; +#else /* BASOP_NOGLOB */ *Overflow = 1; +#endif /* BASOP_NOGLOB */ var_out = ( var1 > 0 ) ? MAX_16 : MIN_16; } else @@ -764,6 +808,7 @@ Word16 shl_o( Word16 var1, Word16 var2, Flag *Overflow ) return ( var_out ); } +#ifdef BASOP_NOGLOB Word16 shl( Word16 var1, Word16 var2 ) { Word16 var_out; @@ -813,6 +858,7 @@ Word16 shl_sat( Word16 var1, Word16 var2 ) Flag Overflow; return shl_o( var1, var2, &Overflow ); } +#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -848,7 +894,11 @@ Word16 shl_sat( Word16 var1, Word16 var2 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ +#ifdef BASOP_NOGLOB Word16 shr_o( Word16 var1, Word16 var2, Flag *Overflow ) +#else /* BASOP_NOGLOB */ +Word16 shr( Word16 var1, Word16 var2 ) +#endif /* BASOP_NOGLOB */ { Word16 var_out; @@ -857,7 +907,11 @@ Word16 shr_o( Word16 var1, Word16 var2, Flag *Overflow ) if ( var2 < -16 ) var2 = -16; var2 = -var2; +#ifdef BASOP_NOGLOB var_out = shl_o( var1, var2, Overflow ); +#else /* BASOP_NOGLOB */ + var_out = shl( var1, var2 ); +#endif /* BASOP_NOGLOB */ #ifdef WMOPS multiCounter[currCounter].shl--; @@ -891,6 +945,7 @@ Word16 shr_o( Word16 var1, Word16 var2, Flag *Overflow ) return ( var_out ); } +#ifdef BASOP_NOGLOB Word16 shr( Word16 var1, Word16 var2 ) { return shr_o( var1, var2, NULL ); @@ -900,6 +955,7 @@ Word16 shr_sat( Word16 var1, Word16 var2 ) Flag Overflow; return shr_o( var1, var2, &Overflow ); } +#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ @@ -936,7 +992,11 @@ Word16 shr_sat( Word16 var1, Word16 var2 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ +#ifdef BASOP_NOGLOB Word16 mult_o( Word16 var1, Word16 var2, Flag *Overflow ) +#else /* BASOP_NOGLOB */ +Word16 mult( Word16 var1, Word16 var2 ) +#endif /* BASOP_NOGLOB */ { Word16 var_out; Word32 L_product; @@ -948,7 +1008,11 @@ Word16 mult_o( Word16 var1, Word16 var2, Flag *Overflow ) if ( L_product & (Word32) 0x00010000L ) L_product = L_product | (Word32) 0xffff0000L; +#ifdef BASOP_NOGLOB var_out = saturate_o( L_product, Overflow ); +#else /* BASOP_NOGLOB */ + var_out = saturate( L_product ); +#endif /* BASOP_NOGLOB */ #ifdef WMOPS multiCounter[currCounter].mult++; @@ -957,6 +1021,7 @@ Word16 mult_o( Word16 var1, Word16 var2, Flag *Overflow ) BASOP_CHECK(); return ( var_out ); } +#ifdef BASOP_NOGLOB Word16 mult( Word16 var1, Word16 var2 ) { Word16 var_out; @@ -983,6 +1048,7 @@ Word16 mult_sat( Word16 var1, Word16 var2 ) return mult_o( var1, var2, &Overflow ); } +#endif /*___________________________________________________________________________ | | @@ -1018,7 +1084,11 @@ Word16 mult_sat( Word16 var1, Word16 var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ +#ifndef BASOP_NOGLOB +Word32 L_mult( Word16 var1, Word16 var2 ) +#else /* BASOP_NOGLOB */ Word32 L_mult_o( Word16 var1, Word16 var2, Flag *Overflow ) +#endif /* BASOP_NOGLOB */ { Word32 L_var_out; @@ -1030,7 +1100,11 @@ Word32 L_mult_o( Word16 var1, Word16 var2, Flag *Overflow ) } else { +#ifndef BASOP_NOGLOB + Overflow = 1; +#else /* BASOP_NOGLOB */ *Overflow = 1; +#endif /* BASOP_NOGLOB */ L_var_out = MAX_32; } @@ -1043,6 +1117,7 @@ Word32 L_mult_o( Word16 var1, Word16 var2, Flag *Overflow ) return ( L_var_out ); } +#ifdef BASOP_NOGLOB Word32 L_mult( Word16 var1, Word16 var2 ) { Word32 L_var_out; @@ -1073,6 +1148,7 @@ Word32 L_mult_sat( Word16 var1, Word16 var2 ) Flag Overflow; return L_mult_o( var1, var2, &Overflow ); } +#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -1238,6 +1314,7 @@ Word16 extract_l( Word32 L_var1 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ +#ifdef BASOP_NOGLOB Word16 round_fx_o( Word32 L_var1, Flag *Overflow ) { Word16 var_out; @@ -1259,6 +1336,7 @@ Word16 round_fx_o( Word32 L_var1, Flag *Overflow ) return ( var_out ); } +#endif /* BASOP_NOGLOB */ Word16 round_fx( Word32 L_var1 ) { Word16 var_out; @@ -1278,11 +1356,13 @@ Word16 round_fx( Word32 L_var1 ) return ( var_out ); } +#ifdef BASOP_NOGLOB Word16 round_fx_sat( Word32 L_var1 ) { Flag Overflow; return round_fx_o( L_var1, &Overflow ); } +#endif /*___________________________________________________________________________ | | | Function Name : L_mac | @@ -1319,6 +1399,7 @@ Word16 round_fx_sat( Word32 L_var1 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ +#ifdef BASOP_NOGLOB Word32 L_mac_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) { Word32 L_var_out; @@ -1336,6 +1417,7 @@ Word32 L_mac_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) return ( L_var_out ); } +#endif /* BASOP_NOGLOB */ Word32 L_mac( Word32 L_var3, Word16 var1, Word16 var2 ) { Word32 L_var_out; @@ -1353,11 +1435,13 @@ Word32 L_mac( Word32 L_var3, Word16 var1, Word16 var2 ) return ( L_var_out ); } +#ifdef BASOP_NOGLOB Word32 L_mac_sat( Word32 L_var3, Word16 var1, Word16 var2 ) { Flag Overflow; return L_mac_o( L_var3, var1, var2, &Overflow ); } +#endif /*___________________________________________________________________________ | | | Function Name : L_msu | @@ -1394,6 +1478,7 @@ Word32 L_mac_sat( Word32 L_var3, Word16 var1, Word16 var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ +#ifdef BASOP_NOGLOB Word32 L_msu_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) { Word32 L_var_out; @@ -1411,6 +1496,7 @@ Word32 L_msu_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) return ( L_var_out ); } +#endif /* BASOP_NOGLOB */ Word32 L_msu( Word32 L_var3, Word16 var1, Word16 var2 ) { Word32 L_var_out; @@ -1428,11 +1514,13 @@ Word32 L_msu( Word32 L_var3, Word16 var1, Word16 var2 ) return ( L_var_out ); } +#ifdef BASOP_NOGLOB Word32 L_msu_sat( Word32 L_var3, Word16 var1, Word16 var2 ) { Flag Overflow; return L_msu_o( L_var3, var1, var2, &Overflow ); } +#endif /*___________________________________________________________________________ | | | Function Name : L_macNs | @@ -1479,6 +1567,7 @@ Word32 L_msu_sat( Word32 L_var3, Word16 var1, Word16 var2 ) | operators which take into account its value. | |___________________________________________________________________________| */ +#ifdef BASOP_NOGLOB Word32 DEPR_L_macNs( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry ) { Word32 L_var_out; @@ -1495,14 +1584,25 @@ Word32 DEPR_L_macNs( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry ) /* BASOP_CHECK(); Do not check for overflow here, function produces the carry bit instead */ return ( L_var_out ); } +#endif +#ifdef BASOP_NOGLOB Word32 L_macNs_co( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry, Flag *Overflow ) +#else /* BASOP_NOGLOB */ +Word32 L_macNs( Word32 L_var3, Word16 var1, Word16 var2 ) +#endif /* BASOP_NOGLOB */ { Word32 L_var_out; +#ifdef BASOP_NOGLOB L_var_out = L_mult_o( var1, var2, Overflow ); L_var_out = L_add_co( L_var3, L_var_out, Carry, Overflow ); +#else /* BASOP_NOGLOB */ + L_var_out = L_mult( var1, var2 ); + L_var_out = L_add_c( L_var3, L_var_out ); +#endif /* BASOP_NOGLOB */ return ( L_var_out ); } +#ifdef BASOP_NOGLOB Word32 L_macNs( Word32 L_var3, Word16 var1, Word16 var2 ) { return L_macNs_co( L_var3, var1, var2, NULL, NULL ); @@ -1512,6 +1612,7 @@ Word32 L_macNs_sat( Word32 L_var3, Word16 var1, Word16 var2 ) Flag Carry, Overflow; return L_macNs_co( L_var3, var1, var2, &Carry, &Overflow ); } +#endif /*___________________________________________________________________________ | | | Function Name : L_msuNs | @@ -1558,12 +1659,20 @@ Word32 L_macNs_sat( Word32 L_var3, Word16 var1, Word16 var2 ) | operators which take into account its value. | |___________________________________________________________________________| */ +#ifndef BASOP_NOGLOB +Word32 L_msuNs( Word32 L_var3, Word16 var1, Word16 var2 ) +#else /* BASOP_NOGLOB */ Word32 DEPR_L_msuNs( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry ) +#endif /* BASOP_NOGLOB */ { Word32 L_var_out; L_var_out = L_mult( var1, var2 ); +#ifndef BASOP_NOGLOB + L_var_out = L_sub_c( L_var3, L_var_out ); +#else /* BASOP_NOGLOB */ L_var_out = DEPR_L_sub_c( L_var3, L_var_out, Carry ); +#endif /* BASOP_NOGLOB */ #ifdef WMOPS multiCounter[currCounter].L_mult--; @@ -1576,6 +1685,7 @@ Word32 DEPR_L_msuNs( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry ) return ( L_var_out ); } +#ifdef BASOP_NOGLOB Word32 L_msuNs_co( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry, Flag *Overflow ) { Word32 L_var_out; @@ -1596,6 +1706,7 @@ Word32 L_msuNs_sat( Word32 L_var3, Word16 var1, Word16 var2 ) Flag Carry, Overflow; return L_msuNs_co( L_var3, var1, var2, &Carry, &Overflow ); } +#endif /*___________________________________________________________________________ | | | Function Name : L_add | @@ -1627,7 +1738,11 @@ Word32 L_msuNs_sat( Word32 L_var3, Word16 var1, Word16 var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ +#ifndef BASOP_NOGLOB +Word32 L_add( Word32 L_var1, Word32 L_var2 ) +#else /* BASOP_NOGLOB */ Word32 L_add_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) +#endif /* BASOP_NOGLOB */ { Word32 L_var_out; @@ -1638,7 +1753,11 @@ Word32 L_add_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) if ( ( L_var_out ^ L_var1 ) & MIN_32 ) { L_var_out = ( L_var1 < 0 ) ? MIN_32 : MAX_32; +#ifndef BASOP_NOGLOB + Overflow = 1; +#else /* BASOP_NOGLOB */ *Overflow = 1; +#endif /* BASOP_NOGLOB */ } } @@ -1652,6 +1771,7 @@ Word32 L_add_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) return ( L_var_out ); } +#ifdef BASOP_NOGLOB Word32 L_add( Word32 L_var1, Word32 L_var2 ) { Word32 L_var_out; @@ -1677,6 +1797,7 @@ Word32 L_add_sat( Word32 L_var1, Word32 L_var2 ) Flag Overflow; return L_add_o( L_var1, L_var2, &Overflow ); } +#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -1709,7 +1830,11 @@ Word32 L_add_sat( Word32 L_var1, Word32 L_var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ +#ifndef BASOP_NOGLOB +Word32 L_sub( Word32 L_var1, Word32 L_var2 ) +#else /* BASOP_NOGLOB */ Word32 L_sub_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) +#endif /* BASOP_NOGLOB */ { Word32 L_var_out; @@ -1720,7 +1845,11 @@ Word32 L_sub_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) if ( ( L_var_out ^ L_var1 ) & MIN_32 ) { L_var_out = ( L_var1 < 0L ) ? MIN_32 : MAX_32; +#ifndef BASOP_NOGLOB + Overflow = 1; +#else /* BASOP_NOGLOB */ *Overflow = 1; +#endif /* BASOP_NOGLOB */ } } @@ -1733,6 +1862,7 @@ Word32 L_sub_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) return ( L_var_out ); } +#ifdef BASOP_NOGLOB Word32 L_sub( Word32 L_var1, Word32 L_var2 ) { Word32 L_var_out; @@ -1760,6 +1890,7 @@ Word32 L_sub_sat( Word32 L_var1, Word32 L_var2 ) Flag Overflow; return L_sub_o( L_var1, L_var2, &Overflow ); } +#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -1806,18 +1937,29 @@ Word32 L_sub_sat( Word32 L_var1, Word32 L_var2 ) | operators which take into account its value. | |___________________________________________________________________________| */ +#ifndef BASOP_NOGLOB +Word32 L_add_c( Word32 L_var1, Word32 L_var2 ) +#else /* BASOP_NOGLOB */ Word32 DEPR_L_add_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) +#endif /* BASOP_NOGLOB */ { Word32 L_var_out; Word32 L_test; Flag carry_int = 0; +#ifndef BASOP_NOGLOB + L_var_out = L_var1 + L_var2 + Carry; +#else /* BASOP_NOGLOB */ L_var_out = L_var1 + L_var2 + *Carry; +#endif /* BASOP_NOGLOB */ L_test = L_var1 + L_var2; if ( ( L_var1 > 0 ) && ( L_var2 > 0 ) && ( L_test < 0 ) ) { +#ifndef BASOP_NOGLOB + Overflow = 1; +#endif /* ! BASOP_NOGLOB */ carry_int = 0; } else @@ -1826,10 +1968,16 @@ Word32 DEPR_L_add_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) { if ( L_test >= 0 ) { +#ifndef BASOP_NOGLOB + Overflow = 1; +#endif /* ! BASOP_NOGLOB */ carry_int = 1; } else { +#ifndef BASOP_NOGLOB + Overflow = 0; +#endif /* ! BASOP_NOGLOB */ carry_int = 1; } } @@ -1837,36 +1985,63 @@ Word32 DEPR_L_add_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) { if ( ( ( L_var1 ^ L_var2 ) < 0 ) && ( L_test >= 0 ) ) { +#ifndef BASOP_NOGLOB + Overflow = 0; +#endif /* ! BASOP_NOGLOB */ carry_int = 1; } else { +#ifndef BASOP_NOGLOB + Overflow = 0; +#endif /* ! BASOP_NOGLOB */ carry_int = 0; } } } +#ifndef BASOP_NOGLOB + if ( Carry ) +#else /* BASOP_NOGLOB */ if ( *Carry ) +#endif /* BASOP_NOGLOB */ { if ( L_test == MAX_32 ) { +#ifndef BASOP_NOGLOB + Overflow = 1; + Carry = carry_int; +#else /* BASOP_NOGLOB */ *Carry = carry_int; +#endif /* BASOP_NOGLOB */ } else { if ( L_test == (Word32) 0xFFFFFFFFL ) { +#ifndef BASOP_NOGLOB + Carry = 1; +#else /* BASOP_NOGLOB */ *Carry = 1; +#endif /* BASOP_NOGLOB */ } else { +#ifndef BASOP_NOGLOB + Carry = carry_int; +#else /* BASOP_NOGLOB */ *Carry = carry_int; +#endif /* BASOP_NOGLOB */ } } } else { +#ifndef BASOP_NOGLOB + Carry = carry_int; +#else /* BASOP_NOGLOB */ *Carry = carry_int; +#endif /* BASOP_NOGLOB */ } #ifdef WMOPS @@ -1878,6 +2053,7 @@ Word32 DEPR_L_add_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) return ( L_var_out ); } +#ifdef BASOP_NOGLOB Word32 L_add_co( Word32 L_var1, Word32 L_var2, Flag *Carry, Flag *Overflow ) { Word32 L_var_out; @@ -1953,6 +2129,7 @@ Word32 L_add_c( Word32 L_var1, Word32 L_var2 ) { return L_add_co( L_var1, L_var2, NULL, NULL ); } +#endif /*___________________________________________________________________________ | | | Function Name : L_sub_c | @@ -1998,18 +2175,34 @@ Word32 L_add_c( Word32 L_var1, Word32 L_var2 ) | operators which take into account its value. | |___________________________________________________________________________| */ +#ifndef BASOP_NOGLOB +Word32 L_sub_c( Word32 L_var1, Word32 L_var2 ) +#else /* BASOP_NOGLOB */ Word32 DEPR_L_sub_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) +#endif /* BASOP_NOGLOB */ { Word32 L_var_out; Word32 L_test; Flag carry_int = 0; +#ifndef BASOP_NOGLOB + if ( Carry ) +#else /* BASOP_NOGLOB */ if ( *Carry ) +#endif /* BASOP_NOGLOB */ { +#ifndef BASOP_NOGLOB + Carry = 0; +#else /* BASOP_NOGLOB */ *Carry = 0; +#endif /* BASOP_NOGLOB */ if ( L_var2 != MIN_32 ) { +#ifndef BASOP_NOGLOB + L_var_out = L_add_c( L_var1, -L_var2 ); +#else /* BASOP_NOGLOB */ L_var_out = DEPR_L_add_c( L_var1, -L_var2, Carry ); +#endif /* BASOP_NOGLOB */ #ifdef WMOPS multiCounter[currCounter].L_add_c--; #endif @@ -2019,7 +2212,12 @@ Word32 DEPR_L_sub_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) L_var_out = L_var1 - L_var2; if ( L_var1 > 0L ) { +#ifndef BASOP_NOGLOB + Overflow = 1; + Carry = 0; +#else /* BASOP_NOGLOB */ *Carry = 0; +#endif /* BASOP_NOGLOB */ } } } @@ -2030,23 +2228,41 @@ Word32 DEPR_L_sub_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) if ( ( L_test < 0 ) && ( L_var1 > 0 ) && ( L_var2 < 0 ) ) { +#ifndef BASOP_NOGLOB + Overflow = 1; +#endif /* ! BASOP_NOGLOB */ carry_int = 0; } else if ( ( L_test > 0 ) && ( L_var1 < 0 ) && ( L_var2 > 0 ) ) { +#ifndef BASOP_NOGLOB + Overflow = 1; +#endif /* ! BASOP_NOGLOB */ carry_int = 1; } else if ( ( L_test > 0 ) && ( ( L_var1 ^ L_var2 ) > 0 ) ) { +#ifndef BASOP_NOGLOB + Overflow = 0; +#endif /* ! BASOP_NOGLOB */ carry_int = 1; } if ( L_test == MIN_32 ) { +#ifndef BASOP_NOGLOB + Overflow = 1; + Carry = carry_int; +#else /* BASOP_NOGLOB */ *Carry = carry_int; +#endif /* BASOP_NOGLOB */ } else { +#ifndef BASOP_NOGLOB + Carry = carry_int; +#else /* BASOP_NOGLOB */ *Carry = carry_int; +#endif /* BASOP_NOGLOB */ } } @@ -2059,6 +2275,7 @@ Word32 DEPR_L_sub_c( Word32 L_var1, Word32 L_var2, Flag *Carry ) return ( L_var_out ); } +#ifdef BASOP_NOGLOB Word32 L_sub_co( Word32 L_var1, Word32 L_var2, Flag *Carry, Flag *Overflow ) { Word32 L_var_out; @@ -2114,6 +2331,7 @@ Word32 L_sub_c( Word32 L_var1, Word32 L_var2 ) { return L_sub_co( L_var1, L_var2, NULL, NULL ); } +#endif /*___________________________________________________________________________ | | | Function Name : L_negate | @@ -2191,6 +2409,7 @@ Word32 L_negate( Word32 L_var1 ) | range : 0x8000 <= var_out <= 0x7fff. | |___________________________________________________________________________| */ +#ifdef BASOP_NOGLOB Word16 mult_ro( Word16 var1, Word16 var2, Flag *Overflow ) { Word16 var_out; @@ -2214,6 +2433,7 @@ Word16 mult_ro( Word16 var1, Word16 var2, Flag *Overflow ) return ( var_out ); } +#endif /* BASOP_NOGLOB */ Word16 mult_r( Word16 var1, Word16 var2 ) { Word16 var_out; @@ -2236,11 +2456,13 @@ Word16 mult_r( Word16 var1, Word16 var2 ) return ( var_out ); } +#ifdef BASOP_NOGLOB Word16 mult_r_sat( Word16 var1, Word16 var2 ) { Flag Overflow; return mult_ro( var1, var2, &Overflow ); } +#endif /*___________________________________________________________________________ | | | Function Name : L_shl | @@ -2274,7 +2496,11 @@ Word16 mult_r_sat( Word16 var1, Word16 var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ +#ifndef BASOP_NOGLOB +Word32 L_shl( Word32 L_var1, Word16 var2 ) +#else /* BASOP_NOGLOB */ Word32 L_shl_o( Word32 L_var1, Word16 var2, Flag *Overflow ) +#endif /* BASOP_NOGLOB */ { Word32 L_var_out = 0L; @@ -2295,7 +2521,11 @@ Word32 L_shl_o( Word32 L_var1, Word16 var2, Flag *Overflow ) { if ( L_var1 > (Word32) 0X3fffffffL ) { +#ifndef BASOP_NOGLOB + Overflow = 1; +#else /* BASOP_NOGLOB */ *Overflow = 1; +#endif /* BASOP_NOGLOB */ L_var_out = MAX_32; break; } @@ -2303,7 +2533,11 @@ Word32 L_shl_o( Word32 L_var1, Word16 var2, Flag *Overflow ) { if ( L_var1 < (Word32) 0xc0000000L ) { +#ifndef BASOP_NOGLOB + Overflow = 1; +#else /* BASOP_NOGLOB */ *Overflow = 1; +#endif /* BASOP_NOGLOB */ L_var_out = MIN_32; break; } @@ -2323,6 +2557,7 @@ Word32 L_shl_o( Word32 L_var1, Word16 var2, Flag *Overflow ) return ( L_var_out ); } +#ifdef BASOP_NOGLOB Word32 L_shl( Word32 L_var1, Word16 var2 ) { @@ -2377,6 +2612,7 @@ Word32 L_shl_sat( Word32 L_var1, Word16 var2 ) return L_shl_o( L_var1, var2, &Overflow ); } +#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | | Function Name : L_shr | @@ -2410,6 +2646,7 @@ Word32 L_shl_sat( Word32 L_var1, Word16 var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ +#ifdef BASOP_NOGLOB Word32 L_shr_o( Word32 L_var1, Word16 var2, Flag *Overflow ) { Word32 L_var_out; @@ -2453,6 +2690,7 @@ Word32 L_shr_o( Word32 L_var1, Word16 var2, Flag *Overflow ) return ( L_var_out ); } +#endif /* BASOP_NOGLOB */ Word32 L_shr( Word32 L_var1, Word16 var2 ) { Word32 L_var_out; @@ -2494,11 +2732,13 @@ Word32 L_shr( Word32 L_var1, Word16 var2 ) return ( L_var_out ); } +#ifdef BASOP_NOGLOB Word32 L_shr_sat( Word32 L_var1, Word16 var2 ) { Flag Overflow; return L_shr_o( L_var1, var2, &Overflow ); } +#endif /*___________________________________________________________________________ | | | Function Name : shr_r | @@ -2572,6 +2812,7 @@ Word16 shr_r( Word16 var1, Word16 var2 ) return ( var_out ); } +#ifdef BASOP_NOGLOB Word16 shr_ro( Word16 var1, Word16 var2, Flag *Overflow ) { Word16 var_out; @@ -2599,6 +2840,7 @@ Word16 shr_r_sat( Word16 var1, Word16 var2 ) Flag Overflow; return shr_ro( var1, var2, &Overflow ); } +#endif /*___________________________________________________________________________ | | | Function Name : mac_r | @@ -2637,6 +2879,7 @@ Word16 shr_r_sat( Word16 var1, Word16 var2 ) | range : 0x0000 8000 <= L_var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ +#ifdef BASOP_NOGLOB Word16 mac_ro( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) { Word16 var_out; @@ -2658,6 +2901,7 @@ Word16 mac_ro( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) return ( var_out ); } +#endif /* BASOP_NOGLOB */ Word16 mac_r( Word32 L_var3, Word16 var1, Word16 var2 ) { Word16 var_out; @@ -2678,11 +2922,13 @@ Word16 mac_r( Word32 L_var3, Word16 var1, Word16 var2 ) return ( var_out ); } +#ifdef BASOP_NOGLOB Word16 mac_r_sat( Word32 L_var3, Word16 var1, Word16 var2 ) { Flag Overflow; return mac_ro( L_var3, var1, var2, &Overflow ); } +#endif /*___________________________________________________________________________ | | | Function Name : msu_r | @@ -2721,6 +2967,7 @@ Word16 mac_r_sat( Word32 L_var3, Word16 var1, Word16 var2 ) | range : 0x0000 8000 <= L_var_out <= 0x0000 7fff. | |___________________________________________________________________________| */ +#ifdef BASOP_NOGLOB Word16 msu_ro( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) { Word16 var_out; @@ -2740,6 +2987,7 @@ Word16 msu_ro( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) return ( var_out ); } +#endif /* BASOP_NOGLOB */ Word16 msu_r( Word32 L_var3, Word16 var1, Word16 var2 ) { Word16 var_out; @@ -2758,11 +3006,13 @@ Word16 msu_r( Word32 L_var3, Word16 var1, Word16 var2 ) return ( var_out ); } +#ifdef BASOP_NOGLOB Word16 msu_r_sat( Word32 L_var3, Word16 var1, Word16 var2 ) { Flag Overflow; return msu_ro( L_var3, var1, var2, &Overflow ); } +#endif /*___________________________________________________________________________ | | | Function Name : L_deposit_h | @@ -2927,6 +3177,7 @@ Word32 L_shr_r( Word32 L_var1, Word16 var2 ) return ( L_var_out ); } +#ifdef BASOP_NOGLOB Word32 L_shr_ro( Word32 L_var1, Word16 var2, Flag *Overflow ) { Word32 L_var_out; @@ -2954,6 +3205,7 @@ Word32 L_shr_r_sat( Word32 L_var1, Word16 var2 ) Flag Overflow = 0; return L_shr_ro( L_var1, var2, &Overflow ); } +#endif /*___________________________________________________________________________ | | | Function Name : L_abs | @@ -3043,7 +3295,11 @@ Word32 L_abs( Word32 L_var1 ) | range : 0x8000 0000 <= var_out <= 0x7fff ffff. | |___________________________________________________________________________| */ +#ifndef BASOP_NOGLOB +Word32 L_sat( Word32 L_var1 ) +#else /* BASOP_NOGLOB */ Word32 DEPR_L_sat_co( Word32 L_var1, Flag Overflow, Flag Carry ) +#endif /* BASOP_NOGLOB */ { Word32 L_var_out; @@ -3060,6 +3316,11 @@ Word32 DEPR_L_sat_co( Word32 L_var1, Flag Overflow, Flag Carry ) { L_var_out = MAX_32; } +#ifndef BASOP_NOGLOB + + Carry = 0; + Overflow = 0; +#endif /* ! BASOP_NOGLOB */ } #ifdef WMOPS @@ -3071,6 +3332,7 @@ Word32 DEPR_L_sat_co( Word32 L_var1, Flag Overflow, Flag Carry ) return ( L_var_out ); } +#ifdef BASOP_NOGLOB Word32 L_sat_co( Word32 L_var1, Flag Carry, Flag Overflow ) { Word32 L_var_out; @@ -3097,6 +3359,7 @@ Word32 L_sat( Word32 L_var1 ) assert( 0 ); /* Overflow and Carry are no longer global, must be passed as parameters */ return L_sat_co( L_var1, 0, 0 ); } +#endif /*___________________________________________________________________________ | | | Function Name : norm_s | @@ -3386,6 +3649,7 @@ Word16 norm_l( Word32 L_var1 ) | | |___________________________________________________________________________| */ +#ifdef BASOP_NOGLOB Word32 L_mls_o( Word32 Lv, Word16 v, Flag *Overflow ) { Word32 Temp; @@ -3407,6 +3671,7 @@ Word32 L_mls_o( Word32 Lv, Word16 v, Flag *Overflow ) return Temp; } +#endif /* BASOP_NOGLOB */ Word32 L_mls( Word32 Lv, Word16 v ) { Word32 Temp; @@ -3427,11 +3692,13 @@ Word32 L_mls( Word32 Lv, Word16 v ) return Temp; } +#ifdef BASOP_NOGLOB Word32 L_mls_sat( Word32 Lv, Word16 v ) { Flag Overflow; return L_mls_o( Lv, v, &Overflow ); } +#endif /*__________________________________________________________________________ | | @@ -3569,7 +3836,11 @@ Word16 div_l( Word32 L_num, Word16 den ) | are performed if ORIGINAL_G7231 is defined. | |___________________________________________________________________________| */ +#ifndef BASOP_NOGLOB +Word16 i_mult( Word16 a, Word16 b ) +#else /* BASOP_NOGLOB */ Word16 DEPR_i_mult( Word16 a, Word16 b ) +#endif /* BASOP_NOGLOB */ { #ifdef ORIGINAL_G7231 return a * b; @@ -3582,6 +3853,7 @@ Word16 DEPR_i_mult( Word16 a, Word16 b ) #endif } +#ifdef BASOP_NOGLOB Word16 i_mult_o( Word16 a, Word16 b, Flag *Overflow ) { #ifdef ORIGINAL_G7231 @@ -3600,6 +3872,7 @@ Word16 i_mult_sat( Word16 a, Word16 b ) Flag Overflow; return i_mult_o( a, b, &Overflow ); } +#endif /* ****************************************************************************** * The following three operators are not part of the original @@ -3679,6 +3952,7 @@ Word32 L_mult0( Word16 var1, Word16 var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |___________________________________________________________________________ */ +#ifdef BASOP_NOGLOB Word32 L_mac0_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) { Word32 L_var_out; @@ -3698,6 +3972,7 @@ Word32 L_mac0_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) return ( L_var_out ); } +#endif /* BASOP_NOGLOB */ Word32 L_mac0( Word32 L_var3, Word16 var1, Word16 var2 ) { Word32 L_var_out; @@ -3717,11 +3992,13 @@ Word32 L_mac0( Word32 L_var3, Word16 var1, Word16 var2 ) return ( L_var_out ); } +#ifdef BASOP_NOGLOB Word32 L_mac0_sat( Word32 L_var3, Word16 var1, Word16 var2 ) { Flag Overflow; return L_mac0_o( L_var3, var1, var2, &Overflow ); } +#endif /*___________________________________________________________________________ | | Function Name : L_msu0 @@ -3752,6 +4029,7 @@ Word32 L_mac0_sat( Word32 L_var3, Word16 var1, Word16 var2 ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |___________________________________________________________________________ */ +#ifdef BASOP_NOGLOB Word32 L_msu0_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) { Word32 L_var_out; @@ -3771,6 +4049,7 @@ Word32 L_msu0_o( Word32 L_var3, Word16 var1, Word16 var2, Flag *Overflow ) return ( L_var_out ); } +#endif /* BASOP_NOGLOB */ Word32 L_msu0( Word32 L_var3, Word16 var1, Word16 var2 ) { Word32 L_var_out; @@ -3790,10 +4069,12 @@ Word32 L_msu0( Word32 L_var3, Word16 var1, Word16 var2 ) return ( L_var_out ); } +#ifdef BASOP_NOGLOB Word32 L_msu0_sat( Word32 L_var3, Word16 var1, Word16 var2 ) { Flag Overflow; return L_msu0_o( L_var3, var1, var2, &Overflow ); } +#endif #undef WMC_TOOL_SKIP diff --git a/lib_com/basop32.h b/lib_com/basop32.h index d9cf0a9e5..785a4bf56 100644 --- a/lib_com/basop32.h +++ b/lib_com/basop32.h @@ -86,11 +86,17 @@ | Constants and Globals | |___________________________________________________________________________| */ +#ifndef BASOP_NOGLOB +extern Flag Overflow, Overflow2; +extern Flag Carry; + +#else /* BASOP_NOGLOB */ /* DISABLED TO AVOID GLOBAL VARIABLES */ /* extern Flag BASOP_Overflow, BASOP_Overflow2; extern Flag BASOP_Carry; */ +#endif /* BASOP_NOGLOB */ #define BASOP_SATURATE_WARNING_ON_EVS #define BASOP_SATURATE_WARNING_OFF_EVS #define BASOP_SATURATE_ERROR_ON_EVS @@ -108,17 +114,36 @@ extern Flag BASOP_Carry; #define MAX_16 (Word16) 0x7fff #define MIN_16 (Word16) 0x8000 +#ifdef BASOP_NOGLOB void set_overflow( Flag *overflow ); void unset_overflow( Flag *overflow ); void set_carry( Flag *carry ); void unset_carry( Flag *carry ); Flag get_carry( const Flag *carry ); +#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | | Prototypes for basic arithmetic operators | |___________________________________________________________________________| */ +#ifndef BASOP_NOGLOB +Word16 add( Word16 var1, Word16 var2 ); /* Short add, 1 */ +Word16 sub( Word16 var1, Word16 var2 ); /* Short sub, 1 */ +Word16 abs_s( Word16 var1 ); /* Short abs, 1 */ +Word16 shl( Word16 var1, Word16 var2 ); /* Short shift left, 1 */ +Word16 shr( Word16 var1, Word16 var2 ); /* Short shift right, 1 */ +Word16 mult( Word16 var1, Word16 var2 ); /* Short mult, 1 */ +Word32 L_mult( Word16 var1, Word16 var2 ); /* Long mult, 1 */ +Word16 negate( Word16 var1 ); /* Short negate, 1 */ +Word16 extract_h( Word32 L_var1 ); /* Extract high, 1 */ +Word16 extract_l( Word32 L_var1 ); /* Extract low, 1 */ +Word16 round_fx( Word32 L_var1 ); /* Round, 1 */ +Word32 L_mac( Word32 L_var3, Word16 var1, Word16 var2 ); /* Mac, 1 */ +Word32 L_msu( Word32 L_var3, Word16 var1, Word16 var2 ); /* Msu, 1 */ +Word32 L_macNs( Word32 L_var3, Word16 var1, Word16 var2 ); /* Mac without + sat, 1 */ +#else /* BASOP_NOGLOB */ Word16 add( Word16 var1, Word16 var2 ); /* Short add, 1 */ Word16 sub( Word16 var1, Word16 var2 ); /* Short sub, 1 */ Word16 abs_s( Word16 var1 ); /* Short abs, 1 */ @@ -138,12 +163,30 @@ Word32 L_macNs( Word32 L_var3, Word16 var1, Word16 var2 ); /* Word32 L_msuNs( Word32 L_var3, Word16 var1, Word16 var2 ); /* Msu without sat, 1 */ Word32 L_add_co( Word32 L_var1, Word32 L_var2, Flag *Carry, Flag *Overflow ); Word32 L_sub_co( Word32 L_var1, Word32 L_var2, Flag *Carry, Flag *Overflow ); -Word32 L_add_c( Word32 L_var1, Word32 L_var2 ); /* Long add with c, 2 */ -Word32 L_sub_c( Word32 L_var1, Word32 L_var2 ); /* Long sub with c, 2 */ +Word32 L_add_c( Word32 L_var1, Word32 L_var2 ); /* Long add with c, 2 */ +Word32 L_sub_c( Word32 L_var1, Word32 L_var2 ); /* Long sub with c, 2 */ +#endif /* BASOP_NOGLOB */ +#ifndef BASOP_NOGLOB +Word32 L_msuNs( Word32 L_var3, Word16 var1, Word16 var2 ); /* Msu without + sat, 1 */ +#else /* BASOP_NOGLOB */ Word32 DEPR_L_msuNs( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry ); /* Msu without sat, 1 */ +#endif /* BASOP_NOGLOB */ +#ifndef BASOP_NOGLOB +Word32 L_add( Word32 L_var1, Word32 L_var2 ); /* Long add, 1 */ +Word32 L_sub( Word32 L_var1, Word32 L_var2 ); /* Long sub, 1 */ +Word32 L_add_c( Word32 L_var1, Word32 L_var2 ); /* Long add with c, 2 */ +Word32 L_sub_c( Word32 L_var1, Word32 L_var2 ); /* Long sub with c, 2 */ +Word32 L_negate( Word32 L_var1 ); /* Long negate, 1 */ +Word16 mult_r( Word16 var1, Word16 var2 ); /* Mult with round, 1 */ +Word32 L_shl( Word32 L_var1, Word16 var2 ); /* Long shift left, 1 */ +Word32 L_shr( Word32 L_var1, Word16 var2 ); /* Long shift right, 1 */ +Word16 shr_r( Word16 var1, Word16 var2 ); /* Shift right with + round, 2 */ +#else /* BASOP_NOGLOB */ Word32 L_add( Word32 L_var1, Word32 L_var2 ); /* Long add, 1 */ Word32 L_sub( Word32 L_var1, Word32 L_var2 ); /* Long sub, 1 */ Word32 DEPR_L_add_c( Word32 L_var1, Word32 L_var2, Flag *Carry ); /* Long add with c, 2 */ @@ -154,32 +197,67 @@ Word32 L_shl( Word32 L_var1, Word16 var2 ); /* Word32 L_shr( Word32 L_var1, Word16 var2 ); /* Long shift right, 1 */ Word16 shr_r( Word16 var1, Word16 var2 ); /* Shift right with round, 2 */ +#endif /* BASOP_NOGLOB */ +#ifndef BASOP_NOGLOB Word16 mac_r( Word32 L_var3, Word16 var1, Word16 var2 ); /* Mac with - rounding, 1 */ + rounding, 1 */ +#else /* BASOP_NOGLOB */ +Word16 mac_r( Word32 L_var3, Word16 var1, Word16 var2 ); /* Mac with + rounding, 1 */ +#endif /* BASOP_NOGLOB */ +#ifndef BASOP_NOGLOB Word16 msu_r( Word32 L_var3, Word16 var1, Word16 var2 ); /* Msu with - rounding, 1 */ -Word32 L_deposit_h( Word16 var1 ); /* 16 bit var1 -> MSB, 1 */ -Word32 L_deposit_l( Word16 var1 ); /* 16 bit var1 -> LSB, 1 */ - -Word32 L_shr_r( Word32 L_var1, Word16 var2 ); /* Long shift right with - round, 3 */ -Word32 L_abs( Word32 L_var1 ); /* Long abs, 1 */ -Word32 DEPR_L_sat_co( Word32 L_var1, Flag Overflow, Flag Carry ); /* Long saturation, 4 */ -Word16 norm_s( Word16 var1 ); /* Short norm, 1 */ -Word16 div_s( Word16 var1, Word16 var2 ); /* Short division, 18 */ + rounding, 1 */ +#else /* BASOP_NOGLOB */ +Word16 msu_r( Word32 L_var3, Word16 var1, Word16 var2 ); /* Msu with + rounding, 1 */ +#endif /* BASOP_NOGLOB */ +#ifndef BASOP_NOGLOB +Word32 L_deposit_h( Word16 var1 ); /* 16 bit var1 -> MSB, 1 */ +Word32 L_deposit_l( Word16 var1 ); /* 16 bit var1 -> LSB, 1 */ +#else /* BASOP_NOGLOB */ +Word32 L_deposit_h( Word16 var1 ); /* 16 bit var1 -> MSB, 1 */ +Word32 L_deposit_l( Word16 var1 ); /* 16 bit var1 -> LSB, 1 */ +#endif /* BASOP_NOGLOB */ + +#ifndef BASOP_NOGLOB +Word32 L_shr_r( Word32 L_var1, Word16 var2 ); /* Long shift right with + round, 3 */ +#else /* BASOP_NOGLOB */ +Word32 L_shr_r( Word32 L_var1, Word16 var2 ); /* Long shift right with + round, 3 */ +#endif /* BASOP_NOGLOB */ +#ifndef BASOP_NOGLOB +Word32 L_abs( Word32 L_var1 ); /* Long abs, 1 */ +Word32 L_sat( Word32 L_var1 ); /* Long saturation, 4 */ +Word16 norm_s( Word16 var1 ); /* Short norm, 1 */ +Word16 div_s( Word16 var1, Word16 var2 ); /* Short division, 18 */ +Word16 norm_l( Word32 L_var1 ); /* Long norm, 1 */ +#else /* BASOP_NOGLOB */ +Word32 L_abs( Word32 L_var1 ); /* Long abs, 1 */ +Word32 DEPR_L_sat_co( Word32 L_var1, Flag Overflow, Flag Carry ); /* Long saturation, 4 */ +Word16 norm_s( Word16 var1 ); /* Short norm, 1 */ +Word16 div_s( Word16 var1, Word16 var2 ); /* Short division, 18 */ Word32 div_w( Word32 L_num, Word32 L_den ); -Word16 norm_l( Word32 L_var1 ); /* Long norm, 1 */ -Word32 L_sat( Word32 L_var1 ); /* Long saturation, 4 */ +Word16 norm_l( Word32 L_var1 ); /* Long norm, 1 */ +Word32 L_sat( Word32 L_var1 ); /* Long saturation, 4 */ +#endif /* BASOP_NOGLOB */ /* * Additional G.723.1 operators */ +#ifndef BASOP_NOGLOB +Word32 L_mls( Word32, Word16 ); /* Weight FFS; currently assigned 5 */ +Word16 div_l( Word32, Word16 ); /* Weight FFS; currently assigned 32 */ +Word16 i_mult( Word16 a, Word16 b ); /* Weight FFS; currently assigned 3 */ +#else /* BASOP_NOGLOB */ Word32 L_mls( Word32, Word16 ); /* Weight FFS; currently assigned 5 */ Word16 div_l( Word32, Word16 ); /* Weight FFS; currently assigned 32 */ Word16 i_mult( Word16 a, Word16 b ); /* Weight FFS; currently assigned 3 */ Word16 DEPR_i_mult( Word16 a, Word16 b ); /* Weight FFS; currently assigned 3 */ +#endif /* BASOP_NOGLOB */ /* * New shiftless operators, not used in G.729/G.723.1 @@ -187,6 +265,7 @@ Word16 DEPR_i_mult( Word16 a, Word16 b ); /* Weight FFS; currently assigned 3 */ Word32 L_mult0( Word16 v1, Word16 v2 ); /* 32-bit Multiply w/o shift 1 */ Word32 L_mac0( Word32 L_v3, Word16 v1, Word16 v2 ); /* 32-bit Mac w/o shift 1 */ Word32 L_msu0( Word32 L_v3, Word16 v1, Word16 v2 ); /* 32-bit Msu w/o shift 1 */ +#ifdef BASOP_NOGLOB /* * Overflowing operators @@ -217,6 +296,7 @@ Word32 L_shr_ro( Word32 L_var1, Word16 var2, Flag *Overflow ); Word32 L_macNs_co( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry, Flag *Overflow ); Word32 L_msuNs_co( Word32 L_var3, Word16 var1, Word16 var2, Flag *Carry, Flag *Overflow ); +#endif /* BASOP_NOGLOB */ /* * Saturating operators diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 4b38a9a03..a7d92629c 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -39,6 +39,7 @@ #include #include "options.h" +#include "stl.h" /* clang-format off */ #ifdef IVAS_FLOAT_FIXED @@ -257,6 +258,8 @@ enum{ #define SBA_AGC_FORCE_DISABLE 0 #define SBA_AGC_DEFAULT -1 +extern const Word16 Idx2Freq_Tbl[]; + /*----------------------------------------------------------------------------------* * Layers *----------------------------------------------------------------------------------*/ @@ -695,6 +698,7 @@ enum #define AUTO_REGRESSIVE 2 #define INT_FS_12k8 12800 /* internal sampling frequency */ +#define ONE_BY_INT_FS_12k8_Q42 343597384 /* internal sampling frequency */ #define M 16 /* order of the LP filter @ 12.8kHz */ #define L_FRAME 256 /* frame size at 12.8kHz */ #define NB_SUBFR 4 /* number of subframes per frame */ @@ -727,9 +731,7 @@ enum #define L_SUBFR16k ( L_FRAME16k / NB_SUBFR ) /* subframe size at 16kHz */ #define L_HALFR16k ( 2 * L_SUBFR16k ) /* half-frame size at 16kHz */ -#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT #define MAX_LP_FILTER_ORDER 20 /* Max order of an LP filter */ -#endif #define L_INTERPOL2 16 /* Length of filter for interpolation */ #define L_INTERPOL ( L_INTERPOL2 + 1 ) /* Length of filter for interpolation */ #define TILT_FAC 0.68f /* tilt factor (denominator) */ @@ -747,6 +749,7 @@ enum #define E_MIN_Q11_FX 7 /* minimum allowable energy in Q11*/ #define E_MIN 0.0035f /* minimum allowable energy */ #define E_MIN_Q11_FX 7 /* minimum allowable energy in Q11*/ +#define E_MIN_Q16_FX 229 /* minimum allowable energy in Q16*/ #define STEP_DELTA 0.0625f /* quantization step for tilt compensation of gaussian cb. excitation */ #define GAMMA_EV 0.92f /* weighting factor for core synthesis error weighting */ #define FORMANT_SHARPENING_NOISE_THRESHOLD 21.0f /* lp_noise level above which formant sharpening is deactivated */ @@ -3062,6 +3065,7 @@ enum #define G192_BIN1 (UWord16) 0x0081 /* binary "1" according to ITU-T G.192 */ #define DEGREE_180 (Word32)(180.0 *ONE_IN_Q23) #define DEGREE_360 (Word32)(360.0 *ONE_IN_Q23) +extern const Word16 Idx2Freq_Tbl[]; #define chk_fs(fs) /* 'x' is converted to Q6, 'Freq_Tbl'/1000 in Q9 */ diff --git a/lib_com/enh1632.c b/lib_com/enh1632.c index 124652b79..04c22ae97 100644 --- a/lib_com/enh1632.c +++ b/lib_com/enh1632.c @@ -376,13 +376,21 @@ Word32 L_lshr( Word32 L_var1, Word16 var2 ) * the range : 0xffff 8000 <= var_out <= 0x0000 7fff. * *****************************************************************************/ +#ifdef BASOP_NOGLOB Word16 shl_ro( Word16 var1, Word16 var2, Flag *Overflow ) +#else +Word16 shl_r( Word16 var1, Word16 var2 ) +#endif { Word16 var_out; if ( var2 >= 0 ) { +#ifdef BASOP_NOGLOB var_out = shl_o( var1, var2, Overflow ); +#else + var_out = shl( var1, var2 ); +#endif #ifdef WMOPS multiCounter[currCounter].shl--; #endif /* ifdef WMOPS */ @@ -390,26 +398,28 @@ Word16 shl_ro( Word16 var1, Word16 var2, Flag *Overflow ) else { var2 = -var2; +#ifdef BASOP_NOGLOB var_out = shr_ro( var1, var2, Overflow ); +#else + var_out = shr_r( var1, var2 ); +#endif #ifdef WMOPS -#ifndef FIX_1049_SHR_RO_COMPLEXITY multiCounter[currCounter].shr_r--; -#endif #endif /* ifdef WMOPS */ } #ifdef WMOPS -#ifndef FIX_1049_SHR_RO_COMPLEXITY multiCounter[currCounter].shl_r++; -#endif #endif /* ifdef WMOPS */ return ( var_out ); } +#ifdef BASOP_NOGLOB Word16 shl_r( Word16 var1, Word16 var2 ) { return shl_ro( var1, var2, NULL ); } +#endif /***************************************************************************** * * Function Name : L_shl_r @@ -674,4 +684,3 @@ Word32 L_rotl( Word32 L_var1, Word16 var2, Word16 *var3 ) #undef WMC_TOOL_SKIP /* end of file */ -/*AddedByWMC_Tool*/ int PROM_Size_Func( enh1632 ) { return 39; } diff --git a/lib_com/enh1632.h b/lib_com/enh1632.h index 755523a40..eed55ccad 100644 --- a/lib_com/enh1632.h +++ b/lib_com/enh1632.h @@ -35,13 +35,14 @@ #include "stl.h" - /***************************************************************************** * * Prototypes for enhanced 16/32 bit arithmetic operators * *****************************************************************************/ +#ifdef BASOP_NOGLOB Word16 shl_ro( Word16 var1, Word16 var2, Flag *Overflow ); +#endif Word16 shl_r( Word16 var1, Word16 var2 ); Word32 L_shl_r( Word32 L_var1, Word16 var2 ); diff --git a/lib_com/enh32.c b/lib_com/enh32.c index 59312a314..64afe8986 100644 --- a/lib_com/enh32.c +++ b/lib_com/enh32.c @@ -76,7 +76,11 @@ Word32 Mpy_32_32( Word32 L_var1, Word32 L_var2 ) #endif L64_var1 = ( (Word64) L_var1 * L_var2 ); +#ifdef BASOP_NOGLOB L64_var1 = W_shl_o( L64_var1, 1, &Overflow ); +#else /* BASOP_NOGLOB */ + L64_var1 = W_shl( L64_var1, 1 ); +#endif /* BASOP_NOGLOB */ L_var_out = W_extract_h( L64_var1 ); #ifdef WMOPS multiCounter[currCounter].Mpy_32_32++; @@ -110,7 +114,11 @@ Word32 Madd_32_16( Word32 L_var3, Word32 L_var1, Word16 var2 ) #endif L_var_out = Mpy_32_16_1( L_var1, var2 ); +#ifdef BASOP_NOGLOB L_var_out = L_add_o( L_var3, L_var_out, &Overflow ); +#else /* BASOP_NOGLOB */ + L_var_out = L_add( L_var3, L_var_out ); +#endif /* BASOP_NOGLOB */ #ifdef WMOPS multiCounter[currCounter].Mpy_32_16_1--; @@ -143,7 +151,11 @@ Word32 Msub_32_16( Word32 L_var3, Word32 L_var1, Word16 var2 ) #endif L_var_out = Mpy_32_16_1( L_var1, var2 ); +#ifdef BASOP_NOGLOB L_var_out = L_sub_o( L_var3, L_var_out, &Overflow ); +#else /* BASOP_NOGLOB */ + L_var_out = L_sub( L_var3, L_var_out ); +#endif #ifdef WMOPS multiCounter[currCounter].Mpy_32_16_1--; @@ -232,4 +244,3 @@ Word32 Msub_32_32_r( Word32 L_var3, Word32 L_var1, Word32 L_var2 ) #undef WMC_TOOL_SKIP /* end of file */ -/*AddedByWMC_Tool*/ int PROM_Size_Func( enh32 ) { return 18; } diff --git a/lib_com/enh40.c b/lib_com/enh40.c index 89960030f..929e3a950 100644 --- a/lib_com/enh40.c +++ b/lib_com/enh40.c @@ -96,7 +96,9 @@ #include #include #include "stl.h" +#ifdef BASOP_NOGLOB #include +#endif /* BASOP_NOGLOB */ #define WMC_TOOL_SKIP @@ -158,7 +160,11 @@ * the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************/ +#ifndef BASOP_NOGLOB +Word40 L40_shl( Word40 L40_var1, Word16 var2 ) +#else /* BASOP_NOGLOB */ Word40 L40_shl_o( Word40 L40_var1, Word16 var2, Flag *Overflow ) +#endif /* BASOP_NOGLOB */ { Word40 L40_var_out; @@ -188,15 +194,27 @@ Word40 L40_shl_o( Word40 L40_var1, Word16 var2, Flag *Overflow ) if ( L40_var_out > 0x003fffffffffLL ) #endif { +#ifndef BASOP_NOGLOB + Overflow = 1; + exit( 1 ); + /* L40_var_out = L40_OVERFLOW_OCCURED( L40_var_out); */ +#else /* BASOP_NOGLOB */ *Overflow = 1; L40_var_out = MAX_40; +#endif /* BASOP_NOGLOB */ break; } else if ( L40_var_out < L40_constant ) { +#ifndef BASOP_NOGLOB + Overflow = 1; + exit( 2 ); + /* L40_var_out = L40_UNDERFLOW_OCCURED( L40_var_out); */ +#else /* BASOP_NOGLOB */ *Overflow = 1; L40_var_out = MIN_40; +#endif /* BASOP_NOGLOB */ break; } @@ -216,6 +234,7 @@ Word40 L40_shl_o( Word40 L40_var1, Word16 var2, Flag *Overflow ) return ( L40_var_out ); } +#ifdef BASOP_NOGLOB Word40 L40_shl( Word40 L40_var1, Word16 var2 ) { @@ -274,6 +293,7 @@ Word40 L40_shl( Word40 L40_var1, Word16 var2 ) return ( L40_var_out ); } +#endif /* BASOP_NOGLOB */ /***************************************************************************** * @@ -402,6 +422,7 @@ Word40 L40_negate( Word40 L40_var1 ) * the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************/ +#ifdef BASOP_NOGLOB Word40 L40_add_o( Word40 L40_var1, Word40 L40_var2, Flag *Overflow ) { @@ -444,6 +465,7 @@ Word40 L40_add_o( Word40 L40_var1, Word40 L40_var2, Flag *Overflow ) return ( L40_var_out ); } +#endif /* BASOP_NOGLOB */ Word40 L40_add( Word40 L40_var1, Word40 L40_var2 ) { Word40 L40_var_out; @@ -453,24 +475,48 @@ Word40 L40_add( Word40 L40_var1, Word40 L40_var2 ) #if defined( _MSC_VER ) && ( _MSC_VER <= 1200 ) if ( ( ( ( L40_var1 & 0x8000000000 ) >> 39 ) != 0 ) && ( ( ( L40_var2 & 0x8000000000 ) >> 39 ) != 0 ) && ( ( ( L40_var_out & 0x8000000000 ) >> 39 ) == 0 ) ) { +#ifndef BASOP_NOGLOB + Overflow = 1; + exit( 2 ); + /* L40_var_out = L40_UNDERFLOW_OCCURED( L40_var_out); */ +#else /* BASOP_NOGLOB */ assert( 0 ); L40_var_out = MIN_40; +#endif /* BASOP_NOGLOB */ } else if ( ( ( ( L40_var1 & 0x8000000000 ) >> 39 ) == 0 ) && ( ( ( L40_var2 & 0x8000000000 ) >> 39 ) == 0 ) && ( ( ( L40_var_out & 0x8000000000 ) >> 39 ) != 0 ) ) { +#ifndef BASOP_NOGLOB + Overflow = 1; + exit( 1 ); + /* L40_var_out = L40_OVERFLOW_OCCURED( L40_var_out); */ +#else /* BASOP_NOGLOB */ assert( 0 ); L40_var_out = MAX_40; +#endif /* BASOP_NOGLOB */ } #else if ( ( ( ( L40_var1 & 0x8000000000LL ) >> 39 ) != 0 ) && ( ( ( L40_var2 & 0x8000000000LL ) >> 39 ) != 0 ) && ( ( ( L40_var_out & 0x8000000000LL ) >> 39 ) == 0 ) ) { +#ifndef BASOP_NOGLOB + Overflow = 1; + exit( 2 ); + /* L40_var_out = L40_UNDERFLOW_OCCURED( L40_var_out); */ +#else /* BASOP_NOGLOB */ assert( 0 ); L40_var_out = MIN_40; +#endif /* BASOP_NOGLOB */ } else if ( ( ( ( L40_var1 & 0x8000000000LL ) >> 39 ) == 0 ) && ( ( ( L40_var2 & 0x8000000000LL ) >> 39 ) == 0 ) && ( ( ( L40_var_out & 0x8000000000LL ) >> 39 ) != 0 ) ) { +#ifndef BASOP_NOGLOB + Overflow = 1; + exit( 1 ); + /* L40_var_out = L40_OVERFLOW_OCCURED( L40_var_out); */ +#else /* BASOP_NOGLOB */ assert( 0 ); L40_var_out = MAX_40; +#endif /* BASOP_NOGLOB */ } #endif @@ -515,7 +561,11 @@ Word40 L40_add( Word40 L40_var1, Word40 L40_var2 ) * the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************/ +#ifndef BASOP_NOGLOB +Word40 L40_sub( Word40 L40_var1, Word40 L40_var2 ) +#else /* BASOP_NOGLOB */ Word40 L40_sub_o( Word40 L40_var1, Word40 L40_var2, Flag *Overflow ) +#endif /* BASOP_NOGLOB */ { Word40 L40_var_out; @@ -524,24 +574,48 @@ Word40 L40_sub_o( Word40 L40_var1, Word40 L40_var2, Flag *Overflow ) #if defined( _MSC_VER ) && ( _MSC_VER <= 1200 ) if ( ( ( ( L40_var1 & 0x8000000000 ) >> 39 ) != 0 ) && ( ( ( L40_var2 & 0x8000000000 ) >> 39 ) == 0 ) && ( ( ( L40_var_out & 0x8000000000 ) >> 39 ) == 0 ) ) { +#ifndef BASOP_NOGLOB + Overflow = 1; + exit( 2 ); + /* L40_var_out = L40_UNDERFLOW_OCCURED( L40_var_out); */ +#else /* BASOP_NOGLOB */ *Overflow = 1; L40_var_out = MIN_40; +#endif /* BASOP_NOGLOB */ } else if ( ( ( ( L40_var1 & 0x8000000000 ) >> 39 ) == 0 ) && ( ( ( L40_var2 & 0x8000000000 ) >> 39 ) != 0 ) && ( ( ( L40_var_out & 0x8000000000 ) >> 39 ) != 0 ) ) { +#ifndef BASOP_NOGLOB + Overflow = 1; + exit( 1 ); + /* L40_var_out = L40_OVERFLOW_OCCURED( L40_var_out); */ +#else /* BASOP_NOGLOB */ *Overflow = 1; L40_var_out = MAX_40; +#endif /* BASOP_NOGLOB */ } #else if ( ( ( ( L40_var1 & 0x8000000000LL ) >> 39 ) != 0 ) && ( ( ( L40_var2 & 0x8000000000LL ) >> 39 ) == 0 ) && ( ( ( L40_var_out & 0x8000000000LL ) >> 39 ) == 0 ) ) { +#ifndef BASOP_NOGLOB + Overflow = 1; + exit( 2 ); + /* L40_var_out = L40_UNDERFLOW_OCCURED( L40_var_out); */ +#else /* BASOP_NOGLOB */ *Overflow = 1; L40_var_out = MIN_40; +#endif /* BASOP_NOGLOB */ } else if ( ( ( ( L40_var1 & 0x8000000000LL ) >> 39 ) == 0 ) && ( ( ( L40_var2 & 0x8000000000LL ) >> 39 ) != 0 ) && ( ( ( L40_var_out & 0x8000000000LL ) >> 39 ) != 0 ) ) { +#ifndef BASOP_NOGLOB + Overflow = 1; + exit( 1 ); + /* L40_var_out = L40_OVERFLOW_OCCURED( L40_var_out); */ +#else /* BASOP_NOGLOB */ *Overflow = 1; L40_var_out = MAX_40; +#endif /* BASOP_NOGLOB */ } #endif @@ -555,6 +629,7 @@ Word40 L40_sub_o( Word40 L40_var1, Word40 L40_var2, Flag *Overflow ) return ( L40_var_out ); } +#ifdef BASOP_NOGLOB Word40 L40_sub( Word40 L40_var1, Word40 L40_var2 ) { Word40 L40_var_out; @@ -594,6 +669,7 @@ Word40 L40_sub( Word40 L40_var1, Word40 L40_var2 ) return ( L40_var_out ); } +#endif /* BASOP_NOGLOB */ /***************************************************************************** * @@ -762,8 +838,12 @@ Word40 L40_min( Word40 L40_var1, Word40 L40_var2 ) * the range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. * *****************************************************************************/ +#ifndef BASOP_NOGLOB +Word32 L_saturate40( Word40 L40_var1 ) +#else /* BASOP_NOGLOB */ Word32 L_saturate40_o( Word40 L40_var1, Flag *Overflow ) +#endif /* BASOP_NOGLOB */ { Word32 L_var_out; @@ -773,13 +853,21 @@ Word32 L_saturate40_o( Word40 L40_var1, Flag *Overflow ) if ( L40_var1 < UNDER_L40_var2 ) { L40_var1 = UNDER_L40_var2; +#ifndef BASOP_NOGLOB + Overflow = 1; +#else /* BASOP_NOGLOB */ *Overflow = 1; +#endif /* BASOP_NOGLOB */ } if ( L40_var1 > OVER_L40_var2 ) { L40_var1 = OVER_L40_var2; +#ifndef BASOP_NOGLOB + Overflow = 1; +#else /* BASOP_NOGLOB */ *Overflow = 1; +#endif /* BASOP_NOGLOB */ } L_var_out = L_Extract40( L40_var1 ); @@ -794,6 +882,7 @@ Word32 L_saturate40_o( Word40 L40_var1, Flag *Overflow ) return ( L_var_out ); } +#ifdef BASOP_NOGLOB Word32 L_saturate40( Word40 L40_var1 ) { Word32 L_var_out; @@ -824,6 +913,7 @@ Word32 L_saturate40( Word40 L40_var1 ) return ( L_var_out ); } +#endif /* BASOP_NOGLOB */ /***************************************************************************** * diff --git a/lib_com/enh40.h b/lib_com/enh40.h index ff1a86b92..ca78cb33e 100644 --- a/lib_com/enh40.h +++ b/lib_com/enh40.h @@ -56,8 +56,10 @@ #include "stl.h" +#if defined( BASOP_NOGLOB ) || defined( _MSC_VER ) #define MAX_40 ( 0x0000007fffffffff ) #define MIN_40 ( 0xffffff8000000000 ) +#endif #define L40_OVERFLOW_OCCURED( L40_var1 ) ( Overflow = 1, exit( 1 ), L40_var1 ) #define L40_UNDERFLOW_OCCURED( L40_var1 ) ( Overflow = 1, exit( 2 ), L40_var1 ) @@ -109,6 +111,7 @@ Word40 L40_max( Word40 L40_var1, Word40 L40_var2 ); Word40 L40_min( Word40 L40_var1, Word40 L40_var2 ); Word32 L_saturate40( Word40 L40_var1 ); Word16 norm_L40( Word40 L40_var1 ); +#ifdef BASOP_NOGLOB /* * Overflowing operators */ @@ -116,6 +119,7 @@ Word40 L40_shl_o( Word40 L40_var1, Word16 var2, Flag *Overflow ); Word40 L40_add_o( Word40 L40_var1, Word40 L40_var2, Flag *Overflow ); Word40 L40_sub_o( Word40 L40_var1, Word40 L40_var2, Flag *Overflow ); Word32 L_saturate40_o( Word40 L40_var1, Flag *Overflow ); +#endif /* BASOP_NOGLOB */ /*#ifdef _MSC_VER*/ static __inline Word40 L40_set( Word40 L40_var1 ) { diff --git a/lib_com/enh64.c b/lib_com/enh64.c index 1eb6c865f..9eb58c4d3 100644 --- a/lib_com/enh64.c +++ b/lib_com/enh64.c @@ -161,7 +161,11 @@ Word64 W_sub_nosat( Word64 L64_var1, Word64 L64_var2 ) | range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | |___________________________________________________________________________| */ +#ifdef BASOP_NOGLOB Word64 W_shl_o( Word64 L64_var1, Word16 var2, Flag *Overflow ) +#else /* BASOP_NOGLOB */ +Word64 W_shl( Word64 L64_var1, Word16 var2 ) +#endif /* BASOP_NOGLOB */ { Word64 L64_var_out = 0LL; @@ -179,7 +183,11 @@ Word64 W_shl_o( Word64 L64_var1, Word16 var2, Flag *Overflow ) { if ( L64_var1 > (Word64) 0X3fffffffffffffffLL ) { +#ifdef BASOP_NOGLOB set_overflow( Overflow ); +#else /* BASOP_NOGLOB */ + Overflow = 1; +#endif /* BASOP_NOGLOB */ L64_var_out = (Word64) 0X7fffffffffffffffLL; break; } @@ -187,7 +195,11 @@ Word64 W_shl_o( Word64 L64_var1, Word16 var2, Flag *Overflow ) { if ( L64_var1 < (Word64) 0xc000000000000000LL ) { +#ifdef BASOP_NOGLOB set_overflow( Overflow ); +#else /* BASOP_NOGLOB */ + Overflow = 1; +#endif /* BASOP_NOGLOB */ L64_var_out = (Word64) 0x8000000000000000LL; break; } @@ -205,10 +217,12 @@ Word64 W_shl_o( Word64 L64_var1, Word16 var2, Flag *Overflow ) return ( L64_var_out ); } +#ifdef BASOP_NOGLOB Word64 W_shl( Word64 L64_var1, Word16 var2 ) { return W_shl_o( L64_var1, var2, NULL ); } +#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ @@ -1171,7 +1185,11 @@ Word32 W_shl_sat_l( Word64 L64_var, Word16 n ) | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |__________________________________________________________________________________| */ +#ifdef BASOP_NOGLOB Word32 W_round48_L_o( Word64 L64_var1, Flag *Overflow ) +#else /* BASOP_NOGLOB */ +Word32 W_round48_L( Word64 L64_var1 ) +#endif /* BASOP_NOGLOB */ { Word64 L64_var_out; Word32 L_result; @@ -1189,7 +1207,11 @@ Word32 W_round48_L_o( Word64 L64_var1, Flag *Overflow ) if ( ( L64_var_out ^ L64_var1 ) & L64_MIN ) { L64_var_out = ( L64_var1 < 0 ) ? L64_MIN : L64_MAX; +#ifdef BASOP_NOGLOB set_overflow( Overflow ); +#else /* BASOP_NOGLOB */ + Overflow = 1; +#endif /* BASOP_NOGLOB */ } } L_result = W_extract_h( L64_var_out ); @@ -1202,10 +1224,12 @@ Word32 W_round48_L_o( Word64 L64_var1, Flag *Overflow ) return ( L_result ); } +#ifdef BASOP_NOGLOB Word32 W_round48_L( Word64 L64_var1 ) { return W_round48_L_o( L64_var1, NULL ); } +#endif /* BASOP_NOGLOB */ /*__________________________________________________________________________________ | | @@ -1234,7 +1258,11 @@ Word32 W_round48_L( Word64 L64_var1 ) | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |__________________________________________________________________________________| */ +#ifdef BASOP_NOGLOB Word16 W_round32_s_o( Word64 L64_var1, Flag *Overflow ) +#else /* BASOP_NOGLOB */ +Word16 W_round32_s( Word64 L64_var1 ) +#endif /* BASOP_NOGLOB */ { Word64 L64_var_out; Word32 L_var; @@ -1253,7 +1281,11 @@ Word16 W_round32_s_o( Word64 L64_var1, Flag *Overflow ) if ( ( L64_var_out ^ L64_var1 ) & L64_MIN ) { L64_var_out = ( L64_var1 < 0 ) ? L64_MIN : L64_MAX; +#ifdef BASOP_NOGLOB set_overflow( Overflow ); +#else /* BASOP_NOGLOB */ + Overflow = 1; +#endif /* BASOP_NOGLOB */ } } L_var = W_extract_h( L64_var_out ); @@ -1268,10 +1300,12 @@ Word16 W_round32_s_o( Word64 L64_var1, Flag *Overflow ) return ( var_out ); } +#ifdef BASOP_NOGLOB Word16 W_round32_s( Word64 L64_var1 ) { return W_round32_s_o( L64_var1, NULL ); } +#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ | | @@ -1364,7 +1398,11 @@ Word16 W_norm( Word64 L64_var1 ) | range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | |_______________________________________________________________________________| */ +#ifdef BASOP_NOGLOB Word64 W_add_o( Word64 L64_var1, Word64 L64_var2, Flag *Overflow ) +#else /* BASOP_NOGLOB */ +Word64 W_add( Word64 L64_var1, Word64 L64_var2 ) +#endif /* BASOP_NOGLOB */ { Word64 L64_var_out; @@ -1375,7 +1413,11 @@ Word64 W_add_o( Word64 L64_var1, Word64 L64_var2, Flag *Overflow ) if ( ( L64_var_out ^ L64_var1 ) & MIN_64 ) { L64_var_out = ( L64_var1 < 0 ) ? MIN_64 : MAX_64; +#ifdef BASOP_NOGLOB set_overflow( Overflow ); +#else /* BASOP_NOGLOB */ + Overflow = 1; +#endif /* BASOP_NOGLOB */ } } @@ -1385,10 +1427,12 @@ Word64 W_add_o( Word64 L64_var1, Word64 L64_var2, Flag *Overflow ) return L64_var_out; } +#ifdef BASOP_NOGLOB Word64 W_add( Word64 L64_var1, Word64 L64_var2 ) { return W_add_o( L64_var1, L64_var2, NULL ); } +#endif /* BASOP_NOGLOB */ /*______________________________________________________________________________ | | @@ -1421,7 +1465,11 @@ Word64 W_add( Word64 L64_var1, Word64 L64_var2 ) | range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | |_______________________________________________________________________________| */ +#ifdef BASOP_NOGLOB Word64 W_sub_o( Word64 L64_var1, Word64 L64_var2, Flag *Overflow ) +#else /* BASOP_NOGLOB */ +Word64 W_sub( Word64 L64_var1, Word64 L64_var2 ) +#endif /* BASOP_NOGLOB */ { Word64 L64_var_out; @@ -1432,7 +1480,11 @@ Word64 W_sub_o( Word64 L64_var1, Word64 L64_var2, Flag *Overflow ) if ( ( L64_var_out ^ L64_var1 ) & MIN_64 ) { L64_var_out = ( L64_var1 < 0 ) ? MIN_64 : MAX_64; +#ifdef BASOP_NOGLOB set_overflow( Overflow ); +#else /* BASOP_NOGLOB */ + Overflow = 1; +#endif /* BASOP_NOGLOB */ } } @@ -1442,10 +1494,12 @@ Word64 W_sub_o( Word64 L64_var1, Word64 L64_var2, Flag *Overflow ) return L64_var_out; } +#ifdef BASOP_NOGLOB Word64 W_sub( Word64 L64_var1, Word64 L64_var2 ) { return W_sub_o( L64_var1, L64_var2, NULL ); } +#endif /* BASOP_NOGLOB */ /*______________________________________________________________________________ @@ -1475,14 +1529,22 @@ Word64 W_sub( Word64 L64_var1, Word64 L64_var2 ) | range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | |_______________________________________________________________________________| */ +#ifdef BASOP_NOGLOB Word64 W_neg_o( Word64 L64_var1, Flag *Overflow ) +#else /* BASOP_NOGLOB */ +Word64 W_neg( Word64 L64_var1 ) +#endif /* BASOP_NOGLOB */ { Word64 L64_var_out; if ( L64_var1 == MIN_64 ) { L64_var_out = MAX_64; +#ifdef BASOP_NOGLOB set_overflow( Overflow ); +#else /* BASOP_NOGLOB */ + Overflow = 1; +#endif /* BASOP_NOGLOB */ } else { @@ -1496,10 +1558,12 @@ Word64 W_neg_o( Word64 L64_var1, Flag *Overflow ) return ( L64_var_out ); } +#ifdef BASOP_NOGLOB Word64 W_neg( Word64 L64_var1 ) { return W_neg_o( L64_var1, NULL ); } +#endif /* BASOP_NOGLOB */ /*___________________________________________________________________________ @@ -1529,14 +1593,22 @@ Word64 W_neg( Word64 L64_var1 ) | range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. | |___________________________________________________________________________| */ +#ifdef BASOP_NOGLOB Word64 W_abs_o( Word64 L64_var1, Flag *Overflow ) +#else /* BASOP_NOGLOB */ +Word64 W_abs( Word64 L64_var1 ) +#endif /* BASOP_NOGLOB */ { Word64 L64_var_out; if ( L64_var1 == MIN_64 ) { L64_var_out = MAX_64; +#ifdef BASOP_NOGLOB set_overflow( Overflow ); +#else /* BASOP_NOGLOB */ + Overflow = 1; +#endif /* BASOP_NOGLOB */ } else { @@ -1557,10 +1629,12 @@ Word64 W_abs_o( Word64 L64_var1, Flag *Overflow ) return ( L64_var_out ); } +#ifdef BASOP_NOGLOB Word64 W_abs( Word64 L64_var1 ) { return W_abs_o( L64_var1, NULL ); } +#endif /* BASOP_NOGLOB */ /*_________________________________________________________________________________________________ | | @@ -1594,14 +1668,22 @@ Word64 W_abs( Word64 L64_var1 ) | range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | |_________________________________________________________________________________________________| */ +#ifdef BASOP_NOGLOB Word64 W_mult_32_32_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) +#else /* BASOP_NOGLOB */ +Word64 W_mult_32_32( Word32 L_var1, Word32 L_var2 ) +#endif /* BASOP_NOGLOB */ { Word64 L64_var_out; if ( ( L_var1 == MIN_32 ) && ( L_var2 == MIN_32 ) ) { L64_var_out = MAX_64; +#ifdef BASOP_NOGLOB set_overflow( Overflow ); +#else /* BASOP_NOGLOB */ + Overflow = 1; +#endif /* BASOP_NOGLOB */ } else { @@ -1614,10 +1696,12 @@ Word64 W_mult_32_32_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ) return L64_var_out; } +#ifdef BASOP_NOGLOB Word64 W_mult_32_32( Word32 L_var1, Word32 L_var2 ) { return W_mult_32_32_o( L_var1, L_var2, NULL ); } +#endif /* BASOP_NOGLOB */ /*_________________________________________________________________________________________________ | | @@ -1819,4 +1903,3 @@ Word32 W_round64_L( Word64 L64_var1 ) #undef WMC_TOOL_SKIP /* end of file */ -/*AddedByWMC_Tool*/ int PROM_Size_Func( enh64 ) { return 74; } diff --git a/lib_com/enh64.h b/lib_com/enh64.h index c3896bb0d..8aed870a6 100644 --- a/lib_com/enh64.h +++ b/lib_com/enh64.h @@ -65,6 +65,7 @@ UWord64 W_lshl( UWord64 L64_var1, Word16 var2 ); UWord64 W_lshr( UWord64 L64_var1, Word16 var2 ); Word32 W_round64_L( Word64 L64_var1 ); +#ifdef BASOP_NOGLOB /* * Overflowing operators */ @@ -76,6 +77,7 @@ Word64 W_sub_o( Word64 L64_var1, Word64 L64_var2, Flag *Overflow ); Word64 W_neg_o( Word64 L64_var1, Flag *Overflow ); Word64 W_abs_o( Word64 L64_var1, Flag *Overflow ); Word64 W_mult_32_32_o( Word32 L_var1, Word32 L_var2, Flag *Overflow ); +#endif /* BASOP_NOGLOB */ #endif /* #ifdef ENH_64_BIT_OPERATOR */ diff --git a/lib_com/enhUL32.c b/lib_com/enhUL32.c index 6ee620ad4..565082120 100644 --- a/lib_com/enhUL32.c +++ b/lib_com/enhUL32.c @@ -25,6 +25,7 @@ #include #include #include "stl.h" +#include "stl.h" #define WMC_TOOL_SKIP @@ -62,6 +63,7 @@ UWord32 UL_deposit_l( UWord16 uvar ) #endif return ( UL_result ); } + /*___________________________________________________________________________ | | | Function Name : UL_addNs | @@ -362,4 +364,3 @@ UWord32 UL_addNsD( UWord32 UL_var1, UWord32 UL_var2 ) #undef WMC_TOOL_SKIP /* end of file */ -/*AddedByWMC_Tool*/ int PROM_Size_Func( enhUL32 ) { return 26; } diff --git a/lib_com/enhUL32.h b/lib_com/enhUL32.h index 284d84a24..d200342b4 100644 --- a/lib_com/enhUL32.h +++ b/lib_com/enhUL32.h @@ -24,7 +24,6 @@ #define UWord64 unsigned long long /* for local use inside UL_Mpy_32_* */ #endif - /***************************************************************************** * * Prototypes for enhanced unsigned 32 bit arithmetic operators diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index 3deeab63d..961425a99 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -182,31 +182,35 @@ extern const Word16 dicnlg2[40]; // Q0 extern const Resampling_cfg resampling_cfg_tbl[]; /* table of resampling configurations */ extern const FrameSizeParams FrameSizeConfig[FRAME_SIZE_NB]; -extern const float h_high[]; /* HP filter for filtering random part of excitation in FEC */ -extern const Word16 h_high_fx[5]; // Q15 +#ifndef IVAS_FLOAT_FIXED +extern const float h_high[]; /* HP filter for filtering random part of excitation in FEC */ +#endif +extern const Word16 h_high_fx[5]; // Q15 +extern const Word16 sincos_t_fx[161]; // Q15 +extern const Word16 sincos_t_ext_fx[]; // Q15 #ifdef IVAS_FLOAT_FIXED extern const Word32 crit_bands_fx[]; -#endif // IVAS_FLOAT_FIXED -extern const float crit_bands[]; /* Table of critical bands */ -extern const float sincos_t[]; /* FFT - sinus and cosinus tables */ -extern const Word16 sincos_t_fx[161]; // Q15 +#endif // IVAS_FLOAT_FIXED +extern const float crit_bands[]; /* Table of critical bands */ +#ifndef IVAS_FLOAT_FIXED +extern const float sincos_t[]; /* FFT - sinus and cosinus tables */ +extern const float inter4_2[]; /* 1/4 resolution interpolation filter */ +#endif +extern const float LP_assym_window[]; /* Assymetric window for LP analysis @12.8kHz */ +extern const float LP_assym_window_16k[]; /* Assymetric window for LP analysis @16kHz */ +extern const float hamcos_window[]; /* Hamming-Cosinus window */ extern const float sincos_t_ext[]; -extern const Word16 sincos_t_ext_fx[]; // Q15 extern const float sincos_t_rad3[]; +extern const float grid50[]; /* Table of grid points for evaluating Chebyshev polynomials */ +extern const float grid40[]; /* Table of grid points for evaluating Chebyshev polynomials */ extern const Word16 sincos_t_rad3_fx[]; // Q15 extern const Word16 fft256_read_indexes[]; /* FFT Q0*/ -extern const float inter4_2[]; /* 1/4 resolution interpolation filter */ extern const Word16 inter4_2_fx_Q15[]; // Q15 /* 1/4 resolution interpolation filter */ extern const Word16 inter4_2_fx[]; extern const Word16 pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1]; /*1Q14*/ extern const Word16 pitch_inter4_2[PIT_FIR_SIZE2]; /*1Q14*/ -extern const float LP_assym_window[]; /* Assymetric window for LP analysis @12.8kHz */ -extern const float LP_assym_window_16k[]; /* Assymetric window for LP analysis @16kHz */ extern const Word16 Assym_window_W16fx[]; // Q15 extern const Word16 assym_window_16k_fx[]; // Q15 -extern const float hamcos_window[]; /* Hamming-Cosinus window */ -extern const float grid50[]; /* Table of grid points for evaluating Chebyshev polynomials */ -extern const float grid40[]; /* Table of grid points for evaluating Chebyshev polynomials */ #ifdef IVAS_FLOAT_FIXED extern const Word16 grid50_fx[( GRID50_POINTS - 1 ) / 2 - 1]; // Q15 extern const Word16 grid40_fx[( GRID40_POINTS - 1 ) / 2 - 1]; // Q15 @@ -240,38 +244,44 @@ extern const Word32 lag_window_16k_32[NUM_LAGW_STRENGTHS][16]; // Q31 extern const Word32 lag_window_25k6_32[NUM_LAGW_STRENGTHS][16]; // Q31 extern const Word32 lag_window_32k_32[NUM_LAGW_STRENGTHS][16]; // Q31 extern const Word32 lag_window_48k_32[16]; // Q31 -extern const float interpol_frac2[]; /* LPC interpolation coefficients for two-subframe mode */ -extern const float interpol_frac2_mid[]; /* LPC interpolation coefficients with mid-ISFs for two-subframe mode */ -extern const float interpol_frac_12k8[]; /* LPC interpolation coefficients */ extern const Word16 interpol_frac2_fx[]; // Q15 /* LPC interpolation coefficients for two-subframe mode */ extern const Word16 interpol_frac2_mid_fx[]; // Q15 /* LPC interpolation coefficients with mid-ISFs for two-subframe mode */ extern const Word16 interpol_frac_12k8_fx[]; // Q15 /* LPC interpolation coefficients */ extern const Word16 interpol_frac_fx[NB_SUBFR]; // Q15 -extern const float interpol_isp_amr_wb[]; /* LPC interpolation coefficients for AMR-WB interoperable mode */ +#ifndef IVAS_FLOAT_FIXED +extern const float interpol_frac2[]; /* LPC interpolation coefficients for two-subframe mode */ +extern const float interpol_frac_12k8[]; /* LPC interpolation coefficients */ +#endif +extern const float interpol_isp_amr_wb[]; /* LPC interpolation coefficients for AMR-WB interoperable mode */ +extern const float interpol_frac2_mid[]; /* LPC interpolation coefficients with mid-ISFs for two-subframe mode */ extern const Word16 interpol_isp_amr_wb_fx[]; // Q15 -extern const float interpol_frac_16k[]; /* LPC interpolation coefficients @ 16kHz */ -extern const Word16 interpol_frac_16k_fx[NB_SUBFR16k]; // Q15 -extern const float interpol_frac_mid[]; /* LPC interpolation coefficients with mid-ISFs */ -extern const Word16 interpol_frac_mid_fx[NB_SUBFR * 3]; // Q15 -extern const float interpol_frac_mid_16k[]; /* LPC interpolation coefficients with mid-ISFs @ 16kHz */ -extern const Word16 interpol_frac_mid_16k_fx[NB_SUBFR16k * 3]; // Q15 -extern const float interpol_frac_mid_relaxprev_12k8[]; /* LPC interpolation coefficients with mid-ISFs @ 16kHz - relaxed prev frame interp */ -extern const Word16 interpol_frac_mid_relaxprev_12k8_fx[NB_SUBFR * 3]; // Q15 -extern const float interpol_frac_mid_FEC[]; /* LPC interpolation coefficients with mid-ISFs - FEC */ -extern const Word16 interpol_frac_mid_FEC_fx[NB_SUBFR * 3]; // Q15 -extern const float interpol_frac_mid_relaxprev_16k[]; /* LPC interpolation coefficients with mid-ISFs @ 16kHz - relaxed prev frame interp */ -extern const Word16 interpol_frac_mid_relaxprev_16k_fx[NB_SUBFR16k * 3]; // Q15 -extern const float interpol_frac_mid_16k_FEC[]; /* LPC interpolation coefficients with mid-ISFs @ 16kHz - FEC */ -extern const Word16 interpol_frac_mid_16k_FEC_fx[NB_SUBFR16k * 3]; // Q15 +extern const float interpol_frac_16k[]; /* LPC interpolation coefficients @ 16kHz */ +extern const float interpol_frac_mid[]; /* LPC interpolation coefficients with mid-ISFs */ +extern const float interpol_frac_mid_16k[]; /* LPC interpolation coefficients with mid-ISFs @ 16kHz */ +extern const float interpol_frac_mid_relaxprev_12k8[]; /* LPC interpolation coefficients with mid-ISFs @ 16kHz - relaxed prev frame interp */ +extern const float interpol_frac_mid_FEC[]; /* LPC interpolation coefficients with mid-ISFs - FEC */ +extern const float interpol_frac_mid_relaxprev_16k[]; /* LPC interpolation coefficients with mid-ISFs @ 16kHz - relaxed prev frame interp */ +extern const float interpol_frac_mid_16k_FEC[]; /* LPC interpolation coefficients with mid-ISFs @ 16kHz - FEC */ extern const float interpol_frac_mid_relaxprev_pred_12k8[]; -extern const Word16 interpol_frac_mid_relaxprev_pred_12k8_fx[NB_SUBFR * 3]; // Q15 extern const float interpol_frac_mid_relaxprev_pred_16k[]; +extern const Word16 interpol_frac_16k_fx[NB_SUBFR16k]; // Q15 +extern const Word16 interpol_frac_mid_fx[NB_SUBFR * 3]; // Q15 +extern const Word16 interpol_frac_mid_16k_fx[NB_SUBFR16k * 3]; // Q15 +extern const Word16 interpol_frac_mid_relaxprev_12k8_fx[NB_SUBFR * 3]; // Q15 +extern const Word16 interpol_frac_mid_FEC_fx[NB_SUBFR * 3]; // Q15 +extern const Word16 interpol_frac_mid_relaxprev_16k_fx[NB_SUBFR16k * 3]; // Q15 +extern const Word16 interpol_frac_mid_16k_FEC_fx[NB_SUBFR16k * 3]; // Q15 +extern const Word16 interpol_frac_mid_relaxprev_pred_12k8_fx[NB_SUBFR * 3]; // Q15 extern const Word16 interpol_frac_mid_relaxprev_pred_16k_fx[NB_SUBFR16k * 3]; // Q15 +#ifndef IVAS_FLOAT_FIXED extern const float inter6_2[PIT_FIR_SIZE6_2]; +#endif +#ifdef IVAS_FLOAT_FIXED extern const Word16 pitch_inter6_2[PIT_FIR_SIZE6_2]; /*1Q14*/ +#endif extern const float inter4_2tcx2_flt[4][4]; extern const float inter6_2tcx2_flt[6][4]; @@ -292,16 +302,18 @@ extern const TCX_LTP_FILTER tcxLtpFilters[12]; extern const float gain_qua_mless_7b[]; /* Gain quantization - gain quantization table */ extern const float gain_qua_mless_6b_stereo[]; /* Gain quantization - gain quantization table in IVAS */ -extern const Word16 gain_qua_mless_6b_stereo_fx[]; // Q14 /* Gain quantization - gain quantization table in IVAS */ extern const float gain_qua_mless_6b[]; /* Gain quantization - gain quantization table */ extern const float gain_qua_mless_5b[]; /* Gain quantization - gain quantization table */ +extern const Word16 gain_qua_mless_6b_stereo_fx[]; // Q14 /* Gain quantization - gain quantization table in IVAS */ extern const Word16 gain_qua_mless_7b_fx[]; // Q14 extern const Word16 gain_qua_mless_6b_fx[]; // Q14 extern const Word16 gain_qua_mless_5b_fx[]; // Q14 -extern const float pred_gain[]; /* Gain quantization - MA predicition coefficients for gain quantizer */ -extern const float t_qua_gain6b[]; /* Gain quantization - gain quantization table for AMR-WB interoperable mode */ -extern const float t_qua_gain7b[]; /* Gain quantization - gain quantization table for AMR-WB interoperable mode */ +#ifndef IVAS_FLOAT_FIXED +extern const float pred_gain[]; /* Gain quantization - MA predicition coefficients for gain quantizer */ +extern const float t_qua_gain6b[]; /* Gain quantization - gain quantization table for AMR-WB interoperable mode */ +extern const float t_qua_gain7b[]; /* Gain quantization - gain quantization table for AMR-WB interoperable mode */ +#endif extern const Word16 pred_gain_fx[GAIN_PRED_ORDER]; // Q14 extern const Word16 t_qua_gain6b_fx[64 * 2]; // Q14 extern const Word16 t_qua_gain7b_fx[128 * 2]; // Q14 @@ -324,7 +336,6 @@ extern const Word16 b_2sfr_fx[]; // Q12 extern const Word16 b_3sfr_fx[]; // Q12 extern const Word16 b_4sfr_fx[]; // Q12 - extern const float gp_gamma_1sfr_8b[]; /* Gain quantization - gain quantization table for gain quantizer at 7.2 and 8.0 kbps */ extern const float gp_gamma_1sfr_7b[]; /* Gain quantization - gain quantization table for gain quantizer at 7.2 and 8.0 kbps */ @@ -354,39 +365,42 @@ extern const int16_t E_ROM_qua_gain7b_const[]; extern const float gain_qua_mless[]; +#ifndef IVAS_FLOAT_FIXED +extern const float tbl_gain_trans_tc[]; /* TC - gain quantization table for g_trans */ +#endif extern const float tbl_gain_code_tc[]; /* TC - code gain quantization table */ +extern const float glottal_cdbk[]; /* TC - table of prototype glottal impulses */ extern const Word16 tbl_gain_code_tc_fx[N_GAIN_CODE_TC]; // Q13 extern const Word16 tbl_gain_code_tc_quant_mean[N_GAIN_CODE_TC - 1]; // Q13 -extern const float tbl_gain_trans_tc[]; /* TC - gain quantization table for g_trans */ -extern const float glottal_cdbk[]; /* TC - table of prototype glottal impulses */ extern const Word16 tbl_gain_trans_tc_fx[]; // Q7/Q4 extern const Word16 Glottal_cdbk_fx[]; // Q13 extern const Word32 PI_select_table[23][8]; /* selection table for Pulse indexing Q0*/ -extern const int32_t PI_offset[8][8]; /* offset table for Pulse indexing Q0*/ +extern const Word32 PI_offset[8][8]; /* offset table for Pulse indexing Q0*/ extern const Word16 PI_factor[]; /* EVS_PI factor table for Pulse indexing Q0*/ /* ACELP pulse coding */ -extern const Word16 hi_to_low_tmpl[10]; // Q0 -extern const uint16_t low_len[10]; // Q0 -extern const uint16_t low_mask[10]; // Q0 -extern const uint16_t indx_fact[10]; // Q0 -extern const int16_t index_len[3]; // Q0 -extern const int16_t index_mask_ACELP[3]; // Q0 - - -extern const float deem_tab[]; /* HF BWE - de-emphasis coefficients */ -extern const Word16 deem_tab_fx[]; // Q15 +extern const Word16 hi_to_low_tmpl[10]; // Q0 +extern const UWord16 low_len[10]; // Q0 +extern const UWord16 low_mask[10]; // Q0 +extern const UWord16 indx_fact[10]; // Q0 +extern const Word16 index_len[3]; // Q0 +extern const Word16 index_mask_ACELP[3]; // Q0 + +#ifndef IVAS_FLOAT_FIXED +extern const float deem_tab[]; /* HF BWE - de-emphasis coefficients */ extern const float filt_hp[]; +extern const float exp_tab_p[]; /* HF BWE - Table of values exp(-j*w*i) */ +extern const float exp_tab_q[]; /* HF BWE - Table of values exp(-j*w*i) */ +#endif +extern const float fir_6k_8k[]; /* HF BWE - band-pass filter coefficients */ +extern const float HP_gain[]; /* HF BWE - quantization table for 23.85 */ +extern const Word16 deem_tab_fx[]; // Q15 extern const Word16 filt_hp_fx[]; // Q15 -extern const float exp_tab_p[]; /* HF BWE - Table of values exp(-j*w*i) */ extern const Word16 exp_tab_p_fx[]; // Q14 -extern const float exp_tab_q[]; /* HF BWE - Table of values exp(-j*w*i) */ extern const Word16 exp_tab_q_fx[]; // Q14 -extern const float HP_gain[]; /* HF BWE - quantization table for 23.85 */ extern const Word16 HP_gain_fx[]; // Q15 -extern const float fir_6k_8k[]; /* HF BWE - band-pass filter coefficients */ extern const float b_hp400[]; /* HF (6-7kHz) BWE - 400Hz HP filter coefficients */ extern const float a_hp400[]; /* HF (6-7kHz) BWE - 400Hz HP filter coefficients */ @@ -402,14 +416,16 @@ extern const Word16 low_H[64]; // Q14 extern const Word16 low_H16k[80]; // Q14 extern const Word16 mid_H[64]; // Q14 extern const Word16 mid_H16k[80]; // Q14 - extern const float filt_lp[1 + L_FILT]; -extern const Word16 filt_lp_fx[1 + L_FILT]; // Q15 + extern const float filt_lp_16kHz[1 + L_FILT16k]; +extern const Word16 filt_lp_fx[1 + L_FILT]; // Q15 extern const Word16 filt_lp_16kHz_fx[1 + L_FILT16k]; // Q15 +#ifndef IVAS_FLOAT_FIXED extern const float tab_hup_l[SIZ_TAB_HUP_L]; /* NB post-filter */ extern const float tab_hup_s[SIZ_TAB_HUP_S]; /* NB post-filter */ +#endif extern const float edct_table_80[]; /* EDCT */ extern const float edct_table_120[]; /* EDCT */ @@ -445,31 +461,34 @@ extern const Word16 edct_table_160_16fx[160]; // Q15 extern const Word16 edct_table_128_16fx[128]; // Q15 extern const Word16 edct_table_320_16fx[320]; // Q16 - -extern const int16_t crit_bins[]; /* (used only in AMR-WB IO mode) */ +#ifndef IVAS_FLOAT_FIXED extern const float crit_bins_corr[CRIT_NOIS_BAND]; -extern const Word16 crit_bins_corr_fx[]; // Q15 -extern const float crit_bands_loc[]; /* (used only in AMR-WB IO mode) */ -extern const Word16 crit_bands_loc_fx[]; // Q0 -extern const float mfreq_loc_LD[]; /* LD music post-filter */ -extern const Word16 mfreq_loc_LD_fx[]; // Q0 -extern const Word16 mfreq_bindiv_LD[]; // Q0 -extern const float post_dct_wind[OFFSET2]; -extern const Word16 post_dct_wind_fx[]; // Q15 +extern const float crit_bands_loc[]; /* (used only in AMR-WB IO mode) */ extern const float MAX_SNR_SNR1_tab[]; extern const float INV_MAX_SNR_tab[]; -extern const Word16 MAX_SNR_SNR1_tab_FX[MBANDS_GN_LD]; // Q14 -extern const Word16 INV_MAX_SNR_tab_FX[MBANDS_GN_LD]; // Q15 extern const float sc_qnoise[]; -extern const Word16 sc_qnoise_fx[]; // Q15 -extern const Word16 inv_mfreq_bindiv_LD_fx[]; // Q15 -extern const Word16 inv_mfreq_bindiv_LD_M1_fx[]; // Q15 -extern const float W_DTX_HO[HO_HIST_SIZE]; -extern const Word16 W_DTX_HO_FX[HO_HIST_SIZE]; // Q15 extern const float ENR_ATT[5]; -extern const Word16 ENR_ATT_fx[5]; // Q8 +extern const float W_DTX_HO[HO_HIST_SIZE]; +#endif +extern const float mfreq_loc_LD[]; /* LD music post-filter */ +extern const float post_dct_wind[OFFSET2]; +extern const int16_t crit_bins[]; /* (used only in AMR-WB IO mode) */ +extern const Word16 crit_bins_corr_fx[]; // Q15 +extern const Word16 crit_bands_loc_fx[]; // Q0 +extern const Word16 mfreq_loc_LD_fx[]; // Q0 +extern const Word16 mfreq_bindiv_LD[]; // Q0 +extern const Word16 post_dct_wind_fx[]; // Q15 +extern const Word16 MAX_SNR_SNR1_tab_FX[MBANDS_GN_LD]; // Q14 +extern const Word16 INV_MAX_SNR_tab_FX[MBANDS_GN_LD]; // Q15 +extern const Word16 sc_qnoise_fx[]; // Q15 +extern const Word16 inv_mfreq_bindiv_LD_fx[]; // Q15 +extern const Word16 inv_mfreq_bindiv_LD_M1_fx[]; // Q15 +extern const Word16 W_DTX_HO_FX[HO_HIST_SIZE]; // Q15 +extern const Word16 ENR_ATT_fx[5]; // Q8 +#ifndef IVAS_FLOAT_FIXED extern const float HO_ATT[5]; +#endif extern const Word16 HO_ATT_FX[5]; // Q15 extern const Word16 hq_swb_bwe_nb_bits[]; // Q0 @@ -477,27 +496,24 @@ extern const Word16 hq_swb_bwe_nb_bits[]; // Q0 /*----------------------------------------------------------------------------------* * ISF quantization (AMR-WB IO mode) *----------------------------------------------------------------------------------*/ -extern const Word16 Indirect_dico1[SIZE_BK1]; // Q0 +extern const float mean_isf_amr_wb[M]; /* Mean ISF vector (only in AMR-WB IO mode) */ +extern const float mean_isf_noise_amr_wb[]; /* Mean ISF vector for SID frame (only in AMR-WB IO mode) */ +extern const float gaus_dico[]; /* Gaussian codebook */ +extern const float gaus_dico_swb[]; /* Gaussian codebook for SWB TBE */ +extern const float dico1_isf[]; /* ISF codebook - common 1st stage, 1st split (only in AMR-WB IO mode) */ +extern const float dico2_isf[]; /* ISF codebook - common 1st stage, 2nd split (only in AMR-WB IO mode) */ -extern const float mean_isf_amr_wb[M]; /* Mean ISF vector (only in AMR-WB IO mode) */ +extern const Word16 Indirect_dico1[SIZE_BK1]; // Q0 extern const Word16 mean_isf_amr_wb_fx[M]; /*Qlog2(2.56)*/ /* Mean ISF vector (only in AMR-WB IO mode) */ -extern const float mean_isf_noise_amr_wb[]; /* Mean ISF vector for SID frame (only in AMR-WB IO mode) */ - extern const Word16 mean_isf_noise_amr_wb_fx[]; /*Qlog2(2.56)*/ /* Mean ISF vector for SID frame (only in AMR-WB IO mode) */ -extern const float gaus_dico[]; /* Gaussian codebook */ extern const Word16 gaus_dico_fx[]; // Q12 -extern const float gaus_dico_swb[]; /* Gaussian codebook for SWB TBE */ extern const Word16 gaus_dico_swb_fx[]; // Q15 -extern const float dico1_isf[]; /* ISF codebook - common 1st stage, 1st split (only in AMR-WB IO mode) */ - extern const Word16 dico1_isf_fx[]; /* ISF codebook - common 1st stage, 1st split (only in AMR-WB IO mode) Qlog2(2.56)*/ -extern const float dico2_isf[]; /* ISF codebook - common 1st stage, 2nd split (only in AMR-WB IO mode) */ - extern const Word16 dico2_isf_fx[]; /* ISF codebook - common 1st stage, 2nd split (only in AMR-WB IO mode) Qlog2(2.56)*/ extern const float dico21_isf_46b[]; /* ISF codebook - 46b, 2nd stage, 1st split (only in AMR-WB IO mode) */ @@ -513,15 +529,13 @@ extern const Word16 dico24_isf_46b_fx[]; /* ISF codebook - 46b, 2nd stage, 4th s extern const Word16 dico25_isf_46b_fx[]; /* ISF codebook - 46b, 2nd stage, 5th split (only in AMR-WB IO mode) Qlog2(2.56)*/ extern const float dico21_isf_36b[]; /* ISF codebook - 36b, 2nd stage, 1st split (only in AMR-WB IO mode) */ +extern const float dico22_isf_36b[]; /* ISF codebook - 36b, 2nd stage, 2nd split (only in AMR-WB IO mode) */ +extern const float dico23_isf_36b[]; /* ISF codebook - 36b, 2nd stage, 3rd split (only in AMR-WB IO mode) */ extern const Word16 dico21_isf_36b_fx[]; /* ISF codebook - 36b, 2nd stage, 1st split (only in AMR-WB IO mode) Qlog2(2.56)*/ -extern const float dico22_isf_36b[]; /* ISF codebook - 36b, 2nd stage, 2nd split (only in AMR-WB IO mode) */ - extern const Word16 dico22_isf_36b_fx[]; /* ISF codebook - 36b, 2nd stage, 2nd split (only in AMR-WB IO mode) Qlog2(2.56)*/ -extern const float dico23_isf_36b[]; /* ISF codebook - 36b, 2nd stage, 3rd split (only in AMR-WB IO mode) */ - extern const Word16 dico23_isf_36b_fx[]; /* ISF codebook - 36b, 2nd stage, 3rd split (only in AMR-WB IO mode) Qlog2(2.56)*/ extern const float dico1_ns_28b[]; /* ISF codebook for SID frames - 28b, 1st split */ @@ -546,24 +560,28 @@ extern const float dico5_cng_ev[]; * LSF quantization - MSVQ tables *----------------------------------------------------------------------------------*/ -extern const float stable_ISP[]; -extern const float stable_LSP[]; extern const float stable_ISF[]; +extern const float stable_LSP[]; +#ifndef IVAS_FLOAT_FIXED +extern const float stable_ISP[]; +#endif extern const Word16 stable_ISP_fx[]; /*Q15*/ extern const Word16 stable_ISF_fx[]; /*15Q16*/ extern const Word16 stable_LSP_fx[]; /*Q15*/ +#ifndef IVAS_FLOAT_FIXED extern const float UVWB_Ave[]; extern const float UVNB_Ave[]; extern const float SVWB_Ave[]; extern const float SVNB_Ave[]; extern const float IAWB_Ave[]; extern const float IANB_Ave[]; +extern const float TRWB_Ave[]; +extern const float TRWB2_Ave[]; +#endif extern const float GENB_Ave[]; extern const float GEWB_Ave[]; extern const float GEWB2_Ave[]; -extern const float TRWB_Ave[]; -extern const float TRWB2_Ave[]; extern const Word16 UVWB_Ave_fx[]; // Qlog2(2.56) extern const Word16 UVNB_Ave_fx[]; // Qlog2(2.56) extern const Word16 SVWB_Ave_fx[]; // Qlog2(2.56) @@ -585,6 +603,7 @@ extern const Word16 means_swb_cleanspeech_lsf25k6[]; // Qlog2(2.56) extern const Word16 means_swb_cleanspeech_lsf32k0[]; // Qlog2(2.56) extern const float ModeMean12[]; +#ifndef IVAS_FLOAT_FIXED extern const float Predictor0[]; extern const float Predictor1[]; extern const float Predictor2[]; @@ -594,6 +613,7 @@ extern const float Predictor5[]; extern const float Predictor6[]; extern const float Predictor7[]; extern const float Predictor8[]; +#endif extern const Word16 Predictor0_fx[]; // Q15 extern const Word16 Predictor1_fx[]; // Q15 extern const Word16 Predictor2_fx[]; // Q15 @@ -608,8 +628,10 @@ extern const float CNG_SN1[]; extern const Word16 CNG_SN1_fx[]; // Qlog2(2.56) extern const Word16 CB_lsf[]; // Q0 extern const Word16 CB_p_lsf[]; // Q0 +#ifndef IVAS_FLOAT_FIXED extern const float *const ModeMeans[]; extern const float *const Predictors[]; +#endif extern const Word16 *const ModeMeans_fx[]; // Qlog2(2.56) extern const Word16 *const Predictors_fx[]; // Q15 extern const Word16 CBsizes[]; // Q0 @@ -628,31 +650,31 @@ extern const Word16 no_vals_ind[NO_LEADERS][MAX_NO_VALS]; // Q0 extern const Word16 C_VQ[LATTICE_DIM + 1][LATTICE_DIM + 1]; // Q0 // extern const Word16 C_VQ_fx[LATTICE_DIM + 1][LATTICE_DIM + 1]; -extern const Word16 BitsVQ[]; // Q0 -extern const Word16 BitsVQ_p[]; // Q0 -extern const UWord8 no_lead_idx[][2]; // Q0 -extern const UWord8 no_lead_p_idx[][2]; // Q0 -extern const Word8 leaders_short[][MAX_NO_SCALES]; // Q0 extern const float sigma_MSLVQ[][16]; -extern const Word16 sigma_MSLVQ_fx[][16]; // Qlog2(2.56) extern const float sigma_p[][16]; -extern const Word16 sigma_p_fx[][16]; // Qlog2(2.56) -extern const Word16 sigma_p_ivas_fx[][16]; // Qlog2(2.56) extern const float inv_sigma_MSLVQ[][16]; -extern const Word16 inv_sigma_MSLVQ_fx[][16]; // Q15 extern const float inv_sigma_p[][16]; -extern const Word16 inv_sigma_p_fx[][16]; // Q15 -extern const Word16 inv_sigma_p_ivas_fx[][16]; // Qlog2(2.56) extern const float scales[][MAX_NO_SCALES * 2]; extern const float scales_p[][MAX_NO_SCALES * 2]; +extern const float pl_HQ[]; +extern const Word16 BitsVQ[]; // Q0 +extern const Word16 BitsVQ_p[]; // Q0 +extern const UWord8 no_lead_idx[][2]; // Q0 +extern const UWord8 no_lead_p_idx[][2]; // Q0 +extern const Word8 leaders_short[][MAX_NO_SCALES]; // Q0 +extern const Word16 sigma_MSLVQ_fx[][16]; // Qlog2(2.56) +extern const Word16 sigma_p_fx[][16]; // Qlog2(2.56) +extern const Word16 sigma_p_ivas_fx[][16]; // Qlog2(2.56) +extern const Word16 inv_sigma_MSLVQ_fx[][16]; // Q15 +extern const Word16 inv_sigma_p_fx[][16]; // Q15 +extern const Word16 inv_sigma_p_ivas_fx[][16]; // Qlog2(2.56) extern const Word16 scales_fx[][MAX_NO_SCALES * 2]; // Q11 extern const Word16 scales_ivas_fx[][MAX_NO_SCALES * 2]; // Q11 extern const Word16 scales_p_ivas_fx[][MAX_NO_SCALES * 2]; // Q11 extern const Word16 scales_p_fx[][MAX_NO_SCALES * 2]; // Q11 -extern const int16_t predmode_tab_float[][6]; +extern const Word16 predmode_tab_float[][6]; extern const Word16 predmode_tab[][6]; // Q0 -extern const float pl_HQ[]; -extern const Word16 pl_HQ_fx[]; // Q1 +extern const Word16 pl_HQ_fx[]; // Q1 extern const Word16 pi0[]; // Q0 // extern const Word16 pi0_fx[]; @@ -674,22 +696,22 @@ extern const Word16 cng_sort[]; // Q0 extern const Word16 perm_MSLVQ[][4]; // Q0 // extern const Word16 perm_MSLVQ_fx[][4]; -extern const int16_t min_lat_bits_SN[]; +extern const Word16 min_lat_bits_SN[]; extern const Word16 min_lat_bits_SN_fx[]; // Q0 -extern const int16_t min_lat_bits_pred[]; +extern const Word16 min_lat_bits_pred[]; extern const Word16 min_lat_bits_pred_fx[]; // Q0 -extern const int16_t offset_in_lvq_mode_SN[][21]; +extern const Word16 offset_in_lvq_mode_SN[][21]; extern const Word16 offset_in_lvq_mode_SN_fx[][21]; // Q0 -extern const int16_t offset_in_lvq_mode_pred[][32]; +extern const Word16 offset_in_lvq_mode_pred[][32]; extern const Word16 offset_in_lvq_mode_pred_fx[][32]; // Q0 -extern const int16_t offset_lvq_modes_SN[]; +extern const Word16 offset_lvq_modes_SN[]; extern const Word16 offset_lvq_modes_SN_fx[]; // Q0 -extern const int16_t offset_lvq_modes_pred[]; +extern const Word16 offset_lvq_modes_pred[]; extern const Word16 offset_lvq_modes_pred_fx[]; // Qlog2(1.6) /*-----------------------------------------------------------------* @@ -703,37 +725,49 @@ extern const Word16 BC_TCVQ_BIT_ALLOC_40B[]; // Q0 extern const Word16 NTRANS[4][16]; // Q0 extern const Word16 NTRANS2[4][16]; // Q0 +#ifndef IVAS_FLOAT_FIXED extern const float AR_IntraCoeff[N_STAGE_VQ - 1][2][2]; extern const float SN_IntraCoeff[N_STAGE_VQ - 1][2][2]; +#endif extern const Word16 AR_IntraCoeff_fx[N_STAGE_VQ - 1][2][2]; /* Q15 */ extern const Word16 SN_IntraCoeff_fx[N_STAGE_VQ - 1][2][2]; // Q15 +#ifndef IVAS_FLOAT_FIXED extern const float scale_ARSN[]; -extern const Word16 scale_ARSN_fx[]; /* Q14 */ extern const float scale_inv_ARSN[]; +#endif +extern const Word16 scale_ARSN_fx[]; /* Q14 */ extern const Word16 scale_inv_ARSN_fx[]; // Q15 +#ifndef IVAS_FLOAT_FIXED extern const float AR_TCVQ_CB_SUB1[2][128][2]; extern const float AR_TCVQ_CB_SUB2[2][64][2]; extern const float AR_TCVQ_CB_SUB3[4][32][2]; +#endif extern const Word16 AR_TCVQ_CB_SUB1_fx[2][128][2]; // Qlog2(2.56) extern const Word16 AR_TCVQ_CB_SUB2_fx[2][64][2]; // Qlog2(2.56) extern const Word16 AR_TCVQ_CB_SUB3_fx[4][32][2]; // Qlog2(2.56) + +#ifndef IVAS_FLOAT_FIXED extern const float SN_TCVQ_CB_SUB1[2][128][2]; extern const float SN_TCVQ_CB_SUB2[2][64][2]; extern const float SN_TCVQ_CB_SUB3[4][32][2]; +#endif extern const Word16 SN_TCVQ_CB_SUB1_fx[2][128][2]; // Qlog2(2.56) extern const Word16 SN_TCVQ_CB_SUB2_fx[2][64][2]; // Qlog2(2.56) extern const Word16 SN_TCVQ_CB_SUB3_fx[4][32][2]; // Qlog2(2.56) + +#ifndef IVAS_FLOAT_FIXED extern const float AR_SVQ_CB1[32][8]; extern const float AR_SVQ_CB2[16][8]; +#endif extern const Word16 AR_SVQ_CB1_fx[32][8]; // Qlog2(2.56) extern const Word16 AR_SVQ_CB2_fx[16][8]; // Qlog2(2.56) -extern const int16_t uniform_model[]; +extern const Word16 uniform_model[]; /*-----------------------------------------------------------------* * LSF quantization - mid-frame quantization tables @@ -858,7 +892,9 @@ extern const Word16 Da_nq[]; /* Codebook number for each absolute leader */ extern const Word16 skip_bands_SWB_TBE[]; /* bands for SWB TBE quantisation Q0*/ extern const Word16 skip_bands_WB_TBE[]; /* bands for WB TBE quantisation Q0*/ +#ifndef IVAS_FLOAT_FIXED extern const float interpol_frac_shb_flt[]; +#endif extern const Word16 interpol_frac_shb[NB_SUBFR * 2]; // Q15 extern const float AP1_STEEP[]; /* All pass filter coeffs for interpolation and decimation by a factor of 2 */ @@ -868,97 +904,118 @@ extern const Word16 AP2_STEEP_FX[]; // Q15 /* All pass filter coeffs for interpo extern const float STEPS[]; /* Granuality in conversion from lpc to lsp */ +#ifndef IVAS_FLOAT_FIXED extern const float cos_fb_exc[]; -extern const Word16 cos_fb_exc_fx[32]; // Q15 +#endif extern const float recip_order[]; +extern const Word16 cos_fb_exc_fx[32]; // Q15 -extern const float win_lpc_shb[]; /* Window for calculating SHB LPC coeffs */ -extern const Word16 win_lpc_shb_fx[]; // Q15 /* Window for calculating SHB LPC coeffs */ -extern const float win_lpc_hb_wb[]; -extern const Word16 win_lpc_hb_wb_fx[]; // Q15 -extern const float ola_win_shb_switch_fold[]; +extern const Word16 win_lpc_shb_fx[]; // Q15 /* Window for calculating SHB LPC coeffs */ +extern const Word16 win_lpc_hb_wb_fx[]; // Q15 extern const Word16 ola_win_shb_switch_fold_fx[]; // Q15 -extern const float win_flatten[]; /* Window for calculating whitening filter for SHB excitation */ extern const Word16 win_flatten_fx[]; // Q15 -extern const float win_flatten_4k[]; /* Window for calculating whitening filter for WB excitation */ extern const Word16 win_flatten_4k_fx[]; // Q15 -extern const float window_shb[]; /* Overlap add window for SHB excitation used in anal and synth */ -extern const Word16 window_shb_fx[]; // Q15 -extern const float window_shb_32k[]; /* Upsampled overlap add window for SHB excitation used transition generation */ -extern const Word16 window_shb_32k_fx[]; // Q15 -extern const float subwin_shb[]; /* Short overlap add window for SHB excitation used in anal and synth */ -extern const Word16 subwin_shb_fx[]; // Q15 /* Short overlap add window for SHB excitation used in anal and synth */ +extern const float win_flatten_4k[]; /* Window for calculating whitening filter for WB excitation */ +#ifndef IVAS_FLOAT_FIXED +extern const float win_lpc_shb[]; /* Window for calculating SHB LPC coeffs */ +extern const float win_lpc_hb_wb[]; +extern const float ola_win_shb_switch_fold[]; +extern const float win_flatten[]; /* Window for calculating whitening filter for SHB excitation */ +extern const float window_shb[]; /* Overlap add window for SHB excitation used in anal and synth */ +extern const float window_shb_32k[]; /* Upsampled overlap add window for SHB excitation used transition generation */ +extern const float subwin_shb[]; /* Short overlap add window for SHB excitation used in anal and synth */ extern const float window_wb[]; -extern const float subwin_wb[]; /* Short overlap add window for SHB excitation used in anal and synth */ -extern const Word16 window_wb_fx[]; // Q15 -extern const Word16 subwin_wb_fx[]; // Q15 +extern const float subwin_wb[]; /* Short overlap add window for SHB excitation used in anal and synth */ +#endif +extern const Word16 window_shb_fx[]; // Q15 +extern const Word16 window_shb_32k_fx[]; // Q15 +extern const Word16 subwin_shb_fx[]; // Q15 /* Short overlap add window for SHB excitation used in anal and synth */ +extern const Word16 window_wb_fx[]; // Q15 +extern const Word16 subwin_wb_fx[]; // Q15 +#ifndef IVAS_FLOAT_FIXED extern const float Hilbert_coeffs[4 * NUM_HILBERTS][HILBERT_ORDER1 + 1]; +#endif extern const Word16 Hilbert_coeffs_fx[4 * NUM_HILBERTS][HILBERT_ORDER1 + 1]; // Q14 extern const float wac[]; +#ifndef IVAS_FLOAT_FIXED extern const float wac_swb[]; +#endif extern const Word16 wac_swb_h[]; // Q15 extern const Word16 wac_swb_l[]; // Q15 +#ifndef IVAS_FLOAT_FIXED extern const float wb_bwe_lsfvq_cbook_8bit[]; -extern const Word16 wb_bwe_lsfvq_cbook_8bit_fx[]; // Q15 extern const float lbr_wb_bwe_lsfvq_cbook_2bit[]; -extern const Word16 lbr_wb_bwe_lsfvq_cbook_2bit_fx[]; // Q15 extern const float swb_tbe_lsfvq_cbook_8b_flt[]; -extern const Word16 swb_tbe_lsfvq_cbook_8b[]; // Q15 -extern const float SHBCB_SubGain5bit[]; /* 5 bit Quantizer table for SHB gain shapes */ -extern const Word16 SHBCB_SubGain5bit_fx[]; // Q14 -extern const float HBCB_SubGain5bit[]; /* 5-bit TD WB BWE temporal shaping codebook */ -extern const Word16 HBCB_SubGain5bit_fx[]; // Q8 -extern const float SHBCB_FrameGain64[]; /* 6 bit Quantizer table for SHB overall gain */ -extern const Word32 SHBCB_FrameGain64_fx[]; // Q18 +extern const float SHBCB_SubGain5bit[]; /* 5 bit Quantizer table for SHB gain shapes */ +extern const float HBCB_SubGain5bit[]; /* 5-bit TD WB BWE temporal shaping codebook */ +extern const float SHBCB_FrameGain64[]; /* 6 bit Quantizer table for SHB overall gain */ extern const float SHBCB_FrameGain16[]; -extern const Word32 SHBCB_FrameGain16_fx[]; /*Q18*/ +#endif +extern const Word16 wb_bwe_lsfvq_cbook_8bit_fx[]; // Q15 +extern const Word16 lbr_wb_bwe_lsfvq_cbook_2bit_fx[]; // Q15 +extern const Word16 swb_tbe_lsfvq_cbook_8b[]; // Q15 +extern const Word16 SHBCB_SubGain5bit_fx[]; // Q14 +extern const Word16 HBCB_SubGain5bit_fx[]; // Q8 +extern const Word32 SHBCB_FrameGain64_fx[]; // Q18 +extern const Word32 SHBCB_FrameGain16_fx[]; /*Q18*/ +#ifndef IVAS_FLOAT_FIXED extern const float full_band_bpf_1[][5]; extern const float full_band_bpf_2[][5]; extern const float full_band_bpf_3[][5]; +#endif extern const Word16 full_band_bpf_1_fx[][5]; /*Q13*/ extern const Word16 full_band_bpf_2_fx[][5]; /*Q13*/ extern const Word16 full_band_bpf_3_fx[][5]; /*Q13*/ -extern const float lsf_q_cb_4b[]; /* 4 bit differential scalar quantizer table for TD SWB BWE LSFs 1 and 2*/ -extern const float lsf_q_cb_3b[]; /* 3 bit differential scalar quantizer table for TD SWB BWE LSFs 3, 4 and 5*/ -extern const float *const lsf_q_cb[]; /* Codebook array for each LSF */ -extern const Word16 *const lsf_q_cb_fx[]; // Q15 -extern const Word16 lsf_q_cb_size[]; /* Size of each element of the above Q0*/ -extern const Word16 lsf_q_num_bits[]; /* Size of each element of the above, in bits Q0*/ -extern const float mirror_point_q_cb[]; /* LSF mirroring point codebook */ -extern const Word16 mirror_point_q_cb_fx[]; // Q15 -extern const float lsf_grid[4][5]; /* LSF mirroring adjustment grid */ -extern const Word16 lsf_grid_fx[4][5]; // Q15 -extern const float grid_smoothing[]; /* LSF mirroring smoothing table */ -extern const Word16 grid_smoothing_fx[]; /* LSF mirroring smoothing table Q15*/ - -extern const float overlap_coefs[]; /* HR SWB BWE - overlap coefficients */ -extern const float overlap_coefs_48kHz[]; /* HR SWB BWE - overlap coefficients @48kHz */ +#ifndef IVAS_FLOAT_FIXED +extern const float lsf_q_cb_4b[]; /* 4 bit differential scalar quantizer table for TD SWB BWE LSFs 1 and 2*/ +extern const float lsf_q_cb_3b[]; /* 3 bit differential scalar quantizer table for TD SWB BWE LSFs 3, 4 and 5*/ +extern const float *const lsf_q_cb[]; /* Codebook array for each LSF */ +#endif +extern const Word16 *const lsf_q_cb_fx[]; // Q15 +extern const Word16 lsf_q_cb_size[]; /* Size of each element of the above Q0*/ +extern const Word16 lsf_q_num_bits[]; /* Size of each element of the above, in bits Q0*/ +extern const Word16 mirror_point_q_cb_fx[]; // Q15 +#ifndef IVAS_FLOAT_FIXED +extern const float mirror_point_q_cb[]; /* LSF mirroring point codebook */ +extern const float lsf_grid[4][5]; /* LSF mirroring adjustment grid */ +extern const float grid_smoothing[]; /* LSF mirroring smoothing table */ +#endif +extern const Word16 lsf_grid_fx[4][5]; // Q15 +extern const Word16 grid_smoothing_fx[]; /* LSF mirroring smoothing table Q15*/ + +#ifndef IVAS_FLOAT_FIXED +extern const float overlap_coefs[]; /* HR SWB BWE - overlap coefficients */ +extern const float overlap_coefs_48kHz[]; /* HR SWB BWE - overlap coefficients @48kHz */ +#endif extern const Word16 overlap_coefs_fx[NSV_OVERLAP * WIDTH_BAND]; /* in Q15 */ extern const Word16 overlap_coefs_48kHz_fx[NSV_OVERLAP * WIDTH_BAND]; /* in Q15 */ -extern const float swb_hr_env_code1[]; /* HR SWB BWE - envelope Q table - first two subabnds in non-transient frames */ -extern const float swb_hr_env_code2[]; /* HR SWB BWE - envelope Q table - second two subabnds in non-transient frames*/ -extern const float swb_hr_env_code3[]; /* HR SWB BWE - envelope Q table - two subabnds in transient frames */ +#ifndef IVAS_FLOAT_FIXED +extern const float swb_hr_env_code1[]; /* HR SWB BWE - envelope Q table - first two subabnds in non-transient frames */ +extern const float swb_hr_env_code2[]; /* HR SWB BWE - envelope Q table - second two subabnds in non-transient frames*/ +extern const float swb_hr_env_code3[]; /* HR SWB BWE - envelope Q table - two subabnds in transient frames */ +#endif extern const Word16 swb_hr_env_code1_fx[]; /* HR SWB BWE - envelope Q table - first two subabnds in non-transient frames Q9*/ extern const Word16 swb_hr_env_code2_fx[]; /* HR SWB BWE - envelope Q table - second two subabnds in non-transient frames Q9*/ extern const Word16 swb_hr_env_code3_fx[]; /* HR SWB BWE - envelope Q table - two subands in transient frames Q9*/ extern const float allpass_poles_3_ov_2_flt[]; -extern const Word16 allpass_poles_3_ov_2[]; /*Q15*/ extern const float decimate_3_ov_2_lowpass_num[]; -extern const Word16 decimate_3_ov_2_lowpass_num_fx[]; /*Q15*/ extern const float decimate_3_ov_2_lowpass_den[]; +extern const Word16 allpass_poles_3_ov_2[]; /*Q15*/ +extern const Word16 decimate_3_ov_2_lowpass_num_fx[]; /*Q15*/ extern const Word16 decimate_3_ov_2_lowpass_den_fx[]; /*Q15*/ /*------------------------------------------------------------------------------* * WB BWE tables *------------------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED extern const float F_2_5[64]; +#endif extern const Word16 F_2_5_fx[64]; /*Q10*/ /*------------------------------------------------------------------------------* * SWB BWE tables @@ -971,45 +1028,51 @@ extern const Word16 sqrt_swb_bwe_trans_subband_width_fx[]; // Q11 extern const Word16 sqrt_swb_bwe_subband_fx_L1[]; // Q12 extern const Word16 sqrt_swb_bwe_subband_fx_L2[]; // Q12 -extern const Word16 swb_bwe_subband[]; // Q0 -extern const Word16 fb_bwe_subband[]; // Q0 -extern const Word16 fb_bwe_sm_subband[]; // Q0 +extern const float smooth_factor[]; +extern const float fb_smooth_factor[]; +#ifndef IVAS_FLOAT_FIXED extern const float swb_inv_bwe_subband_width[]; +extern const float fb_inv_bwe_subband_width[]; +#endif +extern const Word16 swb_bwe_subband[]; // Q0 +extern const Word16 fb_bwe_subband[]; // Q0 +extern const Word16 fb_bwe_sm_subband[]; // Q0 extern const Word16 swb_inv_bwe_subband_width_fx[]; // Q15 extern const Word16 swb_bwe_sm_subband[]; // Q0 -extern const float smooth_factor[]; -extern const Word16 smooth_factor_fx[]; // Q15 -extern const Word16 fb_bwe_subband_float[]; // Q0 -extern const float fb_inv_bwe_subband_width[]; -extern const Word16 fb_inv_bwe_subband_width_fx[]; // Q15 -extern const Word16 fb_bwe_sm_subband_float[]; // Q0 -extern const float fb_smooth_factor[]; -extern const Word16 fb_smooth_factor_fx[]; // Q15 +extern const Word16 smooth_factor_fx[]; // Q15 +extern const Word16 fb_bwe_subband_float[]; // Q0 +extern const Word16 fb_inv_bwe_subband_width_fx[]; // Q15 +extern const Word16 fb_bwe_sm_subband_float[]; // Q0 +extern const Word16 fb_smooth_factor_fx[]; // Q15 +#ifndef IVAS_FLOAT_FIXED extern const float EnvCdbk11[]; extern const float EnvCdbk1st[]; extern const float EnvCdbk2nd[]; extern const float EnvCdbk3rd[]; extern const float EnvCdbk4th[]; +#endif extern const Word16 EnvCdbk11_fx[]; /*Q8 */ extern const Word16 EnvCdbk1st_fx[]; /*Q8 */ extern const Word16 EnvCdbk2nd_fx[]; /*Q8 */ extern const Word16 EnvCdbk3rd_fx[]; /*Q8 */ extern const Word16 EnvCdbk4th_fx[]; /*Q8 */ +#ifndef IVAS_FLOAT_FIXED extern const float EnvCdbkFB[]; -extern const Word16 EnvCdbkFB_fx[]; /*Q7 */ extern const float Env_TR_Cdbk1[]; extern const float Env_TR_Cdbk2[]; -extern const Word16 Env_TR_Cdbk1_fx[]; /*Q8 */ -extern const Word16 Env_TR_Cdbk2_fx[]; /*Q8 */ extern const float w_NOR[]; -extern const Word16 w_NOR_fx[]; // Q15 extern const float Mean_env[]; -extern const Word16 Mean_env_fx[]; // Q8 extern const float Mean_env_fb[]; -extern const Word16 Mean_env_fb_fx[]; /*Q8 */ extern const float Mean_env_tr[]; -extern const Word16 Mean_env_tr_fx[]; /*Q8 */ +#endif +extern const Word16 EnvCdbkFB_fx[]; /*Q7 */ +extern const Word16 Env_TR_Cdbk1_fx[]; /*Q8 */ +extern const Word16 Env_TR_Cdbk2_fx[]; /*Q8 */ +extern const Word16 w_NOR_fx[]; // Q15 +extern const Word16 Mean_env_fx[]; // Q8 +extern const Word16 Mean_env_fb_fx[]; /*Q8 */ +extern const Word16 Mean_env_tr_fx[]; /*Q8 */ /*------------------------------------------------------------------------------* * ACEPL/HQ core switching tables *------------------------------------------------------------------------------*/ @@ -1085,7 +1148,6 @@ extern const Word16 intl_cnt_48[N_INTL_GRP_48]; // Q0 extern const Word16 norm_order_48[NB_SFM]; // Q0 extern const Word16 norm_order_32[SFM_N_SWB]; // Q0 extern const Word16 norm_order_16[SFM_N_WB]; // Q0 - extern const float dicn_pg[45]; extern const Word32 dicn_pg_fx[]; /*Q12 */ extern const Word16 expPkEnrg_tbl[45]; // Q0 @@ -1093,11 +1155,9 @@ extern const Word32 manPkEnrg_tbl[45]; // Q0 extern const Word32 E_max5_tbl[40]; // Q0 extern const float thren_pg[44]; -#ifdef IVAS_FLOAT_FIXED extern const Word32 thren_pg_fx[44]; -#endif -extern const float dicn[40]; extern const Word32 dicn_fx[40]; /*Q14 */ +extern const float dicn[40]; extern const float dicn_inv[40]; extern const float thren_HQ[39]; #ifdef IVAS_FLOAT_FIXED @@ -1275,26 +1335,27 @@ extern const UWord32 intLimCDivInvDQ31[68]; // Q0 extern const UWord8 obtainEnergyQuantizerDensity_f[57]; // Q0 extern const Word16 lim_neg_inv_tbl_fx[11]; // Q0 extern const Word16 fg_inv_tbl_fx[13]; // Q0 -extern const Word16 Idx2Freq_Tbl[]; /* functions and tables for pvq_indexing */ extern const UWord32 exactdivodd[ODD_DIV_SIZE]; // Q0 extern const float gain_att[]; -extern const Word16 gain_att_fx[40]; // Q15 +extern const float stab_trans[]; +extern const float env_stab_tp[2][2]; extern const float att_step[]; -extern const Word16 att_step_fx[4]; // Q13 extern const float gain_qlow[]; +extern const Word16 gain_att_fx[40]; // Q15 +extern const Word16 att_step_fx[4]; // Q13 extern const int16_t gain_cb_size[]; -extern const float stab_trans[]; -extern const Word16 stab_trans_fx[]; // Q15 -extern const float env_stab_tp[2][2]; +extern const Word16 stab_trans_fx[]; // Q15 extern const Word16 env_stab_tp_fx[2][2]; // Q15 /*----------------------------------------------------------------------------------* * SWB BWE for LR MDCT core *----------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED extern const float gain_table_SWB_BWE[NB_SWB_SUBBANDS]; +#endif extern const Word16 gain_table_SWB_BWE_fx[NB_SWB_SUBBANDS]; /*Q14 */ /* HQ_NORMAL mode */ @@ -1431,8 +1492,9 @@ extern const Word16 hvq_cp_huff_tab[52]; // Q0 /*------------------------------------------------------------------------------* * GSC mode *------------------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED extern const float sin_table256[]; +#endif extern const Word16 sin_table256_fx[]; // Q15 extern const Word16 gsc_sfm_start[]; // Q0 extern const Word16 gsc_sfm_end[]; // Q0 @@ -1566,10 +1628,11 @@ extern const float FFT_RotVector_960[1860]; /*----------------------------------------------------------------------------------* * FEC for HQ core *----------------------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED extern const float Asr_LP32[41]; extern const float Asr_LP16[21]; extern const float Asr_LP48[61]; +#endif extern const Word16 Asr_LP32_fx[41]; // Q15 extern const Word16 Asr_LP16_fx[21]; // Q15 extern const Word16 Asr_LP48_fx[61]; // Q15 -- GitLab From b8d786b7bc75181e782c1f9b3141a42d44fcda18 Mon Sep 17 00:00:00 2001 From: malenov Date: Tue, 3 Dec 2024 16:51:44 +0100 Subject: [PATCH 14/21] remove FIX_1049_SHR_RO_COMPLEXITY and FIX_1052_COPY_CMPLX_DISCREPANCY --- lib_com/options.h | 2 -- lib_com/tools_fx.c | 20 -------------------- 2 files changed, 22 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a59d5293e..648395a65 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -78,8 +78,6 @@ #define NON_BE_FIX_807_MASA_DTX_BRSW /* Nokia: adds fix to check existence of DTX encoder for secondary channel in TD mode */ #define FIX_BASOP_812_NAN_COHSNR /* FhG: BASOP issue 812: fix nan values in sparse frames for cohSNR value in ITD estimation*/ #define FIX_828_PORT_1152_FROM_FLT_REPO /* FhG: fix for issue 828 - fix uninitialized value used in BASOP */ -#define FIX_1049_SHR_RO_COMPLEXITY /* VA: fix for issue 1049: incorrect counting of complexity in the shr_ro() function */ -#define FIX_1052_COPY_CMPLX_DISCREPANCY /* fix IF-ELSE discpreancy within the Copy() function depending on memory locations of x[] and y[] */ /* #################### End FIXES switches ############################ */ diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 6895083a8..3580e632e 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -488,12 +488,7 @@ void Copy( move16(); } } - -#ifdef FIX_1052_COPY_CMPLX_DISCREPANCY - IF( y >= x ) -#else ELSE -#endif { FOR( i = L - 1; i >= 0; i-- ) { @@ -522,12 +517,7 @@ void Copy64( move64(); } } - -#ifdef FIX_1052_COPY_CMPLX_DISCREPANCY - IF( y >= x ) -#else ELSE -#endif { FOR( i = L - 1; i >= 0; i-- ) { @@ -571,12 +561,7 @@ void Copy_pword( move16(); } } - -#ifdef FIX_1052_COPY_CMPLX_DISCREPANCY - IF( y >= x ) -#else ELSE -#endif { FOR( i = L - 1; i >= 0; i-- ) { @@ -607,12 +592,7 @@ void Copy32( move32(); } } - -#ifdef FIX_1052_COPY_CMPLX_DISCREPANCY - IF( y >= x ) -#else ELSE -#endif { FOR( i = L - 1; i >= 0; i-- ) { -- GitLab From 0f32cea1363f2026d907aa2881cf6fdc2cd6d47c Mon Sep 17 00:00:00 2001 From: malenov Date: Wed, 4 Dec 2024 12:24:49 +0100 Subject: [PATCH 15/21] fix includes --- lib_com/basop32.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib_com/basop32.c b/lib_com/basop32.c index 2a813e15c..edfe8e649 100644 --- a/lib_com/basop32.c +++ b/lib_com/basop32.c @@ -159,7 +159,9 @@ HISTORY: #include #include +#include "options.h" #include "stl.h" + #ifdef BASOP_NOGLOB #include #endif /* BASOP_NOGLOB */ @@ -170,10 +172,6 @@ HISTORY: #pragma warning( disable : 4310 ) #endif -#ifdef WMOPS -extern BASIC_OP multiCounter[MAXCOUNTERS]; -extern int currCounter; -#endif /*___________________________________________________________________________ | | -- GitLab From 52e86eeb61510b602999ba20a4f016938617e9d2 Mon Sep 17 00:00:00 2001 From: malenov Date: Wed, 4 Dec 2024 15:10:38 +0100 Subject: [PATCH 16/21] cleanup in options.h --- lib_com/options.h | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 92f198ea3..da082297c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -70,31 +70,6 @@ #define BASOP_NOGLOB_DECLARE_LOCAL #endif - -/* ################### Start BE switches ################################# */ -/* only BE switches wrt selection floating point code */ - -/*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ - -#define FIX_854_ARRAY_SIZE_MISMATCH /* VA: issue 854: correct the mismatch between definition and declaration of `ivas_core_dec() */ -#define FIX_785_REMOVE_DEAD_CODE /* VA: issue 785: remove dead code */ -#define FIX_852_FIX_HANDLE_DEREF /* VA: issue 852: Fix missing handle dereferencing of hIsmMetadaData in ivas_ism_metadata_close() */ -#define FIX_901_PARAMMC_DEAD_CODE /* FhG: issue 901: remove dead ParamMC code */ -#define IVAS_ENH32_CADENCE_CHANGES - -/* #################### End BE switches ################################## */ - - -/* #################### Start NON-BE switches ############################ */ -/* any switch which is non-be wrt selection floating point code */ -/* all switches in this category should start with "NONBE_" */ - -#define NONBE_FIX_838_CRASH_24_4_WB /* FhG: Issue 838: fix encoder crashes for Unified Stereo and MASA 2 TC at 24.4 kbps WB due to missing IGF (re-) allocation */ -#define NONBE_FIX_839_MC_RS_CHANNEL_ALLOC /* FhG: Issues #839: problems with reallocation of the channels on the heap in case of MC RS */ -#define BE_FIX_832_ASAN_ERROR_EFAP_OSBA /* FhG: issue #832: fix ASAN error caused by re-allocating EFAP memories in OSBA*/ -#define NONBE_FIX_819_DOUBLE_PREC_COMB_FORMATS /* VA: issue 820: Double precision arithmetic in combined formats */ -#define NONBE_FIX_849_OMASA_BFI_CRASH /* VA: issue 849: fix OMASA 2TC and FEC crashes */ -#define NONBE_FIX_738_QUATERNION_SLERP_PRECISION /* Quaternion slerp changes*/ #define IVAS_FLOAT_FIXED #define IVAS_FLOAT_FIXED_CONVERSIONS /* Temporary macro to keep track of intermediate flt to fixed and fixed to flt conversions */ #ifdef IVAS_FLOAT_FIXED @@ -113,3 +88,4 @@ #define FIX_QMETADATA_PENALTY /* Nokia: transform penalty calculation in qmetadata into integer operations */ #define FIX_1013_CRASH_HQ_CORE_DEC /* Ittiam: Saturation added on the lines of EVS */ #endif + -- GitLab From b0e4d88f7d07003bddbc14c8bb05477f559dfd04 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 5 Dec 2024 08:41:49 +0100 Subject: [PATCH 17/21] clang format --- lib_com/options.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index da082297c..1be359dfd 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -88,4 +88,3 @@ #define FIX_QMETADATA_PENALTY /* Nokia: transform penalty calculation in qmetadata into integer operations */ #define FIX_1013_CRASH_HQ_CORE_DEC /* Ittiam: Saturation added on the lines of EVS */ #endif - -- GitLab From 7d05e98dfb044d4d36ea691307f8109aec1ddc4a Mon Sep 17 00:00:00 2001 From: malenov Date: Thu, 5 Dec 2024 14:13:41 +0100 Subject: [PATCH 18/21] include order --- lib_dec/ivas_agc_dec_fx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_dec/ivas_agc_dec_fx.c b/lib_dec/ivas_agc_dec_fx.c index 5ce95a1f7..8996f087d 100644 --- a/lib_dec/ivas_agc_dec_fx.c +++ b/lib_dec/ivas_agc_dec_fx.c @@ -31,10 +31,9 @@ *******************************************************************************************************/ #include -#include "options.h" -#ifdef IVAS_FLOAT_FIXED #include #include +#include "options.h" #include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" -- GitLab From b6df1ca0013821df08a06823caba18110aecf4c4 Mon Sep 17 00:00:00 2001 From: malenov Date: Thu, 12 Dec 2024 15:22:49 +0100 Subject: [PATCH 19/21] update of code modifications respecting FIX_1054_IF_ELSE_CMPLX in main --- lib_debug/wmc_auto.c | 38 ++++++++++++++++++++++++++++++++------ lib_debug/wmc_auto.h | 7 ++++++- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index c8ab4ac11..8e33c126d 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -154,10 +154,13 @@ static BASIC_OP op_weight = { BASIC_OP *multiCounter = NULL; unsigned int currCounter = 0; -int funcId_where_last_call_to_else_occurred; long funcid_total_wmops_at_last_call_to_else; -int call_occurred = 1; +#ifdef FIX_1054_IF_ELSE_CMPLX char func_name_where_last_call_to_else_occurred[MAX_FUNCTION_NAME_LENGTH + 1]; +#else +int funcId_where_last_call_to_else_occurred; +int call_occurred = 1; +#endif void reset_wmops( void ) { @@ -379,7 +382,9 @@ void push_wmops_fct( const char *label, ... ) /* set the ID of the current BASOP operations counter */ currCounter = index_record; +#ifndef FIX_1054_IF_ELSE_CMPLX call_occurred = 1; +#endif return; } @@ -423,7 +428,9 @@ void pop_wmops( void ) { currCounter = current_record; } +#ifndef FIX_1054_IF_ELSE_CMPLX call_occurred = 1; +#endif return; } @@ -517,7 +524,9 @@ void update_wmops( void ) #endif /* reset the BASOP operations counter */ +#ifndef FIX_1054_IF_ELSE_CMPLX call_occurred = 1; +#endif Reset_BASOP_WMOPS_counter( i ); } @@ -2449,29 +2458,46 @@ void incrIf( const char *func_name ) { /* Technical note: If the "IF" operator comes just after an "ELSE", its counter must not be incremented */ /* The following auxiliary variables are used to check if the "IF" operator doesn't immediately follow an "ELSE" operator */ - if ( ( (int) currCounter != funcId_where_last_call_to_else_occurred ) || ( strncmp( func_name, func_name_where_last_call_to_else_occurred, MAX_FUNCTION_NAME_LENGTH ) != 0 ) || ( TotalWeightedOperation( currCounter) != funcid_total_wmops_at_last_call_to_else ) || ( call_occurred == 1 ) ) +#ifdef FIX_1054_IF_ELSE_CMPLX + if ( ( strncmp( func_name, func_name_where_last_call_to_else_occurred, MAX_FUNCTION_NAME_LENGTH ) != 0 ) || ( TotalWeightedOperation( currCounter ) != funcid_total_wmops_at_last_call_to_else ) ) + { + + multiCounter[currCounter].If++; + } + + func_name_where_last_call_to_else_occurred[0] = '\0'; +#else + if ( ( currCounter != funcId_where_last_call_to_else_occurred ) || ( TotalWeightedOperation() != funcid_total_wmops_at_last_call_to_else ) || ( call_occurred == 1 ) ) multiCounter[currCounter].If++; call_occurred = 0; - funcId_where_last_call_to_else_occurred = -100; + funcId_where_last_call_to_else_occurred = MAXCOUNTERS; +#endif } void incrElse( const char *func_name ) { multiCounter[currCounter].If++; +#ifndef FIX_1054_IF_ELSE_CMPLX /* Save the BASOP counter Id in the last function in which ELSE() has been called */ funcId_where_last_call_to_else_occurred = currCounter; +#endif /* Save the BASOP comeplxity in the last call of the ELSE() statement */ funcid_total_wmops_at_last_call_to_else = TotalWeightedOperation( currCounter ); - /* Save the function name in the last call of the ELSE() statement */ +#ifdef FIX_1054_IF_ELSE_CMPLX + /* We keep track of the name of the last calling function when the ELSE macro was called */ strncpy( func_name_where_last_call_to_else_occurred, func_name, MAX_FUNCTION_NAME_LENGTH ); func_name_where_last_call_to_else_occurred[MAX_FUNCTION_NAME_LENGTH] = '\0'; +#else + /* We keep track of the funcId of the last function which used ELSE {...} structure. */ + funcId_where_last_call_to_else_occurred = currCounter; - /* Set call_occurred to 0 to prevent counting of complexity of the next "immediate" IF statement */ + /* call_occurred is set to 0, in order to count the next IF (if necessary) */ call_occurred = 0; +#endif } long TotalWeightedOperation( unsigned int CounterId ) diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index aea3702a0..a3d1d3bef 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -961,9 +961,14 @@ typedef struct #ifdef WMOPS extern BASIC_OP *multiCounter; extern unsigned int currCounter; +#ifndef FIX_1054_IF_ELSE_CMPLX extern int funcId_where_last_call_to_else_occurred; -extern long funcid_total_wmops_at_last_call_to_else; extern int call_occurred; +#endif +extern long funcid_total_wmops_at_last_call_to_else; +#ifdef FIX_1054_IF_ELSE_CMPLX +extern char func_name_where_last_call_to_else_occurred[]; +#endif long TotalWeightedOperation( unsigned int counterId ); long DeltaWeightedOperation( unsigned int counterId ); -- GitLab From 50000f573c4a16c73be7671fc7c5af907025583a Mon Sep 17 00:00:00 2001 From: malenov Date: Thu, 12 Dec 2024 15:29:53 +0100 Subject: [PATCH 20/21] do not penalize fcn calls by default (introduced macro WMOPS_DISABLE_FCN_CALL_PENALIZATION) --- lib_debug/wmc_auto.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index a3d1d3bef..1d10b889e 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -35,6 +35,7 @@ #define ENH_U_32_BIT_OPERATOR #define COMPLEX_OPERATOR #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 enum instructions @@ -351,7 +352,11 @@ extern int cntr_push_pop; #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 ) +#else #define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) ), OP_COUNT_( _FUNC, 1 ) ) +#endif #define MISC_( x ) ABS_( x ) /* Math Operations */ -- GitLab From 5f78aabd682cd6464ea23a84461809bde1f5ab25 Mon Sep 17 00:00:00 2001 From: malenov Date: Thu, 12 Dec 2024 15:32:45 +0100 Subject: [PATCH 21/21] clean the macro FIX_1054_IF_ELSE_CMPLX from wmc_auto.h and wmc_auto.c as it is not automatically stripped with prepare_instrumentation.sh in CI jobs --- lib_debug/wmc_auto.c | 41 ----------------------------------------- lib_debug/wmc_auto.h | 6 ------ 2 files changed, 47 deletions(-) diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index 8e33c126d..731b01e1c 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -155,12 +155,7 @@ static BASIC_OP op_weight = { BASIC_OP *multiCounter = NULL; unsigned int currCounter = 0; long funcid_total_wmops_at_last_call_to_else; -#ifdef FIX_1054_IF_ELSE_CMPLX char func_name_where_last_call_to_else_occurred[MAX_FUNCTION_NAME_LENGTH + 1]; -#else -int funcId_where_last_call_to_else_occurred; -int call_occurred = 1; -#endif void reset_wmops( void ) { @@ -251,12 +246,6 @@ void reset_wmops( void ) wmops_caller_stack[i] = -1; } -#ifndef FIX_1054_IF_ELSE_CMPLX - /* initialize auxiliary BASOP WMOPS variables */ - //call_occurred = 1; - //funcId_where_last_call_to_else_occurred = INT_MAX; -#endif - return; } @@ -382,9 +371,6 @@ void push_wmops_fct( const char *label, ... ) /* set the ID of the current BASOP operations counter */ currCounter = index_record; -#ifndef FIX_1054_IF_ELSE_CMPLX - call_occurred = 1; -#endif return; } @@ -428,9 +414,6 @@ void pop_wmops( void ) { currCounter = current_record; } -#ifndef FIX_1054_IF_ELSE_CMPLX - call_occurred = 1; -#endif return; } @@ -524,9 +507,6 @@ void update_wmops( void ) #endif /* reset the BASOP operations counter */ -#ifndef FIX_1054_IF_ELSE_CMPLX - call_occurred = 1; -#endif Reset_BASOP_WMOPS_counter( i ); } @@ -2458,7 +2438,6 @@ void incrIf( const char *func_name ) { /* Technical note: If the "IF" operator comes just after an "ELSE", its counter must not be incremented */ /* The following auxiliary variables are used to check if the "IF" operator doesn't immediately follow an "ELSE" operator */ -#ifdef FIX_1054_IF_ELSE_CMPLX if ( ( strncmp( func_name, func_name_where_last_call_to_else_occurred, MAX_FUNCTION_NAME_LENGTH ) != 0 ) || ( TotalWeightedOperation( currCounter ) != funcid_total_wmops_at_last_call_to_else ) ) { @@ -2466,38 +2445,18 @@ void incrIf( const char *func_name ) } func_name_where_last_call_to_else_occurred[0] = '\0'; -#else - if ( ( currCounter != funcId_where_last_call_to_else_occurred ) || ( TotalWeightedOperation() != funcid_total_wmops_at_last_call_to_else ) || ( call_occurred == 1 ) ) - multiCounter[currCounter].If++; - - call_occurred = 0; - funcId_where_last_call_to_else_occurred = MAXCOUNTERS; -#endif } void incrElse( const char *func_name ) { multiCounter[currCounter].If++; -#ifndef FIX_1054_IF_ELSE_CMPLX - /* Save the BASOP counter Id in the last function in which ELSE() has been called */ - funcId_where_last_call_to_else_occurred = currCounter; -#endif - /* Save the BASOP comeplxity in the last call of the ELSE() statement */ funcid_total_wmops_at_last_call_to_else = TotalWeightedOperation( currCounter ); -#ifdef FIX_1054_IF_ELSE_CMPLX /* We keep track of the name of the last calling function when the ELSE macro was called */ strncpy( func_name_where_last_call_to_else_occurred, func_name, MAX_FUNCTION_NAME_LENGTH ); func_name_where_last_call_to_else_occurred[MAX_FUNCTION_NAME_LENGTH] = '\0'; -#else - /* We keep track of the funcId of the last function which used ELSE {...} structure. */ - funcId_where_last_call_to_else_occurred = currCounter; - - /* call_occurred is set to 0, in order to count the next IF (if necessary) */ - call_occurred = 0; -#endif } long TotalWeightedOperation( unsigned int CounterId ) diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index 1d10b889e..59bbc5bbf 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -966,14 +966,8 @@ typedef struct #ifdef WMOPS extern BASIC_OP *multiCounter; extern unsigned int currCounter; -#ifndef FIX_1054_IF_ELSE_CMPLX -extern int funcId_where_last_call_to_else_occurred; -extern int call_occurred; -#endif extern long funcid_total_wmops_at_last_call_to_else; -#ifdef FIX_1054_IF_ELSE_CMPLX extern char func_name_where_last_call_to_else_occurred[]; -#endif long TotalWeightedOperation( unsigned int counterId ); long DeltaWeightedOperation( unsigned int counterId ); -- GitLab