From 942bd24b769abd6dcc3aeb4f2ff2302401936a3e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Sat, 19 Oct 2024 12:03:50 +0530 Subject: [PATCH] LTV crash fixes in OMASA encoder and stereo encoder paths, float code cleanup --- lib_com/float_to_fix_ops.c | 4 +- lib_com/ivas_cnst.h | 2 +- lib_enc/FEC_enc.c | 5 +- lib_enc/SNR_calc.c | 2 + lib_enc/acelp_core_enc.c | 60 ++-------- lib_enc/analy_lp_fx.c | 102 +++++++++++++++++ lib_enc/cng_enc.c | 2 + lib_enc/comvad_decision.c | 2 + lib_enc/core_enc_init.c | 12 ++ lib_enc/core_enc_switch.c | 1 - lib_enc/core_enc_updt.c | 5 +- lib_enc/dtx.c | 56 ++++++++-- lib_enc/dtx_fx.c | 12 +- lib_enc/enc_gen_voic_rf.c | 2 +- lib_enc/energy.c | 2 + lib_enc/ext_sig_ana.c | 10 -- lib_enc/find_uv.c | 1 - lib_enc/igf_enc.c | 11 +- lib_enc/init_enc.c | 30 +++-- lib_enc/ivas_core_enc.c | 29 +---- lib_enc/ivas_core_pre_proc.c | 2 +- lib_enc/ivas_core_pre_proc_front.c | 4 +- lib_enc/ivas_enc.c | 2 +- lib_enc/ivas_front_vad.c | 2 +- lib_enc/ivas_masa_enc.c | 164 +++++++++++++++++----------- lib_enc/ivas_mct_enc.c | 36 +----- lib_enc/ivas_mdct_core_enc.c | 26 ++--- lib_enc/ivas_omasa_enc.c | 11 +- lib_enc/ivas_stereo_mdct_core_enc.c | 30 ----- lib_enc/ivas_stereo_switching_enc.c | 5 +- lib_enc/ivas_tcx_core_enc.c | 5 - lib_enc/lib_enc.c | 28 ++--- lib_enc/lsf_enc.c | 2 + lib_enc/prot_fx_enc.h | 19 ++++ lib_enc/stat_enc.h | 145 +++++++++++++++--------- lib_enc/swb_tbe_enc_fx.c | 2 +- lib_enc/tcx_utils_enc.c | 9 +- lib_enc/vad_proc.c | 2 + 38 files changed, 480 insertions(+), 364 deletions(-) diff --git a/lib_com/float_to_fix_ops.c b/lib_com/float_to_fix_ops.c index 432bc2d2e..ff8e6fd4f 100644 --- a/lib_com/float_to_fix_ops.c +++ b/lib_com/float_to_fix_ops.c @@ -29,9 +29,9 @@ Word32 floatToFixed( float f, Word16 Q ) float fixedToFloat( Word32 i, Word16 Q ) { if ( Q < 0 ) - return ( i * (float) ( ( (unsigned) 1 ) << ( -Q ) ) ); + return ( i * (float) ( ( 1LL ) << ( -Q ) ) ); else - return (float) ( i ) / (float) ( (unsigned int) 1 << Q ); + return (float) ( i ) / (float) ( 1LL << Q ); } void floatToFixed_arrL( float *f, Word32 *i, Word16 Q, Word16 l ) { diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index fec666981..36d75a7c8 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -49,7 +49,7 @@ #define PI_OVER_180_Q22 ( 73204 ) #define _180_OVER_PI ( 180.0f / EVS_PI ) #ifdef IVAS_FLOAT_FIXED -#define _180_OVER_PI_Q25 1922521886 +#define _180_OVER_PI_Q25 1922527338 #define PI_OVER_180_Q25 ( 585635 ) #define _180_IN_Q22 (754974720) #define _360_IN_Q22 (1509949440) diff --git a/lib_enc/FEC_enc.c b/lib_enc/FEC_enc.c index fe61b552d..d011b5961 100644 --- a/lib_enc/FEC_enc.c +++ b/lib_enc/FEC_enc.c @@ -217,7 +217,7 @@ void FEC_encode_ivas_fx( return; } -#endif +#else void FEC_encode( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */ @@ -350,7 +350,9 @@ void FEC_encode( return; } +#endif +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * FEC_lsf_estim_enc() * @@ -438,3 +440,4 @@ void FEC_lsf_estim_enc( return; } +#endif diff --git a/lib_enc/SNR_calc.c b/lib_enc/SNR_calc.c index 7e9f297aa..0f8376c52 100644 --- a/lib_enc/SNR_calc.c +++ b/lib_enc/SNR_calc.c @@ -42,6 +42,7 @@ #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * SNR_calc() * @@ -259,3 +260,4 @@ void calc_lf_snr( return; } +#endif diff --git a/lib_enc/acelp_core_enc.c b/lib_enc/acelp_core_enc.c index b80450511..95a187a6e 100644 --- a/lib_enc/acelp_core_enc.c +++ b/lib_enc/acelp_core_enc.c @@ -230,7 +230,6 @@ ivas_error acelp_core_enc( floatToFixed_arr( &inp[-M - 1], &inp_fx[-M - 1], Q_new, L_FRAME16k + M + 1 ); floatToFixed_arrL( st->Bin_E_old, st->Bin_E_old_fx, Q_new + Q_SCALE - 2, 128 ); floatToFixed_arrL( st->Bin_E, st->Bin_E_fx, Q_new + Q_SCALE - 2, 256 ); - st->stab_fac_fx = float_to_fix16( st->stab_fac, Q15 ); IF( hStereoTD ) { floatToFixed_arr( hStereoTD->tdm_Pri_pitch_buf, hStereoTD->tdm_Pri_pitch_buf_fx, Q6, 4 ); @@ -337,7 +336,11 @@ ivas_error acelp_core_enc( move16(); /* channel-aware mode */ +#ifndef IVAS_FLOAT_FIXED reset_rf_indices( st->hRF, st->L_frame, &st->rf_target_bits_write ); +#else + reset_rf_indices_fx( st ); +#endif /* VBR modes */ IF( st->Opt_SC_VBR ) @@ -499,25 +502,13 @@ ivas_error acelp_core_enc( floatToFixed_arr( Aq, Aq_fx, NB_SUBFR16k * ( M + 1 ), Q12 ); q_inp = Q_factor_arr( inp, st->L_frame ); floatToFixed_arr( inp, inp_fx, q_inp, st->L_frame ); - st->hTdCngEnc->CNG_att_fx = float_to_fix16( st->hTdCngEnc->CNG_att, Q7 ); floatToFixed_arr( lsp_mid, lsp_mid_fx, Q15, M ); floatToFixed_arr( lsp_new, lsp_new_fx, Q15, M ); floatToFixed_arr( st->lsp_old, st->lsp_old_fx, Q15, M ); - floatToFixed_arr( st->hTdCngEnc->ho_lsp_hist, st->hTdCngEnc->ho_lsp_hist_fx, Q15, HO_HIST_SIZE * M ); floatToFixed_arr( st->hTdCngEnc->ho_lsp_circ, st->hTdCngEnc->ho_lsp_circ_fx, Q15, HO_HIST_SIZE * M ); floatToFixed_arr( st->hTdCngEnc->ho_lsp_circ2, st->hTdCngEnc->ho_lsp_circ2_fx, Q15, HO_HIST_SIZE * M ); - floatToFixed_arrL( st->hTdCngEnc->ho_ener_hist, st->hTdCngEnc->ho_ener_hist_fx, Q6, HO_HIST_SIZE ); floatToFixed_arrL( st->hTdCngEnc->ho_ener_circ, st->hTdCngEnc->ho_ener_circ_fx, Q6, HO_HIST_SIZE ); - floatToFixed_arr( st->hTdCngEnc->cng_ener_hist, st->hTdCngEnc->cng_ener_hist_fx, Q8, DTX_HIST_SIZE ); - floatToFixed_arr( st->hDtxEnc->lspCNG, st->hDtxEnc->lspCNG_fx, Q15, M ); - floatToFixed_arrL( st->hTdCngEnc->cng_res_env, st->hTdCngEnc->cng_res_env_fx, Q6, NUM_ENV_CNG * HO_HIST_SIZE ); - floatToFixed_arr( st->hTdCngEnc->cng_lsp_hist, st->hTdCngEnc->cng_lsp_hist_fx, Q15, DTX_HIST_SIZE * M ); - floatToFixed_arrL( st->hTdCngEnc->lp_env, st->hTdCngEnc->lp_env_fx, Q6, NUM_ENV_CNG ); - floatToFixed_arrL( st->hTdCngEnc->ho_env_hist, st->hTdCngEnc->ho_env_hist_fx, Q6, HO_HIST_SIZE * NUM_ENV_CNG ); floatToFixed_arr( st->hTdCngEnc->exc_mem2, st->hTdCngEnc->exc_mem2_fx, q_inp, 30 ); - st->hTdCngEnc->lp_ener_fx = float_to_fix( st->hTdCngEnc->lp_ener, Q6 ); - st->hTdCngEnc->Enew_fx = float_to_fix( st->hTdCngEnc->Enew, Q6 ); - st->hTdCngEnc->lp_sp_enr_fx = float_to_fix16( st->hTdCngEnc->lp_sp_enr, Q8 ); for ( i = 0; i < M; i++ ) { lsf_new_fx[i] = (Word16) ( lsf_new[i] * 2.56f ); @@ -531,23 +522,11 @@ ivas_error acelp_core_enc( fixedToFloat_arr( lsp_new_fx, lsp_new, Q15, M ); fixedToFloat_arrL32( q_env_fx, q_env, Q6, NUM_ENV_CNG ); fixedToFloat_arr( st->lsp_old_fx, st->lsp_old, Q15, M ); - fixedToFloat_arr( st->hDtxEnc->lspCNG_fx, st->hDtxEnc->lspCNG, Q15, M ); fixedToFloat_arr( st->hTdCngEnc->ho_lsp_circ_fx, st->hTdCngEnc->ho_lsp_circ, Q15, HO_HIST_SIZE * M ); fixedToFloat_arr( st->hTdCngEnc->ho_lsp_circ2_fx, st->hTdCngEnc->ho_lsp_circ2, Q15, HO_HIST_SIZE * M ); - fixedToFloat_arr( st->hTdCngEnc->ho_lsp_hist_fx, st->hTdCngEnc->ho_lsp_hist, Q15, HO_HIST_SIZE * M ); fixedToFloat_arrL( st->hTdCngEnc->ho_env_circ_fx, st->hTdCngEnc->ho_env_circ, Q6, 160 ); - fixedToFloat_arrL( st->hTdCngEnc->cng_res_env_fx, st->hTdCngEnc->cng_res_env, Q6, NUM_ENV_CNG * HO_HIST_SIZE ); - fixedToFloat_arr( st->hTdCngEnc->cng_ener_hist_fx, st->hTdCngEnc->cng_ener_hist, Q8, DTX_HIST_SIZE ); - fixedToFloat_arrL( st->hTdCngEnc->ho_ener_hist_fx, st->hTdCngEnc->ho_ener_hist, Q6, HO_HIST_SIZE ); fixedToFloat_arrL( st->hTdCngEnc->ho_ener_circ_fx, st->hTdCngEnc->ho_ener_circ, Q6, HO_HIST_SIZE ); - fixedToFloat_arr( st->hTdCngEnc->cng_lsp_hist_fx, st->hTdCngEnc->cng_lsp_hist, Q15, DTX_HIST_SIZE * M ); - fixedToFloat_arrL( st->hTdCngEnc->lp_env_fx, st->hTdCngEnc->lp_env, Q6, NUM_ENV_CNG ); - fixedToFloat_arrL( st->hTdCngEnc->ho_env_hist_fx, st->hTdCngEnc->ho_env_hist, Q6, HO_HIST_SIZE * NUM_ENV_CNG ); fixedToFloat_arr( st->hTdCngEnc->exc_mem2_fx, st->hTdCngEnc->exc_mem2, q_inp, 30 ); - st->hTdCngEnc->lp_sp_enr = fix16_to_float( st->hTdCngEnc->lp_sp_enr_fx, Q8 ); - st->hTdCngEnc->lp_ener = fix_to_float( st->hTdCngEnc->lp_ener_fx, Q6 ); - st->hTdCngEnc->Enew = fix_to_float( st->hTdCngEnc->Enew_fx, Q6 ); - st->hTdCngEnc->CNG_att = fix16_to_float( st->hTdCngEnc->CNG_att_fx, Q7 ); for ( i = 0; i < M; i++ ) { lsf_new[i] = ( (float) lsf_new_fx[i] / 2.56f ); @@ -562,11 +541,7 @@ ivas_error acelp_core_enc( #endif #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - st->hTdCngEnc->Enew_fx = float_to_fix( st->hTdCngEnc->Enew, Q6 ); - st->hTdCngEnc->lp_ener_fx = float_to_fix( st->hTdCngEnc->lp_ener, Q6 ); floatToFixed_arr32( q_env, q_env_fx, Q6, NUM_ENV_CNG ); - floatToFixed_arr32( st->hTdCngEnc->lp_env, st->hTdCngEnc->lp_env_fx, Q6, NUM_ENV_CNG ); - floatToFixed_arr32( st->hTdCngEnc->old_env, st->hTdCngEnc->old_env_fx, Q6, NUM_ENV_CNG ); // Word16 Q_exc_l = Q_factor_arr( st->hTdCngEnc->exc_mem, 24 ); // Word16 Q_exc1_l = Q_factor_arr( st->hTdCngEnc->exc_mem1, 30 ); // Q_exc_l = min( Q_exc_l, Q_exc1_l ); @@ -583,11 +558,7 @@ ivas_error acelp_core_enc( q_env_fx, st->hTdCngEnc->lp_env_fx, st->hTdCngEnc->old_env_fx, st->hTdCngEnc->exc_mem_fx, st->hTdCngEnc->exc_mem1_fx, &sid_bw, &st->hTdCngEnc->cng_ener_seed1, exc3_fx, st->Opt_AMR_WB, EVS_MONO ); #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - st->hTdCngEnc->Enew = fixedToFloat( st->hTdCngEnc->Enew_fx, Q6 ); - st->hTdCngEnc->lp_ener = fixedToFloat( st->hTdCngEnc->lp_ener_fx, Q6 ); fixedToFloat_arrL( q_env_fx, q_env, Q6, NUM_ENV_CNG ); - fixedToFloat_arrL( st->hTdCngEnc->lp_env_fx, st->hTdCngEnc->lp_env, Q6, NUM_ENV_CNG ); - fixedToFloat_arrL( st->hTdCngEnc->old_env_fx, st->hTdCngEnc->old_env, Q6, NUM_ENV_CNG ); fixedToFloat_arr( exc_fx, exc, Q_new, st->L_frame ); fixedToFloat_arr( exc2_fx, exc2, Q_new, st->L_frame ); fixedToFloat_arr( exc3_fx, exc3, Q_new, st->L_frame ); @@ -616,10 +587,6 @@ ivas_error acelp_core_enc( Word16 Q_cngNoise = Q_factor_arrL( st->hFdCngEnc->hFdCngCom->cngNoiseLevel_flt, FFTCLDFBLEN ); floatToFixed_arrL( st->hFdCngEnc->hFdCngCom->cngNoiseLevel_flt, st->hFdCngEnc->hFdCngCom->cngNoiseLevel, Q_cngNoise, FFTCLDFBLEN ); st->hFdCngEnc->hFdCngCom->cngNoiseLevelExp = sub( 31, Q_cngNoise ); - IF( st->hTdCngEnc != NULL ) - { - st->hTdCngEnc->CNG_att_fx = float_to_fix16( st->hTdCngEnc->CNG_att, Q7 ); - } st->preemph_fac = float_to_fix16( st->preemph_fac_flt, Q15 ); #endif // generate_comfort_noise_enc( st ); @@ -637,7 +604,6 @@ ivas_error acelp_core_enc( // Word16 Q_exc_cng_l = Q_factor_arr( st->hFdCngEnc->hFdCngCom->exc_cng_flt, st->L_frame ); floatToFixed_arr( st->hFdCngEnc->hFdCngCom->exc_cng_flt, st->hFdCngEnc->hFdCngCom->exc_cng, Q_new, st->L_frame ); floatToFixed_arr( st->lsp_old, st->lsp_old_fx, Q15, M ); - floatToFixed_arr( st->hDtxEnc->lspCNG, st->hDtxEnc->lspCNG_fx, Q15, M ); #endif // FdCng_exc_flt( st->hFdCngEnc->hFdCngCom, &st->hDtxEnc->CNG_mode, st->L_frame, st->lsp_old, st->hDtxEnc->first_CNG, st->hDtxEnc->lspCNG, Aq, lsp_new, lsf_new, exc, exc2, bwe_exc ); FdCng_exc( st->hFdCngEnc->hFdCngCom, &st->hDtxEnc->CNG_mode, st->L_frame, st->lsp_old_fx, st->hDtxEnc->first_CNG, st->hDtxEnc->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx ); @@ -649,7 +615,6 @@ ivas_error acelp_core_enc( lsf_new[i] = ( (float) lsf_new_fx[i] / 2.56f ); } - fixedToFloat_arr( st->hDtxEnc->lspCNG_fx, st->hDtxEnc->lspCNG, Q15, M ); fixedToFloat_arr( exc_fx, exc, Q_new, st->L_frame ); fixedToFloat_arr( exc2_fx, exc2, Q_new, st->L_frame ); IF( st->hBWE_TD != NULL ) @@ -666,7 +631,6 @@ ivas_error acelp_core_enc( { Word16 enr, enr_index; #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - st->hTdCngEnc->CNG_att_fx = float_to_fix16( st->hTdCngEnc->CNG_att, Q7 ); // Word16 Q_exc_l = Q_factor_arr( exc, st->L_frame ); floatToFixed_arr( exc, exc_fx, Q_new, st->L_frame ); #endif @@ -703,14 +667,14 @@ ivas_error acelp_core_enc( Q_syn_l = Q_factor_arr( hLPDmem->mem_syn3_flt, M ); floatToFixed_arr( hLPDmem->mem_syn3_flt, hLPDmem->mem_syn3, Q_syn_l, M ); - floatToFixed_arr( Aq, Aq_fx, NB_SUBFR16k * ( M + 1 ), Q12 ); + floatToFixed_arr( Aq, Aq_fx, Q12, NB_SUBFR16k * ( M + 1 ) ); #endif /* synthesis at 12.8kHz sampling rate */ syn_12k8_fx( st->L_frame, Aq_fx, exc3_fx, syn1_fx, hLPDmem->mem_syn3, 1, Q_exc_l, Q_syn_l ); #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - fixedToFloat_arr( Aq_fx, Aq, NB_SUBFR16k * ( M + 1 ), Q12 ); - fixedToFloat_arr( exc3_fx, exc, st->L_frame, Q_exc_l ); + fixedToFloat_arr( Aq_fx, Aq, Q12, NB_SUBFR16k * ( M + 1 ) ); + fixedToFloat_arr( exc3_fx, exc, Q_exc_l, st->L_frame ); fixedToFloat_arr( hLPDmem->mem_syn3, hLPDmem->mem_syn3_flt, Q_syn_l, M ); fixedToFloat_arr( syn1_fx, syn1, Q_syn_l, st->L_frame ); #endif @@ -793,10 +757,6 @@ ivas_error acelp_core_enc( } } - IF( st->hDtxEnc ) - { - floatToFixed_arr( st->hDtxEnc->lspCNG, st->hDtxEnc->lspCNG_fx, Q15, M ); - } for ( i = 0; i < M; i++ ) { st->lsf_old_fx[i] = (Word16) ( st->lsf_old[i] * 2.56f ); @@ -816,8 +776,6 @@ ivas_error acelp_core_enc( st->clip_var_fx[3] = float_to_fix16( st->clip_var[3], 0 ); st->clip_var_fx[4] = float_to_fix16( st->clip_var[4], Q14 ); st->clip_var_fx[5] = float_to_fix16( st->clip_var[5], Q14 ); - - st->streaklimit_fx = (Word16) floatToFixed( st->streaklimit, Q15 ); FOR( Word16 idx = 0; idx < M; idx++ ) { st->lsf_adaptive_mean_fx[idx] = (Word16) ( st->lsf_adaptive_mean[idx] * 2.56f ); @@ -847,8 +805,6 @@ ivas_error acelp_core_enc( st->hGSCEnc->last_ener_fx = (Word16) st->hGSCEnc->last_ener; IF( st->hLPDmem ) st->hLPDmem->tilt_code = float_to_fix16( st->hLPDmem->tilt_code_flt, Q15 ); - IF( st->hTdCngEnc ) - st->hTdCngEnc->CNG_att_fx = float_to_fix16( st->hTdCngEnc->CNG_att, Q7 ); #endif /*-----------------------------------------------------------------* * Configure ACELP bit allocation @@ -1075,7 +1031,6 @@ ivas_error acelp_core_enc( // So each chunk might have a different Q which is predicted by 1st element. fixedToFloat_arr( &Aq_fx[i * ( M + 1 )], &Aq[i * ( M + 1 )], 14 - norm_s( Aq_fx[i * ( M + 1 )] ), ( M + 1 ) ); } - st->stab_fac = fixedToFloat( st->stab_fac_fx, Q15 ); fixedToFloat_arr( old_exc_fx, old_exc_flt, Q15 - hLPDmem->e_old_exc, st->L_frame ); me2f_buf_16( &hLPDmem->old_exc[-M - 1], hLPDmem->e_old_exc, &hLPDmem->old_exc_flt[-M - 1], L_EXC_MEM + M + 1 ); fixedToFloat_arr( old_bwe_exc_fx, old_bwe_exc, Q_old_bwe_exc, 1380 ); @@ -1510,7 +1465,6 @@ ivas_error acelp_core_enc( floatToFixed_arr16( exc, exc_fx, q_exc, L_EXC - L_EXC_MEM ); floatToFixed_arr16( st->hTdCngEnc->cng_exc2_buf_flt, st->hTdCngEnc->cng_exc2_buf, q_exc, HO_HIST_SIZE * L_FFT ); - floatToFixed_arr32( st->hTdCngEnc->ho_ener_circ, st->hTdCngEnc->ho_ener_circ_fx, Q6, HO_HIST_SIZE ); floatToFixed_arr32( st->hTdCngEnc->ho_env_circ, st->hTdCngEnc->ho_env_circ_fx, Q6, HO_HIST_SIZE * NUM_ENV_CNG ); floatToFixed_arr16( st->hTdCngEnc->ho_lsp_circ, st->hTdCngEnc->ho_lsp_circ_fx, Q15, HO_HIST_SIZE * M ); diff --git a/lib_enc/analy_lp_fx.c b/lib_enc/analy_lp_fx.c index 314f7a9c2..cd8856713 100644 --- a/lib_enc/analy_lp_fx.c +++ b/lib_enc/analy_lp_fx.c @@ -23,6 +23,108 @@ * - find interpolated LSPs and convert back to A(z) for all subframes * - update LSPs for the next frame *-------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void analy_lp_ivas_fx( + const Word16 speech[], /* i :(Q_new) pointer to the speech frame */ + const Word16 L_frame, /* i :(q0) length of the frame */ + const Word16 L_look, /* i :(q0) look-ahead */ + Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */ + Word16 A[], /* o :(q14) A(z) filter coefficients */ + Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */ + Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */ + Word16 lsp_new[], /* o :(q15) current frame LSPs */ + Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */ + Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */ + const Word16 Top[2], /* i :(q0) open loop pitch lag */ + const Word16 Tnc[2], /* i :(q15) open loop pitch gain */ + const Word32 Core_sr, /* i :(q0) Internal core sampling rate */ + const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */ + Word16 Q_new, /*i: stores Q for speech*/ + Word16 *Q_r /*stores q for ener*/ ) +{ + Word16 r_h[M + 1]; /* Autocorrelations of windowed speech MSB */ + Word16 r_l[M + 1]; /* Autocorrelations of windowed speech LSB */ + Word32 LepsP[M + 1]; + Word16 i, i_subfr, wind_length = 0; + Word16 *lsp; + const Word16 *wind = NULL; + const Word16 *pt; + Word16 half_frame; + move16(); /* wind_length*/ + + IF( EQ_16( L_frame, L_FRAME ) ) + { + wind_length = L_LP; + move16(); + wind = Assym_window_W16fx; /*q15*/ + } + ELSE /* L_frame == L_FRAME16k */ + { + wind_length = L_LP_16k; + move16(); + wind = assym_window_16k_fx; /*q15*/ + } + lsp = lsp_mid; + half_frame = shr( L_frame, 1 ); + + FOR( i_subfr = 0; i_subfr <= 1; i_subfr++ ) + { + pt = speech + sub( add( half_frame, L_look ), wind_length ); + half_frame = shl( half_frame, 1 ); + + /* Autocorrelations */ + autocorr_fx( pt, M, r_h, r_l, &Q_r[1 - i_subfr], wind_length, wind, 0, 0 ); + + /*if ( r[0] < 100.0f && no_thr == 0 )*/ + /*r[0] = 100.0f*/ + IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( L_Comp( r_h[0], r_l[0] ) /* Q_r[1 - i_subfr]*/, sub( 31, add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ) ), 100 /*q0*/, 31 ), -1 ) ) + { + /*Q_min stores min of 24 and the actual Q for r*/ + Word16 Q_min = s_min( add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ), 24 ); /* comparing q with 24 because exponent of 100 is 7 so max q should be 24*/ + L_Extract( L_shl( 100, Q_min ), &r_h[0], &r_l[0] ); /*extracting high and low components of r[0]*/ + FOR( i = 1; i < 17; i++ ) + { + L_Extract( L_shr( L_Comp( r_h[i], r_l[i] ), sub( add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ), Q_min ) ), &r_h[i], &r_l[i] ); /*scaling all the values to q24*/ + } + Q_r[1 - i_subfr] = sub( Q_min, shl( Q_new, 1 ) ); /*updating the q (subtracting shl( Q_new, 1 ) as in later part it is being added-> to maintain q24 )*/ + move16(); + } + + /* Lag windowing */ + adapt_lag_wind( r_h, r_l, M, Top[i_subfr], Tnc[i_subfr], Core_sr ); + + /* Levinson-Durbin */ + E_LPC_lev_dur( r_h, r_l, A, LepsP, M, NULL ); + FOR( i = 0; i <= M; i++ ) + { + L_Extract( LepsP[i], &epsP_h[i], &epsP_l[i] ); + } + /*Q_r[... might not be needed from external...*/ + Q_r[1 - i_subfr] = add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ); + move16(); + + /* Conversion of A(z) to LSPs */ + E_LPC_a_lsp_conversion( A, lsp, lsp_old, M ); + + lsp = lsp_new; + } + IF( EQ_16( sec_chan_low_rate, 1 ) ) + { + /* LSP interpolation */ + int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 ); + } + ELSE + { + /* LSP interpolation */ + int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 ); + } + Copy( lsp_new, lsp_old, M ); + *ener = L_Comp( epsP_h[M], epsP_l[M] ); + move32(); + + return; +} +#endif // IVAS_FLOAT_FIXED void analy_lp_fx( const Word16 speech[], /* i : pointer to the speech frame */ diff --git a/lib_enc/cng_enc.c b/lib_enc/cng_enc.c index 571fc3549..2c1fbc639 100644 --- a/lib_enc/cng_enc.c +++ b/lib_enc/cng_enc.c @@ -1504,6 +1504,7 @@ static Word16 shb_DTX_ivas_fx( } #endif +#ifndef IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* * calculate_hangover_attenuation_gain() * @@ -1548,3 +1549,4 @@ void calculate_hangover_attenuation_gain( return; } +#endif diff --git a/lib_enc/comvad_decision.c b/lib_enc/comvad_decision.c index d5d81c691..5eb7aeda6 100644 --- a/lib_enc/comvad_decision.c +++ b/lib_enc/comvad_decision.c @@ -41,6 +41,7 @@ #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * local function prototypes *-------------------------------------------------------------------*/ @@ -873,3 +874,4 @@ static int16_t comvad_hangover( return speech_flag; } +#endif diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c index cad53d599..4599d1d11 100644 --- a/lib_enc/core_enc_init.c +++ b/lib_enc/core_enc_init.c @@ -354,7 +354,11 @@ void init_coder_ace_plus( { set_zero( hTcxEnc->Txnq_flt, L_FRAME32k / 2 + 64 ); hTcxEnc->acelp_zir_flt = hTcxEnc->Txnq_flt + L_FRAME / 2; +#ifndef IVAS_FLOAT_FIXED hTcxEnc->tcx_target_bits_fac_flt = 1.0f; +#else + hTcxEnc->tcx_target_bits_fac = ONE_IN_Q14; +#endif #ifdef IVAS_FLOAT_FIXED set16_fx( hTcxEnc->Txnq, 0, L_FRAME32k / 2 + 64 ); @@ -732,7 +736,11 @@ static void init_tcx( #endif /* Init TCX target bits correction factor */ +#ifndef IVAS_FLOAT_FIXED hTcxEnc->tcx_target_bits_fac_flt = 1.0f; +#else + hTcxEnc->tcx_target_bits_fac = ONE_IN_Q14; +#endif hTcxEnc->measuredBwRatio_flt = 1.0f; #ifndef IVAS_FLOAT_FIXED hTcxEnc->noiseTiltFactor_flt = 0.5625f; @@ -762,7 +770,11 @@ static void init_tcx( #endif hTcxEnc->tcxltp_norm_corr_past_flt = 0.f; hTcxEnc->tcxltp_norm_corr_mem_flt = 0.f; +#ifndef IVAS_FLOAT_FIXED hTcxEnc->kernel_switch_corr_past_flt = 0.f; +#else + hTcxEnc->kernel_switch_corr_past = 0; +#endif hTcxEnc->kernel_symmetry_past = 0; /* MDCT_IV & 1 */ hTcxEnc->enc_ste_pre_corr_past = 0; hTcxEnc->tfm_mem = 0.75f; diff --git a/lib_enc/core_enc_switch.c b/lib_enc/core_enc_switch.c index e3cd4c601..f6c196b42 100644 --- a/lib_enc/core_enc_switch.c +++ b/lib_enc/core_enc_switch.c @@ -210,7 +210,6 @@ void core_coder_mode_switch_ivas_fx( { set_zero( hTcxEnc->Txnq_flt, L_FRAME32k / 2 + 64 ); hTcxEnc->acelp_zir_flt = hTcxEnc->Txnq_flt + L_FRAME / 2; - hTcxEnc->tcx_target_bits_fac_flt = 1.0f; } } diff --git a/lib_enc/core_enc_updt.c b/lib_enc/core_enc_updt.c index a388365f6..4c525bd6d 100644 --- a/lib_enc/core_enc_updt.c +++ b/lib_enc/core_enc_updt.c @@ -50,6 +50,7 @@ * Common updates of buffers *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void core_encode_update( Encoder_State *st /* i/o: Encoder state structure */ ) @@ -105,9 +106,7 @@ void core_encode_update( return; } - - -#ifdef IVAS_FLOAT_FIXED +#else void core_encode_update_ivas_fx( Encoder_State *st /* i/o: Encoder state structure */ ) diff --git a/lib_enc/dtx.c b/lib_enc/dtx.c index a466e10a9..896d58b4b 100644 --- a/lib_enc/dtx.c +++ b/lib_enc/dtx.c @@ -43,6 +43,9 @@ #include "ivas_prot.h" #include "rom_com.h" #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "prot_fx.h" +#endif /*-------------------------------------------------------------------* * Local constants @@ -541,7 +544,6 @@ static void update_SID_cnt( return; } -#endif /*-------------------------------------------------------------------* @@ -748,6 +750,7 @@ void dtx_hangover_control( return; } +#endif /*-------------------------------------------------------------------* @@ -766,25 +769,51 @@ void td_cng_enc_init( hTdCngEnc->cng_seed = RANDOM_INITSEED; hTdCngEnc->cng_ener_seed = RANDOM_INITSEED; hTdCngEnc->cng_ener_seed1 = RANDOM_INITSEED; +#ifndef IVAS_FLOAT_FIXED hTdCngEnc->lp_ener = 0.0f; +#else + hTdCngEnc->lp_ener_fx = 0; +#endif hTdCngEnc->old_enr_index = -1; +#ifndef IVAS_FLOAT_FIXED hTdCngEnc->Enew = 0.0f; hTdCngEnc->lp_sp_enr = 0.0f; +#else + hTdCngEnc->Enew_fx = 0; + + hTdCngEnc->lp_sp_enr_fx = 0; +#endif + hTdCngEnc->last_allow_cn_step = 0; +#ifndef IVAS_FLOAT_FIXED hTdCngEnc->CNG_att = 0.0f; +#else + hTdCngEnc->CNG_att_fx = 0; +#endif if ( Opt_DTX_ON ) { hTdCngEnc->cng_hist_ptr = -1; +#ifndef IVAS_FLOAT_FIXED set_f( hTdCngEnc->cng_lsp_hist, 0, DTX_HIST_SIZE * M ); set_f( hTdCngEnc->cng_ener_hist, 0, DTX_HIST_SIZE ); +#else + set16_fx( hTdCngEnc->cng_lsp_hist_fx, 0, DTX_HIST_SIZE * M ); + set16_fx( hTdCngEnc->cng_ener_hist_fx, 0, DTX_HIST_SIZE ); +#endif hTdCngEnc->ho_hist_ptr = -1; hTdCngEnc->ho_sid_bw = 0; +#ifndef IVAS_FLOAT_FIXED set_f( hTdCngEnc->ho_lsp_hist, 0, HO_HIST_SIZE * M ); set_f( hTdCngEnc->ho_ener_hist, 0, HO_HIST_SIZE ); set_f( hTdCngEnc->ho_env_hist, 0, HO_HIST_SIZE * NUM_ENV_CNG ); +#else + set16_fx( hTdCngEnc->ho_lsp_hist_fx, 0, HO_HIST_SIZE * M ); + set32_fx( hTdCngEnc->ho_ener_hist_fx, 0, HO_HIST_SIZE ); + set32_fx( hTdCngEnc->ho_env_hist_fx, 0, HO_HIST_SIZE * NUM_ENV_CNG ); +#endif hTdCngEnc->ho_hist_size = 0; hTdCngEnc->act_cnt = 0; } @@ -802,21 +831,37 @@ void td_cng_enc_init( hTdCngEnc->cng_buf_cnt = 0; +#ifndef IVAS_FLOAT_FIXED set_f( hTdCngEnc->lp_env, 0.0f, 20 ); set_f( hTdCngEnc->cng_res_env, 0.0f, 20 * 8 ); +#else + set32_fx( hTdCngEnc->lp_env_fx, 0, 20 ); + set32_fx( hTdCngEnc->cng_res_env_fx, 0, 20 * 8 ); +#endif set_f( hTdCngEnc->exc_mem, 0.0f, 24 ); set_f( hTdCngEnc->exc_mem1, 0.0f, 30 ); set_f( hTdCngEnc->exc_mem2, 0.0f, 30 ); +#ifndef IVAS_FLOAT_FIXED set_f( hTdCngEnc->old_env, 0.0f, NUM_ENV_CNG ); +#else + set32_fx( hTdCngEnc->old_env_fx, 0, NUM_ENV_CNG ); +#endif #ifdef IVAS_FLOAT_FIXED_CONVERSIONS // required for float fixed conversions set_f( hTdCngEnc->cng_exc2_buf_flt, 0.0f, HO_HIST_SIZE * L_FFT ); #endif /* SWB CNG/DTX */ +#ifndef IVAS_FLOAT_FIXED hTdCngEnc->last_wb_cng_ener = -6.02f; hTdCngEnc->last_shb_cng_ener = -6.02f; hTdCngEnc->mov_wb_cng_ener = -6.02f; hTdCngEnc->mov_shb_cng_ener = -6.02f; +#else + hTdCngEnc->last_wb_cng_ener_fx = -1541; + hTdCngEnc->last_shb_cng_ener_fx = -1541; + hTdCngEnc->mov_wb_cng_ener_fx = -1541; + hTdCngEnc->mov_shb_cng_ener_fx = -1541; +#endif hTdCngEnc->shb_cng_ini_cnt = 1; hTdCngEnc->shb_NO_DATA_cnt = 0; hTdCngEnc->last_SID_bwidth = min( max_bwidth, SWB ); @@ -894,6 +939,7 @@ void td_cng_enc_init( } #endif +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * dtx_enc_init() * @@ -916,17 +962,10 @@ void dtx_enc_init( mvr2r( st->lsp_old1, hDtxEnc->lspCNG, M ); hDtxEnc->VarDTX_cnt_voiced = 0; hDtxEnc->VarDTX_cnt_noise = 0; -#ifndef IVAS_FLOAT_FIXED hDtxEnc->lt_ener_voiced = 0.0f; hDtxEnc->lt_ener_noise = 0.0f; hDtxEnc->frame_ener = 0.0f; hDtxEnc->lt_ener_last_SID = 0.0f; -#else - hDtxEnc->lt_ener_voiced_fx = 0; - hDtxEnc->lt_ener_noise_fx = 0; - hDtxEnc->frame_ener_fx = 0; - hDtxEnc->lt_ener_last_SID_fx = 0; -#endif hDtxEnc->last_CNG_L_frame = L_FRAME; hDtxEnc->var_SID_rate_flag = var_SID_rate_flag; hDtxEnc->last_active_brate = ACELP_7k20; @@ -948,3 +987,4 @@ void dtx_enc_init( return; } +#endif diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index 843b37318..445f25b67 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -1691,19 +1691,19 @@ void dtx_enc_init_fx( hDtxEnc->VarDTX_cnt_noise = 0; move16(); hDtxEnc->lt_ener_voiced_fx = 0; - move16(); + move32(); hDtxEnc->lt_ener_noise_fx = 0; - move16(); + move32(); hDtxEnc->frame_ener_fx = 0; - move16(); + move32(); hDtxEnc->lt_ener_last_SID_fx = 0; - move16(); + move32(); hDtxEnc->last_CNG_L_frame = L_FRAME; move16(); hDtxEnc->var_SID_rate_flag = var_SID_rate_flag; move16(); hDtxEnc->last_active_brate = ACELP_7k20; - move16(); + move32(); hDtxEnc->cng_cnt = 0; move16(); @@ -1711,8 +1711,8 @@ void dtx_enc_init_fx( { hDtxEnc->interval_SID = 12; move16(); - move16(); hDtxEnc->cng_hist_size = DTX_HIST_SIZE; + move16(); } ELSE { diff --git a/lib_enc/enc_gen_voic_rf.c b/lib_enc/enc_gen_voic_rf.c index ed0867eb2..549a16ded 100644 --- a/lib_enc/enc_gen_voic_rf.c +++ b/lib_enc/enc_gen_voic_rf.c @@ -42,6 +42,7 @@ #include "wmc_auto.h" #include "prot_fx.h" +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * reset_rf_indices() * @@ -107,7 +108,6 @@ void reset_rf_indices( } -#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * coder_acelp_rf() * diff --git a/lib_enc/energy.c b/lib_enc/energy.c index 84fedfbfa..77c28484f 100644 --- a/lib_enc/energy.c +++ b/lib_enc/energy.c @@ -41,6 +41,7 @@ #include "rom_enc.h" #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * background_update() * @@ -285,3 +286,4 @@ void est_energy( return; } +#endif diff --git a/lib_enc/ext_sig_ana.c b/lib_enc/ext_sig_ana.c index aeb6804b2..2d1a7c3d6 100644 --- a/lib_enc/ext_sig_ana.c +++ b/lib_enc/ext_sig_ana.c @@ -561,11 +561,6 @@ void core_signal_analysis_high_bitrate( } IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData = &st->hIGFEnc->igfData; - if ( st->hTdCngEnc != NULL ) - { - st->hTdCngEnc->CNG_att_fx = float_to_fix16( st->hTdCngEnc->CNG_att, Q7 ); - } - #endif ProcessIGF_ivas_fx( st, hTcxEnc->spectrum_fx[frameno], hTcxEnc->spectrum_fx[frameno], &q_spectrum, powerSpec_fx, &q_powerSpec, transform_type[frameno] == TCX_20, frameno, 0, vad_hover_flag ); #ifdef IVAS_FLOAT_FIXED_CONVERSIONS @@ -598,11 +593,6 @@ void core_signal_analysis_high_bitrate( hPrivateData->igfPastSFM[i][j] = fixedToFloat( hPrivateData->igfPastSFM_fx[i][j], 13 ); } } - - if ( st->hTdCngEnc != NULL ) - { - st->hTdCngEnc->CNG_att = fix16_to_float( st->hTdCngEnc->CNG_att_fx, Q7 ); - } #endif #else ProcessIGF( st, hTcxEnc->spectrum[frameno], hTcxEnc->spectrum[frameno], powerSpec, transform_type[frameno] == TCX_20, frameno, 0, vad_hover_flag ); diff --git a/lib_enc/find_uv.c b/lib_enc/find_uv.c index 4a4e7f4f2..f51a259bc 100644 --- a/lib_enc/find_uv.c +++ b/lib_enc/find_uv.c @@ -562,7 +562,6 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); #ifdef BASOP_NOGLOB if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774, mean_voi3_offset ) ) ) && /* normalized correlation low */ - ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 ) ) && /* normalized correlation low on look-ahead - onset detection */ ( LT_32( ee[0], 397 ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ ( LT_32( ee[1], 397 ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index c38ed7c92..a2ec04bba 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -410,6 +410,7 @@ static Word16 IGF_getTilt_fx( } #endif #endif +#ifndef IVAS_FLOAT_FIXED static float IGF_getTilt( const float *powerSpectrum, /* i : energies */ const int16_t start, /* i : start subband index */ @@ -445,6 +446,7 @@ static float IGF_getTilt( return slope; } +#endif /*-------------------------------------------------------------------* * IGF_getTNR() @@ -681,6 +683,7 @@ static float IGF_getSFM_ivas( * envelope estimation *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static void IGF_CalculateEnvelope( const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ const float *pMDCTSpectrum, /* i : MDCT spectrum */ @@ -909,8 +912,7 @@ static void IGF_CalculateEnvelope( return; } - -#ifdef IVAS_FLOAT_FIXED +#else static void IGF_CalculateEnvelope_ivas_fx( const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ Word32 *pMDCTSpectrum_fx, /* i : MDCT spectrum */ @@ -4160,6 +4162,7 @@ int16_t IGFEncWriteConcatenatedBitstream( * * apply the IGF encoder, main encoder interface *-------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED void IGFEncApplyMono_ivas_fx( Encoder_State *st, /* i : Encoder state */ @@ -4233,8 +4236,7 @@ void IGFEncApplyMono_ivas_fx( IGF_ErodeSpectrum( &highPassEner_exp, st->hIGFEnc, pMDCTSpectrum_fx, pPowerSpectrumParameter_fx, e_ps, igfGridIdx ); } -#endif - +#else void IGFEncApplyMono( Encoder_State *st, /* i : Encoder state */ const int16_t igfGridIdx, /* i : IGF grid index */ @@ -4272,6 +4274,7 @@ void IGFEncApplyMono( return; } +#endif /*-------------------------------------------------------------------* diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index 703aa2014..31fa376de 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -151,7 +151,11 @@ ivas_error init_encoder( st->next_force_safety_net = 0; st->pstreaklen = 0; +#ifndef IVAS_FLOAT_FIXED st->streaklimit = 1.0f; +#else + st->streaklimit_fx = 32767; +#endif set_f( st->mem_MA, 0, M ); init_gp_clip( st->clip_var ); @@ -231,9 +235,9 @@ ivas_error init_encoder( mvr2r( st->lsp_old, st->lsp_old16k, M ); mvr2r( st->lsp_old, st->lspold_enc, M ); +#ifndef IVAS_FLOAT_FIXED st->stab_fac = 0.0f; - -#ifdef IVAS_FLOAT_FIXED +#else st->stab_fac_fx = 0; move16(); #endif @@ -560,8 +564,12 @@ ivas_error init_encoder( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX variables\n" ) ); } +#ifndef IVAS_FLOAT_FIXED dtx_enc_init( st, var_SID_rate_flag, interval_SID ); -#ifdef IVAS_FLOAT_FIXED +#else +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + floatToFixed_arr( st->lsp_old1, st->lsp_old1_fx, Q15, M ); +#endif dtx_enc_init_fx( st, var_SID_rate_flag, interval_SID ); #endif } @@ -837,7 +845,11 @@ ivas_error init_encoder( } /* initialize RF indice buffers */ +#ifndef IVAS_FLOAT_FIXED reset_rf_indices( st->hRF, st->L_frame, &st->rf_target_bits_write ); +#else + reset_rf_indices_fx( st ); +#endif } else { @@ -1204,7 +1216,6 @@ ivas_error init_encoder_ivas_fx( mvr2r( GEWB_Ave, st->lsf_adaptive_mean, M ); init_gp_clip( st->clip_var ); set_zero( st->mem_MA, M ); - st->streaklimit = 1.0f; pitch_ol_init( #ifndef IVAS_FLOAT_FIXED &st->old_thres, @@ -1263,7 +1274,6 @@ ivas_error init_encoder_ivas_fx( mvr2r( st->lsp_old1, st->lsp_old, M ); mvr2r( st->lsp_old, st->lsp_old16k, M ); mvr2r( st->lsp_old, st->lspold_enc, M ); - st->stab_fac = 0.0f; set_f( st->old_enr_ssf, 0.0f, 2 * NB_SSF ); st->mem_preemph_DFT = 0.0f; set_f( st->inp_12k8_mem_stereo_sw, 0, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ); @@ -1718,10 +1728,10 @@ ivas_error init_encoder_ivas_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX variables\n" ) ); } - dtx_enc_init_fx( st, var_SID_rate_flag, interval_SID ); -#if 1 - dtx_enc_init( st, var_SID_rate_flag, interval_SID ); +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + floatToFixed_arr( st->lsp_old1, st->lsp_old1_fx, Q15, M ); #endif + dtx_enc_init_fx( st, var_SID_rate_flag, interval_SID ); } ELSE { @@ -2032,9 +2042,6 @@ ivas_error init_encoder_ivas_fx( /* initialize RF indice buffers */ reset_rf_indices_fx( st ); -#if 1 - reset_rf_indices( st->hRF, st->L_frame, &st->rf_target_bits_write ); -#endif } ELSE { @@ -2210,7 +2217,6 @@ ivas_error init_encoder_ivas_fx( { set_zero( hTcxEnc->Txnq_flt, L_FRAME32k / 2 + 64 ); hTcxEnc->acelp_zir_flt = hTcxEnc->Txnq_flt + L_FRAME / 2; - hTcxEnc->tcx_target_bits_fac_flt = 1.0f; } } diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index 45704ed04..75f550d91 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -465,12 +465,7 @@ ivas_error ivas_core_enc( st->clip_var_fx[4] = float_to_fix16( st->clip_var[4], Q14 ); st->clip_var_fx[5] = float_to_fix16( st->clip_var[5], Q14 ); } - st->hTcxEnc->tcx_target_bits_fac = float_to_fix16( st->hTcxEnc->tcx_target_bits_fac_flt, Q14 ); st->hTcxEnc->measuredBwRatio = float_to_fix16( st->hTcxEnc->measuredBwRatio_flt, Q14 ); - if ( st->hTdCngEnc != NULL ) - { - st->hTdCngEnc->CNG_att_fx = float_to_fix16( st->hTdCngEnc->CNG_att, Q7 ); - } floatToFixed_arr( st->hTcxEnc->Txnq_flt, st->hTcxEnc->Txnq, -1, L_FRAME32k / 2 + 64 ); st->hTcxEnc->Q_old_out = Q_factor_arr( st->hTcxEnc->old_out, L_FRAME32k ) - 1; @@ -481,7 +476,6 @@ ivas_error ivas_core_enc( floatToFixed_arrL( st->hTdCngEnc->ho_ener_circ, st->hTdCngEnc->ho_ener_circ_fx, Q6, HO_HIST_SIZE ); floatToFixed_arr( st->hTdCngEnc->ho_lsp_circ, st->hTdCngEnc->ho_lsp_circ_fx, Q15, HO_HIST_SIZE * M ); floatToFixed_arrL( st->hTdCngEnc->ho_env_circ, st->hTdCngEnc->ho_env_circ_fx, Q6, HO_HIST_SIZE * NUM_ENV_CNG ); - st->hTdCngEnc->lp_ener_fx = float_to_fix( st->hTdCngEnc->lp_ener, Q6 ); // floatToFixed_arr( st->hTdCngEnc->cng_exc2_buf_flt, st->hTdCngEnc->cng_exc2_buf, Q_exc, HO_HIST_SIZE * L_FFT ); } @@ -507,7 +501,6 @@ ivas_error ivas_core_enc( st->hTcxEnc->measuredBwRatio_flt = fix16_to_float( st->hTcxEnc->measuredBwRatio, Q14 ); - st->streaklimit = fix16_to_float( st->streaklimit_fx, Q15 ); fixedToFloat_arr( st->lsp_old_fx, st->lsp_old, Q15, M ); { st->clip_var[0] = (float) st->clip_var_fx[0] / 2.56f; @@ -530,7 +523,6 @@ ivas_error ivas_core_enc( fixedToFloat_arrL( st->hTcxEnc->spectrum_fx[k], st->hTcxEnc->spectrum[k], 31 - st->hTcxEnc->spectrum_e[k], 720 ); } fixedToFloat_arr( st->hTcxEnc->Txnq, st->hTcxEnc->Txnq_flt, -1, L_FRAME32k / 2 + 64 ); - st->hTcxEnc->tcx_target_bits_fac_flt = me2f_16( st->hTcxEnc->tcx_target_bits_fac, Q15 - Q14 ); #endif // IVAS_FLOAT_FIXED_CONVERSIONS #else /* TCX core encoder */ @@ -1439,17 +1431,9 @@ ivas_error ivas_core_enc( mvr2r( GEWB_Ave, st->mem_AR, M ); } - IF( st->hTcxEnc != NULL ) - { - IF( st->element_mode != IVAS_CPE_MDCT ) - { - st->hTcxEnc->kernel_switch_corr_past_flt = 0.f; - } - } - IF( st->element_mode > EVS_MONO && st->hTcxEnc != NULL ) { - st->hTcxEnc->tcxltp_norm_corr_mem_flt = fixedToFloat( st->hTcxEnc->tcxltp_norm_corr_mem, 31 ); + st->hTcxEnc->tcxltp_norm_corr_mem_flt = fixedToFloat( st->hTcxEnc->tcxltp_norm_corr_mem, 15 ); } IF( EQ_16( st->element_mode, EVS_MONO ) && EQ_16( st->mdct_sw, MODE2 ) ) @@ -1463,17 +1447,6 @@ ivas_error ivas_core_enc( st->preemph_fac_flt = PREEMPH_FAC_16k_FLT; } } - - IF( st->Opt_DTX_ON && st->hTdCngEnc != NULL ) - { - IF( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->hDtxEnc->first_CNG, 1 ) ) - { - IF( ( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && GE_16( st->hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) ) - { - st->hTdCngEnc->CNG_att = fix16_to_float( st->hTdCngEnc->CNG_att_fx, Q7 ); - } - } - } #endif #else updt_enc_common( st ); diff --git a/lib_enc/ivas_core_pre_proc.c b/lib_enc/ivas_core_pre_proc.c index 336b51ca6..9e8ba1410 100644 --- a/lib_enc/ivas_core_pre_proc.c +++ b/lib_enc/ivas_core_pre_proc.c @@ -1841,7 +1841,7 @@ ivas_error ivas_compute_core_buffers( Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); } - analy_lp_fx( inp_16k_fx, L_FRAME16k, L_look, &ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, 0, Q_old_inp_16k, Q_r ); + analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, &ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, 0, Q_old_inp_16k, Q_r ); /*--------------------------------------------------------------* * Compute Weighted Input diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 6d707f9cf..d23b068e8 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -2062,8 +2062,8 @@ ivas_error pre_proc_front_ivas_fx( move16(); } - analy_lp_fx( inp_12k8_loc_fx, L_FRAME, L_look, &ener_fx, A_loc_fx, epsP_h_loc, epsP_l_loc, lsp_new_loc_fx, lsp_mid_loc_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, - INT_FS_12k8, i, Q_new_loc, Q_r ); + analy_lp_ivas_fx( inp_12k8_loc_fx, L_FRAME, L_look, &ener_fx, A_loc_fx, epsP_h_loc, epsP_l_loc, lsp_new_loc_fx, lsp_mid_loc_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, + INT_FS_12k8, i, Q_new_loc, Q_r ); lsp2lsf_fx( lsp_new_loc_fx, lsf_new_16_loc_fx, M, INT_FS_12k8 ); diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 8a1c2ffb8..2de97deda 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -1013,7 +1013,7 @@ ivas_error ivas_enc( st_ivas->q_data_fx = st_ivas->q_data_fx + norm_data_in; for ( i = 0; i < nchan_ism; i++ ) { - floatToFixed_arr32( hOMasa->cldfbAnaEnc[i]->cldfb_state, hOMasa->cldfbAnaEnc[i]->cldfb_state_fx, st_ivas->q_data_fx, hOMasa->cldfbAnaEnc[i]->cldfb_state_length ); + floatToFixed_arrL( hOMasa->cldfbAnaEnc[i]->cldfb_state, hOMasa->cldfbAnaEnc[i]->cldfb_state_fx, st_ivas->q_data_fx, hOMasa->cldfbAnaEnc[i]->cldfb_state_length ); } for ( i = 0; i < nchan_ism; i++ ) { diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index 86dd71446..e7b20b757 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -984,7 +984,7 @@ ivas_error front_vad_spar( floatToFixed_arr( alw_voicing, alw_voicing_fx, Q15, 2 ); Q_inp_12k8 = Q9; // Q_factor_arr( inp_12k8 - 90, 3 * L_FRAME / 2 + 90 ); floatToFixed_arr( inp_12k8 - 90, inp_12k8_fx - 90, Q_inp_12k8, 3 * L_FRAME / 2 + 90 ); - analy_lp_fx( inp_12k8_fx, L_FRAME, L_LOOK_12k8, &res_energy_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, 0 /* <-- sec_chan_low_rate */, Q_inp_12k8, Q_r ); + analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_LOOK_12k8, &res_energy_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, 0 /* <-- sec_chan_low_rate */, Q_inp_12k8, Q_r ); for ( Word16 i = 0; i <= M; i++ ) { epsP_fx[i] = L_Comp( epsP_h[i], epsP_l[i] ); diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index 4c02123a9..302f263af 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -450,16 +450,12 @@ ivas_error ivas_masa_encode( #ifdef IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED_CONVERSIONS Word16 numSf = hMasa->config.joinedSubframes == TRUE ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES; - hMasa->data.q_energy = Q31; - guard_bits = find_guarded_bits_fx( 9 ); - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + for ( i = 0; i < 4; i++ ) { - hMasa->data.q_energy = s_min( hMasa->data.q_energy, L_get_q_buf1( hMasa->data.energy[i], MASA_FREQUENCY_BANDS ) ); - } - hMasa->data.q_energy -= guard_bits; - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - floatToFixed_arrL32( hMasa->data.energy[i], hMasa->data.energy_fx[i], hMasa->data.q_energy, MASA_FREQUENCY_BANDS ); + for ( j = 0; j < 24; j++ ) + { + f2me( hMasa->data.energy[i][j], &hMasa->data.energy_fx[i][j], &hMasa->data.energy_e[i][j] ); + } } if ( hMasa->config.numCodingBands <= MAX_REDUCED_NBANDS ) { @@ -507,9 +503,12 @@ ivas_error ivas_masa_encode( #endif combine_freqbands_and_subframes_fx( hMasa ); #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + for ( i = 0; i < 4; i++ ) { - fixedToFloat_arrL32( hMasa->data.energy_fx[i], hMasa->data.energy[i], hMasa->data.q_energy, MASA_FREQUENCY_BANDS ); + for ( j = 0; j < 24; j++ ) + { + hMasa->data.energy[i][j] = me2f( hMasa->data.energy_fx[i][j], hMasa->data.energy_e[i][j] ); + } } if ( hMasa->config.numCodingBands <= MAX_REDUCED_NBANDS ) { @@ -790,7 +789,7 @@ ivas_error ivas_masa_encode( #ifdef IVAS_FLOAT_FIXED_CONVERSIONS // Word16 numSf = hMasa->config.joinedSubframes == TRUE ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES; hMasa->data.q_energy = Q31; - guard_bits = find_guarded_bits_fx( 9 ); + guard_bits = find_guarded_bits_fx( 24 ); for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { hMasa->data.q_energy = s_min( hMasa->data.q_energy, L_get_q_buf1( hMasa->data.energy[i], MASA_FREQUENCY_BANDS ) ); @@ -1088,16 +1087,12 @@ ivas_error ivas_masa_encode( #ifdef IVAS_FLOAT_FIXED_CONVERSIONS MASA_METADATA_HANDLE hMeta = &( hMasa->masaMetadata ); Word16 numSf = hMasa->config.joinedSubframes == TRUE ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES; - hMasa->data.q_energy = Q31; - guard_bits = find_guarded_bits_fx( 9 ); - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - hMasa->data.q_energy = s_min( hMasa->data.q_energy, L_get_q_buf1( hMasa->data.energy[i], MASA_FREQUENCY_BANDS ) ); - } - hMasa->data.q_energy -= guard_bits; - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + for ( i = 0; i < 4; i++ ) { - floatToFixed_arrL32( hMasa->data.energy[i], hMasa->data.energy_fx[i], hMasa->data.q_energy, MASA_FREQUENCY_BANDS ); + for ( j = 0; j < 24; j++ ) + { + f2me( hMasa->data.energy[i][j], &hMasa->data.energy_fx[i][j], &hMasa->data.energy_e[i][j] ); + } } if ( hMasa->config.numCodingBands <= MAX_REDUCED_NBANDS ) { @@ -1145,9 +1140,12 @@ ivas_error ivas_masa_encode( #endif combine_freqbands_and_subframes_fx( hMasa ); #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + for ( i = 0; i < 4; i++ ) { - fixedToFloat_arrL32( hMasa->data.energy_fx[i], hMasa->data.energy[i], hMasa->data.q_energy, MASA_FREQUENCY_BANDS ); + for ( j = 0; j < 24; j++ ) + { + hMasa->data.energy[i][j] = me2f( hMasa->data.energy_fx[i][j], hMasa->data.energy_e[i][j] ); + } } if ( hMasa->config.numCodingBands <= MAX_REDUCED_NBANDS ) { @@ -2295,14 +2293,20 @@ static void combine_freqbands_and_subframes_fx( Word32 vecLen; Word16 vecLen_e; Word32 xSum, ySum, zSum; + Word16 xSum_e, ySum_e, zSum_e, common_e; Word64 xSum_sq, ySum_sq, zSum_sq; Word32 energySum; + Word16 energySum_e; Word32 spreadCohSum; + Word16 spreadCohSum_e; Word32 surrCohSum; + Word16 surrCohSum_e; Word32 energyRatioSum; + Word16 energyRatioSum_e; Word16 surrCohTemp; Word32 energyRatioTemp; Word32 energy[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; Word16 brange[2]; UWord8 numCodingBands; UWord8 numSf; @@ -2312,7 +2316,6 @@ static void combine_freqbands_and_subframes_fx( UWord8 computeCoherence; Word16 exp_diff; Word32 L_tmp; - Word16 guard_bits; Word64 W_tmp; Word16 q_shift; @@ -2355,7 +2358,7 @@ static void combine_freqbands_and_subframes_fx( { FOR( k = 0; k < MASA_FREQUENCY_BANDS; k++ ) { - hMasa->data.energy_fx[0][k] = L_add( hMasa->data.energy_fx[0][k], hMasa->data.energy_fx[j][k] ); // hMasa->data.q_energy + hMasa->data.energy_fx[0][k] = BASOP_Util_Add_Mant32Exp( hMasa->data.energy_fx[0][k], hMasa->data.energy_e[0][k], hMasa->data.energy_fx[j][k], hMasa->data.energy_e[j][k], &hMasa->data.energy_e[0][k] ); // 31-hMasa->data.energy_e[0][k] move32(); } } @@ -2372,13 +2375,13 @@ static void combine_freqbands_and_subframes_fx( { aziRad = extract_l( L_shl( Mpy_32_32( hMeta->directional_meta[i].azimuth_fx[j][k], PI_OVER_180_FX ), Q13 - Q22 ) ); // ((Q22, Q31) -> Q22) >> Q9 -> Q13 eleRad = extract_l( L_shl( Mpy_32_32( hMeta->directional_meta[i].elevation_fx[j][k], PI_OVER_180_FX ), Q13 - Q22 ) ); // ((Q22, Q31) -> Q22) >> Q9 -> Q13 - vecLen = Mpy_32_32( hMeta->directional_meta[i].energy_ratio_fx[j][k], hMasa->data.energy_fx[j][k] ); // (Q30, hMasa->data.q_energy) -> hMasa->data.q_energy - Q1 + vecLen = Mpy_32_32( hMeta->directional_meta[i].energy_ratio_fx[j][k], hMasa->data.energy_fx[j][k] ); // (Q30, 31-hMasa->data.energy_e[j][k]) -> (31-hMasa->data.energy_e[j][k]) - Q1 - x[i][j][k] = Mpy_32_32( L_mult( getCosWord16( aziRad ), getCosWord16( eleRad ) ), vecLen ); // (Q29, hMasa->data.q_energy - Q1) -> hMasa->data.q_energy - Q3 + x[i][j][k] = Mpy_32_32( L_mult( getCosWord16( aziRad ), getCosWord16( eleRad ) ), vecLen ); // (Q29, (31-hMasa->data.energy_e[j][k]) - Q1) -> (31-hMasa->data.energy_e[j][k]) - Q3 move32(); - y[i][j][k] = Mpy_32_32( L_mult0( getSinWord16( aziRad ), getCosWord16( eleRad ) ), vecLen ); // (Q29, hMasa->data.q_energy - Q1) -> hMasa->data.q_energy - Q3 + y[i][j][k] = Mpy_32_32( L_mult0( getSinWord16( aziRad ), getCosWord16( eleRad ) ), vecLen ); // (Q29, (31-hMasa->data.energy_e[j][k]) - Q1) -> (31-hMasa->data.energy_e[j][k]) - Q3 move32(); - z[i][j][k] = Mpy_32_32( L_mult0( getSinWord16( eleRad ), ONE_IN_Q14 ), vecLen ); // (Q29, hMasa->data.q_energy - Q1) -> hMasa->data.q_energy - Q3 + z[i][j][k] = Mpy_32_32( L_mult0( getSinWord16( eleRad ), ONE_IN_Q14 ), vecLen ); // (Q29, (31-hMasa->data.energy_e[j][k]) - Q1) -> (31-hMasa->data.energy_e[j][k]) - Q3 move32(); } } @@ -2400,49 +2403,62 @@ static void combine_freqbands_and_subframes_fx( zSum = 0; energySum = 0; spreadCohSum = 0; + xSum_e = 0; + ySum_e = 0; + zSum_e = 0; + energySum_e = 0; + spreadCohSum_e = 0; move32(); move32(); move32(); move32(); move32(); + move16(); + move16(); + move16(); + move16(); + move16(); FOR( m = brange[0]; m < brange[1]; m++ ) { - xSum = L_add( xSum, x[i][j][m] ); // hMasa->data.q_energy - Q3 - ySum = L_add( ySum, y[i][j][m] ); // hMasa->data.q_energy - Q3 - zSum = L_add( zSum, z[i][j][m] ); // hMasa->data.q_energy - Q3 - energySum = L_add( energySum, hMasa->data.energy_fx[j][m] ); // hMasa->data.q_energy + xSum = BASOP_Util_Add_Mant32Exp( xSum, xSum_e, x[i][j][m], add( hMasa->data.energy_e[j][m], 3 ), &xSum_e ); // xSum_e + ySum = BASOP_Util_Add_Mant32Exp( ySum, ySum_e, y[i][j][m], add( hMasa->data.energy_e[j][m], 3 ), &ySum_e ); // ySum_e + zSum = BASOP_Util_Add_Mant32Exp( zSum, zSum_e, z[i][j][m], add( hMasa->data.energy_e[j][m], 3 ), &zSum_e ); // zSum_e + energySum = BASOP_Util_Add_Mant32Exp( energySum, energySum_e, hMasa->data.energy_fx[j][m], hMasa->data.energy_e[j][m], &energySum_e ); // energySum_e } - - aziRad = BASOP_util_atan2( ySum, xSum, 0 ); // Q13 - xSum_sq = W_mult0_32_32( xSum, xSum ); // 2 * hMasa->data.q_energy - Q6 - ySum_sq = W_mult0_32_32( ySum, ySum ); // 2 * hMasa->data.q_energy - Q6 - zSum_sq = W_mult0_32_32( zSum, zSum ); // 2 * hMasa->data.q_energy - Q6 - W_tmp = W_add( xSum_sq, ySum_sq ); // 2 * hMasa->data.q_energy - Q6 + common_e = add( s_max( xSum_e, s_max( ySum_e, zSum_e ) ), 2 ); /*2 is guard bit for addition operations*/ + xSum = L_shr( xSum, sub( common_e, xSum_e ) ); /*common_e*/ + ySum = L_shr( ySum, sub( common_e, ySum_e ) ); /*common_e*/ + zSum = L_shr( zSum, sub( common_e, zSum_e ) ); /*common_e*/ + aziRad = BASOP_util_atan2( ySum, xSum, 0 ); // Q13 + xSum_sq = W_mult0_32_32( xSum, xSum ); // 2 * (31-common_e) + ySum_sq = W_mult0_32_32( ySum, ySum ); // 2 * (31-common_e) + zSum_sq = W_mult0_32_32( zSum, zSum ); // 2 * (31-common_e) + W_tmp = W_add( xSum_sq, ySum_sq ); // 2 * (31-common_e) q_shift = W_norm( W_tmp ); - L_tmp = W_extract_h( W_shl( W_tmp, q_shift ) ); // 2 * hMasa->data.q_energy - Q6 + (q_shift -32) - exp_diff = sub( Q31, add( sub( imult1616( 2, hMasa->data.q_energy ), Q6 ), sub( q_shift, 32 ) ) ); + L_tmp = W_extract_h( W_shl( W_tmp, q_shift ) ); // 2 * (31-common_e) + (q_shift -32) + exp_diff = sub( Q31, add( imult1616( 2, sub( 31, common_e ) ), sub( q_shift, 32 ) ) ); L_tmp = Sqrt32( L_tmp, &exp_diff ); - eleRad = BASOP_util_atan2( zSum, L_tmp, sub( sub( 34, hMasa->data.q_energy ), exp_diff ) ); // Q13 + eleRad = BASOP_util_atan2( zSum, L_tmp, sub( common_e, exp_diff ) ); // Q13 hMeta->directional_meta[i].azimuth_fx[j][k] = L_shr( Mpy_32_16_1( _180_OVER_PI_Q25, aziRad ), Q1 ); // ((Q25, Q13) -> Q23) >> Q1 -> Q22 move32(); hMeta->directional_meta[i].elevation_fx[j][k] = L_shr( Mpy_32_16_1( _180_OVER_PI_Q25, eleRad ), Q1 ); // ((Q25, Q13) -> Q23) >> Q1 -> Q22 move32(); - W_tmp = W_add( xSum_sq, ySum_sq ); // 2 * hMasa->data.q_energy - Q6 - W_tmp = W_add( W_tmp, zSum_sq ); // 2 * hMasa->data.q_energy - Q6 + W_tmp = W_add( xSum_sq, ySum_sq ); // 2 * (31-common_e) + W_tmp = W_add( W_tmp, zSum_sq ); // 2 * (31-common_e) q_shift = W_norm( W_tmp ); - vecLen = W_extract_h( W_shl( W_tmp, q_shift ) ); // 2 * hMasa->data.q_energy - Q6 + (q_shift -32) - exp_diff = sub( Q31, add( sub( imult1616( 2, hMasa->data.q_energy ), Q6 ), sub( q_shift, 32 ) ) ); + vecLen = W_extract_h( W_shl( W_tmp, q_shift ) ); // 2 * (31-common_e) + (q_shift -32) + exp_diff = sub( Q31, add( imult1616( 2, sub( 31, common_e ) ), sub( q_shift, 32 ) ) ); vecLen = Sqrt32( vecLen, &exp_diff ); vecLen_e = exp_diff; move16(); hMeta->directional_meta[i].energy_ratio_fx[j][k] = - BASOP_Util_Divide3232_Scale_cadence( vecLen, L_add( energySum, EPSILON_FX ), &exp_diff ); + BASOP_Util_Divide3232_Scale_cadence( vecLen, L_add( energySum, EPSILON_FX ), &exp_diff ); /*exp_diff+vecLen_e-energySum_e*/ move32(); - exp_diff = add( exp_diff, sub( vecLen_e, sub( Q31, hMasa->data.q_energy ) ) ); + exp_diff = add( exp_diff, sub( vecLen_e, energySum_e ) ); hMeta->directional_meta[i].energy_ratio_fx[j][k] = L_shl( hMeta->directional_meta[i].energy_ratio_fx[j][k], sub( exp_diff, Q1 ) ); // (Q31 - exp_diff ) -> Q30 move32(); @@ -2451,9 +2467,10 @@ static void combine_freqbands_and_subframes_fx( { FOR( m = brange[0]; m < brange[1]; m++ ) { - spreadCohSum = L_add( spreadCohSum, Mpy_32_16_1( hMasa->data.energy_fx[j][m], hMeta->directional_meta[i].spread_coherence_fx[j][m] ) ); // hMasa->data.q_energy + spreadCohSum = BASOP_Util_Add_Mant32Exp( spreadCohSum, spreadCohSum_e, Mpy_32_16_1( hMasa->data.energy_fx[j][m], hMeta->directional_meta[i].spread_coherence_fx[j][m] ), hMasa->data.energy_e[j][m], &spreadCohSum_e ); // 31-spreadCohSum_e } - hMeta->directional_meta[i].spread_coherence_fx[j][k] = BASOP_Util_Divide3232_Scale( spreadCohSum, L_add( energySum, EPSILON_FX ), &exp_diff ); + hMeta->directional_meta[i].spread_coherence_fx[j][k] = BASOP_Util_Divide3232_Scale( spreadCohSum, L_add( energySum, EPSILON_FX ), &exp_diff ); /*exp_diff+spreadCohSum_e-energySum_e*/ + exp_diff = add( exp_diff, sub( spreadCohSum_e, energySum_e ) ); move16(); hMeta->directional_meta[i].spread_coherence_fx[j][k] = shl( hMeta->directional_meta[i].spread_coherence_fx[j][k], exp_diff ); // Q15 move16(); @@ -2461,13 +2478,16 @@ static void combine_freqbands_and_subframes_fx( IF( i == 0 ) { surrCohSum = 0; + surrCohSum_e = 0; move32(); + move16(); FOR( m = brange[0]; m < brange[1]; m++ ) { - surrCohSum = L_add( surrCohSum, Mpy_32_16_1( hMasa->data.energy_fx[j][m], hMeta->common_meta.surround_coherence_fx[j][m] ) ); // hMasa->data.q_energy + surrCohSum = BASOP_Util_Add_Mant32Exp( surrCohSum, surrCohSum_e, Mpy_32_16_1( hMasa->data.energy_fx[j][m], hMeta->common_meta.surround_coherence_fx[j][m] ), hMasa->data.energy_e[j][m], &surrCohSum_e ); // 31-surrCohSum_e } - hMeta->common_meta.surround_coherence_fx[j][k] = BASOP_Util_Divide3232_Scale( surrCohSum, L_add( energySum, EPSILON_FX ), &exp_diff ); + hMeta->common_meta.surround_coherence_fx[j][k] = BASOP_Util_Divide3232_Scale( surrCohSum, L_add( energySum, EPSILON_FX ), &exp_diff ); /*exp_diff+surrCohSum_e-energySum_e*/ move16(); + exp_diff = add( exp_diff, sub( surrCohSum_e, energySum_e ) ); hMeta->common_meta.surround_coherence_fx[j][k] = shl( hMeta->common_meta.surround_coherence_fx[j][k], exp_diff ); // Q15 move16(); } @@ -2475,8 +2495,10 @@ static void combine_freqbands_and_subframes_fx( if ( i == 0 ) { - energy[j][k] = energySum; // hMasa->data.q_energy + energy[j][k] = energySum; // 31-energySum_e + energy_e[j][k] = energySum_e; move32(); + move16(); } } } @@ -2488,8 +2510,10 @@ static void combine_freqbands_and_subframes_fx( { FOR( k = 0; k < numCodingBands; k++ ) { - energy[j][k] = hMasa->data.energy_fx[j][k]; // hMasa->data.q_energy + energy[j][k] = hMasa->data.energy_fx[j][k]; // 31-hMasa->data.energy_e[j][k] + energy_e[j][k] = hMasa->data.energy_e[j][k]; move32(); + move16(); } } } @@ -2498,24 +2522,27 @@ static void combine_freqbands_and_subframes_fx( { FOR( k = 0; k < numCodingBands; k++ ) { - guard_bits = 0; - move16(); energySum = 0; move32(); + energySum_e = 0; + move16(); FOR( j = 0; j < numSf; j++ ) { - energySum = L_add( energySum, L_shr( energy[j][k], guard_bits ) ); // hMasa->data.q_energy - guard_bits + energySum = BASOP_Util_Add_Mant32Exp( energySum, energySum_e, energy[j][k], energy_e[j][k], &energySum_e ); // 31-energySum_e } IF( computeCoherence ) { surrCohSum = 0; + surrCohSum_e = 0; move32(); + move16(); FOR( j = 0; j < numSf; j++ ) { - surrCohSum = L_add( surrCohSum, Mpy_32_16_1( L_shr( energy[j][k], guard_bits ), hMeta->common_meta.surround_coherence_fx[j][k] ) ); // hMasa->data.q_energy - guard_bits + surrCohSum = BASOP_Util_Add_Mant32Exp( surrCohSum, surrCohSum_e, Mpy_32_16_1( energy[j][k], hMeta->common_meta.surround_coherence_fx[j][k] ), energy_e[j][k], &surrCohSum_e ); // 31-surrCohSum_e } surrCohTemp = BASOP_Util_Divide3232_Scale( surrCohSum, L_add( energySum, EPSILON_FX ), &exp_diff ); + exp_diff = add( exp_diff, sub( surrCohSum_e, energySum_e ) ); surrCohTemp = shl( surrCohTemp, exp_diff ); // Q15 FOR( j = 0; j < numSf; j++ ) @@ -2528,13 +2555,16 @@ static void combine_freqbands_and_subframes_fx( FOR( i = 0; i < numDirections; i++ ) { energyRatioSum = 0; + energyRatioSum_e = 0; move32(); + move16(); FOR( j = 0; j < numSf; j++ ) { - energyRatioSum = L_add( energyRatioSum, Mpy_32_32( L_shr( energy[j][k], guard_bits ), hMeta->directional_meta[i].energy_ratio_fx[j][k] ) ); // hMasa->data.q_energy - guard_bits - Q1 + energyRatioSum = BASOP_Util_Add_Mant32Exp( energyRatioSum, energyRatioSum_e, Mpy_32_32( energy[j][k], hMeta->directional_meta[i].energy_ratio_fx[j][k] ), add( energy_e[j][k], 1 ), &energyRatioSum_e ); // 31-energyRatioSum_e } energyRatioTemp = BASOP_Util_Divide3232_Scale_cadence( energyRatioSum, L_add( energySum, EPSILON_FX ), &exp_diff ); - energyRatioTemp = L_shl( energyRatioTemp, exp_diff ); // (exp_diff + ((hMasa->data.q_energy - guard_bits) - (hMasa->data.q_energy - guard_bits - Q1))) -> Q30 + exp_diff = add( exp_diff, sub( energyRatioSum_e, energySum_e ) ); + energyRatioTemp = L_shl( energyRatioTemp, sub( exp_diff, 1 ) ); // Q30 FOR( j = 0; j < numSf; j++ ) { @@ -6326,10 +6356,18 @@ void ivas_merge_masa_metadata_fx( move32(); move16(); /*dir_sum = 1.0f - total_diff_nrg / ( EPSILON + eneBand + hMasa->data.hOmasaData->energy_ism[sf][band] )*/ - hMeta->directional_meta[merge_dest].energy_ratio_fx[sf][band] = L_min( L_shl( dir_sum_fx, sub( dir_sum_e, 1 ) ), hOMasaMeta->directional_meta[0].energy_ratio_fx[sf][band] ); /* clip with original ISM dir */ /*q30*/ - hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = L_sub( ONE_IN_Q30, hMeta->directional_meta[merge_dest].energy_ratio_fx[sf][band] ); /*q30*/ - move32(); + IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( dir_sum_fx, dir_sum_e, hOMasaMeta->directional_meta[0].energy_ratio_fx[sf][band], 1 ), -1 ) ) + { + hMeta->directional_meta[merge_dest].energy_ratio_fx[sf][band] = L_shl( dir_sum_fx, sub( dir_sum_e, 1 ) ); /*scaling to Q30*/ + } + ELSE + { + hMeta->directional_meta[merge_dest].energy_ratio_fx[sf][band] = hOMasaMeta->directional_meta[0].energy_ratio_fx[sf][band]; /*q30*/ + } + /* clip with original ISM dir */ + hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = L_sub( ONE_IN_Q30, hMeta->directional_meta[merge_dest].energy_ratio_fx[sf][band] ); /*q30*/ move32(); + move32(); /*hMeta->directional_meta[merge_dest].energy_ratio_fx*/ IF( hMasa->config.useCoherence ) { diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 93d19238b..8a5928b66 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -652,10 +652,6 @@ ivas_error ivas_mct_enc( FOR( int b = 0; b < hMCT->nchan_out_woLFE; b++ ) { st = sts_tmp[b]; - if ( st->hTdCngEnc != NULL ) - { - st->hTdCngEnc->CNG_att_fx = float_to_fix16( st->hTdCngEnc->CNG_att, Q7 ); - } } #endif #endif // 1 @@ -718,11 +714,6 @@ ivas_error ivas_mct_enc( } } } - - if ( st->hTdCngEnc != NULL ) - { - st->hTdCngEnc->CNG_att = fix16_to_float( st->hTdCngEnc->CNG_att_fx, Q7 ); - } if ( st->hIGFEnc ) { st->hIGFEnc->tns_predictionGain_flt = fix16_to_float( st->hIGFEnc->tns_predictionGain, Q23 ); @@ -748,11 +739,6 @@ ivas_error ivas_mct_enc( st = sts[ch]; st->hTcxCfg->bandwidth = float_to_fix16( st->hTcxCfg->bandwidth_flt, Q15 ); st->hTcxCfg->preemph_fac = float_to_fix16( st->hTcxCfg->preemph_fac_flt, Q15 ); - st->hTcxEnc->tcx_target_bits_fac = float_to_fix16( st->hTcxEnc->tcx_target_bits_fac_flt, Q14 ); - if ( st->hTdCngEnc != NULL ) - { - st->hTdCngEnc->CNG_att_fx = float_to_fix16( st->hTdCngEnc->CNG_att, Q7 ); - } st->hTcxEnc->measuredBwRatio = float_to_fix16( st->hTcxEnc->measuredBwRatio_flt, Q14 ); } #endif @@ -763,7 +749,6 @@ ivas_error ivas_mct_enc( { sts = hCPE->hCoreCoder; st = sts[ch]; - st->hTcxEnc->tcx_target_bits_fac_flt = me2f_16( st->hTcxEnc->tcx_target_bits_fac, Q15 - Q14 ); } #endif /* update input samples buffer (as done in ivas_cpe_enc() for other than MCT coding) */ @@ -807,17 +792,9 @@ ivas_error ivas_mct_enc( mvr2r( GEWB_Ave, st->mem_AR, M ); } - IF( st->hTcxEnc != NULL ) - { - IF( st->element_mode != IVAS_CPE_MDCT ) - { - st->hTcxEnc->kernel_switch_corr_past_flt = 0.f; - } - } - IF( st->element_mode > EVS_MONO && st->hTcxEnc != NULL ) { - st->hTcxEnc->tcxltp_norm_corr_mem_flt = fixedToFloat( st->hTcxEnc->tcxltp_norm_corr_mem, 31 ); + st->hTcxEnc->tcxltp_norm_corr_mem_flt = fixedToFloat( st->hTcxEnc->tcxltp_norm_corr_mem, 15 ); } IF( EQ_16( st->element_mode, EVS_MONO ) && EQ_16( st->mdct_sw, MODE2 ) ) @@ -831,17 +808,6 @@ ivas_error ivas_mct_enc( st->preemph_fac_flt = PREEMPH_FAC_16k_FLT; } } - - IF( st->Opt_DTX_ON && st->hTdCngEnc != NULL ) - { - IF( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->hDtxEnc->first_CNG, 1 ) ) - { - IF( ( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && GE_16( st->hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) ) - { - st->hTdCngEnc->CNG_att = fix16_to_float( st->hTdCngEnc->CNG_att_fx, Q7 ); - } - } - } #endif #else updt_enc_common( hCPE->hCoreCoder[n] ); diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c index a597110c5..57ff78f07 100644 --- a/lib_enc/ivas_mdct_core_enc.c +++ b/lib_enc/ivas_mdct_core_enc.c @@ -1949,10 +1949,6 @@ void ivas_mdct_core_whitening_enc( } IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData = &st->hIGFEnc->igfData; - if ( st->hTdCngEnc != NULL ) - { - st->hTdCngEnc->CNG_att_fx = float_to_fix16( st->hTdCngEnc->CNG_att, Q7 ); - } float max_sb = 0; float max_tb = 0; @@ -2056,11 +2052,6 @@ void ivas_mdct_core_whitening_enc( hPrivateData->igfPastSFM[i][j] = fixedToFloat( hPrivateData->igfPastSFM_fx[i][j], 13 ); } } - - if ( st->hTdCngEnc != NULL ) - { - st->hTdCngEnc->CNG_att = fix16_to_float( st->hTdCngEnc->CNG_att_fx, Q7 ); - } } IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) @@ -2171,7 +2162,11 @@ void ivas_mdct_core_whitening_enc( #endif if ( st->last_core == ACELP_CORE ) /* reset past kernel info */ { +#ifndef IVAS_FLOAT_FIXED st->hTcxEnc->kernel_switch_corr_past_flt = 0.f; +#else + st->hTcxEnc->kernel_switch_corr_past = 0; +#endif st->hTcxEnc->kernel_symmetry_past = 0; } } @@ -2225,15 +2220,10 @@ void ivas_mdct_core_whitening_enc( floatToFixed_arrL32( hTcxEnc1->spectrum[n], hTcxEnc1->spectrum_fx[n], q_com, hTcxEnc1->L_frameTCX / nSubframes ); floatToFixed_arrL32( mdst_spectrum[0][n], mdst_spectrum_fx[0][n], q_com, hTcxEnc0->L_frameTCX / nSubframes ); floatToFixed_arrL32( mdst_spectrum[1][n], mdst_spectrum_fx[1][n], q_com, hTcxEnc1->L_frameTCX / nSubframes ); - - hTcxEnc0->kernel_switch_corr_past = float_to_fix16( hTcxEnc0->kernel_switch_corr_past_flt, Q15 ); #endif const Word16 switchKernel = /* these 4 transform types can be applied: 0 = MDCT-IV, 1 = MDST-II, 2 = MDCT-II, 3 = MDST-IV */ kernel_switch_detect_fx( hTcxEnc0->spectrum_fx[n], hTcxEnc1->spectrum_fx[n], mdst_spectrum_fx[0][n], mdst_spectrum_fx[1][n], q_com, nSampCore / nSubframes, L_subframeTCX / nSubframes, hTcxEnc0->transform_type[n], &hTcxEnc0->kernel_switch_corr_past, ( totalRate * L_subframe ) / nSubframes ); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - hTcxEnc0->kernel_switch_corr_past_flt = fix16_to_float( hTcxEnc0->kernel_switch_corr_past, Q15 ); -#endif #else const int16_t switchKernel = /* these 4 transform types can be applied: 0 = MDCT-IV, 1 = MDST-II, 2 = MDCT-II, 3 = MDST-IV */ kernel_switch_detect( hTcxEnc0->spectrum[n], hTcxEnc1->spectrum[n], mdst_spectrum[0][n], mdst_spectrum[1][n], nSampCore / nSubframes, @@ -2252,7 +2242,11 @@ void ivas_mdct_core_whitening_enc( } else { +#ifdef IVAS_FLOAT_FIXED + hTcxEnc0->kernel_switch_corr_past = 0; /* don't update the kernel switching state, postpone it to when data is available */ +#else hTcxEnc0->kernel_switch_corr_past_flt = 0.f; /* don't update the kernel switching state, postpone it to when data is available */ +#endif hTcxEnc0->kernel_type[n] = ( hTcxEnc0->kernel_symmetry_past ? 3 : 0 ); hTcxEnc1->kernel_type[n] = ( hTcxEnc1->kernel_symmetry_past ? 3 : 0 ); } @@ -2454,7 +2448,11 @@ void ivas_mdct_core_whitening_enc( else { sts[0]->hTcxEnc->enc_ste_pre_corr_past = 0; +#ifdef IVAS_FLOAT_FIXED + sts[0]->hTcxEnc->kernel_switch_corr_past = 0; +#else sts[0]->hTcxEnc->kernel_switch_corr_past_flt = 0.f; +#endif for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { diff --git a/lib_enc/ivas_omasa_enc.c b/lib_enc/ivas_omasa_enc.c index a7c26b856..095853da9 100644 --- a/lib_enc/ivas_omasa_enc.c +++ b/lib_enc/ivas_omasa_enc.c @@ -1505,6 +1505,11 @@ static void ivas_omasa_param_est_enc_fx( set_zero_fx( diffuseness_m_fx, hOMasa->nbands ); set16_fx( renormalization_factor_diff_e, 0, hOMasa->nbands ); set16_fx( diffuseness_e, 0, hOMasa->nbands ); + FOR( i = 0; i < nchan_ism; i++ ) + { + set_zero_fx( Chnl_RealBuffer_fx[i], 60 ); + set_zero_fx( Chnl_ImagBuffer_fx[i], 60 ); + } /* Compute ISM to FOA matrices */ FOR( i = 0; i < nchan_ism; i++ ) { @@ -1584,7 +1589,7 @@ static void ivas_omasa_param_est_enc_fx( { FOR( j = brange[0]; j < brange[1]; j++ ) { - temp = Mpy_32_32( Chnl_RealBuffer_fx[k][j], Chnl_RealBuffer_fx[k][j] ), Mpy_32_32( Chnl_ImagBuffer_fx[k][j], Chnl_ImagBuffer_fx[k][j] ); + temp = L_add( Mpy_32_32( Chnl_RealBuffer_fx[k][j], Chnl_RealBuffer_fx[k][j] ), Mpy_32_32( Chnl_ImagBuffer_fx[k][j], Chnl_ImagBuffer_fx[k][j] ) ); temp_e = sub( 62, shl( q, 1 ) ); hOmasaData->energy_ism_fx[block_m_idx][i] = BASOP_Util_Add_Mant32Exp( hOmasaData->energy_ism_fx[block_m_idx][i], hOmasaData->energy_ism_fx_e[block_m_idx][i], temp, temp_e, &hOmasaData->energy_ism_fx_e[block_m_idx][i] ); /*2q-31*/ move32(); @@ -1671,7 +1676,7 @@ static void ivas_omasa_param_est_enc_fx( move32(); move32(); - diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[band_m_idx], diffuseness_e[band_m_idx], Mpy_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ), ref_exp + 1, &diffuseness_e[band_m_idx] ); /*(30-ref_exp)*/ + diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[band_m_idx], diffuseness_e[band_m_idx], W_extract_l( W_shr( W_mult0_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ), 30 ) ), ref_exp, &diffuseness_e[band_m_idx] ); /*(30-ref_exp)*/ renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], ref_exp, &renormalization_factor_diff_e[band_m_idx] ); move32(); move32(); @@ -1712,7 +1717,7 @@ static void ivas_omasa_param_est_enc_fx( { IF( GT_32( BASOP_Util_Log10( renormalization_factor_diff_fx[band_m_idx], ref_exp ), -( 15 << 25 ) ) ) { - diffuseness_m_fx[band_m_idx] = BASOP_Util_Divide3232_Scale( diffuseness_m_fx[band_m_idx], renormalization_factor_diff_fx[band_m_idx], &temp_e ); + diffuseness_m_fx[band_m_idx] = BASOP_Util_Divide3232_Scale( diffuseness_m_fx[band_m_idx], L_add( renormalization_factor_diff_fx[band_m_idx], EPSILON_FX ), &temp_e ); temp_e = add( temp_e, sub( diffuseness_e[band_m_idx], renormalization_factor_diff_e[band_m_idx] ) ); } ELSE diff --git a/lib_enc/ivas_stereo_mdct_core_enc.c b/lib_enc/ivas_stereo_mdct_core_enc.c index 23cc63ccb..dc927331a 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc.c +++ b/lib_enc/ivas_stereo_mdct_core_enc.c @@ -1292,10 +1292,6 @@ void stereo_mdct_core_enc( #ifdef IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED_CONVERSIONS IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData = &st->hIGFEnc->igfData; - if ( st->hTdCngEnc != NULL ) - { - st->hTdCngEnc->CNG_att_fx = float_to_fix16( st->hTdCngEnc->CNG_att, Q7 ); - } int igfGridIdx; if ( st->last_core == ACELP_CORE && st->core == TCX_20_CORE ) @@ -1365,11 +1361,6 @@ void stereo_mdct_core_enc( hPrivateData->igfPastSFM[i][j] = fixedToFloat( hPrivateData->igfPastSFM_fx[i][j], 13 ); } } - - if ( st->hTdCngEnc != NULL ) - { - st->hTdCngEnc->CNG_att = fix16_to_float( st->hTdCngEnc->CNG_att_fx, Q7 ); - } #endif #else ProcessIGF( st, st->hTcxEnc->spectrum[n], orig_spectrum[ch][n], &powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); @@ -1398,10 +1389,6 @@ void stereo_mdct_core_enc( #ifdef IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED_CONVERSIONS IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData = &st->hIGFEnc->igfData; - if ( st->hTdCngEnc != NULL ) - { - st->hTdCngEnc->CNG_att_fx = float_to_fix16( st->hTdCngEnc->CNG_att, Q7 ); - } int igfGridIdx; if ( st->last_core == ACELP_CORE && st->core == TCX_20_CORE ) @@ -1475,11 +1462,6 @@ void stereo_mdct_core_enc( hPrivateData->igfPastSFM[i][j] = fixedToFloat( hPrivateData->igfPastSFM_fx[i][j], 13 ); } } - - if ( st->hTdCngEnc != NULL ) - { - st->hTdCngEnc->CNG_att = fix16_to_float( st->hTdCngEnc->CNG_att_fx, Q7 ); - } #endif #else ProcessIGF( st, st->hTcxEnc->spectrum[n], orig_spectrum[ch][n], &powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); @@ -1571,24 +1553,12 @@ void stereo_mdct_core_enc( st = sts[ch]; st->hTcxCfg->bandwidth = float_to_fix16( st->hTcxCfg->bandwidth_flt, Q15 ); st->hTcxCfg->preemph_fac = float_to_fix16( st->hTcxCfg->preemph_fac_flt, Q15 ); - st->hTcxEnc->tcx_target_bits_fac = float_to_fix16( st->hTcxEnc->tcx_target_bits_fac_flt, Q14 ); - if ( st->hTdCngEnc != NULL ) - { - st->hTdCngEnc->CNG_att_fx = float_to_fix16( st->hTdCngEnc->CNG_att, Q7 ); - } st->hTcxEnc->measuredBwRatio = float_to_fix16( st->hTcxEnc->measuredBwRatio_flt, Q14 ); } #endif ivas_mdct_quant_coder_fx( hCPE, tnsBits, tnsSize, p_param, 0 ); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - st = sts[ch]; - st->hTcxEnc->tcx_target_bits_fac_flt = me2f_16( st->hTcxEnc->tcx_target_bits_fac, Q15 - Q14 ); - } -#endif pop_wmops(); return; diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc.c index 786f0004c..f6417d724 100644 --- a/lib_enc/ivas_stereo_switching_enc.c +++ b/lib_enc/ivas_stereo_switching_enc.c @@ -680,7 +680,10 @@ ivas_error stereo_memory_enc_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX variables\n" ) ); } } - dtx_enc_init( st, 0, FIXED_SID_RATE ); +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + floatToFixed_arr( st->lsp_old1, st->lsp_old1_fx, Q15, M ); +#endif + dtx_enc_init_fx( st, 0, FIXED_SID_RATE ); IF( st->hTdCngEnc != NULL ) { diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index a66c73295..b2dd2863f 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -468,7 +468,6 @@ void stereo_tcx_core_enc( Q_new = q_comm_Bin - ( QSCALE - 2 ); const Word16 Q_ener = Q_new + Q_SCALE - 2; // Q_new + Q_SCALE -2 - st->stab_fac_fx = float_to_fix16( st->stab_fac, Q15 ); floatToFixed_arrL( st->Bin_E_old, st->Bin_E_old_fx, q_comm_Bin, 128 ); floatToFixed_arrL( st->Bin_E, st->Bin_E_fx, q_comm_Bin, 256 ); floatToFixed_arr( st->lsp_old, st->lsp_old_fx, Q15, M ); @@ -522,10 +521,6 @@ void stereo_tcx_core_enc( { floatToFixed_arr( st->hTdCngEnc->cng_exc2_buf_flt, st->hTdCngEnc->cng_exc2_buf, Q_exc, HO_HIST_SIZE * L_FFT ); } - if ( st->hDtxEnc != NULL ) - { - floatToFixed_arr( st->hDtxEnc->lspCNG, st->hDtxEnc->lspCNG_fx, Q15, M ); - } floatToFixed_arr( st->synth_flt, st->synth, Q_new, st->L_frame ); floatToFixed_arr( st->hLPDmem->syn_flt, st->hLPDmem->syn, Q_new, M + 1 ); diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 8e3b4a2e4..16e8868d6 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1567,15 +1567,11 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( { st_ivas->codec_mode = MODE1; move16(); - test(); - IF( NE_16( hEncoderConfig->element_mode_init, EVS_MONO ) ) - { - reset_rf_indices( hCoreCoder->hRF, hCoreCoder->L_frame, &( hCoreCoder->rf_target_bits_write ) ); - } - ELSE - { - reset_rf_indices_fx( hCoreCoder ); - } +#ifndef IVAS_FLOAT_FIXED + reset_rf_indices( hCoreCoder->hRF, hCoreCoder->L_frame, &( hCoreCoder->rf_target_bits_write ) ); +#else + reset_rf_indices_fx( hCoreCoder ); +#endif } hEncoderConfig->Opt_RF_ON = 0; move16(); @@ -1592,15 +1588,11 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( test(); if ( hEncoderConfig->Opt_RF_ON == 0 && EQ_16( hEncoderConfig->ivas_format, MONO_FORMAT ) ) { - test(); - IF( NE_16( hEncoderConfig->element_mode_init, EVS_MONO ) ) - { - reset_rf_indices( hCoreCoder->hRF, hCoreCoder->L_frame, &( hCoreCoder->rf_target_bits_write ) ); - } - ELSE - { - reset_rf_indices_fx( hCoreCoder ); - } +#ifndef IVAS_FLOAT_FIXED + reset_rf_indices( hCoreCoder->hRF, hCoreCoder->L_frame, &( hCoreCoder->rf_target_bits_write ) ); +#else + reset_rf_indices_fx( hCoreCoder ); +#endif } hEncoderConfig->Opt_RF_ON = 1; hEncoderConfig->rf_fec_offset = hIvasEnc->rf_fec_offset_loc; diff --git a/lib_enc/lsf_enc.c b/lib_enc/lsf_enc.c index a999c061a..965caa246 100644 --- a/lib_enc/lsf_enc.c +++ b/lib_enc/lsf_enc.c @@ -50,6 +50,7 @@ #include "ivas_rom_com.h" #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*-----------------------------------------------------------------* * Local constants *-----------------------------------------------------------------*/ @@ -2099,3 +2100,4 @@ static void lsf_mid_enc( return; } +#endif diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 6d1ce0d06..0fdab4955 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -69,6 +69,25 @@ ivas_error acelp_core_enc_fx( const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ #endif ); +#ifdef IVAS_FLOAT_FIXED +void analy_lp_ivas_fx( + const Word16 speech[], /* i :(Q_new) pointer to the speech frame */ + const Word16 L_frame, /* i :(q0) length of the frame */ + const Word16 L_look, /* i :(q0) look-ahead */ + Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */ + Word16 A[], /* o :(q14) A(z) filter coefficients */ + Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */ + Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */ + Word16 lsp_new[], /* o :(q15) current frame LSPs */ + Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */ + Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */ + const Word16 Top[2], /* i :(q0) open loop pitch lag */ + const Word16 Tnc[2], /* i :(q15) open loop pitch gain */ + const Word32 Core_sr, /* i :(q0) Internal core sampling rate */ + const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */ + Word16 Q_new, /*i: stores Q for speech*/ + Word16 *Q_r /*stores q for ener*/ ); +#endif void analy_lp_fx( const Word16 speech[], /* i : pointer to the speech frame */ diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 286db5954..2efcd9aa7 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -425,32 +425,46 @@ typedef struct td_cng_enc_structure { int16_t lp_cng_mode2; - float lp_ener; /* CNG and DTX - low-pass filtered energy for CNG */ - Word32 lp_ener_fx; /* CNG and DTX - low-pass filtered energy for CNG */ /*Q6*/ - int16_t cng_seed; /* CNG and DTX - seed for white noise random generator */ - int16_t old_enr_index; /* CNG and DTX - index of last encoded CNG energy */ - float Enew; /* CNG and DTX - CNG target residual energy */ - Word32 Enew_fx; /* CNG and DTX - CNG target residual energy */ /*Q6*/ - int16_t cng_hist_ptr; /* CNG and DTX - pointer for averaging buffers */ - float cng_lsp_hist[DTX_HIST_SIZE * M]; /* CNG and DTX - old LSP buffer for averaging */ - float cng_ener_hist[DTX_HIST_SIZE]; /* CNG and DTX - log energy buffer for averaging */ - Word16 cng_lsp_hist_fx[DTX_HIST_SIZE * M]; /* CNG and DTX - old LSP buffer for averaging */ - Word16 cng_ener_hist_fx[DTX_HIST_SIZE]; /* CNG and DTX - log energy buffer for averaging */ - int16_t cng_ener_seed; /* CNG and DTX - seed for random generator for variation of excitation energy */ +#ifndef IVAS_FLOAT_FIXED + float lp_ener; /* CNG and DTX - low-pass filtered energy for CNG */ +#else + Word32 lp_ener_fx; /* CNG and DTX - low-pass filtered energy for CNG Q6 */ +#endif + int16_t cng_seed; /* CNG and DTX - seed for white noise random generator */ + int16_t old_enr_index; /* CNG and DTX - index of last encoded CNG energy */ +#ifndef IVAS_FLOAT_FIXED + float Enew; /* CNG and DTX - CNG target residual energy */ +#else + Word32 Enew_fx; /* CNG and DTX - CNG target residual energy Q6 */ +#endif + int16_t cng_hist_ptr; /* CNG and DTX - pointer for averaging buffers */ +#ifndef IVAS_FLOAT_FIXED + float cng_lsp_hist[DTX_HIST_SIZE * M]; /* CNG and DTX - old LSP buffer for averaging */ + float cng_ener_hist[DTX_HIST_SIZE]; /* CNG and DTX - log energy buffer for averaging */ +#else + Word16 cng_lsp_hist_fx[DTX_HIST_SIZE * M]; /* CNG and DTX - old LSP buffer for averaging Q15 */ + Word16 cng_ener_hist_fx[DTX_HIST_SIZE]; /* CNG and DTX - log energy buffer for averaging Q8 */ +#endif + int16_t cng_ener_seed; /* CNG and DTX - seed for random generator for variation of excitation energy */ int16_t cng_ener_seed1; +#ifndef IVAS_FLOAT_FIXED float lp_sp_enr; - - Word16 lp_sp_enr_fx; /*Q8*/ +#else + Word16 lp_sp_enr_fx; /* Q8 */ +#endif int16_t last_allow_cn_step; - int16_t ho_hist_size; /* CNG and DTX - size of DTX hangover history buffer for averaging, <0,HO_HIST_SIZE> */ - int16_t ho_hist_ptr; /* CNG and DTX - pointer for averaging buffers */ - int32_t ho_sid_bw; /* CNG and DTX - SID bandwidth flags */ - Word16 ho_lsp_hist_fx[HO_HIST_SIZE * M]; /* CNG and DTX - old LSP buffer for averaging */ - Word32 ho_ener_hist_fx[HO_HIST_SIZE]; /* CNG and DTX - energy buffer for averaging */ - Word32 ho_env_hist_fx[HO_HIST_SIZE * NUM_ENV_CNG]; + int16_t ho_hist_size; /* CNG and DTX - size of DTX hangover history buffer for averaging, <0,HO_HIST_SIZE> */ + int16_t ho_hist_ptr; /* CNG and DTX - pointer for averaging buffers */ + int32_t ho_sid_bw; /* CNG and DTX - SID bandwidth flags */ +#ifndef IVAS_FLOAT_FIXED float ho_lsp_hist[HO_HIST_SIZE * M]; /* CNG and DTX - old LSP buffer for averaging */ float ho_ener_hist[HO_HIST_SIZE]; /* CNG and DTX - energy buffer for averaging */ float ho_env_hist[HO_HIST_SIZE * NUM_ENV_CNG]; +#else + Word16 ho_lsp_hist_fx[HO_HIST_SIZE * M]; /* CNG and DTX - old LSP buffer for averaging Q15 */ + Word32 ho_ener_hist_fx[HO_HIST_SIZE]; /* CNG and DTX - energy buffer for averaging Q6 */ + Word32 ho_env_hist_fx[HO_HIST_SIZE * NUM_ENV_CNG]; /* Q6 */ +#endif Word16 ho_lsp_circ_fx[HO_HIST_SIZE * M]; /* CNG and DTX - old LSP buffer for averaging */ Word32 ho_ener_circ_fx[HO_HIST_SIZE]; /* CNG and DTX - energy buffer for averaging */ @@ -467,36 +481,45 @@ typedef struct td_cng_enc_structure Word16 cng_exc2_buf[HO_HIST_SIZE * L_FFT]; /* CNG and DTX - exc2 buffer for storing */ Word16 cng_Qexc_buf[HO_HIST_SIZE]; /* CNG and DTX - Q_exc buffer for storing */ int32_t cng_brate_buf[HO_HIST_SIZE]; /* CNG and DTX - buffer for storing last_active_brate */ - float CNG_att; /* CNG and DTX - attenuation factor for CNG, in dB */ - Word16 CNG_att_fx; /* CNG and DTX - attenuation factor for CNG, in dB (Q7)*/ - int16_t ho_16k_lsp[HO_HIST_SIZE]; /* CNG and DTX - 16k LSPs flags */ - int16_t act_cnt2; /* CNG and DTX - counter of active frames for CNG_mode switching */ - float ho_lsp_circ2[HO_HIST_SIZE * M]; /* CNG and DTX - second buffer of LSPs */ - Word16 ho_lsp_circ2_fx[HO_HIST_SIZE * M]; /* CNG and DTX - second buffer of LSPs */ - int16_t num_ho; /* CNG and DTX - number of selected hangover frames */ +#ifndef IVAS_FLOAT_FIXED + float CNG_att; /* CNG and DTX - attenuation factor for CNG, in dB */ +#else + Word16 CNG_att_fx; /* CNG and DTX - attenuation factor for CNG, in dB Q7 */ +#endif + int16_t ho_16k_lsp[HO_HIST_SIZE]; /* CNG and DTX - 16k LSPs flags */ + int16_t act_cnt2; /* CNG and DTX - counter of active frames for CNG_mode switching */ + float ho_lsp_circ2[HO_HIST_SIZE * M]; /* CNG and DTX - second buffer of LSPs */ + Word16 ho_lsp_circ2_fx[HO_HIST_SIZE * M]; /* CNG and DTX - second buffer of LSPs */ + int16_t num_ho; /* CNG and DTX - number of selected hangover frames */ +#ifndef IVAS_FLOAT_FIXED float old_env[NUM_ENV_CNG]; float lp_env[NUM_ENV_CNG]; float cng_res_env[NUM_ENV_CNG * HO_HIST_SIZE]; +#else + Word32 old_env_fx[NUM_ENV_CNG]; /* Q6 */ + Word32 lp_env_fx[NUM_ENV_CNG]; /* Q6 */ + Word32 cng_res_env_fx[NUM_ENV_CNG * HO_HIST_SIZE]; /* Q6 */ +#endif float exc_mem[24]; float exc_mem1[30]; float exc_mem2[30]; - Word32 old_env_fx[NUM_ENV_CNG]; - Word32 lp_env_fx[NUM_ENV_CNG]; - Word32 cng_res_env_fx[NUM_ENV_CNG * HO_HIST_SIZE]; Word16 exc_mem_fx[24]; Word16 exc_mem1_fx[30]; Word16 exc_mem2_fx[30]; /* SWB DTX/CNG parameters */ int16_t last_vad; +#ifndef IVAS_FLOAT_FIXED float last_wb_cng_ener; float last_shb_cng_ener; float mov_wb_cng_ener; float mov_shb_cng_ener; - Word16 last_wb_cng_ener_fx; - Word16 last_shb_cng_ener_fx; - Word16 mov_wb_cng_ener_fx; - Word16 mov_shb_cng_ener_fx; +#else + Word16 last_wb_cng_ener_fx; /* Q8 */ + Word16 last_shb_cng_ener_fx; /* Q8 */ + Word16 mov_wb_cng_ener_fx; /* Q8 */ + Word16 mov_shb_cng_ener_fx; /* Q8 */ +#endif int16_t last_idx_ener; int16_t shb_cng_ini_cnt; int16_t last_SID_bwidth; @@ -632,13 +655,16 @@ typedef struct fd_cng_enc_structure typedef struct dtx_enc_structure { - int16_t cnt_SID; /* CNG and DTX - counter of SID update for the interop. mode or DTX, if enabled */ - int16_t first_CNG; /* CNG and DTX - first CNG frame flag */ - int16_t cng_cnt; /* CNG and DTX - counter of CNG frames for averaging */ - int16_t max_SID; /* CNG and DTX - max allowed number of CNG FRAME_NO_DATA frames */ - int16_t CNG_mode; /* CNG and DTX - mode for DTX configuration */ - float lspCNG[M]; /* CNG and DTX - LP filtered ISPs */ - Word16 lspCNG_fx[M]; /* CNG and DTX - LP filtered lsps */ + int16_t cnt_SID; /* CNG and DTX - counter of SID update for the interop. mode or DTX, if enabled */ + int16_t first_CNG; /* CNG and DTX - first CNG frame flag */ + int16_t cng_cnt; /* CNG and DTX - counter of CNG frames for averaging */ + int16_t max_SID; /* CNG and DTX - max allowed number of CNG FRAME_NO_DATA frames */ + int16_t CNG_mode; /* CNG and DTX - mode for DTX configuration */ +#ifndef IVAS_FLOAT_FIXED + float lspCNG[M]; /* CNG and DTX - LP filtered ISPs */ +#else + Word16 lspCNG_fx[M]; /* CNG and DTX - LP filtered lsps Q15 */ +#endif int16_t VarDTX_cnt_voiced; /* CNG and DTX - counter for variable DTX activation (speech) */ int16_t VarDTX_cnt_noise; /* CNG and DTX - counter for variable DTX activation (noise) */ #ifndef IVAS_FLOAT_FIXED @@ -1682,22 +1708,28 @@ typedef struct rf_enc_structure ACELP_config acelp_cfg_rf; /* configuration for RF frame */ +#ifndef IVAS_FLOAT_FIXED float rf_mem_w0_flt; float rf_clip_var_flt[6]; float rf_tilt_code_flt; float rf_mem_syn2_flt[M]; float rf_dispMem[8]; float rf_gc_threshold_flt; +#else Word16 rf_mem_w0; Word16 rf_clip_var[6]; Word16 rf_tilt_code; Word16 rf_mem_syn2[M]; struct dispMem_fx rf_dm_fx; Word32 rf_gc_threshold; +#endif int16_t rf_target_bits; +#ifndef IVAS_FLOAT_FIXED float rf_tilt_buf_flt[NB_SUBFR16k]; +#else Word16 rf_tilt_buf[NB_SUBFR16k]; +#endif int16_t rf_indx_lsf[MAX_RF_FEC_OFFSET][3]; int16_t rf_indx_pitch[MAX_RF_FEC_OFFSET][NB_SUBFR16k]; @@ -1869,12 +1901,13 @@ typedef struct tcx_enc_structure Word16 tcxltp_gain_past; /* Q15 */ #endif float tcxltp_norm_corr_past_flt; - Word16 tcxltp_norm_corr_past; + Word16 tcxltp_norm_corr_past; /* Q15 */ float tcxltp_norm_corr_mem_flt; + Word16 tcxltp_norm_corr_mem; /* Q15 */ +#ifndef IVAS_FLOAT_FIXED float kernel_switch_corr_past_flt; -#ifdef IVAS_FLOAT_FIXED - Word16 tcxltp_norm_corr_mem; - Word16 kernel_switch_corr_past; +#else + Word16 kernel_switch_corr_past; /* Q15 */ #endif uint16_t kernel_type[2]; /* transform kernel type in each subframe (MDCT or MDST) */ uint16_t kernel_symmetry_past; /* last TDA symmetry (0 for MDCT, 1 for MDST type) */ @@ -1931,10 +1964,13 @@ typedef struct tcx_enc_structure /* TCX memory */ float Txnq_flt[L_FRAME32k / 2 + 64]; /* Q target (overlap or ACELP+ZIR, use Aq) */ float *acelp_zir_flt; - float tcx_target_bits_fac_flt; Word16 Txnq[L_FRAME32k / 2 + 64]; /* Q target (overlap or ACELP+ZIR, use Aq) */ Word16 *acelp_zir; - Word16 tcx_target_bits_fac; // Q14// +#ifndef IVAS_FLOAT_FIXED + float tcx_target_bits_fac_flt; +#else + Word16 tcx_target_bits_fac; /* Q14 */ +#endif int16_t tns_ms_flag[2]; Word32 *spectrum_fx[2]; /* MDCT output for a short block */ @@ -2081,11 +2117,14 @@ typedef struct enc_core_structure Word16 lsf_old_fx[M]; /* old LSF vector at the end of the frame Qlog2(2.56) */ Word16 lsp_old16k_fx[M]; /* old LSP vector at the end of the frame @16kHz */ Word16 lspold_enc_fx[M]; /* old LSP vector at the end of the frame @16kHz */ - - int16_t pstreaklen; /* LSF quantizer */ - - float streaklimit; /* LSF quantizer */ - float stab_fac; /* LSF stability factor */ + int16_t pstreaklen; /* LSF quantizer */ +#ifndef IVAS_FLOAT_FIXED + float streaklimit; /* LSF quantizer */ + float stab_fac; /* LSF stability factor */ +#else + Word16 streaklimit_fx; /* LSF quantizer Q15 */ + Word16 stab_fac_fx; /* LSF stability factor Q15 */ +#endif float mem_preemph; /* preemphasis filter memory */ float old_wsp[L_WSP_MEM]; /* old weighted signal vector */ float old_wsp2[( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM]; /* old decimated weighted signal vector */ @@ -2095,14 +2134,12 @@ typedef struct enc_core_structure float mem_AR[M]; /* AR memory of LSF quantizer (past quantized LSFs without mean) */ float mem_MA[M]; /* MA memory of LSF quantizer (past quantized residual) (used also in AMR-WB IO mode) */ // Word16 pstreaklen_fx; /* LSF quantizer */ - Word16 streaklimit_fx; /* LSF quantizer */ Word32 offset_scale1_fx[MAX_NO_MODES + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure 1st 8-dim subvector*/ Word32 offset_scale2_fx[MAX_NO_MODES + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure 2nd 8-dim subvector*/ Word32 offset_scale1_p_fx[MAX_NO_MODES_p + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure, pred. case, 1st 8-dim subvector*/ Word32 offset_scale2_p_fx[MAX_NO_MODES_p + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure, pred. case, 2nd 8-dim subvector*/ Word16 no_scales_fx[MAX_NO_MODES][2]; /* LSF LVQ structure Q0*/ Word16 no_scales_p_fx[MAX_NO_MODES_p][2]; /* LSF LVQ structure Q0*/ - Word16 stab_fac_fx; /* LSF stability factor */ Word16 mem_preemph_fx; /* preemphasis filter memory */ diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index f75e6050f..18ef67dbf 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -1253,7 +1253,7 @@ void wb_tbe_enc_ivas_fx( FOR( j = 0; j < L_SUBFR16k; j = j + 4 ) { L_tmp = L_mult( hb_old_speech[i], ola_win_shb_switch_fold_fx[j] ); - hb_old_speech[i] = mac_r( L_tmp, hb_speech[j], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j] ); + hb_old_speech[i] = mac_r( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j] ); move16(); i = sub( i, 1 ); k = add( k, 1 ); diff --git a/lib_enc/tcx_utils_enc.c b/lib_enc/tcx_utils_enc.c index 5999ca2cc..a4225f2ce 100644 --- a/lib_enc/tcx_utils_enc.c +++ b/lib_enc/tcx_utils_enc.c @@ -1605,9 +1605,7 @@ void ProcessIGF_ivas_fx( return; } -#endif - - +#else /*---------------------------------------------------------------------* * ProcessIGF() * @@ -1679,6 +1677,7 @@ void ProcessIGF( return; } +#endif /*---------------------------------------------------------------------* @@ -1686,6 +1685,7 @@ void ProcessIGF( * * *---------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED void ProcessStereoIGF_fx( STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, @@ -1779,7 +1779,7 @@ void ProcessStereoIGF_fx( } return; } -#endif +#else void ProcessStereoIGF( STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ @@ -1860,6 +1860,7 @@ void ProcessStereoIGF( return; } +#endif /*---------------------------------------------------------------------* * attenuateNbSpectrum() diff --git a/lib_enc/vad_proc.c b/lib_enc/vad_proc.c index a22e5c2c1..8d9c02f37 100644 --- a/lib_enc/vad_proc.c +++ b/lib_enc/vad_proc.c @@ -142,6 +142,7 @@ int16_t vad_init( } +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * UpdateState() * @@ -289,3 +290,4 @@ int16_t vad_proc( return vad_flag; } +#endif -- GitLab