diff --git a/lib_com/options.h b/lib_com/options.h index 2c70dd14f900bcf3ae42a391332364aa639d8451..072b3b337b3f50afcbfa57f50fdcf4c6f4d556e5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,7 @@ #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_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ +#define FIX_1474_USAN_TRANS_INV /* Eri: Float issue 1474: Fix USAN out-of-bounds warning. No OOB occurs, but the pointer is set to point to uninitialized memory. */ #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 */ diff --git a/lib_com/trans_direct_fx.c b/lib_com/trans_direct_fx.c index 4e259e0cc5076d1d74b4a16d3ed1410fdad505f4..7598bd42237bc1adc5fbdb7ce7df9ce165b80a34 100644 --- a/lib_com/trans_direct_fx.c +++ b/lib_com/trans_direct_fx.c @@ -76,15 +76,21 @@ void direct_transform_fx( move32(); } +#ifndef FIX_1474_USAN_TRANS_INV iseg_fx = &in32_r16_fx[-segment_length4]; /*Q*/ - oseg_fx = out32_fx; /*Q*/ +#endif + oseg_fx = out32_fx; /*Q*/ wh_fx = &win_fx[segment_length4]; /*Q15*/ wl_fx = wh_fx - 1; /*Q15*/ shift = extract_l( L_mult0( 3, segment_length4 ) ); /*Q0*/ - sh_fx = &iseg_fx[shift]; /*Q*/ - sl_fx2 = sh_fx - 1; /*Q*/ +#ifdef FIX_1474_USAN_TRANS_INV + sh_fx = &in32_r16_fx[segment_length2]; /*Q*/ +#else + sh_fx = &iseg_fx[shift]; /*Q*/ +#endif + sl_fx2 = sh_fx - 1; /*Q*/ FOR( i = 0; i < segment_length4; i++ ) @@ -94,7 +100,11 @@ void direct_transform_fx( move32(); } +#ifdef FIX_1474_USAN_TRANS_INV + sl_fx2 = &in32_r16_fx[( segment_length4 - 1 )]; /*Q*/ +#else sl_fx2 = &iseg_fx[( segment_length2 - 1 )]; /*Q*/ +#endif FOR( i = segment_length4; i < segment_length2; i++ ) { @@ -107,7 +117,11 @@ void direct_transform_fx( edct_fx( dctin32_fx, oseg_fx, segment_length2, &Qs[0] ); Qmin = s_min( Qs[0], Qmin ); +#ifdef FIX_1474_USAN_TRANS_INV + iseg_fx = &in32_r16_fx[segment_length4]; +#else iseg_fx += segment_length2; +#endif oseg_fx += segment_length2; FOR( seg = 1; seg < NUM_TIME_SWITCHING_BLOCKS - 1; seg++ ) diff --git a/lib_com/trans_inv_fx.c b/lib_com/trans_inv_fx.c index 8bf63fccac0734f9e46e5332ae9ba842825e42ea..9a07742151ba6dc7bbf9c4ef8853c8c122f521e8 100644 --- a/lib_com/trans_inv_fx.c +++ b/lib_com/trans_inv_fx.c @@ -1032,7 +1032,11 @@ void Inverse_Transform( } } +#ifdef FIX_1474_USAN_TRANS_INV + out_segment = out_alias; +#else out_segment = out_alias - segment_length_div4; +#endif in_segment = in_mdct_modif; /*Q*/ tmp = *Q; @@ -1051,7 +1055,11 @@ void Inverse_Transform( FOR( ta = segment_length_div4; ta < segment_length_div2; ta++ ) { - out_segment[ta] = L_shr( alias[ta], tmp ); /*q_out*/ +#ifdef FIX_1474_USAN_TRANS_INV + *out_segment++ = L_shr( alias[ta], tmp ); /*q_out*/ +#else + out_segment[ta] = L_shr( alias[ta], tmp ); /*q_out*/ +#endif move32(); } /* This previous loop fills the output buffer from [0..seg_len_div4-1] */ @@ -1059,13 +1067,21 @@ void Inverse_Transform( win2 = &win[segment_length_div2]; /*Q15*/ FOR( ta = segment_length_div2; ta < segment_length; ta++ ) { +#ifdef FIX_1474_USAN_TRANS_INV + *out_segment++ = L_shr( Mult_32_16( alias[ta], *--win2 ), tmp ); /*q_out*/ +#else out_segment[ta] = L_shr( Mult_32_16( alias[ta], *--win2 ), tmp ); /*q_out*/ +#endif move32(); } /* This previous loop fills the output buffer from [seg_len_div4..seg_len-seg_len_div4-1] */ - out_segment += segment_length_div2; /*q_out*/ - in_segment += segment_length_div2; /*Q*/ +#ifdef FIX_1474_USAN_TRANS_INV + out_segment = &out_alias[segment_length_div4]; /*q_out*/ +#else + out_segment += segment_length_div2; /*q_out*/ +#endif + in_segment += segment_length_div2; /*Q*/ FOR( seg = 1; seg < NUM_TIME_SWITCHING_BLOCKS - 1; seg++ ) {