Skip to content
......@@ -75,7 +75,16 @@ void ivas_fine_gain_pred_fx(
L_tmp = L_shl( xx, exp ); /*2*(15-shift)+exp */
exp = sub( 31, add( exp, sub( 30, shl( shift, 1 ) ) ) );
L_tmp = Isqrt_lc( L_tmp, &exp ); /*31 - exp */
#ifndef FIX_ISSUE_987
Mpy_32_16_ss( L_tmp, ivas_fine_gain_pred_sqrt_bw[bw_idx], &L_tmp, &lsb ); /*31-exp+11-15=27-exp */
#else
Word16 norm = norm_s( bw );
Word16 tmp1, tmp_exp = sub( 15, norm );
tmp1 = Sqrt16( shl( bw, norm ), &tmp_exp );
tmp1 = shr( tmp1, sub( sub( 15, tmp_exp ), Q11 ) );
Mpy_32_16_ss( L_tmp, tmp1, &L_tmp, &lsb ); /*31-exp+11-15=27-exp */
#endif
#ifdef BASOP_NOGLOB
gp = round_fx_o( L_shl_o( L_tmp, add( 1, exp ), &Overflow ), &Overflow ); /*27-exp+1+exp-16=12 */
#else
......
......@@ -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 )
{
......
......@@ -58,12 +58,17 @@
/*#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 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
#define IVAS_FLOAT_FIXED
#define IVAS_FLOAT_FIXED_CONVERSIONS /* Temporary macro to keep track of intermediate flt to fixed and fixed to flt conversions */
......@@ -83,4 +88,16 @@
#define NONE_BE_FIX_BASOP_1044_OSBA_PRERENDER_MIX_GAINS /* DLB: adjust prerendering and mixing gain in OSBA encoder. This is fix to float codes*/
#define NONBE_1233_HQ_CLASSIFIER_DIV_BY_ZERO /* Eri: issue 1233: Address possible division by zero in hf_spectrum_sparseness() */
#define FIX_ISSUE_1062_AND_1068_TON_ENE_EST_FX
#define FIX_ISSUE_987
#define FIX_1054_IF_ELSE_CMPLX /* VA: Fix 1054 incorrect counting of complexity when ELSE-IF sequence is encoutered in two functions */
#define FIX_1052_COPY_CMPLX_DISCREPANCY /* VA: modify IF-ELSE statements used in Copy*() functions to avoid dependency on x[] and y[] in RAM */
#define FIX_1049_SHR_RO_COMPLEXITY /* VA: fix for issue 1049: incorrect counting of complexity in the shr_ro() function */
#define FIX_1103_OPT_L_NORM_ARR /* FhG: Optimize L_norm_arr(), avoid IF */
#define FIX_1105_OPT_MINIMUM_SL /* FhG: Optimize minimum_s(), minimum_l(), avoid IF */
#define FIX_1104_OPT_GETMINSCALEFAC /* FhG: Optimize get_min_scalefactor(), avoid IF */
#define FIX_1106_SIMPLIFY_SET32FX /* FhG: simplify set32_fx() */
#define FIX_1107_VADDINC /* FhG: Optimize v_add_inc_fx() for most frequent case */
#define FIX_1009_OPT_PARAMMC_RENDER /* FhG: Optimize ivas_param_mc_dec_render_fx() */
#define FIX_1109_OPTIM_MCT_STEREO_IGF_DEC /* FhG: optimize mctStereoIGF_dec_fx() */
#define FIX_1110_OPTIM_DIRAC_DECORR_PROC /* FhG: optimize ivas_dirac_dec_decorr_process() */
#endif
......@@ -337,13 +337,6 @@ void v_multc(
const int16_t N /* i : Vector length */
);
void v_sub_s(
const int16_t x1[], /* i : Input vector 1 */
const int16_t x2[], /* i : Input vector 2 */
int16_t y[], /* o : Output vector that contains vector 1 - vector 2 */
const int16_t N /* i : Vector length */
);
/*! r: index of the winning codeword */
int16_t squant(
const float x, /* i : scalar value to quantize */
......@@ -863,17 +856,6 @@ void deemph(
float *mem /* i/o: memory (y[-1]) */
);
/*! r: tilt of the code */
float est_tilt(
const float *adpt_exc, /* i : adaptive excitation vector */
const float gain_pit, /* i : adaptive gain */
const float *fixe_exc, /* i : algebraic exctitation vector */
const float gain_code, /* i : algebraic code gain */
float *voice_fac, /* o : voicing factor */
const int16_t L_subfr, /* i : subframe size */
const int16_t flag_tilt /* i : flag for special tilt */
);
void weight_a(
const float *a, /* i : LP filter coefficients */
float *ap, /* o : weighted LP filter coefficients */
......@@ -1242,16 +1224,6 @@ void stat_noise_uv_mod(
const int16_t bwidth /* i : audio bandwidth */
);
#ifndef IVAS_FLOAT_FIXED
void pre_echo_att(
float *Last_frame_ener, /* i/o: Energy of the last frame */
float *exc, /* i/o: Excitation of the current frame */
const int16_t attack_flag, /* i : attack flag (GSC or TC) */
const int16_t last_coder_type, /* i : Last coder type */
const int16_t L_frame /* i : frame length */
);
#endif
void limit_band_noise_level_calc(
const int16_t *wnorm, /* i : reordered norm of sub-vectors */
int16_t *limit, /* o : highest band of bit allocation */
......@@ -1569,18 +1541,6 @@ void enforce_zero_for_min_envelope(
const int16_t *sfm_end /* i : Sub band end indices */
);
#ifndef IVAS_FLOAT_FIXED
/*! r: Number of assigned gain bits */
int16_t assign_gain_bits(
const int16_t core, /* i : HQ core */
const int16_t BANDS, /* i : Number of bands */
const int16_t *band_width, /* i : Sub band bandwidth */
int16_t *Rk, /* i/o: Bit allocation/Adjusted bit alloc. (Q3) */
int16_t *gain_bits_array, /* o : Assigned gain bits */
int16_t *Rcalc /* o : Bit budget for shape quantizer (Q3) */
);
#endif
void apply_envelope(
const float *coeff, /* i/o: Coded/noisefilled normalized spectrum */
const int16_t *norm, /* i : Envelope */
......@@ -2905,16 +2865,6 @@ float gsc_gainQ(
const int32_t core_brate_inp /* i : true core brate */
);
#ifndef IVAS_FLOAT_FIXED
void Ener_per_band_comp(
const float exc_diff[], /* i : gain per band */
float y_gain4[], /* o : gain per band to quantize */
const int16_t Mband, /* i : Max band */
const int16_t Eflag, /* i : flag of highest band */
const int16_t L_frame /* i : frame length */
);
#endif
void Comp_and_apply_gain(
float exc_diffQ[], /* i/o: gain per band */
float Ener_per_bd_iQ[], /* o : Quant Ener per band */
......@@ -2923,30 +2873,6 @@ void Comp_and_apply_gain(
const int16_t ReUseGain /* i : Reuse the gain in Ener_per_bd_yQ */
);
#ifndef IVAS_FLOAT_FIXED
void bands_and_bit_alloc(
const int16_t cor_strong_limit, /* i : HF correlation */
const int16_t noise_lev, /* i : dwn scaling factor */
const int32_t core_brate, /* i : core bitrate */
const int16_t Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/
const int16_t bits_used, /* i : Number of bit used before frequency Q */
int16_t *bit, /* i/o: Number of bit allowed for frequency quantization */
float *ener_vec, /* i/o: Quantized energy vector */
int16_t *max_ener_band, /* o : Sorted order */
int16_t *bits_per_bands_s, /* i/o: Number of bit allowed per allowed subband (Q3) */
int16_t *nb_subbands, /* o : Number of subband allowed */
const float *exc_diff, /* i : Difference signal to quantize (encoder side only) */
float *concat_in, /* o : Concatened PVQ's input vector (encoder side only) */
int16_t *pvq_len, /* o : Number of bin covered with the PVQ */
const int16_t coder_type, /* i : coding type */
const int16_t bwidth, /* i : input signal bandwidth */
const int16_t GSC_noisy_speech, /* i : GSC noisy speech flag */
const int16_t L_frame, /* i : frame length */
const int16_t element_mode, /* i : element mode */
const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */
);
#endif
void bands_and_bit_alloc_ivas_fx(
const Word16 cor_strong_limit, /* i : HF correlation */
const Word16 noise_lev, /* i : dwn scaling factor */
......@@ -2969,29 +2895,6 @@ void bands_and_bit_alloc_ivas_fx(
const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */
);
#ifndef IVAS_FLOAT_FIXED
/*! r: average frequency gain */
float gsc_gaindec(
Decoder_State *st, /* i/o: decoder state structure */
float y_gainQ[], /* o : quantized gain per band */
const int32_t core_brate, /* i : core used */
float old_y_gain[], /* i/o: AR gain quantizer for low rate */
const int16_t coder_type, /* i : coding type */
const int16_t bwidth /* i : input signal bandwidth */
);
#endif
#ifndef IVAS_FLOAT_FIXED
void freq_dnw_scaling(
const int16_t cor_strong_limit, /* i : HF correlation */
const int16_t coder_type, /* i : coder type */
const int16_t noise_lev, /* i : Noise level */
const int32_t core_brate, /* i : Core bitrate */
float fy_norm[], /* i/o: Frequency quantized parameter */
const int16_t L_frame /* i : frame length */
);
#endif
void GSC_dec_init_ivas(
GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */
);
......@@ -3042,38 +2945,6 @@ void dec_pit_exc(
const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
);
#ifndef IVAS_FLOAT_FIXED
void highband_exc_dct_in(
const int32_t core_brate, /* i : core bitrate */
const int16_t *mfreq_bindiv_loc, /* i : bin per bands tables */
int16_t last_bin, /* i : last bin of bit allocation */
int16_t Diff_len, /* i : number of bin before cut-off frequency */
int16_t noise_lev, /* i : pulses dynamic */
int16_t pit_band_idx, /* i : bin position of the cut-off frequency */
float *exc_diffQ, /* i : frequency coefficients of per band */
int16_t *seed_tcx, /* i : Seed for noise */
float *Ener_per_bd_iQ, /* i : Quantized energy of targeted vector */
int16_t nb_subfr, /* i : Number of subframe considered */
float *exc_dct_in, /* o : dct of residual signal */
int16_t last_coder_type, /* i : coding type of last frame */
int16_t *bitallocation_band, /* i : bit allocation flag of each band */
const float *lsf_new, /* i : ISFs at the end of the frame */
float *last_exc_dct_in, /* i : dct of residual signal of last frame */
float *last_ener, /* i : frequency energy of last frame */
int16_t *last_bitallocation_band, /* i : bit allocation flag of each band of last frame */
int16_t *bitallocation_exc, /* i : flag of decoded coefficients */
const int16_t bfi, /* i : bad frame indicator */
const int16_t coder_type, /* i : coder type */
const int16_t bwidth, /* i : audio bandwidth */
float *exc_wo_nf, /* o : excitation (in f domain) without noisefill */
const int16_t GSC_noisy_speech, /* i : GSC noisy speech flag */
float *lt_ener_per_band_fx, /* i/o: Average per band energy */
const int16_t L_frame, /* i : frame length */
const int16_t element_mode, /* i : IVAS element moden */
const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */
);
#endif
void music_postfilt_init_flt(
MUSIC_POSTFILT_HANDLE hMusicPF /* i/o: LD music postfilter handle */
);
......@@ -5795,14 +5666,6 @@ void adapt_lag_wind_fx(
const int32_t sr_core /* i : core sampling rate */
);
#ifndef IVAS_FLOAT_FIXED
void hp20_flt(
Float32 signal[],
const Word16 lg,
Float32 mem[],
const Word32 Fs );
#endif
void init_coder_ace_plus(
Encoder_State *st, /* i : Encoder state handle */
const int32_t last_total_brate, /* i : last total bitrate */
......@@ -5945,16 +5808,6 @@ void core_signal_analysis_high_bitrate(
const int16_t vad_hover_flag /* i : VAD hangover flag */
);
#ifndef IVAS_FLOAT_FIXED
/*! r: codebook gain (adaptive or fixed) */
float get_gain_flt(
const float x[], /* i : target signal */
const float y[], /* i : filtered codebook excitation */
const int16_t n, /* i : segment length */
float *en_y /* o : energy of y (sum of y[]^2, optional) */
);
#endif
void encode_acelp_gains(
const float *code,
const int16_t gains_mode,
......@@ -8022,17 +7875,6 @@ float Damping_fact_flt(
const int16_t core /* i : current core: ACELP = 0, TCX20 = 1, TCX10 = 2 */
);
#ifndef IVAS_FLOAT_FIXED
void fer_energy(
const int16_t L_frame, /* i : frame length */
const int16_t clas, /* i : frame classification */
const float synth[], /* i : synthesized speech at Fs = 12k8 Hz */
const float pitch, /* i : pitch period */
float *enr, /* o : pitch-synchronous or half_frame energy */
const int16_t useOffset /* i : speech pointer offset (0 or L_FRAME) */
);
#endif
float getLevelSynDeemph(
const float h1Init[], /* i : input value or vector to be processed */
const float A[], /* i : LPC coefficients */
......
......@@ -388,8 +388,7 @@ void SWB_BWE_decoding_fx(
Word16 *prev_weight, /* i/o: excitation weight value of last frame */
const Word16 extl, /* i : extension layer */
Word16 Q_syn,
const Word16 last_extl, /* i : extension layer of last frame */
Word16 element_mode /* i : element mode */
const Word16 last_extl /* i : extension layer of last frame */
);
 
void time_envelop_shaping_fx(
......@@ -2719,8 +2718,7 @@ void SWB_BWE_decoding_fx(
Word16 *prev_weight, /* i/o: excitation weight value of last frame */
const Word16 extl, /* i : extension layer */
Word16 Q_syn,
const Word16 last_extl, /* i : extension layer of last frame */
Word16 element_mode /* i : element mode */
const Word16 last_extl /* i : extension layer of last frame */
);
 
void time_envelop_shaping_fx(
......@@ -4559,6 +4557,7 @@ Word16 L_norm_arr( Word32 *arr, Word16 size );
Word16 get_min_scalefactor( Word32 x, Word32 y );
 
Flag is_zero_arr( Word32 *arr, Word16 size );
Flag is_zero_arr16( Word16 *arr, Word16 size );
 
void edct2_fx_ivas(
const Word16 n,
......@@ -10741,7 +10740,8 @@ void core_encode_update_ivas_fx(
);
 
void updt_enc_common_ivas_fx(
Encoder_State *st /* i/o: encoder state structure */
Encoder_State *st, /* i/o: encoder state structure */
const Word16 Q_new /* i : CUrrent frame scaling */
);
 
// tools.c
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -49,13 +49,13 @@
#define INTERP_EXP 0
typedef struct
{
int32_t fin; /* input frequency */
Word32 fin; /* input frequency */
Word32 fin_fx; /* input frequency Q0 */
int32_t fout; /* output frequency */
Word32 fout; /* output frequency */
Word32 fout_fx; /* output frequency Q0 */
int16_t fac_num; /* numerator of resampling factor */
Word16 fac_num; /* numerator of resampling factor */
Word16 fac_num_fx; /* numerator of resampling factor Q0 */
Word16 fac_den_fx; /* denominator of resampling factor Q0 */
......@@ -63,7 +63,7 @@ typedef struct
const Word16 *filter_fx; /* resampling filter coefficients Q14 */
int16_t filt_len; /* number of filter coeff. */
Word16 filt_len; /* number of filter coeff. */
Word16 filt_len_fx; /* number of filter coeff. Q0 */
uint16_t flags; /* flags from config. table */
......@@ -177,9 +177,7 @@ extern const Word16 h_high_fx[5]; // Q15
extern const Word16 sincos_t_fx[161]; // Q15
extern const Word16 sincos_t_ext_fx[]; // Q15
extern const Word32 crit_bands_fx[];
extern const float crit_bands[]; /* Table of critical bands */
extern const float sincos_t_ext[];
extern const float sincos_t_rad3[];
extern const float sincos_t_ext[]; // fft_rel dep
extern const Word16 sincos_t_rad3_fx[]; // Q15
extern const Word16 fft256_read_indexes[]; /* FFT Q0*/
extern const Word16 inter4_2_fx_Q15[]; // Q15 /* 1/4 resolution interpolation filter */
......@@ -195,12 +193,6 @@ extern const Word32 crit_bands_fx[]; /* Table of criti
extern const Word16 wind_sss_fx[LEN_WIN_SSS]; // Q15 /*window for modify_sf ana*/
extern const Word16 filter5_39s320_120_fx[]; // Q15
extern const float lag_window_8k_flt[17];
extern const float lag_window_12k8_flt[][17];
extern const float lag_window_16k_flt[][17];
extern const float lag_window_25k6_flt[][17];
extern const float lag_window_32k_flt[][17];
extern const float lag_window_48k_flt[17];
extern const Word16 lag_window_8k[2][16]; // Q15
extern const Word16 lag_window_12k8[NUM_LAGW_STRENGTHS][2][16]; // Q15
extern const Word16 lag_window_16k[NUM_LAGW_STRENGTHS][2][16]; // Q15
......@@ -273,9 +265,9 @@ extern const Word16 gp_gamma_3sfr_6b_fx[]; // Q14/Q9
extern const Word16 gp_gamma_4sfr_6b_fx[]; // Q14/Q9
extern const int16_t E_ROM_qua_gain5b_const[];
extern const int16_t E_ROM_qua_gain6b_const[];
extern const int16_t E_ROM_qua_gain7b_const[];
extern const Word16 E_ROM_qua_gain5b_const[];
extern const Word16 E_ROM_qua_gain6b_const[];
extern const Word16 E_ROM_qua_gain7b_const[];
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
......@@ -426,7 +418,6 @@ extern const Word16 CBsizes[]; // Q0
extern const Word16 CBbits[]; // Q0
extern const Word16 CBbits_p[]; // Q0
extern const float vals[NO_LEADERS][MAX_NO_VALS];
extern const Word16 vals_fx[NO_LEADERS][MAX_NO_VALS]; // Q1
extern const Word16 no_vals[NO_LEADERS]; // Q0
......@@ -438,10 +429,6 @@ 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 float sigma_MSLVQ[][16];
extern const float sigma_p[][16];
extern const float scales[][MAX_NO_SCALES * 2];
extern const float scales_p[][MAX_NO_SCALES * 2];
extern const Word16 BitsVQ[]; // Q0
extern const Word16 BitsVQ_p[]; // Q0
extern const UWord8 no_lead_idx[][2]; // Q0
......@@ -936,13 +923,9 @@ extern const Word16 fg_inv_tbl_fx[13]; // Q0
/* functions and tables for pvq_indexing */
extern const UWord32 exactdivodd[ODD_DIV_SIZE]; // Q0
extern const float gain_att[];
extern const float stab_trans[];
extern const float env_stab_tp[2][2];
extern const float att_step[];
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 Word16 gain_cb_size[];
extern const Word16 stab_trans_fx[]; // Q15
extern const Word16 env_stab_tp_fx[2][2]; // Q15
/*----------------------------------------------------------------------------------*
......@@ -1051,78 +1034,43 @@ extern const Word16 gsc_sfm_start[]; // Q0
extern const Word16 gsc_sfm_end[]; // Q0
extern const Word16 gsc_sfm_size[]; // Q0
extern const float sm_table[];
extern const Word16 sm_table_fx[]; // Q15
extern const float mfreq_loc[];
extern const Word16 mfreq_bindiv_loc[]; // Q0
extern const float mean_gp[];
extern const Word16 mean_gp_fx[]; /*Q14*/
extern const float dic_gp[];
extern const Word16 dic_gp_fx[]; /*Q14*/
extern const float Gain_mean[];
extern const float Gain_meanHR[];
extern const float Gain_mean_dic[];
extern const float Gain_mean_dicHR[];
extern const float YG_mean16[];
extern const Word16 YG_mean16_fx[]; /*Q12 */
extern const float YG_dicMR_1[];
extern const float YG_dicMR_2[];
extern const float YG_dicMR_3[];
extern const float YG_dicMR_4[];
extern const Word16 YG_dicMR_1_fx[]; /*Q12 */
extern const Word16 YG_dicMR_2_fx[]; /*Q12 */
extern const Word16 YG_dicMR_3_fx[]; /*Q12 */
extern const Word16 YG_dicMR_4_fx[]; /*Q12 */
extern const float mean_m[];
extern const Word16 mean_m_fx[]; /*Q12 */
extern const float mean_gain_dic[];
extern const Word16 mean_gain_dic_fx[]; /*Q12 */
extern const float YGain_mean_LR[];
extern const Word16 YGain_mean_LR_fx[]; /* Q12 */
extern const float YGain_dic1_LR[];
extern const float YGain_dic2_LR[];
extern const float YGain_dic3_LR[];
extern const Word16 YGain_dic1_LR_fx[]; /* Q12 */
extern const Word16 YGain_dic2_LR_fx[]; /*Q12 */
extern const Word16 YGain_dic3_LR_fx[]; /*Q12 */
extern const float Gain_dic2_NBHR[];
extern const float Gain_dic3_NBHR[];
extern const Word16 Gain_dic3_NBHR_fx[]; /*Q12 */
extern const Word16 Gain_dic2_NBHR_fx[]; /*Q12 */
extern const float YG_mean16HR[];
extern const Word16 YG_mean16HR_fx[]; /* Q12 */
extern const float YG_dicHR_1[];
extern const Word16 YG_dicHR_1_fx[]; /* Q12 */
extern const float YG_dicHR_2[];
extern const Word16 YG_dicHR_2_fx[]; /* Q12 */
extern const float YG_dicHR_3[];
extern const Word16 YG_dicHR_3_fx[]; /* Q12 */
extern const float YG_mean16HR_16kHz[];
extern const Word16 YG_mean16HR_16kHz_fx[]; /* Q12 */
extern const float YG_dicHR_4_16kHz[];
extern const Word16 YG_dicHR_4_16kHz_fx[]; /* Q12 */
extern const float YG_meanL2G_16kHz[];
extern const Word16 YG_meanL2G_16kHz_fx[]; /* Q12 */
extern const float YG_dicL2G_16kHz[];
extern const Word16 YG_dicL2G_16kHz_fx[]; /* Q12 */
extern const Word16 GSC_freq_bits[]; // Q0
extern const Word32 GSC_freq_bits_fx[]; /*Q18*/
extern const Word32 GSC_freq_bits_fx_Q18[]; /*Q18*/
extern const Word16 GSC_freq_DL0_bits[]; /* Q0 */
extern const Word16 Compl_GSC_freq_bits[]; /* Q0 */
extern const float Gain_meanNB[];
extern const Word16 Gain_meanNB_fx[]; /*Q12*/
extern const float Gain_mean_dicNB[];
extern const Word16 Gain_mean_dicNB_fx[]; /*Q12 */
extern const float Mean_dic_NB[];
extern const Word16 Mean_dic_NB_fx[]; /*Q12 */
extern const float Gain_dic1_NB[];
extern const float Gain_dic2_NB[];
extern const float Gain_dic3_NB[];
extern const Word16 Gain_dic1_NB_fx[]; /*Q12 */
extern const Word16 Gain_dic2_NB_fx[]; /*Q12 */
extern const Word16 Gain_dic3_NB_fx[]; /*Q12 */
......@@ -1132,17 +1080,13 @@ extern const Word16 Gain_dic3_NB_fx[]; /*Q12 */
*------------------------------------------------------------------------------*/
extern const Word16 Odx_fft64[64]; // Q0
extern const float w_fft64[32];
extern const Word16 Ip_fft64[6]; // Q0
extern const Word16 Odx_fft32_15[32]; // Q0
extern const float w_fft32[16];
extern const Word32 w_fft32_16fx[16]; // Q30
extern const Word16 Ip_fft32[6]; // Q0
extern const Word16 Odx_fft32_5[32]; // Q0
extern const Word16 Odx_fft16[16]; // Q0
extern const float w_fft16[8];
extern const Word16 Ip_fft16[6]; // Q0
extern const float w_fft8[8];
extern const Word16 Ip_fft8[6]; // Q0
extern const Word16 Idx_dortft80[80]; // Q0
extern const Word16 Idx_dortft120[120]; // Q0
......@@ -1150,32 +1094,18 @@ extern const Word16 Idx_dortft160[160]; // Q0
extern const Word16 Idx_dortft320[320]; // Q0
extern const Word16 Idx_dortft480[480]; // Q0
extern const Word16 Ip_fft128[10]; // Q0
extern const float w_fft128[64];
extern const Word32 w_fft128_16fx[64]; // Q30
extern const Word16 Ip_fft256[10]; // Q0
extern const float w_fft256[128];
extern const Word16 Ip_fft512[18]; // Q0
extern const float w_fft512[256];
extern const Word16 w_fft512_fx_evs[256]; // Q14
// extern const Word16 w_fft512_fx[256];
extern const Word16 Idx_dortft40[40]; // Q0
extern const Word16 Odx_fft8_5[8]; // Q0
extern const Word16 ip_edct2_64[6]; // Q0
extern const float w_edct2_64[80];
extern const Word16 w_edct2_64_fx[80]; /*Q14 */
extern const Word16 Idx_dortft20[20]; // Q0
extern const Word16 Odx_fft4_5[4]; // Q0
extern const float w_fft4[2];
extern const Word16 Ip_fft4[6]; // Q0
extern const float FFT_RotVector_32[40];
extern const float FFT_RotVector_256[448];
extern const float FFT_RotVector_400[760];
extern const float FFT_RotVector_600[1140];
extern const float FFT_RotVector_640[1240];
extern const float FFT_RotVector_960[1860];
/*----------------------------------------------------------------------------------*
* FEC for HQ core
*----------------------------------------------------------------------------------*/
......@@ -1432,7 +1362,7 @@ extern const Word16 nTnsCoeffCodes; // Q0
extern const Coding *const codesTnsCoeffSWBTCX20[];
extern const Coding *const codesTnsCoeffSWBTCX10[];
extern const Coding *const codesTnsCoeffWBTCX20[];
extern const int16_t nTnsCoeffTables;
extern const Word16 nTnsCoeffTables;
extern const Coding codesTnsOrderTCX20[];
extern const Coding codesTnsOrderTCX10[];
......
......@@ -40,6 +40,9 @@
#ifndef ROM_COM_FX_H
#define ROM_COM_FX_H
#include "typedef.h"
/*------------------------------------------------------------------------------*
* FFT transform
*------------------------------------------------------------------------------*/
......
......@@ -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"
......
......@@ -1377,8 +1377,7 @@ void SWB_BWE_decoding_fx(
Word16 *prev_weight, /* i/o: excitation weight value of last frame */
const Word16 extl, /* i : extension layer */
Word16 Q_syn,
const Word16 last_extl, /* i : extension layer of last frame */
Word16 element_mode /* i : element mode */
const Word16 last_extl /* i : extension layer of last frame */
)
{
Word16 n_freq, n_band, L, L_swb_norm;
......@@ -1581,22 +1580,12 @@ void SWB_BWE_decoding_fx(
exp = norm_s( SWB_FENV );
tmp = div_s( shl( 1, sub( 14, exp ) ), SWB_FENV ); /*Q(29-exp) */
L_tmp = Mult_32_16( L_energy, tmp ); /*Q(1+29-exp+1)->Q(15-exp) */
IF( EQ_16( element_mode, EVS_MONO ) )
{
#ifdef BASOP_NOGLOB
Energy_16 = round_fx_sat( L_shl_sat( L_tmp, add( exp, 4 ) ) );
#else
EnergyL_16 = round_fx( L_shl( L_tmp, add( exp, 4 ) ) );
#endif
}
ELSE
{
#ifdef BASOP_NOGLOB
EnergyL_16 = round_fx_sat( L_shl_sat( L_tmp, add( exp, 4 ) ) ); /* Q3 */
Energy_16 = round_fx_sat( L_shl_sat( L_tmp, add( exp, 4 ) ) ); /* Q3 */
#else
Energy_16 = round_fx( L_shl( L_tmp, add( exp, 4 ) ) ); /*Q3 */
#endif
}
test();
IF( NE_16( last_extl, SWB_BWE ) && NE_16( last_extl, FB_BWE ) )
......
......@@ -879,15 +879,28 @@ Word16 minimum_s(
Word16 *min_val /* o : minimum value in the input vector */
)
{
#ifdef FIX_1105_OPT_MINIMUM_SL
Word16 i, ind;
#else
Word16 i, ind, tmp;
#endif
ind = 0;
move16();
#ifndef FIX_1105_OPT_MINIMUM_SL
tmp = vec[0];
move16();
#endif
FOR( i = 1; i < lvec; i++ )
{
#ifdef FIX_1105_OPT_MINIMUM_SL
if ( LT_16( vec[i], vec[ind] ) )
{
ind = i;
move16();
}
#else
IF( LT_16( vec[i], tmp ) )
{
ind = i;
......@@ -895,11 +908,16 @@ Word16 minimum_s(
tmp = vec[i];
move16();
}
#endif
}
if ( min_val != NULL )
{
#ifdef FIX_1105_OPT_MINIMUM_SL
*min_val = vec[ind];
#else
*min_val = tmp;
#endif
move16();
}
......@@ -920,15 +938,28 @@ Word16 minimum_l(
)
{
Word16 i, ind;
#ifndef FIX_1105_OPT_MINIMUM_SL
Word32 tmp;
#endif
ind = 0;
#ifndef FIX_1105_OPT_MINIMUM_SL
tmp = vec[0];
#endif
move16();
#ifndef FIX_1105_OPT_MINIMUM_SL
move32();
#endif
FOR( i = 1; i < lvec; i++ )
{
#ifdef FIX_1105_OPT_MINIMUM_SL
if ( LT_32( vec[i], vec[ind] ) )
{
ind = i;
move16();
}
#else
IF( LT_32( vec[i], tmp ) )
{
ind = i;
......@@ -936,11 +967,16 @@ Word16 minimum_l(
move16();
move32();
}
#endif
}
if ( min_val != NULL )
{
#ifdef FIX_1105_OPT_MINIMUM_SL
*min_val = vec[ind];
#else
*min_val = tmp;
#endif
move32();
}
......
......@@ -469,6 +469,7 @@ Word32 sum2_fx_mod( /* o : sum of all squared vector element
* Copy:
*
* Copy vector x[] to y[]
*
*-------------------------------------------------------------------*/
void Copy(
const Word16 x[], /* i : input vector */
......@@ -485,15 +486,27 @@ void Copy(
y[i] = x[i];
move16();
}
#ifdef FIX_1052_COPY_CMPLX_DISCREPANCY
/* Location of x and y may differ depending on platform/memory allocation. Since IF and ELSE has different complexity count, the early return is used instead of ELSE to ensure the same complexity number regardless of x and y memory addresses. */
return;
#endif
}
#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY
ELSE
{
#endif
FOR( i = L - 1; i >= 0; i-- )
{
y[i] = x[i];
move16();
}
return;
#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY
}
#endif
}
/*-------------------------------------------------------------------*
* Copy64:
......@@ -514,15 +527,27 @@ void Copy64(
y[i] = x[i];
move64();
}
#ifdef FIX_1052_COPY_CMPLX_DISCREPANCY
/* Location of x and y may differ depending on platform/memory allocation. Since IF and ELSE has different complexity count, the early return is used instead of ELSE to ensure the same complexity number regardless of x and y memory addresses. */
return;
#endif
}
#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY
ELSE
{
#endif
FOR( i = L - 1; i >= 0; i-- )
{
y[i] = x[i];
move64();
}
return;
#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY
}
#endif
}
void set64_fx(
......@@ -558,9 +583,17 @@ void Copy_pword(
move16();
move16();
}
#ifdef FIX_1052_COPY_CMPLX_DISCREPANCY
/* Location of x and y may differ depending on platform/memory allocation. Since IF and ELSE has different complexity count, the early return is used instead of ELSE to ensure the same complexity number regardless of x and y memory addresses. */
return;
#endif
}
#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY
ELSE
{
#endif
FOR( i = L - 1; i >= 0; i-- )
{
y[i].v.im = x[i].v.im;
......@@ -568,7 +601,11 @@ void Copy_pword(
move16();
move16();
}
return;
#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY
}
#endif
}
/*-------------------------------------------------------------------*
* Copy32:
......@@ -589,15 +626,24 @@ void Copy32(
y[i] = x[i];
move32();
}
#ifdef FIX_1052_COPY_CMPLX_DISCREPANCY
return;
#endif
}
#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY
ELSE
{
#endif
FOR( i = L - 1; i >= 0; i-- )
{
y[i] = x[i];
move32();
}
#ifndef FIX_1052_COPY_CMPLX_DISCREPANCY
}
#endif
}
void set8_fx(
......@@ -646,6 +692,15 @@ void set32_fx(
const Word16 N /* i : Lenght of the vector */
)
{
#ifdef FIX_1106_SIMPLIFY_SET32FX
Word16 i;
FOR( i = 0; i < N; i++ )
{
y[i] = a;
move32();
}
#else
Word16 i, tmp;
tmp = extract_l( a );
IF( EQ_32( L_deposit_l( tmp ), a ) )
......@@ -664,6 +719,7 @@ void set32_fx(
move32();
}
}
#endif
return;
}
......
......@@ -6,7 +6,6 @@
#include "options.h"
#include "cnst.h"
#include "prot_fx.h"
#include "control.h"
#include "basop_util.h"
......
/*
* (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
......@@ -18,6 +18,7 @@
#include <stdint.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <limits.h>
#ifndef _MSC_VER
#include <dirent.h>
......@@ -29,17 +30,18 @@
#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
*--------------------------------------------------------------------*/
#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 */
......@@ -48,6 +50,9 @@
#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];
......@@ -73,8 +78,7 @@ typedef struct
#endif
} wmops_record;
double ops_cnt_wmc;
double prom_cnt_wmc;
double ops_cnt;
double inst_cnt[NUM_INST];
static wmops_record *wmops = NULL;
......@@ -89,11 +93,73 @@ 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;
unsigned int currCounter = 0;
long funcid_total_wmops_at_last_call_to_else;
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;
......@@ -103,9 +169,9 @@ 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 */
/* allocate the list of WMOPS records */
if ( wmops == NULL )
{
wmops = (wmops_record *) malloc( max_num_wmops_records * sizeof( wmops_record ) );
......@@ -117,22 +183,20 @@ void reset_wmops( void )
exit( -1 );
}
/* allocate the BASOP WMOPS counter */
//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 );
//}
/* allocate the list of BASOP WMOPS records */
if ( multiCounter == NULL )
{
multiCounter = (BASIC_OP *) malloc( max_num_wmops_records * sizeof( BASIC_OP ) );
}
BASOP_init
if ( multiCounter == NULL )
{
fprintf( stderr, "Error: Unable to Allocate the BASOP WMOPS counter!" );
exit( -1 );
}
/* 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" );
......@@ -159,13 +223,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 */
......@@ -187,10 +246,6 @@ void reset_wmops( void )
wmops_caller_stack[i] = -1;
}
/* initialize auxiliary BASOP WMOPS variables */
//call_occurred = 1;
//funcId_where_last_call_to_else_occurred = INT_MAX;
return;
}
......@@ -198,7 +253,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] = "";
......@@ -223,7 +278,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 )
......@@ -231,51 +286,43 @@ 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++ )
{
strcpy( &wmops[i].label[0], "\0" );
wmops[i].call_number = 0;
wmops[i].update_cnt = 0;
/* initilize the new WMOPS record */
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[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].call_tree[j] = -1;
}
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 )
......@@ -286,8 +333,10 @@ 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;
/* 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 */
for ( j = 0; j < MAX_CALL_TREE_DEPTH; j++ )
......@@ -304,27 +353,31 @@ 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_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++;
#endif
/* set the ID of BASOP functions counters */
//Set_BASOP_WMOPS_counter( index_record );
BASOP_push_wmops( func_name );
/* set the ID of the current BASOP operations counter */
currCounter = index_record;
return;
}
void pop_wmops( void )
{
//long tot;
long tot;
/* Check for underflow */
if ( current_record < 0 )
......@@ -334,28 +387,33 @@ void pop_wmops( void )
}
/* add the BASOP complexity to the counter */
//tot = DeltaWeightedOperation();
//ops_cnt_wmc += tot;
tot = DeltaWeightedOperation( currCounter );
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;
/* set the ID of the previous BASOP counter */
//Set_BASOP_WMOPS_counter( current_record );
wmops[current_record].start_selfcnt = ops_cnt;
}
else
{
current_record = -1;
}
BASOP_pop_wmops();
/* 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;
}
return;
}
......@@ -448,12 +506,11 @@ void update_wmops( void )
wmops[i].current_call_number = 0;
#endif
/* update the WC of all BASOP counters */
//Set_BASOP_WMOPS_counter( i );
//Reset_BASOP_WMOPS_counter();
/* reset the BASOP operations counter */
Reset_BASOP_WMOPS_counter( i );
}
current_cnt = ops_cnt_wmc - start_cnt;
current_cnt = ops_cnt - start_cnt;
if ( current_cnt > max_cnt )
{
max_cnt = current_cnt;
......@@ -476,192 +533,186 @@ void update_wmops( void )
inst_cnt[i] = 0.0;
}
start_cnt = ops_cnt_wmc;
start_cnt = ops_cnt;
/* 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 );
}
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 / 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 );
}
//#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 );
// //}
/* 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;
}
......@@ -701,8 +752,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' )
......@@ -2127,7 +2178,339 @@ void print_mem( ROM_Size_Lookup_Table Const_Data_PROM_Table[] )
#endif /* WMOPS */
#ifdef CONTROL_CODE_OPS
int LT_16( short var1, short var2 )
{
int F_ret = 0;
if ( var1 < var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].LT_16++;
#endif
return F_ret;
}
int GT_16( short var1, short var2 )
{
int F_ret = 0;
if ( var1 > var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].GT_16++;
#endif
return F_ret;
}
int LE_16( short var1, short var2 )
{
int F_ret = 0;
if ( var1 <= var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].LE_16++;
#endif
return F_ret;
}
int GE_16( short var1, short var2 )
{
int F_ret = 0;
if ( var1 >= var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].GE_16++;
#endif
return F_ret;
}
int EQ_16( short var1, short var2 )
{
int F_ret = 0;
if ( var1 == var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].EQ_16++;
#endif
return F_ret;
}
int NE_16( short var1, short var2 )
{
int F_ret = 0;
if ( var1 != var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].NE_16++;
#endif
return F_ret;
}
int LT_32( int L_var1, int L_var2 )
{
int F_ret = 0;
if ( L_var1 < L_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].LT_32++;
#endif
return F_ret;
}
int GT_32( int L_var1, int L_var2 )
{
int F_ret = 0;
if ( L_var1 > L_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].GT_32++;
#endif
return F_ret;
}
int LE_32( int L_var1, int L_var2 )
{
int F_ret = 0;
if ( L_var1 <= L_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].LE_32++;
#endif
return F_ret;
}
int GE_32( int L_var1, int L_var2 )
{
int F_ret = 0;
if ( L_var1 >= L_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].GE_32++;
#endif
return F_ret;
}
int EQ_32( int L_var1, int L_var2 )
{
int F_ret = 0;
if ( L_var1 == L_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].EQ_32++;
#endif
return F_ret;
}
int NE_32( int L_var1, int L_var2 )
{
int F_ret = 0;
if ( L_var1 != L_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].NE_32++;
#endif
return F_ret;
}
int LT_64( long long int L64_var1, long long int L64_var2 )
{
int F_ret = 0;
if ( L64_var1 < L64_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].LT_64++;
#endif
return F_ret;
}
int GT_64( long long int L64_var1, long long int L64_var2 )
{
int F_ret = 0;
if ( L64_var1 > L64_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].GT_64++;
#endif
return F_ret;
}
int LE_64( long long int L64_var1, long long int L64_var2 )
{
int F_ret = 0;
if ( L64_var1 <= L64_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].LE_64++;
#endif
return F_ret;
}
int GE_64( long long int L64_var1, long long int L64_var2 )
{
int F_ret = 0;
if ( L64_var1 >= L64_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].GE_64++;
#endif
return F_ret;
}
int EQ_64( long long int L64_var1, long long int L64_var2 )
{
int F_ret = 0;
if ( L64_var1 == L64_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].EQ_64++;
#endif
return F_ret;
}
int NE_64( long long int L64_var1, long long int L64_var2 )
{
int 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 */
#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 */
/* The following auxiliary variables are used to check if the "IF" operator doesn't immediately follow an "ELSE" operator */
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';
}
void incrElse( const char *func_name )
{
multiCounter[currCounter].If++;
/* Save the BASOP comeplxity in the last call of the ELSE() statement */
funcid_total_wmops_at_last_call_to_else = TotalWeightedOperation( currCounter );
/* 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';
}
long TotalWeightedOperation( unsigned int CounterId )
{
int i;
unsigned int *ptr, *ptr2;
long tot;
tot = 0;
ptr = (unsigned int *) &multiCounter[CounterId];
ptr2 = (unsigned int *) &op_weight;
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", CounterId, i, *ptr );
exit( -1 );
}
tot += ( ( *ptr++ ) * ( *ptr2++ ) );
}
return ( tot );
}
long DeltaWeightedOperation( unsigned int CounterId )
{
long NewWOper, delta;
NewWOper = TotalWeightedOperation( CounterId );
delta = NewWOper - wmops[CounterId].LastWOper;
wmops[CounterId].LastWOper = NewWOper;
return ( delta );
}
/* Resets BASOP operation counter */
void Reset_BASOP_WMOPS_counter( unsigned int counterId )
{
int i;
long *ptr;
/* reset the current BASOP operation counter */
ptr = (long *) &multiCounter[counterId];
for ( i = 0; i < (int) ( sizeof( multiCounter[counterId] ) / sizeof( long ) ); i++ )
{
*ptr++ = 0;
}
wmops[counterId].LastWOper = 0;
return;
}
#ifndef WMOPS
int cntr_push_pop = 0; /* global counter for checking balanced push_wmops()/pop_wmops() pairs when WMOPS is not activated */
#endif
\ No newline at end of file
/*
* (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
......@@ -30,8 +30,12 @@
#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 ENH_32_BIT_OPERATOR
#define ENH_64_BIT_OPERATOR
#define ENH_U_32_BIT_OPERATOR
#define COMPLEX_OPERATOR
#define CONTROL_CODE_OPS /* enable control code operators such as LT_16, GT_16, ... */
#define WMOPS_DISABLE_FCN_CALL_PENALIZATION /* do not count the complexity of function calls */
#ifdef WMOPS
enum instructions
......@@ -59,6 +63,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
......@@ -80,493 +108,158 @@ 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_wmc += ( _ADD_C * ( 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_wmc += ( _ABS_C * ( x ) ); \
ops_cnt += ( _ABS_C * ( x ) ); \
inst_cnt[_ABS] += ( x ); \
{ \
static int pcnt; \
if ( !pcnt ) \
{ \
pcnt = 1; \
prom_cnt_wmc += ( _ABS_P * ( x ) ); \
} \
} \
} \
}
#define MULT( x ) \
{ \
{ \
ops_cnt_wmc += ( _MULT_C * ( x ) ); \
ops_cnt += ( _MULT_C * ( x ) ); \
inst_cnt[_MULT] += ( x ); \
{ \
static int pcnt; \
if ( !pcnt ) \
{ \
pcnt = 1; \
prom_cnt_wmc += ( _MULT_P * ( x ) ); \
} \
} \
} \
}
#define MAC( x ) \
{ \
{ \
ops_cnt_wmc += ( _MAC_C * ( x ) ); \
ops_cnt += ( _MAC_C * ( x ) ); \
inst_cnt[_MAC] += ( x ); \
{ \
static int pcnt; \
if ( !pcnt ) \
{ \
pcnt = 1; \
prom_cnt_wmc += ( _MAC_P * ( x ) ); \
} \
} \
} \
}
#define MOVE( x ) \
{ \
{ \
ops_cnt_wmc += ( _MOVE_C * ( x ) ); \
ops_cnt += ( _MOVE_C * ( x ) ); \
inst_cnt[_MOVE] += ( x ); \
{ \
static int pcnt; \
if ( !pcnt ) \
{ \
pcnt = 1; \
prom_cnt_wmc += ( _MOVE_P * ( x ) ); \
} \
} \
} \
}
#define STORE( x ) \
{ \
{ \
ops_cnt_wmc += ( _STORE_C * ( x ) ); \
ops_cnt += ( _STORE_C * ( x ) ); \
inst_cnt[_STORE] += ( x ); \
{ \
static int pcnt; \
if ( !pcnt ) \
{ \
pcnt = 1; \
prom_cnt_wmc += ( _STORE_P * ( x ) ); \
} \
} \
} \
}
#define LOGIC( x ) \
{ \
{ \
ops_cnt_wmc += ( _LOGIC_C * ( x ) ); \
ops_cnt += ( _LOGIC_C * ( x ) ); \
inst_cnt[_LOGIC] += ( x ); \
{ \
static int pcnt; \
if ( !pcnt ) \
{ \
pcnt = 1; \
prom_cnt_wmc += ( _LOGIC_P * ( x ) ); \
} \
} \
} \
}
#define SHIFT( x ) \
{ \
{ \
ops_cnt_wmc += ( _SHIFT_C * ( x ) ); \
ops_cnt += ( _SHIFT_C * ( x ) ); \
inst_cnt[_SHIFT] += ( x ); \
{ \
static int pcnt; \
if ( !pcnt ) \
{ \
pcnt = 1; \
prom_cnt_wmc += ( _SHIFT_P * ( x ) ); \
} \
} \
} \
}
#define BRANCH( x ) \
{ \
{ \
ops_cnt_wmc += ( _BRANCH_C * ( x ) ); \
ops_cnt += ( _BRANCH_C * ( x ) ); \
inst_cnt[_BRANCH] += ( x ); \
{ \
static int pcnt; \
if ( !pcnt ) \
{ \
pcnt = 1; \
prom_cnt_wmc += ( _BRANCH_P * ( x ) ); \
} \
} \
} \
}
#define DIV( x ) \
{ \
{ \
ops_cnt_wmc += ( _DIV_C * ( x ) ); \
ops_cnt += ( _DIV_C * ( x ) ); \
inst_cnt[_DIV] += ( x ); \
{ \
static int pcnt; \
if ( !pcnt ) \
{ \
pcnt = 1; \
prom_cnt_wmc += ( _DIV_P * ( x ) ); \
} \
} \
} \
}
#define SQRT( x ) \
{ \
{ \
ops_cnt_wmc += ( _SQRT_C * ( x ) ); \
ops_cnt += ( _SQRT_C * ( x ) ); \
inst_cnt[_SQRT] += ( x ); \
{ \
static int pcnt; \
if ( !pcnt ) \
{ \
pcnt = 1; \
prom_cnt_wmc += ( _SQRT_P * ( x ) ); \
} \
} \
} \
}
#define TRANS( x ) \
{ \
{ \
ops_cnt_wmc += ( _TRANS_C * ( x ) ); \
ops_cnt += ( _TRANS_C * ( x ) ); \
inst_cnt[_TRANS] += ( x ); \
{ \
static int pcnt; \
if ( !pcnt ) \
{ \
pcnt = 1; \
prom_cnt_wmc += ( _TRANS_P * ( x ) ); \
} \
} \
} \
}
#define LOOP( x ) \
{ \
{ \
ops_cnt_wmc += ( _LOOP_C * ( x ) ); \
ops_cnt += ( _LOOP_C * ( x ) ); \
inst_cnt[_LOOP] += ( x ); \
{ \
static int pcnt; \
if ( !pcnt ) \
{ \
pcnt = 1; \
prom_cnt_wmc += ( _LOOP_P * ( x ) ); \
} \
} \
} \
}
#define INDIRECT( x ) \
{ \
{ \
ops_cnt_wmc += ( _INDIRECT_C * ( x ) ); \
ops_cnt += ( _INDIRECT_C * ( x ) ); \
inst_cnt[_INDIRECT] += ( x ); \
{ \
static int pcnt; \
if ( !pcnt ) \
{ \
pcnt = 1; \
prom_cnt_wmc += ( _INDIRECT_P * ( x ) ); \
} \
} \
} \
}
#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; \
if ( !pcnt ) \
{ \
pcnt = 1; \
prom_cnt_wmc += ( _PTR_INIT_P * ( x ) ); \
} \
} \
} \
}
#define TEST( x ) \
{ \
{ \
ops_cnt_wmc += ( _TEST_C * ( x ) ); \
ops_cnt += ( _TEST_C * ( x ) ); \
inst_cnt[_TEST] += ( x ); \
{ \
static int pcnt; \
if ( !pcnt ) \
{ \
pcnt = 1; \
prom_cnt_wmc += ( _TEST_P * ( x ) ); \
} \
} \
} \
}
#define POWER( x ) \
{ \
{ \
ops_cnt_wmc += ( _POWER_C * ( x ) ); \
ops_cnt += ( _POWER_C * ( x ) ); \
inst_cnt[_POWER] += ( x ); \
{ \
static int pcnt; \
if ( !pcnt ) \
{ \
pcnt = 1; \
prom_cnt_wmc += ( _POWER_P * ( x ) ); \
} \
} \
} \
}
#define LOG( x ) \
{ \
{ \
ops_cnt_wmc += ( _LOG_C * ( x ) ); \
ops_cnt += ( _LOG_C * ( x ) ); \
inst_cnt[_LOG] += ( x ); \
{ \
static int pcnt; \
if ( !pcnt ) \
{ \
pcnt = 1; \
prom_cnt_wmc += ( _LOG_P * ( x ) ); \
} \
} \
} \
}
#define MISC( x ) \
{ \
{ \
ops_cnt_wmc += ( _MISC_C * ( x ) ); \
ops_cnt += ( _MISC_C * ( x ) ); \
inst_cnt[_MISC] += ( x ); \
{ \
static int pcnt; \
if ( !pcnt ) \
{ \
pcnt = 1; \
prom_cnt_wmc += ( _MISC_P * ( x ) ); \
} \
} \
} \
}
#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 ); \
{ \
static int pcnt; \
if ( !pcnt ) \
{ \
pcnt = 1; \
prom_cnt_wmc += ( _FUNC_P + _MOVE_P * ( x ) ); \
} \
} \
} \
}
#define DADD( x ) \
{ \
{ \
ops_cnt_wmc += ( 2 * _ADD_C * ( 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 DMULT( x ) \
{ \
{ \
ops_cnt_wmc += ( 2 * _MULT_C * ( 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 DMAC( x ) \
{ \
{ \
ops_cnt_wmc += ( 2 * _MAC_C * ( 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 DMOVE( x ) \
{ \
{ \
ops_cnt_wmc += ( 2 * _MOVE_C * ( 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 DSTORE( x ) \
{ \
{ \
ops_cnt_wmc += ( 2 * _STORE_C * ( 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 DLOGIC( x ) \
{ \
{ \
ops_cnt_wmc += ( 2 * _LOGIC_C * ( 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 DSHIFT( x ) \
{ \
{ \
ops_cnt_wmc += ( 2 * _SHIFT_C * ( 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 DDIV( x ) \
{ \
{ \
ops_cnt_wmc += ( 2 * _DIV_C * ( 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 DSQRT( x ) \
{ \
{ \
ops_cnt_wmc += ( 2 * _SQRT_C * ( 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 DTRANS( x ) \
{ \
{ \
ops_cnt_wmc += ( 2 * _TRANS_C * ( x ) ); \
ops_cnt += ( 2 * _TRANS_C * ( x ) ); \
inst_cnt[_TRANS] += ( x ); \
{ \
static int pcnt; \
if ( !pcnt ) \
{ \
pcnt = 1; \
prom_cnt_wmc += ( _TRANS_P * ( x ) ); \
} \
} \
} \
}
extern double ops_cnt_wmc;
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 );
#else
extern int cntr_push_pop;
......@@ -611,14 +304,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 )
......@@ -634,24 +319,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;
#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 Flag */
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 ) \
......@@ -683,7 +352,11 @@ static int wmc_flag_ = 0;
#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 */
......@@ -801,7 +474,6 @@ static int wmc_flag_ = 0;
#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
......@@ -917,7 +589,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:
......@@ -995,18 +666,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__ "<unknown>"
#endif
#elif defined( __GNUC__ )
#define __func__ __extension__ __FUNCTION__
#endif
#ifdef WMOPS
......@@ -1024,11 +683,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 +707,531 @@ void reset_stack( void );
#endif
/* Global counter variable for calculation of complexity weight */
typedef struct
{
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
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
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
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
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
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;
extern unsigned int currCounter;
extern long funcid_total_wmops_at_last_call_to_else;
extern char func_name_where_last_call_to_else_occurred[];
long TotalWeightedOperation( unsigned int counterId );
long DeltaWeightedOperation( unsigned int counterId );
void Reset_BASOP_WMOPS_counter( unsigned int counterId );
#endif
/*****************************************************************************
*
* 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 : 3
*
*****************************************************************************/
#ifndef WMOPS
#define IF( a ) if ( a )
#else /* ifndef WMOPS */
#define IF( a ) if ( incrIf( __func__ ), a )
void incrIf( const char *func_name );
#endif /* ifndef WMOPS */
/*****************************************************************************
*
* Function Name : ELSE
*
* Purpose :
*
* The macro ELSE should be used instead of the 'else' C statement.
*
* Complexity weight : 3
*
*****************************************************************************/
#ifndef WMOPS
#define ELSE else
#else /* ifndef WMOPS */
#define ELSE else if ( incrElse( __func__ ), 0 ); else
void incrElse( const char *func_name );
#endif /* ifndef WMOPS */
/*****************************************************************************
*
* Function Name : SWITCH
*
* Purpose :
*
* The macro SWITCH should be used instead of the 'switch' C statement.
*
* Complexity weight : 6
*
*****************************************************************************/
#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 : 2
*
*****************************************************************************/
#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 : 2
*
*****************************************************************************/
#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 : 2
*
*****************************************************************************/
#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 */
#ifdef CONTROL_CODE_OPS
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 */
#endif /* WMOPS_H */
......@@ -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"
extern const Word16 T_DIV_L_Frame[]; /*0Q15 * 2^-7 */
......
......@@ -31,14 +31,14 @@
*******************************************************************************************************/
#include <stdint.h>
#include <math.h>
#include <assert.h>
#include "options.h"
#include "prot.h"
#include "prot_fx.h"
#include "ivas_prot.h"
#include "ivas_prot_fx.h"
#include <math.h>
#include <assert.h>
#include "rom_com.h"
#include "wmc_auto.h"
......
......@@ -30,16 +30,17 @@
*******************************************************************************************************/
#include <assert.h>
#include <math.h>
#include <stdint.h>
#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 <assert.h>
#include <math.h>
#include <stdint.h>
#include "wmc_auto.h"
#include "prot_fx.h"
#include "ivas_prot_fx.h"
......
......@@ -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"
......
......@@ -31,16 +31,17 @@
*******************************************************************************************************/
#include <stdint.h>
#include "options.h"
#include <math.h>
#include <assert.h>
#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 <assert.h>
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
#include "ivas_rom_com_fx.h"
......