Commit 813cd382 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Fix for 3GPP issue 1566: Complexity measurement crashes: MC7_1 encoder (core dumped)

Link #1566
parent d61cd826
Loading
Loading
Loading
Loading
Loading
+8 −25
Original line number Diff line number Diff line
@@ -1563,9 +1563,12 @@ void TonalMDCTConceal_InsertNoise_ivas_fx(
                        move16();
                        Word32 y = concealment_noise[l]; // concealment_noise_e
                        move32();
                        shift1 = norm_l( y );
                        y = L_shl( y, shift1 );

                        last_block_nrg_correct = L_add( last_block_nrg_correct, Mpy_32_16_1( L_msu( 0, x, fac ), x ) );                                                                                                                        // exp = 2 * x_exp + ld
                        y = L_negate( Mpy_32_32( y, y ) );                                                                                                                                                                // Q31-2* concealment_noise_e
                        hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, y, 2 * concealment_noise_e, &hTonalMDCTConc->curr_noise_nrg_exp ); // Q31- hTonalMDCTConc->curr_noise_nrg_exp
                        y = L_negate( Mpy_32_32( y, y ) );                                                                                                                                                                                     // Q31-(2* concealment_noise_e + shift1)
                        hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, y, shl( sub( concealment_noise_e, shift1 ), 1 ), &hTonalMDCTConc->curr_noise_nrg_exp ); // Q31- hTonalMDCTConc->curr_noise_nrg_exp
                        move32();
                    }
                }
@@ -1631,29 +1634,9 @@ void TonalMDCTConceal_InsertNoise_ivas_fx(
            /* actual fadeout is done in this case */
            ELSE
            {
                Word32 num, den;
                Word16 exp_num, exp_den;

                exp_num = cngLevelBackgroundTrace_bfi_e;
                move16();
                exp_den = hTonalMDCTConc->curr_noise_nrg_exp;
                move16();

                ld = norm_l( cngLevelBackgroundTrace_bfi );
                num = L_shl( cngLevelBackgroundTrace_bfi, ld ); // Q15 - exp_num + ld
                exp_num = sub( exp_num, ld );
                ld = norm_l( hTonalMDCTConc->curr_noise_nrg );
                den = L_shl( hTonalMDCTConc->curr_noise_nrg, ld ); // Q15 - exp_den + ld
                exp_den = sub( exp_den, ld );

                exp = sub( exp_num, exp_den );
                tmp = BASOP_Util_Divide3232_Scale( cngLevelBackgroundTrace_bfi, hTonalMDCTConc->curr_noise_nrg, &exp );
                exp = add( exp, sub( cngLevelBackgroundTrace_bfi_e, hTonalMDCTConc->curr_noise_nrg_exp ) );

                IF( GT_32( num, den ) )
                {
                    num = L_shr( num, 1 ); // Q31- exp -1
                    exp = add( exp, 1 );
                }
                tmp = div_l( num, round_fx( den ) );
                tmp = Sqrt16( tmp, &exp );
                g = mult_r( g, tmp ); // exponent of g = exp

+15 −2
Original line number Diff line number Diff line
@@ -1613,9 +1613,22 @@ static void ivas_param_mc_quantize_ilds_fx(
    {
        dmx_ener_fx = BASOP_Util_Add_Mant32Exp( dmx_ener_fx, dmx_ener_e, Cx_fx[k][k], Cx_e[k][k], &dmx_ener_e );
    }
    /* ener_fac = 10.0f * log10f( ( tot_ener + EPSILON ) / ( dmx_ener + EPSILON ) ); */
    IF( tot_ener_fx == 0 )
    {
        tot_ener_fx = 9223; // 1e-15(EPSILON) in Q63
        tot_ener_e = -32;
        move32();
        move16();
    }
    IF( dmx_ener_fx == 0 )
    {
        dmx_ener_fx = 9223; // 1e-15(EPSILON) in Q63
        dmx_ener_e = -32;
        move32();
        move16();
    }

    tot_ener_fx = BASOP_Util_Add_Mant32Exp( tot_ener_fx, tot_ener_e, EPSILON_FX, 0, &tot_ener_e );
    dmx_ener_fx = BASOP_Util_Add_Mant32Exp( dmx_ener_fx, dmx_ener_e, EPSILON_FX, 0, &dmx_ener_e );
    L_tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( tot_ener_fx, dmx_ener_fx, &tmp_e ) );
    tmp_e = add( sub( tot_ener_e, dmx_ener_e ), tmp_e );
    ener_fac_fx = BASOP_Util_Log10( L_tmp, tmp_e );     // Q25
+3 −2
Original line number Diff line number Diff line
@@ -4016,10 +4016,11 @@ void ivas_lfe_synth_with_filters_fx(
        }
        ELSE
        {
            Flag overFlow;
            lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/
            lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp );
            lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp );           // Q15-lfeGain_fx_exp
            lfeGain_fx = shl_r( lfeGain_fx, lfeGain_fx_exp );   // Q15
            lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp, &overFlow ); // Q15
        }
        IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( Q31, hMasaLfeSynth->targetEneTransSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, sub( Q31, hMasaLfeSynth->transportEneSmooth_q ) ), 1 ) )
        {