Commit 8b03f777 authored by vaclav's avatar vaclav
Browse files

Merge branch 'basop-2271-usan-oob-indexing-in-pitch_ol2_fx-function' into 'main'

basop-2271-usan-oob-indexing-in-pitch_ol2_fx-function

See merge request !2463
parents 0f9262f7 6733a3a6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -170,6 +170,7 @@
#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 */
#define FIX_2271_OOB_INDEXING_IN_PIT_OL2                /* VA: Fix for issue 2271, to silence clang18 */

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

+24 −2
Original line number Diff line number Diff line
@@ -72,7 +72,9 @@ void pitch_ol2(
    int16_t i, t, t0, t1, step, fraction, t0_min, t0_max, t_min, t_max;
    float temp, cor_max, enr_wsp, enr_old, cor[COR_BUF_LEN], *pt_cor, wsp_fr[L_SUBFR];
    const float *pt_wsp;

#ifdef FIX_2271_OOB_INDEXING_IN_PIT_OL2
    int16_t base_idx;
#endif
    t0_min = pitch_ol - delta;
    t0_max = pitch_ol + delta - 1;

@@ -114,24 +116,40 @@ void pitch_ol2(
     * the interpolated normalized correlation.
     *-----------------------------------------------------------------*/

#ifndef FIX_2271_OOB_INDEXING_IN_PIT_OL2
    pt_cor = cor + L_INTERPOL1 - t0_min;
#endif
    t0 = t1;

#ifdef FIX_2271_OOB_INDEXING_IN_PIT_OL2
    base_idx = L_INTERPOL1 - t0_min;
#endif
    step = 1; /* 1/4 subsample resolution */
    fraction = 1;

    if ( t0 == t0_min ) /* Limit case */
    {
        fraction = 0;
#ifndef FIX_2271_OOB_INDEXING_IN_PIT_OL2
        cor_max = interpolation( &pt_cor[t0], E_ROM_inter4_1, fraction, PIT_UP_SAMP, 4 );
#else
        cor_max = interpolation( &cor[t0 + base_idx], E_ROM_inter4_1, fraction, PIT_UP_SAMP, 4 );
#endif
    }
    else /* Process negative fractions */
    {
        t0--;
#ifndef FIX_2271_OOB_INDEXING_IN_PIT_OL2
        cor_max = interpolation( &pt_cor[t0], E_ROM_inter4_1, fraction, PIT_UP_SAMP, 4 );
#else
        cor_max = interpolation( &cor[t0 + base_idx], E_ROM_inter4_1, fraction, PIT_UP_SAMP, 4 );
#endif
        for ( i = ( fraction + step ); i <= 3; i = i + step )
        {
#ifndef FIX_2271_OOB_INDEXING_IN_PIT_OL2
            temp = interpolation( &pt_cor[t0], E_ROM_inter4_1, i, PIT_UP_SAMP, 4 );
#else
            temp = interpolation( &cor[t0 + base_idx], E_ROM_inter4_1, i, PIT_UP_SAMP, 4 );
#endif
            if ( temp > cor_max )
            {
                cor_max = temp;
@@ -142,7 +160,11 @@ void pitch_ol2(

    for ( i = 0; i <= 3; i = i + step ) /* Process positive fractions */
    {
#ifndef FIX_2271_OOB_INDEXING_IN_PIT_OL2
        temp = interpolation( &pt_cor[t1], E_ROM_inter4_1, i, PIT_UP_SAMP, 4 );
#else
        temp = interpolation( &cor[t1 + base_idx], E_ROM_inter4_1, i, PIT_UP_SAMP, 4 );
#endif
        if ( temp > cor_max )
        {
            cor_max = temp;