Commit fb7ce1f8 authored by Manuel Jander's avatar Manuel Jander
Browse files

Add extract_l overflow fixes...

Add extract_l overflow fixes NONBE_FIX_2493_CHECK_EXTRACT_L_res_bpf_adapt_ivas_fx and NONBE_FIX_2493_CHECK_EXTRACT_L_ivas_core_dec_fx
parent 441a528b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -143,6 +143,8 @@
#define NONBE_FIX_2493_EXTRACT_L_spectral_balancer_fx16 /* FhG: Fix extract_l overflow inside spectral_balancer_fx16() */
#define NONBE_FIX_2493_EXTRACT_L_IGF_CalculateStereoEnvelope_fx /* FhG: Fix extract_l overflow inside IGF_CalculateStereoEnvelope_fx() */
#define NONBE_FIX_2493_CHECK_EXTRACT_L_GetTCXMaxenergyChange_fx /* FhG: Fix extract_l overflow inside GetTCXMaxenergyChange_fx() */
#define NONBE_FIX_2493_CHECK_EXTRACT_L_res_bpf_adapt_ivas_fx /* FhG: Fix extract_l overflow inside res_bpf_adapt_ivas_fx() */
#define NONBE_FIX_2493_CHECK_EXTRACT_L_ivas_core_dec_fx  /* FhG: Fix extract_l overflow inside ivas_core_dec_fx() */
// #define NONBE_FIX_2493_CHECK_EXTRACT_L_EnhanceClass_fx  /* FhG: Fix extract_l overflow inside EnhanceClass_fx() (EVS) */
// #define NONBE_FIX_2493_CHECK_EXTRACT_L_decoder_tcx_post_fx /* FhG: Fix extract_l overflow inside decoder_tcx_post_fx() (EVS) */
#define FIX_2584_TD_SM_ISSUE                            /* VA: Fix inconsistencies in the SM part of the TD stereo */
+15 −0
Original line number Diff line number Diff line
@@ -990,8 +990,13 @@ Word16 res_bpf_adapt_ivas_fx(
        move16();
        i_end = 64;
        move16();
#ifdef NONBE_FIX_2493_CHECK_EXTRACT_L_res_bpf_adapt_ivas_fx
        bw_inv = 10486;
        move16(); /* 1/(64 - 39) in Q18 */
#else
        bw_inv = 1311;
        move16(); /* 1/(64 - 39) in Q15 */
#endif
    }
    ELSE
    {
@@ -999,8 +1004,13 @@ Word16 res_bpf_adapt_ivas_fx(
        move16();
        i_end = 40;
        move16();
#ifdef NONBE_FIX_2493_CHECK_EXTRACT_L_res_bpf_adapt_ivas_fx
        bw_inv = 21845;
        move16(); /* 1/(40 - 28) in Q18 */
#else
        bw_inv = 2720;
        move16(); /* 1/(40 - 28) in Q15*/
#endif
    }

    /* Measure energy of high frequency band in MDCT domain */
@@ -1011,12 +1021,17 @@ Word16 res_bpf_adapt_ivas_fx(
        W_tmp = W_add_nosat( W_tmp, W_mult0_32_32( res_buf[i], res_buf[i] ) );
    }

#ifdef NONBE_FIX_2493_CHECK_EXTRACT_L_res_bpf_adapt_ivas_fx
    res_hb_nrg = W_extract_h( W_shl( W_tmp, sub( 32 - 3, shl( q_res, 1 ) ) ) ); // Q-3
    res_hb_nrg = Mpy_32_16_1( res_hb_nrg, bw_inv );                             // Q0
#else
#ifdef FIX_2493_CHECK_EXTRACT_L
    res_hb_nrg = W_extract_l2( W_shr( W_tmp, shl( q_res, 1 ) ) ); // Q0
#else
    res_hb_nrg = W_extract_l( W_shr( W_tmp, shl( q_res, 1 ) ) ); // Q0
#endif
    res_hb_nrg = Mpy_32_16_1( res_hb_nrg, bw_inv ); // Q0
#endif
    res_hb_nrg = L_add( Mpy_32_16_1( res_hb_nrg, STEREO_DFT_BPF_ADAPT_ALPHA_FX ), Mpy_32_16_1( hStereoDft->res_hb_nrg_mem_fx, sub( MAX_16, STEREO_DFT_BPF_ADAPT_ALPHA_FX ) ) );
    hStereoDft->res_hb_nrg_mem_fx = res_hb_nrg;
    move32();
+2 −3
Original line number Diff line number Diff line
@@ -1322,11 +1322,10 @@ void decoder_tcx_post_fx( Decoder_State *st_fx,
        tmp32_2 /*stepCompensate*/ = L_shl_r( L_deposit_h( hTcxDec->stepCompensate ), sub( hTcxDec->stepCompensate_e, 31 - 28 ) ); /*Q28*/
        FOR( i = 0; i < st_fx->L_frame; i++ )
        {
            tmp32 = L_shl( tmp32_1 /*Q28*/, -( 28 - 15 ) ); /*16Q15*/
#ifdef NONBE_FIX_2493_CHECK_EXTRACT_L_decoder_tcx_post_fx
            tmp32 = L_shl_sat( tmp32_1 /*Q28*/, -( 28 - 15 ) + 16 ); /*16Q15*/
            xn_buf[i] = extract_h( Mpy_32_16_1( tmp32, xn_buf[i] ) );
            xn_buf[i] = extract_h( L_shl_sat( Mpy_32_16_1( tmp32, xn_buf[i] ), 16 ) );
#else
            tmp32 = L_shl( tmp32_1 /*Q28*/, -( 28 - 15 ) ); /*16Q15*/
#ifdef FIX_2493_CHECK_EXTRACT_L_EVS
            xn_buf[i] = extract_l2( Mpy_32_16_1( tmp32, xn_buf[i] ) );
#else
+12 −2
Original line number Diff line number Diff line
@@ -265,11 +265,16 @@ ivas_error ivas_core_dec_fx(
            {
                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_CHECK_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
#else
                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
#else
                st->hHQ_core->old_out_fx[i] = extract_l( L_tmp ); // Q0
#endif
#endif
                move16();
            }
@@ -278,11 +283,16 @@ ivas_error ivas_core_dec_fx(
            {
                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_CHECK_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
#else
                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
#else
                st->hHQ_core->old_out_LB_fx[i] = extract_l( L_tmp ); // Q0
#endif
#endif
                move16();
            }