Commit fe1734da authored by vaclav's avatar vaclav
Browse files

cleaning

parent ba11d5e9
Loading
Loading
Loading
Loading
+4 −198
Original line number Diff line number Diff line
@@ -359,11 +359,7 @@ ivas_error acelp_core_dec_fx(
        }

        /* update synthesis filter memories */
#ifdef REMOVE_EVS_DUPLICATES
        ivas_synth_mem_updt2_fx( st_fx->L_frame, st_fx->last_L_frame, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, dec );
#else
        synth_mem_updt2( st_fx->L_frame, st_fx->last_L_frame, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, dec );
#endif

        Copy( st_fx->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC );                                 // Q_exc
        Copy_Scale_sig( st_fx->mem_syn2_fx, st_fx->mem_syn1_fx, M, sub( -1, st_fx->Q_syn ) ); /*Q-1*/
@@ -559,11 +555,8 @@ ivas_error acelp_core_dec_fx(
            /* decode CNG parameters */
            IF( st_fx->cng_type == LP_CNG )
            {
#ifdef REMOVE_EVS_DUPLICATES
                CNG_dec_ivas_fx( st_fx, st_fx->last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sid_bw, q_env );
#else

                CNG_dec_fx( st_fx, EVS_MONO, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sid_bw, q_env );
#endif

                /* comfort noise generation */
                CNG_exc_fx( st_fx->core_brate, st_fx->L_frame, &st_fx->hTdCngDec->Enew_fx, &st_fx->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st_fx->lp_ener_fx, st_fx->last_core_brate,
@@ -599,39 +592,10 @@ ivas_error acelp_core_dec_fx(
            }
            i = st_fx->Q_exc;
            move16();
#ifdef REMOVE_EVS_DUPLICATES
            test();
            IF( st_fx->hMusicPF && st_fx->hGSCDec )
            {
#ifdef REMOVE_EVS_DUPLICATES
                IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
                {
                    Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame,
                                 st_fx->L_frame * HIBND_ACB_L_FAC, 0, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, 0, INACTIVE );
                }
                ELSE
#endif
                {
                    Rescale_exc( st_fx->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame,
                                 imult1616( st_fx->L_frame, HIBND_ACB_L_FAC ), 0, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, 0, INACTIVE );
                }
            }
            IF( st_fx->hPFstat != NULL )
            {
                Rescale_mem( st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, delta_mem_scale,
                             &st_fx->mem_deemph_fx, st_fx->hBPF->pst_old_syn_fx, &st_fx->hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, 0, 0, NULL );
            }
            ELSE
            {
                Rescale_mem( st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, delta_mem_scale,
                             &st_fx->mem_deemph_fx, NULL, NULL, &st_fx->agc_mem_fx[1], NULL, 0, 0, NULL );
            }
#else
            Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame,
                         st_fx->L_frame * HIBND_ACB_L_FAC, 0, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, 0, INACTIVE );
            Rescale_mem( st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, delta_mem_scale,
                         &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, 0, 0, NULL );
#endif
            Copy_Scale_sig( exc2_fx, exc2_fx, st_fx->L_frame, sub( st_fx->Q_exc, i ) ); // Q_exc

            /* update past excitation signals for LD music post-filter */
@@ -705,11 +669,7 @@ ivas_error acelp_core_dec_fx(
                }

#ifdef NONBE_FIX_GSC_BSTR
#ifdef REMOVE_EVS_DUPLICATES
                config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, tc_subfr_tmp, 1, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
#else
                config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_tmp, 1, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
#endif
#else
                config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, tc_subfr_tmp, 1, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
#endif
@@ -719,11 +679,7 @@ ivas_error acelp_core_dec_fx(
                IF( EQ_16( st_fx->coder_type, TRANSITION ) && LT_16( tc_subfr_fx, L_SUBFR ) && EQ_16( st_fx->L_frame, L_FRAME ) )
                {
#ifdef NONBE_FIX_GSC_BSTR
#ifdef REMOVE_EVS_DUPLICATES
                    config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, tc_subfr_fx, 2, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
#else
                    config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, TRANSITION, -1, tc_subfr_fx, 2, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
#endif
#else
                    config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, tc_subfr_fx, 2, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
#endif
@@ -815,11 +771,7 @@ ivas_error acelp_core_dec_fx(
            IF( st_fx->stab_fac_fx == 0 && st_fx->old_bfi_cnt > 0 && NE_16( st_fx->clas_dec, VOICED_CLAS ) && NE_16( st_fx->clas_dec, ONSET ) &&
                st_fx->relax_prev_lsf_interp == 0 && !( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) )
            {
#ifdef REMOVE_EVS_DUPLICATES
                int_lsp4_ivas_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 );
#else
                int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 );
#endif
            }

            /*---------------------------------------------------------------*
@@ -851,11 +803,7 @@ ivas_error acelp_core_dec_fx(
            ELSE IF( EQ_16( st_fx->coder_type, UNVOICED ) )
            {
                /* UNVOICED frames */
#ifdef REMOVE_EVS_DUPLICATES
                decod_unvoiced_ivas_fx( st_fx, Aq_fx, Es_pred_fx, uc_two_stage_flag, st_fx->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, gain_buf );
#else
                decod_unvoiced_fx( st_fx, Aq_fx, st_fx->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, gain_buf );
#endif
            }
            ELSE IF( EQ_16( st_fx->ppp_mode_dec, 1 ) )
            {
@@ -872,28 +820,16 @@ ivas_error acelp_core_dec_fx(
            }
            ELSE IF( EQ_16( st_fx->coder_type, TRANSITION ) )
            {
#ifdef REMOVE_EVS_DUPLICATES
                decod_tran_ivas_fx( st_fx, st_fx->L_frame, tc_subfr_fx, Aq_fx, Es_pred_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, unbits, sharpFlag, gain_buf );
#else
                decod_tran_fx( st_fx, st_fx->L_frame, tc_subfr_fx, Aq_fx, Es_pred_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, unbits, sharpFlag, gain_buf );
#endif
            }
            ELSE IF( EQ_16( st_fx->coder_type, AUDIO ) || ( ( st_fx->coder_type == INACTIVE ) && LE_32( st_fx->core_brate, MAX_GSC_INACTIVE_BRATE ) ) )
            {
#ifdef REMOVE_EVS_DUPLICATES
                decod_audio_ivas_fx( st_fx, dct_exc_tmp, Aq_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf );
#else
                decod_audio_fx( st_fx, dct_exc_tmp, Aq_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf );
#endif
                tmp_noise_fx = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/
            }
            ELSE
            {
#ifdef REMOVE_EVS_DUPLICATES
                IF( NE_32( ( error = decod_gen_voic_ivas_fx( st_fx, st_fx->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf, 0, NULL ) ), IVAS_ERR_OK ) )
#else
                IF( NE_32( ( error = decod_gen_voic_fx( st_fx, st_fx->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf /*, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf*/ ) ), IVAS_ERR_OK ) )
#endif
                {
                    return error;
                }
@@ -906,7 +842,6 @@ ivas_error acelp_core_dec_fx(

            /* synthesis for ACELP core switching and SWB BWE */
            syn_12k8_fx( st_fx->L_frame, Aq_fx, exc_fx, temp_buf_fx, st_fx->mem_syn1_fx, 1, st_fx->Q_exc, -1 );

            /* save and delay synthesis to be used by SWB BWE */
            IF( hBWE_FD != NULL )
            {
@@ -917,11 +852,7 @@ ivas_error acelp_core_dec_fx(
             * Apply energy matching when switching to inactive frames
             *-----------------------------------------------------------------*/

#ifdef REMOVE_EVS_DUPLICATES
            Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode, 0, EVS_MONO );
#else
            Inac_swtch_ematch_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode );
#endif
            /*------------------------------------------------------------*
             * Decode information and modify the excitation signal of stationary unvoiced frames
             *------------------------------------------------------------*/
@@ -1049,13 +980,9 @@ ivas_error acelp_core_dec_fx(
                k = add( k, 1 );
            }

#ifdef REMOVE_EVS_DUPLICATES
            FEC_scale_syn_ivas_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction,
            FEC_scale_syn_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction,
                              &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate,
                                   exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, 0 );
#else
            FEC_scale_syn_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, avoid_lpc_burst_on_recovery, 0 );
#endif
                              exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, avoid_lpc_burst_on_recovery, 0 );

            test();
            test();
@@ -1134,13 +1061,8 @@ ivas_error acelp_core_dec_fx(
        {
            save_old_syn_fx( st_fx->L_frame, temp_buf_fx, old_syn_12k8_16k, hBWE_FD->old_syn_12k8_16k_fx, st_fx->preemph_fac, &hBWE_FD->mem_deemph_old_syn_fx );
        }

        /* Apply energy matching when switching to inactive frames */
#ifdef REMOVE_EVS_DUPLICATES
        Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode, 0, EVS_MONO );
#else
        Inac_swtch_ematch_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode );
