Crash in ivas_calc_tilt_bwe_fx()
with 2fb72211, I got a crash with the following bitstream when decoded at 32 kHz :
ltv_STEREO_32k_-stereo_32000_32.zip
The problem is located at :
Word16 ivas_calc_tilt_bwe_fx( /* o : Tilt in Q24 */
const Word32 *sp, /* i : input signal */
const Word16 exp_sp, /* i : Exp of inp signal */
const Word16 N /* i : signal length */
)
{
Word16 i, j;
Word32 L_ener, L_ener_tot, L_temp;
Word32 tmp1, tmp2;
Word16 sign = 0;
move16();
const Word32 *ptr;
Word16 exp2, tmp_exp;
BASOP_SATURATE_WARNING_OFF_EVS
/* this is required for adaptative precision energy summation loop, do not remove */
exp2 = 0;
move16();
ptr = sp;
L_ener_tot = L_deposit_l( 1 );
/* Divide Frame Length by 32 */
FOR( j = shr( N, 5 ); j > 0; j-- )
{
Word32 tmp = *ptr++; /* Divide by 4 */
L_ener = Mpy_32_32( tmp, tmp );
/* With the shift by 4 and the L_mult0, no overflow possible for 32 samples */
FOR( i = 1; i < 32; i++ )
{
tmp1 = *ptr++; /* Divide by 4 */
L_ener = Madd_32_32( L_ener, tmp1, tmp1 ); <<<<----
}
L_temp = L_add_sat( L_ener_tot, L_ener );
L_ener_tot = L_add_sat( L_ener_tot, L_ener );
}
The proposed solution is the following :
/* Divide Frame Length by 32 */
Word64 W_ener;
W_ener = Mpy_32_32( *ptr, *ptr );
*ptr++;
FOR( j = 1; j < N; j++ )
{
/* With the shift by 4 and the L_mult0, no overflow possible for 32 samples */
W_ener = W_mac_32_32( W_ener, *ptr, *ptr );
*ptr++;
}
L_ener_tot = W_round64_L( W_ener );
L_ener_tot = L_max( L_ener_tot, 1 ); /* L_ener_tot is energy, can't be negative, and have to be > 0 for the following division */
#endif
A branch and MR will follow soon