diff --git a/lib_com/options.h b/lib_com/options.h index 93908a861836ce2bdc6e79fe488f3b4f424e8bb1..fcd836908c090a9334e5b5f71aab5f43ecd53ddc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -180,6 +180,9 @@ #define FIX_869_WRONG_UVGAIN_STEP /* VA: Fix wrong decoding of uv gain quantizer for td-stereo*/ #define FIX_871_REMOVE_UNNECESSARY_CONDITION /* VA: remove a condition that is not needed and prevented correct frame classification of the secondary channel of the TD stereo */ + +#define FIX_874_INCREASE_IPD_PRECISION /*VA : Fix issue 874 by increasing ITD precision already when decoding index */ +#define FIX_874_INCREASE_IPD_PRECISION_A /*VA : Fix a possible issue where 2*PI should be used instead of PI (to be confirmed) */ #define FIX_875_SATURATION_DURING_ROUNDING /* VA: fix a possible saturation when rounding */ #define FIX_882_LOW_LEVEL_DISCONTINUITIES /* VA: Fix 882, discontinuities for low level signal by adding a scaling function that uses rounding, this function is more complex than normal one, has to be used only when necessary*/ #define FIX_879_DIFF_CONCEAL_PATH /* FhG: Fix for issue 879 and different concelalment paths that led to crash */ diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 87cc8fc2c5ed46753a4d5e515ced74668750874b..40c8baf966fade4fdb882e65ddba3930ff5e3059 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -898,11 +898,18 @@ void stereo_dft_dec_smooth_parameters_fx( Word32 diff_ipd; Word16 nbands; Word32 max_res_pred_ind; +#ifdef FIX_874_INCREASE_IPD_PRECISION + Word32 PI_round; +#endif N_div = STEREO_DFT_NBDIV; move16(); k_offset = STEREO_DFT_OFFSET; move16(); +#ifdef FIX_874_INCREASE_IPD_PRECISION + PI_round = EVS_PI_FX_Q27 + EPSILLON_FX; /*add error corrections when comparing ipds with exactly a difference of pi*/ + move32(); +#endif test(); IF( hStereoDft->frame_sid_nodata || prev_sid_nodata ) @@ -926,7 +933,11 @@ void stereo_dft_dec_smooth_parameters_fx( Word16 q_val; IF( GT_32( L_sub( hStereoDft->gipd_fx[add( k, k_offset )], hStereoDft->ipd_xfade_prev_fx ), EVS_PI_FX_Q27 ) ) { +#ifdef FIX_874_INCREASE_IPD_PRECISION_A + hStereoDft->ipd_xfade_target_fx = L_sub( hStereoDft->gipd_fx[add( k, k_offset )], EVS_PI_FX_Q27 << 1 ); +#else hStereoDft->ipd_xfade_target_fx = L_sub( hStereoDft->gipd_fx[add( k, k_offset )], EVS_PI_FX_Q27 ); +#endif move32(); hStereoDft->ipd_xfade_step_fx = BASOP_Util_Divide3232_Scale( L_sub( hStereoDft->ipd_xfade_target_fx, hStereoDft->ipd_xfade_prev_fx ), L_shl( L_sub( STEREO_DFT_ITD_CNG_XFADE, hStereoDft->ipd_xfade_counter ), Q24 ), &q_val ); move32(); @@ -945,7 +956,11 @@ void stereo_dft_dec_smooth_parameters_fx( } ELSE IF( GT_32( L_sub( hStereoDft->ipd_xfade_prev_fx, hStereoDft->gipd_fx[add( k, k_offset )] ), EVS_PI_FX_Q27 ) ) { +#ifndef FIX_874_INCREASE_IPD_PRECISION_A hStereoDft->ipd_xfade_target_fx = L_add( hStereoDft->gipd_fx[add( k, k_offset )], L_shl( EVS_PI_FX_Q27, 1 ) ); +#else + hStereoDft->ipd_xfade_target_fx = L_add( hStereoDft->gipd_fx[add( k, k_offset )], EVS_PI_FX_Q27 << 1 ); +#endif move32(); hStereoDft->ipd_xfade_step_fx = BASOP_Util_Divide3232_Scale( L_sub( hStereoDft->ipd_xfade_target_fx, hStereoDft->ipd_xfade_prev_fx ), L_shl( L_sub( STEREO_DFT_ITD_CNG_XFADE, hStereoDft->ipd_xfade_counter ), Q24 ), &q_val ); q_val = add( q_val, Q9 ); /* Q27 - (Q15 - q_val + (-3))*/ @@ -1234,12 +1249,20 @@ void stereo_dft_dec_smooth_parameters_fx( /* Smoothing of IPDs*/ pgIpd = hStereoDft->gipd_fx + ( add( k, k_offset ) ); diff_ipd = L_sub( pgIpd[0], pgIpd[-hStereoDft->prm_res[add( k, k_offset )]] ); +#ifndef FIX_874_INCREASE_IPD_PRECISION IF( LT_32( diff_ipd, -EVS_PI_FX_Q27 ) ) +#else + IF( LT_32( diff_ipd, -PI_round ) ) +#endif { pgIpd[0] = L_add( pgIpd[0], EVS_2PI_FX_Q27 ); move32(); } +#ifndef FIX_874_INCREASE_IPD_PRECISION ELSE IF( GT_32( diff_ipd, EVS_PI_FX_Q27 ) ) +#else + ELSE IF( GT_32( diff_ipd, PI_round ) ) +#endif { pgIpd[0] = L_sub( pgIpd[0], EVS_2PI_FX_Q27 ); move32(); @@ -2450,12 +2473,16 @@ static void stereo_dft_compute_td_stefi_params_fx( static void stereo_dft_dequantize_ipd_fx( Word16 *ind, Word32 *out_fx, +#ifndef FIX_874_INCREASE_IPD_PRECISION const Word16 N, +#endif const Word16 bits ) { - Word16 i; Word16 delta_fx; +#ifndef FIX_874_INCREASE_IPD_PRECISION + Word16 i; Word32 temp_out; +#endif IF( EQ_16( bits, 2 ) ) /* 2-bit phase quantization for the highest frequency band only */ { delta_fx = ( EVS_PI_FX ) >> 1; @@ -2478,12 +2505,17 @@ static void stereo_dft_dequantize_ipd_fx( assert( 0 ); } +#ifndef FIX_874_INCREASE_IPD_PRECISION FOR( i = 0; i < N; i++ ) { temp_out = L_sub( L_mult0( ind[i], delta_fx ), ( EVS_PI_FX ) ); *out_fx = L_shl( temp_out, 14 ); move32(); } +#else + *out_fx = L_sub( W_sat_l( W_mult_32_16( L_shl( ind[0], 13 ), delta_fx ) ), EVS_PI_FX_Q27 ); + move32(); +#endif return; } @@ -3782,7 +3814,11 @@ void stereo_dft_dec_read_BS_fx( move16(); nb = add( nb, STEREO_DFT_GIPD_NBITS ); n_bits = add( n_bits, STEREO_DFT_GIPD_NBITS ); +#ifndef FIX_874_INCREASE_IPD_PRECISION stereo_dft_dequantize_ipd_fx( &ind1_ipd[0], hStereoDft->gipd_fx + add( k, k_offset ), 1, STEREO_DFT_GIPD_NBITS ); +#else + stereo_dft_dequantize_ipd_fx( &ind1_ipd[0], hStereoDft->gipd_fx + add( k, k_offset ), STEREO_DFT_GIPD_NBITS ); +#endif } } ELSE IF( LE_16( *nb_bits, ( ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - STEREO_DFT_FLAG_BITS - STEREO_DFT_SID_GIPD_NBITS - SID_FORMAT_NBITS ) ) ) @@ -3798,7 +3834,11 @@ void stereo_dft_dec_read_BS_fx( move16(); nb = add( nb, STEREO_DFT_SID_GIPD_NBITS ); n_bits = add( n_bits, STEREO_DFT_SID_GIPD_NBITS ); +#ifndef FIX_874_INCREASE_IPD_PRECISION stereo_dft_dequantize_ipd_fx( &ind1_ipd[0], hStereoDft->gipd_fx + add( k, k_offset ), 1, STEREO_DFT_SID_GIPD_NBITS ); +#else + stereo_dft_dequantize_ipd_fx( &ind1_ipd[0], hStereoDft->gipd_fx + add( k, k_offset ), STEREO_DFT_SID_GIPD_NBITS ); +#endif } } ELSE