From eb4f0485cdabc173fe0e537e7ec5f1d3883a66c5 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 16 Dec 2025 06:49:31 -0500 Subject: [PATCH 1/3] Replicate fix from basop #2273 --- lib_com/options.h | 1 + lib_enc/pit_enc.c | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index efe87417fc..1e237736df 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -166,6 +166,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_2273_OOB_INDEXING_IN_PIT_FR4 /* VA: Fix to silence clang on ptr init */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/pit_enc.c b/lib_enc/pit_enc.c index d1306ac791..f6db28f686 100644 --- a/lib_enc/pit_enc.c +++ b/lib_enc/pit_enc.c @@ -443,7 +443,9 @@ int16_t pitch_fr4( int16_t t0, t1, t_min, t_max, pit_min; float cor_max, max_val, temp; float *corr, corr_v[15 + 2 * L_INTERPOL1 + 1]; - +#ifdef FIX_2273_OOB_INDEXING_IN_PIT_FR4 + int16_t corr_off; +#endif /* initialization */ if ( limit_flag == 0 ) { @@ -482,24 +484,43 @@ int16_t pitch_fr4( t_min = t0_min - L_INTERPOL1; t_max = t0_max + L_INTERPOL1; +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 corr = &corr_v[0] - t_min; /* corr[t_min..t_max] */ - +#else + corr = corr_v; + corr_off = -t_min; +#endif +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 norm_corr( exc, xn, h, t_min, t_max, corr, L_subfr ); - +#else + norm_corr( 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 t0 = t0_min; for ( i = t0_min + 1; i <= t0_max; i++ ) { +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 if ( corr[i] >= max_val ) { max_val = corr[i]; t0 = i; } +#else + if ( corr[i + corr_off] >= max_val ) + { + max_val = corr[i + corr_off]; + t0 = i; + } +#endif } if ( t0_fr1 == pit_min ) @@ -512,7 +533,11 @@ int16_t pitch_fr4( { i -= 2; } +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 if ( corr[i] > corr[i + 2] ) +#else + if ( corr[i + corr_off] > corr[i + 2 + corr_off] ) +#endif { t0 = i; } @@ -551,15 +576,27 @@ int16_t pitch_fr4( if ( t0 == t0_min ) /* Limit case */ { fraction = 0; +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 cor_max = interpolation( &corr[t0], E_ROM_inter4_1, fraction, PIT_UP_SAMP, 4 ); +#else + cor_max = interpolation( &corr[t0 + corr_off], E_ROM_inter4_1, fraction, PIT_UP_SAMP, 4 ); +#endif } else /* Process negative fractions */ { t0--; +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 cor_max = interpolation( &corr[t0], E_ROM_inter4_1, fraction, PIT_UP_SAMP, 4 ); +#else + cor_max = interpolation( &corr[t0 + corr_off], E_ROM_inter4_1, fraction, PIT_UP_SAMP, 4 ); +#endif for ( i = ( fraction + step ); i <= 3; i = i + step ) { +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 temp = interpolation( &corr[t0], E_ROM_inter4_1, i, PIT_UP_SAMP, 4 ); +#else + temp = interpolation( &corr[t0 + corr_off], E_ROM_inter4_1, i, PIT_UP_SAMP, 4 ); +#endif if ( temp > cor_max ) { cor_max = temp; @@ -570,7 +607,11 @@ int16_t pitch_fr4( for ( i = 0; i <= 3; i = i + step ) /* Process positive fractions */ { +#ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 temp = interpolation( &corr[t1], E_ROM_inter4_1, i, PIT_UP_SAMP, 4 ); +#else + temp = interpolation( &corr[t1 + corr_off], E_ROM_inter4_1, i, PIT_UP_SAMP, 4 ); +#endif if ( temp > cor_max ) { cor_max = temp; -- GitLab From 0f7ec76add465bb260675d737fccf319e15a13e3 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 16 Dec 2025 07:38:37 -0500 Subject: [PATCH 2/3] fix clang --- lib_enc/pit_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/pit_enc.c b/lib_enc/pit_enc.c index f6db28f686..9018ff8466 100644 --- a/lib_enc/pit_enc.c +++ b/lib_enc/pit_enc.c @@ -594,7 +594,7 @@ int16_t pitch_fr4( { #ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 temp = interpolation( &corr[t0], E_ROM_inter4_1, i, PIT_UP_SAMP, 4 ); -#else +#else temp = interpolation( &corr[t0 + corr_off], E_ROM_inter4_1, i, PIT_UP_SAMP, 4 ); #endif if ( temp > cor_max ) -- GitLab From d532a673f722f211f174b2141d7864844c6e3402 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 17 Dec 2025 15:20:00 +0100 Subject: [PATCH 3/3] formatting --- lib_enc/pit_enc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_enc/pit_enc.c b/lib_enc/pit_enc.c index 9018ff8466..4ba9b53886 100644 --- a/lib_enc/pit_enc.c +++ b/lib_enc/pit_enc.c @@ -446,6 +446,7 @@ int16_t pitch_fr4( #ifdef FIX_2273_OOB_INDEXING_IN_PIT_FR4 int16_t corr_off; #endif + /* initialization */ if ( limit_flag == 0 ) { @@ -484,17 +485,20 @@ int16_t pitch_fr4( t_min = t0_min - L_INTERPOL1; t_max = t0_max + L_INTERPOL1; + #ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 corr = &corr_v[0] - t_min; /* corr[t_min..t_max] */ #else corr = corr_v; corr_off = -t_min; #endif + #ifndef FIX_2273_OOB_INDEXING_IN_PIT_FR4 norm_corr( exc, xn, h, t_min, t_max, corr, L_subfr ); #else norm_corr( exc, xn, h, t_min, t_max, corr + corr_off, L_subfr ); #endif + /*-----------------------------------------------------------------* * Find integer pitch *-----------------------------------------------------------------*/ -- GitLab