Commit b3a72c9d authored by Jan Kiene's avatar Jan Kiene
Browse files

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

Resolve #2272 "USAN: OOB indexing in tcx_ltp_pitch_search_ivas function"

Closes #2279 and #2272

See merge request !2652
parents 0a270923 19886783
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@
#define FIX_2252_SCALING_SAVE_HB_SYNTH                  /* VA: issue 2252: fix use-of-uninit-value in save_hb_synth_fx[] scaling in FOA decoding with bitstream that starts with an SID */
#define FIX_2248_EVS_ASSERT                             /* VA: Include _sat in an EVS related part of the code */
#define FIX_2254_IMPROV_COMPLEXITY_BE                   /* VA: BE small complexity reduction  */
#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 */
+61 −3
Original line number Diff line number Diff line
@@ -89,6 +89,9 @@ static void tcx_ltp_pitch_search(
    Word16 pitres )
{
    Word16 i, t, t0, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp;
#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH
    Word16 cor_idx_ini, cor_idx;
#endif
    Word32 cor_max, cor[256], *pt_cor, temp;
    Word16 wsp2[L_FRAME_PLUS + PIT_MAX_MAX + L_INTERPOL1];

@@ -203,7 +206,11 @@ static void tcx_ltp_pitch_search(
     * the interpolated normalized correlation.
     *-----------------------------------------------------------------*/

#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH
    cor_idx_ini = sub( L_INTERPOL1, t0_min );
#else
    pt_cor = cor + sub( L_INTERPOL1, t0_min );
#endif
    t0 = t1;
    move16();

@@ -219,18 +226,34 @@ static void tcx_ltp_pitch_search(

    IF( EQ_16( t0, t0_min ) ) /* Limit case */
    {
#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH
        cor_idx = add( cor_idx_ini, t0 );
#endif
        fraction = 0;
        move16();
#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH
        cor_max = interpolate_corr( &cor[cor_idx], fraction, pitres );
#else
        cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres );
#endif
    }
    ELSE /* Process negative fractions */
    {
        t0 = sub( t0, 1 );
#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH
        cor_idx = add( cor_idx_ini, t0 );
        cor_max = interpolate_corr( &cor[cor_idx], fraction, pitres );
#else
        cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres );
#endif

        FOR( i = fraction + step; i < pitres; i += step )
        {
#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH
            temp = interpolate_corr( &cor[cor_idx], i, pitres );
#else
            temp = interpolate_corr( &pt_cor[t0], i, pitres );
#endif

            IF( GT_32( temp, cor_max ) )
            {
@@ -241,11 +264,16 @@ static void tcx_ltp_pitch_search(
        }
    }

    i = 0;
    move16();
#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH
    cor_idx = add( cor_idx_ini, t1 );
#endif
    FOR( i = 0; i < pitres; i += step ) /* Process positive fractions */
    {
#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH
        temp = interpolate_corr( &cor[cor_idx], i, pitres );
#else
        temp = interpolate_corr( &pt_cor[t1], i, pitres );
#endif

        IF( GT_32( temp, cor_max ) )
        {
@@ -293,6 +321,9 @@ static void tcx_ltp_pitch_search_ivas_fx(
    Word16 *border_case )
{
    Word16 i, t, t0, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp;
#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH
    Word16 cor_idx_ini, cor_idx;
#endif
    Word32 cor_max, cor[256], *pt_cor, temp;
    Word16 wsp2[L_FRAME_PLUS + PIT_MAX_MAX + L_INTERPOL1];

@@ -418,8 +449,12 @@ static void tcx_ltp_pitch_search_ivas_fx(
     * search the fractions around t0 and choose the one which maximizes
     * the interpolated normalized correlation.
     *-----------------------------------------------------------------*/
#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH
    cor_idx_ini = sub( L_INTERPOL1, t0_min );
#else

    pt_cor = cor + sub( L_INTERPOL1, t0_min );
#endif
    t0 = t1;
    move16();

@@ -435,18 +470,34 @@ static void tcx_ltp_pitch_search_ivas_fx(

    IF( EQ_16( t0, t0_min ) ) /* Limit case */
    {
#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH
        cor_idx = add( cor_idx_ini, t0 );
#endif
        fraction = 0;
        move16();
#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH
        cor_max = interpolate_corr( &cor[cor_idx], fraction, pitres );
#else
        cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres );
#endif
    }
    ELSE /* Process negative fractions */
    {
        t0 = sub( t0, 1 );
#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH
        cor_idx = add( cor_idx_ini, t0 );
        cor_max = interpolate_corr( &cor[cor_idx], fraction, pitres );
#else
        cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres );
#endif

        FOR( i = fraction + step; i < pitres; i += step )
        {
#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH
            temp = interpolate_corr( &cor[cor_idx], i, pitres );
#else
            temp = interpolate_corr( &pt_cor[t0], i, pitres );
#endif

            IF( GT_32( temp, cor_max ) )
            {
@@ -457,9 +508,16 @@ static void tcx_ltp_pitch_search_ivas_fx(
        }
    }

#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH
    cor_idx = add( cor_idx_ini, t1 );
#endif
    FOR( i = 0; i < pitres; i += step ) /* Process positive fractions */
    {
#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH
        temp = interpolate_corr( &cor[cor_idx], i, pitres );
#else
        temp = interpolate_corr( &pt_cor[t1], i, pitres );
#endif

        IF( GT_32( temp, cor_max ) )
        {