Commit 688eb545 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Changes to fix LTV crashes and high mld observed in some LTV streams

parent 82564c4b
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3531,7 +3531,7 @@ void ivas_get_spar_md_from_dirac_fx(
            /*SPAR from DirAC*/
            set32_fx( response_avg_fx, 0, MAX_OUTPUT_CHANNELS );

            IF( GE_16( n_ts, 1 ) )
            IF( GT_16( n_ts, 1 ) )
            {
                ivas_dirac_dec_get_response_fx( extract_l( L_shr( azi_dirac_fx[band][i_ts], Q22 ) ), extract_l( L_shr( ele_dirac_fx[band][i_ts], Q22 ) ), response_avg_fx, order, Q30 );
            }
+12 −10
Original line number Diff line number Diff line
@@ -143,10 +143,11 @@ static Word16 ivas_imax2_jacobsen_mag_fx(
    const Word16 *pY;
    Word16 y_m1_re, y_0_re, y_p1_re;
    Word16 y_m1_im, y_0_im, y_p1_im;
    Word16 N_re, N_im;
    Word16 D_re, D_im;
    Word32 N_re, N_im;
    Word32 D_re, D_im;
    Word16 tmp, tmp_e;
    Word32 numer, denom;
    Word64 tmp_64_n, tmp_64_d;

    /* Jacobsen estimates peak offset relative y_0 using
     *                 X_m1 - X_p1
@@ -176,19 +177,20 @@ static Word16 ivas_imax2_jacobsen_mag_fx(
    move16();

    /* prepare numerator real and imaginary parts*/
    N_re = sub( y_m1_re, y_p1_re );
    N_im = sub( y_m1_im, y_p1_im );
    N_re = L_sub( y_m1_re, y_p1_re );
    N_im = L_sub( y_m1_im, y_p1_im );

    /* prepare denominator real and imaginary parts */

    /* D_re = 2 * y_0_re - y_m1_re - y_p1_re */
    D_re = add( sub( y_0_re, y_m1_re ), sub( y_0_re, y_p1_re ) );
    /* D_im = 2 * y_0_im - y_m1_im - y_p1_im */
    D_im = add( sub( y_0_im, y_m1_im ), sub( y_0_im, y_p1_im ) );
    D_re = L_sub( L_sub( L_shl( y_0_re, 1 ), y_m1_re ), y_p1_re );
    D_im = L_sub( L_sub( L_shl( y_0_im, 1 ), y_m1_im ), y_p1_im );

    /* REAL part of complex division  */
    numer = L_add( L_mult0( N_re, D_re ), L_mult0( N_im, D_im ) );
    denom = L_add( L_mult0( D_re, D_re ), L_mult0( D_im, D_im ) );
    tmp_64_n = W_mac_32_32( W_mult_32_32( N_re, D_re ), N_im, D_im );
    tmp_64_d = W_mac_32_32( W_mult_32_32( D_re, D_re ), D_im, D_im );
    tmp_e = s_min( W_norm( tmp_64_n ), W_norm( tmp_64_d ) );
    numer = W_extract_h( W_shl( tmp_64_n, tmp_e ) );
    denom = W_extract_h( W_shl( tmp_64_d, tmp_e ) );

    test();
    IF( numer != 0 && denom != 0 )
+18 −7
Original line number Diff line number Diff line
@@ -4705,12 +4705,19 @@ void decoder_tcx_noisefilling_fx(
                IF( ( frame_cnt == 0 ) && ( EQ_16( L_frameTCX, shr( hTcxDec->L_frameTCX, 1 ) ) ) && ( st->tcxonly ) && ( !st->tonal_mdct_plc_active ) && ( EQ_16( st->nbLostCmpt, 1 ) ) && ( NE_16( hTcxCfg->tcx_last_overlap_mode, FULL_OVERLAP ) ) && ( NE_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) ) )
                {
                    Word16 exp1, exp2;
                    exp1 = 0;
                    exp2 = 0;
                    Word32 E_2ndlast, E_last;
                    E_2ndlast = E_last = EPSILON_FX;
                    move16();
                    move16();
                    move32();
                    move32();

                    Word16 tmp_len;
                    IF( st->element_mode > EVS_MONO )
                    {
                        tmp_len = L_frame;
                        tmp_len = L_frameTCX;
                        move16();
                    }
                    ELSE
@@ -4719,21 +4726,25 @@ void decoder_tcx_noisefilling_fx(
                        move16();
                    }

                    E_2ndlast = CalculateAbsEnergy_fx( 1, &( st->hTonalMDCTConc->lastBlockData.spectralData[0] ), tmp_len, &exp2 );
                    E_last = CalculateAbsEnergy_fx( 1, &( st->hTonalMDCTConc->lastBlockData.spectralData[1] ), tmp_len, &exp1 );
                    FOR( i = 0; i < tmp_len; i = i + 2 )
                    {
                        E_2ndlast = BASOP_Util_Add_Mant32Exp( E_2ndlast, exp2, L_mult0( st->hTonalMDCTConc->lastBlockData.spectralData[i], st->hTonalMDCTConc->lastBlockData.spectralData[i] ), 29, &exp2 );
                        E_last = BASOP_Util_Add_Mant32Exp( E_last, exp1, L_mult0( st->hTonalMDCTConc->lastBlockData.spectralData[i + 1], st->hTonalMDCTConc->lastBlockData.spectralData[i + 1] ), 29, &exp1 );
                    }

                    BASOP_Util_Divide_MantExp( extract_h( E_2ndlast ), exp2, extract_h( E_last ), exp1, &tmp1, &tmp2 );
                    tmp1 = BASOP_Util_Divide3232_Scale( E_2ndlast, E_last, &tmp2 );
                    tmp2 = add( tmp2, sub( exp2, exp1 ) );

                    tmp1 = shr( tmp1, 2 ); /*Q13*/
#ifdef BASOP_NOGLOB
                    tmp1 = shl_sat( tmp1, tmp2 );
                    tmp1 = shl_sat( tmp1, sub( tmp2, 2 ) );
#else
                    tmp1 = shl( tmp1, tmp2 );
#endif

                    /* replace higher energy TCX5 frame by lower one to avoid energy fluctuation */
                    IF( st->element_mode > EVS_MONO )
                    {
                        tmp_len = L_frame;
                        tmp_len = L_frameTCX;
                        move16();
                    }
                    ELSE
+2 −1
Original line number Diff line number Diff line
@@ -1852,8 +1852,9 @@ void con_tcx_ivas_fx(

    /*gain_inov = 1.0f / (float)sqrt( dot_product( pt_exc, pt_exc, L_frame ) / L_frame + 0.01f );*/ /* normalize energy */
    L_tmp = Dot_productSq16HQ( 0, pt_exc /*Q0,15+1*/, L_frame, &tmp_e ) /*Q31,tmp_e+16+16*/;
    tmp_e = sub( add( tmp_e, shl( noise_e, 1 ) ), 1 ); // actual multiplier!
    L_tmp = Mpy_32_16_1( L_tmp, getInvFrameLen( L_frame ) /*W16Q21*/ ) /*W32Q37,tmp_e+16+16*/ /*Q5,tmp_e*/;
    tmp_e = add( tmp_e, 31 - 5 ); /*-->Q31*/
    tmp_e = add( tmp_e, 31 - 6 ); /*-->Q31*/
    gain_inov = 0;
    move16();
    gain_inov_e = 0;
+4 −0
Original line number Diff line number Diff line
@@ -746,6 +746,10 @@ ivas_error ivas_core_dec_fx(
#ifdef FIX_778_STEREO_BRATE_SWITCHING
                    if ( NE_16( st->core, st->last_core ) )
                    {
                        IF( st->hTcxDec )
                        {
                            Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, negate( st->Q_syn ) );
                        }
                        st->Q_syn = 0;
                        move16();
                    }
Loading