Commit 396f5869 authored by Manuel Jander's avatar Manuel Jander
Browse files

Modify NONBE_FIX_2493_EXTRACT_L_ivas_core_dec_fx fix so that no saturation...

Modify NONBE_FIX_2493_EXTRACT_L_ivas_core_dec_fx fix so that no saturation happens, because sometimes apparently saturation is worse than the overflow that is being attempted to fix.
parent d8232be0
Loading
Loading
Loading
Loading
+23 −8
Original line number Diff line number Diff line
@@ -98,7 +98,9 @@ ivas_error ivas_core_dec_fx(
    Word32 synth_32_fx[CPE_CHANNELS][L_FRAME48k];
    Word16 e_sig[CPE_CHANNELS];
    Word16 tdm_lsfQ_PCh_fx[M];
#ifndef NONBE_FIX_2493_EXTRACT_L_ivas_core_dec_fx
    Word32 conceal_eof_gain32;
#endif

    error = IVAS_ERR_OK;
    move32();
@@ -259,16 +261,24 @@ ivas_error ivas_core_dec_fx(
        test();
        IF( !st->bfi && st->prev_bfi && GT_32( st->total_brate, SID_2k40 ) && ( EQ_16( st->last_core_bfi, TCX_20_CORE ) || EQ_16( st->last_core_bfi, TCX_10_CORE ) ) && st->hTcxDec != NULL )
        {
#ifdef NONBE_FIX_2493_EXTRACT_L_ivas_core_dec_fx
            Word32 factor = Mpy_32_16_1( st->hTcxDec->conceal_eof_gain32, st->last_concealed_gain_syn_deemph );
            Word16 shift;

            shift = add( norm_l( factor ), norm_arr( st->hHQ_core->old_out_fx, st->hTcxDec->L_frameTCX ) );
            st->hHQ_core->Q_old_wtda = add( shift, sub( st->hHQ_core->Q_old_wtda, add( st->last_concealed_gain_syn_deemph_e, st->hTcxDec->conceal_eof_gain_e ) ) );
#else
            conceal_eof_gain32 = L_shr_sat( st->hTcxDec->conceal_eof_gain32, sub( 16, st->hTcxDec->conceal_eof_gain_e ) ); // e = 31 - Q , 16 - e => 16 - (31 - Q) => Q - 15,
#endif
                                                                                                                           // shr(16 -e ) = shr(Q -15) => 15 - Q ==> Q15
            FOR( i = 0; i < st->hTcxDec->L_frameTCX; i++ )
            {
                L_tmp = Mpy_32_16_1( conceal_eof_gain32, st->hHQ_core->old_out_fx[i] ); // Q0 (15+1+0 - (15 + 1)
                L_tmp = Mpy_32_16_1( L_tmp, st->last_concealed_gain_syn_deemph );       // Q(0+15 - last_concealed_gain_syn_deemph_e -15)
#ifdef NONBE_FIX_2493_EXTRACT_L_ivas_core_dec_fx
                L_tmp = L_shl_sat( L_tmp, add( st->last_concealed_gain_syn_deemph_e, 16 ) ); // Q0 (-last_concealed_gain_syn_deemph_e +last_concealed_gain_syn_deemph_e)
                st->hHQ_core->old_out_fx[i] = extract_h( L_tmp );                            // Q0
                L_tmp = L_shl( Mpy_32_16_1( factor, st->hHQ_core->old_out_fx[i] ), shift ); // st->hHQ_core->Q_old_wtda
                st->hHQ_core->old_out_fx[i] = extract_h( L_tmp );
#else
                L_tmp = Mpy_32_16_1( conceal_eof_gain32, st->hHQ_core->old_out_fx[i] ); // Q0 (15+1+0 - (15 + 1)
                L_tmp = Mpy_32_16_1( L_tmp, st->last_concealed_gain_syn_deemph );       // Q(0+15 - last_concealed_gain_syn_deemph_e -15)
                L_tmp = L_shl( L_tmp, st->last_concealed_gain_syn_deemph_e ); // Q0 (-last_concealed_gain_syn_deemph_e +last_concealed_gain_syn_deemph_e)
#ifdef FIX_2493_CHECK_EXTRACT_L
                st->hHQ_core->old_out_fx[i] = extract_l2( L_tmp ); // Q0
@@ -279,14 +289,19 @@ ivas_error ivas_core_dec_fx(
                move16();
            }

#ifdef NONBE_FIX_2493_EXTRACT_L_ivas_core_dec_fx
            shift = add( norm_l( factor ), norm_arr( st->hHQ_core->old_out_LB_fx, st->L_frame ) );
            st->hHQ_core->Q_old_wtda_LB = add( shift, sub( st->hHQ_core->Q_old_wtda_LB, st->last_concealed_gain_syn_deemph_e ) );
#endif

            FOR( i = 0; i < st->L_frame; i++ )
            {
                L_tmp = Mpy_32_16_1( conceal_eof_gain32, st->hHQ_core->old_out_LB_fx[i] ); // Q0 (15+1+0 - (15 + 1)
                L_tmp = Mpy_32_16_1( L_tmp, st->last_concealed_gain_syn_deemph );          // Q(0+15 - last_concealed_gain_syn_deemph_e -15)
#ifdef NONBE_FIX_2493_EXTRACT_L_ivas_core_dec_fx
                L_tmp = L_shl_sat( L_tmp, add( st->last_concealed_gain_syn_deemph_e, 16 ) ); // Q0 (-last_concealed_gain_syn_deemph_e +last_concealed_gain_syn_deemph_e)
                st->hHQ_core->old_out_LB_fx[i] = extract_h( L_tmp );                         // Q0
                L_tmp = L_shl( Mpy_32_16_1( factor, st->hHQ_core->old_out_LB_fx[i] ), shift ); // st->hHQ_core->Q_old_wtda_LB
                st->hHQ_core->old_out_LB_fx[i] = extract_h( L_tmp );
#else
                L_tmp = Mpy_32_16_1( conceal_eof_gain32, st->hHQ_core->old_out_LB_fx[i] ); // Q0 (15+1+0 - (15 + 1)
                L_tmp = Mpy_32_16_1( L_tmp, st->last_concealed_gain_syn_deemph );          // Q(0+15 - last_concealed_gain_syn_deemph_e -15)
                L_tmp = L_shl( L_tmp, st->last_concealed_gain_syn_deemph_e ); // Q0 (-last_concealed_gain_syn_deemph_e +last_concealed_gain_syn_deemph_e)
#ifdef FIX_2493_CHECK_EXTRACT_L
                st->hHQ_core->old_out_LB_fx[i] = extract_l2( L_tmp ); // Q0