#endif

        /* udate past excitation signals for LD music post-filter */
        IF( hMusicPF != NULL )
@@ -1214,15 +1136,9 @@ ivas_error acelp_core_dec_fx(
             * (smoothing is performed in the excitation domain and signal is resynthesized after)
             *------------------------------------------------------------*/

#ifdef REMOVE_EVS_DUPLICATES
            FEC_scale_syn_ivas_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction,
                                   &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate,
                                   exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, 0 );
#else
            FEC_scale_syn_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction,
                              &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate,
                              exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, avoid_lpc_burst_on_recovery, 0 );
#endif
        }

        /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */
@@ -1317,11 +1233,7 @@ ivas_error acelp_core_dec_fx(
            Copy( syn_fx, temp_buf + L_SYN_MEM, L_FRAME16k );
            st_fx->hPFstat->on = 1;
            move16();
#ifdef REMOVE_EVS_DUPLICATES
            formant_post_filt_ivas_fx( st_fx->hPFstat, temp_buf + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME16k, st_fx->lp_noise, st_fx->total_brate, 0 );
#else
            formant_post_filt_fx( st_fx->hPFstat, temp_buf + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME16k, st_fx->lp_noise, st_fx->total_brate, 0 );
#endif
        }
        ELSE IF( GE_16( st_fx->last_bwidth, WB ) )
        {
@@ -1383,21 +1295,13 @@ ivas_error acelp_core_dec_fx(
                move32();
            }
            /*Noise estimate*/
#ifdef REMOVE_EVS_DUPLICATES
            IF( NE_16( st_fx->element_mode, IVAS_CPE_TD ) && !st_fx->cng_ism_flag )
#else
            IF( NE_16( st_fx->element_mode, IVAS_CPE_TD ) /* && !st->cng_ism_flag IVAS_CODE */ )
#endif
            {
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
                PMT( "Code for IVAS_CODE_CNG_FIX185_PLC_FADEOUT not done" )
                ApplyFdCng_fx( syn, st_fx->Q_syn, NULL, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
#else
#ifdef REMOVE_EVS_DUPLICATES
                ApplyFdCng_ivas_fx( syn_fx, st_fx->Q_syn, NULL, 0, realBuffer, imagBuffer, NULL, st_fx, 0, ( st_fx->coder_type == AUDIO && !st_fx->GSC_noisy_speech ) );
#else
                ApplyFdCng_fx( syn_fx, st_fx->Q_syn, realBuffer, imagBuffer, NULL, st_fx, 0, ( EQ_16( st_fx->coder_type, AUDIO ) && st_fx->GSC_noisy_speech == 0 ) );
#endif
#endif
            }
            /* CNA: Generate additional comfort noise to mask potential coding artefacts */
@@ -1480,82 +1384,6 @@ ivas_error acelp_core_dec_fx(
        bass_psfilter_fx( st_fx->hBPF, st_fx->Opt_AMR_WB, syn_fx, st_fx->L_frame, pitch_buf_fx, st_fx->bpf_off,
                          st_fx->stab_fac_fx, &st_fx->stab_fac_smooth_fx, st_fx->coder_type, st_fx->Q_syn, bpf_error_signal );
    }

#ifdef REMOVE_EVS_DUPLICATES
    IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
    {
        /* analysis of the synthesis at internal sampling rate */
        cldfbAnalysisFiltering( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn_fx, negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX, workBuffer );

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

        /* analysis and add the BPF error signal */
        i = 0;
        move16();
        if ( st_fx->bpf_off == 0 )
        {
            i = CLDFB_NO_COL_MAX;
            move16();
        }

        addBassPostFilter_fx( bpf_error_signal, realBuffer, imagBuffer, st_fx->cldfbBPF, workBuffer, negate( st_fx->Q_syn ),
                              i, st_fx->cldfbAna->no_col, st_fx->cldfbAna->no_channels, &scaleFactor );

        /* set output mask for upsampling */
        IF( EQ_16( st_fx->bwidth, NB ) )
        {
            /* set NB mask for upsampling */
            st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, 10 );
            move16();
        }
        ELSE IF( NE_16( st_fx->cldfbSyn->bandsToZero, sub( st_fx->cldfbSyn->no_channels, st_fx->cldfbAna->no_channels ) ) )
        {
            /* in case of BW switching, re-init to default */
            st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, st_fx->cldfbAna->no_channels );
            move16();
        }

        /*WB/SWB-FD_CNG*/
        scaleFactor.hb_scale = scaleFactor.lb_scale;
        move16();

        test();
        IF( !st_fx->cng_sba_flag || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
        {
            test();
            test();
            test();
            IF( ( ( st_fx->core_brate == FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) && ( EQ_16( st_fx->cng_type, FD_CNG ) ) && ( LT_16( st_fx->hFdCngDec->hFdCngCom->numCoreBands, st_fx->cldfbSyn->no_channels ) ) )
            {
                generate_comfort_noise_dec_hf_fx( realBuffer, imagBuffer, &scaleFactor.hb_scale, st_fx );

                st_fx->cldfbSyn->bandsToZero = 0;
                move16();
                IF( LT_16( st_fx->hFdCngDec->hFdCngCom->regularStopBand, st_fx->cldfbSyn->no_channels ) )
                {
                    st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, st_fx->hFdCngDec->hFdCngCom->regularStopBand );
                    move16();
                }
                st_fx->cldfbSyn->lsb = st_fx->cldfbAna->no_channels;
                move16();
            }
        }

        /* synthesis of the combined signal */
        st_fx->Q_syn2 = st_fx->Q_syn;
        move16();
        cldfbSynthesisFiltering( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out, negate( st_fx->Q_syn2 ), CLDFB_NO_COL_MAX, workBuffer );

        /* Bring CLDFB output to Q0 */
        Scale_sig( synth_out, output_frame, negate( st_fx->Q_syn2 ) );
        st_fx->Q_syn2 = 0;
        move16();

        /* save synthesis - needed in case of core switching */
        Copy( synth_out, st_fx->previoussynth_fx, output_frame );
    }
#else
    test();
    IF( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft )
    {
@@ -1630,7 +1458,6 @@ ivas_error acelp_core_dec_fx(
        /* save synthesis - needed in case of core switching */
        Copy( synth_out, st_fx->previoussynth_fx, output_frame );
    }
#endif

    /*-----------------------------------------------------------------*
     * Bandwidth extension 6kHz-7kHz
@@ -1647,33 +1474,12 @@ ivas_error acelp_core_dec_fx(
        IF( ( EQ_16( st_fx->L_frame, L_FRAME ) && NE_16( st_fx->bwidth, NB ) && GE_16( output_frame, L_FRAME16k ) &&
              ( EQ_16( st_fx->extl, -1 ) || EQ_16( st_fx->extl, SWB_CNG ) || ( EQ_16( st_fx->extl, WB_BWE ) && st_fx->extl_brate == 0 && NE_16( st_fx->coder_type, AUDIO ) ) ) ) )
        {
#ifdef REMOVE_EVS_DUPLICATES
            IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
            {
                hf_synth_fx( st_fx->hBWE_zero, st_fx->core_brate, output_frame, Aq_fx, exc2_fx, syn_fx, synth_out, st_fx->Q_exc,
                             st_fx->Q_syn2, st_fx->hBWE_zero->delay_syn_hf_fx, &st_fx->hBWE_zero->memExp1, st_fx->hBWE_zero->mem_hp_interp_fx, st_fx->extl, st_fx->CNG_mode );
            }
            ELSE
            {
                hf_synth_reset_fx( st_fx->hBWE_zero );
            }
#else
            hf_synth_fx( st_fx->hBWE_zero, st_fx->core_brate, output_frame, Aq_fx, exc2_fx, syn_fx, synth_out, st_fx->Q_exc, st_fx->Q_syn2 );

#endif
        }
#ifdef REMOVE_EVS_DUPLICATES
        ELSE
        {
            hf_synth_reset_fx( st_fx->hBWE_zero );
#ifdef MSAN_FIX
            IF( NE_16( st_fx->element_mode, EVS_MONO ) )
            {
                set16_fx( st_fx->hBWE_zero->mem_hp400_fx, 0, 6 );
            }
#endif
        }
#endif
    }

    /*-----------------------------------------------------------------*