diff --git a/lib_com/options.h b/lib_com/options.h index dec62b523c92816ea679a9c2d954a78e2b5f0ce4..30b76461a1e09a1276d57d55c9b6135b46f04111 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -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 */ diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index 012d6fa0260cd2cc1886c848bf04930652dd80df..bd43b84f111089d2af92f0c02014ad2135f26247 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -4,7 +4,7 @@ #include #include "options.h" -//#include "prot_fx.h" +// #include "prot_fx.h" #include "stl.h" #include "cnst.h" #include "basop_util.h" @@ -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 ) ) {