From 2b9d8012cbcd651dcf0eab67249755ac897b65a9 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 12 Dec 2025 09:23:19 -0500 Subject: [PATCH 1/2] Fix 2273 to silence clang18 on ptr init --- lib_com/options.h | 2 +- lib_enc/pit_enc_fx.c | 54 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index ee8c6be3a..14f10d3b9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,7 +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_2273_OOB_INDEXING_IN_PIT_FR4 /* VA: Fix to silence clang on ptr init */ /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index b812bd6fc..9ea54aa4f 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -762,7 +762,9 @@ Word16 pitch_fr4_fx( Word16 corr_v[15 + 2 * L_INTERPOL1 + 1]; /* Total length = t0_max-t0_min+1+2*L_inter */ Word16 pit_min; Word16 cor_max; - +#ifdef FIX_2273_OOB_INDEXING_IN_PIT_FR4 + Word16 corr_off; +#endif /* initialization */ IF( limit_flag == 0 ) { @@ -805,8 +807,15 @@ Word16 pitch_fr4_fx( t_min = sub( t0_min, L_INTERPOL1 ); t_max = add( t0_max, L_INTERPOL1 ); +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 corr = &corr_v[-t_min]; +#else + corr = corr_v; + corr_off = -t_min; + move16(); +#endif /* corr[t_min..t_max] */ +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 if ( element_mode > EVS_MONO ) { norm_corr_ivas_fx( exc, xn, h, t_min, t_max, corr, L_subfr, Q_new ); @@ -815,24 +824,45 @@ Word16 pitch_fr4_fx( { norm_corr_fx( exc, xn, h, t_min, t_max, corr, L_subfr ); } - +#else + if ( element_mode > EVS_MONO ) + { + norm_corr_ivas_fx( exc, xn, h, t_min, t_max, corr + corr_off, L_subfr, Q_new ); + } + else + { + norm_corr_fx( exc, xn, h, t_min, t_max, corr + corr_off, L_subfr ); + } +#endif /*-----------------------------------------------------------------* * Find integer pitch *-----------------------------------------------------------------*/ +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 max_val = corr[t0_min]; +#else + max_val = corr[t0_min + corr_off]; +#endif move16(); t0 = t0_min; move16(); FOR( i = t0_min + 1; i <= t0_max; i++ ) { +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 if ( GE_16( corr[i], max_val ) ) +#else + if ( GE_16( corr[i + corr_off], max_val ) ) +#endif { t0 = i; move16(); } +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 max_val = s_max( corr[i], max_val ); +#else + max_val = s_max( corr[i + corr_off], max_val ); +#endif } IF( EQ_16( t0_fr1, pit_min ) ) @@ -846,7 +876,11 @@ Word16 pitch_fr4_fx( { i = sub( i, 2 ); } +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 IF( GT_16( corr[i], corr[i + 2] ) ) +#else + IF( GT_16( corr[i + corr_off], corr[i + 2 + corr_off] ) ) +#endif { t0 = i; move16(); @@ -897,15 +931,27 @@ Word16 pitch_fr4_fx( { fraction = 0; move16(); +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 cor_max = Interpol_4( &corr[t0], fraction ); +#else + cor_max = Interpol_4( &corr[t0 + corr_off], fraction ); +#endif } ELSE { t0 = sub( t0, 1 ); +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 cor_max = Interpol_4( &corr[t0], fraction ); +#else + cor_max = Interpol_4( &corr[t0 + corr_off], fraction ); +#endif FOR( i = fraction + step; i <= 3; i = ( i + step ) ) { +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 temp = Interpol_4( &corr[t0], i ); +#else + temp = Interpol_4( &corr[t0 + corr_off], i ); +#endif IF( GT_16( temp, cor_max ) ) { cor_max = temp; @@ -918,7 +964,11 @@ Word16 pitch_fr4_fx( FOR( i = 0; i <= 3; i = ( i + step ) ) { +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 temp = Interpol_4( &corr[t1], i ); +#else + temp = Interpol_4( &corr[t1 + corr_off], i ); +#endif IF( GT_16( temp, cor_max ) ) { cor_max = temp; -- GitLab From 791742b833821cf63bb0fefafdc609ef2c42f7fb Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 17 Dec 2025 15:20:06 +0100 Subject: [PATCH 2/2] formatting --- lib_com/options.h | 2 +- lib_enc/pit_enc_fx.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1154cde9a..d7daa9187 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,8 +102,8 @@ #define FIX_2287_MCT_MDCT_STEREO_DATA_MALLOC_SIZE /* FhG: correct allocation size for STEREO_MDCT_DEC_DATA struct */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_2271_OOB_INDEXING_IN_PIT_OL2 /* VA: Fix for issue 2271, to silence clang18 */ - #define FIX_2273_OOB_INDEXING_IN_PIT_FR4 /* VA: Fix to silence clang on ptr init */ + /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index 9ea54aa4f..5c9a5bdcd 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -765,6 +765,7 @@ Word16 pitch_fr4_fx( #ifdef FIX_2273_OOB_INDEXING_IN_PIT_FR4 Word16 corr_off; #endif + /* initialization */ IF( limit_flag == 0 ) { @@ -807,6 +808,7 @@ Word16 pitch_fr4_fx( t_min = sub( t0_min, L_INTERPOL1 ); t_max = add( t0_max, L_INTERPOL1 ); + #ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 corr = &corr_v[-t_min]; #else @@ -814,6 +816,7 @@ Word16 pitch_fr4_fx( corr_off = -t_min; move16(); #endif + /* corr[t_min..t_max] */ #ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 if ( element_mode > EVS_MONO ) @@ -834,6 +837,7 @@ Word16 pitch_fr4_fx( norm_corr_fx( exc, xn, h, t_min, t_max, corr + corr_off, L_subfr ); } #endif + /*-----------------------------------------------------------------* * Find integer pitch *-----------------------------------------------------------------*/ -- GitLab