diff --git a/lib_com/options.h b/lib_com/options.h index 12580b20da408e223dfd8f55cf37b644bbf8be46..940cd1fe7776e070a461997ee0cb2f18f40c99af 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -54,12 +54,12 @@ #define SUPPORT_JBM_TRACEFILE /* Support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */ -/*#define WMOPS*/ /* Activate complexity and memory counters */ +#define WMOPS /* Activate complexity and memory counters */ #ifdef WMOPS -/*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ -/*#define WMOPS_DETAIL*/ /* Output detailed complexity printout for every function. Increases runtime overhead */ -/*#define WMOPS_WC_FRAME_ANALYSIS*/ /* Output detailed complexity analysis for the worst-case frame */ -/*#define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */ +#define WMOPS_PER_FRAME /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ +#define WMOPS_DETAIL /* Output detailed complexity printout for every function. Increases runtime overhead */ +#define WMOPS_WC_FRAME_ANALYSIS /* Output detailed complexity analysis for the worst-case frame */ +/*define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */ #endif /* #################### End DEBUGGING switches ############################ */ @@ -100,6 +100,7 @@ #define FIX_1481_HARDCODE_DIV /* FhG: hardcode division results in stereo_dmx_evs_init_encoder_fx() */ #define VEC_ARITH_OPT_v1 #define FIX_1486_IND_SHB_RES /* VA: Fix for issue 1486: align the usage of IND_SHB_RES_GS indices with float code */ +#define FIX_1511_POC_RENORM /* NTT: Fix for issue 1511: Renorm for POC. */ #define TEST_HR #define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions, ACELP low-band decoder */ diff --git a/lib_debug/debug.c b/lib_debug/debug.c index aafc1b66332ef261ec444a0c2ca4cd269cb1a325..ee6040fafc840e9ff52aac4e3418b02a6c8935cb 100644 --- a/lib_debug/debug.c +++ b/lib_debug/debug.c @@ -788,7 +788,7 @@ char *fname( #ifdef DEBUG_FORCE_DIR size_t len; len = strlen( tmp_fname ); - if (tmp_fname[len - 1] != '/' && tmp_fname[len - 1] != '\\' ) + if ( tmp_fname[len - 1] != '/' && tmp_fname[len - 1] != '\\' ) { /* add trailing '/' slash */ strcat( tmp_fname, "/" ); diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index d357c03dd7d09ed3721a2fd735b48c26978e6fec..9a4b371fc5fa8cd7bb9147da17355d409ae0819b 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -1018,7 +1018,7 @@ int push_stack( const char *filename, const char *fctname ) } /* Check, if This is the New Worst-Case RAM (stack + heap) */ - current_stack_size = ( int32_t )( ( ( ptr_base_stack - ptr_current_stack ) * sizeof( int16_t ) ) ); + current_stack_size = (int32_t) ( ( ( ptr_base_stack - ptr_current_stack ) * sizeof( int16_t ) ) ); if ( current_stack_size < 0 ) { @@ -1226,7 +1226,7 @@ void *mem_alloc( current_heap_size += ptr_record->block_size; /* Check, if this is the new Worst-Case RAM (stack + heap) */ - current_stack_size = ( int32_t )( ( ( ptr_base_stack - ptr_current_stack ) * sizeof( int16_t ) ) ); + current_stack_size = (int32_t) ( ( ( ptr_base_stack - ptr_current_stack ) * sizeof( int16_t ) ) ); if ( current_stack_size + current_heap_size > wc_ram_size ) { wc_ram_size = current_stack_size + current_heap_size; @@ -2416,7 +2416,7 @@ int EQ_64( long long int L64_var1, long long int L64_var2 ) #endif return F_ret; } -int NE_64( long long int L64_var1, long long int L64_var2 ) +int NE_64( long long int L64_var1, long long int L64_var2 ) { int F_ret = 0; @@ -2503,7 +2503,7 @@ void Reset_BASOP_WMOPS_counter( unsigned int counterId ) /* reset the current BASOP operation counter */ ptr = (unsigned int *) &multiCounter[counterId]; - for ( i = 0; i < (int) (sizeof(BASIC_OP) / sizeof(unsigned int)); i++ ) + for ( i = 0; i < (int) ( sizeof( BASIC_OP ) / sizeof( unsigned int ) ); i++ ) { *ptr++ = 0; } diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index 59bbc5bbf72f54a9ab64216be94d3c5f4ce57800..8c6396313f36143655da2a1e1e4d8613cec6cee8 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -34,7 +34,7 @@ #define ENH_64_BIT_OPERATOR #define ENH_U_32_BIT_OPERATOR #define COMPLEX_OPERATOR -#define CONTROL_CODE_OPS /* enable control code operators such as LT_16, GT_16, ... */ +#define CONTROL_CODE_OPS /* enable control code operators such as LT_16, GT_16, ... */ #define WMOPS_DISABLE_FCN_CALL_PENALIZATION /* do not count the complexity of function calls */ #ifdef WMOPS @@ -258,7 +258,7 @@ void update_mem( void ); { \ ops_cnt += ( 2 * _TRANS_C * ( x ) ); \ inst_cnt[_TRANS] += ( x ); \ - } + } #else @@ -335,29 +335,29 @@ extern int cntr_push_pop; #endif /* Define all Macros without '{' & '}' (None of these should be called externally!) */ -#define ABS_( x ) OP_COUNT_( _ABS, ( x ) ) -#define ADD_( x ) OP_COUNT_( _ADD, ( x ) ) -#define MULT_( x ) OP_COUNT_( _MULT, ( x ) ) -#define MAC_( x ) OP_COUNT_( _MAC, ( x ) ) -#define MOVE_( x ) OP_COUNT_( _MOVE, ( x ) ) -#define STORE_( x ) OP_COUNT_( _STORE, ( x ) ) -#define LOGIC_( x ) OP_COUNT_( _LOGIC, ( x ) ) -#define SHIFT_( x ) OP_COUNT_( _SHIFT, ( x ) ) -#define BRANCH_( x ) OP_COUNT_( _BRANCH, ( x ) ) -#define DIV_( x ) OP_COUNT_( _DIV, ( x ) ) -#define SQRT_( x ) OP_COUNT_( _SQRT, ( x ) ) -#define TRANS_( x ) OP_COUNT_( _TRANS, ( x ) ) +#define ABS_( x ) OP_COUNT_( _ABS, ( x ) ) +#define ADD_( x ) OP_COUNT_( _ADD, ( x ) ) +#define MULT_( x ) OP_COUNT_( _MULT, ( x ) ) +#define MAC_( x ) OP_COUNT_( _MAC, ( x ) ) +#define MOVE_( x ) OP_COUNT_( _MOVE, ( x ) ) +#define STORE_( x ) OP_COUNT_( _STORE, ( x ) ) +#define LOGIC_( x ) OP_COUNT_( _LOGIC, ( x ) ) +#define SHIFT_( x ) OP_COUNT_( _SHIFT, ( x ) ) +#define BRANCH_( x ) OP_COUNT_( _BRANCH, ( x ) ) +#define DIV_( x ) OP_COUNT_( _DIV, ( x ) ) +#define SQRT_( x ) OP_COUNT_( _SQRT, ( x ) ) +#define TRANS_( x ) OP_COUNT_( _TRANS, ( x ) ) #define POWER_( x ) TRANS_( x ) #define LOG_( x ) TRANS_( x ) -#define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) ) -#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) ) -#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) ) +#define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) ) +#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) ) +#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) ) #ifdef WMOPS_DISABLE_FCN_CALL_PENALIZATION -#define FUNC_( x ) ( x ) +#define FUNC_( x ) ( x ) #else -#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) ), OP_COUNT_( _FUNC, 1 ) ) +#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) ), OP_COUNT_( _FUNC, 1 ) ) #endif -#define MISC_( x ) ABS_( x ) +#define MISC_( x ) ABS_( x ) /* Math Operations */ #define abs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), abs ) @@ -401,8 +401,8 @@ extern int cntr_push_pop; #define frexp_ OP_COUNT_WRAPPER1_( MISC_( 2 ), frexp ) #define frexpf_ OP_COUNT_WRAPPER1_( MISC_( 2 ), frexpf ) -/* the macros below are instrumented versions of user-defined macros that might be used in the source code - representing some well-known and recognized mathematical operations (that are not defined in math.h) +/* the macros below are instrumented versions of user-defined macros that might be used in the source code + representing some well-known and recognized mathematical operations (that are not defined in math.h) Note: the 'wmc_flag_=wmc_flag_' is used to avoid warning: left-hand operand of comma expression has no effect with gcc */ #define min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), min( ( a ), ( b ) ) ) @@ -928,7 +928,7 @@ typedef struct unsigned int Madd_32_32_r; /* Complexity Weight of 1 */ unsigned int Msub_32_32; /* Complexity Weight of 1 */ unsigned int Msub_32_32_r; /* Complexity Weight of 1 */ -#endif /* #ifdef ENH_32_BIT_OPERATOR */ +#endif /* #ifdef ENH_32_BIT_OPERATOR */ #ifdef ENH_U_32_BIT_OPERATOR unsigned int UL_addNs; /* Complexity Weight of 1 */ @@ -938,7 +938,7 @@ typedef struct unsigned int Mpy_32_16_uu; /* Complexity Weight of 2 */ unsigned int norm_ul_float; /* Complexity Weight of 1 */ unsigned int UL_deposit_l; /* Complexity Weight of 1 */ -#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ +#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ #ifdef CONTROL_CODE_OPS unsigned int LT_16; /* Complexity Weight of 1 */ @@ -1095,7 +1095,9 @@ void incrIf( const char *func_name ); #ifndef WMOPS #define ELSE else #else /* ifndef WMOPS */ -#define ELSE else if ( incrElse( __func__ ), 0 ); else +#define ELSE \ + else if ( incrElse( __func__ ), 0 ); \ + else void incrElse( const char *func_name ); #endif /* ifndef WMOPS */ diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index 9d0bb92af23e900e4ea0d557e4322861bc69a886..f84f90e460f57ad34899f3a68b5df46d77f30ef7 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -98,6 +98,11 @@ #define STEREO_DMX_EVS_TRNS_EGY_FORGETTING_Q15 24576 +#ifdef FIX_1511_POC_RENORM +#define STEREO_DMX_EVS_POC_RENORM_TH 33554432 // 65536 << 9 +#define STEREO_DMX_EVS_POC_RENORM_SHIFT 3 +#endif + const Word32 ipd_ff_Q31[STEREO_DMX_EVS_NB_SUBBAND_MAX] = { 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, @@ -412,6 +417,19 @@ static void calc_poc_fx( Rr = L_add( L_add( specRr[i], Mpy_32_32_r( specLr[i], eps_cos ) ), Mpy_32_32_r( specLi[i], eps_sin ) ); Ri = L_add( L_sub( specRi[i], Mpy_32_32_r( specLr[i], eps_sin ) ), Mpy_32_32_r( specLi[i], eps_cos ) ); +#ifdef FIX_1511_POC_RENORM + IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Ri ), STEREO_DMX_EVS_POC_RENORM_TH ) ) ) + { + Lr = L_shl( Lr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Li = L_shl( Li, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + } +#endif + specPOr[i] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); specPOi[i] = L_sub( Mpy_32_32_r( Lr, Ri ), Mpy_32_32_r( Li, Rr ) ); // 2*spec_e @@ -424,6 +442,19 @@ static void calc_poc_fx( Rr = L_add( L_sub( specRr[j], Mpy_32_32_r( specLr[j], eps_cos ) ), Mpy_32_32_r( specLi[j], eps_sin ) ); Ri = L_sub( L_sub( specRi[j], Mpy_32_32_r( specLr[j], eps_sin ) ), Mpy_32_32_r( specLi[j], eps_cos ) ); +#ifdef FIX_1511_POC_RENORM + IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Ri ), STEREO_DMX_EVS_POC_RENORM_TH ) ) ) + { + Lr = L_shl( Lr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Li = L_shl( Li, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + } +#endif + specPOr[j] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); specPOi[j] = L_sub( Mpy_32_32_r( Lr, Ri ), Mpy_32_32_r( Li, Rr ) ); // 2*spec_e @@ -444,6 +475,20 @@ static void calc_poc_fx( Li = L_add( L_sub( specLi[i], Mpy_32_32_r( specRr[i], eps_sin ) ), Mpy_32_32_r( specRi[i], eps_cos ) ); Rr = L_add( L_add( specRr[i], Mpy_32_32_r( specLr[i], eps_cos ) ), Mpy_32_32_r( specLi[i], eps_sin ) ); Ri = L_add( L_sub( specRi[i], Mpy_32_32_r( specLr[i], eps_sin ) ), Mpy_32_32_r( specLi[i], eps_cos ) ); + +#ifdef FIX_1511_POC_RENORM + IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Ri ), STEREO_DMX_EVS_POC_RENORM_TH ) ) ) + { + Lr = L_shl( Lr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Li = L_shl( Li, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + } +#endif + specPOr[i] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); specPOi[i] = L_sub( Mpy_32_32_r( Lr, Ri ), Mpy_32_32_r( Li, Rr ) ); // 2*spec_e @@ -454,6 +499,20 @@ static void calc_poc_fx( Li = L_sub( L_sub( specLi[j], Mpy_32_32_r( specRr[j], eps_sin ) ), Mpy_32_32_r( specRi[j], eps_cos ) ); Rr = L_add( L_sub( specRr[j], Mpy_32_32_r( specLr[j], eps_cos ) ), Mpy_32_32_r( specLi[j], eps_sin ) ); Ri = L_sub( L_sub( specRi[j], Mpy_32_32_r( specLr[j], eps_sin ) ), Mpy_32_32_r( specLi[j], eps_cos ) ); + +#ifdef FIX_1511_POC_RENORM + IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && + ( LT_32( L_abs( Ri ), STEREO_DMX_EVS_POC_RENORM_TH ) ) ) + { + Lr = L_shl( Lr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Li = L_shl( Li, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + } +#endif + specPOr[j] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); specPOi[j] = L_sub( Mpy_32_32_r( Lr, Ri ), Mpy_32_32_r( Li, Rr ) ); // 2*spec_e @@ -1144,6 +1203,7 @@ static Word32 find_poc_peak_fx( Word16 itd_cand[CPE_CHANNELS], i, n, cnt[CPE_CHANNELS], Lh, peak_range, *on, *itdLR, prev_off[CPE_CHANNELS], eps_fx; Word32 Q_fx[CPE_CHANNELS], aQ_fx[CPE_CHANNELS], cQ_fx[CPE_CHANNELS], width_fx, *peak_width_fx, *peakQ_fx, cconfidence_fx, *P_fx, tmpf_fx, eps2_fx; Word16 tmpf_e = 0, eps2_e = 0, Q_e[CPE_CHANNELS], eps_e = 15, peakQ_e[CPE_CHANNELS]; + move16(); move16(); move16(); @@ -1535,6 +1595,7 @@ static void weighted_ave_fx( { Word16 i, len; Word32 gain_tmp_fx = 0, gain_sub_fx; + move32(); len = shr( input_frame, 4 ); gain_sub_fx = L_sub( gain_fx, old_gain_fx ); @@ -1569,6 +1630,7 @@ static void calc_energy_fx( Word32 E_32_fx, wnd_fx, wnd_diff_fx; Word16 i, adaptlen; Word64 E_fx; + /* Initialization */ E_fx = 0; move32(); @@ -1630,6 +1692,7 @@ static void calc_energy_fx( // *energy = *energy * ratio_float + ( E / (float) input_frame ) * ( 1.0f - ratio_float ); *energy_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( *energy_fx, ratio_float_fx ), *energy_fx_e, Mpy_32_32( temp32, L_sub( MAX_32, ratio_float_fx ) ), sub( 31, q_temp32 ), energy_fx_e ); move32(); + return; } @@ -1696,6 +1759,7 @@ static void create_M_signal_fx( Word32 temp32_1, temp32_2; Word16 temp_e; Word16 temp_e_1, temp_e_2; + /* Initialization */ eps_fx = 1024; // 1024.0f in Q0 move32(); @@ -2150,6 +2214,7 @@ void stereo_dmx_evs_enc_fx( } Copy_Scale_sig32_16( p_dmx_data, data, n_samples, 5 ); // Q26->Q15 + pop_wmops(); return;