Commit ff8c5ae9 authored by multrus's avatar multrus
Browse files

[cleanup] accept HARM_CORE_SW

parent 594a1deb
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -2961,18 +2961,6 @@ 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                 */
    const Word16 *old_inp_12k8,                                 /* i  : old input signal @12.8kHz               */
    const Word16 q_old_inp_12k8,                                /* i  : Q old input signal @12.8kHz             */
    const Word16 *old_inp_16k,                                  /* i  : old input signal @16kHz                 */
    const Word16 q_old_inp_16k,                                 /* i  : Q old input signal @16kHz               */
    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                        */
+0 −1
Original line number Diff line number Diff line
@@ -88,7 +88,6 @@
#define FIX_1904_HARM_GSC_ENC                           /* VA: #1904 Harmonization of EVS and IVAS GSC code */
#define FIX_1478_UNINIT_ON_BFI                          /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */
#define FIX_2318_CLANG_DECODER                          /* VA: basop issue 2318: Initialize command-line parameter arg.non_diegetic_pan_gain_fx */
#define HARM_CORE_SW                                    /* VA: basop issue 2314: Remove duplicated code in the core switching */
#define HARM_PREPROC                                    /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX  */
#define HARM_NON_LINEARITY                              /* VA: basop issue 2345: Remove duplicated code in core-coder: non_linearity_fx() and LP CNG */
#define FIX_2344_ALIGN_PREPROC                          /* VA: basop issue 2344: Align pre_proc_ivas() between FLP and BASOP */
+0 −64
Original line number Diff line number Diff line
@@ -7054,13 +7054,6 @@ 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*/
@@ -7652,26 +7645,14 @@ 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  */
@@ -7681,24 +7662,9 @@ ivas_error core_switching_pre_dec_fx(
    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*/
    const Word16 core_switching_flag, /* i  : ACELP->HQ switching flag    Q0*/
    const Word16 last_element_mode,   /* i  : element mode of previous frame      Q0*/
    Word16 *Qsynth                    /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */
);
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*/
@@ -9420,15 +9386,6 @@ 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                     */
    const Word16 nchan_out,          /* i  : number of output channels                */
    Word32 *old_syn_12k8_16k_fx,
    Word16 Q,
    Word16 Q_audio );
#endif
UWord32 mvl2s_r(
    const Word32 x[], /* i  : input vector  */
    const Word16 q,
@@ -10237,11 +10194,7 @@ 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                                                  */
@@ -10288,18 +10241,6 @@ 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                 */
    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         */
    Word16 Q_old_synthFB,
    Word16 *Q_olapBufferSynth,
    Word16 *Q_olapBufferSynth2 );
