Commit 460b5517 authored by vaillancour's avatar vaillancour
Browse files

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

parents e7975c72 9b7a99c6
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -162,6 +162,8 @@
/*#define FIX_I4_OL_PITCH*/                             /* fix open-loop pitch used for EVS core switching */
#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_1464_UBSAN_RC_CONTEXT_MAP                   /* FhG: BE UBSAN fix for float issue 1464 in the TCX range coder */
#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 */
+3 −0
Original line number Diff line number Diff line
@@ -662,6 +662,9 @@ int16_t RCcontextMapping_decode2_no_mem_s17_LCS(
                c = 12 + esc_nb;
            }

#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP
            s = s & 0x0F;
#endif
            s = s << 4; /*Shift old 4 bits*/
            s = s + c;  /*replace last 4 bits*/
            t = s & 0xFF;
+7 −0
Original line number Diff line number Diff line
@@ -963,6 +963,9 @@ void RCcontextMapping_encode2_no_mem_s17_LCS(
            }

            /*Shift old 4 bits, replace last 4 bits*/
#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP
            s = s & 0x0F;
#endif
            s = ( s << 4 ) + cp;
            t = s & 0xFF;

@@ -1336,7 +1339,11 @@ int16_t RCcontextMapping_encode2_estimate_no_mem_s17_LCS(
            {
                cp = 12 + esc_nb;
            }

            /*shift old bits and replace last 4 bits*/
#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP
            s = s & 0x0F;
#endif
            s = ( s << 4 ) + cp;
            t = s & 0xFF;

+29 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
    EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
  ====================================================================================*/

#include "cnst.h"
#include <stdint.h>
#include "options.h"
#ifdef DEBUGGING
@@ -113,6 +114,9 @@ static void tcx_ltp_pitch_search(
    int16_t *border_case )
{
    int16_t i, t, t0, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta;
#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH
    int16_t cor_idx_ini, cor_idx;
#endif
    float temp, cor_max, cor[256], *pt_cor;

    if ( pitres == 6 )
@@ -195,7 +199,11 @@ static void tcx_ltp_pitch_search(
     * the interpolated normalized correlation.
     *-----------------------------------------------------------------*/

#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH
    cor_idx_ini = L_INTERPOL1 - t0_min;
#else
    pt_cor = cor + L_INTERPOL1 - t0_min;
#endif
    t0 = t1;
    if ( t0 >= pitfr2 )
    {
@@ -211,15 +219,29 @@ static void tcx_ltp_pitch_search(
    if ( t0 == t0_min ) /* Limit case */
    {
        fraction = 0;
#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH
        cor_idx = cor_idx_ini + t0;
        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--;
#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH
        cor_idx = 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 - 1; i = 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 ( temp > cor_max )
            {
                cor_max = temp;
@@ -228,9 +250,16 @@ static void tcx_ltp_pitch_search(
        }
    }

#ifdef FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH
    cor_idx = cor_idx_ini + t1;
#endif
    for ( i = 0; i <= pitres - 1; i = 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 ( temp > cor_max )
        {
            cor_max = temp;