Loading Workspace_msvc/decoder.vcxproj +1 −1 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ <_ProjectFileVersion>15.0.27428.2015</_ProjectFileVersion> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <OutDir>..\</OutDir> <OutDir>(ProjectDir)\..\</OutDir> <IntDir>.\Debug_$(ProjectName)\</IntDir> <LinkIncremental>false</LinkIncremental> <GenerateManifest>false</GenerateManifest> Loading lib_com/options.h +4 −2 Original line number Diff line number Diff line Loading @@ -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") */ Loading Loading @@ -164,6 +164,8 @@ #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 */ /* #################### End BE switches ################################## */ Loading lib_dec/FEC_HQ_phase_ecu.c +136 −12 Original line number Diff line number Diff line Loading @@ -972,6 +972,9 @@ 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; Loading Loading @@ -1092,7 +1095,92 @@ 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() */ 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]; Loading Loading @@ -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 ) { Loading Loading @@ -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] ); } Loading Loading
Workspace_msvc/decoder.vcxproj +1 −1 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ <_ProjectFileVersion>15.0.27428.2015</_ProjectFileVersion> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <OutDir>..\</OutDir> <OutDir>(ProjectDir)\..\</OutDir> <IntDir>.\Debug_$(ProjectName)\</IntDir> <LinkIncremental>false</LinkIncremental> <GenerateManifest>false</GenerateManifest> Loading
lib_com/options.h +4 −2 Original line number Diff line number Diff line Loading @@ -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") */ Loading Loading @@ -164,6 +164,8 @@ #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 */ /* #################### End BE switches ################################## */ Loading
lib_dec/FEC_HQ_phase_ecu.c +136 −12 Original line number Diff line number Diff line Loading @@ -972,6 +972,9 @@ 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; Loading Loading @@ -1092,7 +1095,92 @@ 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() */ 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]; Loading Loading @@ -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 ) { Loading Loading @@ -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] ); } Loading