Commit 6bacf666 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Integration of fixed point sub-functions 10

[x] Add integeration changes for delay_signal_fx
[x] Stereo_switching dec update
[x] Removes redundant flags/variables from Decoder_struct.
parent 11be5e87
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -223,6 +223,7 @@ enum{
#define INV_LOG_2                       1.442695040888963f /* 1/log(2)  */
#define INV_SQRT_2                      0.70710676908493f  /* 1/sqrt(2) */
#define INV_SQRT_2_Q15                  23170  /* 1/sqrt(2) in Q15 */
#define INV_SQRT_2_Q31                  1.51850022e+09  /* 1/sqrt(2) in Q31 */

#define MAX_V_MULT_MAT                  100             /* maximum array length for the function v_mult_mat() */

+2 −2
Original line number Diff line number Diff line
@@ -1916,8 +1916,8 @@ void fixed_to_float_stereo_tcx_core_dec(

    if ( st->lpcQuantization )
    {
        st->safety_net = st->safety_net_fx;
        st->mid_lsf_int = st->mid_lsf_int_fx;
        st->safety_net = st->safety_net;
        st->mid_lsf_int = st->mid_lsf_int;
    }

    for ( int p = 0; p < M; p++ )
+1 −1
Original line number Diff line number Diff line
@@ -534,7 +534,7 @@ void FEC_exc_estim_fx(
    test();
    IF( EQ_16(st_fx->last_coder_type,AUDIO)||(EQ_16(st_fx->last_good,INACTIVE_CLAS)&&LE_32(st_fx->total_brate, MAX_GSC_INACTIVE_BRATE)&&!st_fx->Opt_AMR_WB))
    {
        st_fx->GSC_noisy_speech_fx = st_fx->Last_GSC_noisy_speech_flag_fx;
        st_fx->GSC_noisy_speech = st_fx->Last_GSC_noisy_speech_flag;
        move16();
        /* Replication of the last spectrum, with a slight downscaling of its dynamic */
        if (st_fx->element_mode == EVS_MONO) {
+14 −14
Original line number Diff line number Diff line
@@ -2709,18 +2709,18 @@ ivas_error acelp_core_dec(
    floatToFixed_arr(lsp_new, tmp_lsp_new_fx, Q15, M);
    floatToFixed_arr(voice_factors, tmp_voice_factors_fx, Q15, NB_SUBFR16k);
    floatToFixed_arr(gain_buf, tmp_voice_factors_fx, Q14, NB_SUBFR16k);
    st->Last_GSC_noisy_speech_flag_fx = st->Last_GSC_noisy_speech_flag;
    st->Last_GSC_noisy_speech_flag = st->Last_GSC_noisy_speech_flag;
    st->coder_type = st->coder_type;
    if (st->hGSCDec != NULL)
    {
        st->hGSCDec->Last_GSC_pit_band_idx_fx = st->hGSCDec->Last_GSC_pit_band_idx;
        st->hGSCDec->seed_tcx_fx = st->hGSCDec->seed_tcx;
    }
    st->GSC_noisy_speech_fx = st->GSC_noisy_speech;
    st->last_ppp_mode_dec_fx = st->last_ppp_mode_dec;
    st->ppp_mode_dec_fx = st->ppp_mode_dec;
    st->nelp_mode_dec_fx = st->nelp_mode_dec;
    st->vbr_hw_BWE_disable_dec_fx = st->vbr_hw_BWE_disable_dec;
    st->GSC_noisy_speech = st->GSC_noisy_speech;
    st->last_ppp_mode_dec = st->last_ppp_mode_dec;
    st->ppp_mode_dec = st->ppp_mode_dec;
    st->nelp_mode_dec = st->nelp_mode_dec;
    st->vbr_hw_BWE_disable_dec = st->vbr_hw_BWE_disable_dec;
    // just outputs:
    if (st->hGSCDec != NULL)
    {
@@ -2729,13 +2729,13 @@ ivas_error acelp_core_dec(
        floatToFixed_arr(st->hGSCDec->Last_GSC_spectrum, st->hGSCDec->Last_GSC_spectrum_fx, Q10, M);
    }
    st->last_coder_type = st->last_coder_type;
    st->Last_GSC_noisy_speech_flag_fx = st->Last_GSC_noisy_speech_flag;
    st->Last_GSC_noisy_speech_flag = st->Last_GSC_noisy_speech_flag;
    if (st->hHQ_core != NULL)
        st->hHQ_core->HqVoicing_fx = st->hHQ_core->HqVoicing;
    st->old_ppp_mode_fx = st->old_ppp_mode;
    st->last_ppp_mode_dec_fx = st->last_ppp_mode_dec;
    st->old_ppp_mode = st->old_ppp_mode;
    st->last_ppp_mode_dec = st->last_ppp_mode_dec;
    st->last_nelp_mode_dec = st->last_nelp_mode_dec;
    st->last_vbr_hw_BWE_disable_dec_fx = st->last_vbr_hw_BWE_disable_dec;
    st->last_vbr_hw_BWE_disable_dec = st->last_vbr_hw_BWE_disable_dec;
    floatToFixed_arr(st->old_exc, st->old_exc_fx, tmp_Q_exc, L_EXC_MEM_DEC);
    for (i = 0; i < M; i++)
    {
@@ -2763,13 +2763,13 @@ ivas_error acelp_core_dec(
        st->hGSCDec->noise_lev = st->hGSCDec->noise_lev_fx;
        st->hGSCDec->Last_GSC_pit_band_idx = st->hGSCDec->Last_GSC_pit_band_idx_fx;
    }
    st->Last_GSC_noisy_speech_flag = st->Last_GSC_noisy_speech_flag_fx;
    st->Last_GSC_noisy_speech_flag = st->Last_GSC_noisy_speech_flag;
    if (st->hHQ_core != NULL)
        st->hHQ_core->HqVoicing = st->hHQ_core->HqVoicing_fx;
    st->old_ppp_mode = st->old_ppp_mode_fx;
    st->last_ppp_mode_dec = st->last_ppp_mode_dec_fx;
    st->old_ppp_mode = st->old_ppp_mode;
    st->last_ppp_mode_dec = st->last_ppp_mode_dec;
    st->last_nelp_mode_dec = st->last_nelp_mode_dec;
    st->last_vbr_hw_BWE_disable_dec = st->last_vbr_hw_BWE_disable_dec_fx;
    st->last_vbr_hw_BWE_disable_dec = st->last_vbr_hw_BWE_disable_dec;
    fixedToFloat_arr(st->old_exc_fx, st->old_exc, tmp_Q_exc, L_EXC_MEM_DEC);
    IF(!st->Opt_AMR_WB && st->hBWE_TD != NULL)
        fixedToFloat_arr(st->hBWE_TD->old_bwe_exc_fx, st->hBWE_TD->old_bwe_exc, tmp_Q_exc, PIT16k_MAX * 2);
+18 −18
Original line number Diff line number Diff line
@@ -303,9 +303,9 @@ ivas_error acelp_core_dec_fx(
    move16();
    do_WI_fx = 0;
    move16();
    st_fx->GSC_noisy_speech_fx = 0;
    st_fx->GSC_noisy_speech = 0;
    move16();
    st_fx->relax_prev_lsf_interp_fx = 0;
    st_fx->relax_prev_lsf_interp = 0;
    move16();

    set16_fx( gain_buf, 0, NB_SUBFR16k );
@@ -724,7 +724,7 @@ ivas_error acelp_core_dec_fx(
            uc_two_stage_flag = 0;
            move16(); move16(); move16();
            test();
            IF (!st_fx->nelp_mode_dec_fx && !st_fx->ppp_mode_dec_fx)
            IF (!st_fx->nelp_mode_dec && !st_fx->ppp_mode_dec)
            {
                Word16 tc_subfr_tmp;

@@ -742,7 +742,7 @@ ivas_error acelp_core_dec_fx(
                    move16();
                }

                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_fx, &(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);
                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);

                test(); test(); test();
                IF (EQ_16(st_fx->coder_type, TRANSITION) && LT_16(tc_subfr_fx, L_SUBFR) && EQ_16(st_fx->L_frame, L_FRAME)) 
@@ -771,7 +771,7 @@ ivas_error acelp_core_dec_fx(
            {
                st_fx->mem_preemp_preQ_fx = 0;
                move16();
                st_fx->last_nq_preQ_fx = 0;
                st_fx->last_nq_preQ = 0;
                move16();
#ifdef IVAS_CODE
                st_fx->last_code_preq = 0;
@@ -912,7 +912,7 @@ ivas_error acelp_core_dec_fx(
            test();
            test();
            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_fx==0 && !(EQ_16(st_fx->element_mode, IVAS_CPE_TD) && EQ_16(st_fx->idchan, 1)))
                            st_fx->relax_prev_lsf_interp==0 && !(EQ_16(st_fx->element_mode, IVAS_CPE_TD) && EQ_16(st_fx->idchan, 1)))
            {
                int_lsp4_fx(st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx,  M, 2 );
            }
@@ -951,7 +951,7 @@ ivas_error acelp_core_dec_fx(
            }
            else
#endif
            IF( EQ_16(st_fx->nelp_mode_dec_fx,1))
            IF( EQ_16(st_fx->nelp_mode_dec,1))
            {
                /* SC-VBR - NELP frames */
                Scale_sig(exc_fx-L_EXC_MEM, L_EXC_MEM, -st_fx->Q_exc);
@@ -966,7 +966,7 @@ ivas_error acelp_core_dec_fx(
                /* UNVOICED frames */
                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 );
            }
            ELSE IF ( EQ_16(st_fx->ppp_mode_dec_fx,1))
            ELSE IF ( EQ_16(st_fx->ppp_mode_dec,1))
            {
                Scale_sig(exc_fx-L_EXC_MEM, L_EXC_MEM, -st_fx->Q_exc);
                st_fx->Q_exc = 0;
@@ -1021,7 +1021,7 @@ ivas_error acelp_core_dec_fx(
             * Decode information and modify the excitation signal of stationary unvoiced frames
             *------------------------------------------------------------*/
            test(); test(); test();
            IF (!(EQ_16(st_fx->idchan, 1) && EQ_16(st_fx->element_mode, IVAS_CPE_TD)) && NE_16(st_fx->nelp_mode_dec_fx, 1) && !(EQ_16(st_fx->element_mode, IVAS_SCE) && tdm_low_rate_mode))
            IF (!(EQ_16(st_fx->idchan, 1) && EQ_16(st_fx->element_mode, IVAS_CPE_TD)) && NE_16(st_fx->nelp_mode_dec, 1) && !(EQ_16(st_fx->element_mode, IVAS_SCE) && tdm_low_rate_mode))
            {
                stat_noise_uv_dec_fx( st_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, exc2_fx, uc_two_stage_flag);
            }
@@ -1039,12 +1039,12 @@ ivas_error acelp_core_dec_fx(
                Copy(hMusicPF->dct_post_old_exc_fx, exc_buffer_fx, DCT_L_POST - OFFSET2);
            }
            test();
            IF(hMusicPF != NULL && ((EQ_16(st_fx->coder_type, AUDIO) && EQ_16(st_fx->GSC_noisy_speech_fx, 0)) || (GE_16(st_fx->GSC_IVAS_mode, 1) && EQ_16(st_fx->L_frame, L_FRAME)))) 
            IF(hMusicPF != NULL && ((EQ_16(st_fx->coder_type, AUDIO) && EQ_16(st_fx->GSC_noisy_speech, 0)) || (GE_16(st_fx->GSC_IVAS_mode, 1) && EQ_16(st_fx->L_frame, L_FRAME)))) 
            {

                Word16 last_coder_type = st_fx->last_coder_type;

                if ( (EQ_16(st_fx->idchan, 1) && EQ_16(st_fx->element_mode, IVAS_CPE_TD)) || (GE_16(st_fx->GSC_IVAS_mode, 1) && st_fx->GSC_noisy_speech_fx == 0))
                if ( (EQ_16(st_fx->idchan, 1) && EQ_16(st_fx->element_mode, IVAS_CPE_TD)) || (GE_16(st_fx->GSC_IVAS_mode, 1) && st_fx->GSC_noisy_speech == 0))
                {
                    last_coder_type = AUDIO;
                }
@@ -1154,7 +1154,7 @@ ivas_error acelp_core_dec_fx(
        /* SC-VBR */
        if ( EQ_16(st_fx->last_nelp_mode_dec,1))
        {
            st_fx->nelp_mode_dec_fx = 1;
            st_fx->nelp_mode_dec = 1;
            move16();
        }

@@ -1174,7 +1174,7 @@ ivas_error acelp_core_dec_fx(

        FEC_lsf2lsp_interp( st_fx, st_fx->L_frame, Aq_fx, lsf_new_fx, lsp_new_fx );

        IF ( st_fx->nelp_mode_dec_fx == 1 )
        IF ( st_fx->nelp_mode_dec == 1 )
        {
            /* SC-VBR */
            Scale_sig(exc_fx-L_EXC_MEM, L_EXC_MEM, -st_fx->Q_exc);
@@ -1292,11 +1292,11 @@ ivas_error acelp_core_dec_fx(
        /* fer_energy( st_fx->L_frame, st_fx->last_good, syn_fx, FEC_pitch_fx, &st_fx->enr_old_fx, st_fx->L_frame ); */
        frame_ener_fx( st_fx->L_frame, st_fx->last_good, syn_fx, shr(add(FEC_pitch_fx,32),6), &st_fx->enr_old_fx, st_fx->L_frame, st_fx->Q_syn, 3, 0 );

        IF ( st_fx->nelp_mode_dec_fx !=1 )
        IF ( st_fx->nelp_mode_dec !=1 )
        {
            /* modify the excitation signal of stationary unvoiced frames */
            stat_noise_uv_mod_fx( st_fx->coder_type, 0, st_fx->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, st_fx->Q_exc, 1, &st_fx->ge_sm_fx,
                                  &st_fx->uv_count_fx, &st_fx->act_count_fx, st_fx->lspold_s_fx, &st_fx->noimix_seed_fx, &st_fx->min_alpha_fx,
                                  &st_fx->uv_count, &st_fx->act_count, st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx,
                                  &st_fx->exc_pe_fx, st_fx->core_brate,st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge );
        }

@@ -1437,7 +1437,7 @@ ivas_error acelp_core_dec_fx(
                PMT("Code for IVAS_CODE_CNG_FIX185_PLC_FADEOUT not done")
                    ApplyFdCng(syn, st_fx->Q_syn, NULL, realBuffer, imagBuffer, st, 0, (st->coder_type == AUDIO && !st->GSC_noisy_speech));
#else
                ApplyFdCng(syn_fx, st_fx->Q_syn, realBuffer, imagBuffer, NULL, st_fx, 0, (EQ_16(st_fx->coder_type, AUDIO) && st_fx->GSC_noisy_speech_fx == 0));
                ApplyFdCng(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
            }
            /* CNA: Generate additional comfort noise to mask potential coding artefacts */
@@ -1780,7 +1780,7 @@ ivas_error acelp_core_dec_fx(
    IF(hBWE_TD != NULL)
    {
        test(); test(); test(); test(); test(); test(); test(); test(); test(); test();
        IF((!st_fx->bfi && (st_fx->prev_bfi)) || ((EQ_16(st_fx->last_vbr_hw_BWE_disable_dec_fx, 1)) && (st_fx->vbr_hw_BWE_disable_dec_fx == 0)) || ((EQ_16(st_fx->extl, SWB_TBE) || EQ_16(st_fx->extl, WB_TBE) || EQ_16(st_fx->extl, FB_TBE)) 
        IF((!st_fx->bfi && (st_fx->prev_bfi)) || ((EQ_16(st_fx->last_vbr_hw_BWE_disable_dec, 1)) && (st_fx->vbr_hw_BWE_disable_dec == 0)) || ((EQ_16(st_fx->extl, SWB_TBE) || EQ_16(st_fx->extl, WB_TBE) || EQ_16(st_fx->extl, FB_TBE)) 
             && NE_16(st_fx->last_extl, SWB_TBE) && NE_16(st_fx->last_extl, WB_TBE) && NE_16(st_fx->last_extl, FB_TBE))
                || (EQ_16(st_fx->idchan, 1) && EQ_16(st_fx->element_mode, IVAS_CPE_TD) && !st_fx->tdm_LRTD_flag))
        {
@@ -1789,7 +1789,7 @@ ivas_error acelp_core_dec_fx(
        }


        IF(!st_fx->ppp_mode_dec_fx && (st_fx->idchan == 0 || NE_16(st_fx->element_mode, IVAS_CPE_TD) || (EQ_16(st_fx->idchan, 1) && EQ_16(st_fx->element_mode, IVAS_CPE_TD) && st_fx->tdm_LRTD_flag)))
        IF(!st_fx->ppp_mode_dec && (st_fx->idchan == 0 || NE_16(st_fx->element_mode, IVAS_CPE_TD) || (EQ_16(st_fx->idchan, 1) && EQ_16(st_fx->element_mode, IVAS_CPE_TD) && st_fx->tdm_LRTD_flag)))
        {
            non_linearity_fx(bwe_exc_fx, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, st_fx->Q_exc,
                st_fx->coder_type, voice_factors, st_fx->L_frame);
Loading