diff --git a/lib_com/calc_st_com.c b/lib_com/calc_st_com.c index 3c263838cbfb0044091735334ef9d4d1d58c656e..4a1369c10974aee2a60f7e7b485490fc806773f6 100644 --- a/lib_com/calc_st_com.c +++ b/lib_com/calc_st_com.c @@ -95,14 +95,14 @@ static void calc_rc0_h( /*---------------------------------------------------------------------------- - * calc_st_filt() + * calc_st_filt_fx() * * computes impulse response of A(gamma2) / A(gamma1) * controls gain : computation of energy impulse response as * SUMn (abs (h[n])) and computes parcor0 *---------------------------------------------------------------------------- */ -void calc_st_filt( +void calc_st_filt_fx( const float *apond2, /* i : coefficients of numerator */ const float *apond1, /* i : coefficients of denominator */ float *parcor0, /* o : 1st parcor calcul. on composed filter */ diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index b9129c4bf8010a4c53d131f40b4908b6c045a3f4..9b5c18ccb7893882117a1c3735f8f09b19aeffac 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -2784,7 +2784,7 @@ const float ivas_param_mc_quant_ild_5d1_48[PARAM_MC_SZ_ILD_QUANTIZER_4BITS] = }; #ifdef IVAS_FLOAT_FIXED -//Q7 +//Q8 const Word16 ivas_param_mc_quant_ild_5d1_48_fx[PARAM_MC_SZ_ILD_QUANTIZER_4BITS] = { -25600 ,-5120 ,-3328 ,-2560 ,-2048 ,-1408 ,-896 ,-384 ,0 ,384 ,896 ,1408 ,2048 ,2560 ,3328 ,5120 , @@ -2798,10 +2798,10 @@ const float ivas_param_mc_quant_icc[PARAM_MC_SZ_ICC_QUANTIZER] = }; #ifdef IVAS_FLOAT_FIXED -//Q14 +//Q15 const Word16 ivas_param_mc_quant_icc_fx[PARAM_MC_SZ_ICC_QUANTIZER] = { - -16220 ,-9650 ,0 ,6023 ,9845 ,13782 ,15352 ,16384 , + -32440,-19300,0,12046,19690,27563,30703,32767 }; #endif diff --git a/lib_com/prot.h b/lib_com/prot.h index 4b232e19eb1149e216953b3163afd61643604419..b27d15c20a47607f2c84e5492b5ab3752d0835c9 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -2530,6 +2530,17 @@ void calc_st_filt( const int16_t extl /* i : extension layer info */ ); +void calc_st_filt_fx( + const float *apond2, /* i : coefficients of numerator */ + const float *apond1, /* i : coefficients of denominator */ + float *parcor0, /* o : 1st parcor calcul. on composed filter */ + float *sig_ltp_ptr, /* i/o: input of 1/A(gamma1) : scaled by 1/g0 */ + float *mem_zero, /* i/o: All zero memory */ + const int16_t L_subfr, /* i : the length of subframe */ + const int16_t extl /* i : extension layer info */ + +); + void scale_st_ivas( const float *sig_in, /* i : postfilter input signal */ float *sig_out, /* i/o: postfilter output signal */ diff --git a/lib_com/prot_fx2.h b/lib_com/prot_fx2.h index 5f0d68b725ef0d9d74b068ad4a2b1977d3f301bb..0b1b531aab747ddac3b6a07cab953571970b8704 100644 --- a/lib_com/prot_fx2.h +++ b/lib_com/prot_fx2.h @@ -6162,12 +6162,12 @@ void TonalMDCTConceal_Apply( ); //dec_post_fx - void Init_post_filter( + void Init_post_filter_fx( PFSTAT_HANDLE hPFstat /* i : core decoder parameters */ ); /* (i) : core decoder parameters */ - void nb_post_filt( + void nb_post_filt_fx( const Word16 L_frame, /* i : frame length */ PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16* psf_lp_noise, /* i : Long term noise Q8 */ @@ -6180,7 +6180,7 @@ void TonalMDCTConceal_Apply( const Word16 disable_hpf /* i : flag to diabled HPF */ ); - void formant_post_filt( + void formant_post_filt_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *synth_in, /* i : 12k8 synthesis */ Word16 *Aq, /* i : LP filter coefficient */ @@ -6192,7 +6192,7 @@ void TonalMDCTConceal_Apply( ); #ifdef IVAS_FLOAT_FIXED - void formant_post_filt_fx( + void formant_post_filt_ivas_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *synth_in, /* i : 12k8 synthesis */ Word16 *Aq, /* i : LP filter coefficient */ @@ -6203,7 +6203,7 @@ void TonalMDCTConceal_Apply( const Word16 off_flag /* i : off flag */ ); #endif - void Filt_mu( + void Filt_mu_fx( Word16 * sig_in, /* i : signal (beginning at sample -1) */ Word16 * sig_out, /* o : signal with tilt */ Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ @@ -6211,7 +6211,7 @@ void TonalMDCTConceal_Apply( ); #ifdef IVAS_FLOAT_FIXED - void Filt_mu_fx( + void Filt_mu_ivas_fx( Word16 * sig_in, /* i : signal (beginning at sample -1) */ Word16 * sig_out, /* o : signal with tilt */ Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ @@ -6219,14 +6219,14 @@ void TonalMDCTConceal_Apply( const Word16 extl ); #endif - void scale_st( + void scale_st_fx( const Word16 * sig_in, /* i : postfilter i signal */ Word16 * sig_out, /* i/o: postfilter o signal */ Word16 * gain_prec, /* i/o: last value of gain for subframe */ Word16 L_subfr ); - void blend_subfr2( + void blend_subfr2_fx( Word16 *sigIn1, /* i : i signal for fade-out */ Word16 *sigIn2, /* i : i signal for fade-in */ Word16 *sigOut /* o : output signal */ diff --git a/lib_com/swb_tbe_com.c b/lib_com/swb_tbe_com.c index b27fb86b2f0610084573d5a4570fac2d5c658bf8..1bdb0fa104f30fc69a4ab8b4d65a33f5c932670f 100644 --- a/lib_com/swb_tbe_com.c +++ b/lib_com/swb_tbe_com.c @@ -743,7 +743,7 @@ void PostShortTerm( sig_ltp[0] = *ptr_mem_stp; /* Control short term pst filter gain and compute parcor0 */ - calc_st_filt( apond2, apond1, &parcor0, sig_ltp + 1, mem_zero, L_SUBFR16k, SWB_TBE ); + calc_st_filt_fx( apond2, apond1, &parcor0, sig_ltp + 1, mem_zero, L_SUBFR16k, SWB_TBE ); /* 1/A(gamma1) filtering, mem_stp is updated */ syn_filt( apond1, LPC_SHB_ORDER, sig_ltp + 1, sig_ltp + 1, L_SUBFR16k, mem_stp, 1 ); diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 8cacdbd5b18d7688ec62ce453e26b000014f96ba..2033bc20bcb9be640bce4f7bb0a9b527c6da5ccf 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1333,13 +1333,13 @@ ivas_error acelp_core_dec_fx( { st_fx->hPFstat->on = 1; move16(); - nb_post_filt( st_fx->L_frame, st_fx->hPFstat, &st_fx->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, st_fx->coder_type, st_fx->BER_detect, 0 ); + nb_post_filt_fx( st_fx->L_frame, st_fx->hPFstat, &st_fx->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, st_fx->coder_type, st_fx->BER_detect, 0 ); } ELSE { st_fx->hPFstat->on = 0; move16(); - nb_post_filt( st_fx->L_frame, st_fx->hPFstat, &st_fx->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, AUDIO, st_fx->BER_detect, 0 ); + nb_post_filt_fx( st_fx->L_frame, st_fx->hPFstat, &st_fx->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, AUDIO, st_fx->BER_detect, 0 ); } } ELSE @@ -1376,7 +1376,7 @@ ivas_error acelp_core_dec_fx( Copy( syn_fx, temp_buf + L_SYN_MEM, L_FRAME16k ); st_fx->hPFstat->on = 1; move16(); - formant_post_filt( st_fx->hPFstat, temp_buf + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME16k, st_fx->lp_noise, st_fx->total_brate, 0); + 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); } ELSE IF( GE_16(st_fx->last_bwidth,WB)) { @@ -1386,9 +1386,9 @@ ivas_error acelp_core_dec_fx( Copy( syn_fx, temp_buf + M, L_SUBFR ); Residu3_fx ( Aq_fx, temp_buf + M, temp_buf+M+L_SUBFR, L_SUBFR, 1 ); E_UTIL_synthesis ( 1, Aq_fx, temp_buf+M+L_SUBFR, temp_buf, L_SUBFR, st_fx->hPFstat->mem_stp+L_SYN_MEM-M, 0, M ); - scale_st ( syn_fx, temp_buf, &st_fx->hPFstat->gain_prec, L_SUBFR ); + scale_st_fx ( syn_fx, temp_buf, &st_fx->hPFstat->gain_prec, L_SUBFR ); Copy( temp_buf, syn_fx, L_SUBFR/2 ); - blend_subfr2( temp_buf + L_SUBFR/2, syn_fx + L_SUBFR/2, syn_fx + L_SUBFR/2 ); + blend_subfr2_fx( temp_buf + L_SUBFR/2, syn_fx + L_SUBFR/2, syn_fx + L_SUBFR/2 ); } st_fx->hPFstat->on = 0; move16(); diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 1940591db5bfebd35caa6d9e19223745bb0987ce..4bae09992d44650e1191485c5352000b179e5cc8 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -78,91 +78,51 @@ ivas_error acelp_core_dec_ivas_fx( const int16_t read_sid_info /* i : read SID info flag */ ) { - //Word16 output_fx[960], synth_fx16[960],/* save_hb_synth_fx[960],*/ voice_factors_fx[NB_SUBFR16k], old_syn_12k8_16k_fx[960], pitch_buf_out_fx[NB_SUBFR16k], tdm_lspQ_PCh_fx[M], tdm_lsfQ_PCh_fx[M]; Word32 synth_fx[960], save_hb_synth_fx[960]/*, bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]*/; - /*for (int i = 0; i < M; i++) { - tdm_lsfQ_PCh_fx[i] = (Word16)(tdm_lsfQ_PCh[i] * 2.56f); - } - floatToFixed_arr((float *)tdm_lspQ_PCh, tdm_lspQ_PCh_fx, Q15, M); - if (save_hb_synth) { - floatToFixed_arrL(save_hb_synth, save_hb_synth_fx, 0, L_FRAME48k); - } - floatToFixed_arrL(bwe_exc_extended, bwe_exc_extended_fx, 0, L_FRAME32k + NL_BUFF_OFFSET);*/ - //float old_exc[L_EXC_DEC], *exc; /* excitation signal buffer */ Word16 old_exc_fx[L_EXC_DEC], *exc_fx; /* excitation signal buffer */ - //float syn_tmp[L_FRAME16k + L_SUBFR], *syn; /* synthesis signal buffer */ Word16 syn_tmp_fx[L_FRAME16k + L_SUBFR], *psyn_fx; /* synthesis signal buffer */ int16_t output_frame; /* frame length at output sampling freq. */ - //float lsf_new[M]; /* LSFs at the end of the frame */ Word16 lsf_new_fx[M]; /* LSFs at the end of the frame Qlog2(2.56) */ - //float lsp_new[M]; /* LSPs at the end of the frame */ Word16 lsp_new_fx[M]; /* LSPs at the end of the frame Q15 */ - //float lsp_mid[M]; /* LSPs in the middle of the frame */ Word16 lsp_mid_fx[M]; /* LSPs in the middle of the frame */ - //float Aq[NB_SUBFR16k * ( M + 1 )]; /* A(q) quantized for the 4 subframes */ Word16 Aq_fx[NB_SUBFR16k * ( M + 1 )]; /* A(q) quantized for the 4 subframes */ - //float old_exc2[L_FRAME16k + L_EXC_MEM], *exc2; /* total excitation buffer */ Word16 old_exc2_fx[L_FRAME16k + L_EXC_MEM], *exc2_fx; /* total excitation buffer */ - //float mem_tmp[M]; /* temporary synthesis filter memory */ Word16 mem_tmp_fx[M]; /* temporary synthesis filter memory */ - //float enr_q; /* E information for FER protection */ Word32 enr_q_fx; /* E information for FER protection */ - //float tmp_noise; /* Long term temporary noise energy */ Word16 tmp_noise_fx; /* Long term temporary noise energy */ - //float Es_pred; /* predicted scaled innov. energy */ Word16 Es_pred_fx; /* predicted scaled innov. energy Q8 */ - //float FEC_pitch; /* FEC pitch */ Word16 FEC_pitch_fx; /* FEC pitch */ - //float old_bwe_exc[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */ Word16 old_bwe_exc_fx[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */ - //float *bwe_exc; /* Excitation for SWB TBE */ Word16 *bwe_exc_fx; /* Excitation for SWB TBE */ int16_t i, j, int_fs; int16_t tc_subfr; int16_t allow_cn_step; - //float temp_buf[L_FRAME16k + L_SYN_MEM]; Word16 temp_buf_fx[L_FRAME16k + L_SYN_MEM]; int16_t last_pulse_pos; int16_t T0_tmp; int16_t do_WI; - //float dct_buffer[DCT_L_POST]; Word16 dct_buffer_fx[DCT_L_POST]; - //float exc_buffer[DCT_L_POST]; Word16 exc_buffer_fx[DCT_L_POST]; - //float dct_exc_tmp[L_FRAME16k]; Word16 dct_exc_tmp_fx[L_FRAME16k]; - //float bpf_error_signal[L_FRAME16k]; int16_t nb_bits; /* number of bits */ int16_t indice; /* parameter indices to write */ - //float gain_buf[NB_SUBFR16k]; Word16 gain_buf_fx[NB_SUBFR16k]; Word16 syn_fx_tmp2[L_FRAME_16k]; Word16 pitch_buf_tmp[NB_SUBFR16k]; Word16 update_flg; - //float q_env[20]; Word32 q_env_fx[20]; - //float exc3[L_FRAME16k]; Word16 exc3_fx[L_FRAME16k]; - //float syn1_tmp[L_FRAME16k + 2], *syn1; Word16 syn1_tmp_fx[L_FRAME16k + 2], *syn1_fx; - //float *realBuffer[CLDFB_NO_COL_MAX], *imagBuffer[CLDFB_NO_COL_MAX]; -#ifdef IVAS_FLOAT_FIXED Word32 *realBuffer_fx[CLDFB_NO_COL_MAX], *imagBuffer_fx[CLDFB_NO_COL_MAX]; Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word32 imagBufferTmp_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; -#endif // IVAS_FLOAT_FIXED - //float realBufferTmp[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - //float imagBufferTmp[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; int16_t LSF_Q_prediction; /* LSF prediction mode */ Word16 avoid_lpc_burst_on_recovery; - //float tmpF; Word16 tmpF_fx; int16_t uc_two_stage_flag; int16_t tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag; - //float *old_exc_s; /* Start of last excitation frame */ Word16 *old_exc_s_fx; /* Start of last excitation frame */ - //float *p_tdm_Pri_pitch_buf; Word16 *p_tdm_Pri_pitch_buf_fx; int16_t local_element_mode; ivas_error error; @@ -189,75 +149,46 @@ ivas_error acelp_core_dec_ivas_fx( { if ( st->cng_type == FD_CNG ) { - //configureFdCngDec_flt( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode ); configureFdCngDec( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode ); Word16 old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp; /* Only run parameter decoding in SID frames */ if ( st->core_brate == SID_2k40 ) { - //FdCng_decodeSID_flt( st ); FdCng_decodeSID_ivas_fx( st ); - //FdCng_decodeSID(st->hFdCngDec->hFdCngCom, st ); rescale_fdCngDec(st->hFdCngDec, old_NoiseEstExp - st->hFdCngDec->hFdCngCom->sidNoiseEstExp); } for ( i = 0; i < NPART; i++ ) { - //st->hFdCngDec->hFdCngCom->sidNoiseEstLp_flt[i] = STEREO_DFT_FD_FILT * st->hFdCngDec->hFdCngCom->sidNoiseEstLp_flt[i] + ( 1 - STEREO_DFT_FD_FILT ) * st->hFdCngDec->hFdCngCom->sidNoiseEst_flt[i]; st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = L_add( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ), Mpy_32_32( STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] ) ); } -#ifdef IVAS_FLOAT_FIXED - - //for ( int p = 0; p < ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); p++ ) - //{ - //st->hFdCngDec->bandNoiseShape[p] = (Word32) ( st->hFdCngDec->bandNoiseShape_float[p] * ( 1u << ( 31 - st->hFdCngDec->bandNoiseShape_exp ) ) ); - //} - ApplyFdCng_fx( NULL, 0, NULL, 0, NULL, NULL, NULL, st, 0, 0 ); if (st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0) { Scale_sig32(st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp); st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0; } -#else - ApplyFdCng_flt( NULL, NULL, NULL, NULL, st, 0, 0 ); -#endif // IVAS_FLOAT_FIXED } else { - //configureFdCngDec_flt( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode ); configureFdCngDec( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode ); /* decode CNG parameters */ - //CNG_dec( st, last_element_mode, Aq, lsp_new, lsf_new, &allow_cn_step, sid_bw, q_env ); CNG_dec_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx); /* comfort noise generation */ - //CNG_exc( st->core_brate, st->L_frame, &st->hTdCngDec->Enew, &st->hTdCngDec->cng_seed, NULL, NULL, &st->lp_ener, st->last_core_brate, &st->first_CNG, &( st->hTdCngDec->cng_ener_seed ), NULL, allow_cn_step, &st->hTdCngDec->last_allow_cn_step, st->hTdCngDec->num_ho, q_env, st->hTdCngDec->lp_env, st->hTdCngDec->old_env, st->hTdCngDec->exc_mem, st->hTdCngDec->exc_mem1, sid_bw, &st->hTdCngDec->cng_ener_seed1, NULL, st->Opt_AMR_WB, st->element_mode ); CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngDec->Enew_fx, &st->hTdCngDec->cng_seed, NULL, NULL, &st->lp_ener_fx, st->last_core_brate, &st->first_CNG, &( st->hTdCngDec->cng_ener_seed ), NULL, allow_cn_step, &st->hTdCngDec->last_allow_cn_step, st->prev_Q_exc, st->Q_exc, st->hTdCngDec->num_ho, q_env_fx, st->hTdCngDec->lp_env_fx, st->hTdCngDec->old_env_fx, st->hTdCngDec->exc_mem_fx, st->hTdCngDec->exc_mem1_fx, sid_bw, &st->hTdCngDec->cng_ener_seed1, NULL, st->Opt_AMR_WB, st->element_mode ); - //mvr2r( Aq, st->Aq_cng_float, M + 1 ); Copy( Aq_fx, st->Aq_cng, M + 1 ); /* update old LSP and LSF vector */ - /*mvr2r( lsf_new, st->lsf_old, M ); - mvr2r( lsp_new, st->lsp_old, M );*/ Copy( lsf_new_fx, st->lsf_old_fx, M ); Copy( lsp_new_fx, st->lsp_old_fx, M ); - /*Local fix2float (to be removed)*/ - //fixedToFloat_arr(st->Aq_cng, st->Aq_cng_float, Q14 - norm_s(st->Aq_cng[0]), M + 1); - /*fixedToFloat_arr(Aq_fx, Aq, Q12, NB_SUBFR16k * (M + 1)); - fixedToFloat_arr(lsp_new_fx, lsp_new, Q15, M); - for (i = 0; i < M; i++) { - lsf_new[i] = lsf_new_fx[i] / 2.56f; - }*/ } - //set_f( output, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ set_s( output_fx, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ - //set_f( synth, 0, output_frame ); /* They are however read in a few places which causes errors in the valgrind tests. Simplest solution from a code perspective was to set them to zero. */ set_s( synth_fx16, 0, output_frame ); /* They are however read in a few places which causes errors in the valgrind tests. Simplest solution from a code perspective was to set them to zero. */ /* CN generation done in DFT domain */ @@ -271,14 +202,6 @@ ivas_error acelp_core_dec_ivas_fx( *----------------------------------------------------------------*/ /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ - /*for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - set_f( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); - set_f( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); - realBuffer[i] = realBufferTmp[i]; - imagBuffer[i] = imagBufferTmp[i]; - }*/ -#ifdef IVAS_FLOAT_FIXED for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { set32_fx( realBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); @@ -286,17 +209,11 @@ ivas_error acelp_core_dec_ivas_fx( realBuffer_fx[i] = realBufferTmp_fx[i]; imagBuffer_fx[i] = imagBufferTmp_fx[i]; } -#endif // IVAS_FLOAT_FIXED /*----------------------------------------------------------------* * Initialization *----------------------------------------------------------------*/ LSF_Q_prediction = -1; - /*set_f( syn_tmp, 0, L_SUBFR ); - syn = syn_tmp + L_SUBFR; - syn1_tmp[0] = 0; - syn1_tmp[1] = 0; - syn1 = syn1_tmp + 2;*/ set_s(syn_tmp_fx, 0, L_SUBFR); psyn_fx = syn_tmp_fx + L_SUBFR; @@ -332,59 +249,43 @@ ivas_error acelp_core_dec_ivas_fx( if ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && ( st->last_core_brate == SID_2k40 || st->last_core_brate == FRAME_NO_DATA ) ) { - /*set_zero( st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, FFTLEN ); - set_zero( hStereoCng->olapBufferSynth22, FFTLEN );*/ set_s( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, FFTLEN ); set_s( hStereoCng->olapBufferSynth22_fx, 0, FFTLEN ); } st->clas_dec = st->last_good; - //enr_q = 0.0f; - /*Es_pred = 0.0f; - tmp_noise = 0.0f;*/ enr_q_fx = 0; Es_pred_fx = 0; tmp_noise_fx = 0; - //mvr2r( st->old_exc, old_exc, L_EXC_MEM_DEC ); Copy( st->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); - //exc = old_exc + L_EXC_MEM_DEC; exc_fx = old_exc_fx + L_EXC_MEM_DEC; if ( st->hWIDec != NULL ) { - //mvr2r( st->hWIDec->old_exc2, old_exc2, L_EXC_MEM ); Copy( st->hWIDec->old_exc2_fx, old_exc2_fx, L_EXC_MEM ); } else { - //set_f( old_exc2, 0, L_EXC_MEM ); set_s( old_exc2_fx, 0, L_EXC_MEM ); } - //exc2 = old_exc2 + L_EXC_MEM; exc2_fx = old_exc2_fx + L_EXC_MEM; if ( st->hBWE_TD != NULL ) { - //mvr2r( st->hBWE_TD->old_bwe_exc, old_bwe_exc, PIT16k_MAX * 2 ); Copy( st->hBWE_TD->old_bwe_exc_fx, old_bwe_exc_fx, PIT16k_MAX * 2 ); - //bwe_exc = old_bwe_exc + PIT16k_MAX * 2; bwe_exc_fx = old_bwe_exc_fx + PIT16k_MAX * 2; } else { - //bwe_exc = NULL; bwe_exc_fx = NULL; } last_pulse_pos = 0; do_WI = 0; - //st->GSC_noisy_speech = 0; st->GSC_noisy_speech = 0; - //st->relax_prev_lsf_interp = 0; st->relax_prev_lsf_interp = 0; - //set_zero( gain_buf, NB_SUBFR16k ); set_s( gain_buf_fx, 0, NB_SUBFR16k ); if ( st->L_frame == L_FRAME ) @@ -420,7 +321,6 @@ ivas_error acelp_core_dec_ivas_fx( tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag; tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode; tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag; - //p_tdm_Pri_pitch_buf = hStereoTD->tdm_Pri_pitch_buf; p_tdm_Pri_pitch_buf_fx = hStereoTD->tdm_Pri_pitch_buf_fx; } else @@ -432,7 +332,6 @@ ivas_error acelp_core_dec_ivas_fx( tdm_low_rate_mode = 1; } tdm_Pitch_reuse_flag = 0; - //p_tdm_Pri_pitch_buf = NULL; p_tdm_Pri_pitch_buf_fx = NULL; } @@ -447,29 +346,19 @@ ivas_error acelp_core_dec_ivas_fx( if ( st->hPFstat->on != 0 ) { int16_t mem_syn_r_size_old, mem_syn_r_size_new; - - //mem_syn_r_size_old = (int16_t) ( 1.25 * st->last_L_frame / 20.f ); - //mem_syn_r_size_new = (int16_t) ( 1.25 * st->L_frame / 20.f ); mem_syn_r_size_old = mult_r( 2048, st->last_L_frame ); mem_syn_r_size_new = mult_r( 2048, st->L_frame ); - //lerp_flt( st->hPFstat->mem_stp_flt + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp_flt + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); lerp( st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); - //lerp_flt( st->hPFstat->mem_pf_in_flt + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in_flt + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); lerp( st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); } /* convert quantized LSP vector */ - //st->rate_switching_reset = lsp_convert_poly( st->lsp_old, st->L_frame, 0 ); st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 ); /* convert old quantized LSF vector */ - //lsp2lsf( st->lsp_old, st->lsf_old, M, int_fs ); lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, int_fs ); /* FEC - update adaptive LSF mean vector */ - //mvr2r( st->lsf_old, st->lsfoldbfi1, M ); - //mvr2r( st->lsf_old, st->lsfoldbfi0, M ); - //mvr2r( st->lsf_old, st->lsf_adaptive_mean, M ); Copy( st->lsf_old_fx, st->lsfoldbfi1_fx, M ); Copy( st->lsf_old_fx, st->lsfoldbfi0_fx, M ); Copy( st->lsf_old_fx, st->lsf_adaptive_mean_fx, M ); @@ -477,15 +366,12 @@ ivas_error acelp_core_dec_ivas_fx( /* Reset LPC mem */ if ( st->sr_core == INT_FS_16k ) { - //mvr2r( GEWB2_Ave, st->mem_AR, M ); Copy( GEWB2_Ave_fx, st->mem_AR_fx, M ); } else { - //mvr2r( GEWB_Ave, st->mem_AR, M ); Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); } - //set_zero( st->mem_MA, M ); set_s( st->mem_MA_fx, 0, M ); /* update synthesis filter memories */ @@ -494,11 +380,7 @@ ivas_error acelp_core_dec_ivas_fx( { dec = DEC_IVAS; } - //synth_mem_updt2_flt( st->L_frame, st->last_L_frame, st->old_exc, st->mem_syn_r_float, st->mem_syn2, NULL, dec ); synth_mem_updt2( st->L_frame, st->last_L_frame, st->old_exc_fx, st->mem_syn_r, st->mem_syn2_fx, NULL, dec ); - //mvr2r( st->old_exc, old_exc, L_EXC_MEM_DEC ); - //mvr2r( st->mem_syn2, st->mem_syn1, M ); - //mvr2r( st->mem_syn2, st->mem_syn3, M ); Copy( st->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); Copy_Scale_sig(st->mem_syn2_fx, st->mem_syn1_fx, M, sub(-1, st->Q_syn)); /*Q-1*/ Copy( st->mem_syn2_fx, st->mem_syn3_fx, M ); @@ -511,30 +393,25 @@ ivas_error acelp_core_dec_ivas_fx( { IF(EQ_16(st->last_L_frame, L_FRAME32k)) { - //tmpF = (float) 12800 / (float) 32000; tmpF_fx = 13107; } ELSE IF(EQ_16(st->last_L_frame, 512)) { - //tmpF = (float)12800/(float)25600; tmpF_fx = 16384; } ELSE /* st->last_L_frame == L_FRAME16k */ { - //tmpF = (float) 12800 / (float) 16000; tmpF_fx = 26214; } FOR(i = NB_SUBFR16k - NB_SUBFR; i < NB_SUBFR16k; i++) { - //st->old_pitch_buf[i - 1] = tmpF * st->old_pitch_buf[i]; st->old_pitch_buf_fx[i - 1] = Mpy_32_16_1(st->old_pitch_buf_fx[i], tmpF_fx); move32(); } FOR(i = 2 * NB_SUBFR16k - NB_SUBFR; i < 2 * NB_SUBFR16k; i++) { - //st->old_pitch_buf[i - 2] = tmpF * st->old_pitch_buf[i]; st->old_pitch_buf_fx[i - 2] = Mpy_32_16_1(st->old_pitch_buf_fx[i], tmpF_fx); move32(); } @@ -545,38 +422,31 @@ ivas_error acelp_core_dec_ivas_fx( Word16 exp = 0; IF(EQ_16(st->last_L_frame,L_FRAME32k)) { - /* (float)16000/(float)32000; */ tmpF_fx = 16384; } ELSE IF(EQ_16(st->last_L_frame,512)) { - /* tmpF = (float)16000/(float)25600; */ tmpF_fx = 20480; } ELSE /* st->last_L_frame == L_FRAME12k8 */ { - /* tmpF = (float)16000/(float)12800; */ tmpF_fx = 20480; //Q14 exp = 1; } FOR(i = 2 * NB_SUBFR - 1; i >= NB_SUBFR; i--) { - //st->old_pitch_buf[i + 2] = tmpF * st->old_pitch_buf[i]; st->old_pitch_buf_fx[i + 2] = Mpy_32_16_1( L_shl( st->old_pitch_buf_fx[i], exp ), tmpF_fx ); move32(); } - //st->old_pitch_buf[NB_SUBFR + 1] = st->old_pitch_buf[NB_SUBFR + 2]; st->old_pitch_buf_fx[NB_SUBFR + 1] = st->old_pitch_buf_fx[NB_SUBFR + 2]; move32(); FOR(i = NB_SUBFR - 1; i >= 0; i--) { - //st->old_pitch_buf[i + 1] = tmpF * st->old_pitch_buf[i]; st->old_pitch_buf_fx[i + 1] = Mpy_32_16_1( L_shl( st->old_pitch_buf_fx[i], exp ), tmpF_fx ); move32(); } - //st->old_pitch_buf[0] = st->old_pitch_buf[1]; st->old_pitch_buf_fx[0] = st->old_pitch_buf_fx[1]; move32(); } @@ -589,21 +459,16 @@ ivas_error acelp_core_dec_ivas_fx( move16(); IF(EQ_16(st->bfi_pitch_frame, L_FRAME32k)) { - /* (float)12800/(float)32000; */ tmpF_fx = 13107; } ELSE IF(EQ_16(st->bfi_pitch_frame, 512)) { - /* (float)12800/(float)25600; */ tmpF_fx = 16384; } ELSE /* st->bfi_pitch_frame == L_FRAME16k */ { - /* (float)12800/(float)16000; */ tmpF_fx = 26214; } - //st->bfi_pitch *= tmpF; - //st->bfi_pitch_frame = L_FRAME; st->bfi_pitch_fx = mult_r(st->bfi_pitch_fx, tmpF_fx); st->bfi_pitch_frame = L_FRAME; move16(); @@ -614,32 +479,23 @@ ivas_error acelp_core_dec_ivas_fx( Word16 exp = 0; IF(EQ_16(st->bfi_pitch_frame,L_FRAME32k)) { - /* (float)16000/(float)32000; */ tmpF_fx = 16384; } ELSE IF(EQ_16(st->bfi_pitch_frame,512)) { - /* tmpF = (float)16000/(float)25600; */ tmpF_fx = 20480; } ELSE /* st->bfi_pitch_frame == L_FRAME12k8 */ { - /* tmpF = (float)16000/(float)12800; */ tmpF_fx = 20480; //Q14 exp = 1; } - //st->bfi_pitch *= tmpF; - //st->bfi_pitch_frame = L_FRAME16k; st->bfi_pitch_fx = mult_r( shl_sat( st->bfi_pitch_fx, exp ), tmpF_fx ); st->bfi_pitch_frame = L_FRAME16k; move16(); } } - /*Local fix2float (to be removed)*/ - /*fixedToFloat_arr(old_exc_fx, old_exc, st->Q_exc, L_EXC_DEC); - fixedToFloat_arr(gain_buf_fx, gain_buf, Q14, NB_SUBFR16k);*/ - if ( st->last_bwidth == NB && st->bwidth != NB && st->ini_frame != 0 ) { st->rate_switching_reset = 1; @@ -683,15 +539,12 @@ ivas_error acelp_core_dec_ivas_fx( /* decode CNG parameters */ if ( st->cng_type == LP_CNG ) { - //CNG_dec( st, last_element_mode, Aq, lsp_new, lsf_new, &allow_cn_step, sid_bw, q_env ); CNG_dec_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx ); for (int nsf = 0; nsf < NB_SUBFR16k; nsf++) { Scale_sig(Aq_fx + (nsf * (M + 1)), M + 1, norm_s(Aq_fx[nsf * (M + 1)]) - Q2); Aq_fx[nsf * (M + 1)] = ONE_IN_Q12; } Copy( Aq_fx, st->Aq_cng, M + 1 ); - /*Local fix2float (to be removed)*/ - //fixedToFloat_arr(st->Aq_cng, st->Aq_cng_float, Q12, M + 1); /* comfort noise generation */ local_element_mode = st->element_mode; @@ -699,9 +552,7 @@ ivas_error acelp_core_dec_ivas_fx( { local_element_mode = IVAS_SCE; /* For DFT Stereo mono decoding, run CNG_exc as in SCE */ } - //CNG_exc( st->core_brate, st->L_frame, &st->hTdCngDec->Enew, &st->hTdCngDec->cng_seed, exc, exc2, &st->lp_ener, st->last_core_brate, &st->first_CNG, &( st->hTdCngDec->cng_ener_seed ), bwe_exc, allow_cn_step, &st->hTdCngDec->last_allow_cn_step, st->hTdCngDec->num_ho, q_env, st->hTdCngDec->lp_env, st->hTdCngDec->old_env, st->hTdCngDec->exc_mem, st->hTdCngDec->exc_mem1, sid_bw, &st->hTdCngDec->cng_ener_seed1, exc3, st->Opt_AMR_WB, local_element_mode ); CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngDec->Enew_fx, &st->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st->lp_ener_fx, st->last_core_brate, &st->first_CNG, &( st->hTdCngDec->cng_ener_seed ), bwe_exc_fx, allow_cn_step, &st->hTdCngDec->last_allow_cn_step, st->prev_Q_exc, st->Q_exc, st->hTdCngDec->num_ho, q_env_fx, st->hTdCngDec->lp_env_fx, st->hTdCngDec->old_env_fx, st->hTdCngDec->exc_mem_fx, st->hTdCngDec->exc_mem1_fx, sid_bw, &st->hTdCngDec->cng_ener_seed1, exc3_fx, st->Opt_AMR_WB, local_element_mode ); - //mvr2r( Aq, st->Aq_cng_float, M + 1 ); } else @@ -709,12 +560,10 @@ ivas_error acelp_core_dec_ivas_fx( if ( st->core_brate == SID_2k40 && st->element_mode != IVAS_CPE_MDCT ) { - //FdCng_decodeSID_flt( st ); Word16 old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp; FdCng_decodeSID_ivas_fx( st ); rescale_fdCngDec(st->hFdCngDec, old_NoiseEstExp - st->hFdCngDec->hFdCngCom->sidNoiseEstExp); Scale_sig(st->hFdCngDec->hFdCngCom->A_cng, M + 1, norm_s(st->hFdCngDec->hFdCngCom->A_cng[0]) - Q2); - //st->hFdCngDec->hFdCngCom->A_cng[0] = ONE_IN_Q12; *sid_bw = 0; } @@ -724,16 +573,9 @@ ivas_error acelp_core_dec_ivas_fx( for ( i = 0; i < NPART; i++ ) { - //st->hFdCngDec->hFdCngCom->sidNoiseEstLp_flt[i] = STEREO_DFT_FD_FILT * st->hFdCngDec->hFdCngCom->sidNoiseEstLp_flt[i] + ( 1 - STEREO_DFT_FD_FILT ) * st->hFdCngDec->hFdCngCom->sidNoiseEst_flt[i]; st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = L_add( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ), Mpy_32_32( STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] ) ); } -#ifdef IVAS_FLOAT_FIXED - /* local float2fix (to be removed) */ - //for ( int p = 0; p < ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); p++ ) - { - //st->hFdCngDec->bandNoiseShape[p] = (Word32) ( st->hFdCngDec->bandNoiseShape_float[p] * ( 1u << ( 31 - st->hFdCngDec->bandNoiseShape_exp ) ) ); - } Word16 new_sidNoiseEstExp = 31 - Q4; Scale_sig32(st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, st->hFdCngDec->hFdCngCom->sidNoiseEstExp - new_sidNoiseEstExp); Scale_sig32(st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART, st->hFdCngDec->hFdCngCom->sidNoiseEstExp - new_sidNoiseEstExp); @@ -748,17 +590,12 @@ ivas_error acelp_core_dec_ivas_fx( Scale_sig32(st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp); st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0; } -#else - ApplyFdCng_flt( syn, NULL, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); -#endif // IVAS_FLOAT_FIXED } if ( !read_sid_info ) { - //float noise_lvl_highest; Word32 noise_lvl_highest_fx; - //noise_lvl_highest = st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand - 1]; noise_lvl_highest_fx = st->hFdCngDec->hFdCngCom->cngNoiseLevel[st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand - 1]; for ( int16_t b = st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand; b < st->hFdCngDec->hFdCngCom->stopBand; b++ ) { @@ -766,13 +603,10 @@ ivas_error acelp_core_dec_ivas_fx( } } - //generate_comfort_noise_dec_flt( NULL, NULL, st, nchan_out ); generate_comfort_noise_dec(NULL, NULL, NULL, st, &(st->Q_exc), 1, nchan_out); - //FdCng_exc_flt( st->hFdCngDec->hFdCngCom, &st->CNG_mode, st->L_frame, st->lsp_old, st->first_CNG, st->lspCNG, Aq, lsp_new, lsf_new, exc, exc2, bwe_exc ); FdCng_exc(st->hFdCngDec->hFdCngCom, &st->CNG_mode, st->L_frame, st->lsp_old_fx, st->first_CNG, st->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx); - //mvr2r( exc2, exc3, st->L_frame ); Copy( exc2_fx, exc3_fx, st->L_frame ); } @@ -796,46 +630,37 @@ ivas_error acelp_core_dec_ivas_fx( /* update past excitation signals for LD music post-filter */ if ( st->hMusicPF != NULL ) { - //mvr2r( st->hMusicPF->dct_post_old_exc + L_FRAME, st->hMusicPF->dct_post_old_exc, DCT_L_POST - L_FRAME - OFFSET2 ); Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 ); - //mvr2r( exc2, st->hMusicPF->dct_post_old_exc + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME ); Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME ); /* Update music post processing values */ /* Filter energies update */ for ( i = 0; i < DCT_L_POST; i++ ) { - //st->hMusicPF->filt_lfE[i] = 0.3f + 0.7f * st->hMusicPF->filt_lfE[i]; st->hMusicPF->filt_lfE_fx[i] = add( 9830, mult_r( 22937, st->hMusicPF->filt_lfE_fx[i] ) ); } } /* synthesis at 12.8kHz sampling rate */ - //syn_12k8( st->L_frame, Aq, exc2, syn, st->mem_syn2, 1 ); Aq_fx[0] = ONE_IN_Q12; syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn ); - //syn_12k8( st->L_frame, Aq, exc3, syn1, st->mem_syn3, 1 ); syn_12k8_fx( st->L_frame, Aq_fx, exc3_fx, syn1_fx, st->mem_syn3_fx, 1, st->Q_exc, st->Q_syn ); st->Q_syn_cng = st->Q_syn; st->Q_exc_cng = st->Q_exc; /* reset the decoder */ - //CNG_reset_dec( st, pitch_buf, voice_factors ); CNG_reset_dec_fx( st, pitch_buf_fx, voice_factors_fx ); /* update st->mem_syn1 for ACELP core switching */ - //mvr2r( st->mem_syn3, st->mem_syn1, M ); Copy_Scale_sig( st->mem_syn3_fx, st->mem_syn1_fx, M, sub(-1, st->Q_syn)); /* update old synthesis for classification */ - //mvr2r( syn1 + st->L_frame - L_SYN_MEM_CLAS_ESTIM, st->mem_syn_clas_estim, L_SYN_MEM_CLAS_ESTIM ); Copy( syn1_fx + st->L_frame - L_SYN_MEM_CLAS_ESTIM, st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM ); /* save and delay synthesis to be used by SWB BWE */ Copy_Scale_sig(syn1_fx, temp_buf_fx, st->L_frame, sub(-1, st->Q_syn)); if ( st->hBWE_FD != NULL ) { - //save_old_syn( st->L_frame, syn1, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k, st->preemph_fac_float, &st->hBWE_FD->mem_deemph_old_syn ); save_old_syn_fx(st->L_frame, syn1_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx); } @@ -885,9 +710,7 @@ ivas_error acelp_core_dec_ivas_fx( if ( st->hTdCngDec != NULL && ( st->last_core_brate == FRAME_NO_DATA || st->last_core_brate == SID_2k40 ) ) { - //mvr2r( st->lspCNG, st->lsp_old, M ); Copy( st->lspCNG_fx, st->lsp_old_fx, M ); - //lsp2lsf( st->lspCNG, st->lsf_old, M, int_fs ); lsp2lsf_fx( st->lspCNG_fx, st->lsf_old_fx, M, int_fs ); } @@ -897,9 +720,7 @@ ivas_error acelp_core_dec_ivas_fx( if ( !st->use_acelp_preq ) { - //st->mem_preemp_preQ = 0.0f; st->mem_preemp_preQ_fx = 0; - //st->last_nq_preQ = 0; st->last_nq_preQ = 0; st->last_code_preq = 0; } @@ -911,12 +732,10 @@ ivas_error acelp_core_dec_ivas_fx( if ( !tdm_lp_reuse_flag ) { - //lsf_dec( st, tc_subfr, Aq, &LSF_Q_prediction, lsf_new, lsp_new, lsp_mid, tdm_low_rate_mode, tdm_lsfQ_PCh ); lsf_dec_fx( st, tc_subfr, Aq_fx, &LSF_Q_prediction, lsf_new_fx, lsp_new_fx, lsp_mid_fx, tdm_low_rate_mode/*, tdm_lsfQ_PCh*/ ); } else { - //const float *pt_interp_2; const Word16 *pt_interp_2_fx; if ( st->active_cnt != 1 ) @@ -924,48 +743,36 @@ ivas_error acelp_core_dec_ivas_fx( int16_t beta_index; beta_index = get_next_indice( st, TDM_IC_LSF_PRED_BITS ); - //tdm_SCh_lsf_reuse( DEC, st->element_brate, lsf_new, lsp_new, tdm_lsfQ_PCh, NULL, &beta_index ); - //tdm_SCh_lsf_reuse_ivas_fx( DEC, st->element_brate, lsf_new_fx, lsp_new_fx, tdm_lsfQ_PCh_fx, NULL, &beta_index ); tdm_SCh_lsf_reuse_fx(DEC, st->element_brate, lsf_new_fx, lsp_new_fx, tdm_lsfQ_PCh_fx, NULL, &beta_index); } else { - //mvr2r( tdm_lspQ_PCh, lsp_new, M ); Copy( tdm_lspQ_PCh_fx, lsp_new_fx, M ); - //mvr2r( tdm_lspQ_PCh, lsp_new, M ); Copy( tdm_lsfQ_PCh_fx, lsf_new_fx, M ); } if ( st->rate_switching_reset ) { /* extrapolation in case of unstable LSF convert */ - //mvr2r( lsp_new, st->lsp_old, M ); Copy( lsp_new_fx, st->lsp_old_fx, M ); - //mvr2r( lsf_new, st->lsf_old, M ); Copy( lsf_new_fx, st->lsf_old_fx, M ); } - //pt_interp_2 = interpol_frac_12k8; pt_interp_2_fx = interpol_frac_fx; if ( tdm_low_rate_mode == 1 && st->coder_type > UNVOICED ) { - //pt_interp_2 = intercpol_frac2; pt_interp_2_fx = interpol_frac2_fx; } if ( st->active_cnt == 1 ) { - //mvr2r( lsp_new, st->lsp_old, M ); Copy( lsp_new_fx, st->lsp_old_fx, M ); - //lsp2lsf( lsp_new, st->lsf_old, M, st->sr_core ); lsp2lsf_fx( lsp_new_fx, st->lsf_old_fx, M, st->sr_core ); } /* LSP interpolation and conversion of LSPs to A(z) */ - //int_lsp( st->L_frame, st->lsp_old, lsp_new, Aq, M, pt_interp_2, 0 ); int_lsp_fx( st->L_frame, st->lsp_old_fx, lsp_new_fx, Aq_fx, M, pt_interp_2_fx, 0 ); /* Check LSF stability (distance between old LSFs and current LSFs) */ - //st->stab_fac = lsf_stab( lsf_new, st->lsf_old, 0, st->L_frame ); st->stab_fac_fx = lsf_stab_ivas_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame ); } for (int nsf = 0; nsf < NB_SUBFR16k; nsf++) { @@ -975,17 +782,11 @@ ivas_error acelp_core_dec_ivas_fx( if ( st->last_core == HQ_CORE && st->element_mode > EVS_MONO ) { /* Prepare ACB memory from last HQ frame */ - //old_exc_s = st->old_exc + L_EXC_MEM_DEC - st->L_frame; old_exc_s_fx = st->old_exc_fx + L_EXC_MEM_DEC - st->L_frame; - //tmpF = *old_exc_s; tmpF_fx = *old_exc_s_fx; - //st->mem_deemph = old_exc_s_fx[st->L_frame - 1]; st->mem_deemph_fx = old_exc_s_fx[st->L_frame - 1]; - //preemph( old_exc_s, st->preemph_fac_float, L_FRAME16k, &tmpF ); preemph_fx( old_exc_s_fx, st->preemph_fac, L_FRAME16k, &tmpF_fx ); - //mvr2r( old_exc_s + st->L_frame - M, st->mem_syn2, M ); Copy(old_exc_s_fx + st->L_frame - M, st->mem_syn2_fx, M ); - //residu( Aq, M, old_exc_s, old_exc + L_EXC_MEM_DEC - st->L_frame, st->L_frame ); Residu3_fx( Aq_fx, old_exc_s_fx, old_exc_fx + L_EXC_MEM_DEC - st->L_frame, st->L_frame, 0 ); } @@ -994,12 +795,10 @@ ivas_error acelp_core_dec_ivas_fx( /* Prepare ACB memory of old_bwe_exc */ if ( st->L_frame == L_FRAME ) { - //lerp_flt( old_exc, old_bwe_exc, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC ); lerp( old_exc_fx, old_bwe_exc_fx, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC ); } else { - //lerp_flt( old_exc, old_bwe_exc, L_EXC_MEM_DEC * 2, L_EXC_MEM_DEC ); lerp( old_exc_fx, old_bwe_exc_fx, L_EXC_MEM_DEC * 2, L_EXC_MEM_DEC ); } } @@ -1013,19 +812,16 @@ ivas_error acelp_core_dec_ivas_fx( last_pulse_pos = 0; /* decode the last glottal pulse position */ - //T0_tmp = FEC_pos_dec( st, &last_pulse_pos, &enr_q, nb_bits ); T0_tmp = FEC_pos_dec_fx( st, &last_pulse_pos, &enr_q_fx, nb_bits ); if ( st->last_core != HQ_CORE || ( st->last_core == HQ_CORE && st->last_con_tcx ) ) { if ( st->clas_dec == SIN_ONSET && last_pulse_pos != 0 && st->prev_bfi == 1 ) { - //FEC_SinOnset( old_exc + L_EXC_MEM_DEC - L_EXC_MEM, last_pulse_pos, T0_tmp, enr_q, Aq, st->L_frame ); FEC_SinOnset_fx( old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, last_pulse_pos, T0_tmp, enr_q_fx, Aq_fx, st->L_frame, st->Q_exc ); } else if ( ( st->coder_type == GENERIC || st->coder_type == VOICED ) && last_pulse_pos != 0 && st->old_bfi_cnt == 1 && st->hWIDec != NULL ) { - //do_WI = FEC_enhACB( st->L_frame, st->last_L_frame, old_exc + L_EXC_MEM_DEC - L_EXC_MEM, T0_tmp, last_pulse_pos, st->bfi_pitch ); do_WI = FEC_enhACB_fx( st->L_frame, st->last_L_frame, old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, T0_tmp, last_pulse_pos, st->bfi_pitch_fx ); } } @@ -1038,7 +834,6 @@ ivas_error acelp_core_dec_ivas_fx( if ( st->stab_fac_fx == 0 && st->old_bfi_cnt > 0 && st->clas_dec != VOICED_CLAS && st->clas_dec != ONSET && st->relax_prev_lsf_interp == 0 && !( st->element_mode == IVAS_CPE_TD && st->idchan == 1 ) ) { - //int_lsp4( st->L_frame, st->lsp_old, lsp_mid, lsp_new, Aq, M, 2 ); int_lsp4_fx( st->L_frame, st->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 ); } @@ -1049,7 +844,6 @@ ivas_error acelp_core_dec_ivas_fx( if ( nb_bits > 0 ) { indice = get_next_indice( st, nb_bits ); - //Es_pred_dec( &Es_pred, indice, nb_bits, uc_two_stage_flag ); Es_pred_dec_fx( &Es_pred_fx, indice, nb_bits, uc_two_stage_flag ); } @@ -1061,18 +855,15 @@ ivas_error acelp_core_dec_ivas_fx( { if ( st->coder_type <= UNVOICED ) { - //tdm_low_rate_dec( st, dct_exc_tmp, &tmp_noise, pitch_buf, voice_factors, exc, exc2, bwe_exc, lsf_new ); tdm_low_rate_dec_fx( st, dct_exc_tmp_fx/*, &tmp_noise*/, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx ); tmp_noise_fx = shr_r(st->lp_gainc_fx, 3); /*Q0*/ } else /* GENERIC */ { - //decod_gen_2sbfr( st, sharpFlag, Aq, pitch_buf, voice_factors, exc, exc2, bwe_exc, gain_buf, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf ); decod_gen_2sbfr_ivas_fx( st, sharpFlag, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ); if ( st->element_mode == IVAS_CPE_TD ) { - //tmp_noise = st->lp_gainc; tmp_noise_fx = shr_r(st->lp_gainc_fx, 3); /*Q0*/ } } @@ -1084,15 +875,12 @@ ivas_error acelp_core_dec_ivas_fx( st->Q_exc = 0; move16(); /* SC-VBR - NELP frames */ - //decod_nelp( st, &tmp_noise, pitch_buf, exc, exc2, voice_factors, bwe_exc, st->bfi, gain_buf ); decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx); Rescale_exc(st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32)0, &(st->Q_exc), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type); } else if ( st->coder_type == UNVOICED ) { /* UNVOICED frames */ - //decod_unvoiced( st, Aq, Es_pred, uc_two_stage_flag, &tmp_noise, pitch_buf, voice_factors, exc, exc2, bwe_exc, gain_buf ); - //decod_unvoiced_fx( st, Aq_fx, st->coder_type, &tmp_noise_fx, pitch_buf_out_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx); decod_unvoiced_ivas_fx( st, Aq_fx, Es_pred_fx, uc_two_stage_flag, st->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx); tmp_noise_fx = shr_r(st->lp_gainc_fx, 3); /*Q0*/ } @@ -1101,7 +889,6 @@ ivas_error acelp_core_dec_ivas_fx( Scale_sig(exc_fx - L_EXC_MEM, L_EXC_MEM, -st->Q_exc); st->Q_exc = 0; /* SC-VBR - PPP frames */ - //if ( ( error = decod_ppp( st, Aq, pitch_buf, exc, exc2, voice_factors, bwe_exc, gain_buf, st->bfi ) ) != IVAS_ERR_OK ) if ( ( error = decod_ppp_fx( st, Aq_fx, pitch_buf_fx, exc_fx, exc2_fx, st->bfi, gain_buf_fx, voice_factors_fx, bwe_exc_fx ) ) != IVAS_ERR_OK ) { return error; @@ -1112,13 +899,11 @@ ivas_error acelp_core_dec_ivas_fx( } else if ( st->coder_type == TRANSITION ) { - //decod_tran( st, st->L_frame, tc_subfr, Aq, Es_pred, pitch_buf, voice_factors, exc, exc2, bwe_exc, unbits, sharpFlag, gain_buf ); decod_tran_fx( st, st->L_frame, tc_subfr, Aq_fx, Es_pred_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, sharpFlag, gain_buf_fx); } else if ( st->coder_type == AUDIO || ( st->coder_type == INACTIVE && st->inactive_coder_type_flag ) ) { /* AUDIO and INACTIVE frames (coded by GSC technology) */ - //decod_audio( st, dct_exc_tmp, Aq, &tmp_noise, pitch_buf, voice_factors, exc, exc2, bwe_exc, lsf_new, gain_buf, tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf ); decod_audio_ivas_fx( st, dct_exc_tmp_fx, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf_fx #if 1//def ADD_LRTD , tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx @@ -1129,8 +914,6 @@ ivas_error acelp_core_dec_ivas_fx( else { /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */ - //if ( ( error = decod_gen_voic( st, st->L_frame, sharpFlag, Aq, Es_pred, do_WI, pitch_buf, voice_factors, exc, exc2, bwe_exc, unbits, gain_buf, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf ) ) != IVAS_ERR_OK ) - //if ( ( error = decod_gen_voic_fx( st, st->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI, pitch_buf_out_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf_fx/*, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx*/) ) != IVAS_ERR_OK ) if ( ( error = decod_gen_voic_ivas_fx( st, st->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx) ) != IVAS_ERR_OK ) { return error; @@ -1138,20 +921,16 @@ ivas_error acelp_core_dec_ivas_fx( if ( st->element_mode == IVAS_CPE_TD ) { - //tmp_noise = st->lp_gainc; tmp_noise_fx = shr_r(st->lp_gainc_fx, 3); /*Q0*/ } } - //printf("\nnextBitPos: %d ", st->next_bit_pos); /* synthesis for ACELP core switching and SWB BWE */ - //syn_12k8( st->L_frame, Aq, exc, temp_buf, st->mem_syn1, 1 ); syn_12k8_fx( st->L_frame, Aq_fx, exc_fx, temp_buf_fx, st->mem_syn1_fx, 1, st->Q_exc, -1); /* save and delay synthesis to be used by SWB BWE */ if ( st->hBWE_FD != NULL ) { - //save_old_syn( st->L_frame, temp_buf, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k, st->preemph_fac_float, &st->hBWE_FD->mem_deemph_old_syn ); save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); } @@ -1167,7 +946,6 @@ ivas_error acelp_core_dec_ivas_fx( if ( !( st->idchan == 1 && st->element_mode == IVAS_CPE_TD ) && st->nelp_mode_dec != 1 && !( st->element_mode == IVAS_SCE && tdm_low_rate_mode ) ) { - //stat_noise_uv_dec( st, lsp_new, lsp_mid, Aq, exc2, uc_two_stage_flag ); stat_noise_uv_dec_fx(st, lsp_new_fx, lsp_mid_fx, Aq_fx, exc2_fx, uc_two_stage_flag); } @@ -1179,9 +957,6 @@ ivas_error acelp_core_dec_ivas_fx( /* update past excitation signals for LD music post-filter */ if ( st->hMusicPF != NULL ) { - /*mvr2r( st->hMusicPF->dct_post_old_exc + L_FRAME, st->hMusicPF->dct_post_old_exc, DCT_L_POST - L_FRAME - OFFSET2 ); - mvr2r( exc2, st->hMusicPF->dct_post_old_exc + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME ); - mvr2r( st->hMusicPF->dct_post_old_exc, exc_buffer, DCT_L_POST - OFFSET2 );*/ Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 ); Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME ); Copy( st->hMusicPF->dct_post_old_exc_fx, exc_buffer_fx, DCT_L_POST - OFFSET2 ); @@ -1198,17 +973,13 @@ ivas_error acelp_core_dec_ivas_fx( Word16 qdct = 0; /* Extrapolation of the last future part, windowing and high resolution DCT transform */ - //Prep_music_postP( exc_buffer, dct_buffer, st->hMusicPF->filt_lfE, st->last_core, pitch_buf, st->hMusicPF->LDm_enh_lp_gbin ); Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_core, st->element_mode, pitch_buf_fx, st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct); /* LD music post-filter */ - //LD_music_post_filter( st->hMusicPF, dct_buffer, dct_buffer, st->core_brate, AUDIO, last_coder_type ); LD_music_post_filter_fx( st->hMusicPF, dct_buffer_fx, dct_buffer_fx, st->core_brate, &st->hMusicPF->Old_ener_Q, AUDIO, last_coder_type, qdct ); /* Inverse DCT transform, retrieval of the aligned excitation, re-synthesis */ - //mvr2r( st->mem_syn2, mem_tmp, M ); Copy( st->mem_syn2_fx, mem_tmp_fx, M ); - //Post_music_postP( dct_buffer, exc_buffer, exc2, st->mem_syn2, st->mem_syn2, Aq, syn ); Post_music_postP_fx(dct_buffer_fx, exc2_fx, st->mem_syn2_fx, st->mem_syn2_fx, Aq_fx, psyn_fx, &st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn_clas_estim_fx, 0, &st->mem_deemph_fx, st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, temp_buf_fx, mem_tmp_fx); @@ -1237,16 +1008,13 @@ ivas_error acelp_core_dec_ivas_fx( Rescale_mem(st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, 4, &st->mem_deemph_fx, st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, i, k, temp_buf_fx); - //mvr2r( st->mem_syn2, mem_tmp, M ); Copy( st->mem_syn2_fx, mem_tmp_fx, M ); - //syn_12k8( st->L_frame, Aq, exc2, syn, st->mem_syn2, 1 ); syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn); if ( st->hMusicPF != NULL ) { for ( i = 0; i < DCT_L_POST; i++ ) { - //st->hMusicPF->filt_lfE[i] = 0.3f + 0.7f * st->hMusicPF->filt_lfE[i]; st->hMusicPF->filt_lfE_fx[i] = round_fx(L_mac((1228 << (16)), 22938, st->hMusicPF->filt_lfE_fx[i])); } } @@ -1256,7 +1024,6 @@ ivas_error acelp_core_dec_ivas_fx( * FEC - Estimate the classification information *------------------------------------------------------------*/ - //FEC_clas_estim( syn, pitch_buf, st->L_frame, st->coder_type, st->codec_mode, st->mem_syn_clas_estim, &st->clas_dec, &st->lp_ener_bfi, st->Opt_AMR_WB, &st->decision_hyst, NULL, NULL, NULL, NULL, NULL, NULL, temp_buf, 0, 0, 0, 0, 0, 0, st->last_core_brate, st->acelp_cfg.FEC_mode ); FEC_clas_estim_fx(st, st->Opt_AMR_WB, st->L_frame, &st->clas_dec, st->coder_type, pitch_buf_fx, psyn_fx, &st->lp_ener_FER_fx, &st->decision_hyst, NULL, NULL, NULL, NULL, 0, NULL, st->core_brate, st->Q_syn, temp_buf_fx, @@ -1266,7 +1033,6 @@ ivas_error acelp_core_dec_ivas_fx( * FEC - Estimate pitch *------------------------------------------------------------*/ - //FEC_pitch_estim( st->Opt_AMR_WB, st->last_core, st->L_frame, st->clas_dec, st->last_good, pitch_buf, st->old_pitch_buf, &st->bfi_pitch, &st->bfi_pitch_frame, &st->upd_cnt, st->coder_type ); FEC_pitch_estim_fx(st->Opt_AMR_WB, st->last_core, st->L_frame, st->clas_dec, st->last_good, pitch_buf_fx, st->old_pitch_buf_fx, &st->bfi_pitch_fx, &st->bfi_pitch_frame, &st->upd_cnt, st->coder_type, st->element_mode); @@ -1277,7 +1043,6 @@ ivas_error acelp_core_dec_ivas_fx( move16(); Copy_Scale_sig(pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k, -Q6); - //FEC_scale_syn( st->L_frame, st->clas_dec, st->last_good, syn, pitch_buf, st->enr_old, enr_q, st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av_float, &st->lp_ener_FEC_max_float, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, exc, exc2, Aq, &st->old_enr_LP_float, mem_tmp, st->mem_syn2, st->last_con_tcx && ( st->L_frameTCX_past != st->L_frame ) && ( st->last_core != ACELP_CORE ), 0 ); FEC_scale_syn_fx(st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0); @@ -1285,16 +1050,10 @@ ivas_error acelp_core_dec_ivas_fx( /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */ if ( ( st->idchan == 1 && st->element_mode == IVAS_CPE_TD && st->total_brate <= ACELP_7k20 ) || ( st->total_brate == ACELP_7k20 ) || ( st->total_brate == ACELP_8k00 ) ) { - //fer_energy( st->L_frame, st->clas_dec, syn, pitch_buf[( ( st->L_frame ) >> 6 ) - 1], &st->enr_old, st->L_frame ); frame_ener_fx(st->L_frame, st->clas_dec, psyn_fx, pitch_buf_tmp[sub(shr(st->L_frame, 6), 1)], &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0); } } - //printf("\n%f ",st->hBWE_FD->mem_deemph_old_syn); - /*printf("\n"); - for (int nm = 0; nm < NS2SA(16000, DELAY_FD_BWE_ENC_NS); nm++) { - printf("%f ", st->hBWE_FD->old_syn_12k8_16k[nm]); - }*/ } /* End of GOOD FRAME */ /*----------------------------------------------------------------* @@ -1318,10 +1077,8 @@ ivas_error acelp_core_dec_ivas_fx( } /* LSF estimation and A(z) calculation */ - //lsf_dec_bfi_flt( MODE1, lsf_new, st->lsf_old, st->lsf_adaptive_mean, NULL, st->mem_MA, st->mem_AR, st->stab_fac, st->last_coder_type, st->L_frame, st->last_good, st->nbLostCmpt, 0, NULL, NULL, NULL, st->hGSCDec->Last_GSC_pit_band_idx, st->Opt_AMR_WB, st->bwidth ); lsf_dec_bfi(MODE1, lsf_new_fx, st->lsf_old_fx, st->lsf_adaptive_mean_fx, NULL, st->mem_MA_fx, st->mem_AR_fx, st->stab_fac_fx, st->last_coder_type, st->L_frame, st->last_good, st->nbLostCmpt, 0, NULL, NULL, NULL, st->hGSCDec->Last_GSC_pit_band_idx, st->Opt_AMR_WB, 0, st->bwidth); - //FEC_lsf2lsp_interp_flt( st, st->L_frame, Aq, lsf_new, lsp_new ); FEC_lsf2lsp_interp(st, st->L_frame, Aq_fx, lsf_new_fx, lsp_new_fx); for (int nsf = 0; nsf < NB_SUBFR16k; nsf++) { Scale_sig(Aq_fx + (nsf * (M + 1)), M + 1, norm_s(Aq_fx[nsf * (M + 1)]) - Q2); @@ -1334,7 +1091,6 @@ ivas_error acelp_core_dec_ivas_fx( st->Q_exc = 0; move16(); - //decod_nelp( st, &tmp_noise, pitch_buf, exc, exc2, voice_factors, bwe_exc, st->bfi, gain_buf ); decod_nelp_fx(st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx); FEC_pitch_fx = pitch_buf_fx[3]; @@ -1343,28 +1099,23 @@ ivas_error acelp_core_dec_ivas_fx( else { /* calculation of excitation signal */ - //FEC_exc_estim( st, st->L_frame, exc, exc2, dct_exc_tmp, pitch_buf, voice_factors, &FEC_pitch, bwe_exc, lsf_new, &tmp_noise ); FEC_exc_estim_fx(st, st->L_frame, exc_fx, exc2_fx, dct_exc_tmp_fx, pitch_buf_fx, voice_factors_fx, &FEC_pitch_fx, bwe_exc_fx, lsf_new_fx, &st->Q_exc, &tmp_noise_fx); Rescale_exc(NULL, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, L_FRAME32k, (Word32)0, &(st->Q_exc), st->Q_subfr, exc2_fx, st->L_frame, st->last_coder_type); - //tmp_noise = st->lp_gainc; tmp_noise_fx = shr_r(st->lp_gainc_fx, 3); /*Q0*/ /* SC-VBR */ - //st->prev_gain_pit_dec = st->lp_gainp; st->prev_gain_pit_dec_fx = st->lp_gainp_fx; } /* synthesis for ACELP core switching and SWB BWE */ - //syn_12k8( st->L_frame, Aq, exc, temp_buf, st->mem_syn1, 1 ); syn_12k8_fx(st->L_frame, Aq_fx, exc_fx, temp_buf_fx, st->mem_syn1_fx, 1, st->Q_exc, -1); /* save and delay synthesis to be used by SWB BWE */ if ( st->hBWE_FD != NULL ) { - //save_old_syn( st->L_frame, temp_buf, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k, st->preemph_fac_float, &st->hBWE_FD->mem_deemph_old_syn ); save_old_syn_fx(st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx); } @@ -1374,22 +1125,18 @@ ivas_error acelp_core_dec_ivas_fx( /* update past excitation signals for LD music post-filter */ if ( st->hMusicPF != NULL ) { - //mvr2r( st->hMusicPF->dct_post_old_exc + L_FRAME, st->hMusicPF->dct_post_old_exc, DCT_L_POST - L_FRAME - OFFSET2 ); Copy(st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2); - //mvr2r( exc2, st->hMusicPF->dct_post_old_exc + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME ); Copy(exc2_fx, st->hMusicPF->dct_post_old_exc_fx + (DCT_L_POST - L_FRAME - OFFSET2), L_FRAME); /* Update music post processing values */ /* Filter energies update */ for ( i = 0; i < DCT_L_POST; i++ ) { - //st->hMusicPF->filt_lfE[i] = 0.3f + 0.7f * st->hMusicPF->filt_lfE[i]; st->hMusicPF->filt_lfE_fx[i] = round_fx(L_mac((1228 << (16)), 22938, st->hMusicPF->filt_lfE_fx[i])); } /* Update circular buffer, keep last energy difference unchanged */ for ( i = 1; i < MAX_LT; i++ ) { - //st->hMusicPF->LDm_lt_diff_etot[i - 1] = st->hMusicPF->LDm_lt_diff_etot[i]; st->hMusicPF->LDm_lt_diff_etot_fx[i - 1] = st->hMusicPF->LDm_lt_diff_etot_fx[i]; } } @@ -1411,24 +1158,19 @@ ivas_error acelp_core_dec_ivas_fx( if ( ( st->total_brate == ACELP_7k20 ) || ( st->total_brate == ACELP_8k00 ) ) { - //mvr2r( st->mem_syn2, mem_tmp, M ); Copy(st->mem_syn2_fx, mem_tmp_fx, M); } - //syn_12k8( st->L_frame, Aq, exc2, syn, st->mem_syn2, 1 ); syn_12k8_fx(st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn); /* update buffer for classifier */ if ( st->hWIDec != NULL ) { - //mvr2r( exc2 + st->L_frame - L_EXC_MEM, st->hWIDec->old_exc2, L_EXC_MEM ); Copy(exc2_fx + st->L_frame - L_EXC_MEM, st->hWIDec->old_exc2_fx, L_EXC_MEM); - //mvr2r( syn + st->L_frame - L_EXC_MEM, st->hWIDec->old_syn2, L_EXC_MEM ); Copy(psyn_fx + st->L_frame - L_EXC_MEM, st->hWIDec->old_syn2_fx, L_EXC_MEM); } st->prev_Q_exc_fr = st->Q_exc; st->prev_Q_syn_fr = st->Q_syn; - //mvr2r( syn + st->L_frame - L_SYN_MEM_CLAS_ESTIM, st->mem_syn_clas_estim, L_SYN_MEM_CLAS_ESTIM ); Copy(psyn_fx + st->L_frame - L_SYN_MEM_CLAS_ESTIM, st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM); /*------------------------------------------------------------* @@ -1440,59 +1182,38 @@ ivas_error acelp_core_dec_ivas_fx( { Copy_Scale_sig(pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k, -Q6); - //FEC_scale_syn( st->L_frame, st->clas_dec, st->last_good, syn, pitch_buf, st->enr_old, enr_q, st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av_float, &st->lp_ener_FEC_max_float, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, exc, exc2, Aq, &st->old_enr_LP_float, mem_tmp, st->mem_syn2, st->last_con_tcx && ( st->L_frameTCX_past != st->L_frame ) && ( st->last_core != ACELP_CORE ), 0 ); FEC_scale_syn_fx(st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0); } /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */ - //fer_energy( st->L_frame, st->last_good, syn, FEC_pitch, &st->enr_old, st->L_frame ); frame_ener_fx(st->L_frame, st->last_good, psyn_fx, shr(add(FEC_pitch_fx, 32), 6), &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0); if ( st->nelp_mode_dec != 1 ) { /* modify the excitation signal of stationary unvoiced frames */ - //stat_noise_uv_mod( st->coder_type, 0, st->lsp_old, lsp_new, lsp_new, Aq, exc2, 1, &st->ge_sm, &st->uv_count, &st->act_count, st->lspold_s, &st->noimix_seed, &st->min_alpha, &st->exc_pe, st->core_brate, st->bwidth ); stat_noise_uv_mod_fx(st->coder_type, 0, st->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, st->Q_exc, 1, &st->ge_sm_fx, &st->uv_count, &st->act_count, st->lspold_s_fx, &st->noimix_seed, &st->min_alpha_fx, &st->exc_pe_fx, st->core_brate, st->bwidth, &st->Q_stat_noise, &st->Q_stat_noise_ge); } } -#ifdef IVAS_FLOAT_FIXED - //floatToFixed_arr(Aq, Aq_fx, Q12, NB_SUBFR16k * (M + 1)); IF(st->hBWE_TD != NULL) { IF(EQ_16(st->L_frame, L_FRAME)) { - //Copy_Scale_sig(Aq_fx + 2 * (M + 1), st->hBWE_TD->cur_sub_Aq_fx, norm_s((Aq_fx + 2 * (M + 1))[0]) - Q2,(M + 1)); Copy( Aq_fx + 2 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); } ELSE { - //Copy_Scale_sig( Aq_fx + 3 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, norm_s( (Aq_fx + 3 * (M + 1))[0] ) - Q2, ( M + 1 ) ); Copy( Aq_fx + 3 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); } } -#else - if (st->hBWE_TD != NULL) - { - if (st->L_frame == L_FRAME) - { - mvr2r(Aq + 2 * (M + 1), st->hBWE_TD->cur_sub_Aq, (M + 1)); - } - else - { - mvr2r(Aq + 3 * (M + 1), st->hBWE_TD->cur_sub_Aq, (M + 1)); - } - } -#endif /*--------------------------------------------------------* * Apply NB postfilter in case of 8kHz output *--------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED test(); IF(EQ_16(st->last_bwidth, NB) && st->hPFstat != NULL) { @@ -1500,183 +1221,70 @@ ivas_error acelp_core_dec_ivas_fx( IF(EQ_16(st->bwidth, NB)) { st->hPFstat->on = 1; -#ifdef IVAS_FLOAT_FIXED move16(); - nb_post_filt(st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, st->coder_type, st->BER_detect, 0); - -#else - nb_post_filt_ivas(st->L_frame, L_SUBFR, st->hPFstat, &st->psf_lp_noise, tmp_noise, syn, Aq, pitch_buf, st->coder_type, st->BER_detect, 0); -#endif + nb_post_filt_fx(st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, st->coder_type, st->BER_detect, 0); } ELSE { st->hPFstat->on = 0; -#ifdef IVAS_FLOAT_FIXED - nb_post_filt(st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, AUDIO, st->BER_detect, 0); - -#else - nb_post_filt_ivas(st->L_frame, L_SUBFR, st->hPFstat, &st->psf_lp_noise, tmp_noise, syn, Aq, pitch_buf, AUDIO, st->BER_detect, 0); -#endif + nb_post_filt_fx(st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, AUDIO, st->BER_detect, 0); } } else { -#ifdef IVAS_FLOAT_FIXED st->psf_lp_noise_fx = round_fx(L_shl(st->lp_noise, 1)); - -#else - st->psf_lp_noise = st->lp_noise_float; -#endif - } -#else - if (st->last_bwidth == NB && st->hPFstat != NULL) - { - if (st->bwidth == NB) - { - st->hPFstat->on = 1; - nb_post_filt_ivas(st->L_frame, L_SUBFR, st->hPFstat, &st->psf_lp_noise, tmp_noise, syn, Aq, pitch_buf, st->coder_type, st->BER_detect, 0); - } - else - { - st->hPFstat->on = 0; - nb_post_filt_ivas(st->L_frame, L_SUBFR, st->hPFstat, &st->psf_lp_noise, tmp_noise, syn, Aq, pitch_buf, AUDIO, st->BER_detect, 0); - } } - else - { - st->psf_lp_noise = st->lp_noise_float; - } -#endif /*------------------------------------------------------------------* * Perform fixed deemphasis through 1/(1 - g*z^-1) *-----------------------------------------------------------------*/ /* update old synthesis buffer - needed for ACELP internal sampling rate switching */ -#ifdef IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED Copy(psyn_fx + st->L_frame - L_SYN_MEM, st->mem_syn_r, L_SYN_MEM); -#else - mvr2r(syn + st->L_frame - L_SYN_MEM, st->mem_syn_r_float, L_SYN_MEM); -#endif - -#ifdef IVAS_FLOAT_FIXED deemph_fx(psyn_fx, st->preemph_fac, st->L_frame, &(st->mem_deemph_fx)); - #else - deemph(syn, st->preemph_fac_float, st->L_frame, &(st->mem_deemph)); -#endif -#ifdef IVAS_FLOAT_FIXED unscale_AGC(psyn_fx, st->Q_syn, syn_fx_tmp2, st->agc_mem_fx, st->L_frame); Copy(syn_fx_tmp2, psyn_fx, st->L_frame); -#else - AGC_dec(syn, st->agc_mem2, st->L_frame); -#endif - -#ifdef IVAS_FLOAT_FIXED - //floatToFixed_arr(syn, psyn_fx, st->Q_syn, L_FRAME16k); - IF(st->hTcxDec != NULL) { Copy_Scale_sig(psyn_fx + st->L_frame / 2, st->hTcxDec->old_syn_Overl, st->L_frame / 2, sub(-1, st->Q_syn)); /*Q-1*/ - //fixedToFloat_arr(st->hTcxDec->old_syn_Overl, st->hTcxDec->old_syn_Overl_float, st->Q_syn - 1, st->L_frame / 2); } Copy_Scale_sig(psyn_fx + st->L_frame - M - 1, st->syn, M + 1, sub(0, st->Q_syn)); /*Q0*/ - //fixedToFloat_arr(st->syn, st->syn_float, st->Q_syn, M + 1); -#else - if (st->hTcxDec != NULL) - { - mvr2r(syn + st->L_frame / 2, st->hTcxDec->old_syn_Overl_float, st->L_frame / 2); - } - mvr2r(syn + st->L_frame - M - 1, st->syn_float, M + 1); -#endif -#else - mvr2r(syn + st->L_frame - L_SYN_MEM, st->mem_syn_r_float, L_SYN_MEM); - deemph(syn, st->preemph_fac_float, st->L_frame, &(st->mem_deemph)); - - AGC_dec(syn, st->agc_mem2, st->L_frame); - - if (st->hTcxDec != NULL) - { - mvr2r(syn + st->L_frame / 2, st->hTcxDec->old_syn_Overl_float, st->L_frame / 2); - } - mvr2r(syn + st->L_frame - M - 1, st->syn_float, M + 1); -#endif /*------------------------------------------------------------------* * Formant post-filter *-----------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED - //Word16 temp_buf_fx[L_FRAME16k + L_SYN_MEM]; + test(); test(); test(); + IF(st->hPFstat != NULL && GE_16(st->last_bwidth, WB) && (GT_32(st->core_brate, ACELP_24k40) || GT_16(st->element_mode, EVS_MONO)) && LE_32(st->core_brate, ACELP_32k)) { st->hPFstat->on = 1; -#ifdef IVAS_FLOAT_FIXED /*----ftf conversions---*/ - //floatToFixed_arr(syn, psyn_fx, st->Q_syn, st->L_frame); Copy(psyn_fx, temp_buf_fx + L_SYN_MEM, L_FRAME16k); set16_fx(st->hPFstat->mem_zero, 0, M); - formant_post_filt_fx(st->hPFstat, temp_buf_fx + L_SYN_MEM, Aq_fx, psyn_fx, st->L_frame, st->lp_noise, st->total_brate, 0); + formant_post_filt_ivas_fx(st->hPFstat, temp_buf_fx + L_SYN_MEM, Aq_fx, psyn_fx, st->L_frame, st->lp_noise, st->total_brate, 0); -#else - mvr2r(syn, temp_buf + L_SYN_MEM, L_FRAME16k); - formant_post_filt_ivas(st->hPFstat, temp_buf + L_SYN_MEM, Aq, syn, st->L_frame, L_SUBFR, st->lp_noise_float, st->total_brate, 0); -#endif } ELSE IF(st->hPFstat != NULL && GE_16(st->last_bwidth, WB)) { IF(st->hPFstat->on) { -#ifdef IVAS_FLOAT_FIXED Copy(st->hPFstat->mem_pf_in + L_SYN_MEM - M, temp_buf_fx, M); Copy(psyn_fx, temp_buf_fx + M, L_SUBFR); Residu3_fx(Aq_fx, temp_buf_fx + M, temp_buf_fx + M + L_SUBFR, L_SUBFR, 1); E_UTIL_synthesis(1, Aq_fx, temp_buf_fx + M + L_SUBFR, temp_buf_fx, L_SUBFR, st->hPFstat->mem_stp + L_SYN_MEM - M, 0, M); - scale_st(psyn_fx, temp_buf_fx, &st->hPFstat->gain_prec, L_SUBFR); + scale_st_fx(psyn_fx, temp_buf_fx, &st->hPFstat->gain_prec, L_SUBFR); Copy(temp_buf_fx, psyn_fx, L_SUBFR / 2); - blend_subfr2(temp_buf_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2); - -#else - mvr2r(st->hPFstat->mem_pf_in_flt + L_SYN_MEM - M, temp_buf, M); - mvr2r(syn, temp_buf + M, L_SUBFR); - residu(Aq, M, temp_buf + M, temp_buf + M + L_SUBFR, L_SUBFR); - syn_filt(Aq, M, temp_buf + M + L_SUBFR, temp_buf, L_SUBFR, st->hPFstat->mem_stp_flt + L_SYN_MEM - M, 0); - scale_st_ivas(syn, temp_buf, &st->hPFstat->gain_prec_flt, L_SUBFR, -1); - mvr2r(temp_buf, syn, L_SUBFR / 2); - blend_subfr2_flt(temp_buf + L_SUBFR / 2, syn + L_SUBFR / 2, syn + L_SUBFR / 2); -#endif - } - st->hPFstat->on = 0; - } -#else - if (st->hPFstat != NULL && st->last_bwidth >= WB && (st->core_brate > ACELP_24k40 || st->element_mode > EVS_MONO) && st->core_brate <= ACELP_32k) - { - mvr2r(syn, temp_buf + L_SYN_MEM, L_FRAME16k); - - st->hPFstat->on = 1; - formant_post_filt_ivas(st->hPFstat, temp_buf + L_SYN_MEM, Aq, syn, st->L_frame, L_SUBFR, st->lp_noise_float, st->total_brate, 0); - } - else if (st->hPFstat != NULL && st->last_bwidth >= WB) - { - if (st->hPFstat->on) - { - mvr2r(st->hPFstat->mem_pf_in_flt + L_SYN_MEM - M, temp_buf, M); - mvr2r(syn, temp_buf + M, L_SUBFR); - residu(Aq, M, temp_buf + M, temp_buf + M + L_SUBFR, L_SUBFR); - syn_filt(Aq, M, temp_buf + M + L_SUBFR, temp_buf, L_SUBFR, st->hPFstat->mem_stp_flt + L_SYN_MEM - M, 0); - scale_st_ivas(syn, temp_buf, &st->hPFstat->gain_prec_flt, L_SUBFR, -1); - mvr2r(temp_buf, syn, L_SUBFR / 2); - blend_subfr2_flt(temp_buf + L_SUBFR / 2, syn + L_SUBFR / 2, syn + L_SUBFR / 2); + blend_subfr2_fx(temp_buf_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2); } st->hPFstat->on = 0; } -#endif /*----------------------------------------------------------------* * Comfort noise addition @@ -1692,19 +1300,15 @@ ivas_error acelp_core_dec_ivas_fx( if (st->idchan == 0 && (st->flag_cna || (st->cng_type == FD_CNG && st->total_brate <= ACELP_32k) || (st->cng_type == LP_CNG && st->core_brate <= SID_2k40))) { /*Noisy speech detector*/ - //noisy_speech_detection_flt(st->hFdCngDec, st->VAD, syn); noisy_speech_detection(st->hFdCngDec, st->VAD, psyn_fx, st->Q_syn); - //st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt = 0.99f * st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt + 0.01f * (float)st->hFdCngDec->hFdCngCom->flag_noisy_speech; st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = mult_r(st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 32440/*0.99 Q15*/); IF(st->hFdCngDec->hFdCngCom->flag_noisy_speech != 0) { st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = add(st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 328/*0.01 Q15*/); move16(); } -#ifdef IVAS_FLOAT_FIXED st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx = L_deposit_h(st->hFdCngDec->hFdCngCom->likelihood_noisy_speech); -#endif } if (st->idchan == 0) @@ -1716,7 +1320,6 @@ ivas_error acelp_core_dec_ivas_fx( if (st->element_mode != IVAS_CPE_TD && !st->cng_ism_flag) { /*Noise estimate*/ -#ifdef IVAS_FLOAT_FIXED Scale_sig32(st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp - Q27); st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 31 - Q4; // Q4 @@ -1725,7 +1328,6 @@ ivas_error acelp_core_dec_ivas_fx( Scale_sig32(st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, st->hFdCngDec->hFdCngCom->sidNoiseEstExp - Q27); st->hFdCngDec->hFdCngCom->sidNoiseEstExp = 31 - Q4; // Q4 /*==========================================================*/ - //ApplyFdCng_fx( syn_fx + L_SUBFR, st->Q_syn, NULL, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); ApplyFdCng_fx(psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, (st->coder_type == AUDIO && !st->GSC_noisy_speech)); /*==========================================================*/ if (st->hFdCngDec->partNoiseShape_exp < 0) { @@ -1737,9 +1339,6 @@ ivas_error acelp_core_dec_ivas_fx( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0; } -#else - ApplyFdCng_flt(syn, NULL, realBuffer, imagBuffer, st, 0, (st->coder_type == AUDIO && !st->GSC_noisy_speech)); -#endif // IVAS_FLOAT_FIXED } if (!st->cna_dirac_flag) @@ -1751,11 +1350,7 @@ ivas_error acelp_core_dec_ivas_fx( { if (hStereoCng->flag_cna_fade) { -#ifndef IVAS_FLOAT_FIXED - generate_stereo_masking_noise(syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out); -#else generate_stereo_masking_noise_16fx(psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out); -#endif hStereoCng->flag_cna_fade = 0; } else @@ -1763,15 +1358,10 @@ ivas_error acelp_core_dec_ivas_fx( if (st->element_mode != last_element_mode && st->idchan == 0) { /* Clear memory for secondary channel CNA */ - //set_f(hStereoCng->olapBufferSynth22, 0.0f, st->hFdCngDec->hFdCngCom->frameSize / 2); set_s(hStereoCng->olapBufferSynth22_fx, 0, st->hFdCngDec->hFdCngCom->frameSize / 2); } -#ifndef IVAS_FLOAT_FIXED - generate_stereo_masking_noise(syn, st, hStereoTD, flag_sec_CNA, 0, hStereoCng, nchan_out); -#else generate_stereo_masking_noise_16fx(psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 0, hStereoCng, nchan_out); -#endif } } else if (st->element_mode != IVAS_CPE_DFT) @@ -1780,10 +1370,8 @@ ivas_error acelp_core_dec_ivas_fx( { if (st->element_mode != last_element_mode) { - //set_f(st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, 0.0f, st->hFdCngDec->hFdCngCom->fftlen); set_s(st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen); } - //generate_masking_noise_flt(syn, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0, 0, 0, st->element_mode, hStereoCng, nchan_out); generate_masking_noise(psyn_fx, st->Q_syn, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0/*, 0, 0, st->element_mode, hStereoCng, nchan_out*/); } } @@ -1792,17 +1380,11 @@ ivas_error acelp_core_dec_ivas_fx( { if (st->element_mode == IVAS_CPE_TD && nchan_out == 2) { -#ifndef IVAS_FLOAT_FIXED - generate_stereo_masking_noise(syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out); -#else generate_stereo_masking_noise_16fx(psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out); -#endif hStereoCng->flag_cna_fade = 1; } else { - //v_multc(st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt + 5 * st->hFdCngDec->hFdCngCom->frameSize / 4, (float)(st->hFdCngDec->hFdCngCom->fftlen / 2), temp_buf, st->hFdCngDec->hFdCngCom->frameSize / 2); - //v_add(temp_buf, syn, syn, st->hFdCngDec->hFdCngCom->frameSize / 2); FOR(i = 0; i < st->hFdCngDec->hFdCngCom->frameSize / 2; i++) { psyn_fx[i] = add(psyn_fx[i], shr_r(mult_r(st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st->hFdCngDec->hFdCngCom->frameSize / 4], st->hFdCngDec->hFdCngCom->fftlenFac), -st->Q_syn)); @@ -1824,7 +1406,6 @@ ivas_error acelp_core_dec_ivas_fx( /*Noise estimate*/ if (st->idchan == 0 && (nchan_out == 2 || (st->core_brate != FRAME_NO_DATA && st->core_brate != SID_2k40))) { -#ifdef IVAS_FLOAT_FIXED ApplyFdCng_fx(psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, (st->coder_type == AUDIO && !st->GSC_noisy_speech)); if (st->hFdCngDec->partNoiseShape_exp < 0) { Scale_sig32(st->hFdCngDec->partNoiseShape, NPART, -st->hFdCngDec->partNoiseShape_exp); @@ -1838,10 +1419,6 @@ ivas_error acelp_core_dec_ivas_fx( Scale_sig32(st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp); st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0; } - -#else - ApplyFdCng_flt(syn, NULL, realBuffer, imagBuffer, st, 0, (st->coder_type == AUDIO && !st->GSC_noisy_speech)); -#endif // IVAS_FLOAT_FIXED } } } @@ -1851,8 +1428,6 @@ ivas_error acelp_core_dec_ivas_fx( { if (st->flag_cna == 0 && st->L_frame == L_FRAME16k && st->last_flag_cna == 1 && ((st->last_core == ACELP_CORE && !(st->last_coder_type == AUDIO && !(st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag))) || st->last_core == AMR_WB_CORE)) { - //v_multc(st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt + 5 * st->L_frame / 4, 256.f, temp_buf, st->L_frame / 2); - //v_add(temp_buf, syn, syn, st->L_frame / 2); FOR(i = 0; i < st->hFdCngDec->hFdCngCom->frameSize / 2; i++) { psyn_fx[i] = add(psyn_fx[i], shr_r(mult_r(st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st->hFdCngDec->hFdCngCom->frameSize / 4], st->hFdCngDec->hFdCngCom->fftlenFac), -st->Q_syn)); @@ -1864,12 +1439,10 @@ ivas_error acelp_core_dec_ivas_fx( { if (st->idchan == 0) { - //set_f(st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, 0.f, st->hFdCngDec->hFdCngCom->fftlen); set_s(st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen); } if (hStereoCng != NULL && st->idchan == 0) { - //set_f(hStereoCng->olapBufferSynth22, 0.f, st->hFdCngDec->hFdCngCom->fftlen); set_s(hStereoCng->olapBufferSynth22_fx, 0, st->hFdCngDec->hFdCngCom->fftlen); } } @@ -1884,30 +1457,9 @@ ivas_error acelp_core_dec_ivas_fx( /* check if the CLDFB works on the right sample rate */ if ((st->cldfbAna->no_channels * st->cldfbAna->no_col) != st->L_frame) { -#ifdef IVAS_FLOAT_FIXED - /*Word16 old_len_ana, old_len_bpf; - Word16 new_len;*/ - - // The following lines are to calculate the length of the buffers before and - // after calling the function for fixed pt conversion. The calculations are taken - // based on the logic used in resampleCldfb_ivas_fx - //old_len_ana = st->cldfbAna->p_filter_length - st->cldfbAna->no_channels; - //old_len_bpf = st->cldfbBPF->p_filter_length - st->cldfbBPF->no_channels; - //new_len = 9 * (int16_t)(st->L_frame * FRAMES_PER_SEC * INV_CLDFB_BANDWIDTH + 0.5f); - - //floatToFixed_arrL(st->cldfbAna->cldfb_state, st->cldfbAna->cldfb_state_fx, Q11, old_len_ana); - //floatToFixed_arrL(st->cldfbBPF->cldfb_state, st->cldfbBPF->cldfb_state_fx, Q10, old_len_bpf); - resampleCldfb_ivas_fx(st->cldfbAna, st->L_frame * FRAMES_PER_SEC); resampleCldfb_ivas_fx(st->cldfbBPF, st->L_frame * FRAMES_PER_SEC); - /*fixedToFloat_arrL(st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_state, Q11, new_len); - fixedToFloat_arrL(st->cldfbBPF->cldfb_state_fx, st->cldfbBPF->cldfb_state, Q10, new_len);*/ -#else - resampleCldfb_ivas(st->cldfbAna, st->L_frame * FRAMES_PER_SEC); - resampleCldfb_ivas(st->cldfbBPF, st->L_frame * FRAMES_PER_SEC); -#endif - if (st->ini_frame > 0) { st->cldfbSyn->bandsToZero = st->cldfbSyn->no_channels - st->cldfbAna->no_channels; @@ -1916,8 +1468,6 @@ ivas_error acelp_core_dec_ivas_fx( /* analyze pitch coherence for bass post-filter */ -#ifdef IVAS_FLOAT_FIXED - Word32 pitch_buf_fx_q20[12]; Scale_sig32(st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, Q4); @@ -1930,10 +1480,6 @@ ivas_error acelp_core_dec_ivas_fx( bpf_pitch_coherence_ivas_fx(st, pitch_buf_fx_q20); Scale_sig32(st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, -Q4); -#else - bpf_pitch_coherence(st, pitch_buf); -#endif - IF( !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->bpf_off ) ) { @@ -1960,23 +1506,7 @@ ivas_error acelp_core_dec_ivas_fx( if (st->element_mode != IVAS_CPE_DFT || use_cldfb_for_dft) { - /*float realBufferSave[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - float imagBufferSave[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - float *pRealSave[CLDFB_NO_COL_MAX], *pImagSave[CLDFB_NO_COL_MAX]; - for (i = 0; i < CLDFB_NO_COL_MAX; i++) - { - pRealSave[i] = realBufferSave[i]; - pImagSave[i] = imagBufferSave[i]; - } - - if (st->p_bpf_noise_buf_float) - { - mvr2r(bpf_error_signal, st->p_bpf_noise_buf_float, st->L_frame); - }*/ - /* analysis of the synthesis at internal sampling rate */ - -#ifdef IVAS_FLOAT_FIXED Word32 realBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word32 imagBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word32 *pRealSave_fx[CLDFB_NO_COL_MAX], *pImagSave_fx[CLDFB_NO_COL_MAX]; @@ -1985,62 +1515,36 @@ ivas_error acelp_core_dec_ivas_fx( pRealSave_fx[i] = realBufferSave_fx[i]; pImagSave_fx[i] = imagBufferSave_fx[i]; } - //floatToFixed_arrL(bpf_error_signal, bpf_error_signal_fx, st->Q_syn - 1, st->L_frame); Copy_Scale_sig_16_32(bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1); //Q_syn-1 IF(st->p_bpf_noise_buf_32) { Copy32(bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame); } - //floatToFixed_arr(syn, psyn_fx, st->Q_syn, L_FRAME16k); for (i = 0; i < L_FRAME16k; i++) { syn_32_fx[i] = L_shr(L_deposit_h(psyn_fx[i]), 4 + st->Q_syn); //Q12 } Word16 offset = sub(st->cldfbAna->p_filter_length, st->cldfbAna->no_channels); - //floatToFixed_arrL(st->cldfbAna->cldfb_state, st->cldfbAna->cldfb_state_fx, Q12, offset); Scale_sig32(st->cldfbAna->cldfb_state_fx, offset, 1); //Q12 cldfbAnalysis_ivas_fx(syn_32_fx, realBuffer_fx, imagBuffer_fx, -1, st->cldfbAna); - - //fixedToFloat_arrL(st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_state, Q12, offset); Scale_sig32(st->cldfbAna->cldfb_state_fx, offset, -1); //Q11 - /*for (i = 0; i < CLDFB_NO_COL_MAX; i++) - { - fixedToFloat_arrL(realBuffer_fx[i], realBuffer[i], Q12 - 5, CLDFB_NO_CHANNELS_MAX); //Q7 - fixedToFloat_arrL(imagBuffer_fx[i], imagBuffer[i], Q12 - 5, CLDFB_NO_CHANNELS_MAX); //Q7 - }*/ -#else - cldfbAnalysis_ivas(syn, realBuffer, imagBuffer, -1, st->cldfbAna); -#endif - /* analysis and add the BPF error signal */ -#ifdef IVAS_FLOAT_FIXED Word32 tmp_bpf_error_signal_fx[L_FRAME16k]; Word16 q_bpf_error_signal; Word16 cldfb_state_offset = sub(st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels); q_bpf_error_signal = Q6; - // Float to fixed - //floatToFixed_arrL(bpf_error_signal, tmp_bpf_error_signal_fx, q_bpf_error_signal, L_FRAME16k); Copy_Scale_sig_16_32(bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, q_bpf_error_signal - st->Q_syn); // Q6 for (i = 0; i < CLDFB_NO_COL_MAX; i++) { - /*for (j = 0; j < CLDFB_NO_CHANNELS_MAX; j++) - { - realBuffer_fx[i][j] = floatToFixed(realBuffer[i][j], q_bpf_error_signal - 6); - imagBuffer_fx[i][j] = floatToFixed(imagBuffer[i][j], q_bpf_error_signal - 6); - }*/ Scale_sig32(realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7); //Q0 Scale_sig32(imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7); //Q0 } - /*for (i = 0; i < cldfb_state_offset; i++) - { - st->cldfbBPF->cldfb_state_fx[i] = float_to_fix(st->cldfbBPF->cldfb_state[i], q_bpf_error_signal); - }*/ Scale_sig32(st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, q_bpf_error_signal - Q10); //q_bpf_error_signal (Q6) tmp = -1; @@ -2052,27 +1556,9 @@ ivas_error acelp_core_dec_ivas_fx( } addBassPostFilter_ivas_fx(tmp_bpf_error_signal_fx, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF); - - // Fixed to float - /*for (i = 0; i < CLDFB_NO_COL_MAX; i++) - { - for (j = 0; j < CLDFB_NO_CHANNELS_MAX; j++) - { - realBuffer[i][j] = fixedToFloat(realBuffer_fx[i][j], q_bpf_error_signal - 6); - imagBuffer[i][j] = fixedToFloat(imagBuffer_fx[i][j], q_bpf_error_signal - 6); - } - } - for (i = 0; i < cldfb_state_offset; i++) - { - st->cldfbBPF->cldfb_state[i] = fix_to_float(st->cldfbBPF->cldfb_state_fx[i], q_bpf_error_signal); - }*/ Scale_sig32(st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, -(q_bpf_error_signal - Q10)); //Q10 -#else - addBassPostFilter(bpf_error_signal, st->bpf_off ? 0 : -1, realBuffer, imagBuffer, st->cldfbBPF); -#endif /* set output mask for upsampling */ -#ifdef IVAS_FLOAT_FIXED IF(EQ_16(st->bwidth, NB)) { /* set NB mask for upsampling */ @@ -2083,20 +1569,7 @@ ivas_error acelp_core_dec_ivas_fx( /* in case of BW switching, re-init to default */ st->cldfbSyn->bandsToZero = sub(st->cldfbSyn->no_channels, st->cldfbAna->no_channels); } -#else - if (st->bwidth == NB) - { - /* set NB mask for upsampling */ - st->cldfbSyn->bandsToZero = st->cldfbSyn->no_channels - 10; - } - else if (st->cldfbSyn->bandsToZero != st->cldfbSyn->no_channels - st->cldfbAna->no_channels) - { - /* in case of BW switching, re-init to default */ - st->cldfbSyn->bandsToZero = st->cldfbSyn->no_channels - st->cldfbAna->no_channels; - } -#endif -#ifdef IVAS_FLOAT_FIXED IF(!st->cng_sba_flag || EQ_16(st->element_mode, IVAS_CPE_MDCT)) { /*WB/SWB-FD_CNG*/ @@ -2108,11 +1581,6 @@ ivas_error acelp_core_dec_ivas_fx( /* Fixed to float */ FOR(i = 0; i < st->hFdCngDec->hFdCngCom->numSlots; i++) { - /*FOR( j = st->hFdCngDec->hFdCngCom->numCoreBands; j < st->hFdCngDec->hFdCngCom->regularStopBand; j++ ) - { - realBuffer[i][j] = me2f(realBuffer_fx[i][j], tmpBufferScale + 15); - imagBuffer[i][j] = me2f(imagBuffer_fx[i][j], tmpBufferScale + 15); - }*/ Scale_sig32(realBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, st->hFdCngDec->hFdCngCom->regularStopBand - st->hFdCngDec->hFdCngCom->numCoreBands, (tmpBufferScale + 15) - Q31); //Q0 Scale_sig32(imagBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, st->hFdCngDec->hFdCngCom->regularStopBand - st->hFdCngDec->hFdCngCom->numCoreBands, (tmpBufferScale + 15) - Q31); //Q0 } @@ -2127,61 +1595,30 @@ ivas_error acelp_core_dec_ivas_fx( } } } -#else - if (!st->cng_sba_flag || st->element_mode == IVAS_CPE_MDCT) - { - /*WB/SWB-FD_CNG*/ - if ((st->core_brate == FRAME_NO_DATA || st->core_brate == SID_2k40) && (st->cng_type == FD_CNG) && (st->hFdCngDec->hFdCngCom->numCoreBands < st->cldfbSyn->no_channels)) - { - generate_comfort_noise_dec_hf_flt(realBuffer, imagBuffer, st->hFdCngDec->hFdCngCom, st->cng_ism_flag); - - if (st->hFdCngDec->hFdCngCom->regularStopBand < st->cldfbSyn->no_channels) - { - st->cldfbSyn->bandsToZero = st->cldfbSyn->no_channels - st->hFdCngDec->hFdCngCom->regularStopBand; - } - else - { - st->cldfbSyn->bandsToZero = 0; - } - } - } -#endif if (save_hb_synth_fx16 != NULL) { /* save and then zero-out lowband */ -#ifdef IVAS_FLOAT_FIXED - //Word32 save_hb_synth_fx[L_FRAME48k]; - //Word32 synth_fx[L_FRAME48k]; - Word16 Q_real = 0, Q_imag = 0; - //float max_real = 0.f, max_imag = 0.f; Word32 max_real = 0, max_imag = 0; for (i = 0; i < CLDFB_NO_COL_MAX; i++) { for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { - //max_real = (float)max(max_real, fabs(realBuffer[i][j])); max_real = max(max_real, L_abs(realBuffer_fx[i][j])); - //max_imag = (float)max(max_imag, fabs(imagBuffer[i][j])); max_imag = max(max_imag, L_abs(imagBuffer_fx[i][j])); } } - //float max_val = max(max_real, max_imag); Word32 max_val = max(max_real, max_imag); Q_imag = norm_s((Word16)max_val); Q_real = Q_imag; for (i = 0; i < CLDFB_NO_COL_MAX; i++) { - //floatToFixed_arrL(realBuffer[i], realBuffer_fx[i], Q_real, CLDFB_NO_CHANNELS_MAX); Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real); - //floatToFixed_arrL(imagBuffer[i], imagBuffer_fx[i], Q_imag, CLDFB_NO_CHANNELS_MAX); Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_imag); } - //floatToFixed_arrL(st->cldfbSynHB->cldfb_state, st->cldfbSynHB->cldfb_state_fx, Q_real - 1, st->cldfbSynHB->p_filter_length); Scale_sig32( st->cldfbSynHB->cldfb_state_fx, (Q_real - 1) - Q10, st->cldfbSynHB->p_filter_length); // (Q_real-1) - //floatToFixed_arrL(save_hb_synth, save_hb_synth_fx, Q_real - 1, L_FRAME48k); Scale_sig32(save_hb_synth_fx, L_FRAME48k, Q_real - 1); FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) @@ -2200,9 +1637,7 @@ ivas_error acelp_core_dec_ivas_fx( cldfbSynthesis_ivas_fx(realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, st->cldfbSynHB); - //fixedToFloat_arrL(save_hb_synth_fx, save_hb_synth, Q_real - 1, L_FRAME48k); Scale_sig32(save_hb_synth_fx, L_FRAME48k, -(Q_real - 1)); //Q0 - //fixedToFloat_arrL(st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->cldfb_state, Q_real - 1, st->cldfbSynHB->p_filter_length); Scale_sig32(st->cldfbSynHB->cldfb_state_fx, Q10 - (Q_real - 1), st->cldfbSynHB->p_filter_length); // Q10 /* restore lowband */ @@ -2214,86 +1649,39 @@ ivas_error acelp_core_dec_ivas_fx( imagBuffer_fx[i][j] = imagBufferSave_fx[i][j]; } } - //floatToFixed_arrL(st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_fx, Q_real - 1, st->cldfbSyn->p_filter_length); Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, (Q_real - 1) - Q10); //Q_real-1 cldfbSynthesis_ivas_fx(pRealSave_fx, pImagSave_fx, synth_fx, -1, st->cldfbSyn); - //fixedToFloat_arrL(synth_fx, synth, Q_real - 1, L_FRAME48k); Scale_sig32(synth_fx, L_FRAME48k, -(Q_real - 1)); - //fixedToFloat_arrL(st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->cldfb_state, Q_real - 1, st->cldfbSynHB->p_filter_length); Scale_sig32(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, Q10 - (Q_real - 1)); //Q10 -#else - for (int16_t j = 0; j < CLDFB_NO_CHANNELS_MAX; j++) - { - for (i = 0; i < CLDFB_NO_COL_MAX; i++) - { - realBufferSave[i][j] = realBuffer[i][j]; - imagBufferSave[i][j] = imagBuffer[i][j]; - if (j < st->hFdCngDec->hFdCngCom->numCoreBands && i < st->hFdCngDec->hFdCngCom->numSlots) - { - realBuffer[i][j] = 0.0f; - imagBuffer[i][j] = 0.0f; - } - } - } - cldfbSynthesis_ivas(realBuffer, imagBuffer, save_hb_synth, -1, st->cldfbSynHB); - - /* restore lowband */ - for (int16_t j = 0; j < CLDFB_NO_CHANNELS_MAX; j++) - { - for (i = 0; i < CLDFB_NO_COL_MAX; i++) - { - realBuffer[i][j] = realBufferSave[i][j]; - imagBuffer[i][j] = imagBufferSave[i][j]; - } - } - - cldfbSynthesis_ivas(pRealSave, pImagSave, synth, -1, st->cldfbSyn); -#endif } else { /* synthesis of the combined signal */ -#ifdef IVAS_FLOAT_FIXED Word16 Q_real = 0, Q_imag = 0; - //float max_real = 0.f, max_imag = 0.f; Word32 max_real = 0, max_imag = 0; for (i = 0; i < CLDFB_NO_COL_MAX; i++) { for (j = 0; j < CLDFB_NO_CHANNELS_MAX; j++) { - //max_real = (float)max(max_real, fabs(realBuffer[i][j])); max_real = max(max_real, L_abs(realBuffer_fx[i][j])); - //max_imag = (float)max(max_imag, fabs(imagBuffer[i][j])); max_imag = max(max_imag, L_abs(imagBuffer_fx[i][j])); } } - //float max_val = max(max_real, max_imag); Word32 max_val = max(max_real, max_imag); Q_imag = norm_s((Word16)max_val); Q_real = Q_imag; for (i = 0; i < CLDFB_NO_COL_MAX; i++) { - //floatToFixed_arrL(realBuffer[i], realBuffer_fx[i], Q_real, CLDFB_NO_CHANNELS_MAX); Scale_sig32(realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real); - //floatToFixed_arrL(imagBuffer[i], imagBuffer_fx[i], Q_real, CLDFB_NO_CHANNELS_MAX); Scale_sig32(imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real); } - //floatToFixed_arrL(st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_fx, Q_real - 1, st->cldfbSyn->p_filter_length); Scale_sig32(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, (Q_real - 1) - Q10); //(Q_real - 1) - //Word32 synth_fx[L_FRAME48k]; - //floatToFixed_arrL(synth, synth_fx, Q_real - 1, L_FRAME48k); Scale_sig32( synth_fx, L_FRAME48k, Q_real - 1); cldfbSynthesis_ivas_fx(realBuffer_fx, imagBuffer_fx, synth_fx, -1, st->cldfbSyn); - - //fixedToFloat_arrL(synth_fx, synth, Q_real - 1, L_FRAME48k); Scale_sig32(synth_fx, L_FRAME48k, -(Q_real - 1)); - //fixedToFloat_arrL(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_state, Q_real - 1, st->cldfbSyn->p_filter_length); Scale_sig32(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, Q10 - (Q_real - 1)); //Q10 -#else - cldfbSynthesis_ivas(realBuffer, imagBuffer, synth, -1, st->cldfbSyn); -#endif } /* save synthesis - needed in case of core switching */ @@ -2305,33 +1693,19 @@ ivas_error acelp_core_dec_ivas_fx( int16_t nSamples = NS2SA(st->L_frame * FRAMES_PER_SEC, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/); /* IVAS-64: optimization is likely possible here (don't resample the whole frame) */ /* analysis of the synthesis at internal sampling rate - needed for DFT stereo -> TD stereo switching */ -#ifdef IVAS_FLOAT_FIXED - //floatToFixed_arr(syn, psyn_fx, st->Q_syn, L_FRAME16k); for (i = 0; i < L_FRAME16k; i++) { syn_32_fx[i] = L_shr(L_deposit_h(psyn_fx[i]), 4 + st->Q_syn); } Word16 offset = sub(st->cldfbAna->p_filter_length, st->cldfbAna->no_channels); - //floatToFixed_arrL(st->cldfbAna->cldfb_state, st->cldfbAna->cldfb_state_fx, Q12, offset); Scale_sig32(st->cldfbAna->cldfb_state_fx, offset, 1); //Q12 cldfbAnalysis_ivas_fx(syn_32_fx + st->L_frame - nSamples, realBuffer_fx, imagBuffer_fx, nSamples, st->cldfbAna); - //fixedToFloat_arrL(st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_state, Q12, offset); Scale_sig32(st->cldfbAna->cldfb_state_fx, offset, -1); //Q11 - /*for (i = 0; i < CLDFB_NO_COL_MAX; i++) - { - fixedToFloat_arrL(realBuffer_fx[i], realBuffer[i], Q12 - 5, CLDFB_NO_CHANNELS_MAX); - fixedToFloat_arrL(imagBuffer_fx[i], imagBuffer[i], Q12 - 5, CLDFB_NO_CHANNELS_MAX); - }*/ -#else - cldfbAnalysis_ivas(syn + st->L_frame - nSamples, realBuffer, imagBuffer, nSamples, st->cldfbAna); -#endif - /* analysis and add the BPF error signal - needed for DFT stereo -> TD stereo switching */ -#ifdef IVAS_FLOAT_FIXED Word32 tmp_bpf_error_signal_fx[L_FRAME16k]; Word16 q_bpf_error_signal; Word16 cldfb_state_offset = sub(st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels); @@ -2339,23 +1713,12 @@ ivas_error acelp_core_dec_ivas_fx( // Get Q-factor q_bpf_error_signal = Q6; - // Float to fixed - //floatToFixed_arrL(bpf_error_signal, tmp_bpf_error_signal_fx, q_bpf_error_signal, L_FRAME16k); Copy_Scale_sig_16_32(bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, q_bpf_error_signal - st->Q_syn); // Q6 for (i = 0; i < CLDFB_NO_COL_MAX; i++) { - /*for (j = 0; j < CLDFB_NO_CHANNELS_MAX; j++) - { - realBuffer_fx[i][j] = floatToFixed(realBuffer[i][j], q_bpf_error_signal - 6); - imagBuffer_fx[i][j] = floatToFixed(imagBuffer[i][j], q_bpf_error_signal - 6); - }*/ Scale_sig32(realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7); //Q0 Scale_sig32(imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7); //Q0 } - /*for (i = 0; i < cldfb_state_offset; i++) - { - st->cldfbBPF->cldfb_state_fx[i] = float_to_fix(st->cldfbBPF->cldfb_state[i], q_bpf_error_signal); - }*/ Scale_sig32(st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, q_bpf_error_signal - Q10); //q_bpf_error_signal (Q6) tmp = 0; @@ -2369,61 +1732,40 @@ ivas_error acelp_core_dec_ivas_fx( Scale_sig32(st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, -(q_bpf_error_signal - Q10)); //Q10 -#else - addBassPostFilter(bpf_error_signal + st->L_frame - nSamples, st->bpf_off ? 0 : nSamples, realBuffer, imagBuffer, st->cldfbBPF); -#endif /* synthesis of the combined signal - needed for DFT stereo -> TD stereo switching */ -#ifdef IVAS_FLOAT_FIXED Word16 Q_real = 0, Q_imag = 0; - //float max_real = 0.f, max_imag = 0.f; Word32 max_real = 0, max_imag = 0; for (i = 0; i < CLDFB_NO_COL_MAX; i++) { for (j = 0; j < CLDFB_NO_CHANNELS_MAX; j++) { - //max_real = (float)max(max_real, fabs(realBuffer[i][j])); max_real = max(max_real, L_abs(realBuffer_fx[i][j])); - //max_imag = (float)max(max_imag, fabs(imagBuffer[i][j])); max_imag = max(max_imag, L_abs(imagBuffer_fx[i][j])); } } - //float max_val = max(max_real, max_imag); Word32 max_val = max(max_real, max_imag); Q_imag = norm_s((Word16)max_val); Q_real = Q_imag; for (i = 0; i < CLDFB_NO_COL_MAX; i++) { - //floatToFixed_arrL(realBuffer[i], realBuffer_fx[i], Q_real, CLDFB_NO_CHANNELS_MAX); Scale_sig32(realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real); - //floatToFixed_arrL(imagBuffer[i], imagBuffer_fx[i], Q_real, CLDFB_NO_CHANNELS_MAX); Scale_sig32(imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real); } - //floatToFixed_arrL(st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_fx, Q_real - 1, st->cldfbSyn->p_filter_length); Scale_sig32(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, (Q_real - 1) - Q10); //(Q_real - 1) - //Word32 synth_fx[L_FRAME48k]; - //floatToFixed_arrL(synth, synth_fx, Q_real - 1, L_FRAME48k); Scale_sig32( synth_fx, L_FRAME48k, Q_real - 1); cldfbSynthesis_ivas_fx(realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA(st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/), st->cldfbSyn); - //fixedToFloat_arrL(synth_fx, synth, Q_real - 1, L_FRAME48k); Scale_sig32(synth_fx, L_FRAME48k, -(Q_real - 1)); - //fixedToFloat_arrL(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_state, Q_real - 1, st->cldfbSyn->p_filter_length); Scale_sig32(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, Q10 - (Q_real - 1)); -#else - cldfbSynthesis_ivas(realBuffer, imagBuffer, synth /*dummy*/, NS2SA(st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/), st->cldfbSyn); -#endif - if (st->p_bpf_noise_buf_float) { - //mvr2r(bpf_error_signal, st->p_bpf_noise_buf_float, st->L_frame); Copy_Scale_sig_16_32(bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1); //Q_syn-1 Copy32(bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame); } - //set_f(synth, 0.0f, output_frame); set_l(synth_fx, 0, output_frame); } @@ -2432,7 +1774,6 @@ ivas_error acelp_core_dec_ivas_fx( Scale_sig(syn_tmp_fx, L_FRAME16k + L_SUBFR, -st->Q_syn); if (st->element_mode > EVS_MONO) { - //mvr2r(syn, output, st->L_frame); Copy(psyn_fx, output_fx, st->L_frame); } @@ -2441,7 +1782,6 @@ ivas_error acelp_core_dec_ivas_fx( /*-----------------------------------------------------------------* * Bandwidth extension 6kHz-7kHz *-----------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED IF( st->hBWE_zero != NULL ) { test(); @@ -2455,8 +1795,6 @@ ivas_error acelp_core_dec_ivas_fx( ( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) || ( EQ_16( st->extl, WB_BWE ) && st->extl_brate == 0 && NE_16( st->coder_type, AUDIO ) ) ) ) ) { Word16 tmp_exp = 0; - - //Word16 output_subfr = output_frame / NB_SUBFR; Copy_Scale_sig_32_16(synth_fx, synth_fx16, L_FRAME48k, 0); hf_synth_ivas_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc_fx, @@ -2476,24 +1814,8 @@ ivas_error acelp_core_dec_ivas_fx( ELSE { hf_synth_reset_fx( st->hBWE_zero ); - /*to be cleaned up*/ - //hf_synth_reset( st->hBWE_zero ); - } - } -#else - if (st->hBWE_zero != NULL) - { - if ((st->L_frame == L_FRAME && st->bwidth != NB && output_frame >= L_FRAME16k && - (st->extl == -1 || st->extl == SWB_CNG || (st->extl == WB_BWE && st->extl_brate == 0 && st->coder_type != AUDIO)))) - { - hf_synth(st->hBWE_zero, st->core_brate, output_frame, Aq, exc2, syn, synth); - } - else - { - hf_synth_reset(st->hBWE_zero); } } -#endif /*-----------------------------------------------------------------* * Populate parameters for SWB TBE @@ -2503,39 +1825,19 @@ ivas_error acelp_core_dec_ivas_fx( { if ((!st->bfi && st->prev_bfi) || (st->last_vbr_hw_BWE_disable_dec == 1 && st->vbr_hw_BWE_disable_dec == 0) || ((st->extl == SWB_TBE || st->extl == WB_TBE || st->extl == FB_TBE) && st->last_extl != SWB_TBE && st->last_extl != WB_TBE && st->last_extl != FB_TBE) || (st->idchan == 1 && st->element_mode == IVAS_CPE_TD && !st->tdm_LRTD_flag)) { - //st->hBWE_TD->bwe_non_lin_prev_scale = 0.0f; st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - //set_f(st->hBWE_TD->old_bwe_exc_extended, 0.0f, NL_BUFF_OFFSET); set_s(st->hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET); } if (!st->ppp_mode_dec && (st->idchan == 0 || st->element_mode != IVAS_CPE_TD || (st->idchan == 1 && st->element_mode == IVAS_CPE_TD && st->tdm_LRTD_flag))) { -#ifdef IVAS_FLOAT_FIXED - - - ///* update buffer memory */ - //Copy32( tmp_old_bwe_exc_extended_fx, tmp_bwe_exc_extended_fx, NL_BUFF_OFFSET ); Copy_Scale_sig_16_32(st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, 2 * st->Q_exc); - - //non_linearity_ivas_fx(bwe_exc_fx, tmp_bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame); non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); - - ///* update buffer memory */ - //Copy32( tmp_bwe_exc_extended_fx + L_FRAME32k, tmp_old_bwe_exc_extended_fx, NL_BUFF_OFFSET ); - - //// Fixed to float - //me2f_buf( tmp_bwe_exc_extended_fx, 31 - 2 * st->Q_exc, bwe_exc_extended, L_FRAME32k + NL_BUFF_OFFSET ); - //me2f_buf( tmp_old_bwe_exc_extended_fx, 31 - 2 * st->Q_exc, st->hBWE_TD->old_bwe_exc_extended, NL_BUFF_OFFSET ); Copy_Scale_sig_32_16(bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, -(2 * st->Q_exc)); -#else - non_linearity( bwe_exc, bwe_exc_extended, st->hBWE_TD->old_bwe_exc_extended, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale, st->coder_type, voice_factors, st->L_frame ); -#endif } if ( st->core_brate == FRAME_NO_DATA || st->core_brate == SID_2k40 ) { - //st->hBWE_TD->bwe_non_lin_prev_scale = 0.0f; st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; } } @@ -2543,18 +1845,11 @@ ivas_error acelp_core_dec_ivas_fx( * Updates *----------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED - updt_dec_fx( st, old_exc_fx, pitch_buf_fx, Es_pred_fx, Aq_fx, lsf_new_fx, lsp_new_fx, voice_factors_fx, old_bwe_exc_fx, gain_buf_fx ); -#else - updt_dec( st, old_exc, pitch_buf, Es_pred, Aq, lsf_new, lsp_new, voice_factors, old_bwe_exc, gain_buf ); -#endif - -#ifdef IVAS_FLOAT_FIXED IF( GT_32( st->core_brate, SID_2k40 ) && st->hTdCngDec != NULL && st->hFdCngDec != NULL ) { - ///* update CNG parameters in active frames */ + /* update CNG parameters in active frames */ cng_params_upd_ivas_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth ); @@ -2569,29 +1864,15 @@ ivas_error acelp_core_dec_ivas_fx( move16(); } } -#else - if (st->core_brate > SID_2k40 && st->hTdCngDec != NULL && st->hFdCngDec != NULL) - { - /* update CNG parameters in active frames */ - cng_params_upd(lsp_new, exc, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ, DEC, st->hTdCngDec->ho_env_circ, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth); - /* Set 16k LSP flag for CNG buffer */ - st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = (st->L_frame == L_FRAME ? 0 : 1); - } -#endif pop_wmops(); { - /* Lccal fix2float (To be removed) */ - /*fixedToFloat_arrL(bwe_exc_extended_fx, bwe_exc_extended, 2 * st->Q_exc, L_FRAME32k + NL_BUFF_OFFSET); - fixedToFloat_arr(output_fx, output, 0, st->L_frame);*/ if (save_hb_synth_fx16) { - //fixedToFloat_arrL(save_hb_synth_fx, save_hb_synth, 0, L_FRAME48k); Copy_Scale_sig_32_16(save_hb_synth_fx, save_hb_synth_fx16, L_FRAME48k, 0); } - //fixedToFloat_arrL(synth_fx, synth, 0, L_FRAME48k); Copy_Scale_sig_32_16(synth_fx, synth_fx16, L_FRAME48k, 0); if (st->hFdCngDec) { @@ -2605,9 +1886,6 @@ ivas_error acelp_core_dec_ivas_fx( void acelp_decoder_state_float2fix(Decoder_State *st/*, STEREO_CNG_DEC_HANDLE hStereoCng*/) { - //if (hStereoCng) { - // floatToFixed_arr(hStereoCng->olapBufferSynth22, hStereoCng->olapBufferSynth22_fx, st->Q_syn, FFTLEN); - //} /* CLDFB */ Word16 old_len_ana, old_len_bpf; @@ -2628,57 +1906,20 @@ void acelp_decoder_state_float2fix(Decoder_State *st/*, STEREO_CNG_DEC_HANDLE hS //FdCng if ( st->hFdCngDec ) { - //floatToFixed_arrL( st->hFdCngDec->hFdCngCom->sidNoiseEstLp_flt, st->hFdCngDec->hFdCngCom->sidNoiseEstLp, Q31 - st->hFdCngDec->hFdCngCom->sidNoiseEstExp, NPART ); st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = Q31 - 4; floatToFixed_arrL(st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, Q31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN); - //floatToFixed_arr(st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, Q12, M + 1); - //st->hFdCngDec->hFdCngCom->A_cng[0] = 4096; - //floatToFixed_arr(st->hFdCngDec->hFdCngCom->exc_cng_flt, st->hFdCngDec->hFdCngCom->exc_cng, st->Q_exc_cng, L_FRAME16k); - - //floatToFixed_arr(st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->fftlenShift, FFTLEN); - //st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = float_to_fix16(st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt, Q15); - //floatToFixed_arrL( st->hFdCngDec->bandNoiseShape_float, st->hFdCngDec->bandNoiseShape, Q31 - st->hFdCngDec->bandNoiseShape_exp, FFTLEN2); - /*CNA: ApplyFdCng*/ - if ((st->hFdCngDec != NULL || st->idchan == 1) && st->element_mode != IVAS_CPE_MDCT) - { - if (st->element_mode == IVAS_CPE_TD || st->flag_cna || (st->cng_type == FD_CNG && st->total_brate <= ACELP_32k) || (st->cng_type == LP_CNG && st->core_brate <= SID_2k40)) - { - if (st->element_mode != IVAS_CPE_TD && !st->cng_ism_flag) - { - //st->hFdCngDec->hFdCngCom->fftBuffer_exp = /*st->hFdCngDec->msNoiseEst_exp = */Q31 - Q4; //st->hFdCngDec->hFdCngCom->periodog_exp = st->hFdCngDec->msPsd_exp_fft = st->hFdCngDec->msPeriodog_exp = st->hFdCngDec->msPeriodog_ST_exp = 31 - Q4; Q4 - - //floatToFixed_arrL(st->hFdCngDec->hFdCngCom->fftBuffer_flt, st->hFdCngDec->hFdCngCom->fftBuffer, Q31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp, st->hFdCngDec->hFdCngCom->fftlen); - //floatToFixed_arrL(st->hFdCngDec->msNoiseEst_float, st->hFdCngDec->msNoiseEst, Q31 - st->hFdCngDec->msNoiseEst_exp, st->hFdCngDec->npart_shaping); - - //if (st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT) - //{ - //floatToFixed_arrL(st->hFdCngDec->smoothed_psd, st->hFdCngDec->smoothed_psd_fx, Q31 - /*st->hFdCngDec->msNoiseEst_exp*/ Q27, L_FRAME16k - st->hFdCngDec->hFdCngCom->startBand); - //} - } - } - } } /*TD_BWE_DEC_HANDLE*/ if (st->hBWE_TD) { floatToFixed_arr(st->hBWE_TD->old_bwe_exc_extended, st->hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET); } - - /*TCX_DEC_HANDLE*/ - if (st->hTcxDec) { - //floatToFixed_arr(st->hTcxDec->syn_Overl_float, st->hTcxDec->syn_Overl, 0, L_FRAME32k / 2); - //floatToFixed_arr(st->hTcxDec->old_syn_Overl_float, st->hTcxDec->old_syn_Overl, -1, st->L_frame / 2); - } } -void acelp_decoder_state_fix2float(Decoder_State *st/*, STEREO_CNG_DEC_HANDLE hStereoCng*/) { +void acelp_decoder_state_fix2float(Decoder_State *st) { st->prev_Q_syn = st->Q_syn; - //if (hStereoCng) { - // fixedToFloat_arr(hStereoCng->olapBufferSynth22_fx, hStereoCng->olapBufferSynth22, st->Q_syn, FFTLEN); - //} - /* CLDFB */ Word16 new_len; new_len = 9 * (int16_t)(st->L_frame * FRAMES_PER_SEC * INV_CLDFB_BANDWIDTH + 0.5f); @@ -2695,15 +1936,7 @@ void acelp_decoder_state_fix2float(Decoder_State *st/*, STEREO_CNG_DEC_HANDLE hS //FdCng if ( st->hFdCngDec ) { - //fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->sidNoiseEstLp, st->hFdCngDec->hFdCngCom->sidNoiseEstLp_flt, Q31 - st->hFdCngDec->hFdCngCom->sidNoiseEstExp, NPART); fixedToFloat_arrL( st->hFdCngDec->hFdCngCom->cngNoiseLevel, st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, Q31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN ); - //fixedToFloat_arr( st->hFdCngDec->hFdCngCom->A_cng, st->hFdCngDec->hFdCngCom->A_cng_flt, Q12, M + 1 ); - //fixedToFloat_arr(st->hFdCngDec->hFdCngCom->exc_cng, st->hFdCngDec->hFdCngCom->exc_cng_flt, st->Q_exc_cng, L_FRAME16k); - //fixedToFloat_arr(st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, st->hFdCngDec->hFdCngCom->fftlenShift, FFTLEN); - //st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt = fixedToFloat(st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, Q15); - //fixedToFloat_arrL(st->hFdCngDec->bandNoiseShape, st->hFdCngDec->bandNoiseShape_float, Q31 - st->hFdCngDec->bandNoiseShape_exp, FFTLEN2); - //fixedToFloat_arrL(st->hFdCngDec->partNoiseShape, st->hFdCngDec->partNoiseShape_float, Q31 - st->hFdCngDec->partNoiseShape_exp, NPART); - /*CNA: ApplyFdCng*/ if ((st->hFdCngDec != NULL || st->idchan == 1) && st->element_mode != IVAS_CPE_MDCT) { if (st->element_mode == IVAS_CPE_TD || st->flag_cna || (st->cng_type == FD_CNG && st->total_brate <= ACELP_32k) || (st->cng_type == LP_CNG && st->core_brate <= SID_2k40)) @@ -2720,21 +1953,7 @@ void acelp_decoder_state_fix2float(Decoder_State *st/*, STEREO_CNG_DEC_HANDLE hS (st->m_frame_type == ZERO_FRAME) && (st != NULL && st->cng_type == LP_CNG) ) { - //fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->periodog, st->hFdCngDec->hFdCngCom->periodog_flt, Q31 - st->hFdCngDec->hFdCngCom->periodog_exp, PERIODOGLEN); - //fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->fftBuffer, st->hFdCngDec->hFdCngCom->fftBuffer_flt, Q31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp, st->hFdCngDec->hFdCngCom->fftlen); fixedToFloat_arrL(st->hFdCngDec->msNoiseEst, st->hFdCngDec->msNoiseEst_float, Q31 - st->hFdCngDec->msNoiseEst_exp, st->hFdCngDec->npart_shaping); - // fixedToFloat_arrL(st->hFdCngDec->msPeriodog, st->hFdCngDec->msPeriodog_float, Q31 - st->hFdCngDec->msPeriodog_exp, st->hFdCngDec->npart_shaping); - //fixedToFloat_arrL(st->hFdCngDec->msPeriodog_ST_fx, st->hFdCngDec->msPeriodog_ST, Q31 - st->hFdCngDec->msPeriodog_ST_exp, st->hFdCngDec->npart_shaping); - - //if (st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT) - //{ - //fixedToFloat_arrL(st->hFdCngDec->smoothed_psd_fx, st->hFdCngDec->smoothed_psd, Q31 - st->hFdCngDec->msNoiseEst_exp, L_FRAME16k - st->hFdCngDec->hFdCngCom->startBand); - //} - if (!((st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT) && (st->hFdCngDec->hFdCngCom->active_frame_counter > 0))) - { - //st->hTcxDec->CngLevelBackgroundTrace_bfi = fixedToFloat(st->hTcxDec->CngLevelBackgroundTrace_bfi_fx, (31 - st->hTcxDec->CngLevelBackgroundTrace_bfi_exp)); - //st->hTcxDec->CngLevelBackgroundTrace_bfi = fix16_to_float(st->hTcxDec->conCngLevelBackgroundTrace, (15 - st->hTcxDec->conCngLevelBackgroundTrace_e)); - } } } } @@ -2745,20 +1964,10 @@ void acelp_decoder_state_fix2float(Decoder_State *st/*, STEREO_CNG_DEC_HANDLE hS if (st->hBWE_TD) { fixedToFloat_arr(st->hBWE_TD->old_bwe_exc_extended_fx, st->hBWE_TD->old_bwe_exc_extended, 0, NL_BUFF_OFFSET); } - - /*TCX_DEC_HANDLE*/ - if (st->hTcxDec) { - //fixedToFloat_arr(st->hTcxDec->syn_Overl, st->hTcxDec->syn_Overl_float, 0, L_FRAME32k / 2); - //fixedToFloat_arr(st->hTcxDec->old_syn_Overl, st->hTcxDec->old_syn_Overl_float, -1, st->L_frame / 2); - } } static void rescale_fdCngDec(HANDLE_FD_CNG_DEC hFdCngDec, Word16 Exp_diff) { Scale_sig32(hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, Exp_diff); - /*Scale_sig32(hFdCngDec->hFdCngCom->sidNoiseEst, NPART, -Exp_diff); - hFdCngDec->hFdCngCom->sidNoiseEstExp += Exp_diff; - Scale_sig32(hFdCngDec->hFdCngCom->cngNoiseLevel, NPART, -Exp_diff); - hFdCngDec->hFdCngCom->cngNoiseLevelExp += Exp_diff;*/ } #endif diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index a52d669fd2f6ba63a118e4ca94f8956159c1214c..cf28c1ed57ca9de169a0074807c4b8163074e180 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -151,7 +151,7 @@ ivas_error acelp_core_switch_dec_fx( pitch_buf_tmp[i] = L_SUBFR; move16(); } - nb_post_filt( 2*L_SUBFR, st_fx->hPFstat, &tmp_noise, 0, synth_intFreq, Aq, pitch_buf_tmp, AUDIO, st_fx->BER_detect, 0 ); + nb_post_filt_fx( 2*L_SUBFR, st_fx->hPFstat, &tmp_noise, 0, synth_intFreq, Aq, pitch_buf_tmp, AUDIO, st_fx->BER_detect, 0 ); } IF( EQ_16(L_frame_for_cs,L_FRAME)) @@ -173,9 +173,9 @@ ivas_error acelp_core_switch_dec_fx( Copy( synth_intFreq, bpf_error_signal + M, L_SUBFR ); Residu3_fx ( Aq, bpf_error_signal + M, exc, L_SUBFR, 1 ); E_UTIL_synthesis ( 1, Aq, exc, bpf_error_signal, L_SUBFR, st_fx->hPFstat->mem_stp+L_SYN_MEM-M, 0, M ); - scale_st ( synth_intFreq, bpf_error_signal, &st_fx->hPFstat->gain_prec, L_SUBFR ); + scale_st_fx ( synth_intFreq, bpf_error_signal, &st_fx->hPFstat->gain_prec, L_SUBFR ); Copy( bpf_error_signal, synth_intFreq, L_SUBFR/2 ); - blend_subfr2( bpf_error_signal + L_SUBFR/2, synth_intFreq + L_SUBFR/2, synth_intFreq + L_SUBFR/2 ); + blend_subfr2_fx( bpf_error_signal + L_SUBFR/2, synth_intFreq + L_SUBFR/2, synth_intFreq + L_SUBFR/2 ); } st_fx->hPFstat->on = 0; diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index 63056a2cb80eb9f3d59436c135809aa057b72d5d..69ed9d99060ea3d3170675ce4363df226aa0932d 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -720,13 +720,13 @@ ivas_error amr_wb_dec_fx( { st_fx->hPFstat->on = 1; move16(); - nb_post_filt( L_FRAME, st_fx->hPFstat, &st_fx->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, st_fx->coder_type, st_fx->BER_detect, 0 ); + nb_post_filt_fx( L_FRAME, st_fx->hPFstat, &st_fx->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, st_fx->coder_type, st_fx->BER_detect, 0 ); } ELSE { st_fx->hPFstat->on = 0; move16(); - nb_post_filt( L_FRAME, st_fx->hPFstat, &st_fx->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, AUDIO, st_fx->BER_detect, 0 ); + nb_post_filt_fx( L_FRAME, st_fx->hPFstat, &st_fx->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, AUDIO, st_fx->BER_detect, 0 ); } } @@ -756,7 +756,7 @@ ivas_error amr_wb_dec_fx( st_fx->hPFstat->on = 1; move16(); test(); - formant_post_filt( st_fx->hPFstat, tmp_buffer_fx + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME, L_shl(st_fx->psf_lp_noise_fx,15), st_fx->total_brate, sub(amr_io_class,AUDIO_CLAS) == 0); + formant_post_filt_fx( st_fx->hPFstat, tmp_buffer_fx + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME, L_shl(st_fx->psf_lp_noise_fx,15), st_fx->total_brate, sub(amr_io_class,AUDIO_CLAS) == 0); } /*----------------------------------------------------------------* diff --git a/lib_dec/dec_post.c b/lib_dec/dec_post.c index 075746dda06046ef3f5d718e942e8eafd068e7ee..a38a4155c3a3c1d9f91ee2a394555ceecfaf27ce 100644 --- a/lib_dec/dec_post.c +++ b/lib_dec/dec_post.c @@ -181,7 +181,7 @@ void nb_post_filt_ivas( #endif /*-------------------------------------------------------------------------- - * formant_post_filt: + * formant_post_filt_ivas: * * WB and SWB formant post-filtering *--------------------------------------------------------------------------*/ diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index 3a8f3bd33063bea53f37dabb2f63f1eb91188a56..17ef599cc8240cb9ebffe218b54a54911f896bd6 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -9,7 +9,7 @@ #include "rom_dec.h" #include "rom_com.h" #include "cnst.h" - +#ifdef IVAS_FLOAT_FIXED #define FORMAT_POST_FILT_G1 24576/*0.75f Q15*/ /*0.75f*/ /*denominator 0.9,0.75,0.15,0.9*/ #define FORMAT_POST_FILT_G2 22938/*0.7f Q15*/ /*0.7f*/ /*numerator 0.75,0.7,0.1,0.7*/ #define FORMAT_POST_FILT_G1_MAX 26214/*0.8f Q15*/ /*for low bit-rates on clean speech*/ @@ -19,39 +19,39 @@ * Local function prototypes *--------------------------------------------------------------------------*/ -static void Dec_postfilt( PFSTAT_HANDLE hPFstat, const Word16 t0, const Word16 *signal_ptr, const Word16 *coeff, +static void Dec_postfilt_fx( PFSTAT_HANDLE hPFstat, const Word16 t0, const Word16 *signal_ptr, const Word16 *coeff, Word16 *sig_out, const Word16 gamma1, const Word16 gamma2, const Word16 Gain_factor, const Word16 disable_hpf ); -static void pst_ltp( Word16 t0, Word16 * ptr_sig_in, Word16 * ptr_sig_pst0, Word16 gain_factor ); +static void pst_ltp_fx( Word16 t0, Word16 * ptr_sig_in, Word16 * ptr_sig_pst0, Word16 gain_factor ); -static void search_del( Word16 t0, Word16 * ptr_sig_in, Word16 * ltpdel, Word16 * phase, Word16 * num_gltp, Word16 * den_gltp, +static void search_del_fx( Word16 t0, Word16 * ptr_sig_in, Word16 * ltpdel, Word16 * phase, Word16 * num_gltp, Word16 * den_gltp, Word16 * sh_num_gltp, Word16 * sh_den_gltp, Word16 * y_up, Word16 * off_yup ); -static void filt_plt( Word16 * s_in, Word16 * s_ltp, Word16 * s_out, Word16 gain_plt ); +static void filt_plt_fx( Word16 * s_in, Word16 * s_ltp, Word16 * s_out, Word16 gain_plt ); -static void compute_ltp_l( Word16 * s_in, Word16 ltpdel, Word16 phase, Word16 * y_up, Word16 * num, Word16 * den, Word16 * sh_num, Word16 * sh_den ); +static void compute_ltp_l_fx( Word16 * s_in, Word16 ltpdel, Word16 phase, Word16 * y_up, Word16 * num, Word16 * den, Word16 * sh_num, Word16 * sh_den ); -static Word16 select_ltp( Word16 num1, Word16 den1, Word16 sh_num1, Word16 sh_den1, Word16 num2, Word16 den2, Word16 sh_num2, Word16 sh_den2 ); +static Word16 select_ltp_fx( Word16 num1, Word16 den1, Word16 sh_num1, Word16 sh_den1, Word16 num2, Word16 den2, Word16 sh_num2, Word16 sh_den2 ); -static void calc_st_filt( Word16 * apond2, Word16 * apond1, Word16 * parcor0, Word16 * sig_ltp_ptr, Word16 * mem_zero ); +static void calc_st_filt_local_fx( Word16 * apond2, Word16 * apond1, Word16 * parcor0, Word16 * sig_ltp_ptr, Word16 * mem_zero ); -static void modify_pst_param( const Word16 lp_noise, Word16 *g1, Word16 *g2, const Word16 coder_type, Word16 *gain_factor ); +static void modify_pst_param_fx( const Word16 lp_noise, Word16 *g1, Word16 *g2, const Word16 coder_type, Word16 *gain_factor ); -static void Dec_formant_postfilt( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 ); +static void Dec_formant_postfilt_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 ); #ifdef IVAS_FLOAT_FIXED -static void Dec_formant_postfilt_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 ); +static void Dec_formant_postfilt_ivas_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 ); -static void calc_st_filt_fx( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero, const Word16 extl ); +static void calc_st_filt_ivas_fx( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero, const Word16 extl ); #endif /*-------------------------------------------------------------------------- - * Init_post_filter + * Init_post_filter_fx * * post filter initialization *--------------------------------------------------------------------------*/ -void Init_post_filter( +void Init_post_filter_fx( PFSTAT_HANDLE hPFstat /* i : core decoder parameters */ ) { @@ -84,7 +84,7 @@ void Init_post_filter( * * Main routine to perform post filtering on NB synthesis *--------------------------------------------------------------------------*/ -void nb_post_filt( +void nb_post_filt_fx( const Word16 L_frame, /* i : frame length */ PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *psf_lp_noise, /* i : Long term noise Q8 */ @@ -111,7 +111,7 @@ void nb_post_filt( } } - modify_pst_param( *psf_lp_noise, &Post_G1, &Post_G2, coder_type, &Gain_factor ); + modify_pst_param_fx( *psf_lp_noise, &Post_G1, &Post_G2, coder_type, &Gain_factor ); if(hPFstat->reset) { @@ -149,7 +149,7 @@ void nb_post_filt( { T0_first = Pitch_buf[j]; - Dec_postfilt( hPFstat, T0_first, &Pf_in[i], p_Aq, &Synth[i], Post_G1, Post_G2, Gain_factor, disable_hpf ); + Dec_postfilt_fx( hPFstat, T0_first, &Pf_in[i], p_Aq, &Synth[i], Post_G1, Post_G2, Gain_factor, disable_hpf ); p_Aq += (M+1); j = add(j,1); @@ -182,7 +182,7 @@ void nb_post_filt( * 1. search around 1st subframe delay (3 integer values) * 2. search around best integer with fract. delays (1/8) *----------------------------------------------------------------------------*/ -static void Dec_postfilt( +static void Dec_postfilt_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ const Word16 t0, /* i : pitch delay given by coder */ const Word16 * signal_ptr, /* i : input signal (pointer to current subframe */ @@ -225,7 +225,7 @@ static void Dec_postfilt( IF (disable_hpf == 0) { - pst_ltp( t0, res2_ptr, sig_ltp_ptr, Gain_factor ); + pst_ltp_fx( t0, res2_ptr, sig_ltp_ptr, Gain_factor ); } ELSE { @@ -238,16 +238,16 @@ static void Dec_postfilt( move16(); /* Controls short term pst filter gain and compute parcor0 */ - calc_st_filt(apond2, apond1, &parcor0, sig_ltp_ptr, hPFstat->mem_zero ); + calc_st_filt_local_fx(apond2, apond1, &parcor0, sig_ltp_ptr, hPFstat->mem_zero ); E_UTIL_synthesis(1, apond1, sig_ltp_ptr, sig_ltp_ptr, L_SUBFR, hPFstat->mem_stp+L_SYN_MEM-M, 0, M); Copy( sig_ltp_ptr+L_SUBFR-L_SYN_MEM, hPFstat->mem_stp, L_SYN_MEM ); /* Tilt filtering */ - Filt_mu(sig_ltp, sig_out, parcor0, L_SUBFR); + Filt_mu_fx(sig_ltp, sig_out, parcor0, L_SUBFR); /* Gain control */ - scale_st(signal_ptr, sig_out, &hPFstat->gain_prec, L_SUBFR); + scale_st_fx(signal_ptr, sig_out, &hPFstat->gain_prec, L_SUBFR); /* Update for next subframe */ Copy(&res2[L_SUBFR], hPFstat->mem_res2, DECMEM_RES2); @@ -257,11 +257,11 @@ static void Dec_postfilt( } /*-------------------------------------------------------------------------- - * formant_post_filt: + * formant_post_filt_fx: * * Main routine to perform formant post filtering *--------------------------------------------------------------------------*/ -void formant_post_filt( +void formant_post_filt_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *synth_in, /* i : 12k8 synthesis */ Word16 *Aq, /* i : LP filter coefficient */ @@ -381,14 +381,14 @@ void formant_post_filt( p_Aq = Aq; FOR (i_subfr = 0; i_subfr < L_frame; i_subfr += L_SUBFR ) { - Dec_formant_postfilt(hPFstat, &synth_in[i_subfr], p_Aq, &synth_out[i_subfr], post_G1, post_G2 ); + Dec_formant_postfilt_fx(hPFstat, &synth_in[i_subfr], p_Aq, &synth_out[i_subfr], post_G1, post_G2 ); p_Aq += (M+1); } } #ifdef IVAS_FLOAT_FIXED -void formant_post_filt_fx( +void formant_post_filt_ivas_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *synth_in, /* i : 12k8 synthesis */ Word16 *Aq, /* i : LP filter coefficient */ @@ -508,13 +508,13 @@ void formant_post_filt_fx( p_Aq = Aq; FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_SUBFR ) { - Dec_formant_postfilt_fx( hPFstat, &synth_in[i_subfr], p_Aq, &synth_out[i_subfr], post_G1, post_G2 ); + Dec_formant_postfilt_ivas_fx( hPFstat, &synth_in[i_subfr], p_Aq, &synth_out[i_subfr], post_G1, post_G2 ); p_Aq += ( M + 1 ); } } #endif /*---------------------------------------------------------------------------- - * Dec_postfilt + * Dec_formant_postfilt_fx * * Post - adaptive postfilter main function * Short term postfilter : @@ -528,7 +528,7 @@ void formant_post_filt_fx( * k1 = 1st parcor calculated on {hi} * gamma3 = gamma3_minus if k1<0, gamma3_plus if k1>0 *----------------------------------------------------------------------------*/ -static void Dec_formant_postfilt( +static void Dec_formant_postfilt_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *signal_ptr, /* i : input signal (pointer to current subframe */ Word16 *coeff, /* i : LPC coefficients for current subframe */ @@ -576,7 +576,7 @@ static void Dec_formant_postfilt( } /* Controls short term pst filter gain and compute parcor0 */ - calc_st_filt(apond2, apond1, &parcor0, res2, hPFstat->mem_zero ); + calc_st_filt_local_fx(apond2, apond1, &parcor0, res2, hPFstat->mem_zero ); /* 1/A(gamma1) filtering, mem_stp is updated */ resynth[0] = *(hPFstat->mem_stp + sub(L_SYN_MEM, 1)); @@ -594,21 +594,21 @@ static void Dec_formant_postfilt( } /* Tilt filtering */ - Filt_mu(resynth, sig_out, parcor0, L_SUBFR); + Filt_mu_fx(resynth, sig_out, parcor0, L_SUBFR); IF (scale_down) { Scale_sig(sig_out, L_SUBFR, 1); } /* Gain control */ - scale_st(signal_ptr, sig_out, &hPFstat->gain_prec, L_SUBFR); + scale_st_fx(signal_ptr, sig_out, &hPFstat->gain_prec, L_SUBFR); return; } #ifdef IVAS_FLOAT_FIXED -static void Dec_formant_postfilt_fx( +static void Dec_formant_postfilt_ivas_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *signal_ptr, /* i : input signal (pointer to current subframe */ Word16 *coeff, /* i : LPC coefficients for current subframe */ @@ -656,7 +656,7 @@ static void Dec_formant_postfilt_fx( } /* Controls short term pst filter gain and compute parcor0 */ - calc_st_filt_fx(apond2, apond1, &parcor0, res2, hPFstat->mem_zero , -1 ); + calc_st_filt_ivas_fx(apond2, apond1, &parcor0, res2, hPFstat->mem_zero , -1 ); /* 1/A(gamma1) filtering, mem_stp is updated */ resynth[0] = *(hPFstat->mem_stp + sub(L_SYN_MEM, 1)); @@ -674,14 +674,14 @@ static void Dec_formant_postfilt_fx( } /* Tilt filtering */ - Filt_mu_fx(resynth, sig_out, parcor0, L_SUBFR , -1); + Filt_mu_ivas_fx(resynth, sig_out, parcor0, L_SUBFR , -1); IF(scale_down) { Scale_sig(sig_out, L_SUBFR, 1); } /* Gain control */ - scale_st(signal_ptr, sig_out, &hPFstat->gain_prec, L_SUBFR); + scale_st_fx(signal_ptr, sig_out, &hPFstat->gain_prec, L_SUBFR); return; @@ -694,7 +694,7 @@ static void Dec_formant_postfilt_fx( * Modify gamma1 and gamma2 values in function of the long term noise level *-----------------------------------------------------------------------------------*/ -static void modify_pst_param( +static void modify_pst_param_fx( const Word16 lp_noise, /* i : Long term noise energy Q8 */ Word16 *g1, /* o : Gamma1 used in post filter Q15 */ Word16 *g2, /* o : Gamma1 used in post filter Q15 */ @@ -758,11 +758,11 @@ static void modify_pst_param( } /*---------------------------------------------------------------------------- - * pst_ltp + * pst_ltp_fx * * Perform harmonic postfilter *----------------------------------------------------------------------------*/ -static void pst_ltp( +static void pst_ltp_fx( Word16 t0, /* i : pitch delay given by coder */ Word16 * ptr_sig_in, /* i : postfilter i filter (residu2) */ Word16 * ptr_sig_pst0, /* o : harmonic postfilter o */ @@ -808,7 +808,7 @@ static void pst_ltp( ptr_sig_cadr = sig_cadr + DECMEM_RES2; /* Sub optimal delay search */ - search_del(t0, ptr_sig_cadr, <pdel, &phase, &num_gltp, &den_gltp, &sh_num, &sh_den, y_up, &off_yup); + search_del_fx(t0, ptr_sig_cadr, <pdel, &phase, &num_gltp, &den_gltp, &sh_num, &sh_den, y_up, &off_yup); IF (num_gltp == 0) @@ -824,10 +824,10 @@ static void pst_ltp( ELSE { /* Filtering with long filter */ - compute_ltp_l(ptr_sig_cadr, ltpdel, phase, ptr_sig_pst0, &num2_gltp, &den2_gltp, &sh_num2, &sh_den2); + compute_ltp_l_fx(ptr_sig_cadr, ltpdel, phase, ptr_sig_pst0, &num2_gltp, &den2_gltp, &sh_num2, &sh_den2); - IF (EQ_16(select_ltp(num_gltp, den_gltp, sh_num, sh_den, num2_gltp, den2_gltp, sh_num2, sh_den2), 1)) + IF (EQ_16(select_ltp_fx(num_gltp, den_gltp, sh_num, sh_den, num2_gltp, den2_gltp, sh_num2, sh_den2), 1)) { /* select short filter */ temp = sub(phase, 1); @@ -901,17 +901,17 @@ static void pst_ltp( #endif /** filtering by H0(z) = harmonic filter **/ - filt_plt(ptr_sig_in, ptr_y_up, ptr_sig_pst0, gain_plt); + filt_plt_fx(ptr_sig_in, ptr_y_up, ptr_sig_pst0, gain_plt); } } /*---------------------------------------------------------------------------- - * search_del: + * search_del_fx: * * Computes best (shortest) integer LTP delay + fine search *---------------------------------------------------------------------------*/ -static void search_del( +static void search_del_fx( Word16 t0, /* i : pitch delay given by coder */ Word16 * ptr_sig_in, /* i : i signal (with delay line) */ Word16 * ltpdel, /* o : delay = *ltpdel - *phase / f_up */ @@ -1366,11 +1366,11 @@ static void search_del( } /*---------------------------------------------------------------------------- - * filt_plt: + * filt_plt_fx: * * Perform long term postfilter *----------------------------------------------------------------------------*/ -static void filt_plt( +static void filt_plt_fx( Word16 * s_in, /* i : i signal with past */ Word16 * s_ltp, /* i : filtered signal with gain 1 */ Word16 * s_out, /* o : signal */ @@ -1402,12 +1402,12 @@ static void filt_plt( /*---------------------------------------------------------------------------- - * compute_ltp_l : + * compute_ltp_l_fx : * * compute delayed signal, num & den of gain for fractional delay * with long interpolation filter *----------------------------------------------------------------------------*/ -static void compute_ltp_l( +static void compute_ltp_l_fx( Word16 * s_in, /* i/o: signal with past */ Word16 ltpdel, /* i : delay factor */ Word16 phase, /* i : phase factor */ @@ -1489,13 +1489,13 @@ static void compute_ltp_l( } /*---------------------------------------------------------------------------- - * select_ltp: + * select_ltp_fx: * * selects best of (gain1, gain2) * with gain1 = num1 * 2** sh_num1 / den1 * 2** sh_den1 * and gain2 = num2 * 2** sh_num2 / den2 * 2** sh_den2 *----------------------------------------------------------------------------*/ -static Word16 select_ltp( /* o : 1 = 1st gain, 2 = 2nd gain */ +static Word16 select_ltp_fx( /* o : 1 = 1st gain, 2 = 2nd gain */ Word16 num1, /* i : numerator of gain1 */ Word16 den1, /* i : denominator of gain1 */ Word16 sh_num1, /* i : just. factor for num1 */ @@ -1554,13 +1554,13 @@ static Word16 select_ltp( /* o : 1 = 1st gain, 2 = 2nd gain */ } /*---------------------------------------------------------------------------- - * calc_st_filt + * calc_st_filt_local_fx * * computes impulse response of A(gamma2) / A(gamma1) * controls gain : computation of energy impulse response as * SUMn (abs (h[n])) and computes parcor0 *---------------------------------------------------------------------------- */ -static void calc_st_filt( +static void calc_st_filt_local_fx( Word16 * apond2, /* i : coefficients of numerator */ Word16 * apond1, /* i : coefficients of denominator */ Word16 * parcor0, /* o : 1st parcor calcul. on composed filter */ @@ -1608,7 +1608,7 @@ static void calc_st_filt( } #ifdef IVAS_FLOAT_FIXED -static void calc_st_filt_fx( +static void calc_st_filt_ivas_fx( Word16 * apond2, /* i : coefficients of numerator */ Word16 * apond1, /* i : coefficients of denominator */ Word16 * parcor0, /* o : 1st parcor calcul. on composed filter */ @@ -1668,7 +1668,7 @@ static void calc_st_filt_fx( * tilt filtering with : (1 + mu z-1) * (1/1-|mu|) * computes y[n] = (1/1-|mu|) (x[n]+mu*x[n-1]) *---------------------------------------------------------------------------*/ -void Filt_mu( +void Filt_mu_fx( Word16 * sig_in, /* i : signal (beginning at sample -1) */ Word16 * sig_out, /* o : signal with tilt */ Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ @@ -1748,7 +1748,7 @@ void Filt_mu( } #ifdef IVAS_FLOAT_FIXED -void Filt_mu_fx( +void Filt_mu_ivas_fx( Word16 * sig_in, /* i : signal (beginning at sample -1) */ Word16 * sig_out, /* o : signal with tilt */ Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ @@ -1851,12 +1851,12 @@ void Filt_mu_fx( } #endif /*---------------------------------------------------------------------------- - * scale_st() + * scale_st_fx() * * control of the subframe gain * gain[n] = AGC_FAC_FX * gain[n-1] + (1 - AGC_FAC_FX) g_in/g_out *---------------------------------------------------------------------------*/ -void scale_st( +void scale_st_fx( const Word16 * sig_in, /* i : postfilter i signal */ Word16 * sig_out, /* i/o: postfilter o signal */ Word16 * gain_prec, /* i/o: last value of gain for subframe */ @@ -1961,12 +1961,12 @@ void scale_st( } /*---------------------------------------------------------------------------- - * blend_subfr2() + * blend_subfr2_fx() * * *---------------------------------------------------------------------------*/ -void blend_subfr2( +void blend_subfr2_fx( Word16 *sigIn1, Word16 *sigIn2, Word16 *sigOut @@ -1994,4 +1994,4 @@ void blend_subfr2( return; } - +#endif diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 89f39045a9d54491143fbdfdf6fc8b7daff02c49..3831b1d78f60177933a64600b494c4f86072009d 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -2429,8 +2429,6 @@ void generate_stereo_masking_noise_16fx( IF(st->idchan == 0) { hFdCngCom = st->hFdCngDec->hFdCngCom; - // mvr2r(hStereoCng->olapBufferSynth22, Ns, hFdCngCom->frameSize / 2); - // mvr2r(hFdCngCom->olapBufferSynth2_flt, Np, hFdCngCom->frameSize / 2); Copy_Scale_sig_16_32( hStereoCng->olapBufferSynth22_fx, Ns_fx, hFdCngCom->frameSize / 2, Q6 - st->Q_syn ); Copy32(hFdCngCom->olapBufferSynth2_fx, Np_fx, hFdCngCom->frameSize / 2); @@ -2500,9 +2498,6 @@ void generate_stereo_masking_noise_16fx( } } /* Below code to be converted */ - //float gamma = fix_to_float(gamma_fx, Q30); - //float scale = fix_to_float(scale_fx, Q30); - //scale *= (float)(hFdCngCom->fftlen / 2); Word32 scale_fx_tmp = Mpy_32_32(scale_fx, L_shl(hFdCngCom->fftlen / 2, Q22)); // Q21 // scale_fx = L_shr(scale_fx, Q1) * hFdCngCom->fftlen; for (i = 0; i < hFdCngCom->frameSize / 2; i++) @@ -2547,8 +2542,6 @@ void generate_stereo_masking_noise_16fx( } if (flag_sec_CNA) { - // mvr2r(Ns, hStereoCng->maskingNoiseS, hFdCngCom->frameSize); - //Copy(Ns_fx, hStereoCng->maskingNoiseS_fx, hFdCngCom->frameSize); // Q6 Copy_Scale_sig_32_16(Ns_fx, hStereoCng->maskingNoiseS_fx, hFdCngCom->frameSize, 0); // Q6 hStereoCng->enableSecCNA = 1; } @@ -2566,14 +2559,15 @@ void generate_stereo_masking_noise_16fx( } else if (hStereoCng->enableSecCNA) { - //float SP_ratio = hStereoTD->SP_ratio_LT; /* Use long-term SP ratio based on L/R synthesis */ - Word16 SP_ratio_fx = float_to_fix16(hStereoTD->SP_ratio_LT, Q15); /* Use long-term SP ratio based on L/R synthesis */ - Word16 prevSP_ratio_fx = float_to_fix16(hStereoTD->prevSP_ratio, Q15); /* Use long-term SP ratio based on L/R synthesis */ + Word16 SP_ratio_fx = extract_h( hStereoTD->SP_ratio_LT_fx ); /* Use long-term SP ratio based on L/R synthesis */ + Word16 prevSP_ratio_fx = hStereoTD->prevSP_ratio_fx; /* Use long-term SP ratio based on L/R synthesis */ /* scale and add masking noise */ for (i = 0; i < *hStereoCng->frameSize / 4; i++) { - //float scale = ( ( hStereoTD->prevSP_ratio * ( *hStereoCng->frameSize / 4 - (float) i ) + SP_ratio * (float) i ) / ( *hStereoCng->frameSize / 4 ) ); - Word16 scale_fx_tmp = (Word16)(((Word32)prevSP_ratio_fx * (*hStereoCng->frameSize / 4 - i) + SP_ratio_fx * i) / (*hStereoCng->frameSize / 4)); //Q15 + //Word16 scale_fx_tmp = idiv1616( add( imult1616( prevSP_ratio_fx, sub( shr( *hStereoCng->frameSize, 2 ), i ) ), imult1616( SP_ratio_fx, i ) ), shr( *hStereoCng->frameSize, 2 ) ); // Q15 + Word16 s; + Word16 scale_fx_tmp = BASOP_Util_Divide3216_Scale( L_add( L_mult0( prevSP_ratio_fx, sub( shr( *hStereoCng->frameSize, 2 ), i ) ), L_mult0( SP_ratio_fx, i ) ), shr( *hStereoCng->frameSize, 2 ), &s ); // Q15 + scale_fx_tmp = shl(scale_fx_tmp, s); //syn[i] += scale * hStereoCng->maskingNoiseS[i]; syn[i] = add( syn[i], mult( scale_fx_tmp, shr( hStereoCng->maskingNoiseS_fx[i], Q6 - Q_syn ) ) ); } @@ -2587,7 +2581,7 @@ void generate_stereo_masking_noise_16fx( //syn[i] += SP_ratio * hStereoCng->maskingNoiseS[i]; syn[i] = add( syn[i], mult( SP_ratio_fx, shr( hStereoCng->maskingNoiseS_fx[i], Q6 - Q_syn ) ) ); } - hStereoTD->prevSP_ratio = hStereoTD->SP_ratio_LT; + hStereoTD->prevSP_ratio_fx = extract_h(hStereoTD->SP_ratio_LT_fx); } return; diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c index b753b84d53e9f8b87f21f59e9fcc6f37ceb5142b..04d294df1ef5ffa792570d8d8f43b3b8c5d72304 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -273,7 +273,7 @@ ivas_error init_decoder( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for NB/formant postflter\n" ) ); } #ifdef IVAS_FLOAT_FIXED - Init_post_filter(st->hPFstat);//fixed + Init_post_filter_fx(st->hPFstat);//fixed st->psf_lp_noise_fx = 0; /*to be cleaned up*/ Init_post_filter_ivas(st->hPFstat); diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 6d567deb96239928bd525beeed87022f69e8e507..880628a176ccaef805ff32e27c7458ff7acbaf36 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -249,7 +249,7 @@ ivas_error init_decoder_fx( return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for NB/formant postflter\n")); } - Init_post_filter(st_fx->hPFstat); + Init_post_filter_fx(st_fx->hPFstat); st_fx->psf_lp_noise_fx = 0; } ELSE @@ -1253,7 +1253,7 @@ ivas_error init_decoder_ivas_fx( Init_post_filter_ivas(st_fx->hPFstat); st_fx->psf_lp_noise = 0.0f; #endif - Init_post_filter(st_fx->hPFstat); + Init_post_filter_fx(st_fx->hPFstat); st_fx->psf_lp_noise_fx = 0; } ELSE diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 06f6ae2a6706ba7071c1c30071a65f49722a4c8a..df70e04c156f07f0557b2501e758881cc43e229c 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -5300,8 +5300,131 @@ void ivas_dirac_dec_render_sf( index_slot = slot_idx_start_cldfb_synth; +#ifdef IVAS_FLOAT_FIXED + Word16 cldfb_re_q = Q_factor_arrL((float *)Cldfb_RealBuffer, MAX_OUTPUT_CHANNELS*MAX_PARAM_SPATIAL_SUBFRAMES*CLDFB_NO_CHANNELS_MAX); + Word16 cldfb_im_q = Q_factor_arrL((float *)Cldfb_ImagBuffer, MAX_OUTPUT_CHANNELS*MAX_PARAM_SPATIAL_SUBFRAMES*CLDFB_NO_CHANNELS_MAX); + for (int idx1 = 0; idx1 < MAX_OUTPUT_CHANNELS; idx1++) + { + for (int idx2 = 0; idx2 < MAX_PARAM_SPATIAL_SUBFRAMES; idx2++) + { + for (int idx3 = 0; idx3 < CLDFB_NO_CHANNELS_MAX; idx3++) + { + Cldfb_RealBuffer_fx[idx1][idx2][idx3] = floatToFixed(Cldfb_RealBuffer[idx1][idx2][idx3], cldfb_re_q); + Cldfb_ImagBuffer_fx[idx1][idx2][idx3] = floatToFixed(Cldfb_ImagBuffer[idx1][idx2][idx3], cldfb_im_q); + + } + } + } +#endif + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { +#ifdef IVAS_FLOAT_FIXED + // Float to fixed + Word32 output_buf_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + for (i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++) + { + floatToFixed_arrL(output_f[i], output_buf_fx[i], Q11, L_FRAME48k); + } +#endif + +#ifdef IVAS_FLOAT_FIXED + /* render objects in combined format onto the CICP19 channels for BINAURAL_ROOM_IR */ + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + int16_t in_ch; + for ( in_ch = 0; in_ch < st_ivas->nchan_ism; in_ch++ ) + { + Word16 j, k, j2, l; + Word16 num_objects, nchan_out_woLFE, lfe_index; + Word16 az1, el1; + Word16 n_slots_to_render; + Word16 n_samples_to_render; + Word16 interp_offset; + + Word32 gain_fx, prev_gain_fx; + + num_objects = st_ivas->nchan_ism; + move16(); + nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; + move16(); + n_slots_to_render = st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->subframes_rendered]; + move16(); + n_samples_to_render = imult1616( hSpatParamRendCom->num_freq_bands, n_slots_to_render ); + interp_offset = st_ivas->hTcBuffer->n_samples_rendered; + move16(); + + IF( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] ) + { + ivas_jbm_dec_get_adapted_linear_interpolator_fx( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator_fx ); + interp_offset = 0; + move16(); + } + FOR( i = 0; i < num_objects; i++ ) + { + /* Combined rotation: rotate the object positions depending the head and external orientations */ + IF( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) + { + Word16 az_q0 = extract_l( L_shr( st_ivas->hIsmMetaData[i]->azimuth_fx, Q22 ) ); + Word16 el_q0 = extract_l( L_shr( st_ivas->hIsmMetaData[i]->elevation_fx, Q22 ) ); + Word32 az1_32, el1_32; + rotateAziEle_fixed( az_q0, el_q0, &az1_32, &el1_32, st_ivas->hCombinedOrientationData->Rmat_fx[0], st_ivas->hIntSetup.is_planar_setup ); + az1 = extract_h( az1_32 ); + el1 = extract_h( el1_32 ); + + IF( st_ivas->hEFAPdata != NULL ) + { + const Word32 azi_fx = L_shl( az1, Q22 ); // Q0 -> Q22 + const Word32 ele_fx = L_shl( el1, Q22 ); // Q0 -> Q22 + efap_determine_gains_fixed( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], azi_fx, ele_fx, EFAP_MODE_EFAP ); + } + } + + lfe_index = 0; + move16(); + for ( j = 0, j2 = 0; j < nchan_out_woLFE; j++, j2++ ) + { + IF( ( st_ivas->hIntSetup.num_lfe > 0 ) && ( EQ_16( st_ivas->hIntSetup.index_lfe[lfe_index], j ) ) ) + { + ( lfe_index < ( st_ivas->hIntSetup.num_lfe - 1 ) ) ? ( lfe_index++, j2++ ) : j2++; + } + gain_fx = st_ivas->hIsmRendererData->gains_fx[i][j]; + prev_gain_fx = st_ivas->hIsmRendererData->prev_gains_fx[i][j]; + IF( L_abs( gain_fx ) > 0 || L_abs( prev_gain_fx ) > 0 ) + { + Word32 *tc_re_fx, *tc_im_fx; + Word16 *w1_fx, w2_fx; + w1_fx = &st_ivas->hIsmRendererData->interpolator_fx[interp_offset]; + tc_re_fx = pppQMfFrame_ts_re_fx[nchan_transport + i][0]; + tc_im_fx = pppQMfFrame_ts_im_fx[nchan_transport + i][0]; + FOR( k = 0; k < n_slots_to_render; k++ ) + { + Word32 g_fx; + w2_fx = sub( MAX16B, *w1_fx ); + g_fx = L_add( Mpy_32_16_1( gain_fx, *w1_fx ), Mpy_32_16_1( prev_gain_fx, w2_fx ) ); + FOR( l = 0; l < hSpatParamRendCom->num_freq_bands; l++ ) + { + Word32 tmp; + tmp = Mpy_32_32( g_fx, *tc_re_fx ); + Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = L_add( Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], tmp ); + tc_re_fx++; + tmp = Mpy_32_32( g_fx, *tc_im_fx ); + Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = L_add( Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], tmp ); + tc_re_fx++; + } + w1_fx += hSpatParamRendCom->num_freq_bands; + } + } + /* update here only in case of head rotation */ + IF( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) + { + st_ivas->hIsmRendererData->prev_gains_fx[i][j] = gain_fx; + } + } + } + } + } +#else /* render objects in combined format onto the CICP19 channels for BINAURAL_ROOM_IR */ if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { @@ -5314,6 +5437,7 @@ void ivas_dirac_dec_render_sf( int16_t n_slots_to_render; int16_t n_samples_to_render; int16_t interp_offset; + float gain, prev_gain; num_objects = st_ivas->nchan_ism; @@ -5331,7 +5455,6 @@ void ivas_dirac_dec_render_sf( #endif interp_offset = 0; } - for ( i = 0; i < num_objects; i++ ) { /* Combined rotation: rotate the object positions depending the head and external orientations */ @@ -5357,13 +5480,7 @@ void ivas_dirac_dec_render_sf( #endif if ( st_ivas->hEFAPdata != NULL ) { -#ifdef IVAS_FLOAT_FIXED - float gains[MAX_OUTPUT_CHANNELS]; - fixedToFloat_arrL(st_ivas->hIsmRendererData->gains_fx[i], gains, Q30, MAX_OUTPUT_CHANNELS); - efap_determine_gains( st_ivas->hEFAPdata, gains, az1, el1, EFAP_MODE_EFAP ); -#else efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], az1, el1, EFAP_MODE_EFAP ); -#endif } } @@ -5374,93 +5491,155 @@ void ivas_dirac_dec_render_sf( { ( lfe_index < ( st_ivas->hIntSetup.num_lfe - 1 ) ) ? ( lfe_index++, j2++ ) : j2++; } - -#ifdef IVAS_FLOAT_FIXED - gain = fix_to_float( st_ivas->hIsmRendererData->gains_fx[i][j], Q30 ); - prev_gain = fix_to_float( st_ivas->hIsmRendererData->prev_gains_fx[i][j], Q30 ); -#else gain = st_ivas->hIsmRendererData->gains[i][j]; prev_gain = st_ivas->hIsmRendererData->prev_gains[i][j]; -#endif if ( fabsf( gain ) > 0.0f || fabsf( prev_gain ) > 0.0f ) { float *tc_re, *tc_im; float *w1, w2; - -#ifdef IVAS_FLOAT_FIXED - Word16 *w1_fx; - w1_fx = &st_ivas->hIsmRendererData->interpolator_fx[interp_offset]; -#else w1 = &st_ivas->hIsmRendererData->interpolator[interp_offset]; -#endif tc_re = pppQMfFrame_ts_re[nchan_transport + i][0]; tc_im = pppQMfFrame_ts_im[nchan_transport + i][0]; - for ( k = 0; k < n_slots_to_render; k++ ) { float g; - -#ifdef IVAS_FLOAT_FIXED - w2 = 1.0f - fix16_to_float(*w1_fx, Q15); - g = ( fix16_to_float(*w1_fx, Q15) * gain + w2 * prev_gain ); -#else w2 = 1.0f - *w1; - g = (*w1 * gain + w2 * prev_gain); -#endif + g = ( *w1 * gain + w2 * prev_gain ); for ( l = 0; l < hSpatParamRendCom->num_freq_bands; l++ ) { Cldfb_RealBuffer[j2][0][k * hSpatParamRendCom->num_freq_bands + l] += g * *( tc_re++ ); Cldfb_ImagBuffer[j2][0][k * hSpatParamRendCom->num_freq_bands + l] += g * *( tc_im++ ); } -#ifdef IVAS_FLOAT_FIXED - w1_fx += hSpatParamRendCom->num_freq_bands; -#else w1 += hSpatParamRendCom->num_freq_bands; -#endif } } - /* update here only in case of head rotation */ if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) { -#ifdef IVAS_FLOAT_FIXED - st_ivas->hIsmRendererData->prev_gains_fx[i][j] = float_to_fix(gain, Q30); -#else st_ivas->hIsmRendererData->prev_gains[i][j] = gain; -#endif } } } } } - +#endif /* Perform binaural rendering */ ivas_binRenderer( st_ivas->hBinRenderer, - st_ivas->hCombinedOrientationData, hSpatParamRendCom->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); +#ifdef IVAS_FLOAT_FIXED + Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; // cldfb_re_bin_q + Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; // cldfb_im_bin_q + + Word16 cldfb_re_bin_q, cldfb_im_bin_q; + cldfb_re_bin_q = Q6;//Q_factor_arrL( (float *)Cldfb_RealBuffer_Binaural, BINAURAL_CHANNELS*MAX_PARAM_SPATIAL_SUBFRAMES*CLDFB_NO_CHANNELS_MAX ); + cldfb_im_bin_q = Q6;//Q_factor_arrL( (float *)Cldfb_ImagBuffer_Binaural, BINAURAL_CHANNELS*MAX_PARAM_SPATIAL_SUBFRAMES*CLDFB_NO_CHANNELS_MAX ); + for (int idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++) + { + for (int idx2 = 0; idx2 < MAX_PARAM_SPATIAL_SUBFRAMES; idx2++) + { + for (int idx3 = 0; idx3 < CLDFB_NO_CHANNELS_MAX; idx3++) + { + Cldfb_RealBuffer_Binaural_fx[idx1][idx2][idx3] = float_to_fix(Cldfb_RealBuffer_Binaural[idx1][idx2][idx3], cldfb_re_bin_q); + Cldfb_ImagBuffer_Binaural_fx[idx1][idx2][idx3] = float_to_fix(Cldfb_ImagBuffer_Binaural[idx1][idx2][idx3], cldfb_im_bin_q); + + } + } + } +#endif + /* Inverse CLDFB*/ for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) { /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ - float *RealBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; - float *ImagBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; +#ifdef IVAS_FLOAT_FIXED + Word32 *synth_fx = &output_buf_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands]; + st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q_factor_arrL( st_ivas->cldfbSynDec[ch]->cldfb_state, st_ivas->cldfbSynDec[ch]->p_filter_length ); + floatToFixed_arrL( st_ivas->cldfbSynDec[ch]->cldfb_state, st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->Q_cldfb_state, st_ivas->cldfbSynDec[ch]->p_filter_length ); + + Word32 *RealBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; + Word32 *ImagBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; + FOR ( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) + { + RealBuffer_fx[i] = Cldfb_RealBuffer_Binaural_fx[ch][i]; + ImagBuffer_fx[i] = Cldfb_ImagBuffer_Binaural_fx[ch][i]; + } + Word16 common_q = sub( s_min( cldfb_re_bin_q, cldfb_im_bin_q ), 1 ); // 1 guard bit. + FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) + { + scale_sig32( RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sub( common_q, cldfb_re_bin_q ) ); + scale_sig32( ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sub( common_q, cldfb_im_bin_q ) ); + } + cldfb_re_bin_q = common_q; + move16(); + cldfb_im_bin_q = common_q; + move16(); + + scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub( sub( common_q, 1 ), st_ivas->cldfbSynDec[ch]->Q_cldfb_state ) ); + st_ivas->cldfbSynDec[ch]->Q_cldfb_state = sub( common_q, 1 ); + + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, synth_fx, hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch] ); + + Word16 no_col = st_ivas->cldfbSynDec[ch]->no_col, no_channels = st_ivas->cldfbSynDec[ch]->no_channels; + Word16 samplesToProcess = hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx]; + IF( GT_16( samplesToProcess, -1 ) ) + { + no_col = s_min( no_col, ( samplesToProcess + st_ivas->cldfbSynDec[ch]->no_channels - 1 ) / st_ivas->cldfbSynDec[ch]->no_channels ); + } + Word16 synth_len = imult1616( no_col, no_channels ); + + scale_sig32( synth_fx, synth_len, sub( Q11, sub( common_q, 1 ) ) ); + for (i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++) + { + scale_sig32(RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sub( Q6, common_q ) ); + scale_sig32(ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sub( Q6, common_q ) ); + } + cldfb_re_bin_q = Q6; + cldfb_im_bin_q = Q6; + // Fixed to float + fixedToFloat_arrL( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_state, st_ivas->cldfbSynDec[ch]->Q_cldfb_state, st_ivas->cldfbSynDec[ch]->p_filter_length ); for ( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) + { + fixedToFloat_arrL( Cldfb_RealBuffer_Binaural_fx[ch][i], Cldfb_RealBuffer_Binaural[ch][i], CLDFB_NO_CHANNELS_MAX, Q6 ); + fixedToFloat_arrL( Cldfb_ImagBuffer_Binaural_fx[ch][i], Cldfb_ImagBuffer_Binaural[ch][i], CLDFB_NO_CHANNELS_MAX, Q6 ); + } +#else + float *RealBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; + float *ImagBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; + for (i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++) { RealBuffer[i] = Cldfb_RealBuffer_Binaural[ch][i]; ImagBuffer[i] = Cldfb_ImagBuffer_Binaural[ch][i]; } - cldfbSynthesis_ivas( RealBuffer, ImagBuffer, &( output_f[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch] ); +#endif + } +#ifdef IVAS_FLOAT_FIXED + for (i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++) + { + fixedToFloat_arrL(output_buf_fx[i], output_f[i], Q11, index_slot * hSpatParamRendCom->num_freq_bands + hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx]); } +#endif } else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { +#ifdef IVAS_FLOAT_FIXED + for ( ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE; ch++ ) + { + for ( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) + { + Copy32( Cldfb_RealBuffer_fx[ch][slot_idx], pppQMfFrame_ts_re_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands ); + Copy32( Cldfb_ImagBuffer_fx[ch][slot_idx], pppQMfFrame_ts_im_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands ); + scale_sig32( pppQMfFrame_ts_re_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( Q6, cldfb_re_q ) ); + scale_sig32( pppQMfFrame_ts_im_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( Q6, cldfb_im_q ) ); + } + } +#else for ( ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE; ch++ ) { for ( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) @@ -5469,9 +5648,34 @@ void ivas_dirac_dec_render_sf( mvr2r( Cldfb_ImagBuffer[ch][slot_idx], pppQMfFrame_ts_im[ch][slot_idx], hSpatParamRendCom->num_freq_bands ); } } +#endif } else { +#ifdef IVAS_FLOAT_FIXED + float *RealBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; + float *ImagBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; + Word32 *RealBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; + Word32 *ImagBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; + Word16 outchannels; + + idx_in = 0; + move16(); + idx_lfe = 0; + move16(); + + outchannels = add( hDirACRend->hOutSetup.nchan_out_woLFE, hDirACRend->hOutSetup.num_lfe ); + + if ( hDirACRend->hOutSetup.separateChannelEnabled && ( hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_5_1 || + hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_7_1 || + hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_5_1_2 || + hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_5_1_4 || + hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_7_1_4 || + ( hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hLsSetupCustom->separate_ch_found ) ) ) + { + outchannels = add(outchannels, 1); + } +#else float *RealBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; float *ImagBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; int16_t outchannels; @@ -5480,6 +5684,7 @@ void ivas_dirac_dec_render_sf( idx_lfe = 0; outchannels = hDirACRend->hOutSetup.nchan_out_woLFE + hDirACRend->hOutSetup.num_lfe; + if ( hDirACRend->hOutSetup.separateChannelEnabled && ( hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_5_1 || hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_7_1 || hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_5_1_2 || @@ -5489,9 +5694,67 @@ void ivas_dirac_dec_render_sf( { outchannels++; } +#endif + +#ifdef IVAS_FLOAT_FIXED + // Float to fixed + Word32 output_buf_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + for (i = 0; i < outchannels; i++) + { + floatToFixed_arrL(output_f[i], output_buf_fx[i], Q11, L_FRAME48k); + } +#endif if ( hDirACRend->hOutSetup.separateChannelEnabled && hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { +#ifdef IVAS_FLOAT_FIXED + Word32 tmp_separated_fx[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; + Word32 tmp_lfe_fx[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; + const Word16 subframe_start_sample = imult1616( index_slot, hSpatParamRendCom->num_freq_bands ); + const Word16 num_samples_subframe = imult1616( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); + + /* Move the separated and the LFE channels to temporary variables as spatial synthesis may overwrite current channels */ + Copy32( &( output_buf_fx[st_ivas->hOutSetup.separateChannelIndex][subframe_start_sample] ), tmp_separated_fx, num_samples_subframe ); + Copy32( &( output_buf_fx[LFE_CHANNEL][subframe_start_sample] ), tmp_lfe_fx, num_samples_subframe ); + FOR( ch = 0; ch < outchannels; ch++ ) + { + IF( ( hDirACRend->hOutSetup.num_lfe > 0 ) && ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) + { + /* Move the LFE channel to the correct place */ + Copy32( tmp_lfe_fx, &( output_buf_fx[ch][subframe_start_sample] ), num_samples_subframe ); + + IF( LT_16( idx_lfe, sub( hDirACRend->hOutSetup.num_lfe, 1 ) ) ) + { + idx_lfe = add( idx_lfe, 1 ); + } + } + ELSE IF( ( st_ivas->hLsSetupCustom->separate_ch_found ) && EQ_16( hDirACRend->hOutSetup.separateChannelIndex, ch ) ) + { + /* Move the separated channel to the correct place. Thus, the separated channel is + * combined with the synthesized channels here when there is a matching channel. */ + Copy32( tmp_separated_fx, &( output_buf_fx[ch][subframe_start_sample] ), num_samples_subframe ); + } + ELSE + { + /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ + FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) + { + RealBuffer_fx[i] = Cldfb_RealBuffer_fx[idx_in][i]; + ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[idx_in][i]; + } + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_buf_fx[ch][subframe_start_sample] ), num_samples_subframe, st_ivas->cldfbSynDec[idx_in] ); + + IF( !st_ivas->hLsSetupCustom->separate_ch_found ) + { + /* Pan the separated channel and mix with the synthesized channels. Thus, the separated channel + * is combined with the synthesized channels here when there is no matching channel. */ + v_multc_acc_32_16( tmp_separated_fx, st_ivas->hLsSetupCustom->separate_ch_gains_fx[idx_in], &( output_buf_fx[ch][subframe_start_sample] ), num_samples_subframe ); + } + + idx_in = add( idx_in, 1 ); + } + } +#else float tmp_separated[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; float tmp_lfe[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; const int16_t subframe_start_sample = index_slot * hSpatParamRendCom->num_freq_bands; @@ -5500,7 +5763,6 @@ void ivas_dirac_dec_render_sf( /* Move the separated and the LFE channels to temporary variables as spatial synthesis may overwrite current channels */ mvr2r( &( output_f[st_ivas->hOutSetup.separateChannelIndex][subframe_start_sample] ), tmp_separated, num_samples_subframe ); mvr2r( &( output_f[LFE_CHANNEL][subframe_start_sample] ), tmp_lfe, num_samples_subframe ); - for ( ch = 0; ch < outchannels; ch++ ) { if ( ( hDirACRend->hOutSetup.num_lfe > 0 ) && ( hDirACRend->hOutSetup.index_lfe[idx_lfe] == ch ) ) @@ -5539,6 +5801,7 @@ void ivas_dirac_dec_render_sf( idx_in++; } } +#endif } else { @@ -5552,8 +5815,57 @@ void ivas_dirac_dec_render_sf( { RealBuffer[i] = Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS - 1][i]; ImagBuffer[i] = Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS - 1][i]; +#ifdef IVAS_FLOAT_FIXED + RealBuffer_fx[i] = Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS - 1][i]; + ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS - 1][i]; +#endif + } +#ifdef IVAS_FLOAT_FIXED + // Float to fixed. + st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q_factor_arrL(st_ivas->cldfbSynDec[ch]->cldfb_state, st_ivas->cldfbSynDec[ch]->p_filter_length); + floatToFixed_arrL(st_ivas->cldfbSynDec[ch]->cldfb_state, st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->Q_cldfb_state, st_ivas->cldfbSynDec[ch]->p_filter_length); + + + Word32 *p_out = &(output_buf_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands]); + Word16 common_q; + common_q = sub( s_min( cldfb_re_q, cldfb_im_q ), 1 ); // 1 guard bit + FOR(i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++) + { + scale_sig32(RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sub(common_q, cldfb_re_q)); + scale_sig32(ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sub(common_q, cldfb_im_q)); + } + cldfb_re_q = common_q; + move16(); + cldfb_im_q = common_q; + move16(); + + Word16 samplesToProcess = hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx]; + + scale_sig32(st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub(sub(common_q, 1), st_ivas->cldfbSynDec[ch]->Q_cldfb_state)); + st_ivas->cldfbSynDec[ch]->Q_cldfb_state = sub(common_q, 1); + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, st_ivas->cldfbSynDec[hDirACRend->hOutSetup.nchan_out_woLFE + idx_lfe] ); + + // Calculating length of output + Word16 no_col = st_ivas->cldfbSynDec[ch]->no_col, no_channels = st_ivas->cldfbSynDec[ch]->no_channels; + IF(GT_16(samplesToProcess, -1)) + { + no_col = s_min(no_col, (samplesToProcess + st_ivas->cldfbSynDec[ch]->no_channels - 1) / st_ivas->cldfbSynDec[ch]->no_channels); + } + Word16 synth_len = imult1616(no_col, no_channels); + + scale_sig32(p_out, synth_len, sub(Q11, sub(common_q, 1))); + + // Fixed to float + fixedToFloat_arrL(st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_state, st_ivas->cldfbSynDec[ch]->Q_cldfb_state, st_ivas->cldfbSynDec[ch]->p_filter_length); + for (i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++) + { + fixedToFloat_arrL(Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS - 1][i], Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS - 1][i], CLDFB_NO_CHANNELS_MAX, cldfb_re_q); + fixedToFloat_arrL(Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS - 1][i], Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS - 1][i], CLDFB_NO_CHANNELS_MAX, cldfb_im_q); } + fixedToFloat_arrL(output_buf_fx[ch], output_f[ch], Q11, L_FRAME48k); +#else cldfbSynthesis_ivas( RealBuffer, ImagBuffer, &( output_f[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[hDirACRend->hOutSetup.nchan_out_woLFE + idx_lfe] ); +#endif } else if ( st_ivas->mc_mode == MC_MODE_MCMASA && hDirACRend->hOutSetup.separateChannelEnabled ) { @@ -5577,6 +5889,57 @@ void ivas_dirac_dec_render_sf( else { /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ +#ifdef IVAS_FLOAT_FIXED + // Float to fixed + st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state = Q_factor_arrL(st_ivas->cldfbSynDec[idx_in]->cldfb_state, st_ivas->cldfbSynDec[idx_in]->p_filter_length); + floatToFixed_arrL(st_ivas->cldfbSynDec[idx_in]->cldfb_state, st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state, st_ivas->cldfbSynDec[idx_in]->p_filter_length); + + Word32 *p_out = &( output_buf_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ); + + Word16 samplesToProcess, out_len; + FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) + { + RealBuffer_fx[i] = Cldfb_RealBuffer_fx[idx_in][i]; // cldfb_re_q + ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[idx_in][i]; // cldfb_im_q + // Scaling cldfb buffers to Q6 + scale_sig32( RealBuffer_fx[i], hSpatParamRendCom->num_freq_bands, sub( Q6, cldfb_re_q ) ); + scale_sig32( ImagBuffer_fx[i], hSpatParamRendCom->num_freq_bands, sub( Q6, cldfb_im_q ) ); + } + samplesToProcess = imult1616( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); + + // Calculating length of output + Word16 no_col = st_ivas->cldfbSynDec[idx_in]->no_col, no_channels = st_ivas->cldfbSynDec[idx_in]->no_channels; + IF(GT_16(samplesToProcess, -1)) + { + no_col = s_min(no_col, (samplesToProcess + st_ivas->cldfbSynDec[idx_in]->no_channels - 1) / st_ivas->cldfbSynDec[idx_in]->no_channels); + } + out_len = imult1616(no_col, no_channels); + + // Scaling cldfb_state to Q6-1 + scale_sig32(st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->p_filter_length, sub(Q6 - 1, st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state)); + st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state = Q6 - 1; + move16(); + + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, st_ivas->cldfbSynDec[idx_in] ); + + // Scaling output from Q6-1 to Q11 + /* NOTE: here, the output is saturating. since Q11 is not sufficient for storing the output in 1 case. + hence there is significant increase in MLD for [Multi-channel 7_1_4 bitrate switching from 13.2 kbps to 512 kbps, 48kHz in, 48kHz out, HOA3 out] case. + Need to fix this. + */ + Scale_sig32(p_out, out_len, (Q11 - (Q6 - 1))); + + // Fixed to float + fixedToFloat_arrL(st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->cldfb_state, st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state, st_ivas->cldfbSynDec[idx_in]->p_filter_length); + for (i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++) + { + fixedToFloat_arrL(Cldfb_RealBuffer_fx[idx_in][i], Cldfb_RealBuffer[idx_in][i], CLDFB_NO_CHANNELS_MAX, Q6 ); + fixedToFloat_arrL(Cldfb_ImagBuffer_fx[idx_in][i], Cldfb_ImagBuffer[idx_in][i], CLDFB_NO_CHANNELS_MAX, Q6 ); + } + fixedToFloat_arrL(output_buf_fx[ch], output_f[ch], Q11, samplesToProcess + index_slot * hSpatParamRendCom->num_freq_bands); + + idx_in = add( idx_in, 1 ); +#else for ( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) { RealBuffer[i] = Cldfb_RealBuffer[idx_in][i]; @@ -5584,6 +5947,7 @@ void ivas_dirac_dec_render_sf( } cldfbSynthesis_ivas( RealBuffer, ImagBuffer, &( output_f[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[idx_in] ); idx_in++; +#endif } } } @@ -5591,6 +5955,21 @@ void ivas_dirac_dec_render_sf( hSpatParamRendCom->slots_rendered += hSpatParamRendCom->subframe_nbslots[subframe_idx]; hSpatParamRendCom->subframes_rendered++; +#ifdef IVAS_FLOAT_FIXED + // Fixed to float + if (st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT) + { + for (ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE; ch++) + { + for (slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++) + { + fixedToFloat_arrL(pppQMfFrame_ts_re_fx[ch][slot_idx], pppQMfFrame_ts_re[ch][slot_idx], Q6, hSpatParamRendCom->num_freq_bands); + fixedToFloat_arrL(pppQMfFrame_ts_im_fx[ch][slot_idx], pppQMfFrame_ts_im[ch][slot_idx], Q6, hSpatParamRendCom->num_freq_bands); + } + } + } +#endif + pop_wmops(); return; diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 216d41651ad28a61838616e576285d4248a2643d..c461c12c6556d504ea3038993b60074ccc581ee3 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -154,30 +154,33 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open_fx( { return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n")); } - if ((h_dirac_output_synthesis_state->mixing_matrix_old_e = (Word16 *)malloc(CLDFB_NO_CHANNELS_MAX * sizeof(Word16))) == NULL) + + set16_fx(h_dirac_output_synthesis_state->cx_old_e, 0, CLDFB_NO_CHANNELS_MAX); + set16_fx(h_dirac_output_synthesis_state->cy_old_e, 0, CLDFB_NO_CHANNELS_MAX); + + if ((h_dirac_output_synthesis_state->mixing_matrix_res_exp = (Word16 *)malloc(nchan_out * nchan_out * sizeof(Word16))) == NULL) { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n")); + return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis matrix\n")); } - if ((h_dirac_output_synthesis_state->mixing_matrix_e = (Word16 *)malloc(CLDFB_NO_CHANNELS_MAX * sizeof(Word16))) == NULL) + set16_fx(h_dirac_output_synthesis_state->mixing_matrix_res_exp, 0, nchan_out * nchan_out); + + if ((h_dirac_output_synthesis_state->mixing_matrix_res_old_exp = (Word16 *)malloc(nchan_out * nchan_out * sizeof(Word16))) == NULL) { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n")); + return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis matrix\n")); } - if ((h_dirac_output_synthesis_state->mixing_matrix_res_old_e = (Word16 *)malloc(CLDFB_NO_CHANNELS_MAX * sizeof(Word16))) == NULL) + set16_fx(h_dirac_output_synthesis_state->mixing_matrix_res_old_exp, 0, nchan_out * nchan_out); + + if ((h_dirac_output_synthesis_state->mixing_matrix_exp = (Word16 *)malloc(nchan_out * nchan_out * sizeof(Word16))) == NULL) { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n")); + return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis matrix\n")); } - if ((h_dirac_output_synthesis_state->mixing_matrix_res_e = (Word16 *)malloc(CLDFB_NO_CHANNELS_MAX * sizeof(Word16))) == NULL) + set16_fx(h_dirac_output_synthesis_state->mixing_matrix_exp, 0, nchan_out * nchan_out); + + if ((h_dirac_output_synthesis_state->mixing_matrix_old_exp = (Word16 *)malloc(nchan_out * nchan_out * sizeof(Word16))) == NULL) { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n")); + return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis matrix\n")); } - - set16_fx(h_dirac_output_synthesis_state->cx_old_e, 0, CLDFB_NO_CHANNELS_MAX); - set16_fx(h_dirac_output_synthesis_state->cy_old_e, 0, CLDFB_NO_CHANNELS_MAX); - set16_fx(h_dirac_output_synthesis_state->mixing_matrix_old_e, 0, CLDFB_NO_CHANNELS_MAX); - - set16_fx(h_dirac_output_synthesis_state->mixing_matrix_e, 0, CLDFB_NO_CHANNELS_MAX); - set16_fx(h_dirac_output_synthesis_state->mixing_matrix_res_old_e, 0, CLDFB_NO_CHANNELS_MAX); - set16_fx(h_dirac_output_synthesis_state->mixing_matrix_res_e, 0, CLDFB_NO_CHANNELS_MAX); + set16_fx(h_dirac_output_synthesis_state->mixing_matrix_old_exp, 0, nchan_out * nchan_out); /*-----------------------------------------------------------------* * prepare processing parameters @@ -470,6 +473,11 @@ void ivas_dirac_dec_output_synthesis_cov_init_fx( set_zero_fx( h_dirac_output_synthesis_state->mixing_matrix_res_fx[idx], nchan_out * nchan_out ); } + + set16_fx(h_dirac_output_synthesis_state->mixing_matrix_old_exp, 0, nchan_out * nchan_in); + set16_fx(h_dirac_output_synthesis_state->mixing_matrix_exp, 0, nchan_out * nchan_in); + set16_fx(h_dirac_output_synthesis_state->mixing_matrix_res_old_exp, 0, nchan_out * nchan_out); + set16_fx(h_dirac_output_synthesis_state->mixing_matrix_res_exp, 0, nchan_out * nchan_out); #if 1/*TODO: To be removed :Floating point initializations*/ FOR ( idx = 0; idx < n_param_bands; idx++ ) { @@ -570,26 +578,6 @@ void ivas_dirac_dec_output_synthesis_cov_close( free(h_dirac_output_synthesis_state->cy_old_e); h_dirac_output_synthesis_state->cy_old_e = NULL; } - IF(h_dirac_output_synthesis_state->mixing_matrix_old_e != NULL) - { - free(h_dirac_output_synthesis_state->mixing_matrix_old_e); - h_dirac_output_synthesis_state->mixing_matrix_old_e = NULL; - } - IF(h_dirac_output_synthesis_state->mixing_matrix_e != NULL) - { - free(h_dirac_output_synthesis_state->mixing_matrix_e); - h_dirac_output_synthesis_state->mixing_matrix_e = NULL; - } - IF(h_dirac_output_synthesis_state->mixing_matrix_res_old_e != NULL) - { - free(h_dirac_output_synthesis_state->mixing_matrix_res_old_e); - h_dirac_output_synthesis_state->mixing_matrix_res_old_e = NULL; - } - IF(h_dirac_output_synthesis_state->mixing_matrix_res_e != NULL) - { - free(h_dirac_output_synthesis_state->mixing_matrix_res_e); - h_dirac_output_synthesis_state->mixing_matrix_res_e = NULL; - } /* free cov buffers */ FOR ( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) @@ -630,6 +618,30 @@ void ivas_dirac_dec_output_synthesis_cov_close( h_dirac_output_synthesis_state->mixing_matrix_res_fx[idx] = NULL; } } + + IF(h_dirac_output_synthesis_state->mixing_matrix_old_exp != NULL) + { + free(h_dirac_output_synthesis_state->mixing_matrix_old_exp); + h_dirac_output_synthesis_state->mixing_matrix_old_exp= NULL; + } + + IF(h_dirac_output_synthesis_state->mixing_matrix_res_old_exp != NULL) + { + free(h_dirac_output_synthesis_state->mixing_matrix_res_old_exp ); + h_dirac_output_synthesis_state->mixing_matrix_res_old_exp = NULL; + } + + IF(h_dirac_output_synthesis_state->mixing_matrix_exp != NULL) + { + free(h_dirac_output_synthesis_state->mixing_matrix_exp); + h_dirac_output_synthesis_state->mixing_matrix_exp = NULL; + } + + IF(h_dirac_output_synthesis_state->mixing_matrix_res_exp != NULL) + { + free(h_dirac_output_synthesis_state->mixing_matrix_res_exp); + h_dirac_output_synthesis_state->mixing_matrix_res_exp = NULL; + } #if 1/*TODO: To be removed later(floating point dealloc)*/ /* free interpolator */ IF ( h_dirac_output_synthesis_params->interpolator != NULL ) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index c8a232407a962be5f7adb5ccc11118d4d62590ec..8b71eef9b9a868a3f5e6e2502aadf7cbb0ce9639 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -219,15 +219,6 @@ ivas_error ivas_jbm_dec_tc( } ELSE IF( st_ivas->ivas_format == ISM_FORMAT ) { -#if 1 // Float to fix - FOR( Word16 ind = 0; ind < st_ivas->nchan_ism; ind++ ) - { - st_ivas->hIsmMetaData[ind]->last_azimuth_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->last_azimuth * ( 1 << 22 ) ); - st_ivas->hIsmMetaData[ind]->last_elevation_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->last_elevation * ( 1 << 22 ) ); - st_ivas->hIsmMetaData[ind]->last_true_azimuth_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->last_true_azimuth * ( 1 << 22 ) ); - st_ivas->hIsmMetaData[ind]->last_true_elevation_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->last_true_elevation * ( 1 << 22 ) ); - } -#endif /* Metadata decoding and configuration */ IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) { @@ -284,15 +275,6 @@ ivas_error ivas_jbm_dec_tc( return error; } } -#if 1 // fix to float - FOR( Word16 ind = 0; ind < st_ivas->nchan_ism; ind++ ) - { - st_ivas->hIsmMetaData[ind]->last_azimuth = (float) ( st_ivas->hIsmMetaData[ind]->last_azimuth_fx ) / (float) ( 1 << 22 ); - st_ivas->hIsmMetaData[ind]->last_elevation = (float) ( st_ivas->hIsmMetaData[ind]->last_elevation_fx ) / (float) ( 1 << 22 ); - st_ivas->hIsmMetaData[ind]->last_true_azimuth = (float) ( st_ivas->hIsmMetaData[ind]->last_true_azimuth_fx ) / (float) ( 1 << 22 ); - st_ivas->hIsmMetaData[ind]->last_true_elevation = (float) ( st_ivas->hIsmMetaData[ind]->last_true_elevation_fx ) / (float) ( 1 << 22 ); - } -#endif FOR( n = 0; n < st_ivas->nchan_transport; n++ ) { @@ -391,18 +373,6 @@ ivas_error ivas_jbm_dec_tc( } } } - FOR( Word16 d = 0; d < max( st_ivas->hMasa->config.numberOfDirections, st_ivas->hQMetaData->no_directions ); d++ ) - { - FOR( j = 0; j < max( st_ivas->hMasa->config.numCodingBands, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); j++ ) - { - FOR( Word16 k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++ ) - { - st_ivas->hQMetaData->q_direction[d].band_data[j].elevation[k] = fix_to_float( st_ivas->hQMetaData->q_direction[d].band_data[j].elevation_fx[k], Q22 ); - st_ivas->hQMetaData->q_direction[d].band_data[j].azimuth[k] = fix_to_float( st_ivas->hQMetaData->q_direction[d].band_data[j].azimuth_fx[k], Q22 ); - st_ivas->hQMetaData->q_direction[d].band_data[j].energy_ratio[k] = fix_to_float( st_ivas->hQMetaData->q_direction[d].band_data[j].energy_ratio_fx[k], Q30 ); - } - } - } st_ivas->hMasa->data.dir_decode_quality = fix16_to_float( st_ivas->hMasa->data.dir_decode_quality_fx, Q14 ); IF( st_ivas->hMasa->hMasaLfeSynth != NULL ) { @@ -504,9 +474,6 @@ ivas_error ivas_jbm_dec_tc( } } - - //IF( st->hTcxDec ) - //f2me_16( st->hTcxDec->CngLevelBackgroundTrace_bfi, &st->hTcxDec->conCngLevelBackgroundTrace, &st->hTcxDec->conCngLevelBackgroundTrace_e ); if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) { st->hTcxDec->conLastFrameLevel_e = 0; @@ -519,10 +486,6 @@ ivas_error ivas_jbm_dec_tc( st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; IF( st->hTcxDec ) st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; - IF( st->hFdCngDec && st->hFdCngDec->hFdCngCom ) - //floatToFixed_arr( st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, 15, 17 ); - - /*cldfb struct*/ /*------------------fix-to-fix-start---------------------*/ @@ -623,21 +586,11 @@ ivas_error ivas_jbm_dec_tc( { st = hCPE->hCoreCoder[n]; sts = hCPE->hCoreCoder; - //IF( st->hTcxDec ) - //st->hTcxDec->CngLevelBackgroundTrace_bfi = me2f_16( st->hTcxDec->conCngLevelBackgroundTrace, st->hTcxDec->conCngLevelBackgroundTrace_e ); IF( st->hTonalMDCTConc && st->hTonalMDCTConc->lastPcmOut_float ) fixedToFloat_arr( st->hTonalMDCTConc->lastPcmOut, st->hTonalMDCTConc->lastPcmOut_float, 0, st->hTonalMDCTConc->nSamples ); IF( sts[0]->bfi == 0 && !st->hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive ) fixedToFloat_arr( st->hTonalMDCTConc->secondLastPcmOut, st->hTonalMDCTConc->secondLastPcmOut_float, 0, st->hTonalMDCTConc->nSamples / 2 ); - //fixedToFloat_arr( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synthFB, st->Q_syn, st->hTcxDec->old_synth_lenFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); - - for ( int p = 0; p < st->L_frame / 2; p++ ) - { - //st->hTcxDec->old_syn_Overl_float[p] = (float) st->hTcxDec->old_syn_Overl[p] * 2 * ( 1u << st->Q_syn ); - //st->hTcxDec->syn_Overl_TDACFB_float[p] = (float) st->hTcxDec->syn_Overl_TDACFB[p] * 2 * (float) pow( 2, st->Q_syn ); - //st->hTcxDec->syn_Overl_TDAC_float[p] = (float) st->hTcxDec->syn_Overl_TDAC[p] * 2 * (float) pow( 2, st->Q_syn ); - } for ( int p = 0; p < 640; p++ ) { st->hHQ_core->old_outLB[p] = (float) st->hHQ_core->old_out_LB_fx[p] / ( 1u << st->Q_syn ); @@ -648,12 +601,8 @@ ivas_error ivas_jbm_dec_tc( fixedToFloat_arr( st->p_bpf_noise_buf, st->p_bpf_noise_buf_float, 0, L_FRAME_16k ); } - //fixedToFloat_arr( st->hTcxDec->syn_Overl, st->hTcxDec->syn_Overl_float, st->Q_syn, L_FRAME32k / 2 ); - /*-------------------cldfb-start-------------------------*/ - /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ - if ( sts[n]->cldfbAna != NULL ) { fixedToFloat_arrL( sts[n]->cldfbAna->cldfb_state_fx, sts[n]->cldfbAna->cldfb_state, 10, sts[n]->cldfbAna->cldfb_state_length ); @@ -893,7 +842,6 @@ ivas_error ivas_jbm_dec_tc( Scale_sig32( p_output_fx[i], L_FRAME48k, s ); } hCPE->hStereoDft->q_dft = Q11 + s; - // st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->q_smoothed_psd = Q11 - Q9; IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) { hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; @@ -1280,13 +1228,6 @@ ivas_error ivas_jbm_dec_tc( } } } - FOR( Word16 ind = 0; ind < tmp_nchan_ism; ind++ ) - { - st_ivas->hIsmMetaData[ind]->last_azimuth_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->last_azimuth * ( 1 << 22 ) ); - st_ivas->hIsmMetaData[ind]->last_elevation_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->last_elevation * ( 1 << 22 ) ); - st_ivas->hIsmMetaData[ind]->last_true_azimuth_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->last_true_azimuth * ( 1 << 22 ) ); - st_ivas->hIsmMetaData[ind]->last_true_elevation_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->last_true_elevation * ( 1 << 22 ) ); - } FOR( n = 0; n < tmp_nchan_ism; n++ ) { set32_fx( p_output_fx[n], 0, L_FRAME48k ); @@ -1385,18 +1326,6 @@ ivas_error ivas_jbm_dec_tc( } } } - FOR( Word16 d = 0; d < max( st_ivas->hMasa->config.numberOfDirections, st_ivas->hQMetaData->no_directions ); d++ ) - { - FOR( j = 0; j < max( st_ivas->hMasa->config.numCodingBands, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); j++ ) - { - FOR( Word16 k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++ ) - { - st_ivas->hQMetaData->q_direction[d].band_data[j].elevation[k] = fix_to_float( st_ivas->hQMetaData->q_direction[d].band_data[j].elevation_fx[k], Q22 ); - st_ivas->hQMetaData->q_direction[d].band_data[j].azimuth[k] = fix_to_float( st_ivas->hQMetaData->q_direction[d].band_data[j].azimuth_fx[k], Q22 ); - st_ivas->hQMetaData->q_direction[d].band_data[j].energy_ratio[k] = fix_to_float( st_ivas->hQMetaData->q_direction[d].band_data[j].energy_ratio_fx[k], Q30 ); - } - } - } st_ivas->hMasa->data.dir_decode_quality = fix16_to_float( st_ivas->hMasa->data.dir_decode_quality_fx, Q14 ); IF( st_ivas->hMasa->hMasaLfeSynth != NULL ) { @@ -1418,13 +1347,6 @@ ivas_error ivas_jbm_dec_tc( } } } - FOR( Word16 ind = 0; ind < tmp_nchan_ism; ind++ ) - { - st_ivas->hIsmMetaData[ind]->last_azimuth = (float) ( st_ivas->hIsmMetaData[ind]->last_azimuth_fx ) / (float) ( 1 << 22 ); - st_ivas->hIsmMetaData[ind]->last_elevation = (float) ( st_ivas->hIsmMetaData[ind]->last_elevation_fx ) / (float) ( 1 << 22 ); - st_ivas->hIsmMetaData[ind]->last_true_azimuth = (float) ( st_ivas->hIsmMetaData[ind]->last_true_azimuth_fx ) / (float) ( 1 << 22 ); - st_ivas->hIsmMetaData[ind]->last_true_elevation = (float) ( st_ivas->hIsmMetaData[ind]->last_true_elevation_fx ) / (float) ( 1 << 22 ); - } IF( NE_16( output_q, Q11 ) ) { FOR( n = 0; n < s_max( getNumChanSynthesis( st_ivas ), nchan_transport_ism + st_ivas->nchan_transport ); n++ ) @@ -1529,10 +1451,6 @@ ivas_error ivas_jbm_dec_tc( sts[n]->hIGFDec->infoTCXNoise_evs[l] = (Word16) sts[n]->hIGFDec->infoTCXNoise[l]; } } - - - //IF( st->hTcxDec ) - //f2me_16( st->hTcxDec->CngLevelBackgroundTrace_bfi, &st->hTcxDec->conCngLevelBackgroundTrace, &st->hTcxDec->conCngLevelBackgroundTrace_e ); if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) { st->hTcxDec->conLastFrameLevel_e = 0; @@ -1545,8 +1463,6 @@ ivas_error ivas_jbm_dec_tc( st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; IF( st->hTcxDec ) st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; - IF( st->hFdCngDec && st->hFdCngDec->hFdCngCom ) - //floatToFixed_arr( st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, 15, 17 ); /*cldfb struct*/ @@ -2264,10 +2180,6 @@ ivas_error ivas_jbm_dec_tc( sts[n]->hIGFDec->infoTCXNoise_evs[l] = (Word16) sts[n]->hIGFDec->infoTCXNoise[l]; } } - - - //IF( st->hTcxDec ) - //f2me_16( st->hTcxDec->CngLevelBackgroundTrace_bfi, &st->hTcxDec->conCngLevelBackgroundTrace, &st->hTcxDec->conCngLevelBackgroundTrace_e ); if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) { st->hTcxDec->conLastFrameLevel_e = 0; @@ -2280,8 +2192,6 @@ ivas_error ivas_jbm_dec_tc( st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; IF( st->hTcxDec ) st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; - IF( st->hFdCngDec && st->hFdCngDec->hFdCngCom ) - //floatToFixed_arr( st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, 15, 17 ); /*cldfb struct*/ /*------------------fix-to-fix-start---------------------*/ @@ -2382,21 +2292,11 @@ ivas_error ivas_jbm_dec_tc( { st = hCPE->hCoreCoder[n]; sts = hCPE->hCoreCoder; - //IF( st->hTcxDec ) - //st->hTcxDec->CngLevelBackgroundTrace_bfi = me2f_16( st->hTcxDec->conCngLevelBackgroundTrace, st->hTcxDec->conCngLevelBackgroundTrace_e ); IF( st->hTonalMDCTConc && st->hTonalMDCTConc->lastPcmOut_float ) fixedToFloat_arr( st->hTonalMDCTConc->lastPcmOut, st->hTonalMDCTConc->lastPcmOut_float, 0, st->hTonalMDCTConc->nSamples ); IF( sts[0]->bfi == 0 && !st->hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive ) fixedToFloat_arr( st->hTonalMDCTConc->secondLastPcmOut, st->hTonalMDCTConc->secondLastPcmOut_float, 0, st->hTonalMDCTConc->nSamples / 2 ); - //fixedToFloat_arr( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synthFB, st->Q_syn, st->hTcxDec->old_synth_lenFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); - - for ( int p = 0; p < st->L_frame / 2; p++ ) - { - //st->hTcxDec->old_syn_Overl_float[p] = (float) st->hTcxDec->old_syn_Overl[p] * 2 * ( 1u << st->Q_syn ); - //st->hTcxDec->syn_Overl_TDACFB_float[p] = (float) st->hTcxDec->syn_Overl_TDACFB[p] * 2 * (float) pow( 2, st->Q_syn ); - //st->hTcxDec->syn_Overl_TDAC_float[p] = (float) st->hTcxDec->syn_Overl_TDAC[p] * 2 * (float) pow( 2, st->Q_syn ); - } for ( int p = 0; p < 640; p++ ) { st->hHQ_core->old_outLB[p] = (float) st->hHQ_core->old_out_LB_fx[p] / ( 1u << st->Q_syn ); @@ -2407,8 +2307,6 @@ ivas_error ivas_jbm_dec_tc( fixedToFloat_arr( st->p_bpf_noise_buf, st->p_bpf_noise_buf_float, 0, L_FRAME_16k ); } - //fixedToFloat_arr( st->hTcxDec->syn_Overl, st->hTcxDec->syn_Overl_float, st->Q_syn, L_FRAME32k / 2 ); - /*-------------------cldfb-start-------------------------*/ /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ @@ -2586,10 +2484,6 @@ ivas_error ivas_jbm_dec_tc( sts[n]->hIGFDec->infoTCXNoise_evs[l] = (Word16) sts[n]->hIGFDec->infoTCXNoise[l]; } } - - - //IF( st->hTcxDec ) - //f2me_16( st->hTcxDec->CngLevelBackgroundTrace_bfi, &st->hTcxDec->conCngLevelBackgroundTrace, &st->hTcxDec->conCngLevelBackgroundTrace_e ); if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) { st->hTcxDec->conLastFrameLevel_e = 0; @@ -2602,8 +2496,7 @@ ivas_error ivas_jbm_dec_tc( st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; IF( st->hTcxDec ) st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; - IF( st->hFdCngDec && st->hFdCngDec->hFdCngCom ) - //floatToFixed_arr( st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, 15, 17 ); + /*cldfb struct*/ @@ -2676,8 +2569,6 @@ ivas_error ivas_jbm_dec_tc( st_ivas->hLsSetUpConversion->dmxMtx_fx[chInIdx][chOutIdx] = float_to_fix( st_ivas->hLsSetUpConversion->dmxMtx[chInIdx][chOutIdx], 30 ); /*Q30*/ } } - - #endif // Float to fix if ( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { @@ -2705,21 +2596,10 @@ ivas_error ivas_jbm_dec_tc( { st = hCPE->hCoreCoder[n]; sts = hCPE->hCoreCoder; - //IF( st->hTcxDec ) - //st->hTcxDec->CngLevelBackgroundTrace_bfi = me2f_16( st->hTcxDec->conCngLevelBackgroundTrace, st->hTcxDec->conCngLevelBackgroundTrace_e ); IF( st->hTonalMDCTConc && st->hTonalMDCTConc->lastPcmOut_float ) fixedToFloat_arr( st->hTonalMDCTConc->lastPcmOut, st->hTonalMDCTConc->lastPcmOut_float, 0, st->hTonalMDCTConc->nSamples ); IF( sts[0]->bfi == 0 && !st->hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive ) fixedToFloat_arr( st->hTonalMDCTConc->secondLastPcmOut, st->hTonalMDCTConc->secondLastPcmOut_float, 0, st->hTonalMDCTConc->nSamples / 2 ); - - //fixedToFloat_arr( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synthFB, st->Q_syn, st->hTcxDec->old_synth_lenFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); - - for ( int p = 0; p < st->L_frame / 2; p++ ) - { - //st->hTcxDec->old_syn_Overl_float[p] = (float) st->hTcxDec->old_syn_Overl[p] * 2 * ( 1u << st->Q_syn ); - //st->hTcxDec->syn_Overl_TDACFB_float[p] = (float) st->hTcxDec->syn_Overl_TDACFB[p] * 2 * (float) pow( 2, st->Q_syn ); - //st->hTcxDec->syn_Overl_TDAC_float[p] = (float) st->hTcxDec->syn_Overl_TDAC[p] * 2 * (float) pow( 2, st->Q_syn ); - } for ( int p = 0; p < 640; p++ ) { st->hHQ_core->old_outLB[p] = (float) st->hHQ_core->old_out_LB_fx[p] / ( 1u << st->Q_syn ); @@ -2729,13 +2609,8 @@ ivas_error ivas_jbm_dec_tc( { fixedToFloat_arr( st->p_bpf_noise_buf, st->p_bpf_noise_buf_float, 0, L_FRAME_16k ); } - - //fixedToFloat_arr( st->hTcxDec->syn_Overl, st->hTcxDec->syn_Overl_float, st->Q_syn, L_FRAME32k / 2 ); - /*-------------------cldfb-start-------------------------*/ - /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ - if ( sts[n]->cldfbAna != NULL ) { fixedToFloat_arrL( sts[n]->cldfbAna->cldfb_state_fx, sts[n]->cldfbAna->cldfb_state, 10, sts[n]->cldfbAna->cldfb_state_length ); @@ -2917,10 +2792,6 @@ ivas_error ivas_jbm_dec_tc( sts[n]->hIGFDec->infoTCXNoise_evs[l] = (Word16) sts[n]->hIGFDec->infoTCXNoise[l]; } } - - - //IF( st->hTcxDec ) - //f2me_16( st->hTcxDec->CngLevelBackgroundTrace_bfi, &st->hTcxDec->conCngLevelBackgroundTrace, &st->hTcxDec->conCngLevelBackgroundTrace_e ); if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) { st->hTcxDec->conLastFrameLevel_e = 0; @@ -2933,8 +2804,6 @@ ivas_error ivas_jbm_dec_tc( st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; IF( st->hTcxDec ) st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; - IF( st->hFdCngDec && st->hFdCngDec->hFdCngCom ) - //floatToFixed_arr( st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, 15, 17 ); /*cldfb struct*/ @@ -3036,21 +2905,10 @@ ivas_error ivas_jbm_dec_tc( { st = hCPE->hCoreCoder[n]; sts = hCPE->hCoreCoder; - //IF( st->hTcxDec ) - //st->hTcxDec->CngLevelBackgroundTrace_bfi = me2f_16( st->hTcxDec->conCngLevelBackgroundTrace, st->hTcxDec->conCngLevelBackgroundTrace_e ); IF( st->hTonalMDCTConc && st->hTonalMDCTConc->lastPcmOut_float ) fixedToFloat_arr( st->hTonalMDCTConc->lastPcmOut, st->hTonalMDCTConc->lastPcmOut_float, 0, st->hTonalMDCTConc->nSamples ); IF( sts[0]->bfi == 0 && !st->hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive ) fixedToFloat_arr( st->hTonalMDCTConc->secondLastPcmOut, st->hTonalMDCTConc->secondLastPcmOut_float, 0, st->hTonalMDCTConc->nSamples / 2 ); - - //fixedToFloat_arr( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synthFB, st->Q_syn, st->hTcxDec->old_synth_lenFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); - - for ( int p = 0; p < st->L_frame / 2; p++ ) - { - //st->hTcxDec->old_syn_Overl_float[p] = (float) st->hTcxDec->old_syn_Overl[p] * 2 * ( 1u << st->Q_syn ); - //st->hTcxDec->syn_Overl_TDACFB_float[p] = (float) st->hTcxDec->syn_Overl_TDACFB[p] * 2 * (float) pow( 2, st->Q_syn ); - //st->hTcxDec->syn_Overl_TDAC_float[p] = (float) st->hTcxDec->syn_Overl_TDAC[p] * 2 * (float) pow( 2, st->Q_syn ); - } for ( int p = 0; p < 640; p++ ) { st->hHQ_core->old_outLB[p] = (float) st->hHQ_core->old_out_LB_fx[p] / ( 1u << st->Q_syn ); @@ -3060,9 +2918,6 @@ ivas_error ivas_jbm_dec_tc( { fixedToFloat_arr( st->p_bpf_noise_buf, st->p_bpf_noise_buf_float, 0, L_FRAME_16k ); } - - //fixedToFloat_arr( st->hTcxDec->syn_Overl, st->hTcxDec->syn_Overl_float, st->Q_syn, L_FRAME32k / 2 ); - /*-------------------cldfb-start-------------------------*/ /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ @@ -3089,7 +2944,6 @@ ivas_error ivas_jbm_dec_tc( /*------------------reset-code-start---------------------*/ - /* reset WB BWE buffers */ IF( NE_16( sts[n]->last_extl, WB_BWE ) && EQ_16( sts[n]->extl, WB_BWE ) && sts[n]->hBWE_FD != NULL ) @@ -3249,18 +3103,6 @@ ivas_error ivas_jbm_dec_tc( } } } - FOR( Word16 d = 0; d < max( st_ivas->hMasa->config.numberOfDirections, st_ivas->hQMetaData->no_directions ); d++ ) - { - FOR( j = 0; j < max( st_ivas->hMasa->config.numCodingBands, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); j++ ) - { - FOR( Word16 k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++ ) - { - st_ivas->hQMetaData->q_direction[d].band_data[j].elevation[k] = fix_to_float( st_ivas->hQMetaData->q_direction[d].band_data[j].elevation_fx[k], Q22 ); - st_ivas->hQMetaData->q_direction[d].band_data[j].azimuth[k] = fix_to_float( st_ivas->hQMetaData->q_direction[d].band_data[j].azimuth_fx[k], Q22 ); - st_ivas->hQMetaData->q_direction[d].band_data[j].energy_ratio[k] = fix_to_float( st_ivas->hQMetaData->q_direction[d].band_data[j].energy_ratio_fx[k], Q30 ); - } - } - } st_ivas->hMasa->data.dir_decode_quality = fix16_to_float( st_ivas->hMasa->data.dir_decode_quality_fx, Q14 ); IF( st_ivas->hMasa->hMasaLfeSynth != NULL ) { @@ -5482,7 +5324,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) { #ifdef IVAS_FLOAT_FIXED - Word16 cldfb_slots, i, j; + Word16 cldfb_slots, j; Word32 p_data_f_fx[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k]; /* 'float' buffer for transport channels that will be directly converted with the CLDFB */ cldfb_slots = DEFAULT_JBM_CLDFB_TIMESLOTS; if (st_ivas->hDecoderConfig->Opt_tsm) @@ -5564,10 +5406,10 @@ void ivas_jbm_dec_feed_tc_to_renderer( FOR(Word16 param_band_idx = 0; param_band_idx < st_ivas->hParamMC->num_param_bands_synth; param_band_idx++) { - me2f_buf(st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_e[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix[param_band_idx], nchan_out_cov * nchan_transport); + me2f_buf(st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix[param_band_idx], nchan_out_cov * nchan_transport); IF(st_ivas->hParamMC->band_grouping[param_band_idx] < st_ivas->hParamMC->h_output_synthesis_params.max_band_decorr) { - me2f_buf(st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_e[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res[param_band_idx], nchan_out_cov * nchan_out_cov); + me2f_buf(st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res[param_band_idx], nchan_out_cov * nchan_out_cov); } } diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index f30db50ec7d9e7ecfd884ad49aafd864db7f996b..5c5102b288afba0baa3717d1529cb44f6d676ca0 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -86,7 +86,7 @@ static void ivas_param_mc_dec_copy_diffuse_proto(PARAM_MC_DEC_HANDLE hParamMC, W #else static void ivas_param_mc_dec_copy_diffuse_proto( PARAM_MC_DEC_HANDLE hParamMC, float Cldfb_buffer_real[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float Cldfb_buffer_imag[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t nY, const int16_t slot_idx ); #endif -static int16_t ivas_param_mc_range_decoder_LC( uint16_t *bit_buffer, int16_t *x, int16_t *BER_detect, const int16_t sz_seq, const int16_t sz_alphabet, const uint16_t *cft, const uint16_t *sft, const int16_t tot_shift, const int16_t nbbits ); +static Word16 ivas_param_mc_range_decoder_LC( UWord16 *bit_buffer, Word16 *x, Word16 *BER_detect, const Word16 sz_seq, const Word16 sz_alphabet, const UWord16 *cft, const UWord16 *sft, const Word16 tot_shift, const Word16 nbbits ); static int16_t ivas_param_mc_uniform_decoder( float *seq, const int16_t sz_seq, const float *alphabet, const int16_t N, uint16_t bit_buffer[PARAM_MC_MAX_BITS] ); @@ -114,6 +114,7 @@ static void ivas_param_mc_get_mono_stereo_mixing_matrices( PARAM_MC_DEC_HANDLE h static void param_mc_update_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, float *mixing_matrix[], float *mixing_matrix_res[], const uint16_t nX, const uint16_t nY ); #ifdef IVAS_FLOAT_FIXED +static Word16 ivas_param_mc_uniform_decoder_fx(Word16 *seq, const Word16 sz_seq, const Word16 *alphabet, const Word16 N, UWord16 bit_buffer[PARAM_MC_MAX_BITS]); static void ivas_param_mc_dec_compute_interpolator_fx( const UWord16 bAttackPresent, const UWord16 attackPos, const UWord16 interp_length, Word16 *interpolator ); #endif // IVAS_FLOAT_FIXED @@ -128,8 +129,10 @@ static void ivas_param_mc_get_param_band_mapping( const int16_t n_target_bands, static void ivas_param_mc_bs_decode_parameter_values( uint16_t bit_buffer[], int16_t *bit_pos, const int16_t max_bits, int16_t *BER_detect, HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC, HANDLE_PARAM_MC_PARAMETER_CODING_INFO hParamCodingInfo, const int16_t map_size_wo_lfe, const int16_t map_size, const int16_t num_lfe_bands, const int16_t band_step, const int16_t num_param_bands, float *value_buffer ); #ifdef IVAS_FLOAT_FIXED +static void ivas_param_mc_bs_decode_parameter_values_fx(UWord16 bit_buffer[], Word16 *bit_pos, const Word16 max_bits, Word16 *BER_detect, HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC, HANDLE_PARAM_MC_PARAMETER_CODING_INFO hParamCodingInfo, const Word16 map_size_wo_lfe, const Word16 map_size, const Word16 num_lfe_bands, const Word16 band_step, const Word16 num_param_bands, Word16 *value_buffer); static void ivas_param_mc_dequantize_cov_fx(PARAM_MC_DEC_HANDLE hParamMC, Word16 *ild_q_fx, Word16 *icc_q_fx, const Word16 param_band_index, const Word16 nY_cov, const PARAM_MC_SYNTHESIS_CONF synth_conf, const Word16 nY_int, const Word16 nX, Word32 *Cx_state_fx, Word16 Cx_state_e, Word32 *Cproto_fx, Word16 Cproto_e, Word32 *Cy_state_fx, Word16 *Cy_state_e); static ivas_error param_mc_get_diff_proto_info_fx(const Word32 *proto_mtx, const UWord16 nchan_transport, const UWord16 nchan_out_cov, PARAM_MC_DIFF_PROTO_INFO *p_diff_proto_info); +static void param_mc_update_mixing_matrices_fx( PARAM_MC_DEC_HANDLE hParamMC, Word32 *mixing_matrix[], Word16 *mixing_matrix_fx, Word32 *mixing_matrix_res[], Word16 *mixing_matrix_res_exp, const UWord16 nX, const UWord16 nY ); #endif /*------------------------------------------------------------------------- @@ -2142,12 +2145,26 @@ void ivas_param_mc_dec_read_BS( } #endif +#ifdef IVAS_FLOAT_FIXED + floatToFixed_arr16( hParamMC->icc_q, hParamMC->icc_q_fx, Q15, hMetadataPMC->nbands_coded * icc_map_size ); + ivas_param_mc_bs_decode_parameter_values_fx( bit_buffer, &bit_pos, bits_to_copy, &st->BER_detect, hMetadataPMC, &hMetadataPMC->icc_coding, + icc_map_size_wo_lfe, icc_map_size, num_lfe_bands, band_step, num_param_bands, hParamMC->icc_q_fx ); + fixedToFloat_arr( hParamMC->icc_q_fx, hParamMC->icc_q, Q15, hMetadataPMC->nbands_coded*icc_map_size ); +#else ivas_param_mc_bs_decode_parameter_values( bit_buffer, &bit_pos, bits_to_copy, &st->BER_detect, hMetadataPMC, &hMetadataPMC->icc_coding, icc_map_size_wo_lfe, icc_map_size, num_lfe_bands, band_step, num_param_bands, hParamMC->icc_q ); +#endif // IVAS_FLOAT_FIXED if ( !st->BER_detect ) { +#ifdef IVAS_FLOAT_FIXED + floatToFixed_arr16( hParamMC->icld_q, hParamMC->icld_q_fx, Q8, hMetadataPMC->nbands_coded * ild_map_size ); + ivas_param_mc_bs_decode_parameter_values_fx( bit_buffer, &bit_pos, bits_to_copy, &st->BER_detect, hMetadataPMC, &hMetadataPMC->ild_coding, + ild_map_size_wo_lfe, ild_map_size, num_lfe_bands, band_step, num_param_bands, hParamMC->icld_q_fx ); + fixedToFloat_arr( hParamMC->icld_q_fx, hParamMC->icld_q, Q8, hMetadataPMC->nbands_coded*ild_map_size); +#else ivas_param_mc_bs_decode_parameter_values( bit_buffer, &bit_pos, bits_to_copy, &st->BER_detect, hMetadataPMC, &hMetadataPMC->ild_coding, ild_map_size_wo_lfe, ild_map_size, num_lfe_bands, band_step, num_param_bands, hParamMC->icld_q ); +#endif // IVAS_FLOAT_FIXED } /* set LFE ILD and ICC to zero above PARAM_MC_MAX_BAND_LFE for attack frames */ if ( hMetadataPMC->bAttackPresent ) @@ -2407,7 +2424,7 @@ void ivas_param_mc_dec_digest_tc_fx( ELSE { /* generate mixing matrices */ - ivas_param_mc_get_mixing_matrices_fx( hParamMC, hSynthesisOutputSetup, cx_fx, cx_e, hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_e, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_e, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); + ivas_param_mc_get_mixing_matrices_fx( hParamMC, hSynthesisOutputSetup, cx_fx, cx_e, hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); } pop_wmops(); @@ -3002,7 +3019,26 @@ void ivas_param_mc_dec_render( if ( hParamMC->slots_rendered == hParamMC->num_slots ) { hParamMC->hMetadataPMC->last_coded_bwidth = hParamMC->hMetadataPMC->coded_bwidth; +#ifdef IVAS_FLOAT_FIXED + FOR(Word16 param_band_idx = 0; param_band_idx < hParamMC->hMetadataPMC->nbands_coded; param_band_idx++) { + f2me_buf(hParamMC->h_output_synthesis_cov_state.mixing_matrix[param_band_idx], hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], &hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx], nchan_transport * nchan_out_cov); + IF(hParamMC->band_grouping[param_band_idx] < hParamMC->h_output_synthesis_params.max_band_decorr) { + f2me_buf(hParamMC->h_output_synthesis_cov_state.mixing_matrix_res[param_band_idx], hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], &hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx], nchan_transport * nchan_out_cov); + } + } + + param_mc_update_mixing_matrices_fx(hParamMC, hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_transport, nchan_out_cov); + + FOR(Word16 param_band_idx = 0; param_band_idx < hParamMC->hMetadataPMC->nbands_coded; param_band_idx++) { + IF( hParamMC->band_grouping[param_band_idx] < hParamMC->h_output_synthesis_params.max_band_decorr) { + mvr2r(hParamMC->h_output_synthesis_cov_state.mixing_matrix_res[param_band_idx], hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[param_band_idx], nchan_transport * nchan_out_cov ); + } + mvr2r(hParamMC->h_output_synthesis_cov_state.mixing_matrix[param_band_idx], hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[param_band_idx], nchan_transport * nchan_out_cov); + } + +#else param_mc_update_mixing_matrices( hParamMC, hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, nchan_transport, nchan_out_cov ); +#endif } hParamMC->subframes_rendered = last_sf; *nSamplesAvailableNext = ( hParamMC->num_slots - hParamMC->slots_rendered ) * NS2SA( output_Fs, CLDFB_SLOT_NS ); @@ -3259,6 +3295,33 @@ static int16_t ivas_param_mc_bin2dec( * * decode a uniformily coded sequence of float values *------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +static Word16 ivas_param_mc_uniform_decoder_fx( + Word16 *seq, /* o : decoded sequence of float values */ + const Word16 sz_seq, /* i : number of values to decode */ + const Word16 *alphabet, /* i : codebook */ + const Word16 N, /* i : number of bits per coded index */ + UWord16 bit_buffer[PARAM_MC_MAX_BITS] /* i : bit buffer to decode */ +) +{ + Word16 i; + Word16 idx; + Word16 n_bits; + + n_bits = 0; + assert( N * sz_seq < PARAM_MC_MAX_BITS ); + + FOR ( i = 0; i < sz_seq; ++i ) + { + idx = ivas_param_mc_bin2dec( &bit_buffer[i * N], N ); + seq[i] = alphabet[idx]; + } + + n_bits = imult1616(N , sz_seq); + + return n_bits; +} +#endif // IVAS_FLOAT_FIXED static int16_t ivas_param_mc_uniform_decoder( float *seq, /* o : decoded sequence of float values */ @@ -3293,22 +3356,22 @@ static int16_t ivas_param_mc_uniform_decoder( * decode a sequency of inidices coded with a range coder *------------------------------------------------------------------------*/ -static int16_t ivas_param_mc_range_decoder_LC( - uint16_t *bit_buffer, /* i : bit buffer to read from */ - int16_t *x, /* o : decoded indices */ - int16_t *BER_detect, /* o : flag for indicating a bit error */ - const int16_t sz_seq, /* i : size of the sequence to be decoded */ - const int16_t sz_alphabet, /* i : size of the alphabet */ - const uint16_t *cft, /* i : cumulative frequency table */ - const uint16_t *sft, /* i : symbol frequency table */ - const int16_t tot_shift, /* i : total frequency as a power of 2 */ - const int16_t nbbits /* i : maximum bit budget */ +static Word16 ivas_param_mc_range_decoder_LC( + UWord16 *bit_buffer, /* i : bit buffer to read from */ + Word16 *x, /* o : decoded indices */ + Word16 *BER_detect, /* o : flag for indicating a bit error */ + const Word16 sz_seq, /* i : size of the sequence to be decoded */ + const Word16 sz_alphabet, /* i : size of the alphabet */ + const UWord16 *cft, /* i : cumulative frequency table */ + const UWord16 *sft, /* i : symbol frequency table */ + const Word16 tot_shift, /* i : total frequency as a power of 2 */ + const Word16 nbbits /* i : maximum bit budget */ ) { RangeUniDecState rc_st_dec; /* State of the range decoder */ - int16_t cur_bit_pos; - int16_t k; - int16_t r; + Word16 cur_bit_pos; + Word16 k; + Word16 r; /* Start Decoding */ /* Initialize range decoder */ @@ -3320,7 +3383,7 @@ static int16_t ivas_param_mc_range_decoder_LC( #endif // IVAS_FLOAT_FIXED /* Main Loop through the indices */ - for ( k = 0; k < sz_seq; k++ ) + FOR ( k = 0; k < sz_seq; k++ ) { #ifdef IVAS_FLOAT_FIXED r = rc_uni_dec_read_symbol_fastS_fx( &rc_st_dec, cft, sft, sz_alphabet, tot_shift ); /*Alphabet size = 17 (2^4 = 16 MSB symbols + 1 ESC symbol) */ @@ -3334,7 +3397,7 @@ static int16_t ivas_param_mc_range_decoder_LC( cur_bit_pos = rc_uni_dec_virtual_finish( &rc_st_dec ); /* Confirm that there is no overflow */ - if ( cur_bit_pos > nbbits ) + IF ( cur_bit_pos > nbbits ) { *BER_detect |= 1; } @@ -3346,7 +3409,7 @@ static int16_t ivas_param_mc_range_decoder_LC( /*st->next_bit_pos = rc_uni_dec_finish(&rc_st_dec);*/ /* Check for bitstream errors */ - if ( rc_st_dec.bit_error_detected != 0 ) + IF ( rc_st_dec.bit_error_detected != 0 ) { *BER_detect |= 1; } @@ -4498,6 +4561,39 @@ static void param_mc_update_mixing_matrices( return; } +#ifdef IVAS_FLOAT_FIXED +static void param_mc_update_mixing_matrices_fx( + PARAM_MC_DEC_HANDLE hParamMC, /* i/o: Parametric MC handle */ + Word32 *mixing_matrix[], /* i : direct mixing matrices for the frame just processed */ + Word16 *mixing_matrix_exp, + Word32 *mixing_matrix_res[], /* i : residual mixing matrices for the frame just processed */ + Word16 *mixing_matrix_res_exp, + const UWord16 nX, /* i : number of transport channels */ + const UWord16 nY ) /* i : number of synthesis channels */ +{ + UWord16 param_band_idx; + + FOR ( param_band_idx = 0; param_band_idx < hParamMC->hMetadataPMC->nbands_coded; param_band_idx++ ) + { + Word16 brange[2]; + + brange[0] = hParamMC->band_grouping[param_band_idx]; + brange[1] = hParamMC->band_grouping[param_band_idx + 1]; + + Copy32( mixing_matrix[param_band_idx], hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[param_band_idx], nX * nY ); + hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_exp[param_band_idx] = mixing_matrix_exp[param_band_idx]; + + IF ( brange[0] < hParamMC->h_output_synthesis_params.max_band_decorr ) + { + Copy32( mixing_matrix_res[param_band_idx], hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_fx[param_band_idx], nY * nY ); + hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_exp[param_band_idx] = mixing_matrix_res_exp[param_band_idx]; + } + } + + return; +} +#endif + /*------------------------------------------------------------------------- * ivas_param_mc_dequantize_cov() @@ -5412,6 +5508,124 @@ static ivas_error param_mc_get_diff_proto_info( * * reads and decodes a sequence of Parametric MC parameters from the bitstream *-------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +static void ivas_param_mc_bs_decode_parameter_values_fx( + UWord16 bit_buffer[], /* i : bitstream buffer */ + Word16 *bit_pos, /* i/o: current bitstream buffer position */ + const Word16 max_bits, /* i : maximum available bits in the buffer */ + Word16 *BER_detect, /* i/o: bit error detection flag */ + HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC, /* i : Parametric MC metadata information */ + HANDLE_PARAM_MC_PARAMETER_CODING_INFO hParamCodingInfo, /* i : Parametric MC parameter quantization and coding tables */ + const Word16 map_size_wo_lfe, /* i : number of parameters per band (w/o LFEs) */ + const Word16 map_size, /* i : number of parameters per band (total) */ + const Word16 num_lfe_bands, /* i : number of parameter bands with coded LFE */ + const Word16 band_step, /* i : parameter band step */ + const Word16 num_param_bands, /* i : number of parameter bands to decode */ + Word16 *value_buffer /* o : output buffer for decoded parameter values */ +) +{ + Word16 range_coding; + Word16 sz_seq; + Word16 delta_coding; + Word16 delta_idx[PARAM_MC_MAX_PARAMETER_BANDS * PARAM_MC_MAX_VAL_MAP_SIZE]; + Word16 idx[PARAM_MC_MAX_PARAMETER_BANDS * PARAM_MC_MAX_VAL_MAP_SIZE]; + Word16 idx_prev; + Word16 idx_offset; + Word16 sz_alphabet; + Word16 i, j, k; + Word16 dequant_seq_fx[PARAM_MC_MAX_PARAMETER_BANDS * PARAM_MC_MAX_VAL_MAP_SIZE]; + Word16 dequant_ordered_fx[PARAM_MC_MAX_PARAMETER_BANDS * PARAM_MC_MAX_VAL_MAP_SIZE]; + Word16 n_lfe_idx; + + range_coding = bit_buffer[( *bit_pos )++]; + + /* Decoding the sequence */ + n_lfe_idx = sub(map_size , map_size_wo_lfe); + sz_seq = add(imult1616(num_param_bands , map_size_wo_lfe ) , imult1616(num_lfe_bands , n_lfe_idx)); + + set_s( idx, 0, PARAM_MC_MAX_PARAMETER_BANDS * PARAM_MC_MAX_VAL_MAP_SIZE ); + set16_fx( dequant_ordered_fx, 0, PARAM_MC_MAX_PARAMETER_BANDS * PARAM_MC_MAX_VAL_MAP_SIZE ); + set16_fx( dequant_seq_fx, 0, PARAM_MC_MAX_PARAMETER_BANDS * PARAM_MC_MAX_VAL_MAP_SIZE ); + IF ( range_coding ) + { + delta_coding = bit_buffer[( *bit_pos )++]; + + IF ( delta_coding ) + { + idx_prev = sub(add(shr(hParamCodingInfo->quantizer_size , 1) , hParamCodingInfo->quantizer_size % 2) , 1); + sz_alphabet = sub(shl(hParamCodingInfo->quantizer_size,1) , 1); + idx_offset = sub(hParamCodingInfo->quantizer_size , 1); + + /* read range coded delta ICC indices */ + *bit_pos = add(*bit_pos,ivas_param_mc_range_decoder_LC( &bit_buffer[*bit_pos], delta_idx, BER_detect, sz_seq, sz_alphabet, + hParamCodingInfo->cum_freq_delta, hParamCodingInfo->sym_freq_delta, PARAM_MC_RANGE_CODER_TOT_SHIFT, max_bits - *bit_pos )); + + /* delta index to absolute index */ + FOR ( j = 0; j < sz_seq; j++ ) + { + idx[j] = add(idx_prev , sub(delta_idx[j] , idx_offset)); + idx_prev = idx[j]; + } + } + ELSE + { + /* read range coded absolute ICC indices */ + sz_alphabet = hParamCodingInfo->quantizer_size; + *bit_pos = add(*bit_pos,ivas_param_mc_range_decoder_LC( &bit_buffer[*bit_pos], idx, BER_detect, sz_seq, sz_alphabet, + hParamCodingInfo->cum_freq, hParamCodingInfo->sym_freq, PARAM_MC_RANGE_CODER_TOT_SHIFT, max_bits - *bit_pos )); + } + + /* dequantize */ + FOR ( j = 0; j < sz_seq; j++ ) + { + dequant_seq_fx[j] = hParamCodingInfo->quantizer_fx[idx[j]]; + } + } + ELSE + { + set16_fx( dequant_seq_fx, 0, PARAM_MC_MAX_PARAMETER_BANDS * PARAM_MC_MAX_VAL_MAP_SIZE ); + /* read uniformly coded ICCs */ + *bit_pos = add(*bit_pos,ivas_param_mc_uniform_decoder_fx( dequant_seq_fx, sz_seq, hParamCodingInfo->quantizer_fx, hParamCodingInfo->uni_bits, &bit_buffer[*bit_pos] )); + } + + /* reorder from sequential to parameter-band-wise */ + k = 0; + FOR ( j = 0; j < map_size_wo_lfe; ++j ) + { + FOR ( i = 0; i < num_param_bands; ++i ) + { + dequant_ordered_fx[j + i * map_size] = dequant_seq_fx[k++]; + } + } + + FOR ( i = 0; i < num_lfe_bands; i++ ) + { + FOR ( j = 0; j < n_lfe_idx; j++ ) + { + dequant_ordered_fx[map_size - n_lfe_idx + j + i * map_size] = dequant_seq_fx[k++]; + } + } + + IF ( !( *BER_detect ) ) + { + j = 0; + FOR ( k = 0; k < hMetadataPMC->nbands_coded; k += band_step ) + { + IF ( hMetadataPMC->bAttackPresent || EQ_16(hMetadataPMC->param_frame_idx , hMetadataPMC->coding_band_mapping[k]) ) + { + Copy( dequant_ordered_fx + j * map_size, value_buffer + k * map_size, map_size ); + j++; + } + IF ( hMetadataPMC->bAttackPresent && k + 1 < hMetadataPMC->nbands_coded ) + { + Copy( value_buffer + k * map_size, value_buffer + ( k + 1 ) * map_size, map_size ); + } + } + } + + return; +} +#endif // IVAS_FLOAT_FIXED static void ivas_param_mc_bs_decode_parameter_values( uint16_t bit_buffer[], /* i : bitstream buffer */ diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index e9602d536c598acd9167ef4a5942f74edc7b03f4..cb15a6c1a6c090298484164848511b6832badadb 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -469,16 +469,15 @@ typedef struct stereo_td_dec_data_structure #ifndef IVAS_FLOAT_FIXED float TCX_old_syn_Overl[L_FRAME16k / 2]; /* past ovrl buffer for possible switching from TD stereo ACELP to MDCT stereo TCX frame */ -#else - Word32 TCX_old_syn_Overl_fx[L_FRAME16k / 2]; /* past ovrl buffer for possible switching from TD stereo ACELP to MDCT stereo TCX frame */ /* Q11 */ -#endif - float prevSP_ratio; /* previous SP ratio */ - Word32 prevSP_ratio_fx; /* previous SP ratio */ float SP_ratio_LT; /* longterm SP ratio */ - Word32 SP_ratio_LT_fx; /* longterm SP ratio */ float c_LR_LT; /* left-right cross-correlation */ +#else + Word32 TCX_old_syn_Overl_fx[L_FRAME16k / 2]; /* past ovrl buffer for possible switching from TD stereo ACELP to MDCT stereo TCX frame */ /* Q11 */ + Word16 prevSP_ratio_fx; /* previous SP ratio */ + Word32 SP_ratio_LT_fx; /* longterm SP ratio */ Word32 c_LR_LT_fx; /* left-right cross-correlation */ +#endif } STEREO_TD_DEC_DATA, *STEREO_TD_DEC_DATA_HANDLE; @@ -779,12 +778,12 @@ typedef struct dirac_output_synthesis_cov_state_structure Word32 *mixing_matrix_res_old_fx[CLDFB_NO_CHANNELS_MAX]; Word32 *mixing_matrix_res_fx[CLDFB_NO_CHANNELS_MAX]; - Word16 *cx_old_e; - Word16 *cy_old_e; - Word16 *mixing_matrix_old_e; - Word16 *mixing_matrix_e; - Word16 *mixing_matrix_res_old_e; - Word16 *mixing_matrix_res_e; + Word16 * cx_old_e; + Word16 *cy_old_e; + Word16 *mixing_matrix_old_exp; + Word16 *mixing_matrix_res_old_exp; + Word16 *mixing_matrix_exp; + Word16 *mixing_matrix_res_exp; #endif // IVAS_FLOAT_FIXED } DIRAC_OUTPUT_SYNTHESIS_COV_STATE; diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index 063908d25fa76ccfb36307554d6d7b4934d39ccc..6036f72d06a0545875864313747add2aecd23420 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -1830,9 +1830,6 @@ static void stereo_cng_compute_LRcorr_fx( c_fx = BASOP_Util_Divide3232_Scale( (Word32) enrL_fx, (Word32) enrR_fx, &div_q ); c_q = 15 - div_q + ( enrR_q - enrL_q ); - // to be delete - hCPE->hStereoTD->c_LR_LT = (float) hCPE->hStereoTD->c_LR_LT_fx / ( ONE_IN_Q31 ); - hCPE->hStereoTD->c_LR_LT_fx = L_add( Mpy_32_32( STEREO_TD_PS_CORR_FILT_FX, hCPE->hStereoTD->c_LR_LT_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, STEREO_TD_PS_CORR_FILT_FX ), L_deposit_h( (Word16) c_LR_fx ) ) ); hCPE->hStereoCng->c_LR_LT_fx = hCPE->hStereoTD->c_LR_LT_fx; @@ -1894,8 +1891,6 @@ static void stereo_cng_compute_LRcorr_fx( hCPE->hStereoTD->SP_ratio_LT_fx = L_add_sat( Mpy_32_32( 1932735283, hCPE->hStereoTD->SP_ratio_LT_fx ), L_shl_sat( Mpy_32_32( 214748364, sqrt_res ), sqrt_q ) ); - // to be deleted - hCPE->hStereoTD->SP_ratio_LT = (float) hCPE->hStereoTD->SP_ratio_LT_fx / ONE_IN_Q31; IF( hCPE->hStereoCng->nr_corr_frames < CM_INIT ) { hCPE->hStereoCng->nr_corr_frames++; diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index a4c5ef026d0d814a6159eba30f849e4363cfa7a0..b56676021a1e4f1e5041575f1a71ffc354b84ea3 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -263,7 +263,7 @@ static ivas_error allocate_CoreCoder( Init_post_filter_ivas( st->hPFstat ); #ifdef IVAS_FLOAT_FIXED - Init_post_filter(st->hPFstat); + Init_post_filter_fx(st->hPFstat); #endif // IVAS_FLOAT_FIXED st->psf_lp_noise = 0.0f; } @@ -344,7 +344,7 @@ static ivas_error allocate_CoreCoder_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for NB/formant postflter\n" ) ); } - Init_post_filter( st->hPFstat ); + Init_post_filter_fx( st->hPFstat ); st->psf_lp_noise_fx = 0; move16(); diff --git a/lib_dec/ivas_stereo_td_dec.c b/lib_dec/ivas_stereo_td_dec.c index d0202a9e6117563c5b14075f7a2ebb61f6a744e2..ceec414f04b73853c55faa5c943ae7a09bd78171 100644 --- a/lib_dec/ivas_stereo_td_dec.c +++ b/lib_dec/ivas_stereo_td_dec.c @@ -78,7 +78,7 @@ void stereo_td_init_dec( } #endif - +#ifdef IVAS_FLOAT_FIXED void stereo_td_init_dec_fx( STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ const int16_t last_element_mode /* i : last element mode */ @@ -89,11 +89,11 @@ void stereo_td_init_dec_fx( hStereoTD->tdm_last_ratio_idx = LRTD_STEREO_MID_IS_PRIM; hStereoTD->tdm_prev_last_SM_flag = 0; hStereoTD->tdm_LRTD_flag = 0; - hStereoTD->prevSP_ratio = 0.5f; - hStereoTD->prevSP_ratio_fx = ONE_IN_Q30; //.5 - hStereoTD->SP_ratio_LT = 0.0f; + //hStereoTD->prevSP_ratio = 0.5f; + hStereoTD->prevSP_ratio_fx = ONE_IN_Q14; //.5 + //hStereoTD->SP_ratio_LT = 0.0f; hStereoTD->SP_ratio_LT_fx = 0; - hStereoTD->c_LR_LT = 0.5f; + //hStereoTD->c_LR_LT = 0.5f; hStereoTD->c_LR_LT_fx = ONE_IN_Q30; //.5 hStereoTD->flag_skip_DMX = 0; @@ -108,7 +108,7 @@ void stereo_td_init_dec_fx( return; } - +#endif /*-------------------------------------------------------------------* * tdm_configure_dec() diff --git a/lib_dec/post_dec_fx.c b/lib_dec/post_dec_fx.c index a6f1a1ca2f2500619f2cfab1f2949854375b39c1..ddc727b09d4bda5e7b1b6efe97ee066663015435 100644 --- a/lib_dec/post_dec_fx.c +++ b/lib_dec/post_dec_fx.c @@ -8,7 +8,7 @@ #include "prot_fx1.h" #include "prot_fx2.h" #include "basop_util.h" - +#ifdef IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* * Function prototypes @@ -85,8 +85,8 @@ void post_decoder( Copy( st->hPFstat->mem_pf_in+L_SYN_MEM-M, synth-M, M ); Residu3_fx ( st->old_Aq_12_8_fx, synth, synth_buf, L_SUBFR, 1 ); E_UTIL_synthesis ( 1, st->old_Aq_12_8_fx, synth_buf, synth2, L_SUBFR, st->hPFstat->mem_stp+L_SYN_MEM-M, 0, M ); - scale_st ( synth, synth2, &st->hPFstat->gain_prec, L_SUBFR ); - blend_subfr2(synth2+L_SUBFR/2, synth+L_SUBFR/2, synth2+L_SUBFR/2); + scale_st_fx ( synth, synth2, &st->hPFstat->gain_prec, L_SUBFR ); + blend_subfr2_fx(synth2+L_SUBFR/2, synth+L_SUBFR/2, synth2+L_SUBFR/2); } } ELSE @@ -122,14 +122,14 @@ void post_decoder( st->hPFstat->on = 1; move16(); tmp_noise = 0; - nb_post_filt( L_frame, st->hPFstat, &tmp_noise, 0, synth2_pe, st->mem_Aq, pitch, GENERIC, st->BER_detect, tmp ); + nb_post_filt_fx( L_frame, st->hPFstat, &tmp_noise, 0, synth2_pe, st->mem_Aq, pitch, GENERIC, st->BER_detect, tmp ); } ELSE { st->hPFstat->on = 0; move16(); tmp_noise = 0; - nb_post_filt( L_frame, st->hPFstat, &tmp_noise, 0, synth2_pe, st->mem_Aq, pitch, AUDIO, st->BER_detect, tmp ); + nb_post_filt_fx( L_frame, st->hPFstat, &tmp_noise, 0, synth2_pe, st->mem_Aq, pitch, AUDIO, st->BER_detect, tmp ); } Copy(synth2_pe, synth2, L_frame); @@ -148,13 +148,13 @@ void post_decoder( { st->hPFstat->on = 1; move16(); - formant_post_filt( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 ); + formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 ); } ELSE { st->hPFstat->on = 0; move16(); - formant_post_filt( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 ); + formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 ); } } @@ -247,8 +247,8 @@ void post_decoder_ivas_fx( Word16 L_subfr = st->L_frame / st->nb_subfr; Residu3_fx ( st->old_Aq_12_8_fx, synth, synth_buf, L_subfr, 1 ); E_UTIL_synthesis ( 1, st->old_Aq_12_8_fx, synth_buf, synth2, L_subfr, st->hPFstat->mem_stp+L_SYN_MEM-M, 0, M ); - scale_st ( synth, synth2, &st->hPFstat->gain_prec, L_subfr ); - blend_subfr2(synth2+L_subfr/2, synth+L_subfr/2, synth2+L_subfr/2); + scale_st_fx ( synth, synth2, &st->hPFstat->gain_prec, L_subfr ); + blend_subfr2_fx(synth2+L_subfr/2, synth+L_subfr/2, synth2+L_subfr/2); } } ELSE @@ -284,14 +284,14 @@ void post_decoder_ivas_fx( st->hPFstat->on = 1; move16(); tmp_noise = 0; - nb_post_filt( L_frame, st->hPFstat, &tmp_noise, 0, synth2_pe, st->mem_Aq, pitch, GENERIC, st->BER_detect, tmp ); + nb_post_filt_fx( L_frame, st->hPFstat, &tmp_noise, 0, synth2_pe, st->mem_Aq, pitch, GENERIC, st->BER_detect, tmp ); } ELSE { st->hPFstat->on = 0; move16(); tmp_noise = 0; - nb_post_filt( L_frame, st->hPFstat, &tmp_noise, 0, synth2_pe, st->mem_Aq, pitch, AUDIO, st->BER_detect, tmp ); + nb_post_filt_fx( L_frame, st->hPFstat, &tmp_noise, 0, synth2_pe, st->mem_Aq, pitch, AUDIO, st->BER_detect, tmp ); } Copy(synth2_pe, synth2, L_frame); @@ -310,13 +310,13 @@ void post_decoder_ivas_fx( { st->hPFstat->on = 1; move16(); - formant_post_filt( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 ); + formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 ); } ELSE { st->hPFstat->on = 0; move16(); - formant_post_filt( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 ); + formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 ); } } @@ -833,3 +833,4 @@ void cldfb_synth_set_bandsToZero( return; } +#endif \ No newline at end of file diff --git a/lib_dec/voiced_dec.c b/lib_dec/voiced_dec.c index acd98de402aa77e349ef3165470227f6d911dc8e..76cf273a568504d6c6abfd1e9c12ae94872e7a4b 100644 --- a/lib_dec/voiced_dec.c +++ b/lib_dec/voiced_dec.c @@ -124,7 +124,7 @@ ivas_error ppp_voiced_decoder( { for ( k = 0; k < NB_SUBFR; k++ ) { - /* do the linear pitch interp to drive the nb_post_filt */ + /* do the linear pitch interp to drive the nb_post_filt_fx */ Interpol_delay( interp_delay, &( temp_pl ), &( temp_l ), k, frac_4sf ); pitch[k] = min( MAX_LAG_PIT, max( 19, interp_delay[0] ) ); } diff --git a/lib_dec/voiced_dec_fx.c b/lib_dec/voiced_dec_fx.c index 607939b6dfe78eea5d81b2a3a23249bf35dfc5cc..c5d761968ab7b66d521c9b11a1cffc862cd9bf1c 100644 --- a/lib_dec/voiced_dec_fx.c +++ b/lib_dec/voiced_dec_fx.c @@ -158,7 +158,7 @@ ivas_error ppp_voiced_decoder_fx( { FOR(k=0; k