Commit 67d3d01f authored by vaclav's avatar vaclav
Browse files

harmonize swb_pre_proc_ivas_fx()

parent 4ddd2769
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -10258,7 +10258,7 @@ void swb_pre_proc_ivas_fx(
    Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i  : real buffer Q - q_reImbuffer             */
    Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i  : imag buffer Q - q_reImbuffer             */
    Word16 q_reImBuffer,                                        /* i  : scale data of real and imag CLDFB buffers*/
#ifdef HARMONIZE_TBE
#ifdef HARMONIZE_TBE2
    const CLDFB_SCALE_FACTOR *cldfbScale,                       /* i : scale data of real and imag CLDFB buffers */
#endif
    CPE_ENC_HANDLE hCPE                                         /* i/o: CPE encoder structure                    */
+6 −2
Original line number Diff line number Diff line
@@ -418,8 +418,12 @@ ivas_error evs_enc_fx(
    IF( GE_32( st->input_Fs, 16000 ) && ( LT_16( st->bwidth, SWB ) ) )
    {
        /* Common pre-processing for WB TBE and WB BWE */
#ifdef HARMONIZE_TBE2aa
        wb_pre_proc_ivas_fx( st, EVS_MONO, new_inp_resamp16k, hb_speech );
#else
        wb_pre_proc_fx( st, new_inp_resamp16k, hb_speech );
        /* o: new_inp_resamp16k at Q = -1 */
#endif
    }

    IF( EQ_16( st->extl, WB_TBE ) )
@@ -450,8 +454,8 @@ ivas_error evs_enc_fx(
    IF( !st->Opt_SC_VBR && GE_32( st->input_Fs, 32000 ) )
    {
        /* Common pre-processing for SWB(FB) TBE and SWB BWE */
#ifdef HARMONIZE_TBEaa
        swb_pre_proc_ivas_fx( st, new_swb_speech, shb_speech, &Q_shb_spch, realBuffer, imagBuffer, 0, &cldfbScale, NULL );
#ifdef HARMONIZE_TBE2
        swb_pre_proc_ivas_fx( st, new_swb_speech, shb_speech, realBuffer, imagBuffer, 0, &cldfbScale, NULL );
#else
        swb_pre_proc_fx( st, st->input_fx, new_swb_speech, shb_speech, &Q_shb_spch, realBuffer, imagBuffer, &cldfbScale );
#endif
+1 −1
Original line number Diff line number Diff line
@@ -734,7 +734,7 @@ ivas_error ivas_core_enc_fx(
            }

#ifdef REMOVE_SCALING_SHB_SPEECH
#ifdef HARMONIZE_TBE
#ifdef HARMONIZE_TBE2
            swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, shb_speech_fx, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], NULL, hCPE );
#else
            swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, shb_speech_fx, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE );
+59 −21
Original line number Diff line number Diff line
@@ -217,7 +217,6 @@ void wb_pre_proc_ivas_fx(
    move64();
    move64();


    TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD;
    FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD;

@@ -265,6 +264,29 @@ void wb_pre_proc_ivas_fx(
    Q_wb_sp = norm_s( max_wb );

    Copy_Scale_sig( new_inp_resamp16k, temp_buf, L_FRAME16k, -3 );

#ifdef HARMONIZE_TBE2
    IF( st_fx->element_mode == EVS_MONO )
    {
        tmp1 = 0;
        tmp2 = 0;
        move32();
        move32();
        tmp1 = L_mac0( tmp1, temp_buf[0], temp_buf[0] );
        FOR( i = 1; i < L_FRAME16k; i++ )
        {
            tmp1 = L_mac0( tmp1, temp_buf[i], temp_buf[i] );
            tmp2 = L_mac0( tmp2, temp_buf[i - 1], temp_buf[i] );
        }

        IF( tmp2 < Mult_32_16( tmp1, 31129 /*0.95f*/ ) )
        {
            Q_wb_sp = sub( Q_wb_sp, 3 ); /* leave 3 bit headroom */
        }
    }
    ELSE
#endif
    {
        temp1 = W_mac_32_32( temp1, temp_buf[0], temp_buf[0] );
        FOR( i = 1; i < L_FRAME16k; i++ )
        {
@@ -279,6 +301,8 @@ void wb_pre_proc_ivas_fx(
        {
            Q_wb_sp = sub( Q_wb_sp, 3 ); /* leave 3 bit headroom */
        }
    }

    Copy_Scale_sig( new_inp_resamp16k, temp_buf, L_FRAME16k, Q_wb_sp );
    Scale_sig( hBWE_TD->decim_state1_fx, ( 2 * ALLPASSSECTIONS_STEEP + 1 ), Q_wb_sp );
    Scale_sig( hBWE_TD->decim_state2_fx, ( 2 * ALLPASSSECTIONS_STEEP + 1 ), Q_wb_sp );
@@ -448,8 +472,12 @@ void wb_pre_proc_ivas_fx(
    /* st->old_input_wb and st->old_wtda_wb must be updated each frame, or there are often some clicks during WB TBE <-> WB BWE switching */
    test();
    test();
#ifdef HARMONIZE_TBE2
    IF( ( NE_16( st_fx->extl, WB_BWE ) || ( EQ_16( st_fx->extl, WB_BWE ) ) ) && !ppp_mode )
#else
    test();
    IF( ( NE_16( st_fx->extl, WB_BWE ) || ( EQ_16( st_fx->extl, WB_BWE ) && EQ_32( st_fx->total_brate, 0 ) ) ) && !ppp_mode )
#endif
    {
        Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS );

@@ -464,6 +492,7 @@ void wb_pre_proc_ivas_fx(
            move16();
        }
    }

    return;
}

@@ -784,7 +813,7 @@ void swb_pre_proc_ivas_fx(
    Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i  : real buffer Q - q_reImbuffer                */
    Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i  : imag buffer Q - q_reImbuffer                */
    Word16 q_reImBuffer,                                        /* i  : scale data of real and imag CLDFB buffers   */
#ifdef HARMONIZE_TBE
#ifdef HARMONIZE_TBE2
    const CLDFB_SCALE_FACTOR *cldfbScale, /* i : scale data of real and imag CLDFB buffers    */
#endif
    CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure                       */
@@ -811,7 +840,7 @@ void swb_pre_proc_ivas_fx(
    Word32 lbEner;
    Word16 exp_lbEner = 0;
    Word16 Sample_Delay_SWB_BWE32k, lMemRecalc32k, dft_ovl32k;
    Word32 one_by_50_Q31 = 42949673;
    const Word32 one_by_50_Q31 = 42949673;

    lMemRecalc32k = NS2SA( 32000, L_MEM_RECALC_NS );
    move16(); // exp_lbEner
@@ -846,11 +875,12 @@ void swb_pre_proc_ivas_fx(
            Copy( st->input_fx - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE );
            Copy( st->input_fx - L_FRAME32k, hBWE_FD->old_fdbwe_speech_fx, L_FRAME32k );

            test();
            test();
            scale_sig( hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( st->q_inp, st->Q_old_wtda ) ); // st->Q_old_wtda -> st->q_inp
            st->Q_old_wtda = st->q_inp;
            st->Q_old_wtda = st->q_inp;                                                                             //    st->Q_old_wtda = st->q_inp;
            move16();

            test();
            test();
            IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && GE_16( st->bwidth, SWB ) )
            {
                Copy( st->input_fx - hCPE->hStereoTCA->lMemRecalc, hBWE_FD->L_old_wtda_swb_fx + L_FRAME32k - sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ), sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ) );
@@ -1159,7 +1189,7 @@ void swb_pre_proc_ivas_fx(
            thr = icbwe_thr_DFT_fx;
            regV = icbwe_regressionValuesDFT_fx;
        }
#ifdef HARMONIZE_TBE
#ifdef HARMONIZE_TBE2
        ELSE IF( st->element_mode == EVS_MONO )
        {
            IF( EQ_16( st->L_frame, L_FRAME ) )
@@ -1547,6 +1577,14 @@ void swb_pre_proc_ivas_fx(
            }
        }

#ifdef HARMONIZE_TBE2
        IF( st->element_mode == EVS_MONO )
        {
            /* Reset CLDFB synthesis buffer */
            set16_fx( st->cldfbSynTd->FilterStates, 0, st->cldfbSynTd->p_filter_length + st->cldfbSynTd->no_channels * st->cldfbSynTd->no_col );
        }
        ELSE
#endif
        IF( NE_16( st->element_mode, IVAS_CPE_DFT ) )
        {
            /* Reset CLDFB synthesis buffer */