Issue when computing the excitation in decod_gen_2sbfr_ivas_fx()
The current code is written like at Ln 722 of ivas_td_low_rate_dec.c :
exc2[i + i_subfr] = mult_r( gain_pit, shl( exc[i + i_subfr], Q15 - Q14 ) );
exc[i + i_subfr] = add( exc2[i + i_subfr], (Word16) L_shr( Mpy_32_16_1( gain_code, code[i] ), Q9 ) );
First, the excitation should never be in Q15, otherwise it will certainly overflow during the synthesis process at some point
In any cases, the operation order here are could lead to an undesired saturation as the excitation is left shift by one before applying the gain. To not lose precision and reduce the risk of overflow, it would be better to write it like (as done in decod_gen_voic_fx()) :
gain_code16 = round_fx(L_shl(gain_code_fx,st_fx->Q_exc)); /*Q_exc*/
for ()
{
L_tmp = L_shl(L_mult(gain_pit_fx, exc2[i+i_subfr]), 1); /*Q16+Q_exc*/
exc2[i+i_subfr] = round_fx(L_tmp); /*Q_exc*/
L_tmp = L_add(L_tmp, L_shl(L_mult(gain_code16, code[i]), 6)); /*Q16+Q_exc*/
exc[i+i_subfr] = round_fx(L_tmp); /*Q_exc*/
}
Even if the previous issues are solved, excitation saturate here at frame 129 ff_mic12_SbSb001_-stereo_24400_16.bit IVAS_dec STEREO 16 bit syn