Commit f48701fc authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'bug_fixes_precision_impr' into 'main'

Precision improvement in wb_vad_ivas_fx [allow regression]

See merge request !1577
parents b3570dfe 0d81dfcd
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -377,6 +377,8 @@ ivas_error init_encoder_fx(
        move16();
        st_fx->hVAD->L_snr_sum_vad_fx = 0;
        move32();
        st_fx->hVAD->q_L_snr_sum_vad = Q31;
        move16();
    }
    ELSE
    {
+12 −23
Original line number Diff line number Diff line
@@ -223,6 +223,7 @@ ivas_error pre_proc_front_ivas_fx(
    Word16 res_cod_SNR_M_fx_e[STEREO_DFT_BAND_MAX];
    Word16 Qfact_PS, q_lf_E_fx;
    Word16 enerBuffer_fx_exp_buf[CLDFB_NO_CHANNELS_MAX];
    Word32 bckr_temp[NB_BANDS];
#ifdef DEBUG_MODE_INFO
    Word32 *in_buff_temp;
    Word16 in_q_temp;
@@ -781,21 +782,9 @@ ivas_error pre_proc_front_ivas_fx(
        move16();
    }

    Word16 scale = add( L_norm_arr( st->hNoiseEst->enrO_fx, NB_BANDS ), st->hNoiseEst->q_enrO );
    scale = s_min( scale, fr_bands_fx_q );

    scale_sig32( st->hNoiseEst->enrO_fx, NB_BANDS, sub( scale, st->hNoiseEst->q_enrO ) );
    st->hNoiseEst->q_enrO = scale;
    move16();

    scale_sig32( fr_bands_fx, 2 * NB_BANDS, sub( scale, fr_bands_fx_q ) );
    fr_bands_fx_q = scale;
    move16();

    st->vad_flag = wb_vad_ivas_fx( st, fr_bands_fx, fr_bands_fx_q, &i, &i, &i, &snr_sum_he_fx, &localVAD_HE_SAD,
                                   &( st->flag_noisy_speech_snr ), NULL, NULL, -MAX_16, -MAX_16 ); //-100000f == max 16bit float
    move16();

#ifdef DEBUG_FORCE_DIR
    if ( st->force_dir[0] != '\0' )
    {
@@ -919,13 +908,13 @@ ivas_error pre_proc_front_ivas_fx(
     *----------------------------------------------------------------*/

    noise_est_down_ivas_fx( fr_bands_fx, fr_bands_fx_q, st->hNoiseEst->bckr_fx, &st->hNoiseEst->q_bckr, tmpN_fx, &q_tmpN, tmpE_fx, &q_tmpE, st->min_band, st->max_band,
                            &st->hNoiseEst->totalNoise_fx, Etot_fx, &st->hNoiseEst->Etot_last_32fx, &st->hNoiseEst->Etot_v_h2_fx );
                            &st->hNoiseEst->totalNoise_fx, Etot_fx, &st->hNoiseEst->Etot_last_32fx, &st->hNoiseEst->Etot_v_h2_32fx );

    test();
    IF( lr_vad_enabled && st->idchan == 0 )
    {
        noise_est_down_ivas_fx( fr_bands_LR_fx[0], fr_bands_LR_fx_q[0], hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, &hCPE->hFrontVad[0]->hNoiseEst->q_bckr, tmpN_LR_fx[0], &q_tmpN_LR[0], tmpE_LR_fx[0], &q_tmpE_LR[0], st->min_band, st->max_band, &hCPE->hFrontVad[0]->hNoiseEst->totalNoise_fx, L_deposit_h( Etot_LR_fx[0] ), &hCPE->hFrontVad[0]->hNoiseEst->Etot_last_32fx, &hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_fx );
        noise_est_down_ivas_fx( fr_bands_LR_fx[1], fr_bands_LR_fx_q[1], hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, &hCPE->hFrontVad[1]->hNoiseEst->q_bckr, tmpN_LR_fx[1], &q_tmpN_LR[1], tmpE_LR_fx[1], &q_tmpE_LR[1], st->min_band, st->max_band, &hCPE->hFrontVad[1]->hNoiseEst->totalNoise_fx, L_deposit_h( Etot_LR_fx[1] ), &hCPE->hFrontVad[1]->hNoiseEst->Etot_last_32fx, &hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_fx );
        noise_est_down_ivas_fx( fr_bands_LR_fx[0], fr_bands_LR_fx_q[0], hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, &hCPE->hFrontVad[0]->hNoiseEst->q_bckr, tmpN_LR_fx[0], &q_tmpN_LR[0], tmpE_LR_fx[0], &q_tmpE_LR[0], st->min_band, st->max_band, &hCPE->hFrontVad[0]->hNoiseEst->totalNoise_fx, L_deposit_h( Etot_LR_fx[0] ), &hCPE->hFrontVad[0]->hNoiseEst->Etot_last_32fx, &hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_32fx );
        noise_est_down_ivas_fx( fr_bands_LR_fx[1], fr_bands_LR_fx_q[1], hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, &hCPE->hFrontVad[1]->hNoiseEst->q_bckr, tmpN_LR_fx[1], &q_tmpN_LR[1], tmpE_LR_fx[1], &q_tmpE_LR[1], st->min_band, st->max_band, &hCPE->hFrontVad[1]->hNoiseEst->totalNoise_fx, L_deposit_h( Etot_LR_fx[1] ), &hCPE->hFrontVad[1]->hNoiseEst->Etot_last_32fx, &hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_32fx );

        corr_shiftL_fx = correlation_shift_fx( hCPE->hFrontVad[0]->hNoiseEst->totalNoise_fx ); // Q15
        corr_shiftR_fx = correlation_shift_fx( hCPE->hFrontVad[1]->hNoiseEst->totalNoise_fx ); // Q15
@@ -1249,7 +1238,7 @@ ivas_error pre_proc_front_ivas_fx(
     * Update estimated noise energy and voicing cut-off frequency
     *-----------------------------------------------------------------*/

    scale = s_min( Q31, s_min( add( q_tmpN, L_norm_arr( tmpN_fx, NB_BANDS ) ), add( st->hNoiseEst->q_bckr, L_norm_arr( st->hNoiseEst->bckr_fx, NB_BANDS ) ) ) );
    Word16 scale = s_min( Q31, s_min( add( q_tmpN, L_norm_arr( tmpN_fx, NB_BANDS ) ), add( st->hNoiseEst->q_bckr, L_norm_arr( st->hNoiseEst->bckr_fx, NB_BANDS ) ) ) );
    scale = sub( scale, 1 ); // guard bits
    scale_sig32( st->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, st->hNoiseEst->q_bckr ) );
    scale_sig32( tmpN_fx, NB_BANDS, sub( scale, q_tmpN ) );
@@ -1278,7 +1267,7 @@ ivas_error pre_proc_front_ivas_fx(

    noise_est_ivas_fx( st, old_pitch1, tmpN_fx, epsP_fx, extract_h( Etot_fx ), *relE_fx, corr_shift_fx, tmpE_fx, q_tmpE, fr_bands_fx, fr_bands_fx_q, cor_map_sum_fx,
                       &ncharX_fx, &sp_div_fx, &q_sp_div, &non_staX_fx, loc_harm, lf_E_fx, q_lf_E_fx, &st->hNoiseEst->harm_cor_cnt, extract_h( st->hNoiseEst->Etot_l_lp_32fx ),
                       st->hNoiseEst->Etot_v_h2_fx, &st->hNoiseEst->bg_cnt, st->lgBin_E_fx, &dummy_fx, S_map_fx,
                       extract_h( st->hNoiseEst->Etot_v_h2_32fx ), &st->hNoiseEst->bg_cnt, st->lgBin_E_fx, &dummy_fx, S_map_fx,
                       hStereoClassif, NULL, st->ini_frame );

    test();
@@ -1321,14 +1310,14 @@ ivas_error pre_proc_front_ivas_fx(
        noise_est_ivas_fx( st, old_pitch1, tmpN_LR_fx[0], epsP_fx, Etot_LR_fx[0], sub( Etot_LR_fx[0], hCPE->hFrontVad[0]->lp_speech_fx ), corr_shiftL_fx,
                           tmpE_LR_fx[0], q_tmpE_LR[0], fr_bands_LR_fx[0], fr_bands_LR_fx_q[0], &cor_map_sum_LR_fx[0], &ncharX_LR_fx, &sp_div_LR_fx, &q_sp_div_LR,
                           &non_staX_LR_fx, loc_harmLR_fx, lf_E_LR_fx[0], lf_E_LR_fx_q, &hCPE->hFrontVad[0]->hNoiseEst->harm_cor_cnt,
                           extract_h( hCPE->hFrontVad[0]->hNoiseEst->Etot_l_lp_32fx ), hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_fx, &hCPE->hFrontVad[0]->hNoiseEst->bg_cnt,
                           extract_h( hCPE->hFrontVad[0]->hNoiseEst->Etot_l_lp_32fx ), extract_h( hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_32fx ), &hCPE->hFrontVad[0]->hNoiseEst->bg_cnt,
                           st->lgBin_E_fx, &dummy_fx, S_map_LR_fx, NULL, hCPE->hFrontVad[0], hCPE->hFrontVad[0]->ini_frame );

        /* Note: the index [0] in the last argument is intended, the ini_frame counter is only maintained in the zero-th channel's VAD handle */
        noise_est_ivas_fx( st, old_pitch1, tmpN_LR_fx[1], epsP_fx, Etot_LR_fx[1], sub( Etot_LR_fx[1], hCPE->hFrontVad[1]->lp_speech_fx ), corr_shiftR_fx,
                           tmpE_LR_fx[1], q_tmpE_LR[1], fr_bands_LR_fx[1], fr_bands_LR_fx_q[1], &cor_map_sum_LR_fx[1], &ncharX_LR_fx, &sp_div_LR_fx, &q_sp_div_LR,
                           &non_staX_LR_fx, loc_harmLR_fx, lf_E_LR_fx[1], lf_E_LR_fx_q, &hCPE->hFrontVad[1]->hNoiseEst->harm_cor_cnt,
                           extract_h( hCPE->hFrontVad[1]->hNoiseEst->Etot_l_lp_32fx ), hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_fx, &hCPE->hFrontVad[1]->hNoiseEst->bg_cnt,
                           extract_h( hCPE->hFrontVad[1]->hNoiseEst->Etot_l_lp_32fx ), extract_h( hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_32fx ), &hCPE->hFrontVad[1]->hNoiseEst->bg_cnt,
                           st->lgBin_E_fx, &dummy_fx, S_map_LR_fx, NULL, hCPE->hFrontVad[1], hCPE->hFrontVad[0]->ini_frame );
    }

@@ -1346,14 +1335,14 @@ ivas_error pre_proc_front_ivas_fx(
     * Find spectral tilt
     * UC and VC frame selection
     *-----------------------------------------------------------------*/

    scale = s_min( Q31, s_min( add( st->hNoiseEst->q_bckr, L_norm_arr( st->hNoiseEst->bckr_fx, NB_BANDS ) ), add( fr_bands_fx_q, L_norm_arr( fr_bands_fx, 2 * NB_BANDS ) ) ) );
    scale_sig32( fr_bands_fx, 2 * NB_BANDS, sub( scale, fr_bands_fx_q ) );
    scale_sig32( st->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, st->hNoiseEst->q_bckr ) );
    st->hNoiseEst->q_bckr = fr_bands_fx_q = scale;
    move16();
    Copy_Scale_sig32( st->hNoiseEst->bckr_fx, bckr_temp, NB_BANDS, sub( scale, st->hNoiseEst->q_bckr ) );
    fr_bands_fx_q = scale;
    move16();

    find_tilt_ivas_fx( fr_bands_fx, fr_bands_fx_q, st->hNoiseEst->bckr_fx, st->hNoiseEst->q_bckr, ee_fx, st->pitch, st->voicing_fx, lf_E_fx, q_lf_E_fx,
    find_tilt_ivas_fx( fr_bands_fx, fr_bands_fx_q, bckr_temp, scale, ee_fx, st->pitch, st->voicing_fx, lf_E_fx, q_lf_E_fx,
                       corr_shift_fx, st->input_bwidth, st->max_band, hp_E_fx, MODE1, &( st->bckr_tilt_lt ), st->Opt_SC_VBR );

    st->coder_type = find_uv_ivas_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, extract_h( Etot_fx ), hp_E_fx,
+2 −12
Original line number Diff line number Diff line
@@ -282,16 +282,6 @@ ivas_error front_vad_fx(
            move16();

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

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

            scale_sig32( fr_bands_fx[n], 2 * NB_BANDS, sub( scale, q_fr_bands[n] ) ); // scale
            q_fr_bands[n] = scale;
            move16();

            hFrontVad->hVAD->vad_flag = wb_vad_ivas_fx( sts[n], fr_bands_fx[n], q_fr_bands[n], &dummy, &dummy, &dummy, &snr_sum_he_fx,
                                                        &localVAD_HE_SAD[n], &dummy_short, hFrontVad->hVAD, hFrontVad->hNoiseEst,
                                                        hFrontVad->lp_speech_fx, hFrontVad->lp_noise_fx ); // Q0
@@ -613,7 +603,7 @@ ivas_error front_vad_spar_fx(

        Word16 q_tmpN, q_tmpE;
        noise_est_down_ivas_fx( fr_bands_fx[0], q_fr_bands[0], hFrontVad->hNoiseEst->bckr_fx, &hFrontVad->hNoiseEst->q_bckr, tmpN_fx, &q_tmpN, tmpE_fx, &q_tmpE, st->min_band, st->max_band,
                                &hFrontVad->hNoiseEst->totalNoise_fx, L_deposit_h( Etot_fx[0] ) /*q8->q24*/, &hFrontVad->hNoiseEst->Etot_last_32fx, &hFrontVad->hNoiseEst->Etot_v_h2_fx );
                                &hFrontVad->hNoiseEst->totalNoise_fx, L_deposit_h( Etot_fx[0] ) /*q8->q24*/, &hFrontVad->hNoiseEst->Etot_last_32fx, &hFrontVad->hNoiseEst->Etot_v_h2_32fx );

        corr_shift_fx = correlation_shift_fx( hFrontVad->hNoiseEst->totalNoise_fx ); /* Q15 */

@@ -755,7 +745,7 @@ ivas_error front_vad_spar_fx(

        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, extract_h( hFrontVad->hNoiseEst->Etot_l_lp_32fx ), hFrontVad->hNoiseEst->Etot_v_h2_fx,
                           lf_E_fx[0], q_lf_E[0], &hFrontVad->hNoiseEst->harm_cor_cnt, extract_h( hFrontVad->hNoiseEst->Etot_l_lp_32fx ), extract_h( hFrontVad->hNoiseEst->Etot_v_h2_32fx ),
                           &hFrontVad->hNoiseEst->bg_cnt, st->lgBin_E_fx, &sp_floor, S_map_fx, NULL, hFrontVad, hFrontVad->ini_frame );

        MVR2R_WORD16( st->pitch, st->pitch, 3 );
+8 −8
Original line number Diff line number Diff line
@@ -361,13 +361,13 @@ void noise_est_init_ivas_fx(
    hNoiseEst->Etot_l_fx = 0;
    hNoiseEst->Etot_l_lp_32fx = 0;
    hNoiseEst->Etot_last_32fx = 0;
    hNoiseEst->Etot_v_h2_fx = 0;
    hNoiseEst->Etot_v_h2_32fx = 0;
    hNoiseEst->sign_dyn_lp_fx = 0;
    move16();
    move16();
    move16();
    move16();
    move16();
    move32();
    move32();
    move32();

@@ -514,8 +514,8 @@ void noise_est_pre_32fx(
        move32();
        hNoiseEst->Etot_last_32fx = Etot; // Q24
        move32();
        hNoiseEst->Etot_v_h2_fx = 0;
        move16();
        hNoiseEst->Etot_v_h2_32fx = 0;
        move32();
        Etot_lp_32fx = Etot;
        move32();
        hNoiseEst->sign_dyn_lp_fx = 0;
@@ -750,7 +750,7 @@ void noise_est_down_ivas_fx(
    Word16 *totalNoise,    /* o  : noise estimate over all critical bands                */
    Word32 Etot,           /* i  : Energy of current frame                            Q24*/
    Word32 *Etot_last,     /* i/o: Energy of last frame            Q24                   */
    Word16 *Etot_v_h2      /* i/o: Energy variations of noise frames  Q8                 */
    Word32 *Etot_v_h2      /* i/o: Energy variations of noise frames  Q24                */
)

{
@@ -773,7 +773,7 @@ void noise_est_down_ivas_fx(
    L_Etot = Etot; /*Q24 for later AR1 computations*/
    move32();
    L_Etot_last = *Etot_last;
    L_Etot_v_h2 = L_shl( *Etot_v_h2, 16 );
    L_Etot_v_h2 = *Etot_v_h2;

    /*-----------------------------------------------------------------*
     * Estimate total noise energy
@@ -901,7 +901,7 @@ void noise_est_down_ivas_fx(
    L_Etot_v_h2 = Madd_32_16( L_tmp, L_Etot_v_h2, 32113 /* 0.98 in Q15 */ ); // Q24

    /* if (*Etot_v_h2 < 0.1f) {  *Etot_v_h2 = 0.1f; } */
    *Etot_v_h2 = s_max( round_fx( L_Etot_v_h2 ), 26 /* 0.1 in Q8*/ ); // Q8
    *Etot_v_h2 = L_max( L_Etot_v_h2, 1677722 /* 0.1 in Q24*/ ); // Q24
    move16();

    return;
@@ -3494,7 +3494,7 @@ void noise_est_ivas_fx(
                ) */
        ELSE IF( ( LT_16( hNoiseEst->act_pred_fx, 26214 /* 0.8 in Q15*/ ) && ( ( aE_bgd != 0 ) || ( PAU != 0 ) ) && ( LT_16( hNoiseEst->lt_haco_ev_fx, 3277 /* 0.1 in q15*/ ) ) ) ||
                 ( ( LT_16( hNoiseEst->act_pred_fx, 22938 /* 0.70 in Q15 */ ) ) && ( ( aE_bgd != 0 ) || ( LT_16( non_staB, 17 * 256 /* 17.0 in Q8 */ ) ) ) && ( PAU != 0 ) && ( LT_16( hNoiseEst->lt_haco_ev_fx, 4915 /* 0.15 in Q15 */ ) ) ) ||
                 ( GT_16( hNoiseEst->harm_cor_cnt, 80 ) && GT_16( hNoiseEst->totalNoise_fx, 5 * 256 /* 5.0 in Q8 */ ) && LT_16( Etot, s_max( 1 * 256, add( Etot_l_lp, add( hNoiseEst->Etot_v_h2_fx, shr( hNoiseEst->Etot_v_h2_fx, 1 ) ) /* 1.5= 1.0+.5 */ ) ) ) ) ||
                 ( GT_16( hNoiseEst->harm_cor_cnt, 80 ) && GT_16( hNoiseEst->totalNoise_fx, 5 * 256 /* 5.0 in Q8 */ ) && LT_16( Etot, s_max( 1 * 256, add( Etot_l_lp, extract_h( L_add( hNoiseEst->Etot_v_h2_32fx, L_shr( hNoiseEst->Etot_v_h2_32fx, 1 ) ) ) /* 1.5= 1.0+.5 */ ) ) ) ) ||
                 ( GT_16( hNoiseEst->harm_cor_cnt, 50 ) && GT_16( hNoiseEst->first_noise_updt, 30 ) && ( aE_bgd != 0 ) && GT_16( hNoiseEst->lt_aEn_zero_fx, 16384 /*.5 in Q15*/ ) ) || ( tn_ini != 0 ) )
        {
            updt_step = 3277;
+11 −2
Original line number Diff line number Diff line
@@ -1686,13 +1686,17 @@ void pitch_ol_ivas_fx(
            move16();

            /* enr1 = dotp( pt2, pt2, len[j] ) + 0.01f; */
            temp = 167772 /*0.01f in Q24*/;
            temp = 0;
            move64();
            FOR( m = 0; m < len[j]; m++ )
            {
                temp = W_mac0_16_16( temp, pt2[m], pt2[m] ); // 2*qwsp
            }

            temp = W_shl( temp, sub( Q24, shl( qwsp, 1 ) ) ); // Q24

            temp = W_add( temp, 167772 ); /*0.01f in Q24*/

            enr1_exp = W_norm( temp );
            enr1 = W_extract_h( W_shl( temp, enr1_exp ) ); // enr1_exp+24-32
            enr1_exp = sub( 39, enr1_exp );                // 31-(enr1_exp+24-32)
@@ -1724,13 +1728,18 @@ void pitch_ol_ivas_fx(
            move16();

            /* enr1 = dotp(pt4, pt4, len1[j]) + 0.01f; */
            temp = 167772 /*0.01f in Q24*/;
            temp = 0;
            move64();
            move64();
            FOR( m = 0; m < len1[j]; m++ )
            {
                temp = W_mac0_16_16( temp, pt4[m], pt4[m] ); // 2*qwsp
            }

            temp = W_shl( temp, sub( Q24, shl( qwsp, 1 ) ) ); // Q24

            temp = W_add( temp, 167772 ); /*0.01f in Q24*/

            enr1_exp = W_norm( temp );
            enr1 = W_extract_h( W_shl( temp, enr1_exp ) ); // enr1_exp+24-32
            enr1_exp = sub( 39, enr1_exp );                // 31-(enr1_exp+24-32)
Loading