Commit 57938ce2 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Updates for function noise_est_ivas_fx for MLD improvements

parent 24f29d12
Loading
Loading
Loading
Loading
Loading
+100 −95
Original line number Diff line number Diff line
@@ -56,22 +56,22 @@
 * Find LF/HF energy ratio
 *-------------------------------------------------------------------*/
void find_tilt_ivas_fx(
    const Word32 fr_bands[], /* i  : energy in frequency bands										Q_new*/
    const Word32 bckr[],     /* i  : per band background noise energy estimate						Q_new*/
    const Word32 fr_bands[], /* i  : energy in frequency bands						q_fr_bands*/
    const Word16 q_fr_bands, /* i  : Q of fr_bands						Q0*/
    const Word32 bckr[],     /* i  : per band background noise energy estimate    q_bckr*/
    const Word16 q_bckr,     /* i  : Q of bckr    Q0*/
    Word32 ee[2],            /* o  : lf/hf E ration for present frame							 Q6*/
    const Word16 pitch[3],   /* i  : open loop pitch values for 3 half-frames					 Q0*/
    const Word16 voicing[3], /* i  : normalized correlation for 3 half-frames					Q15*/
    const Word32 *lf_E,      /* i  : per bin energy  for low frequencies							Q_new - 2*/
    const Word32 *lf_E,      /* i  : per bin energy  for low frequencies         q_lf_E*/
    const Word16 q_lf_E,     /* i  : Q of lf_E         */
    const Word16 corr_shift, /* i  : normalized correlation correction							Q15*/
    const Word16 bwidth,     /* i  : input signal bandwidth                                         Q0*/
    const Word16 max_band,   /* i  : maximum critical band                                          Q0*/
    const Word16 bwidth,     /* i  : input signal bandwidth                                         */
    const Word16 max_band,   /* i  : maximum critical band                                          */
    Word32 hp_E[],           /* o  : energy in HF                                    Q_new*/
    const Word16 codec_mode, /* i  : MODE1 or MODE2													Q0*/
    const Word16 Q_new,      /* i  : scaling factor													*/
    Word32 *bckr_tilt_lt     /* i/o: lf/hf E ratio of background noise								Q16*/
    ,
    Word16 Opt_vbr_mode /* Q0 */
)
    const Word16 codec_mode, /* i  : MODE1 or MODE2                                      */
    Word32 *bckr_tilt_lt,    /* i/o: lf/hf E ratio of background noise  Q16                        */
    Word16 Opt_vbr_mode )
{
    Word32 lp_bckr = 0, hp_bckr = 0, lp_E, Ltmp;
    const Word32 *pt_E, *pt_bands, *pt_bckr, *hf_bands, *tmp_E;
@@ -81,6 +81,9 @@ void find_tilt_ivas_fx(
    Word16 m_Fs, e_Fs;
    Word16 m_cnt, e_cnt;
    Word16 m_hpE, e_hpE;
    Word64 sum;
    Word16 inv_bands, q_lp_E;
    Word32 Le_min_scaled, Ltmp2;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
@@ -91,7 +94,7 @@ void find_tilt_ivas_fx(
     * Initializations
     *-----------------------------------------------------------------*/

    IF( NE_16( bwidth, NB ) )
    IF( ( bwidth != NB ) )
    {
        /* WB processing */
        bin = BIN4_FX;
@@ -100,16 +103,20 @@ void find_tilt_ivas_fx(
        tmp_E = lf_E;        /* Q_new - 2 */
        pt_bckr = bckr;      /* Q_new */
        nb_bands = 10;
        inv_bands = 3277 /* 1/10 in Q15 */;
        move16();
        move16();
    }
    ELSE
    {
        /* NB processing */
        bin = add( shl( BIN4_FX, 1 ), BIN4_FX ); /* First useful frequency bin ~ 150 Hz    */
        bin = 3 * BIN4_FX;       /* First useful frequency bin ~ 150 Hz    */
        pt_bands = fr_bands + 1; /* Exlcude 1st critical band              */
        tmp_E = lf_E + 2;        /* Start at the 3rd bin (150 Hz)          */
        pt_bckr = bckr + 1;      /* Exlcude 1st critical band              */
        nb_bands = 9;
        inv_bands = 3641; /* 1/9 in Q15 */
        move16();
        move16(); /* Nb. of "low" frequency bands taken into account in NB processing      */
    }

@@ -122,21 +129,23 @@ void find_tilt_ivas_fx(

    /* bckr + voicing */
    /*lp_bckr = mean( pt_bckr, nb_bands );*/ /* estimated noise E in first critical bands, up to 1270 Hz */
    lp_bckr = Mean32( pt_bckr, nb_bands );
    sum = 0;
    move64();
    FOR( i = 0; i < nb_bands; i++ )
    {
        sum = W_mac_32_16( sum, pt_bckr[i], inv_bands ); // q_bckr+16
    }
    lp_bckr = W_shl_sat_l( sum, -16 );                                                                                  // q_bckr
    /*hp_bckr = 0.5f * (bckr[max_band-1] + bckr[max_band]);*/                                                           /* estimated noise E in last 2 critical bands */
#ifdef BASOP_NOGLOB
    hp_bckr = L_shr( L_add_sat( bckr[max_band - 1], bckr[max_band] ), 1 ); /* Q_new - 1 */
#else
    hp_bckr = L_shr( L_add( bckr[max_band - 1], bckr[max_band] ), 1 );
#endif
    hp_bckr = W_extract_h( W_mac_32_32( W_mult_32_32( bckr[max_band - 1], ONE_IN_Q30 ), bckr[max_band], ONE_IN_Q30 ) ); // q_bckr
    if ( hp_bckr == 0 )                                                                                                 /* Avoid division by zero. */
    {
        hp_bckr = L_deposit_l( 1 );
    }
    Ltmp = BASOP_Util_Divide3232_Scale_cadence( lp_bckr, hp_bckr, &e_tmp ); /* exp(e_tmp) */
    Ltmp = Mpy_32_16_r( Ltmp, 3277 /* 0.1 in Q15 */ );
    Ltmp = BASOP_Util_Divide3232_Scale_cadence( lp_bckr, hp_bckr, &e_tmp );
    Ltmp = Mpy_32_16_r( Ltmp, 3277 /* 0.1f in Q15 */ );
    Ltmp = L_shr_sat( Ltmp, sub( 15, e_tmp ) );
    *bckr_tilt_lt = L_add_sat( Mpy_32_16_r( *bckr_tilt_lt, 29491 ), Ltmp ); /* Q16 */
    *bckr_tilt_lt = L_add_sat( Mpy_32_16_r( *bckr_tilt_lt, 29491 /* 0.9f in Q15 */ ), Ltmp ); // Q16
    move32();

    test();
@@ -171,34 +180,31 @@ void find_tilt_ivas_fx(
    e_Fs = sub( 15, e_tmp );
    f0 = shr( m_Fs, sub( e_Fs, 4 ) ); /* Q4 */

    Le_min_scaled = L_shl( E_MIN_FXQ31, sub( q_fr_bands, Q31 ) ); // q_fr_bands=q_bckr

    FOR( i = 0; i < 2; i++ )
    {
        /*hp_E[i] = 0.5f * (hf_bands[max_band-1] + hf_bands[max_band]) - hp_bckr; */                                             /* averaged E in last 2 critical bands */
        Ltmp = L_add( L_shr( hf_bands[max_band - 1], 1 ), L_shr( hf_bands[max_band], 1 ) ); /* Q_new */
        hp_E[i] = L_sub( Ltmp, hp_bckr );                                                   /* Q_new */
        move32();
        IF( Opt_vbr_mode == 0 )
        {
            IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hp_E[i], sub( 31, Q_new ), E_MIN_IVAS_FX, 31 - Q19 ), -1 ) )
        Ltmp = W_extract_h( W_mac_32_32( W_mult_32_32( hf_bands[max_band - 1], ONE_IN_Q30 ), hf_bands[max_band], ONE_IN_Q30 ) ); // q_fr_bands
        Ltmp = L_sub( Ltmp, hp_bckr );                                                                                           // q_fr_bands

        Ltmp2 = L_max( Ltmp, L_shl_sat( 1, q_fr_bands ) ); // q_fr_bands, saturation is added because q_fr_bands is limited to 31
        if ( Opt_vbr_mode == 0 )
        {
                hp_E[i] = L_shl( E_MIN_IVAS_FX, sub( Q_new, Q19 ) );
                move32();
            Ltmp2 = L_max( Ltmp, Le_min_scaled ); // q_fr_bands
        }
        }
        ELSE
        {
            hp_E[i] = L_max( hp_E[i], L_shl( 1, Q_new ) );
        hp_E[i] = L_max( Ltmp2, 1 ); // to prevent division by zero
        move32();
        }

        test();
        IF( GT_16( mean_voi, TH_COR_FX ) && LT_16( pitch[2], TH_PIT_FX ) ) /* High-pitched voiced frames */
        {
            freq = bin;
            freq = bin; // Q4
            move16();   /* 1st useful frequency bin */
            m_cnt = 0;
            move16();
            lp_E = L_deposit_l( 0 );
            sum = 0;
            move64();

            f1 = add( shr( f0, 1 ), f0 ); /* Middle between 2 harmonics */
            f2 = f0;
@@ -208,14 +214,10 @@ void find_tilt_ivas_fx(
                FOR( ; freq <= f1; freq += BIN4_FX )
                {
                    /* include only bins sufficiently close to harmonics */
                    tmp = sub( freq, f2 ); /* Q4 */
                    IF( L_mac0( -(Word32) TH_D_FX * TH_D_FX, tmp, tmp ) < 0 )
                    tmp = sub( freq, f2 );
                    IF( L_mac0( -TH_D_FX * TH_D_FX, tmp, tmp ) < 0 )
                    {
#ifdef BASOP_NOGLOB
                        lp_E = L_add_o( *pt_E, lp_E, &Overflow ); /* Q_new - 1 */
#else
                        lp_E = L_add( *pt_E, lp_E );
#endif
                        sum = W_mac_32_16( sum, *pt_E, 1 ); // q_lf_E+1
                        m_cnt = add( m_cnt, 1 );
                    }
                    pt_E++;
@@ -229,52 +231,65 @@ void find_tilt_ivas_fx(
#endif
            }
            /*lp_E = lp_E / (float)cnt - lp_bckr;*/
            e_tmp = sub( norm_l( lp_E ), 1 );
            m_tmp = extract_h( L_shl( lp_E, e_tmp ) );

            e_tmp = sub( e_tmp, 2 ); /* lf_e divided by 4 in anal_sp */
            e_tmp = sub( W_norm( sum ), 1 );
            m_tmp = extract_h( W_extract_h( W_shl( sum, e_tmp ) ) ); // q_lf_E+1+e_tmp-32-16
            e_tmp = sub( add( q_lf_E, e_tmp ), 47 );

            e_cnt = norm_s( m_cnt );
            m_cnt = shl( m_cnt, e_cnt );
            m_cnt = shl( m_cnt, e_cnt ); // e_cnt

            m_tmp = div_s( m_tmp, m_cnt );
            e_tmp = sub( e_tmp, e_cnt );

#ifdef BASOP_NOGLOB
            lp_E = L_sub_o( L_shr_o( m_tmp, sub( e_tmp, 1 ), &Overflow ), lp_bckr, &Overflow );
#else
            lp_E = L_sub( L_shr( m_tmp, sub( e_tmp, 1 ) ), lp_bckr );
#endif
            m_tmp = div_s( m_tmp, m_cnt ); // Q15+e_tmp-e_cnt
            e_tmp = add( Q15, sub( e_tmp, e_cnt ) );
            sum = W_shl( m_tmp, sub( add( q_bckr, 1 ), e_tmp ) ); // q_bckr+1
            sum = W_msu_32_16( sum, lp_bckr, 1 );                 // q_bckr+1
            q_lp_E = W_norm( sum );
            lp_E = W_extract_h( W_shl( sum, q_lp_E ) ); // q_bckr+1+q_lp_E-32
            q_lp_E = sub( add( q_lp_E, q_bckr ), Q31 );

            pt_E = tmp_E + VOIC_BINS; /* Update for next half-frame		Q_new - 1 */
        }
        ELSE /* Other than high-pitched voiced frames */
        {
            /*lp_E = mean( pt_bands, nb_bands ) - lp_bckr;*/ /* averaged E in first critical bands, up to 1270 Hz */
            lp_E = L_sub( Mean32( pt_bands, nb_bands ), lp_bckr );
        }
        IF( Opt_vbr_mode == 0 )
            sum = 0;
            move64();
            FOR( Word16 j = 0; j < nb_bands; j++ )
            {
            IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( lp_E, sub( 31, Q_new ), E_MIN_IVAS_FX, 31 - Q19 ), -1 ) )
            {
                lp_E = L_shl( E_MIN_IVAS_FX, sub( Q_new, Q19 ) );
                sum = W_mac_32_16( sum, pt_bands[j], inv_bands ); // q_fr_bands+16
            }
            sum = W_mac_32_16( sum, lp_bckr, -ONE_IN_Q15 ); // q_fr_bands+16
            lp_E = W_round48_L( sum );                      // q_fr_bands=q_bckr
            q_lp_E = q_bckr;                                // q_fr_bands=q_bckr
            move16();
        }
        ELSE
        test();
        IF( Opt_vbr_mode == 0 && GT_32( L_shl_sat( Le_min_scaled, sub( q_lp_E, q_bckr ) ), lp_E ) )
        {
            lp_E = E_MIN_FXQ31;
            q_lp_E = Q31;
            move32();
            move16();
        }
        if ( Opt_vbr_mode != 0 )
        {
            lp_E = L_max( lp_E, 0 );
            lp_E = L_max( lp_E, 0 ); // q_lp_E
        }
        /*ee[i] = lp_E / hp_E[i];*/ /* LF/HF ratio */

        if ( lp_E == 0 )
        {
            ee[i] = 0;
            move32();
        }
        test();
        IF( lp_E != 0 && hp_E[i] != 0 )
        IF( lp_E != 0 )
        {
            e_tmp = sub( norm_l( lp_E ), 1 );
            m_tmp = extract_h( L_shl( lp_E, e_tmp ) );
            m_tmp = extract_h( L_shl( lp_E, e_tmp ) ); // e_tmp+q_lp_E-16
            e_hpE = norm_l( hp_E[i] );
            m_hpE = extract_h( L_shl( hp_E[i], e_hpE ) );
            m_tmp = div_s( m_tmp, m_hpE ); /* e_tmp + e_hpE */
            e_tmp = sub( e_tmp, e_hpE );

            m_hpE = extract_h( L_shl( hp_E[i], e_hpE ) ); // e_hpE+q_bckr-16
            m_tmp = div_s( m_tmp, m_hpE );                // Q15+(e_tmp+q_lp_E)-(e_hpE+q_bckr)
            e_tmp = sub( add( e_tmp, q_lp_E ), add( e_hpE, q_bckr ) );
#ifdef BASOP_NOGLOB
            ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */
#else                                                                  /* BASOP_NOGLOB */
@@ -282,18 +297,8 @@ void find_tilt_ivas_fx(
#endif
            move32();
        }
        ELSE IF( lp_E == 0 )
        {
            ee[i] = L_deposit_l( 0 );
            move32();
        }
        ELSE
        {
            ee[i] = MAX_32;
            move32();
        }

        IF( EQ_16( bwidth, NB ) ) /* For NB input, compensate for the missing bands */
        IF( bwidth == NB ) /* For NB input, compensate for the missing bands */
        {
#ifdef BASOP_NOGLOB
            Ltmp = L_shl_o( ee[i], 3, &Overflow ); /* Q6 */
+92 −146

File changed.

Preview size limit exceeded, changes collapsed.

+40 −50
Original line number Diff line number Diff line
@@ -196,7 +196,6 @@ ivas_error front_vad_fx(
        set_val_Word32( band_energies_LR_fx, 0, 2 * NB_BANDS );
        Qband = -1;
        move16();
        Word16 Q_new_old = add( sub( Q_inp, Qband ), Q_add );

        IF( *front_create_flag )
        {
@@ -205,8 +204,6 @@ ivas_error front_vad_fx(
            move16();
            FOR( n = 0; n < n_chan; n++ )
            {
                scale_sig32( hFrontVads[n]->hNoiseEst->bckr_fx, 20, sub( add( Q_new_old, QSCALE ), Q11 ) ); /* Q_new_old + QSCALE */
                scale_sig32( hFrontVads[n]->hNoiseEst->enrO_fx, 20, sub( add( Q_new_old, QSCALE ), Q11 ) ); /* Q_new_old + QSCALE */
                hFrontVads[n]->lp_speech_fx = shr( hFrontVads[n]->lp_speech_fx, 1 );
                move16();

@@ -279,25 +276,15 @@ ivas_error front_vad_fx(
            v_add_fx( &band_energies_fx[0], &band_energies_LR_fx[0], &band_energies_LR_fx[0], 2 * NB_BANDS ); // q_band_energies_LR

            /* add up energies for later calculating average of channel energies */
            Q_new_old = Q_new;
            move16();

            Word32 Etot_fx = L_deposit_h( Etot_LR_fx[n] ); /* Q24 */

            noise_est_pre_32fx( Etot_fx, hFrontVads[0]->ini_frame, hFrontVad->hNoiseEst, 0, 0, 0 );

            /* wb_vad */
            Word16 scale = getScaleFactor32( hFrontVads[n]->hNoiseEst->bckr_fx, NB_BANDS );
            scale_sig32( hFrontVads[n]->hNoiseEst->bckr_fx, NB_BANDS, scale ); // hFrontVads[n]->hNoiseEst->q_bckr + scale
            hFrontVads[n]->hNoiseEst->q_bckr = add( hFrontVads[n]->hNoiseEst->q_bckr, scale );
            move16();

            scale = getScaleFactor32( hFrontVads[n]->hNoiseEst->enrO_fx, NB_BANDS );
            scale_sig32( hFrontVads[n]->hNoiseEst->enrO_fx, NB_BANDS, scale ); //  hFrontVads[n]->hNoiseEst->q_enrO + scale
            hFrontVads[n]->hNoiseEst->q_enrO = add( hFrontVads[n]->hNoiseEst->q_enrO, scale );
            move16();

            scale = s_min( q_fr_bands[n], s_min( hFrontVads[n]->hNoiseEst->q_bckr, hFrontVads[n]->hNoiseEst->q_enrO ) );
            Word16 scale = add( hFrontVads[n]->hNoiseEst->q_bckr, L_norm_arr( hFrontVads[n]->hNoiseEst->bckr_fx, NB_BANDS ) );
            scale = s_min( scale, add( hFrontVads[n]->hNoiseEst->q_enrO, L_norm_arr( hFrontVads[n]->hNoiseEst->enrO_fx, NB_BANDS ) ) );
            scale = s_min( q_fr_bands[n], scale );

            scale_sig32( hFrontVads[n]->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, hFrontVads[n]->hNoiseEst->q_bckr ) ); // scale
            hFrontVads[n]->hNoiseEst->q_bckr = scale;
@@ -581,15 +568,6 @@ ivas_error front_vad_spar_fx(
        move16();
        Word16 front_create_flag = 0;
        move16();
        Word16 Qband = -1;
        move16();
        Word16 Q_bands = Q9;
        move16();

        Scale_sig32( hFrontVad->hNoiseEst->ave_enr_fx, NB_BANDS, ( Q_bands + QSCALE ) - hFrontVad->hNoiseEst->ave_enr_q );  /* Q_bands + QSCALE */
        Scale_sig32( hFrontVad->hNoiseEst->ave_enr2_fx, NB_BANDS, ( Q_bands + QSCALE ) - hFrontVad->hNoiseEst->ave_enr_q ); /* Q_bands + QSCALE */
        hFrontVad->hNoiseEst->ave_enr_q = ( Q_bands + QSCALE );
        move16();
        Word16 tmp1;
        Word16 Q_inp_12k8 = hFrontVad->q_buffer_12k8;
        move16();
@@ -643,14 +621,6 @@ ivas_error front_vad_spar_fx(
         *-----------------------------------------------------------------*/
        Word16 scale;

        Word16 Q_new_old = add( sub( Q_inp, Qband ), Q_add );

        Scale_sig32( hFrontVad->hNoiseEst->bckr_fx, 20, sub( add( Q_new_old, QSCALE + 2 ), hFrontVad->hNoiseEst->q_bckr ) ); // Q_new_old +QSCALE +2
        Scale_sig32( hFrontVad->hNoiseEst->enrO_fx, 20, sub( add( Q_new_old, QSCALE + 2 ), hFrontVad->hNoiseEst->q_enrO ) ); // Q_new_old +QSCALE +2
        hFrontVad->hNoiseEst->q_bckr = add( Q_new_old, QSCALE + 2 );
        move16();
        hFrontVad->hNoiseEst->q_enrO = hFrontVad->hNoiseEst->q_bckr;
        move16();
        Word16 Q_buffer = hFrontVad->q_buffer_12k8;
        move16();
        Scale_sig( hFrontVad->mem_decim_fx, 2 * L_FILT_MAX, sub( Q_inp, hFrontVad->q_mem_decim ) ); /* Q_inp */
@@ -671,17 +641,16 @@ ivas_error front_vad_spar_fx(
        Q_inp_12k8 = hFrontVad->q_buffer_12k8;
        move16();

        Scale_sig32( fr_bands_fx[0], 40, sub( add( Q_bands, QSCALE ), q_fr_bands[0] ) ); // Q_bands+QSCALE
        q_fr_bands[0] = add( Q_bands, QSCALE );
        scale = s_min( add( q_fr_bands[0], L_norm_arr( fr_bands_fx[0], 2 * NB_BANDS ) ), add( hFrontVad->hNoiseEst->q_bckr, L_norm_arr( hFrontVad->hNoiseEst->bckr_fx, NB_BANDS ) ) );
        scale_sig32( fr_bands_fx[0], 40, sub( scale, q_fr_bands[0] ) );                                     // scale
        scale_sig32( hFrontVad->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->q_bckr ) ); // scale
        hFrontVad->hNoiseEst->q_bckr = q_fr_bands[0] = scale;
        move16();
        move16();

        Word32 e_min_scaled;
        e_min_scaled = L_shr_r( L_add( L_shr( E_MIN_FXQ15, sub( 14, add( Q_bands, QSCALE ) ) ), 1 ), 1 );
        noise_est_down_ivas_fx( fr_bands_fx[0], q_fr_bands[0], hFrontVad->hNoiseEst->bckr_fx, tmpN_fx, tmpE_fx, st->min_band, st->max_band,
                                &hFrontVad->hNoiseEst->totalNoise_fx, Etot_fx[0], &hFrontVad->hNoiseEst->Etot_last_fx, &hFrontVad->hNoiseEst->Etot_v_h2_fx );

        Scale_sig32( hFrontVad->hNoiseEst->bckr_fx, 20, sub( add( Q_bands, QSCALE ), hFrontVad->hNoiseEst->q_bckr ) ); /* Q_bands + QSCALE */
        hFrontVad->hNoiseEst->q_bckr = add( Q_bands, QSCALE );
        move16();
        noise_est_down_fx( fr_bands_fx[0], hFrontVad->hNoiseEst->bckr_fx, tmpN_fx, tmpE_fx, st->min_band, st->max_band, &hFrontVad->hNoiseEst->totalNoise_fx, Etot_fx[0], &hFrontVad->hNoiseEst->Etot_last_fx, &hFrontVad->hNoiseEst->Etot_v_h2_fx, Q_bands, e_min_scaled );
        corr_shift_fx = correlation_shift_fx( hFrontVad->hNoiseEst->totalNoise_fx ); /* Q15 */
        dtx_ivas_fx( st, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 );

@@ -752,21 +721,42 @@ ivas_error front_vad_spar_fx(
            }
            loc_harm = multi_harm_fx( st->lgBin_E_fx, hFrontVad->hNoiseEst->old_S_fx, hFrontVad->hNoiseEst->cor_map_fx, &hFrontVad->hNoiseEst->multi_harm_limit_fx, st->total_brate, st->bwidth, cor_strong_limit, &st->hSpMusClas->mean_avr_dyn_fx, &st->hSpMusClas->last_sw_dyn_fx, &cor_map_sum_fx, &dummy_fx, S_map_fx ); /* Q0 */
        }

        scale = getScaleFactor32( epsP_fx, M + 1 );
        Q_esp = add( Q_r[0], scale );
        Scale_sig32( epsP_fx, M + 1, scale );
        FOR( Word16 i = 0; i <= M; i++ )
        {
            L_Extract( epsP_fx[i], &epsP_h[i], &epsP_l[i] );
        }
        Q_bands = Q9;
        Scale_sig32( epsP_fx, M + 1, scale ); // Q_esp

        scale = add( hFrontVad->hNoiseEst->ave_enr_q, s_min( L_norm_arr( hFrontVad->hNoiseEst->ave_enr_fx, NB_BANDS ), L_norm_arr( hFrontVad->hNoiseEst->ave_enr2_fx, NB_BANDS ) ) );
        scale = s_min( scale, add( hFrontVad->hNoiseEst->q_bckr, L_norm_arr( tmpE_fx, NB_BANDS ) ) );
        scale = sub( s_min( scale, Q31 ), 1 );
        scale_sig32( hFrontVad->hNoiseEst->ave_enr_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->ave_enr_q ) );
        scale_sig32( hFrontVad->hNoiseEst->ave_enr2_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->ave_enr_q ) );
        scale_sig32( tmpE_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->q_bckr ) );
        hFrontVad->hNoiseEst->ave_enr_q = scale;
        move16();

        scale = add( hFrontVad->hNoiseEst->q_bckr, s_min( L_norm_arr( hFrontVad->hNoiseEst->bckr_fx, NB_BANDS ), L_norm_arr( tmpN_fx, NB_BANDS ) ) );
        scale = sub( s_min( Q31, scale ), 1 ); // guard bits
        scale_sig32( hFrontVad->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->q_bckr ) );
        scale_sig32( tmpN_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->q_bckr ) );
        hFrontVad->hNoiseEst->q_bckr = scale;
        move16();

        Scale_sig32( lf_E_fx[0], 148, sub( add( Q_bands, QSCALE - 2 ), q_lf_E[0] ) ); // Q_bands+QSCALE-2
        q_lf_E[0] = add( Q_bands, QSCALE - 2 );
        scale = add( hFrontVad->hNoiseEst->fr_bands_fx_q, s_min( L_norm_arr( hFrontVad->hNoiseEst->fr_bands1_fx, NB_BANDS ), L_norm_arr( hFrontVad->hNoiseEst->fr_bands2_fx, NB_BANDS ) ) );
        scale = s_min( scale, add( q_fr_bands[0], L_norm_arr( fr_bands_fx[0], 2 * NB_BANDS ) ) );
        scale = s_min( Q31, scale );
        scale_sig32( hFrontVad->hNoiseEst->fr_bands1_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->fr_bands_fx_q ) );
        scale_sig32( hFrontVad->hNoiseEst->fr_bands2_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->fr_bands_fx_q ) );
        scale_sig32( fr_bands_fx[0], 2 * NB_BANDS, sub( scale, q_fr_bands[0] ) );
        hFrontVad->hNoiseEst->fr_bands_fx_q = q_fr_bands[0] = scale;
        move16();
        move16();

        noise_est_ivas_fx( st, old_pitch, tmpN_fx, epsP_fx, Etot_fx[0], sub( Etot_fx[0], hFrontVad->lp_speech_fx ), corr_shift_fx, tmpE_fx,
                           hFrontVad->hNoiseEst->ave_enr_q, fr_bands_fx[0], q_fr_bands[0], &cor_map_sum_fx, NULL, &sp_div_fx, &Q_sp_div, &non_staX_fx, &loc_harm,
                           lf_E_fx[0], q_lf_E[0], &hFrontVad->hNoiseEst->harm_cor_cnt, hFrontVad->hNoiseEst->Etot_l_lp_fx, hFrontVad->hNoiseEst->Etot_v_h2_fx,
                           &hFrontVad->hNoiseEst->bg_cnt, st->lgBin_E_fx, &sp_floor, S_map_fx, NULL, hFrontVad, hFrontVad->ini_frame );

        noise_est_ivas_fx( st, old_pitch, tmpN_fx, epsP_h, epsP_l, Etot_fx[0], Etot_fx[0] - hFrontVad->lp_speech_fx, corr_shift_fx, tmpE_fx, fr_bands_fx[0], &cor_map_sum_fx, NULL, &sp_div_fx, &Q_sp_div, &non_staX_fx, &loc_harm, lf_E_fx[0], &hFrontVad->hNoiseEst->harm_cor_cnt, hFrontVad->hNoiseEst->Etot_l_lp_fx, hFrontVad->hNoiseEst->Etot_v_h2_fx, &hFrontVad->hNoiseEst->bg_cnt, st->lgBin_E_fx, Q_bands, e_min_scaled, &sp_floor, S_map_fx, NULL, hFrontVad, hFrontVad->ini_frame );
        MVR2R_WORD16( st->pitch, st->pitch, 3 );
        vad_param_updt_fx( st, st->pitch[1], corr_shift_fx, corr_shift_fx, A_fx, &hFrontVad, 1 );
        /* 1st stage speech/music classification (GMM model) */
+1 −1
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@ Word16 select_stereo_mode(
        test();
        test();
        test();
        IF( EQ_16( stereo_switching_flag, 1 ) && GT_32( hCPE->element_brate, IVAS_13k2 ) && LT_16( hCPE->hCoreCoder[0]->hSpMusClas->past_dlp_fx[0], ONE_IN_Q9 ) && LT_32( hCPE->hCoreCoder[0]->hSpMusClas->wdlp_xtalk_fx, -5243 /* -0.01 in Q19*/ ) && EQ_16( hCPE->hCoreCoder[0]->vad_flag, 1 ) && ( hCPE->hStereoMdct->sw_uncorr || hStereoClassif->xtalk_decision ) )
        IF( EQ_16( stereo_switching_flag, 1 ) && GT_32( hCPE->element_brate, IVAS_13k2 ) && LT_16( hCPE->hCoreCoder[0]->hSpMusClas->past_dlp_fx[0], ONE_IN_Q9 ) && LT_32( hCPE->hCoreCoder[0]->hSpMusClas->wdlp_xtalk_fx, -335544 /* -0.01 in Q25 */ ) && EQ_16( hCPE->hCoreCoder[0]->vad_flag, 1 ) && ( hCPE->hStereoMdct->sw_uncorr || hStereoClassif->xtalk_decision ) )
        {
            hStereoClassif->lrtd_mode = 1;
            move16();
+410 −396

File changed.

Preview size limit exceeded, changes collapsed.

Loading