Commit 55b54127 authored by vaclav's avatar vaclav
Browse files

Merge branch 'basop-2314-remove-duplicated-code-in-core-switching' into 'main'

Resolve "Remove duplicated code in core switching"

See merge request !2697
parents f6fbd503 ec27c09b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2967,6 +2967,7 @@ void stereo_icBWE_preproc_fx(
    Word16 shb_speech_nonref[],                                 /* o  : SHB speech non-ref channel              */
    Word16 q_shb_speech_nonref                                  /* i  : Q SHB speech non-ref channel            */
);
#ifndef HARM_CORE_SW

void core_switching_pre_enc_ivas_fx(
    Encoder_State *st_fx,                                       /* i/o: encoder state structure                 */
@@ -2977,7 +2978,7 @@ void core_switching_pre_enc_ivas_fx(
    const Word16 active_cnt,                                    /* i  : active frame counter                    */
    const Word16 last_element_mode                              /* i  : last_element_mode                       */
);

#endif
Word16 ivas_acelp_tcx20_switching_fx(
    Encoder_State *st,                                          /* i/o: encoder state structure                 */
    Word16 *inp_fx,                                             /* i  : new input signal                        */
+1 −0
Original line number Diff line number Diff line
@@ -99,6 +99,7 @@
#define REMOVE_CAM_FROM_IVAS                            /* VA: basop issue 210: remove obsoelte CAM code from IVAS */
#define OPT_BE_2311_HARM_GSC_GAIN                       /* VA: issue 2311: BE part of the GSC gain harmonization pipeline #70380 shows the BE */
#define HARM_CORECODER_UPDT                             /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */
#define HARM_CORE_SW                                    /* VA: basop issue 2314: Remove duplicated code in the core switching */

/* #################### End BE switches ################################## */

+44 −14
Original line number Diff line number Diff line
@@ -7113,12 +7113,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*/
@@ -7710,22 +7711,43 @@ void hq_configure_bfi_fx(
void bandwidth_switching_detect_fx(
    Decoder_State *st_fx /* i/o: encoder state structure */
);
#ifndef HARM_CORE_SW
void bandwidth_switching_detect_ivas_fx(
    Decoder_State *st_fx /* i/o: encoder state structure */
);
#endif
void bw_switching_pre_proc_fx(
#ifdef HARM_CORE_SW
    Decoder_State *st_fx,             /* i/o: decoder state structure                    */
    const Word32 last_element_brate,  /* i  : last element bitrate                       */
    const Word16 nchan_out,           /* i  : number of output channels                  */
    const Word16 *old_syn_12k8_16k_fx /* i  : ACELP core synthesis at 12.8kHz or 16kHz Qx*/
#else
    const Word16 *old_syn_12k8_16k_fx,  /* i  : ACELP core synthesis at 12.8kHz or 16kHz        Qx*/
    Decoder_State *st_fx                /* i/o: decoder state structure     */
#endif
);
ivas_error core_switching_pre_dec_fx(
#ifdef HARM_CORE_SW
    Decoder_State *st,                /* i/o: decoder state structure      */
    const Word16 output_frame,        /* i  : frame length                 */
    const Word32 last_core_brate_st0, /* i  : channel 0 last core bitrate  */
    const Word16 nchan_out,           /* i  : number of output channels    */
    const Word16 last_element_mode,   /* i  : last_element_mode            */
    const Word32 last_element_brate,  /* i  : last element bitrate         */
    const Word16 Q_old_synthFB,
    Word16 *Q_olapBufferSynth,
    Word16 *Q_olapBufferSynth2
#else
    Decoder_State *st_fx,               /* i/o: decoder state structure     */
    const Word16 output_frame           /* i  : frame length              Q0*/
#endif
);
ivas_error core_switching_post_dec_fx(
#ifndef HARM_CORE_SW
    Decoder_State *st_fx,             /* i/o: decoder state structure     */
    Word16 *synth,                    /* i/o: output synthesis Qsynth     Qsynth*/
    const Word16 output_frame,        /* i  : frame length                Q0*/
@@ -7735,6 +7757,7 @@ ivas_error core_switching_post_dec_fx(
);
ivas_error core_switching_post_dec_ivas_fx(
#endif
    Decoder_State *st_fx,               /* i/o: decoder state structure                                                           */
    Word16 *synth,                      /* i/o: output synthesis                                                            Qsynth*/
    Word32 *output_fx,                  /* i/o: LB synth/upsampled LB synth                                                     Q4*/
@@ -9465,6 +9488,7 @@ void stereo_dft_dec_open(
    const Word16 nchan_transport           /* i  : number of transport channels */
);
#ifndef HARM_CORE_SW
void ivas_bw_switching_pre_proc_fx(
    Decoder_State *st,               /* i/o: decoder state structure                  */
    const Word32 last_element_brate, /* i  : last element bitrate                     */
@@ -9472,7 +9496,7 @@ void ivas_bw_switching_pre_proc_fx(
    Word32 *old_syn_12k8_16k_fx,
    Word16 Q,
    Word16 Q_audio );
#endif
UWord32 mvl2s_r(
    const Word32 x[], /* i  : input vector  */
    const Word16 q,
@@ -10281,7 +10305,11 @@ void ivas_swb_tbe_dec_fx(
    const Word32 *bwe_exc_extended_fx,    /* i  : bandwidth extended excitation : Q_exc             */
    Word16 Q_exc,
    const Word16 voice_factors_fx[], /* i  : voicing factors  : Q15                              */
#ifdef HARM_CORE_SW
    const Word16 old_syn_12k8_16k_fx16[], /* i  : low band synthesis : old_syn_fx                     */
#else
    const Word32 old_syn_12k8_16k_fx[], /* i  : low band synthesis : old_syn_fx                     */
#endif
    Word16 *White_exc16k_fx, /* o  : shaped white excitation for the FB TBE : Q_white_exc*/
    Word32 *synth_fx,        /* o  : SHB synthesis/final synthesis  : Qx                 */
    Word16 *pitch_buf_fx,    /* i  : Q6                                                  */
@@ -10328,6 +10356,7 @@ void wtda_fx32(
    const Word16 L           /* i  : length                              */
);
#ifndef HARM_CORE_SW
ivas_error core_switching_pre_dec_ivas_fx(
    Decoder_State *st,                /* i/o: decoder state structure      */
    const Word16 output_frame,        /* i  : frame length                 */
@@ -10338,7 +10367,7 @@ ivas_error core_switching_pre_dec_ivas_fx(
    Word16 Q_old_synthFB,
    Word16 *Q_olapBufferSynth,
    Word16 *Q_olapBufferSynth2 );
#endif
void hp20_fx_32(
    Word32 signal_fx[],
    const Word16 lg,
@@ -10813,10 +10842,11 @@ ivas_error IGF_Reconfig_fx(
    const Word16 rf_mode              /* i  : flag to signal the RF mode      */
);
#ifndef HARM_CORE_SW
void core_switching_post_enc_ivas_fx(
    Encoder_State *st /* i/o: encoder state structure             */
);
#endif
void residu_ivas_fx(
    const Word16 *a, /* i  : LP filter coefficients           Q31-a_exp*/
    const Word16 a_exp,
+71 −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( EQ_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)
@@ -820,8 +867,6 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx(
        {
            return error;
        }
    /*cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn,
                            negate(st_fx->Q_syn), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer);*/
        cldfbAnalysis_ivas_fx( syn32, realBuffer, imagBuffer, shr( st_fx->L_frame, 1 ), st_fx->cldfbAna );
        cldfb_restore_memory_ivas_fx( st_fx->cldfbAna );

@@ -830,20 +875,18 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx(
        {
            return error;
        }
    /*cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out,
                             negate(st_fx->Q_syn), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer );*/

        Word16 out_len = extract_l( Mpy_32_16_1( st_fx->output_Fs, 328 ) );
        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 ) );

        Copy_Scale_sig_32_16( synth32, synth_out, out_len, -4 );
        cldfb_restore_memory_ivas_fx( st_fx->cldfbSyn );
    }

    return error;
}


/*-------------------------------------------------------------------*
 * decod_gen_voic_core_switch()
 *
@@ -873,7 +916,6 @@ static void decod_gen_voic_core_switch_fx(
    GSC_DEC_HANDLE hGSCDec;
    hGSCDec = st_fx->hGSCDec;


    /*----------------------------------------------------------------------*
     * initializations
     *----------------------------------------------------------------------*/
@@ -902,6 +944,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 +953,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
     *--------------------------------------------------------------*/
@@ -973,6 +1017,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 );
+4 −0
Original line number Diff line number Diff line
@@ -172,7 +172,11 @@ ivas_error amr_wb_dec_fx(
    }

    /* Updates in case of EVS -> AMR-WB IO switching */
#ifdef HARM_CORE_SW
    IF( NE_32( ( error = core_switching_pre_dec_fx( st_fx, output_frame, -1, 1, EVS_MONO, EVS_MONO, -1, &tmp16, &tmp16 ) ), IVAS_ERR_OK ) )
#else
    IF( NE_32( ( error = core_switching_pre_dec_fx( st_fx, output_frame ) ), IVAS_ERR_OK ) )
#endif
    {
        return error;
    }
Loading