Commit 06d212d3 authored by fotopoulou's avatar fotopoulou
Browse files

fix for corner cases where ipd differences are exactly pi, but fixed point...

fix for corner cases where ipd differences are exactly pi, but fixed point calculation rounding enables changes for cases when <> pi
parent 68b58421
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -898,11 +898,17 @@ void stereo_dft_dec_smooth_parameters_fx(
    Word32 diff_ipd;
    Word16 nbands;
    Word32 max_res_pred_ind;
#ifdef FIX_874_INCREASE_ITD_PRECISION 
    Word32 PI_round;
#endif

    N_div = STEREO_DFT_NBDIV;
    move16();
    k_offset = STEREO_DFT_OFFSET;
    move16();
#ifdef FIX_874_INCREASE_ITD_PRECISION 
    PI_round = EVS_PI_FX_Q27 + EPSILLON_FX; /*add error corrections when comparing ipds with exactly a difference of pi*/
#endif

    test();
    IF( hStereoDft->frame_sid_nodata || prev_sid_nodata )
@@ -1242,12 +1248,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_ITD_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_ITD_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();
@@ -1264,6 +1278,7 @@ void stereo_dft_dec_smooth_parameters_fx(
            {
                pgIpd[0] = L_add( L_shr( pgIpd[0], 1 ), L_shr( pgIpd[-hStereoDft->prm_res[add( k, k_offset )]], 1 ) );
                move32();
                printf("offset = %d \n", hStereoDft->prm_res[add( k, k_offset )]);
            }
        }

@@ -3837,6 +3852,7 @@ void stereo_dft_dec_read_BS_fx(
            move16();
            move16();

            dbgwrite(hStereoDft->gipd_fx, sizeof(Word32), 3, 1, "res/gipd_fx");
            /*------------------------------------------------------------------*
             * read Residual parameters
             *-----------------------------------------------------------------*/