Commit 02394042 authored by vaclav's avatar vaclav
Browse files

HARM_CORE_SW, decoder step 5 (acelp_core_switch_dec_bfi_fx)

parent fe38daf8
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -7197,12 +7197,13 @@ ivas_error acelp_core_switch_dec_bfi_fx(
    const Word16 coder_type /* i  : coder type              */
);
#ifndef HARM_CORE_SW
ivas_error acelp_core_switch_dec_bfi_ivas_fx(
    Decoder_State *st_fx,   /* i/o: decoder state structure */
    Word16 synth_out[],     /* o  : synthesis Q_syn         */
    const Word16 coder_type /* i  : coder type              */
);
#endif
void pred_lt4(
    const Word16 excI[],   /* in : excitation buffer       Q_exc*/
    Word16 excO[],         /* out: excitation buffer       Q_exc*/
+75 −26
Original line number Diff line number Diff line
@@ -351,7 +351,7 @@ ivas_error acelp_core_switch_dec_fx(
 *
 * ACELP core decoder in the first ACELP->HQ switching frame in case of BAD frame
 *-------------------------------------------------------------------*/

#ifndef HARM_CORE_SW
ivas_error acelp_core_switch_dec_bfi_fx(
    Decoder_State *st_fx,   /* i/o: decoder state structure */
    Word16 synth_out[],     /* o  : synthesis Q_syn         */
@@ -594,8 +594,13 @@ ivas_error acelp_core_switch_dec_bfi_fx(

    return error;
}
#endif

#ifdef HARM_CORE_SW
ivas_error acelp_core_switch_dec_bfi_fx(
#else
ivas_error acelp_core_switch_dec_bfi_ivas_fx(
#endif
    Decoder_State *st_fx,   /* i/o: decoder state structure */
    Word16 synth_out[],     /* o  : synthesis Q_syn         */
    const Word16 coder_type /* i  : coder type              */
@@ -647,6 +652,7 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx(
    /*----------------------------------------------------------------*
     * Initialization
     *----------------------------------------------------------------*/

    Q_exc = st_fx->Q_exc;
    move16();
    st_fx->bpf_off = 1;
@@ -757,11 +763,17 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx(
    /*------------------------------------------------------------------*
     * Synthesis
     *-----------------------------------------------------------------*/

    Prev_Q_syn_r = st_fx->Q_syn;
    move16();
    Rescale_mem( Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, 4, &st_fx->mem_deemph_fx,
                 hBPF->pst_old_syn_fx, &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, 1, 0, NULL );
#ifdef HARM_CORE_SW
    IF( NE_16( st_fx->element_mode, EVS_MONO ) )
#endif
    {
        Scale_sig( st_fx->mem_syn_r, L_SYN_MEM, sub( st_fx->Q_syn, Prev_Q_syn_r ) ); // Q_syn
    }
    Copy( st_fx->mem_syn2_fx, tmp1, M );
    syn_12k8_fx( st_fx->L_frame, Aq, exc2, syn, tmp1, 1, Q_exc, st_fx->Q_syn );

@@ -772,6 +784,7 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx(
    /*------------------------------------------------------------------*
     * Perform fixed deemphasis through 1/(1 - g*z^-1)
     *-----------------------------------------------------------------*/

    tmp1[0] = st_fx->mem_deemph_fx;
    move16(); /*if in acelp_core_dec_fx deemph_fx is used*/
    /*tmp1 = shr(st_fx->mem_deemph_fx, sub(st_fx->Q_syn,1));      if in acelp_core_dec_fx Deemph2 is used*/
@@ -810,9 +823,43 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx(
    Copy( tmp6, hBPF->vibrato_hist, L_TRACK_HIST );
    hBPF->psf_att_fx = tmp7;
    move16();

    /*----------------------------------------------------------------*
     * Resamping to the output sampling frequency
     *----------------------------------------------------------------*/

#ifdef HARM_CORE_SW
    IF( NE_16( st_fx->element_mode, EVS_MONO ) )
    {
        CLDFB_SCALE_FACTOR scaleFactor;
        Word32 workBuffer[128 * 3];

        IF( NE_32( ( error = cldfb_save_memory( st_fx->cldfbAna ) ), IVAS_ERR_OK ) )
        {
            return error;
        }
        cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn, negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer );
        cldfb_restore_memory( st_fx->cldfbAna );

        scaleFactor.hb_scale = scaleFactor.lb_scale;
        move16();

        /* CLDFB synthesis of the combined signal */
        IF( NE_32( ( error = cldfb_save_memory( st_fx->cldfbSyn ) ), IVAS_ERR_OK ) )
        {
            return error;
        }
        cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out,
                           negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer );

        /* output to Q0 */
        Scale_sig( synth_out, L_FRAME48k, negate( st_fx->Q_syn ) ); // Q0

        cldfb_restore_memory( st_fx->cldfbSyn );
    }
    ELSE
#endif
    { 
        /* CLDFB analysis of the synthesis at internal sampling rate */
        Qtmp = sub( 11, st_fx->Q_syn );
        Copy_Scale_sig_16_32_no_sat( syn, syn32, L_FRAME16k, Qtmp ); // Q(11)
@@ -836,10 +883,10 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx(
        cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, synth32, out_len, -1, 0, st_fx->cldfbSyn );
        Copy_Scale_sig_32_16( synth32, synth_out, out_len, -4 );


        // Scale_sig( synth_out, L_FRAME48k, negate( st_fx->Q_syn ) );

        cldfb_restore_memory_ivas_fx( st_fx->cldfbSyn );
    }

    return error;
}
@@ -873,7 +920,6 @@ static void decod_gen_voic_core_switch_fx(
    GSC_DEC_HANDLE hGSCDec;
    hGSCDec = st_fx->hGSCDec;


    /*----------------------------------------------------------------------*
     * initializations
     *----------------------------------------------------------------------*/
@@ -902,6 +948,7 @@ static void decod_gen_voic_core_switch_fx(
    /*--------------------------------------------------------------*
     * Find the adaptive codebook vector.
     *--------------------------------------------------------------*/

    IF( st_fx->element_mode != EVS_MONO )
    {
        pred_lt4_ivas_fx( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
@@ -910,6 +957,7 @@ static void decod_gen_voic_core_switch_fx(
    {
        pred_lt4( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
    }

    /*--------------------------------------------------------------*
     * LP filtering of the adaptive excitation
     *--------------------------------------------------------------*/
@@ -977,6 +1025,7 @@ static void decod_gen_voic_core_switch_fx(
    /*-----------------------------------------------------------------*
     * long term prediction on the 2nd sub frame
     *-----------------------------------------------------------------*/

    IF( st_fx->element_mode != EVS_MONO )
    {
        pred_lt4_ivas_fx( &exc[L_SUBFR], &exc[L_SUBFR], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+5 −13
Original line number Diff line number Diff line
@@ -1354,22 +1354,14 @@ ivas_error core_switching_post_dec_ivas_fx(
    IF( st_fx->core == ACELP_CORE && st_fx->bfi && hHQ_core != NULL && !st_fx->con_tcx )
    {
#ifdef HARM_CORE_SW
        IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
        {
        IF( ( error = acelp_core_switch_dec_bfi_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK )
            {
                return error;
            } /*the output at Q0*/
        }
        ELSE
#endif
        {
#else
        IF( ( error = acelp_core_switch_dec_bfi_ivas_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK )
#endif
        {
            return error;
        } /*the output at Q0*/
    }
    }

    /* set multiplication factor according to the sampling rate */
    tmp = extract_l( L_shr( st_fx->output_Fs, 13 ) ); /* Q0 */