Commit 4e7de6c3 authored by Jan Kiene's avatar Jan Kiene
Browse files

Merge branch 'main' into basop-2272-usan-oob-indexing-in-tcx_ltp_pitch_search_ivas-function

parents cc8aa421 2761da76
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -163,6 +163,9 @@
#define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR      /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */
#define NONBE_1122_KEEP_EVS_MODE_UNCHANGED              /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR.  */
#define FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH         /* FhG: fix OOB index USAN error in TCX LTP pitch search */
#define FIX_2274_OOB_INDEXING_IN_CORRMATRIX             /* FhG: fix OOB indexing complaint */
#define FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH /* FhG: fix oob indexing USAN complaint */
#define FIX_2287_MCT_MDCT_STEREO_DATA_MALLOC_SIZE       /* FhG: correct allocation size for STEREO_MDCT_DEC_DATA struct */

/* #################### End BE switches ################################## */

+4 −0
Original line number Diff line number Diff line
@@ -564,7 +564,11 @@ ivas_error mct_dec_reconfigure(
                hMCT->hBlockData[n]->ch2 = 0;

                /* MDCT stereo initialization */
#ifdef FIX_2287_MCT_MDCT_STEREO_DATA_MALLOC_SIZE
                if ( ( hMCT->hBlockData[n]->hStereoMdct = (STEREO_MDCT_DEC_DATA_HANDLE) malloc( sizeof( STEREO_MDCT_DEC_DATA ) ) ) == NULL )
#else
                if ( ( hMCT->hBlockData[n]->hStereoMdct = (STEREO_MDCT_DEC_DATA_HANDLE) malloc( sizeof( STEREO_MDCT_ENC_DATA ) ) ) == NULL )
#endif
                {
                    return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MDCT Stereo \n" ) );
                }
+7 −0
Original line number Diff line number Diff line
@@ -492,7 +492,14 @@ static void E_ACELP_corrmatrix(
        p3 = &rrixiy[2][pos];
        p2 = &rrixiy[1][pos];
        p1 = &rrixiy[0][pos];
#ifdef FIX_2274_OOB_INDEXING_IN_CORRMATRIX
        p0 = &rrixiy[3][pos];
        /* decrement pointer instead of indexing the array to avoid CLANG Usan complaint */
        /* for last loop iteration, this points to rrixiy[3][-1], but is not actually accessed in later loop (k = 15 then, so inner loop will not run) */
        p0 -= 16;
#else
        p0 = &rrixiy[3][pos - 16];
#endif

        cor = 0.0F;
        ptr_h1 = h;
+46 −0
Original line number Diff line number Diff line
@@ -147,7 +147,11 @@ int16_t E_GAIN_closed_loop_search(
{
    float corr_v[32 + 2 * L_INTERPOL1 + 1];
    float cor_max, max_val, temp;
#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH
    int16_t corr_idx;
#else
    float *corr;
#endif
    int16_t i, fraction, frac1, frac2, step;
    int16_t t0, t_min, t_max;

@@ -159,22 +163,45 @@ int16_t E_GAIN_closed_loop_search(
    t_min = t0_min - L_INTERPOL1;
    t_max = t0_max + L_INTERPOL1;

#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH
    corr_idx = -t_min;
#else
    /* allocate memory to normalized correlation vector */
    corr = &corr_v[-t_min]; /* corr[t_min..t_max] */
#endif

    /* Compute normalized correlation between target and filtered excitation */
#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH
    norm_corr( exc, xn, h, t_min, t_max, &corr_v[0] + corr_idx, L_subfr );
#else
    norm_corr( exc, xn, h, t_min, t_max, corr, L_subfr );
#endif

    /*  find integer pitch */
#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH
    max_val = corr_v[t0_min + corr_idx];
#else
    max_val = corr[t0_min];
#endif
    t0 = t0_min;
    for ( i = t0_min + 1; i <= t0_max; i++ )
    {
#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH
        float corr_tmp;

        corr_tmp = corr_v[corr_idx + i];
        if ( corr_tmp >= max_val )
        {
            max_val = corr_tmp;
            t0 = i;
        }
#else
        if ( corr[i] >= max_val )
        {
            max_val = corr[i];
            t0 = i;
        }
#endif
    }

    /* If first subframe and t0 >= pit_fr1, do not search fractionnal pitch */
@@ -220,13 +247,24 @@ int16_t E_GAIN_closed_loop_search(
        frac2 = t0_max_frac;
    }
    assert( frac1 <= 0 && frac2 >= 0 && frac2 > frac1 );
#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH
    corr_idx += t0;
#endif
    if ( pit_res_max == 6 )
    {
#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH
        cor_max = E_GAIN_norm_corr_interpolate6( &corr_v[corr_idx], frac1 );
#else
        cor_max = E_GAIN_norm_corr_interpolate6( &corr[t0], frac1 );
#endif
        fraction = frac1;
        for ( i = ( frac1 + step ); i <= frac2; i += step )
        {
#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH
            temp = E_GAIN_norm_corr_interpolate6( &corr_v[corr_idx], i );
#else
            temp = E_GAIN_norm_corr_interpolate6( &corr[t0], i );
#endif
            if ( temp > cor_max )
            {
                cor_max = temp;
@@ -236,11 +274,19 @@ int16_t E_GAIN_closed_loop_search(
    }
    else
    {
#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH
        cor_max = E_GAIN_norm_corr_interpolate( &corr_v[corr_idx], frac1 );
#else
        cor_max = E_GAIN_norm_corr_interpolate( &corr[t0], frac1 );
#endif
        fraction = frac1;
        for ( i = ( frac1 + step ); i <= frac2; i += step )
        {
#ifdef FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH
            temp = E_GAIN_norm_corr_interpolate( &corr_v[corr_idx], i );
#else
            temp = E_GAIN_norm_corr_interpolate( &corr[t0], i );
#endif
            if ( temp > cor_max )
            {
                cor_max = temp;