From b917cfed05fd17e8d021e624346d4ed524514dfc Mon Sep 17 00:00:00 2001 From: Jonas Sv Date: Tue, 5 Mar 2024 16:02:29 +0100 Subject: [PATCH 01/12] fix for issue 1002 with debug code, under define FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE --- Workspace_msvc/decoder.vcxproj | 2 +- lib_com/options.h | 6 +- lib_dec/FEC_HQ_phase_ecu.c | 148 ++++++++++++++++++++++++++++++--- 3 files changed, 141 insertions(+), 15 deletions(-) diff --git a/Workspace_msvc/decoder.vcxproj b/Workspace_msvc/decoder.vcxproj index 2228349d5e..157f6dc94e 100644 --- a/Workspace_msvc/decoder.vcxproj +++ b/Workspace_msvc/decoder.vcxproj @@ -45,7 +45,7 @@ <_ProjectFileVersion>15.0.27428.2015 - ..\ + (ProjectDir)\..\ .\Debug_$(ProjectName)\ false false diff --git a/lib_com/options.h b/lib_com/options.h index 7065d18d91..b3f34cc810 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -48,7 +48,7 @@ /* ################### Start DEBUGGING switches ########################### */ #ifndef RELEASE -/*#define DEBUGGING*/ /* Activate debugging part of the code */ +/*#define DEBUGGING */ /*1002fix*/ /* Activate debugging part of the code */ #endif /*#define WMOPS*/ /* Activate complexity and memory counters */ /*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ @@ -163,7 +163,9 @@ #define FIX_1003_PARAMISM_BINAURAL_RECONFIG_USAN /* FhG: fix for #1003: fix USAN caused by ParamISM reconfig */ #define FIX_1001_ARI_HM_OVERFLOW /* FhG: fix for undef behaviour in in the harmonic TCX model arithmetic coder */ #define FIX_901_PARAMMC_DEAD_CODE /* FhG: issue 901: remove dead ParamMC code */ -#define FIX_1008_EXTORIENT_TARGET_INTERPOLATION /* FhG: issue #1008, external orientation init was wrong for 5ms */ +#define FIX_1008_EXTORIENT_TARGET_INTERPOLATION /* FhG: issue #1008, external orientation init was wrong for 5ms */ +#define FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE /* Eri: issue #1002, usan-value-out-of-range-for-int16 */ + /* #################### End BE switches ################################## */ diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c index ea604ef705..2fa0391fa7 100644 --- a/lib_dec/FEC_HQ_phase_ecu.c +++ b/lib_dec/FEC_HQ_phase_ecu.c @@ -288,9 +288,9 @@ static void trans_ana( *ph_dith = 0.0f; /* softly shift attenuation just a bit later for estimated "stable" music_content */ - burst_phdith_thresh = BURST_PHDITH_THRESH + (int16_t) ( est_mus_content * 1.0f + 0.5f ); - burst_att_thresh = BURST_ATT_THRESH + (int16_t) ( est_mus_content * 1.0f + 0.5f ); - att_per_frame = (float) ( ATT_PER_FRAME - (int16_t) ( est_mus_content * 1.0f + 0.5f ) ); /* only slighty less att for music */ + burst_phdith_thresh = BURST_PHDITH_THRESH + ( int16_t )( est_mus_content * 1.0f + 0.5f ); + burst_att_thresh = BURST_ATT_THRESH + ( int16_t )( est_mus_content * 1.0f + 0.5f ); + att_per_frame = (float) ( ATT_PER_FRAME - ( int16_t )( est_mus_content * 1.0f + 0.5f ) ); /* only slighty less att for music */ att_per_frame *= 0.1f; if ( burst_len > burst_phdith_thresh ) @@ -972,10 +972,13 @@ static void subst_spec( float one_peak_flag_mask; float alpha_local; float beta_local; +#ifdef FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE + float tmpf; +#endif sincos = sincos_t_ext + 128; - Lprot = (int16_t) ( L_PROT32k * output_frame / 640 ); + Lprot = ( int16_t )( L_PROT32k * output_frame / 640 ); Lprot_1 = 1.0f / Lprot; Lecu = output_frame * 2; @@ -1092,7 +1095,92 @@ static void subst_spec( } Xph = corr_phase[m]; - Xph_short = (int16_t) ( ( (int32_t) ( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; +#ifdef FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE + +#ifdef DEBUGGING + /* old : Xph_short = ( int16_t )( ( ( int32_t )( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; */ + /* the costly "%" modulo 32768 is not the correct way of obtaining the fractional part in Q10 resolution */ +#endif +#define WMC_TOOL_SKIP + tmpf = Xph * ( 1.0f / PI2 ); /* normalize : mult() with a constant */ + tmpf = ( 1024.0f ) * ( tmpf - floorf( tmpf ) ) + 0.5f; /* obtain fraction : floor(), sub(), mult(), rnd() , out: [0...1024.5[ */ + //tmpf = ( 1024.0f ) * ( tmpf - floorf( tmpf ) ) ; /* obtain fraction : floor(), sub(), mult() , out: [0...1023.x[ */ + Xph_short = ( (int16_t) tmpf ) & 0x03ff; /* mask to [0..1023]: s_and() */ + + MULT( 2 ); + MISC( 1 ); /* floor */ + ADD( 2 ); /* sub, rnd */ + LOGIC( 1 ); /* s_and */ +#undef WMC_TOOL_SKIP + +#ifdef DEBUGGING + if ( 1 ) + { + int32_t ii; + +#define ONE_OVER_PI2 ( 1.0f / ( PI2 ) ) + float Xph_norm = Xph * ( ONE_OVER_PI2 ); + /* extract IEEE single precision mantissa and exponent values */ + int32_t n; + float frac_3 = frexpf( Xph_norm, &n ); /* a math.h function, currently not counted by WMC tool */ + int32_t L_frac_3 = ( int32_t )( frac_3 * (float) ( 1L << 23 ) ); /* make into Q(23+n) */ + int32_t Xph_int32 = L_frac_3 >> ( 23 - 10 - n ); /* make into Q10 , no rounding */ + int16_t Xph_short_new_frexpf = ( int16_t )( Xph_int32 & 0x03ff ); /* mask out fractional part */ + + /* approx cost: mul, frexpf, mult, add, shr, s_and , similar to 1024.0*(x-floor(x)) */ + + int16_t Xph_short_new = Xph_short; + int16_t Xph_short_orig = ( int16_t )( ( ( int32_t )( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; + + + assert( ( (abs( Xph_short - Xph_short_orig) <= 1 ) || ( abs( (Xph_short+1)&1023 - (Xph_short_orig+1)&1023 ) <= 1 ) ) && "Xph_short diff larger than rounding !! "); + for ( ii = 0; ii < 2048; ii++ ) + + { + float Xph_tst = Xph + ( ii / 2048.0f ) * PI2; + + float Xph_short_flt0 = ( Xph_tst * ( 1.0f / PI2 ) ); /* (x+"fr")*/ + float Xph_short_flt0_fr = Xph_short_flt0 - (float) floor( (double) Xph_short_flt0 ); /* "fr" in the range [0..1.0[ */ + float Xph_short_flt1 = 1024.0f * ( Xph_short_flt0_fr ); + + float Xph_short_flt2round = (float) floor( (double) ( Xph_short_flt1 + 0.5f ) ); + Xph_short_flt2round -= ( Xph_short_flt2round == 1024.0f ? 1024.0f : 0.0f ); /* wrap 1.0 to 0.0 */ + + float Xph_short_flt2floor = (float) floor( (double) Xph_short_flt1 ); + + + if ( ii == 0 ) + { + fprintf( stderr, "\n frame=%5d, m=%3d, ii=%4d, tst= %.15g rad, Xph_short_orig=%4d, Xph_short_flt2round=%4d, Xph_shortflt2floor=%4d, Xph_short_new=%4d ", + frame, m, ii, Xph_tst, Xph_short_orig, (int16_t) Xph_short_flt2round, (int16_t) Xph_short_flt2floor, Xph_short_new ); + } + + if ( ii == 0 && Xph_short_orig != Xph_short_new && ( ( abs( Xph_short_orig - Xph_short_new ) > 1 ) || abs( (Xph_short_orig+1)&1023 - (Xph_short_new+1)&1023) > 1) ) + { + fprintf( stderr, " MISS !! Xph_short_orig != Xph_short_new && diff > 1 !!" ); + } + assert( Xph_short_flt2floor >= 0.0 ); + assert( Xph_short_flt2floor <= 1023.0 ); + + if ( ii == 0 && Xph_short_flt2round != Xph_short_flt2floor ) + { + // fprintf( stderr, "\n frame=%5d, m=%3d, ii=%4d, tst= %.15g rad, Xph_short_orig=%4d, Xph_short_flt2round=%4d, Xph_shortflt2floor=%4d, Xph_short_new=%4d ", + // frame, m, ii, Xph_tst, Xph_short_orig, (int16_t) Xph_short_flt2round, (int16_t) Xph_short_flt2floor, Xph_short_new ); + + fprintf( stderr, " rounding change by %.2f !!**", Xph_short_flt2round - Xph_short_flt2floor ); + } + assert( Xph_short_flt2round >= 0.0 ); + assert( Xph_short_flt2round <= 1023.0 ); + + } /* end for */ + } +#endif + +#else + Xph_short = ( int16_t )( ( ( int32_t )( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; +#endif + + if ( Xph_short >= 512 ) { sin_F = -sincos_t_ext[Xph_short - 512]; @@ -1136,7 +1224,43 @@ static void subst_spec( mag_chg_local *= 0.5f + ( 1.0f - ( 1.0f / PHASE_DITH ) * ph_dith ) * 0.5f; } - Xph_short = (int16_t) ( Xph * 512 / EVS_PI ) & 0x03ff; +#ifdef FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE + /* fractional phase of Xph converted to an integer in the range [0..1023] */ + /* in BASOP this is simply a truncation (through extract_l(Word32)) of a 32bit value at the Q16 bimal point + shifting to a 10 bit index */ + + /* old: Xph_short = ( int16_t )( Xph * 512 / EVS_PI ) & 0x03ff; */ /* yields out USAN of range for int16_t */ +#define WMC_TOOL_SKIP + tmpf = Xph * ( 1.0f / PI2 ); /* normalize : mult() with a constant */ + tmpf = ( 1024.0f ) * ( tmpf - floorf( tmpf ) ) + 0.5f; /* obtain fraction : floor(), sub(), mult(), rnd(), out: [0...1024.5[ */ + Xph_short = ( (int16_t) tmpf ) & 0x03ff; /* mask to [0..1023]: s_and() , out: [0...1023] */ + + MULT( 2 ); + MISC( 1 ); /* floor */ + ADD( 2 ); /* sub, rnd */ + LOGIC( 1 ); /* s_and */ +#undef WMC_TOOL_SKIP + +#ifdef DEBUGGING + { + int16_t Xph_short_bad; + int16_t Xph_short_corrected; + + + Xph_short_bad = ( int16_t )( Xph * 512 / EVS_PI ) & 0x03ff; /* yields out USAN of range for int16 */ + /* negative number can be created in cat to int16_t , but wraps back with &0x03ff in MSVC */ + + Xph_short_corrected = Xph_short; + + assert( Xph_short_corrected >= 0 && Xph_short_corrected <= 1023 ); + if ( Xph_short_bad != Xph_short_corrected ) + { + fprintf( stderr, "\n fix1002 actually active %5d -> %5d !!**", Xph_short_bad, Xph_short_corrected ); + } + } +#endif +#else + Xph_short = ( int16_t )( Xph * 512 / EVS_PI ) & 0x03ff; /* yields out of range for int16 */ +#endif if ( Xph_short >= 512 ) { @@ -1353,12 +1477,12 @@ static void rec_wtda( else { /* Smoothen onset of ECU frame */ - xf_len = (int16_t) ( (float) output_frame * N_ZERO_MDCT_NS / FRAME_SIZE_NS ) - ( output_frame - Lprot / 2 ); + xf_len = ( int16_t )( (float) output_frame * N_ZERO_MDCT_NS / FRAME_SIZE_NS ) - ( output_frame - Lprot / 2 ); p_ecu = xsubst_ + 2 * output_frame - Lprot + timesh; tbl_delta = 64.f / xf_len; /* 64 samples = 1/4 cycle in sincos_t */ for ( i = 0; i < xf_len; i++, p_ecu++ ) { - g = sincos_t[( (int16_t) ( i * tbl_delta ) )]; + g = sincos_t[( ( int16_t )( i * tbl_delta ) )]; g *= g; *p_ecu = g * ( *p_ecu ); } @@ -1530,7 +1654,7 @@ static void fec_ecu_pitch( /* Resampling to work at 8Khz */ fir_dwn( prevsynth, Asr_LP, prevsynth_LP, 2 * L, filt_size, *decimatefator ); /* resampling without delay */ - Lon20 = (int16_t) ( ( L / 20 ) / *decimatefator ); + Lon20 = ( int16_t )( ( L / 20 ) / *decimatefator ); /* Correlation analysis */ *min_corr = 0; @@ -1662,7 +1786,7 @@ static void fec_ecu_dft( Tfr[*Nfft - 1] = target[N - 1]; for ( i = 1; i < *Nfft - 1; i++ ) /* interpolation for FFT */ { - tmp_short = (int16_t) floor( i * tmp ); + tmp_short = (int16_t) floorf( i * tmp ); Tfr[i] = target[tmp_short] + ( (float) i * tmp - ( (float) tmp_short ) ) * ( target[tmp_short + 1] - target[tmp_short] ); } @@ -1951,7 +2075,7 @@ static void fec_noise_filling( kk = 0; } - Rnd_N_noise = (int16_t) ( (float) N_noise * tmp ); + Rnd_N_noise = ( int16_t )( (float) N_noise * tmp ); sinq( (const float) EVS_PI / ( 2.0f * (float) Rnd_N_noise ), (const float) EVS_PI / ( 4.0f * (float) Rnd_N_noise ), (const int16_t) Rnd_N_noise, SS ); @@ -2029,7 +2153,7 @@ static void fec_alg( fec_noise_filling( prevsynth, synthesis, output_frame, N * decimatefactor, HqVoicing, gapsynth, ni_seed_forfec, element_mode, old_out ); - n = (int16_t) ( (float) output_frame * N_ZERO_MDCT_NS / FRAME_SIZE_NS ); + n = ( int16_t )( (float) output_frame * N_ZERO_MDCT_NS / FRAME_SIZE_NS ); wtda( synthesis + ( output_frame - n ), ecu_rec, NULL, ALDO_WINDOW, ALDO_WINDOW, output_frame ); return; -- GitLab From 6f5e4add68b768657a5a151d949a88b675fa559b Mon Sep 17 00:00:00 2001 From: Jonas Sv Date: Tue, 5 Mar 2024 16:32:43 +0100 Subject: [PATCH 02/12] fix for issue 1002 removed debug code, active define FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE --- lib_com/options.h | 4 +- lib_dec/FEC_HQ_phase_ecu.c | 97 ++------------------------------------ 2 files changed, 5 insertions(+), 96 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index b3f34cc810..3c928025ed 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -48,7 +48,7 @@ /* ################### Start DEBUGGING switches ########################### */ #ifndef RELEASE -/*#define DEBUGGING */ /*1002fix*/ /* Activate debugging part of the code */ +/*#define DEBUGGING */ /* Activate debugging part of the code */ #endif /*#define WMOPS*/ /* Activate complexity and memory counters */ /*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ @@ -164,7 +164,7 @@ #define FIX_1001_ARI_HM_OVERFLOW /* FhG: fix for undef behaviour in in the harmonic TCX model arithmetic coder */ #define FIX_901_PARAMMC_DEAD_CODE /* FhG: issue 901: remove dead ParamMC code */ #define FIX_1008_EXTORIENT_TARGET_INTERPOLATION /* FhG: issue #1008, external orientation init was wrong for 5ms */ -#define FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE /* Eri: issue #1002, usan-value-out-of-range-for-int16 */ +#define FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE /* Eri: issue #1002, usan-value-out-of-range-for-int16, non-BE for PLC-conditions */ diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c index 2fa0391fa7..9fe4760c82 100644 --- a/lib_dec/FEC_HQ_phase_ecu.c +++ b/lib_dec/FEC_HQ_phase_ecu.c @@ -1096,86 +1096,16 @@ static void subst_spec( Xph = corr_phase[m]; #ifdef FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE - -#ifdef DEBUGGING - /* old : Xph_short = ( int16_t )( ( ( int32_t )( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; */ - /* the costly "%" modulo 32768 is not the correct way of obtaining the fractional part in Q10 resolution */ -#endif #define WMC_TOOL_SKIP - tmpf = Xph * ( 1.0f / PI2 ); /* normalize : mult() with a constant */ - tmpf = ( 1024.0f ) * ( tmpf - floorf( tmpf ) ) + 0.5f; /* obtain fraction : floor(), sub(), mult(), rnd() , out: [0...1024.5[ */ - //tmpf = ( 1024.0f ) * ( tmpf - floorf( tmpf ) ) ; /* obtain fraction : floor(), sub(), mult() , out: [0...1023.x[ */ - Xph_short = ( (int16_t) tmpf ) & 0x03ff; /* mask to [0..1023]: s_and() */ + tmpf = Xph * ( 1.0f / PI2 ); /* normalize : mult() with a constant */ + tmpf = ( 1024.0f ) * ( tmpf - floorf( tmpf ) ) + 0.5f; /* obtain fraction : floor(), sub(), mult(), rnd(), out: [0...1024.5[ */ + Xph_short = ( (int16_t) tmpf ) & 0x03ff; /* mask to [0..1023]: s_and() , out: [0...1023] */ MULT( 2 ); MISC( 1 ); /* floor */ ADD( 2 ); /* sub, rnd */ LOGIC( 1 ); /* s_and */ #undef WMC_TOOL_SKIP - -#ifdef DEBUGGING - if ( 1 ) - { - int32_t ii; - -#define ONE_OVER_PI2 ( 1.0f / ( PI2 ) ) - float Xph_norm = Xph * ( ONE_OVER_PI2 ); - /* extract IEEE single precision mantissa and exponent values */ - int32_t n; - float frac_3 = frexpf( Xph_norm, &n ); /* a math.h function, currently not counted by WMC tool */ - int32_t L_frac_3 = ( int32_t )( frac_3 * (float) ( 1L << 23 ) ); /* make into Q(23+n) */ - int32_t Xph_int32 = L_frac_3 >> ( 23 - 10 - n ); /* make into Q10 , no rounding */ - int16_t Xph_short_new_frexpf = ( int16_t )( Xph_int32 & 0x03ff ); /* mask out fractional part */ - - /* approx cost: mul, frexpf, mult, add, shr, s_and , similar to 1024.0*(x-floor(x)) */ - - int16_t Xph_short_new = Xph_short; - int16_t Xph_short_orig = ( int16_t )( ( ( int32_t )( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; - - - assert( ( (abs( Xph_short - Xph_short_orig) <= 1 ) || ( abs( (Xph_short+1)&1023 - (Xph_short_orig+1)&1023 ) <= 1 ) ) && "Xph_short diff larger than rounding !! "); - for ( ii = 0; ii < 2048; ii++ ) - - { - float Xph_tst = Xph + ( ii / 2048.0f ) * PI2; - - float Xph_short_flt0 = ( Xph_tst * ( 1.0f / PI2 ) ); /* (x+"fr")*/ - float Xph_short_flt0_fr = Xph_short_flt0 - (float) floor( (double) Xph_short_flt0 ); /* "fr" in the range [0..1.0[ */ - float Xph_short_flt1 = 1024.0f * ( Xph_short_flt0_fr ); - - float Xph_short_flt2round = (float) floor( (double) ( Xph_short_flt1 + 0.5f ) ); - Xph_short_flt2round -= ( Xph_short_flt2round == 1024.0f ? 1024.0f : 0.0f ); /* wrap 1.0 to 0.0 */ - - float Xph_short_flt2floor = (float) floor( (double) Xph_short_flt1 ); - - - if ( ii == 0 ) - { - fprintf( stderr, "\n frame=%5d, m=%3d, ii=%4d, tst= %.15g rad, Xph_short_orig=%4d, Xph_short_flt2round=%4d, Xph_shortflt2floor=%4d, Xph_short_new=%4d ", - frame, m, ii, Xph_tst, Xph_short_orig, (int16_t) Xph_short_flt2round, (int16_t) Xph_short_flt2floor, Xph_short_new ); - } - - if ( ii == 0 && Xph_short_orig != Xph_short_new && ( ( abs( Xph_short_orig - Xph_short_new ) > 1 ) || abs( (Xph_short_orig+1)&1023 - (Xph_short_new+1)&1023) > 1) ) - { - fprintf( stderr, " MISS !! Xph_short_orig != Xph_short_new && diff > 1 !!" ); - } - assert( Xph_short_flt2floor >= 0.0 ); - assert( Xph_short_flt2floor <= 1023.0 ); - - if ( ii == 0 && Xph_short_flt2round != Xph_short_flt2floor ) - { - // fprintf( stderr, "\n frame=%5d, m=%3d, ii=%4d, tst= %.15g rad, Xph_short_orig=%4d, Xph_short_flt2round=%4d, Xph_shortflt2floor=%4d, Xph_short_new=%4d ", - // frame, m, ii, Xph_tst, Xph_short_orig, (int16_t) Xph_short_flt2round, (int16_t) Xph_short_flt2floor, Xph_short_new ); - - fprintf( stderr, " rounding change by %.2f !!**", Xph_short_flt2round - Xph_short_flt2floor ); - } - assert( Xph_short_flt2round >= 0.0 ); - assert( Xph_short_flt2round <= 1023.0 ); - - } /* end for */ - } -#endif - #else Xph_short = ( int16_t )( ( ( int32_t )( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; #endif @@ -1227,8 +1157,6 @@ static void subst_spec( #ifdef FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE /* fractional phase of Xph converted to an integer in the range [0..1023] */ /* in BASOP this is simply a truncation (through extract_l(Word32)) of a 32bit value at the Q16 bimal point + shifting to a 10 bit index */ - - /* old: Xph_short = ( int16_t )( Xph * 512 / EVS_PI ) & 0x03ff; */ /* yields out USAN of range for int16_t */ #define WMC_TOOL_SKIP tmpf = Xph * ( 1.0f / PI2 ); /* normalize : mult() with a constant */ tmpf = ( 1024.0f ) * ( tmpf - floorf( tmpf ) ) + 0.5f; /* obtain fraction : floor(), sub(), mult(), rnd(), out: [0...1024.5[ */ @@ -1239,25 +1167,6 @@ static void subst_spec( ADD( 2 ); /* sub, rnd */ LOGIC( 1 ); /* s_and */ #undef WMC_TOOL_SKIP - -#ifdef DEBUGGING - { - int16_t Xph_short_bad; - int16_t Xph_short_corrected; - - - Xph_short_bad = ( int16_t )( Xph * 512 / EVS_PI ) & 0x03ff; /* yields out USAN of range for int16 */ - /* negative number can be created in cat to int16_t , but wraps back with &0x03ff in MSVC */ - - Xph_short_corrected = Xph_short; - - assert( Xph_short_corrected >= 0 && Xph_short_corrected <= 1023 ); - if ( Xph_short_bad != Xph_short_corrected ) - { - fprintf( stderr, "\n fix1002 actually active %5d -> %5d !!**", Xph_short_bad, Xph_short_corrected ); - } - } -#endif #else Xph_short = ( int16_t )( Xph * 512 / EVS_PI ) & 0x03ff; /* yields out of range for int16 */ #endif -- GitLab From fa2b3f818cf85721a5dee52c6b1b33222b1ffbc5 Mon Sep 17 00:00:00 2001 From: Jonas Sv Date: Tue, 5 Mar 2024 16:42:58 +0100 Subject: [PATCH 03/12] clang format --- lib_dec/FEC_HQ_phase_ecu.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c index 9fe4760c82..7459faaa0f 100644 --- a/lib_dec/FEC_HQ_phase_ecu.c +++ b/lib_dec/FEC_HQ_phase_ecu.c @@ -288,9 +288,9 @@ static void trans_ana( *ph_dith = 0.0f; /* softly shift attenuation just a bit later for estimated "stable" music_content */ - burst_phdith_thresh = BURST_PHDITH_THRESH + ( int16_t )( est_mus_content * 1.0f + 0.5f ); - burst_att_thresh = BURST_ATT_THRESH + ( int16_t )( est_mus_content * 1.0f + 0.5f ); - att_per_frame = (float) ( ATT_PER_FRAME - ( int16_t )( est_mus_content * 1.0f + 0.5f ) ); /* only slighty less att for music */ + burst_phdith_thresh = BURST_PHDITH_THRESH + (int16_t) ( est_mus_content * 1.0f + 0.5f ); + burst_att_thresh = BURST_ATT_THRESH + (int16_t) ( est_mus_content * 1.0f + 0.5f ); + att_per_frame = (float) ( ATT_PER_FRAME - (int16_t) ( est_mus_content * 1.0f + 0.5f ) ); /* only slighty less att for music */ att_per_frame *= 0.1f; if ( burst_len > burst_phdith_thresh ) @@ -978,7 +978,7 @@ static void subst_spec( sincos = sincos_t_ext + 128; - Lprot = ( int16_t )( L_PROT32k * output_frame / 640 ); + Lprot = (int16_t) ( L_PROT32k * output_frame / 640 ); Lprot_1 = 1.0f / Lprot; Lecu = output_frame * 2; @@ -1107,7 +1107,7 @@ static void subst_spec( LOGIC( 1 ); /* s_and */ #undef WMC_TOOL_SKIP #else - Xph_short = ( int16_t )( ( ( int32_t )( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; + Xph_short = (int16_t) ( ( (int32_t) ( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; #endif @@ -1168,7 +1168,7 @@ static void subst_spec( LOGIC( 1 ); /* s_and */ #undef WMC_TOOL_SKIP #else - Xph_short = ( int16_t )( Xph * 512 / EVS_PI ) & 0x03ff; /* yields out of range for int16 */ + Xph_short = (int16_t) ( Xph * 512 / EVS_PI ) & 0x03ff; /* yields out of range for int16 */ #endif if ( Xph_short >= 512 ) @@ -1386,12 +1386,12 @@ static void rec_wtda( else { /* Smoothen onset of ECU frame */ - xf_len = ( int16_t )( (float) output_frame * N_ZERO_MDCT_NS / FRAME_SIZE_NS ) - ( output_frame - Lprot / 2 ); + xf_len = (int16_t) ( (float) output_frame * N_ZERO_MDCT_NS / FRAME_SIZE_NS ) - ( output_frame - Lprot / 2 ); p_ecu = xsubst_ + 2 * output_frame - Lprot + timesh; tbl_delta = 64.f / xf_len; /* 64 samples = 1/4 cycle in sincos_t */ for ( i = 0; i < xf_len; i++, p_ecu++ ) { - g = sincos_t[( ( int16_t )( i * tbl_delta ) )]; + g = sincos_t[( (int16_t) ( i * tbl_delta ) )]; g *= g; *p_ecu = g * ( *p_ecu ); } @@ -1563,7 +1563,7 @@ static void fec_ecu_pitch( /* Resampling to work at 8Khz */ fir_dwn( prevsynth, Asr_LP, prevsynth_LP, 2 * L, filt_size, *decimatefator ); /* resampling without delay */ - Lon20 = ( int16_t )( ( L / 20 ) / *decimatefator ); + Lon20 = (int16_t) ( ( L / 20 ) / *decimatefator ); /* Correlation analysis */ *min_corr = 0; @@ -1984,7 +1984,7 @@ static void fec_noise_filling( kk = 0; } - Rnd_N_noise = ( int16_t )( (float) N_noise * tmp ); + Rnd_N_noise = (int16_t) ( (float) N_noise * tmp ); sinq( (const float) EVS_PI / ( 2.0f * (float) Rnd_N_noise ), (const float) EVS_PI / ( 4.0f * (float) Rnd_N_noise ), (const int16_t) Rnd_N_noise, SS ); @@ -2062,7 +2062,7 @@ static void fec_alg( fec_noise_filling( prevsynth, synthesis, output_frame, N * decimatefactor, HqVoicing, gapsynth, ni_seed_forfec, element_mode, old_out ); - n = ( int16_t )( (float) output_frame * N_ZERO_MDCT_NS / FRAME_SIZE_NS ); + n = (int16_t) ( (float) output_frame * N_ZERO_MDCT_NS / FRAME_SIZE_NS ); wtda( synthesis + ( output_frame - n ), ecu_rec, NULL, ALDO_WINDOW, ALDO_WINDOW, output_frame ); return; -- GitLab From 5831e5bff86959ff82cb91f413c22bbca77416a1 Mon Sep 17 00:00:00 2001 From: Jonas Sv Date: Tue, 5 Mar 2024 18:04:43 +0100 Subject: [PATCH 04/12] added element_mode != EVS_MONO logic --- lib_dec/FEC_HQ_phase_ecu.c | 52 ++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c index 7459faaa0f..2bd0fea8ab 100644 --- a/lib_dec/FEC_HQ_phase_ecu.c +++ b/lib_dec/FEC_HQ_phase_ecu.c @@ -1096,16 +1096,23 @@ static void subst_spec( Xph = corr_phase[m]; #ifdef FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE + if ( element_mode != EVS_MONO ) + { #define WMC_TOOL_SKIP - tmpf = Xph * ( 1.0f / PI2 ); /* normalize : mult() with a constant */ - tmpf = ( 1024.0f ) * ( tmpf - floorf( tmpf ) ) + 0.5f; /* obtain fraction : floor(), sub(), mult(), rnd(), out: [0...1024.5[ */ - Xph_short = ( (int16_t) tmpf ) & 0x03ff; /* mask to [0..1023]: s_and() , out: [0...1023] */ - - MULT( 2 ); - MISC( 1 ); /* floor */ - ADD( 2 ); /* sub, rnd */ - LOGIC( 1 ); /* s_and */ + tmpf = Xph * ( 1.0f / PI2 ); /* normalize : mult() with a constant */ + tmpf = ( 1024.0f * ( tmpf - floorf( tmpf ))) + 0.5f; /* obtain fraction : floor(), sub(), mult(), rnd(), out: [0...1024.5[ */ + Xph_short = ( (int16_t) tmpf ) & 0x03ff; /* mask to [0..1023]: s_and() , out: [0...1023] */ + + MULT( 2 ); + MISC( 1 ); /* floor */ + ADD( 2 ); /* sub, rnd */ + LOGIC( 1 ); /* s_and */ #undef WMC_TOOL_SKIP + } + else + { + Xph_short = ( int16_t )( ( ( int32_t )( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; /* WMC-costly % in use, no rounding */ + } #else Xph_short = (int16_t) ( ( (int32_t) ( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; #endif @@ -1155,20 +1162,27 @@ static void subst_spec( } #ifdef FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE - /* fractional phase of Xph converted to an integer in the range [0..1023] */ - /* in BASOP this is simply a truncation (through extract_l(Word32)) of a 32bit value at the Q16 bimal point + shifting to a 10 bit index */ + if ( element_mode != EVS_MONO ) + { + /* fractional phase of Xph converted to an integer in the range [0..1023] */ + /* in BASOP this is simply a truncation (through extract_l(Word32)) of a 32bit value at the Q16 bimal point + shifting to a 10 bit index */ #define WMC_TOOL_SKIP - tmpf = Xph * ( 1.0f / PI2 ); /* normalize : mult() with a constant */ - tmpf = ( 1024.0f ) * ( tmpf - floorf( tmpf ) ) + 0.5f; /* obtain fraction : floor(), sub(), mult(), rnd(), out: [0...1024.5[ */ - Xph_short = ( (int16_t) tmpf ) & 0x03ff; /* mask to [0..1023]: s_and() , out: [0...1023] */ - - MULT( 2 ); - MISC( 1 ); /* floor */ - ADD( 2 ); /* sub, rnd */ - LOGIC( 1 ); /* s_and */ + tmpf = Xph * ( 1.0f / PI2 ); /* normalize : mult() with a constant */ + tmpf = ( 1024.0f * ( tmpf - floorf( tmpf ) )) + 0.5f; /* obtain fraction : floor(), sub(), mult(), rnd(), out: [0...1024.5[ */ + Xph_short = ( (int16_t) tmpf ) & 0x03ff; /* mask to [0..1023]: s_and() , out: [0...1023] */ + + MULT( 2 ); + MISC( 1 ); /* floor */ + ADD( 2 ); /* sub, rnd */ + LOGIC( 1 ); /* s_and */ #undef WMC_TOOL_SKIP + } + else + { + Xph_short = ( int16_t )( Xph * 512 / EVS_PI ) & 0x03ff; /* NB! USAN warning for cast from float to int16_t, no rounding */ + } #else - Xph_short = (int16_t) ( Xph * 512 / EVS_PI ) & 0x03ff; /* yields out of range for int16 */ + Xph_short = (int16_t) ( Xph * 512 / EVS_PI ) & 0x03ff; #endif if ( Xph_short >= 512 ) -- GitLab From cf0bb74d550f6b5d2b3000699944ff95d2427368 Mon Sep 17 00:00:00 2001 From: Jonas Sv Date: Tue, 5 Mar 2024 18:08:52 +0100 Subject: [PATCH 05/12] clang format --- lib_dec/FEC_HQ_phase_ecu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c index 2bd0fea8ab..a4ddf56ac9 100644 --- a/lib_dec/FEC_HQ_phase_ecu.c +++ b/lib_dec/FEC_HQ_phase_ecu.c @@ -1100,7 +1100,7 @@ static void subst_spec( { #define WMC_TOOL_SKIP tmpf = Xph * ( 1.0f / PI2 ); /* normalize : mult() with a constant */ - tmpf = ( 1024.0f * ( tmpf - floorf( tmpf ))) + 0.5f; /* obtain fraction : floor(), sub(), mult(), rnd(), out: [0...1024.5[ */ + tmpf = ( 1024.0f * ( tmpf - floorf( tmpf ) ) ) + 0.5f; /* obtain fraction : floor(), sub(), mult(), rnd(), out: [0...1024.5[ */ Xph_short = ( (int16_t) tmpf ) & 0x03ff; /* mask to [0..1023]: s_and() , out: [0...1023] */ MULT( 2 ); @@ -1111,7 +1111,7 @@ static void subst_spec( } else { - Xph_short = ( int16_t )( ( ( int32_t )( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; /* WMC-costly % in use, no rounding */ + Xph_short = (int16_t) ( ( (int32_t) ( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; /* WMC-costly % in use, no rounding */ } #else Xph_short = (int16_t) ( ( (int32_t) ( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; @@ -1168,7 +1168,7 @@ static void subst_spec( /* in BASOP this is simply a truncation (through extract_l(Word32)) of a 32bit value at the Q16 bimal point + shifting to a 10 bit index */ #define WMC_TOOL_SKIP tmpf = Xph * ( 1.0f / PI2 ); /* normalize : mult() with a constant */ - tmpf = ( 1024.0f * ( tmpf - floorf( tmpf ) )) + 0.5f; /* obtain fraction : floor(), sub(), mult(), rnd(), out: [0...1024.5[ */ + tmpf = ( 1024.0f * ( tmpf - floorf( tmpf ) ) ) + 0.5f; /* obtain fraction : floor(), sub(), mult(), rnd(), out: [0...1024.5[ */ Xph_short = ( (int16_t) tmpf ) & 0x03ff; /* mask to [0..1023]: s_and() , out: [0...1023] */ MULT( 2 ); @@ -1179,10 +1179,10 @@ static void subst_spec( } else { - Xph_short = ( int16_t )( Xph * 512 / EVS_PI ) & 0x03ff; /* NB! USAN warning for cast from float to int16_t, no rounding */ + Xph_short = (int16_t) ( Xph * 512 / EVS_PI ) & 0x03ff; /* NB! USAN warning for cast from float to int16_t, no rounding */ } #else - Xph_short = (int16_t) ( Xph * 512 / EVS_PI ) & 0x03ff; + Xph_short = (int16_t) ( Xph * 512 / EVS_PI ) & 0x03ff; #endif if ( Xph_short >= 512 ) -- GitLab From fd47d26e6d98de5292faa80e5d976a6fb019b8f0 Mon Sep 17 00:00:00 2001 From: Jonas Sv Date: Wed, 6 Mar 2024 15:07:33 +0100 Subject: [PATCH 06/12] revert to a lower complexity likely BE(IVAS and EVS-Mono) version without rounding --- lib_dec/FEC_HQ_phase_ecu.c | 105 ++++++++++++++++++++++++------------- 1 file changed, 68 insertions(+), 37 deletions(-) diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c index a4ddf56ac9..f4c6505c9b 100644 --- a/lib_dec/FEC_HQ_phase_ecu.c +++ b/lib_dec/FEC_HQ_phase_ecu.c @@ -288,9 +288,9 @@ static void trans_ana( *ph_dith = 0.0f; /* softly shift attenuation just a bit later for estimated "stable" music_content */ - burst_phdith_thresh = BURST_PHDITH_THRESH + (int16_t) ( est_mus_content * 1.0f + 0.5f ); - burst_att_thresh = BURST_ATT_THRESH + (int16_t) ( est_mus_content * 1.0f + 0.5f ); - att_per_frame = (float) ( ATT_PER_FRAME - (int16_t) ( est_mus_content * 1.0f + 0.5f ) ); /* only slighty less att for music */ + burst_phdith_thresh = BURST_PHDITH_THRESH + ( int16_t )( est_mus_content * 1.0f + 0.5f ); + burst_att_thresh = BURST_ATT_THRESH + ( int16_t )( est_mus_content * 1.0f + 0.5f ); + att_per_frame = (float) ( ATT_PER_FRAME - ( int16_t )( est_mus_content * 1.0f + 0.5f ) ); /* only slighty less att for music */ att_per_frame *= 0.1f; if ( burst_len > burst_phdith_thresh ) @@ -978,7 +978,7 @@ static void subst_spec( sincos = sincos_t_ext + 128; - Lprot = (int16_t) ( L_PROT32k * output_frame / 640 ); + Lprot = ( int16_t )( L_PROT32k * output_frame / 640 ); Lprot_1 = 1.0f / Lprot; Lecu = output_frame * 2; @@ -1096,25 +1096,58 @@ static void subst_spec( Xph = corr_phase[m]; #ifdef FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE - if ( element_mode != EVS_MONO ) - { + /* BE , but with maintained dual mult of a constant, bnut mask the 10 bits in Word32, truncation */ +#define WMC_TOOL_SKIP + Xph_short = ( int16_t )( 0x000003ff & ( int32_t )( ( Xph * 512 ) / EVS_PI ) ); + MULT( 2 ); /* mult with constant, twice due to legacy precedence use */ + LOGIC( 1 ); /* L_and */ + MISC( 1 ); /* extract_l */ +#undef WMC_TOOL_SKIP +#if 1 + int16_t Xph_short_orig = ( int16_t )( ( ( int32_t )( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; /* BE: 2 mults, 1 modulo */ /* bad line(for WMC): WMC-costly modulo % in use, no rounding */ + int16_t Xph_short_1mult_nonbe = ( int16_t )( 0x000003ff & ( int32_t )( ( Xph * ( 512.0 / EVS_PI ) ) ) ); /* nonBE: single mult, mask the 10 bits in Word32 , still no rounding */ + int16_t Xph_short_1mult_rnd_nonbe = ( int16_t )( 0x000003ff & ( ( 1L + ( ( int32_t )( Xph * ( 1024.0 / EVS_PI ) ) ) ) >> 1 ) ); /* nonBE: single mult, add 1(round) shift1, mask the 10 bits in Word32 , i.e. with rounding */ + + assert( Xph_short == Xph_short_orig && "Xph_short == Xph_short_orig" ); +#endif + +#ifdef DEBUGGING + + int32_t Xph_long_new = ( int32_t )( Xph * ( 512 / EVS_PI ) ); /* mult by a single constant and float cast to int32_t */ + int32_t Xph_long_old = ( int32_t )( ( Xph * 512 ) / EVS_PI ); /* mult by 2 constants ! and float cast to int32_t , (Xph<<9) / pi */ + int32_t Xph_long = Xph_long_old; + + //assert( Xph_long_new == Xph_long_old && __func__ && " Xph_long_new != Xph_long_old" ); // mat differ due to order of division + + int32_t L_tmp1 = Xph_long % 32768; /* counts as division: 6-25 cycles */ + int32_t L_tmp2 = Xph_long & 0x00007fff; /* L_and mask : 1 cycle */ + // assert( L_tmp1 == L_tmp2 && __func__ && " L_tmp1 != L_tmp2 " ); + + + Xph_long = ( Xph_long & 0x00007fff ); /* L_and() equivalent to % 32768 */ + int16_t Xph_short_new1 = ( (int16_t) Xph_long ) & 0x03ff; + int16_t Xph_short_new2 = ( int16_t )( Xph_long_old & 0x000003ff ); + + //assert( Xph_short == Xph_short_new1 && __func__ && " Xph_short != Xph_short_new1" ); + //assert( Xph_short == Xph_short_new2 && __func__ && " Xph_short != Xph_short_new2" ); + +#if 0 + /* guarantee no wrap around to negative side of 32 bit signed integer value */ #define WMC_TOOL_SKIP tmpf = Xph * ( 1.0f / PI2 ); /* normalize : mult() with a constant */ tmpf = ( 1024.0f * ( tmpf - floorf( tmpf ) ) ) + 0.5f; /* obtain fraction : floor(), sub(), mult(), rnd(), out: [0...1024.5[ */ - Xph_short = ( (int16_t) tmpf ) & 0x03ff; /* mask to [0..1023]: s_and() , out: [0...1023] */ + int16_t Xph_short_flt_correct = ( (int16_t) tmpf ) & 0x03ff; /* mask to [0..1023]: s_and() , out: [0...1023] */ MULT( 2 ); MISC( 1 ); /* floor */ ADD( 2 ); /* sub, rnd */ LOGIC( 1 ); /* s_and */ #undef WMC_TOOL_SKIP - } - else - { - Xph_short = (int16_t) ( ( (int32_t) ( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; /* WMC-costly % in use, no rounding */ - } +#endif +#endif + #else - Xph_short = (int16_t) ( ( (int32_t) ( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; + Xph_short = ( int16_t )( ( ( int32_t )( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; #endif @@ -1162,30 +1195,28 @@ static void subst_spec( } #ifdef FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE - if ( element_mode != EVS_MONO ) - { - /* fractional phase of Xph converted to an integer in the range [0..1023] */ - /* in BASOP this is simply a truncation (through extract_l(Word32)) of a 32bit value at the Q16 bimal point + shifting to a 10 bit index */ #define WMC_TOOL_SKIP - tmpf = Xph * ( 1.0f / PI2 ); /* normalize : mult() with a constant */ - tmpf = ( 1024.0f * ( tmpf - floorf( tmpf ) ) ) + 0.5f; /* obtain fraction : floor(), sub(), mult(), rnd(), out: [0...1024.5[ */ - Xph_short = ( (int16_t) tmpf ) & 0x03ff; /* mask to [0..1023]: s_and() , out: [0...1023] */ - - MULT( 2 ); - MISC( 1 ); /* floor */ - ADD( 2 ); /* sub, rnd */ - LOGIC( 1 ); /* s_and */ + Xph_short = ( int16_t )( ( ( int32_t )( ( Xph * 512 ) / EVS_PI ) ) & 0x000003ff ); + MULT( 2 ); /* mult with constant, twice due to legacy precedence */ + LOGIC( 1 ); /* L_and */ + MISC( 1 ); /* extract_l */ #undef WMC_TOOL_SKIP - } - else - { - Xph_short = (int16_t) ( Xph * 512 / EVS_PI ) & 0x03ff; /* NB! USAN warning for cast from float to int16_t, no rounding */ - } +#if 1 + int16_t Xph_short_orig_ph_dith = ( int16_t )( Xph * 512 / EVS_PI ) & 0x03ff; /* USAN bad cast, bad dual mults */ + assert( Xph_short == Xph_short_orig_ph_dith ); +#endif + +#ifdef DEBUGGING + /* NB! USAN undefined behaviour warning for float-> short cast adressed, no rounding required here as phase is scrambled anyway */ + /* applied also EVS_MONO */ +#endif + + #else - Xph_short = (int16_t) ( Xph * 512 / EVS_PI ) & 0x03ff; + Xph_short = ( int16_t )( Xph * 512 / EVS_PI ) & 0x03ff; #endif - if ( Xph_short >= 512 ) + if ( Xph_short >= 512 ) { sin_F = -sincos_t_ext[Xph_short - 512]; if ( Xph_short < 768 ) @@ -1400,12 +1431,12 @@ static void rec_wtda( else { /* Smoothen onset of ECU frame */ - xf_len = (int16_t) ( (float) output_frame * N_ZERO_MDCT_NS / FRAME_SIZE_NS ) - ( output_frame - Lprot / 2 ); + xf_len = ( int16_t )( (float) output_frame * N_ZERO_MDCT_NS / FRAME_SIZE_NS ) - ( output_frame - Lprot / 2 ); p_ecu = xsubst_ + 2 * output_frame - Lprot + timesh; tbl_delta = 64.f / xf_len; /* 64 samples = 1/4 cycle in sincos_t */ for ( i = 0; i < xf_len; i++, p_ecu++ ) { - g = sincos_t[( (int16_t) ( i * tbl_delta ) )]; + g = sincos_t[( ( int16_t )( i * tbl_delta ) )]; g *= g; *p_ecu = g * ( *p_ecu ); } @@ -1577,7 +1608,7 @@ static void fec_ecu_pitch( /* Resampling to work at 8Khz */ fir_dwn( prevsynth, Asr_LP, prevsynth_LP, 2 * L, filt_size, *decimatefator ); /* resampling without delay */ - Lon20 = (int16_t) ( ( L / 20 ) / *decimatefator ); + Lon20 = ( int16_t )( ( L / 20 ) / *decimatefator ); /* Correlation analysis */ *min_corr = 0; @@ -1998,7 +2029,7 @@ static void fec_noise_filling( kk = 0; } - Rnd_N_noise = (int16_t) ( (float) N_noise * tmp ); + Rnd_N_noise = ( int16_t )( (float) N_noise * tmp ); sinq( (const float) EVS_PI / ( 2.0f * (float) Rnd_N_noise ), (const float) EVS_PI / ( 4.0f * (float) Rnd_N_noise ), (const int16_t) Rnd_N_noise, SS ); @@ -2076,7 +2107,7 @@ static void fec_alg( fec_noise_filling( prevsynth, synthesis, output_frame, N * decimatefactor, HqVoicing, gapsynth, ni_seed_forfec, element_mode, old_out ); - n = (int16_t) ( (float) output_frame * N_ZERO_MDCT_NS / FRAME_SIZE_NS ); + n = ( int16_t )( (float) output_frame * N_ZERO_MDCT_NS / FRAME_SIZE_NS ); wtda( synthesis + ( output_frame - n ), ecu_rec, NULL, ALDO_WINDOW, ALDO_WINDOW, output_frame ); return; -- GitLab From 74dc3e3a8074bfd1856943a20fd2e14738169599 Mon Sep 17 00:00:00 2001 From: Jonas Sv Date: Wed, 6 Mar 2024 15:23:09 +0100 Subject: [PATCH 07/12] clang format --- lib_dec/FEC_HQ_phase_ecu.c | 54 +++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c index f4c6505c9b..fb0fe74dca 100644 --- a/lib_dec/FEC_HQ_phase_ecu.c +++ b/lib_dec/FEC_HQ_phase_ecu.c @@ -288,9 +288,9 @@ static void trans_ana( *ph_dith = 0.0f; /* softly shift attenuation just a bit later for estimated "stable" music_content */ - burst_phdith_thresh = BURST_PHDITH_THRESH + ( int16_t )( est_mus_content * 1.0f + 0.5f ); - burst_att_thresh = BURST_ATT_THRESH + ( int16_t )( est_mus_content * 1.0f + 0.5f ); - att_per_frame = (float) ( ATT_PER_FRAME - ( int16_t )( est_mus_content * 1.0f + 0.5f ) ); /* only slighty less att for music */ + burst_phdith_thresh = BURST_PHDITH_THRESH + (int16_t) ( est_mus_content * 1.0f + 0.5f ); + burst_att_thresh = BURST_ATT_THRESH + (int16_t) ( est_mus_content * 1.0f + 0.5f ); + att_per_frame = (float) ( ATT_PER_FRAME - (int16_t) ( est_mus_content * 1.0f + 0.5f ) ); /* only slighty less att for music */ att_per_frame *= 0.1f; if ( burst_len > burst_phdith_thresh ) @@ -978,7 +978,7 @@ static void subst_spec( sincos = sincos_t_ext + 128; - Lprot = ( int16_t )( L_PROT32k * output_frame / 640 ); + Lprot = (int16_t) ( L_PROT32k * output_frame / 640 ); Lprot_1 = 1.0f / Lprot; Lecu = output_frame * 2; @@ -1098,38 +1098,38 @@ static void subst_spec( #ifdef FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE /* BE , but with maintained dual mult of a constant, bnut mask the 10 bits in Word32, truncation */ #define WMC_TOOL_SKIP - Xph_short = ( int16_t )( 0x000003ff & ( int32_t )( ( Xph * 512 ) / EVS_PI ) ); + Xph_short = (int16_t) ( 0x000003ff & (int32_t) ( ( Xph * 512 ) / EVS_PI ) ); MULT( 2 ); /* mult with constant, twice due to legacy precedence use */ LOGIC( 1 ); /* L_and */ MISC( 1 ); /* extract_l */ #undef WMC_TOOL_SKIP #if 1 - int16_t Xph_short_orig = ( int16_t )( ( ( int32_t )( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; /* BE: 2 mults, 1 modulo */ /* bad line(for WMC): WMC-costly modulo % in use, no rounding */ - int16_t Xph_short_1mult_nonbe = ( int16_t )( 0x000003ff & ( int32_t )( ( Xph * ( 512.0 / EVS_PI ) ) ) ); /* nonBE: single mult, mask the 10 bits in Word32 , still no rounding */ - int16_t Xph_short_1mult_rnd_nonbe = ( int16_t )( 0x000003ff & ( ( 1L + ( ( int32_t )( Xph * ( 1024.0 / EVS_PI ) ) ) ) >> 1 ) ); /* nonBE: single mult, add 1(round) shift1, mask the 10 bits in Word32 , i.e. with rounding */ + int16_t Xph_short_orig = (int16_t) ( ( (int32_t) ( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; /* BE: 2 mults, 1 modulo */ /* bad line(for WMC): WMC-costly modulo % in use, no rounding */ + int16_t Xph_short_1mult_nonbe = (int16_t) ( 0x000003ff & (int32_t) ( ( Xph * ( 512.0 / EVS_PI ) ) ) ); /* nonBE: single mult, mask the 10 bits in Word32 , still no rounding */ + int16_t Xph_short_1mult_rnd_nonbe = (int16_t) ( 0x000003ff & ( ( 1L + ( (int32_t) ( Xph * ( 1024.0 / EVS_PI ) ) ) ) >> 1 ) ); /* nonBE: single mult, add 1(round) shift1, mask the 10 bits in Word32 , i.e. with rounding */ assert( Xph_short == Xph_short_orig && "Xph_short == Xph_short_orig" ); #endif #ifdef DEBUGGING - int32_t Xph_long_new = ( int32_t )( Xph * ( 512 / EVS_PI ) ); /* mult by a single constant and float cast to int32_t */ - int32_t Xph_long_old = ( int32_t )( ( Xph * 512 ) / EVS_PI ); /* mult by 2 constants ! and float cast to int32_t , (Xph<<9) / pi */ + int32_t Xph_long_new = (int32_t) ( Xph * ( 512 / EVS_PI ) ); /* mult by a single constant and float cast to int32_t */ + int32_t Xph_long_old = (int32_t) ( ( Xph * 512 ) / EVS_PI ); /* mult by 2 constants ! and float cast to int32_t , (Xph<<9) / pi */ int32_t Xph_long = Xph_long_old; - //assert( Xph_long_new == Xph_long_old && __func__ && " Xph_long_new != Xph_long_old" ); // mat differ due to order of division + // assert( Xph_long_new == Xph_long_old && __func__ && " Xph_long_new != Xph_long_old" ); // mat differ due to order of division int32_t L_tmp1 = Xph_long % 32768; /* counts as division: 6-25 cycles */ int32_t L_tmp2 = Xph_long & 0x00007fff; /* L_and mask : 1 cycle */ - // assert( L_tmp1 == L_tmp2 && __func__ && " L_tmp1 != L_tmp2 " ); + // assert( L_tmp1 == L_tmp2 && __func__ && " L_tmp1 != L_tmp2 " ); Xph_long = ( Xph_long & 0x00007fff ); /* L_and() equivalent to % 32768 */ int16_t Xph_short_new1 = ( (int16_t) Xph_long ) & 0x03ff; - int16_t Xph_short_new2 = ( int16_t )( Xph_long_old & 0x000003ff ); + int16_t Xph_short_new2 = (int16_t) ( Xph_long_old & 0x000003ff ); - //assert( Xph_short == Xph_short_new1 && __func__ && " Xph_short != Xph_short_new1" ); - //assert( Xph_short == Xph_short_new2 && __func__ && " Xph_short != Xph_short_new2" ); + // assert( Xph_short == Xph_short_new1 && __func__ && " Xph_short != Xph_short_new1" ); + // assert( Xph_short == Xph_short_new2 && __func__ && " Xph_short != Xph_short_new2" ); #if 0 /* guarantee no wrap around to negative side of 32 bit signed integer value */ @@ -1143,11 +1143,11 @@ static void subst_spec( ADD( 2 ); /* sub, rnd */ LOGIC( 1 ); /* s_and */ #undef WMC_TOOL_SKIP -#endif +#endif #endif #else - Xph_short = ( int16_t )( ( ( int32_t )( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; + Xph_short = (int16_t) ( ( (int32_t) ( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; #endif @@ -1196,14 +1196,14 @@ static void subst_spec( #ifdef FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE #define WMC_TOOL_SKIP - Xph_short = ( int16_t )( ( ( int32_t )( ( Xph * 512 ) / EVS_PI ) ) & 0x000003ff ); + Xph_short = (int16_t) ( ( (int32_t) ( ( Xph * 512 ) / EVS_PI ) ) & 0x000003ff ); MULT( 2 ); /* mult with constant, twice due to legacy precedence */ LOGIC( 1 ); /* L_and */ MISC( 1 ); /* extract_l */ #undef WMC_TOOL_SKIP #if 1 - int16_t Xph_short_orig_ph_dith = ( int16_t )( Xph * 512 / EVS_PI ) & 0x03ff; /* USAN bad cast, bad dual mults */ - assert( Xph_short == Xph_short_orig_ph_dith ); + int16_t Xph_short_orig_ph_dith = (int16_t) ( Xph * 512 / EVS_PI ) & 0x03ff; /* USAN bad cast, bad dual mults */ + assert( Xph_short == Xph_short_orig_ph_dith ); #endif #ifdef DEBUGGING @@ -1213,10 +1213,10 @@ static void subst_spec( #else - Xph_short = ( int16_t )( Xph * 512 / EVS_PI ) & 0x03ff; + Xph_short = (int16_t) ( Xph * 512 / EVS_PI ) & 0x03ff; #endif - if ( Xph_short >= 512 ) + if ( Xph_short >= 512 ) { sin_F = -sincos_t_ext[Xph_short - 512]; if ( Xph_short < 768 ) @@ -1431,12 +1431,12 @@ static void rec_wtda( else { /* Smoothen onset of ECU frame */ - xf_len = ( int16_t )( (float) output_frame * N_ZERO_MDCT_NS / FRAME_SIZE_NS ) - ( output_frame - Lprot / 2 ); + xf_len = (int16_t) ( (float) output_frame * N_ZERO_MDCT_NS / FRAME_SIZE_NS ) - ( output_frame - Lprot / 2 ); p_ecu = xsubst_ + 2 * output_frame - Lprot + timesh; tbl_delta = 64.f / xf_len; /* 64 samples = 1/4 cycle in sincos_t */ for ( i = 0; i < xf_len; i++, p_ecu++ ) { - g = sincos_t[( ( int16_t )( i * tbl_delta ) )]; + g = sincos_t[( (int16_t) ( i * tbl_delta ) )]; g *= g; *p_ecu = g * ( *p_ecu ); } @@ -1608,7 +1608,7 @@ static void fec_ecu_pitch( /* Resampling to work at 8Khz */ fir_dwn( prevsynth, Asr_LP, prevsynth_LP, 2 * L, filt_size, *decimatefator ); /* resampling without delay */ - Lon20 = ( int16_t )( ( L / 20 ) / *decimatefator ); + Lon20 = (int16_t) ( ( L / 20 ) / *decimatefator ); /* Correlation analysis */ *min_corr = 0; @@ -2029,7 +2029,7 @@ static void fec_noise_filling( kk = 0; } - Rnd_N_noise = ( int16_t )( (float) N_noise * tmp ); + Rnd_N_noise = (int16_t) ( (float) N_noise * tmp ); sinq( (const float) EVS_PI / ( 2.0f * (float) Rnd_N_noise ), (const float) EVS_PI / ( 4.0f * (float) Rnd_N_noise ), (const int16_t) Rnd_N_noise, SS ); @@ -2107,7 +2107,7 @@ static void fec_alg( fec_noise_filling( prevsynth, synthesis, output_frame, N * decimatefactor, HqVoicing, gapsynth, ni_seed_forfec, element_mode, old_out ); - n = ( int16_t )( (float) output_frame * N_ZERO_MDCT_NS / FRAME_SIZE_NS ); + n = (int16_t) ( (float) output_frame * N_ZERO_MDCT_NS / FRAME_SIZE_NS ); wtda( synthesis + ( output_frame - n ), ecu_rec, NULL, ALDO_WINDOW, ALDO_WINDOW, output_frame ); return; -- GitLab From 0ad22373a08625c810f91aa227e9f0ca48b7035e Mon Sep 17 00:00:00 2001 From: Jonas Sv Date: Wed, 6 Mar 2024 15:39:45 +0100 Subject: [PATCH 08/12] removed debug code and alt2(with rounding) code --- lib_dec/FEC_HQ_phase_ecu.c | 56 +------------------------------------- 1 file changed, 1 insertion(+), 55 deletions(-) diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c index fb0fe74dca..4313fb45a0 100644 --- a/lib_dec/FEC_HQ_phase_ecu.c +++ b/lib_dec/FEC_HQ_phase_ecu.c @@ -1096,56 +1096,13 @@ static void subst_spec( Xph = corr_phase[m]; #ifdef FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE - /* BE , but with maintained dual mult of a constant, bnut mask the 10 bits in Word32, truncation */ + /* BE , but with maintained dual mult of a constant, mask the 10 bits in Word32, truncation */ #define WMC_TOOL_SKIP Xph_short = (int16_t) ( 0x000003ff & (int32_t) ( ( Xph * 512 ) / EVS_PI ) ); MULT( 2 ); /* mult with constant, twice due to legacy precedence use */ LOGIC( 1 ); /* L_and */ MISC( 1 ); /* extract_l */ #undef WMC_TOOL_SKIP -#if 1 - int16_t Xph_short_orig = (int16_t) ( ( (int32_t) ( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; /* BE: 2 mults, 1 modulo */ /* bad line(for WMC): WMC-costly modulo % in use, no rounding */ - int16_t Xph_short_1mult_nonbe = (int16_t) ( 0x000003ff & (int32_t) ( ( Xph * ( 512.0 / EVS_PI ) ) ) ); /* nonBE: single mult, mask the 10 bits in Word32 , still no rounding */ - int16_t Xph_short_1mult_rnd_nonbe = (int16_t) ( 0x000003ff & ( ( 1L + ( (int32_t) ( Xph * ( 1024.0 / EVS_PI ) ) ) ) >> 1 ) ); /* nonBE: single mult, add 1(round) shift1, mask the 10 bits in Word32 , i.e. with rounding */ - - assert( Xph_short == Xph_short_orig && "Xph_short == Xph_short_orig" ); -#endif - -#ifdef DEBUGGING - - int32_t Xph_long_new = (int32_t) ( Xph * ( 512 / EVS_PI ) ); /* mult by a single constant and float cast to int32_t */ - int32_t Xph_long_old = (int32_t) ( ( Xph * 512 ) / EVS_PI ); /* mult by 2 constants ! and float cast to int32_t , (Xph<<9) / pi */ - int32_t Xph_long = Xph_long_old; - - // assert( Xph_long_new == Xph_long_old && __func__ && " Xph_long_new != Xph_long_old" ); // mat differ due to order of division - - int32_t L_tmp1 = Xph_long % 32768; /* counts as division: 6-25 cycles */ - int32_t L_tmp2 = Xph_long & 0x00007fff; /* L_and mask : 1 cycle */ - // assert( L_tmp1 == L_tmp2 && __func__ && " L_tmp1 != L_tmp2 " ); - - - Xph_long = ( Xph_long & 0x00007fff ); /* L_and() equivalent to % 32768 */ - int16_t Xph_short_new1 = ( (int16_t) Xph_long ) & 0x03ff; - int16_t Xph_short_new2 = (int16_t) ( Xph_long_old & 0x000003ff ); - - // assert( Xph_short == Xph_short_new1 && __func__ && " Xph_short != Xph_short_new1" ); - // assert( Xph_short == Xph_short_new2 && __func__ && " Xph_short != Xph_short_new2" ); - -#if 0 - /* guarantee no wrap around to negative side of 32 bit signed integer value */ -#define WMC_TOOL_SKIP - tmpf = Xph * ( 1.0f / PI2 ); /* normalize : mult() with a constant */ - tmpf = ( 1024.0f * ( tmpf - floorf( tmpf ) ) ) + 0.5f; /* obtain fraction : floor(), sub(), mult(), rnd(), out: [0...1024.5[ */ - int16_t Xph_short_flt_correct = ( (int16_t) tmpf ) & 0x03ff; /* mask to [0..1023]: s_and() , out: [0...1023] */ - - MULT( 2 ); - MISC( 1 ); /* floor */ - ADD( 2 ); /* sub, rnd */ - LOGIC( 1 ); /* s_and */ -#undef WMC_TOOL_SKIP -#endif -#endif - #else Xph_short = (int16_t) ( ( (int32_t) ( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; #endif @@ -1201,17 +1158,6 @@ static void subst_spec( LOGIC( 1 ); /* L_and */ MISC( 1 ); /* extract_l */ #undef WMC_TOOL_SKIP -#if 1 - int16_t Xph_short_orig_ph_dith = (int16_t) ( Xph * 512 / EVS_PI ) & 0x03ff; /* USAN bad cast, bad dual mults */ - assert( Xph_short == Xph_short_orig_ph_dith ); -#endif - -#ifdef DEBUGGING - /* NB! USAN undefined behaviour warning for float-> short cast adressed, no rounding required here as phase is scrambled anyway */ - /* applied also EVS_MONO */ -#endif - - #else Xph_short = (int16_t) ( Xph * 512 / EVS_PI ) & 0x03ff; #endif -- GitLab From 34ec6f28cc62b4a42c4cff0ed403c23a19676c9b Mon Sep 17 00:00:00 2001 From: Jonas Sv Date: Wed, 6 Mar 2024 15:47:15 +0100 Subject: [PATCH 09/12] removed further debug code --- lib_com/options.h | 2 +- lib_dec/FEC_HQ_phase_ecu.c | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8d354de568..fafd80a242 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -170,7 +170,7 @@ #define FIX_998_UNUSED_FUNCTION /* FhG: issue 998: delete unused funtion ivas_dirac_dec_get_response_split_order */ #define FIX_1009_ISM_NONDIEGETIC_PANNING /* FhG: issue #1009: use correct object buffer for ISM1 non-diegetic pan */ #define FIX_993_REMOVE_SBA_GET_ORDER /* VA: issue 993: remove unused function ivas_sba_get_order() */ -#define FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE /* Eri: issue #1002, usan-value-out-of-range-for-int16, non-BE for PLC-conditions */ +#define FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE /* Eri: issue #1002, usan-value-out-of-range-for-int16, kept BE for PLC-conditions */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c index 4313fb45a0..f376aca8ea 100644 --- a/lib_dec/FEC_HQ_phase_ecu.c +++ b/lib_dec/FEC_HQ_phase_ecu.c @@ -972,10 +972,6 @@ static void subst_spec( float one_peak_flag_mask; float alpha_local; float beta_local; -#ifdef FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE - float tmpf; -#endif - sincos = sincos_t_ext + 128; Lprot = (int16_t) ( L_PROT32k * output_frame / 640 ); -- GitLab From cf8c7e2ba8a5db428dc123ae636efe08699319cc Mon Sep 17 00:00:00 2001 From: Jonas Sv Date: Wed, 6 Mar 2024 16:12:35 +0100 Subject: [PATCH 10/12] rvered chaneg to decoder project file --- Workspace_msvc/decoder.vcxproj | 2 +- lib_dec/FEC_HQ_phase_ecu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Workspace_msvc/decoder.vcxproj b/Workspace_msvc/decoder.vcxproj index 157f6dc94e..2228349d5e 100644 --- a/Workspace_msvc/decoder.vcxproj +++ b/Workspace_msvc/decoder.vcxproj @@ -45,7 +45,7 @@ <_ProjectFileVersion>15.0.27428.2015 - (ProjectDir)\..\ + ..\ .\Debug_$(ProjectName)\ false false diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c index f376aca8ea..c98222be76 100644 --- a/lib_dec/FEC_HQ_phase_ecu.c +++ b/lib_dec/FEC_HQ_phase_ecu.c @@ -1682,7 +1682,7 @@ static void fec_ecu_dft( Tfr[*Nfft - 1] = target[N - 1]; for ( i = 1; i < *Nfft - 1; i++ ) /* interpolation for FFT */ { - tmp_short = (int16_t) floorf( i * tmp ); + tmp_short = (int16_t) floor( i * tmp ); Tfr[i] = target[tmp_short] + ( (float) i * tmp - ( (float) tmp_short ) ) * ( target[tmp_short + 1] - target[tmp_short] ); } -- GitLab From 79c618cbb921cd072de69834e23db3cbbade32b7 Mon Sep 17 00:00:00 2001 From: Jonas Sv Date: Wed, 6 Mar 2024 16:39:23 +0100 Subject: [PATCH 11/12] corrected automerged switches in options.h --- lib_com/options.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index fafd80a242..aae6e7807a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -156,16 +156,6 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ /*#define SPLIT_REND_WITH_HEAD_ROT */ /* Dlb,FhG: Split Rendering contributions 21 and 35 */ - -#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ -#define FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI /* FhG: fix and undef behaviour bug in the harmonic TCX model arithmetic coder */ -#define FIX_699_FILE_READER_JBM_TSM /* VA: issue 699: complement FileReader_getFilePath() logic for TSM and JBM */ -#define FIX_997_REMOVE_SPAR_DEC_UPMIXER /* VA: issue 997: remove obsolete function ivas_spar_dec_upmixer() */ -#define FIX_944_REMOVE_LS_RENDERER_CALL_IN_STEREO /* VA: issue 994: remove an obsolete call of function ivas_ls_setup_conversion() in stereo */ -#define FIX_1003_PARAMISM_BINAURAL_RECONFIG_USAN /* FhG: fix for #1003: fix USAN caused by ParamISM reconfig */ -#define FIX_1001_ARI_HM_OVERFLOW /* FhG: fix for undef behaviour in in the harmonic TCX model arithmetic coder */ -#define FIX_901_PARAMMC_DEAD_CODE /* FhG: issue 901: remove dead ParamMC code */ -#define FIX_1008_EXTORIENT_TARGET_INTERPOLATION /* FhG: issue #1008, external orientation init was wrong for 5ms */ #define FIX_998_UNUSED_FUNCTION /* FhG: issue 998: delete unused funtion ivas_dirac_dec_get_response_split_order */ #define FIX_1009_ISM_NONDIEGETIC_PANNING /* FhG: issue #1009: use correct object buffer for ISM1 non-diegetic pan */ -- GitLab From 898f904c8b20833838056e42767ec6a986aa616e Mon Sep 17 00:00:00 2001 From: Jonas Sv Date: Wed, 6 Mar 2024 17:41:31 +0100 Subject: [PATCH 12/12] cleaned up comments , removed manual instrumentation --- lib_dec/FEC_HQ_phase_ecu.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c index c98222be76..7deb7db646 100644 --- a/lib_dec/FEC_HQ_phase_ecu.c +++ b/lib_dec/FEC_HQ_phase_ecu.c @@ -1092,13 +1092,8 @@ static void subst_spec( Xph = corr_phase[m]; #ifdef FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE - /* BE , but with maintained dual mult of a constant, mask the 10 bits in Word32, truncation */ -#define WMC_TOOL_SKIP + /* extract fractional phase integer index in the range [0...1023] */ Xph_short = (int16_t) ( 0x000003ff & (int32_t) ( ( Xph * 512 ) / EVS_PI ) ); - MULT( 2 ); /* mult with constant, twice due to legacy precedence use */ - LOGIC( 1 ); /* L_and */ - MISC( 1 ); /* extract_l */ -#undef WMC_TOOL_SKIP #else Xph_short = (int16_t) ( ( (int32_t) ( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; #endif @@ -1148,12 +1143,7 @@ static void subst_spec( } #ifdef FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE -#define WMC_TOOL_SKIP Xph_short = (int16_t) ( ( (int32_t) ( ( Xph * 512 ) / EVS_PI ) ) & 0x000003ff ); - MULT( 2 ); /* mult with constant, twice due to legacy precedence */ - LOGIC( 1 ); /* L_and */ - MISC( 1 ); /* extract_l */ -#undef WMC_TOOL_SKIP #else Xph_short = (int16_t) ( Xph * 512 / EVS_PI ) & 0x03ff; #endif -- GitLab