#endif
void hp20_fx_32(
    Word32 signal_fx[],
    const Word16 lg,
@@ -10765,11 +10706,6 @@ 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,
+0 −252
Original line number Diff line number Diff line
@@ -351,256 +351,8 @@ 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         */
    const Word16 coder_type /* i  : coder type              */
)
{
    Word16 old_exc[L_EXC_DEC], *exc;                                              /* excitation signal buffer              */
    Word16 syn[L_FRAME16k];                                                       /* synthesis signal buffer               */
    Word16 lsf_new[M];                                                            /* LSFs at the end of the frame          */
    Word16 lsp_new[M];                                                            /* LSPs at the end of the frame          */
    Word16 Aq[NB_SUBFR16k * ( M + 1 )];                                           /* A(q)   quantized for the 4 subframes  */
    Word16 old_exc2[L_FRAME16k + L_EXC_MEM], *exc2;                               /* total excitation buffer               */
    Word16 tmp_noise;                                                             /* Long term temporary noise energy      */
    Word16 FEC_pitch;                                                             /* FEC pitch                             */
    Word16 old_bwe_exc[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */
    Word16 *bwe_exc;                                                              /* Excitation for SWB TBE */
    Word16 tmp1[NBPSF_PIT_MAX];
    Word16 tmp2[M];
    Word16 tmp3;
    Word16 tmp4[L_TRACK_HIST];
    Word16 tmp5[L_TRACK_HIST];
    Word16 tmp6[L_TRACK_HIST];
    Word16 tmp7;
    Word32 tmp8;
    Word16 voice_factors[NB_SUBFR16k];
    Word16 pitch_buf[NB_SUBFR16k];
    Word16 Q_exc;
    Word32 *realBuffer[CLDFB_NO_COL_MAX_SWITCH_BFI], *imagBuffer[CLDFB_NO_COL_MAX_SWITCH_BFI];
    Word32 realBufferTmp[CLDFB_NO_COL_MAX_SWITCH_BFI][CLDFB_NO_CHANNELS_MAX], imagBufferTmp[CLDFB_NO_COL_MAX_SWITCH_BFI][CLDFB_NO_CHANNELS_MAX];
    Word16 i;
    CLDFB_SCALE_FACTOR scaleFactor;
    Word32 workBuffer[128 * 3];
    MUSIC_POSTFILT_HANDLE hMusicPF;
    BPF_DEC_HANDLE hBPF;
    ivas_error error;

    hMusicPF = st_fx->hMusicPF;
    hBPF = st_fx->hBPF;
    error = IVAS_ERR_OK;
    move32();

    FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH_BFI; i++ )
    {
        set32_fx( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX );
        set32_fx( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX );
        realBuffer[i] = realBufferTmp[i];
        imagBuffer[i] = imagBufferTmp[i];
    }

    /*----------------------------------------------------------------*
     * Initialization
     *----------------------------------------------------------------*/
    Q_exc = st_fx->Q_exc;
    move16();
    st_fx->bpf_off = 1;
    move16();
    st_fx->clas_dec = st_fx->last_good;
    move16();
    tmp_noise = 0;
    move16();

    Copy( st_fx->old_exc_fx, old_exc, L_EXC_MEM_DEC ); // Q_exc
    exc = old_exc + L_EXC_MEM_DEC;
    IF( st_fx->hWIDec != NULL )
    {
        Copy( st_fx->hWIDec->old_exc2_fx, old_exc2, L_EXC_MEM );
    }
    ELSE
    {
        set16_fx( old_exc2, 0, L_EXC_MEM );
    }
    exc2 = old_exc2 + L_EXC_MEM;
    IF( st_fx->hBWE_TD != NULL )
    {
        Copy( st_fx->hBWE_TD->old_bwe_exc_fx, old_bwe_exc, PIT16k_MAX * 2 ); // Q_exc
        bwe_exc = old_bwe_exc + PIT16k_MAX * 2;
    }
    ELSE
    {
        bwe_exc = NULL;
    }

    st_fx->GSC_noisy_speech = 0;
    move16();
    st_fx->relax_prev_lsf_interp = 0;
    move16();

    /* SC-VBR */
    if ( EQ_16( st_fx->last_nelp_mode_dec, 1 ) )
    {
        st_fx->nelp_mode_dec = 1;
        move16();
    }

    Copy( st_fx->mem_AR_fx, tmp1, M );
    Copy( st_fx->mem_MA_fx, tmp2, M );

    /* LSF estimation and A(z) calculation */
    lsf_dec_bfi( MODE1, lsf_new, st_fx->lsf_old_fx, st_fx->lsf_adaptive_mean_fx, NULL, st_fx->mem_MA_fx, st_fx->mem_AR_fx,
                 st_fx->stab_fac_fx, st_fx->last_coder_type, st_fx->L_frame, st_fx->last_good,
                 st_fx->nbLostCmpt, 0, NULL, NULL, NULL, st_fx->hGSCDec->Last_GSC_pit_band_idx, st_fx->Opt_AMR_WB, 0, st_fx->bwidth );

    FEC_lsf2lsp_interp( st_fx, st_fx->L_frame, Aq, lsf_new, lsp_new );

    Copy( tmp1, st_fx->mem_AR_fx, M );
    Copy( tmp2, st_fx->mem_MA_fx, M );

    /*----------------------------------------------------------------*
     * Excitation decoding
     *----------------------------------------------------------------*/

    IF( EQ_16( st_fx->nelp_mode_dec, 1 ) )
    {
        Word16 gain_buf[NB_SUBFR16k];
        Scale_sig( exc - L_EXC_MEM, L_EXC_MEM, negate( st_fx->Q_exc ) ); // Q0
        st_fx->Q_exc = 0;
        move16();
        /* SC-VBR */
        decod_nelp_fx( st_fx, &tmp_noise, pitch_buf, exc, exc2, voice_factors, bwe_exc, &Q_exc, st_fx->bfi, gain_buf );
        FEC_pitch = pitch_buf[3];
        move16();
        Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc, NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &Q_exc, st_fx->Q_subfr, exc2, L_FRAME, coder_type );
        st_fx->Q_exc = Q_exc;
        move16();
    }
    ELSE
    {
        tmp1[0] = st_fx->bfi_pitch_fx;
        move16();
        tmp1[1] = st_fx->bfi_pitch_frame;
        move16();
        tmp1[2] = st_fx->lp_gainp_fx;
        move16();
        tmp1[3] = st_fx->lp_gainc_fx;
        move16();
        tmp1[4] = st_fx->upd_cnt;
        move16();
        tmp1[5] = st_fx->seed;
        move16();

        /* calculation of excitation signal */
        FEC_exc_estim_fx( st_fx, st_fx->L_frame, exc, exc2, syn /* dummy buffer */, pitch_buf, voice_factors, &FEC_pitch, bwe_exc, lsf_new, &Q_exc, &tmp_noise );
        Rescale_exc( NULL, exc, bwe_exc, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame, L_FRAME32k, (Word32) 0,
                     &Q_exc, st_fx->Q_subfr, exc2, st_fx->L_frame, st_fx->last_coder_type );

        st_fx->seed = tmp1[5];
        move16();
        st_fx->bfi_pitch_fx = tmp1[0];
        move16();
        st_fx->bfi_pitch_frame = tmp1[1];
        move16();
        st_fx->lp_gainp_fx = tmp1[2];
        move16();
        st_fx->lp_gainc_fx = tmp1[3];
        move16();
        st_fx->upd_cnt = tmp1[4];
        move16();
    }

    /*------------------------------------------------------------------*
     * Synthesis
     *-----------------------------------------------------------------*/

    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 );
    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 );

    tmp8 = st_fx->enr_old_fx;
    move32();
    frame_ener_fx( st_fx->L_frame, st_fx->last_good, syn, shr( add( FEC_pitch, 32 ), 6 ), &tmp8, st_fx->L_frame, st_fx->Q_syn, 3, 0 );

    /*------------------------------------------------------------------*
     * 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*/

    IF( EQ_16( st_fx->L_frame, L_FRAME ) )
    {
        deemph_fx( syn, PREEMPH_FAC, L_FRAME, &tmp1[0] ); /*Q0*/
    }
    ELSE
    {
        deemph_fx( syn, PREEMPH_FAC_16k, L_FRAME16k, &tmp1[0] ); /*Q0*/
    }

    /*----------------------------------------------------------------*
     * Bass post-filter
     *----------------------------------------------------------------*/

    st_fx->bpf_off = 1;
    move16();
    Copy( hBPF->pst_old_syn_fx, tmp1, NBPSF_PIT_MAX );

    tmp3 = st_fx->stab_fac_smooth_fx;
    move16();
    Copy( hBPF->mem_mean_pit_fx, tmp4, L_TRACK_HIST );
    Copy( hBPF->Track_on_hist, tmp5, L_TRACK_HIST );
    Copy( hBPF->vibrato_hist, tmp6, L_TRACK_HIST );
    tmp7 = hBPF->psf_att_fx;
    move16();

    bass_psfilter_fx( st_fx->hBPF, st_fx->Opt_AMR_WB, syn, st_fx->L_frame, pitch_buf,
                      st_fx->bpf_off, st_fx->stab_fac_fx, &tmp3, coder_type, st_fx->Q_syn, old_exc /* tmp buffer*/ );

    Copy( tmp1, hBPF->pst_old_syn_fx, NBPSF_PIT_MAX );
    Copy( tmp4, hBPF->mem_mean_pit_fx, L_TRACK_HIST );
    Copy( tmp5, hBPF->Track_on_hist, L_TRACK_HIST );
    Copy( tmp6, hBPF->vibrato_hist, L_TRACK_HIST );
    hBPF->psf_att_fx = tmp7;
    move16();
    /*----------------------------------------------------------------*
     * Resamping to the output sampling frequency
     *----------------------------------------------------------------*/
    /* CLDFB analysis of the synthesis at internal sampling rate */
    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 );

    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              */
@@ -768,9 +520,7 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx(
    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
    }
@@ -828,7 +578,6 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx(
     * Resamping to the output sampling frequency
     *----------------------------------------------------------------*/

#ifdef HARM_CORE_SW
    IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
    {
        CLDFB_SCALE_FACTOR scaleFactor;
@@ -858,7 +607,6 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx(
        cldfb_restore_memory( st_fx->cldfbSyn );
    }
    ELSE
#endif
    {
        /* CLDFB analysis of the synthesis at internal sampling rate */
        Qtmp = sub( 11, st_fx->Q_syn );
+0 −4
Original line number Diff line number Diff line
@@ -172,11 +172,7 @@ 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