Skip to content

Possibe saturation in FB BWE

for some highlevel content, a saturation can happen in this part of the code :


    IF( EQ_16( extl, FB_TBE ) )
    {
        tmp = sub( add( *Q_bwe_exc_fb, 20 ), prev_Q_bwe_exc_fb );
        Scale_sig( fb_state_lpc_syn, LPC_SHB_ORDER, tmp );
        Scale_sig( fb_tbe_demph, 1, tmp );
        Syn_filt_s( 0, lpc_shb, LPC_SHB_ORDER, White_exc16k_FB, White_exc16k_FB_temp, L_FRAME16k, fb_state_lpc_syn, 1 );
        /* i: White_exc16k_FB       in (14-n2) */
        /* o: White_exc16k_FB_temp  in (14-n2) */

        FOR( i = 0; i < 10; i++ )
        {
            FOR( j = 0; j < 32; ++j )
            {
 >>>            White_exc16k_FB_temp[i * 32 + j] = mult_r( White_exc16k_FB_temp[i * 32 + j], cos_fb_exc_fx[j] );
                move16();
            }
        }

Where cos_fb_exc_fx is in Q15 and containing values equal to 32767 and -32768. It seems White_exc16k_FB_temp is also using the full 16 bits scale, so leading to potential 32767 x 32767 or -32768 x -32768, thus leading to an overflow caused by the rounding.

I proposed to use mult_r_sat() instead.