From 40b36092b86562509c66ccfbf6c534d6fb2bfc15 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 24 Jan 2024 14:21:35 +0530 Subject: [PATCH] Fixed point related updates to decoder_tcx_invQ func calls --- lib_dec/ivas_mdct_core_dec.c | 79 +++++++++++++++++++++++++++++++--- lib_dec/tonalMDCTconcealment.c | 3 +- 2 files changed, 76 insertions(+), 6 deletions(-) diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 0cd91bf8c..bee437aec 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -843,8 +843,79 @@ void ivas_mdct_core_invQ( } nf_seed = 0; - decoder_tcx_invQ( st, prm[ch], Aq[ch], Aind[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], NULL, xn_buf, &fUseTns[ch][k], &tnsData[ch][k], &gain_tcx, &prm_sqQ, &nf_seed, bfi, k ); +#ifdef IVAS_FLOAT_FIXED + Word32 x_fx[N_MAX]; + Word16 Aq_fx[M + 1], Aq_e, x_e; + set32_fx(x_fx, 0, N_MAX); +#endif +#ifdef IVAS_FLOAT_FIXED + + f2me_buf(x[ch][k], x_fx, &x_e, L_frameTCX[ch]); + f2me_buf_16(Aq[ch], Aq_fx, &Aq_e, M + 1); + + st->gamma = float_to_fix16(st->gamma_float, Q15); + st->preemph_fac = float_to_fix16(st->preemph_fac_float, Q15); + st->hTcxDec->cummulative_damping_tcx = float_to_fix16(st->hTcxDec->cummulative_damping_tcx_float, Q15); + st->Mode2_lp_gainp = float_to_fix(st->lp_gainp, Q16); + st->stab_fac_fx = float_to_fix16(st->stab_fac, Q15); + st->hTcxCfg->na_scale = float_to_fix16(st->hTcxCfg->na_scale_flt, Q15); + st->hTcxCfg->sq_rounding = float_to_fix16(st->hTcxCfg->sq_rounding_flt, Q15); + st->hTcxLtpDec->tcxltp_gain = float_to_fix16(st->hTcxLtpDec->tcxltp_gain_float, Q15); + st->inv_gamma = FL2WORD16_SCALE(1 / st->gamma_float, 1); + st->hTcxCfg->preemph_fac = FL2WORD16(st->hTcxCfg->preemph_fac_flt); + f2me_16(st->last_gain_syn_deemph_float, &st->last_gain_syn_deemph, &st->last_gain_syn_deemph_e); + f2me_16(st->last_concealed_gain_syn_deemph_float, &st->last_concealed_gain_syn_deemph, &st->last_concealed_gain_syn_deemph_e); + f2me_16(st->hTcxDec->old_gaintcx_bfi_float, &st->hTcxDec->old_gaintcx_bfi, &st->hTcxDec->old_gaintcx_bfi_e); + + decoder_tcx_invQ_fx( st, prm[ch], Aq_fx, Aind[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x_fx, &x_e, NULL, NULL, xn_buf_fx, &fUseTns[ch][k], &tnsData[ch][k], &gain_tcx_fx, &gain_tcx_e, &prm_sqQ, &nf_seed, bfi, k ); + + /* TODO: remove float dependency */ + st->hTcxDec->stepCompensate_float = me2f_16(st->hTcxDec->stepCompensate, st->hTcxDec->stepCompensate_e); + st->hTcxDec->gainHelper_float = me2f_16(st->hTcxDec->gainHelper, st->hTcxDec->gainHelper_e); + st->last_concealed_gain_syn_deemph_float = me2f_16(st->last_concealed_gain_syn_deemph, st->last_concealed_gain_syn_deemph_e); + st->last_gain_syn_deemph_float = me2f_16(st->last_gain_syn_deemph, st->last_gain_syn_deemph_e); + st->hTcxDec->old_gaintcx_bfi_float = me2f_16(st->hTcxDec->old_gaintcx_bfi, st->hTcxDec->old_gaintcx_bfi_e); + + st->hTcxDec->cummulative_damping_tcx_float = fix16_to_float(st->hTcxDec->cummulative_damping_tcx, Q15); + st->hTcxDec->damping_float = fix16_to_float(st->hTcxDec->damping, Q14); + st->lp_gainp = fix_to_float(st->Mode2_lp_gainp, Q16); + + me2f_buf(x_fx, x_e, x[ch][k], L_frameTCX[ch]); + gain_tcx = me2f_16(gain_tcx_fx, gain_tcx_e); + for (int i = 0; i < max(max(L_frame[ch], L_spec[ch]), L_frameTCX[ch]); i++) + { + xn_buf[i] = fix16_to_float(xn_buf_fx[i], Q14); + } +#if 0 + dbgwrite_txt(x[ch][k], L_frameTCX[ch], "logs\\dir\\Fixed_code_decoderTcxInvQ_x.txt", NULL); + dbgwrite_txt(xn_buf, max(max(L_frame[ch], L_spec[ch]), L_frameTCX[ch]), "logs\\dir\\Fixed_code_decoderTcxInvQ_xnBuf.txt", NULL); + dbgwrite_txt(&(st->hTcxDec->stepCompensate_float), 1, "logs\\dir\\Fixed_code_decoderTcxInvQ_stepCompensate.txt", NULL); + dbgwrite_txt(&(st->hTcxDec->gainHelper_float), 1, "logs\\dir\\Fixed_code_decoderTcxInvQ_gainHelper.txt", NULL); + dbgwrite_txt(&(st->last_concealed_gain_syn_deemph_float), 1, "logs\\dir\\Fixed_code_decoderTcxInvQ_lastConcealedGainSynDeemph.txt", NULL); + dbgwrite_txt(&(gain_tcx), 1, "logs\\dir\\Fixed_code_decoderTcxInvQ_gainTcx.txt", NULL); + dbgwrite_txt(&(st->last_gain_syn_deemph_float), 1, "logs\\dir\\Fixed_code_decoderTcxInvQ_lastGainSynDeemph.txt", NULL); + dbgwrite_txt(&(st->hTcxDec->old_gaintcx_bfi_float), 1, "logs\\dir\\Fixed_code_decoderTcxInvQ_oldGaintcxBfi.txt", NULL); + dbgwrite_txt(&(st->hTcxDec->cummulative_damping_tcx_float), 1, "logs\\dir\\Fixed_code_decoderTcxInvQ_cummulativeDampingTcx.txt", NULL); + dbgwrite_txt(&(st->hTcxDec->damping_float), 1, "logs\\dir\\Fixed_code_decoderTcxInvQ_dampingFact.txt", NULL); + dbgwrite_txt(&(st->lp_gainp), 1, "logs\\dir\\Fixed_code_decoderTcxInvQ_lpGainp.txt", NULL); +#endif +#else + decoder_tcx_invQ(st, prm[ch], Aq[ch], Aind[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], NULL, xn_buf, &fUseTns[ch][k], &tnsData[ch][k], &gain_tcx, &prm_sqQ, &nf_seed, bfi, k); +#if 0 + dbgwrite_txt(x[ch][k], L_frameTCX[ch], "logs\\dir\\Float_code_decoderTcxInvQ_x.txt", NULL); + dbgwrite_txt(xn_buf, max(max(L_frame[ch], L_spec[ch]), L_frameTCX[ch]), "logs\\dir\\Float_code_decoderTcxInvQ_xnBuf.txt", NULL); + dbgwrite_txt(&(st->hTcxDec->stepCompensate_float), 1, "logs\\dir\\Float_code_decoderTcxInvQ_stepCompensate.txt", NULL); + dbgwrite_txt(&(st->hTcxDec->gainHelper_float), 1, "logs\\dir\\Float_code_decoderTcxInvQ_gainHelper.txt", NULL); + dbgwrite_txt(&(st->last_concealed_gain_syn_deemph_float), 1, "logs\\dir\\Float_code_decoderTcxInvQ_lastConcealedGainSynDeemph.txt", NULL); + dbgwrite_txt(&(gain_tcx), 1, "logs\\dir\\Float_code_decoderTcxInvQ_gainTcx.txt", NULL); + dbgwrite_txt(&(st->last_gain_syn_deemph_float), 1, "logs\\dir\\Float_code_decoderTcxInvQ_lastGainSynDeemph.txt", NULL); + dbgwrite_txt(&(st->hTcxDec->old_gaintcx_bfi_float), 1, "logs\\dir\\Float_code_decoderTcxInvQ_oldGaintcxBfi.txt", NULL); + dbgwrite_txt(&(st->hTcxDec->cummulative_damping_tcx_float), 1, "logs\\dir\\Float_code_decoderTcxInvQ_cummulativeDampingTcx.txt", NULL); + dbgwrite_txt(&(st->hTcxDec->damping_float), 1, "logs\\dir\\Float_code_decoderTcxInvQ_dampingFact.txt", NULL); + dbgwrite_txt(&(st->lp_gainp), 1, "logs\\dir\\Float_code_decoderTcxInvQ_lpGainp.txt", NULL); +#endif +#endif mvr2r( x[ch][k], x_0[ch][k], L_frameTCX[ch] ); if ( bfi && !MCT_flag ) @@ -853,9 +924,6 @@ void ivas_mdct_core_invQ( } #ifdef IVAS_FLOAT_FIXED - Word32 x_fx[N_MAX]; - Word16 Aq_fx[M + 1], Aq_e, x_e; - set32_fx( x_fx, 0, N_MAX ); f2me_buf( x[ch][k], x_fx, &x_e, L_frameTCX[ch] ); f2me_buf_16( Aq[ch], Aq_fx, &Aq_e, M + 1 ); f2me_16( gain_tcx, &gain_tcx_fx, &gain_tcx_e ); @@ -1179,7 +1247,8 @@ void ivas_mdct_core_tns_ns( { if ( st->hTonalMDCTConc != NULL ) { - if ( !MCT_flag && st->hTcxDec->cummulative_damping_tcx_float != 1.f ) + if ( !MCT_flag && st->hTcxDec->cummulative_damping_tcx_float < 0.99f ) + //if ( !MCT_flag && st->hTcxDec->cummulative_damping_tcx_float != 1.f ) { float *scf_last, *scf_bg; float fade_in, fade_out; diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index 408151569..33ed8fa0d 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -1153,7 +1153,8 @@ void TonalMdctConceal_create_concealment_noise_ivas( *rnd_c = 1979; } - if ( crossfade_gain == 1.0f ) + //if ( crossfade_gain == 1.0f ) + if (crossfade_gain > 0.999f) /* Due to precision loss */ { /* In first frame, noise is weighted with zero anyway, we only need the random numbers for the sign scrambling */ for ( i = 0; i < max_noise_line; i++ ) -- GitLab