Skip to content

crash because of saturation in stereo_dft_dec_sid_coh_fx

With 0c11047f, When computing the prediction gain in the function stereo_dft_dec_sid_coh_fx, saturation can happen around line 3110 with this bitsteam :

fh_mic12_F2Fa001_-stereo_-dtx_13200_32.bit

and a potential solution could be the following :

    pptr_fx = dft_cng_coh_pred_fx[coh_pred_index]; /*Q-13*/
    pred_fx = 3276;                                /*Q-13*/
    move16();
    move16();
    FOR( b = 0; b < nbands; b++ )
    {
        /* Intra-frame prediction */

        FOR( i = 0; i < b; i++ )
        {
#ifdef TMP_FIX_720
            pred_fx = add( pred_fx, shl_sat(mult( ( *pptr_fx++ ), cohBandq_fx[i]), 2 ) ); /*q-13*/
#else
            pred_fx = add( pred_fx, mult( ( *pptr_fx++ ), shl( cohBandq_fx[i], 2 ) ) ); /*q-13*/
#endif
        }

doing the mult() before the shl ensure to limit possible saturation without having to revise the scaling of pred_fx. shl_sat has been added just for more security

Edited by vaillancour