Commit 56940aff authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Integrated decoder_tcx_imdct function in decoder_tns_fx function

[x] Removed q from CNG Noise Level struct.
[x] integrated decoder_tcx_imdct function in
decoder_tns_fx function.
parent 37ae3435
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -461,7 +461,7 @@ typedef struct
    Word16  exp_cldfb_periodog;

    Word32  cngNoiseLevel[FFTCLDFBLEN];  /* Noise level applied for the CNG in each (sub)band */
    Word16 q_cngNoiseLevel;
    //Word16 q_cngNoiseLevel;
    Word16  cngNoiseLevelExp;

    int16_t seed;                     /* Seed memory (for random function) */
+1 −1
Original line number Diff line number Diff line
@@ -2034,7 +2034,7 @@ ivas_error acelp_core_dec(
                f2me_buf(st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, &st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN);

                // NOTE: this should be removed later.
                st->hFdCngDec->hFdCngCom->q_cngNoiseLevel = 31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp;
                //st->hFdCngDec->hFdCngCom->q_cngNoiseLevel = 31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp;

                Word16 tmpBufferScale = 0;
                generate_comfort_noise_dec_hf_ivas_fx( realBuffer_fx, imagBuffer_fx, /*realBuffer, imagBuffer,*/ &tmpBufferScale, st->hFdCngDec->hFdCngCom, st->cng_ism_flag );
+10 −10
Original line number Diff line number Diff line
@@ -1916,11 +1916,11 @@ void decoder_tcx_imdct(
        {
            maxim = fmaxf(maxim, fabsf(st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[ind]));
        }
        st->hFdCngDec->hFdCngCom->q_cngNoiseLevel = 31;
        IF(L_abs((Word32)maxim)!=0) st->hFdCngDec->hFdCngCom->q_cngNoiseLevel = norm_l((Word32)maxim);
        st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0;
        IF(L_abs((Word32)maxim)!=0) st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 31 - norm_l((Word32)maxim);
        FOR(Word16 ind = 0; ind < FFTCLDFBLEN; ind++)
        {
            st->hFdCngDec->hFdCngCom->cngNoiseLevel[ind] = (Word32)(st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[ind] * (1LL<<st->hFdCngDec->hFdCngCom->q_cngNoiseLevel));
            st->hFdCngDec->hFdCngCom->cngNoiseLevel[ind] = (Word32)(st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[ind] * (1LL<<(31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp)));
        }
        st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = float_to_fix16(st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt, 15);

@@ -2182,24 +2182,24 @@ void decoder_tcx_imdct_fx(
               kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr(s_max( L_frameTCX, L_spec ), 1), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx );
    }

    IF ( NE_16(st->element_mode, EVS_MONO) )
    {
    FOR(Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++) {
        xn_bufFB_fx_16[ind] = (Word16)L_shr(xn_bufFB_fx[ind], (q_x - q_win));
    }
    IF ( NE_16(st->element_mode, EVS_MONO) )
    {
        IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB,
               hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index,
               kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, max( L_frameTCX, L_spec ) >> 1, L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, FSCALE_DENOM * L_frameTCX_glob / L_frame_glob, acelp_zir_fx );
        FOR(Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++) {
            xn_bufFB_fx[ind] = L_shl(xn_bufFB_fx_16[ind], (q_x - q_win));
        }
    }
    ELSE
    {

        IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_buf_fx, hTcxCfg->tcx_aldo_window_1_FB,  hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index,
        IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB,  hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index,
               kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, FSCALE_DENOM * L_frameTCX_glob / L_frame_glob, acelp_zir_fx );
    }
    FOR(Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++) {
        xn_bufFB_fx[ind] = L_shl(xn_bufFB_fx_16[ind], (q_x - q_win));
    }

    IF ( EQ_16(bfi, 0) )
    {
+115 −1
Original line number Diff line number Diff line
@@ -3383,7 +3383,7 @@ void decoder_tcx_fx(
    {
        st->hIGFDec->infoTCXNoise[l] = (uint8_t)st->hIGFDec->infoTCXNoise_evs[l];
    }
    me2f_buf(st->hIGFDec->virtualSpec, st->hIGFDec->virtualSpec_e, st->hIGFDec->virtualSpec_float, (N_MAX_TCX - IGF_START_MN));
    me2f_buf(st->hIGFDec->virtualSpec, st->hIGFDec->virtualSpec_e, st->hIGFDec->virtualSpecBuf, (N_MAX_TCX - IGF_START_MN));
    me2f_buf(x_fx, x_e, x, x_len);
    // Fixed to float ends here
#else
@@ -3403,8 +3403,122 @@ void decoder_tcx_fx(
    decoder_tcx_tns( st, L_frame_glob, L_spec, L_frame, L_frameTCX, &x[0], fUseTns, &tnsData, bfi, frame_cnt, 0 );
#endif

#ifdef IVAS_FLOAT_FIXED
                    //
    Word16 synth_fx[2040], synthFB_fx[2040];
    Word16 q_x = Q11, q_win = -2;

    FOR(Word16 i = 0; i < s_min(s_max(s_max(st->hIGFDec->infoIGFStopLine, s_max(L_frameTCX, L_spec)), L_frame), 1200); i++) {
        x_fx[i] = (Word32)(x[i] * (1 << q_x));
    }
    FOR (Word16 ind = 0; ind < 2040; ind++) {
        xn_buf_fx[ind] = (Word16)(xn_buf[ind] / 4.f);
    }
    x_e = 31 - q_x;
    st->hIGFDec->virtualSpec_e = x_e;
    IF ( NE_16(st->igf, 0) )
    FOR(Word16 i = 0; i < s_min(st->hIGFDec->infoIGFStopLine - st->hIGFDec->infoIGFStartLine, 856); i++) {
        st->hIGFDec->virtualSpec_fx[st->hIGFDec->infoIGFStartLine - IGF_START_MN + i] = (Word32)(st->hIGFDec->virtualSpec_float[st->hIGFDec->infoIGFStartLine - IGF_START_MN + i] * (1 << (31 - st->hIGFDec->virtualSpec_e)));
    }

    FOR( Word16 ind = 0; ind < 320; ind++ )
    {
        st->hTcxDec->syn_Overl[ind] = (Word16)(st->hTcxDec->syn_Overl_float[ind] / (1<<(-q_win)));
    }
    FOR(Word16 ind = 0; ind < 320; ind++) {
        st->hTcxDec->syn_Overl_TDAC[ind] = (Word16)(st->hTcxDec->syn_Overl_TDAC_float[ind] / (1<<(-q_win)));
    }
    FOR( Word16 ind = 0; ind < 480; ind++ )
    {
        st->hTcxDec->syn_OverlFB[ind] = (Word16)(st->hTcxDec->syn_OverlFB_float[ind] / (1<<(-q_win)));
    }
    FOR(Word16 ind = 0; ind < 480; ind++) {
        st->hTcxDec->syn_Overl_TDACFB[ind] = (Word16)(st->hTcxDec->syn_Overl_TDACFB_float[ind] / (1<<(-q_win)));
    }
    FOR(Word16 ind = 0; ind < 640; ind++) {
        st->hHQ_core->old_out_LB_fx[ind] = (Word16)(st->hHQ_core->old_outLB[ind] / (1<<(-q_win)));
    }
    FOR(Word16 ind = 0; ind < 17; ind++) {
        st->old_Aq_12_8_fx_32[ind] = (Word32)(st->old_Aq_12_8[ind] * (1<<28));
    }
    FOR( Word16 ind = 0; ind < M + 1; ind++ )
    {
        st->old_Aq_12_8_fx[ind] = (Word16) ( st->old_Aq_12_8[ind] * 4096.f );
    }
    FOR(Word16 ind = 0; ind < 320; ind++) {
        st->hTcxDec->old_syn_Overl[ind] = (Word16)(st->hTcxDec->old_syn_Overl_float[ind] / (1<<(-q_win)));
    }
    FOR(Word16 ind = 0; ind < 320; ind++) {
        st->hTcxDec->syn_Overl_TDAC[ind] = (Word16)(st->hTcxDec->syn_Overl_TDAC_float[ind] / (1<<(-q_win)));
    }
    FOR(Word16 ind = 0; ind < 480; ind++) {
        st->hTcxDec->syn_OverlFB[ind] = (Word16)(st->hTcxDec->syn_OverlFB_float[ind] / (1<<(-q_win)));
    }
    FOR(Word16 ind = 0; ind < 320; ind++) {
        st->hTcxDec->syn_Overl[ind] = (Word16)(st->hTcxDec->syn_Overl_float[ind] / (1<<(-q_win)));
    }
    st->hTcxDec->conceal_eof_gain = (Word16)(st->hTcxDec->conceal_eof_gain_float * 16384.f);
    st->last_concealed_gain_syn_deemph = (Word16)(st->last_concealed_gain_syn_deemph_float * 32767.f);
    float maxim = 0;
    IF(st->hFdCngDec && st->hFdCngDec->hFdCngCom) {
        FOR(Word16 ind = 0; ind < FFTCLDFBLEN; ind++)
        {
            maxim = fmaxf(maxim, fabsf(st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[ind]));
        }
        st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0;
        IF(L_abs((Word32)maxim)!=0) st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 31 - norm_l((Word32)maxim);
        FOR(Word16 ind = 0; ind < FFTCLDFBLEN; ind++)
        {
            st->hFdCngDec->hFdCngCom->cngNoiseLevel[ind] = (Word32)(st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[ind] * (1LL<<(31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp)));
        }
        st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = float_to_fix16(st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt, 15);
    }
    FOR(Word16 ind = 0; ind < 960; ind++) {
        st->hHQ_core->old_out_fx[ind] = (Word16)(st->hHQ_core->old_out[ind] / (1<<(-q_win)));
    }
    FOR(Word16 ind = 0; ind < L_frame_glob; ind++) {
        synth_fx[ind] = (Word16)(synth[ind] / (1<<(-q_win)));
    }
    FOR(Word16 ind = 0; ind < L_frameTCX_glob; ind++) {
        synthFB_fx[ind] = (Word16)(synthFB[ind] / (1<<(-q_win)));
    }

    decoder_tcx_imdct_fx( st, L_frame_glob, L_frameTCX_glob, L_spec, tcx_offset, tcx_offsetFB, L_frame, L_frameTCX, left_rect, &x_fx[0], q_x, xn_buf_fx, q_win, MDCT_IV,
                        fUseTns, &synth_fx[0], &synthFB_fx[0], bfi, frame_cnt, sba_dirac_stereo_flag );
                    
    IF(st->igf) me2f_buf(x_fx, x_e, x, s_max(st->hIGFDec->infoIGFStopLine, s_max(L_frameTCX, L_spec) ) );
        
    FOR(Word16 ind = 0; ind < 17; ind++) {
        st->old_Aq_12_8[ind] = (float)(st->old_Aq_12_8_fx[ind]) / (float)(1<<12);
    }
    FOR(Word16 ind = 0; ind < 640; ind++) {
        st->hHQ_core->old_outLB[ind] = (float)st->hHQ_core->old_out_LB_fx[ind] * (1<<(-q_win));
    }
    FOR(Word16 ind = 0; ind < 960; ind++) {
        st->hHQ_core->old_out[ind] = (float)st->hHQ_core->old_out_fx[ind] * (1<<(-q_win));
    }
    FOR(Word16 ind = 0; ind < L_frame_glob; ind++) {
        synth[ind] = (float)synth_fx[ind] * (1<<(-q_win));
    }
    FOR(Word16 ind = 0; ind < L_frameTCX_glob; ind++) {
        synthFB[ind] = (float)synthFB_fx[ind] * (1<<(-q_win));
    }
    IF ( EQ_16(st->hTcxCfg->last_aldo, 0) ) FOR(Word16 ind = 0; ind < L_FRAME32k / 2; ind++) {
        st->hTcxDec->syn_Overl_float[ind] = (float)st->hTcxDec->syn_Overl[ind] * (1<<(-q_win));
    }
    IF ( EQ_16(st->hTcxCfg->last_aldo, 0) ) FOR(Word16 ind = 0; ind < L_FRAME_MAX / 2; ind++) {
        st->hTcxDec->syn_OverlFB_float[ind] = (float)st->hTcxDec->syn_OverlFB[ind] * (1<<(-q_win));
    }
    st->hTcxDec->tcxltp_third_last_pitch_float = fix_to_float(st->hTcxDec->tcxltp_third_last_pitch, 16);
    st->hTcxDec->tcxltp_second_last_pitch_float = fix_to_float(st->hTcxDec->tcxltp_second_last_pitch, 16);
    st->old_fpitch_float = fix_to_float(st->old_fpitch, 16);
    st->old_fpitchFB_float = fix_to_float(st->old_fpitchFB, 16);
    //

#else
    decoder_tcx_imdct( st, L_frame_glob, L_frameTCX_glob, L_spec, tcx_offset, tcx_offsetFB, L_frame, L_frameTCX, left_rect, &x[0], &xn_buf[0], MDCT_IV,
                       fUseTns, &synth[0], &synthFB[0], bfi, frame_cnt, sba_dirac_stereo_flag );
#endif
}

/*-------------------------------------------------------------------*
+1 −1
Original line number Diff line number Diff line
@@ -3047,7 +3047,7 @@ void generate_masking_noise_dirac_fx(
        scale_fx = Mpy_32_32(scale_fx, Mpy_32_16_1(L_mult(h_cldfb->scale, h_cldfb->scale), CLDFB_SCALING)); //Q = q_scale + 2q -34
        q_scale = sub(add(q_scale, i_mult(2, h_cldfb->q_scale)), 34);
        ptr_level_fx = hFdCngCom->cngNoiseLevel + hFdCngCom->stopFFTbin - hFdCngCom->startBand;
        q_ptr_level = hFdCngCom->q_cngNoiseLevel;
        q_ptr_level = 31 - hFdCngCom->cngNoiseLevelExp;
        move16();

        FOR ( i = hFdCngCom->numCoreBands; i < hFdCngCom->regularStopBand; i++ )
Loading