From 424b84004c8d4792fbda8d42d5400c44a226331d Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 11 Apr 2024 22:34:10 +0530 Subject: [PATCH 1/2] Integration of fixed point sub-functions 16 [x] Some of EVS_FLOAT macro dependency removal done [x] Clean up of intermediate buffers, float variables/buffers in different structures [x] Build warnings fix [x] added rescaling in decod_gen_2sfbr [x] ivas_spar_update_md_hist, ivas_spar_smooth_md_dtx, ivas_spar_setup_md_smoothing converted to fixed point [x] Converted few functions in ivas_dirac_output_synthesis_dec.c file --- Makefile | 2 +- lib_com/cnst.h | 2 +- lib_com/float_to_fix_ops.c | 333 +---- lib_com/hp50.c | 14 +- lib_com/ivas_entropy_coder_common.c | 3 + lib_com/ivas_prot.h | 24 +- lib_com/ivas_prot_fx.h | 21 +- lib_com/ivas_spar_com.c | 43 +- lib_com/ivas_spar_com_quant_util.c | 8 +- lib_com/prot.h | 42 +- lib_com/swb_tbe_com_fx.c | 2 +- lib_com/tcx_mdct_window.c | 2 +- lib_dec/acelp_core_dec.c | 1290 +------------------- lib_dec/acelp_core_dec_ivas_fx.c | 42 +- lib_dec/amr_wb_dec.c | 213 +--- lib_dec/core_dec_init.c | 211 +--- lib_dec/core_dec_init_fx.c | 3 +- lib_dec/core_dec_reconf.c | 6 +- lib_dec/core_dec_reconf_fx.c | 4 - lib_dec/core_dec_switch.c | 23 + lib_dec/core_switching_dec.c | 6 +- lib_dec/core_switching_dec_fx.c | 4 +- lib_dec/dec_LPD.c | 178 --- lib_dec/dec_tcx.c | 2 +- lib_dec/dec_tcx_fx.c | 6 +- lib_dec/er_dec_tcx_fx.c | 14 +- lib_dec/evs_dec.c | 367 +----- lib_dec/fd_cng_dec.c | 6 +- lib_dec/hq_core_dec.c | 6 +- lib_dec/init_dec_fx.c | 23 +- lib_dec/ivas_agc_dec_fx.c | 5 +- lib_dec/ivas_binRenderer_internal.c | 2 +- lib_dec/ivas_core_dec.c | 267 ++-- lib_dec/ivas_corecoder_dec_reconfig.c | 16 +- lib_dec/ivas_cpe_dec_fx.c | 2 +- lib_dec/ivas_dirac_dec.c | 5 + lib_dec/ivas_dirac_output_synthesis_cov.c | 28 + lib_dec/ivas_jbm_dec.c | 30 +- lib_dec/ivas_mct_dec.c | 303 +++-- lib_dec/ivas_mdct_core_dec.c | 40 +- lib_dec/ivas_pca_dec_fx.c | 2 +- lib_dec/ivas_sce_dec_fx.c | 21 +- lib_dec/ivas_spar_decoder.c | 272 ++++- lib_dec/ivas_spar_md_dec.c | 245 +++- lib_dec/ivas_stat_dec.h | 6 +- lib_dec/ivas_stereo_dft_dec.c | 4 +- lib_dec/ivas_stereo_dft_dec_fx.c | 2 +- lib_dec/ivas_stereo_mdct_core_dec_fx.c | 80 +- lib_dec/ivas_stereo_switching_dec.c | 6 +- lib_dec/ivas_tcx_core_dec.c | 24 +- lib_dec/ivas_td_low_rate_dec.c | 46 +- lib_dec/lsf_dec.c | 6 +- lib_dec/stat_dec.h | 34 +- lib_dec/swb_bwe_dec_fx.c | 2 +- lib_dec/swb_tbe_dec.c | 4 +- lib_dec/swb_tbe_dec_fx.c | 4 +- lib_dec/tonalMDCTconcealment_fx.c | 163 +-- lib_dec/updt_dec_fx.c | 10 +- lib_enc/ACcontextMapping_enc_fx.c | 2 +- lib_enc/acelp_core_enc.c | 10 +- lib_enc/cod_ace_fx.c | 2 +- lib_enc/core_enc_2div_fx.c | 4 +- lib_enc/core_enc_ol_fx.c | 6 +- lib_enc/enc_gen_voic_rf_fx.c | 2 +- lib_enc/enc_uv_fx.c | 2 +- lib_enc/ext_sig_ana_fx.c | 4 +- lib_enc/igf_scf_enc_fx.c | 8 +- lib_enc/ivas_agc_enc.c | 2 +- lib_enc/ivas_core_pre_proc_front.c | 4 +- lib_enc/ivas_cpe_enc.c | 2 +- lib_enc/ivas_init_enc.c | 2 +- lib_enc/ivas_spar_encoder.c | 2 +- lib_enc/ivas_spar_md_enc.c | 2 +- lib_enc/ivas_stat_enc.h | 2 +- lib_enc/ivas_stereo_classifier.c | 4 +- lib_enc/ivas_stereo_ica_enc.c | 2 +- lib_enc/lib_enc.c | 2 +- lib_enc/lsf_enc.c | 6 +- lib_enc/qlpc_stoch_fx.c | 2 +- lib_enc/stat_enc.h | 2 +- lib_rend/ivas_crend.c | 16 +- lib_rend/ivas_dirac_output_synthesis_dec.c | 373 +++++- lib_rend/ivas_dirac_rend.c | 97 ++ lib_rend/ivas_reverb.c | 2 +- lib_rend/ivas_stat_rend.h | 40 +- lib_rend/lib_rend.c | 42 +- 86 files changed, 1871 insertions(+), 3302 deletions(-) diff --git a/Makefile b/Makefile index 311cb8b9b..ef8fa2d3a 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ endif # C compiler flags CFLAGS += -std=c99 -pedantic -Wcast-qual -Wall -W -Wextra -Wno-long-long \ - -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \ + -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wconversion \ -Werror-implicit-function-declaration \ -Wno-implicit-fallthrough -ffp-contract=off diff --git a/lib_com/cnst.h b/lib_com/cnst.h index b0a482d1c..4d432ca7b 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -226,7 +226,7 @@ enum{ #define INV_LOG_2 1.442695040888963f /* 1/log(2) */ #define INV_SQRT_2 0.70710676908493f /* 1/sqrt(2) */ #define INV_SQRT_2_Q15 23170 /* 1/sqrt(2) in Q15 */ -#define INV_SQRT_2_Q31 1.51850022e+09 /* 1/sqrt(2) in Q31 */ +#define INV_SQRT_2_Q31 (Word32)1.51850022e+09 /* 1/sqrt(2) in Q31 */ #define MAX_V_MULT_MAT 100 /* maximum array length for the function v_mult_mat() */ diff --git a/lib_com/float_to_fix_ops.c b/lib_com/float_to_fix_ops.c index cf3d63323..264f1cd68 100644 --- a/lib_com/float_to_fix_ops.c +++ b/lib_com/float_to_fix_ops.c @@ -114,14 +114,14 @@ Word16 Q_factor(float x) { Word16 Q = 15; if ( x >= 1 || x <= -1 ) - Q = norm_s((Word16)abs(x)); + Q = norm_s((Word16)abs((Word32)x)); return Q; } Word16 Q_factor_L(float x) { Word16 Q = 31; if ( x >= 1 || x <= -1 ) - Q = norm_l((Word32)abs(x)); + Q = norm_l(abs((Word32)x)); return Q; } Word16 Q_factor_arr(float *x, Word16 l) @@ -130,7 +130,7 @@ Word16 Q_factor_arr(float *x, Word16 l) for (int i = 0; i < l; i++) { if (x[i] >= 1 || x[i] <= -1) - Q = s_min(Q, norm_s((Word16)abs(x[i]))); + Q = s_min(Q, norm_s((Word16)abs((Word32)x[i]))); } return Q; } @@ -140,7 +140,7 @@ Word16 Q_factor_arrL(float *x, Word16 l) for (int i = 0; i < l; i++) { if (x[i] >= 1 || x[i] <= -1) - Q = s_min(Q, norm_l((Word32)abs(x[i]))); + Q = s_min(Q, norm_l((Word32)abs((Word32)x[i]))); } return Q; } @@ -201,14 +201,13 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( Word16 i = 0, Q_old_synth = 0, Q_syn = 0, Q_synth_history = 0, Q_fer_samples = 0, Q_cldfbAna_cldfb_state = 0, Q_cldfbBPF_cldfb_state = 0, Q_cldfbSyn_cldfb_state = 0, Q_cldfbSynHB_cldfb_state = 0, - Q_old_Aq_12_8 = 12, Q_pst_old_syn = 0, + Q_pst_old_syn = 0, delay_comp = 0, Q_loBuffer = 0; Word16 Q_lsf_cng = Q_factor( 6400 ); - Word16 Q_old_enr_LP = Q_factor( st->old_enr_LP_float ); Word16 Q_tcxltp_mem_in = 0, Q_tcxltp_mem_out = 0, Q_tcxltp_gain_post_prev = 0; TD_BWE_DEC_HANDLE hBWE_TD = st->hBWE_TD; - Word16 Q_state_lsyn_filt_shb = 0, Q_state_lsyn_filt_dwn_shb = 0, Q_mem_resamp_HB = 0, Q_syn_overlap = 0, Q_tbe_demph = 0, Q_tbe_premph = 0, Q_int_3_over_2_tbemem_dec = 0, Q_mem_resamp_HB_32k = 0, Q_prev_fb_ener_adjust = 0, Q_fb_state_lpc_syn = 0, Q_fb_tbe_demph = 0, + Word16 Q_state_lsyn_filt_shb = 0, Q_state_lsyn_filt_dwn_shb = 0, Q_mem_resamp_HB = 0, Q_syn_overlap = 0, Q_int_3_over_2_tbemem_dec = 0, Q_mem_resamp_HB_32k = 0, Q_prev_fb_ener_adjust = 0, Q_fb_state_lpc_syn = 0, Q_genSHBsynth_Hilbert_Mem = 0, Q_genSHBsynth_state_lsyn_filt_shb_local = 0; if ( tofix ) @@ -234,7 +233,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( st->preemph_fac = (Word16) floatToFixed( st->preemph_fac_float, 15 ); Q_syn = Q_factor_arr( st->syn_float, 17 ); floatToFixed_arr( st->syn_float, st->syn, Q_syn, M + 1 ); - floatToFixed_arr( st->lsp_old, st->lsp_old_fx, 15, M ); + //floatToFixed_arr( st->lsp_old, st->lsp_old_fx, 15, M ); FOR( i = 0; i < M; i++ ) { st->mem_MA_fx[i] = (Word16) floatToFixed( (float) ( st->mem_MA[i] * 2.56 ), 0 ); @@ -242,35 +241,10 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( } IF( st->hTcxCfg ) { - st->hTcxCfg->preemph_fac = (Word16) floatToFixed( st->hTcxCfg->preemph_fac_flt, 15 ); - st->hTcxCfg->sq_rounding = (Word16) floatToFixed( st->hTcxCfg->sq_rounding_flt, 15 ); - st->hTcxCfg->bandwidth = (Word16) floatToFixed( st->hTcxCfg->bandwidth_flt, 15 ); - st->hTcxCfg->na_scale = (Word16) floatToFixed( st->hTcxCfg->na_scale_flt, 15 ); - Word16 n = st->L_frame; Word16 n0 = shr( imult1616( n, 9 ), 5 ); Word16 n1 = shr( imult1616( n, 23 ), 5 ); /* left slope length */ Word16 n2 = shr( imult1616( n, 14 ), 5 ); /* right slope length */ - FOR( i = 0; i < n0; i++ ) - { - st->hTcxCfg->tcx_aldo_window_1[i] = (Word16) floatToFixed( st->hTcxCfg->tcx_aldo_window_1_flt[i], 15 ); - } - FOR( i = n0; i < n / 2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_1_trunc[i - n0].v.im = (Word16) floatToFixed( st->hTcxCfg->tcx_aldo_window_1_flt[i], 15 ); - } - FOR( i = 0; i < n1 - n / 2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_1_trunc[n1 - n / 2 - 1 - i].v.re = (Word16) floatToFixed( st->hTcxCfg->tcx_aldo_window_1_flt[n / 2 + i], 15 ); - } - FOR( i = 0; i < n2 / 2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_2[i].v.im = (Word16) floatToFixed( st->hTcxCfg->tcx_aldo_window_2_flt[i], 15 ); - } - FOR( i = n2 / 2; i < n2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_2[n2 - i - 1].v.re = (Word16) floatToFixed( st->hTcxCfg->tcx_aldo_window_2_flt[i], 15 ); - } n = NS2SA_fx2( st->output_Fs, FRAME_SIZE_NS ); n0 = shr( imult1616( n, 9 ), 5 ); n1 = shr( imult1616( n, 23 ), 5 ); /* left slope length */ @@ -359,7 +333,6 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( Q_cldfbSynHB_cldfb_state = Q_factor_arrL( st->cldfbSynHB->cldfb_state, st->cldfbSynHB->cldfb_state_length ) - 1; floatToFixed_arrL( st->cldfbSynHB->cldfb_state, st->cldfbSynHB->cldfb_state_fx, Q_cldfbSynHB_cldfb_state, st->cldfbSynHB->cldfb_state_length ); } - floatToFixed_arr( st->old_Aq_12_8, st->old_Aq_12_8_fx, Q_old_Aq_12_8, M + 1 ); IF( st->hBPF ) { Q_pst_old_syn = Q_syn; @@ -367,17 +340,9 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( floatToFixed_arr( st->hBPF->pst_old_syn, st->hBPF->pst_old_syn_fx, Q_pst_old_syn, NBPSF_PIT_MAX ); } - //floatToFixed_arr( st->lsf_cng_float, st->lsf_cng, Q_lsf_cng, M ); st->last_concealed_gain_syn_deemph = (Word16) floatToFixed( st->last_concealed_gain_syn_deemph_float, 14 ); - st->old_enr_LP = (Word16) floatToFixed( st->old_enr_LP_float, Q_old_enr_LP ); st->enr_old_fx = (Word16) floatToFixed( st->enr_old, 0 ); floatToFixed_arr( st->previoussynth, st->previoussynth_fx, 0, 960 ); - //FOR( i = 0; i < M; i++ ) - //{ - //st->lsf_adaptive_mean_fx[i] = (Word16) floatToFixed( st->lsf_adaptive_mean[i] / 100, 8 ); - //st->lsfoldbfi0_fx[i] = (Word16) floatToFixed( st->lsfoldbfi0[i] / 100, 8 ); - //st->lsfoldbfi1_fx[i] = (Word16) floatToFixed( st->lsfoldbfi1[i] / 100, 8 ); - //} IF( st->hTcxLtpDec ) { Q_tcxltp_mem_in = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_in_float, TCXLTP_MAX_DELAY ); @@ -389,7 +354,6 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( } - // st->last_gain_syn_deemph = floatToFixed(st->last_gain_syn_deemph_float, 14); st->last_gain_syn_deemph = 0; IF( hBWE_TD ) { @@ -399,21 +363,14 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( floatToFixed_arr( hBWE_TD->state_lsyn_filt_dwn_shb, hBWE_TD->state_lsyn_filt_dwn_shb_fx, Q_state_lsyn_filt_dwn_shb, 6 ); Q_mem_resamp_HB = Q_factor_arr( hBWE_TD->mem_resamp_HB, 13 ); floatToFixed_arr( hBWE_TD->mem_resamp_HB, hBWE_TD->mem_resamp_HB_fx, Q_mem_resamp_HB, 13 ); - hBWE_TD->prev_pow_exc16kWhtnd_fx = (Word16) floatToFixed( hBWE_TD->prev_pow_exc16kWhtnd, 15 ); Q_syn_overlap = Q_factor_arr( hBWE_TD->syn_overlap, 20 ); floatToFixed_arr( hBWE_TD->syn_overlap, hBWE_TD->syn_overlap_fx, Q_syn_overlap, 20 ); - Q_tbe_demph = Q_factor( (Word16) hBWE_TD->tbe_demph ); - Q_tbe_premph = Q_factor( (Word16) hBWE_TD->tbe_premph ); Q_int_3_over_2_tbemem_dec = Q_factor_arr( hBWE_TD->int_3_over_2_tbemem_dec, 15 ); Q_mem_resamp_HB_32k = Q_factor_arr( hBWE_TD->mem_resamp_HB_32k, 7 ); Q_prev_fb_ener_adjust = Q_factor( (Word16) st->hBWE_FD->prev_fb_ener_adjust ); Q_fb_state_lpc_syn = Q_factor_arr( hBWE_TD->fb_state_lpc_syn, 10 ); st->prev_fb_ener_adjust_fx = (Word16) floatToFixed( st->hBWE_FD->prev_fb_ener_adjust, Q_prev_fb_ener_adjust ); floatToFixed_arr( hBWE_TD->fb_state_lpc_syn, hBWE_TD->fb_state_lpc_syn_fx, Q_fb_state_lpc_syn, 10 ); - Q_fb_tbe_demph = Q_factor( (Word16) hBWE_TD->fb_tbe_demph ); - hBWE_TD->fb_tbe_demph_fx = (Word16) floatToFixed( hBWE_TD->fb_tbe_demph, Q_fb_tbe_demph ); - hBWE_TD->tbe_demph_fx = (Word16) floatToFixed( hBWE_TD->tbe_demph, Q_tbe_demph ); - hBWE_TD->tbe_premph_fx = (Word16) floatToFixed( hBWE_TD->tbe_premph, Q_tbe_premph ); floatToFixed_arr( hBWE_TD->int_3_over_2_tbemem_dec, hBWE_TD->int_3_over_2_tbemem_dec_fx, Q_int_3_over_2_tbemem_dec, INTERP_3_2_MEM_LEN ); floatToFixed_arr( hBWE_TD->mem_resamp_HB_32k, hBWE_TD->mem_resamp_HB_32k_fx, Q_mem_resamp_HB_32k, 7 ); Q_genSHBsynth_Hilbert_Mem = Q_factor_arrL( hBWE_TD->genSHBsynth_Hilbert_Mem, 21 ); @@ -475,34 +432,23 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( Q_state_lsyn_filt_dwn_shb = Q_factor_arr( hBWE_TD->state_lsyn_filt_dwn_shb, 6 ); Q_mem_resamp_HB = Q_factor_arr( hBWE_TD->mem_resamp_HB, 13 ); Q_syn_overlap = Q_factor_arr( hBWE_TD->syn_overlap, 20 ); - Q_tbe_demph = Q_factor( (Word16) hBWE_TD->tbe_demph ); - Q_tbe_premph = Q_factor( (Word16) hBWE_TD->tbe_premph ); Q_int_3_over_2_tbemem_dec = Q_factor_arr( hBWE_TD->int_3_over_2_tbemem_dec, 15 ); Q_mem_resamp_HB_32k = Q_factor_arr( hBWE_TD->mem_resamp_HB_32k, 7 ); Q_prev_fb_ener_adjust = Q_factor( (Word16) st->hBWE_FD->prev_fb_ener_adjust ); Q_fb_state_lpc_syn = Q_factor_arr( hBWE_TD->fb_state_lpc_syn, 10 ); - Q_fb_tbe_demph = Q_factor( (Word16) hBWE_TD->fb_tbe_demph ); Q_genSHBsynth_Hilbert_Mem = Q_factor_arrL( hBWE_TD->genSHBsynth_Hilbert_Mem, 21 ); Q_genSHBsynth_state_lsyn_filt_shb_local = Q_factor_arr( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local, 6 ); st->hBWE_TD->prev_tilt_para = 0.0f; - fixedToFloat_arr( st->hBWE_TD->cur_sub_Aq_fx, st->hBWE_TD->cur_sub_Aq, 15, M + 1 ); fixedToFloat_arr( hBWE_TD->state_lsyn_filt_shb_fx, hBWE_TD->state_lsyn_filt_shb, Q_state_lsyn_filt_shb, 6 ); fixedToFloat_arr( hBWE_TD->state_lsyn_filt_dwn_shb_fx, hBWE_TD->state_lsyn_filt_dwn_shb, Q_state_lsyn_filt_dwn_shb, 6 ); fixedToFloat_arr( hBWE_TD->mem_resamp_HB_fx, hBWE_TD->mem_resamp_HB, Q_mem_resamp_HB, 13 ); fixedToFloat_arr( hBWE_TD->syn_overlap_fx, hBWE_TD->syn_overlap, Q_syn_overlap, 20 ); fixedToFloat_arr( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local, Q_genSHBsynth_state_lsyn_filt_shb_local, HILBERT_MEM_SIZE ); fixedToFloat_arrL( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_Hilbert_Mem, Q_genSHBsynth_Hilbert_Mem, HILBERT_MEM_SIZE ); - hBWE_TD->tbe_demph = fixedToFloat( hBWE_TD->tbe_demph_fx, Q_tbe_demph ); - hBWE_TD->tbe_premph = fixedToFloat( hBWE_TD->tbe_premph_fx, Q_tbe_premph ); fixedToFloat_arr( hBWE_TD->int_3_over_2_tbemem_dec_fx, hBWE_TD->int_3_over_2_tbemem_dec, Q_int_3_over_2_tbemem_dec, 15 ); fixedToFloat_arr( hBWE_TD->mem_resamp_HB_32k_fx, hBWE_TD->mem_resamp_HB_32k, Q_mem_resamp_HB_32k, 7 ); //bool des = ( st->bwidth == WB && st->last_extl != WB_TBE ) || ( st->bwidth == SWB && st->last_extl != SWB_TBE ) || ( st->bwidth == FB && st->last_extl != FB_TBE ); - if ( ( st->bwidth == SWB || st->bwidth == FB ) && st->igf && ( st->bwidth == SWB || st->bwidth == FB ) ) - { - hBWE_TD->prev_pow_exc16kWhtnd = (float) hBWE_TD->prev_pow_exc16kWhtnd_fx / 32767; - } st->hBWE_FD->prev_fb_ener_adjust = fixedToFloat( st->prev_fb_ener_adjust_fx, Q_prev_fb_ener_adjust ); - hBWE_TD->fb_tbe_demph = fixedToFloat( hBWE_TD->fb_tbe_demph_fx, Q_fb_tbe_demph ); } st->preemph_fac_float = fixedToFloat( st->preemph_fac, 15 ); IF( st->hTECDec != NULL ) @@ -516,45 +462,6 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( } IF( st->hTcxCfg ) { - st->hTcxCfg->preemph_fac_flt = fixedToFloat( st->hTcxCfg->preemph_fac, 15 ); - st->hTcxCfg->sq_rounding_flt = fixedToFloat( st->hTcxCfg->sq_rounding, 15 ); - st->hTcxCfg->bandwidth_flt = fixedToFloat( st->hTcxCfg->bandwidth, 15 ); - st->hTcxCfg->na_scale_flt = fixedToFloat( st->hTcxCfg->na_scale, 15 ); - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_length / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_window_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_window[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_window_flt[st->hTcxCfg->tcx_mdct_window_length - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_window[i].v.re, 15 ); - } - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_lengthFB / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_windowFB_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_windowFB[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_windowFB_flt[st->hTcxCfg->tcx_mdct_window_lengthFB - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_windowFB[i].v.re, 15 ); - } - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_trans_length / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_window_trans_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_trans[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_window_trans_flt[st->hTcxCfg->tcx_mdct_window_trans_length - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_trans[i].v.re, 15 ); - } - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_trans_lengthFB / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_window_transFB_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_transFB[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_window_transFB_flt[st->hTcxCfg->tcx_mdct_window_trans_lengthFB - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_transFB[i].v.re, 15 ); - } - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_half_length / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_window_half_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_half[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_window_half_flt[st->hTcxCfg->tcx_mdct_window_half_length - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_half[i].v.re, 15 ); - } - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_half_lengthFB / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_window_halfFB_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_halfFB[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_window_halfFB_flt[st->hTcxCfg->tcx_mdct_window_half_lengthFB - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_halfFB[i].v.re, 15 ); - } - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_min_length / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_window_minimum_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_minimum[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_window_minimum_flt[st->hTcxCfg->tcx_mdct_window_min_length - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_minimum[i].v.re, 15 ); - } FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_min_lengthFB / 2; i++ ) { st->hTcxCfg->tcx_mdct_window_minimumFB_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.im, 15 ); @@ -564,26 +471,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( Word16 n0 = shr( imult1616( n, 9 ), 5 ); Word16 n1 = shr( imult1616( n, 23 ), 5 ); /* left slope length */ Word16 n2 = shr( imult1616( n, 14 ), 5 ); /* right slope length */ - FOR( i = 0; i < n0; i++ ) - { - st->hTcxCfg->tcx_aldo_window_1_flt[i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_1[i], 15 ); - } - FOR( i = n0; i < n / 2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_1_flt[i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_1_trunc[i - n0].v.im, 15 ); - } - FOR( i = 0; i < n1 - n / 2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_1_flt[n / 2 + i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_1_trunc[n1 - n / 2 - 1 - i].v.re, 15 ); - } - FOR( i = 0; i < n2 / 2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_2_flt[i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_2[i].v.im, 15 ); - } - FOR( i = n2 / 2; i < n2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_2_flt[i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_2[n2 - i - 1].v.re, 15 ); - } + n = NS2SA_fx2( st->output_Fs, FRAME_SIZE_NS ); n0 = shr( imult1616( n, 9 ), 5 ); n1 = shr( imult1616( n, 23 ), 5 ); /* left slope length */ @@ -602,7 +490,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( } FOR( i = 0; i < n2 / 2; i++ ) { - st->hTcxCfg->tcx_aldo_window_2_FB_flt[i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_2_FB[i].v.im, 15 ); + st->hTcxCfg->tcx_aldo_window_2_FB_flt[i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_2_FB[i].v.im, 15 ); } FOR( i = n2 / 2; i < n2; i++ ) { @@ -639,7 +527,6 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( st->hTcxDec->cummulative_damping_tcx_float = fixedToFloat( st->hTcxDec->cummulative_damping_tcx, 15 ); } fixedToFloat_arr( st->syn, st->syn_float, Q_syn, M + 1 ); - fixedToFloat_arr( st->lsp_old_fx, st->lsp_old, 15, M ); FOR( i = 0; i < M; i++ ) { st->mem_AR[i] = fixedToFloat( L_mult( st->mem_AR_fx[i], 100 ), 9 ); @@ -670,9 +557,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( Q_cldfbSynHB_cldfb_state = Q_factor_arrL( st->cldfbSynHB->cldfb_state, st->cldfbSynHB->cldfb_state_length ) - 1; fixedToFloat_arrL( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->cldfb_state, Q_cldfbSynHB_cldfb_state, st->cldfbSynHB->cldfb_state_length ); } - Word16 scale_fac = norm_s( st->old_Aq_12_8_fx[0] ) - 2; - Scale_sig( st->old_Aq_12_8_fx, M + 1, scale_fac ); - fixedToFloat_arr( st->old_Aq_12_8_fx, st->old_Aq_12_8, Q_old_Aq_12_8, M + 1 ); + IF( st->hBPF ) { Q_pst_old_syn = Q_syn; @@ -684,19 +569,13 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( Q_lsf_cng = Q_factor( 6400 ); st->past_gpit_float = fixedToFloat( st->past_gpit, 0 ); st->past_gcode_float = fixedToFloat( st->past_gcode, 0 ); - //fixedToFloat_arr( st->lspold_cng, st->lspold_cng_float, 15, M ); fixedToFloat_arr( st->Aq_cng, st->Aq_cng_float, 2, M ); - //fixedToFloat_arr( st->lsp_q_cng, st->lsp_q_cng_float, 15, M ); - //fixedToFloat_arr( st->old_lsp_q_cng, st->old_lsp_q_cng_float, 15, M ); - fixedToFloat_arr( st->mem_syn_unv_back, st->mem_syn_unv_back_float, 0, M ); - //fixedToFloat_arr( st->mem_Aq, st->mem_Aq_float, 0, NB_SUBFR16k * ( M + 1 ) ); + if ( st->last_gain_syn_deemph == 16384 ) { st->last_gain_syn_deemph_float = 1; } st->last_concealed_gain_syn_deemph_float = fixedToFloat( st->last_concealed_gain_syn_deemph, 14 ); - st->lp_ener_bfi = fixedToFloat( st->lp_ener_FER_fx, 8 ); - st->old_enr_LP_float = fixedToFloat( st->old_enr_LP, Q_old_enr_LP ); st->enr_old = fixedToFloat( st->enr_old_fx, 0 ); st->lp_gainc = fixedToFloat( st->lp_gainc_fx, 0 ); st->lp_gainp = fixedToFloat( st->lp_gainp_fx, 0 ); @@ -711,7 +590,6 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( { st->dispMem[i] = 0; } - st->voice_fac_float = st->voice_fac; /* purely unvoiced */ IF( st->hTcxLtpDec != NULL ) { Q_tcxltp_mem_in = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_in_float, TCXLTP_MAX_DELAY ); @@ -732,7 +610,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( { FOR( i = 0; i < L_FRAME_MAX; i++ ) { - st->hPlcInfo->data_reci2[i] = fixedToFloat( st->hPlcInfo->data_reci2_fx[i], 0 ); + //st->hPlcInfo->data_reci2[i] = fixedToFloat( st->hPlcInfo->data_reci2_fx[i], 0 ); } } st->old_fpitchFB_float = fixedToFloat( st->old_fpitchFB, 16 ); @@ -784,10 +662,9 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( Q_pst_old_syn = 0, delay_comp = 0, Q_loBuffer = 0; - Word16 Q_old_enr_LP = 3; Word16 Q_tcxltp_mem_in = 0, Q_tcxltp_mem_out = 0, Q_tcxltp_gain_post_prev = 0; TD_BWE_DEC_HANDLE hBWE_TD = st->hBWE_TD; - Word16 Q_state_lsyn_filt_shb = 0, Q_state_lsyn_filt_dwn_shb = 0, Q_mem_resamp_HB = 0, Q_syn_overlap = 0, Q_tbe_demph = 0, Q_tbe_premph = 0, Q_int_3_over_2_tbemem_dec = 0, Q_mem_resamp_HB_32k = 0, Q_prev_fb_ener_adjust = 0, Q_fb_state_lpc_syn = 0, Q_fb_tbe_demph = 0, + Word16 Q_state_lsyn_filt_shb = 0, Q_state_lsyn_filt_dwn_shb = 0, Q_mem_resamp_HB = 0, Q_syn_overlap = 0, Q_int_3_over_2_tbemem_dec = 0, Q_mem_resamp_HB_32k = 0, Q_prev_fb_ener_adjust = 0, Q_fb_state_lpc_syn = 0, Q_genSHBsynth_Hilbert_Mem = 0, Q_genSHBsynth_state_lsyn_filt_shb_local = 0; if ( tofix ) @@ -813,7 +690,6 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( st->preemph_fac = (Word16) floatToFixed( st->preemph_fac_float, 15 ); Q_syn = 0; floatToFixed_arr( st->syn_float, st->syn, Q_syn, M + 1 ); - floatToFixed_arr( st->lsp_old, st->lsp_old_fx, 15, M ); FOR( i = 0; i < M; i++ ) { st->mem_MA_fx[i] = (Word16) floatToFixed( (float) ( st->mem_MA[i] * 2.56 ), 0 ); @@ -821,35 +697,11 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( } IF( st->hTcxCfg ) { - st->hTcxCfg->preemph_fac = (Word16) floatToFixed( st->hTcxCfg->preemph_fac_flt, 15 ); - st->hTcxCfg->sq_rounding = (Word16) floatToFixed( st->hTcxCfg->sq_rounding_flt, 15 ); - st->hTcxCfg->bandwidth = (Word16) floatToFixed( st->hTcxCfg->bandwidth_flt, 15 ); - st->hTcxCfg->na_scale = (Word16) floatToFixed( st->hTcxCfg->na_scale_flt, 15 ); - Word16 n = st->L_frame; Word16 n0 = shr( imult1616( n, 9 ), 5 ); Word16 n1 = shr( imult1616( n, 23 ), 5 ); /* left slope length */ Word16 n2 = shr( imult1616( n, 14 ), 5 ); /* right slope length */ - FOR( i = 0; i < n0; i++ ) - { - st->hTcxCfg->tcx_aldo_window_1[i] = (Word16) floatToFixed( st->hTcxCfg->tcx_aldo_window_1_flt[i], 15 ); - } - FOR( i = n0; i < n / 2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_1_trunc[i - n0].v.im = (Word16) floatToFixed( st->hTcxCfg->tcx_aldo_window_1_flt[i], 15 ); - } - FOR( i = 0; i < n1 - n / 2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_1_trunc[n1 - n / 2 - 1 - i].v.re = (Word16) floatToFixed( st->hTcxCfg->tcx_aldo_window_1_flt[n / 2 + i], 15 ); - } - FOR( i = 0; i < n2 / 2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_2[i].v.im = (Word16) floatToFixed( st->hTcxCfg->tcx_aldo_window_2_flt[i], 15 ); - } - FOR( i = n2 / 2; i < n2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_2[n2 - i - 1].v.re = (Word16) floatToFixed( st->hTcxCfg->tcx_aldo_window_2_flt[i], 15 ); - } + n = NS2SA_fx2( st->output_Fs, FRAME_SIZE_NS ); n0 = shr( imult1616( n, 9 ), 5 ); n1 = shr( imult1616( n, 23 ), 5 ); /* left slope length */ @@ -938,7 +790,6 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( Q_cldfbSynHB_cldfb_state = Q_factor_arrL( st->cldfbSynHB->cldfb_state, st->cldfbSynHB->cldfb_state_length ) - 1; floatToFixed_arrL( st->cldfbSynHB->cldfb_state, st->cldfbSynHB->cldfb_state_fx, Q_cldfbSynHB_cldfb_state, st->cldfbSynHB->cldfb_state_length ); } - floatToFixed_arr( st->old_Aq_12_8, st->old_Aq_12_8_fx, Q12, M + 1 ); IF( st->hBPF ) { Q_pst_old_syn = Q_syn; @@ -947,7 +798,6 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( } st->last_concealed_gain_syn_deemph = (Word16) floatToFixed( st->last_concealed_gain_syn_deemph_float, 14 ); - st->old_enr_LP = (Word16) floatToFixed( st->old_enr_LP_float, Q_old_enr_LP ); st->enr_old_fx = (Word16) floatToFixed( st->enr_old, 0 ); floatToFixed_arr( st->previoussynth, st->previoussynth_fx, 0, 960 ); IF( st->hTcxLtpDec ) @@ -961,7 +811,6 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( } - // st->last_gain_syn_deemph = floatToFixed(st->last_gain_syn_deemph_float, 14); st->last_gain_syn_deemph = 0; IF( hBWE_TD ) { @@ -971,21 +820,14 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( floatToFixed_arr( hBWE_TD->state_lsyn_filt_dwn_shb, hBWE_TD->state_lsyn_filt_dwn_shb_fx, Q_state_lsyn_filt_dwn_shb, 6 ); Q_mem_resamp_HB = Q_factor_arr( hBWE_TD->mem_resamp_HB, 13 ); floatToFixed_arr( hBWE_TD->mem_resamp_HB, hBWE_TD->mem_resamp_HB_fx, Q_mem_resamp_HB, 13 ); - hBWE_TD->prev_pow_exc16kWhtnd_fx = (Word16) floatToFixed( hBWE_TD->prev_pow_exc16kWhtnd, 15 ); Q_syn_overlap = Q_factor_arr( hBWE_TD->syn_overlap, 20 ); floatToFixed_arr( hBWE_TD->syn_overlap, hBWE_TD->syn_overlap_fx, Q_syn_overlap, 20 ); - Q_tbe_demph = Q_factor( (Word16) hBWE_TD->tbe_demph ); - Q_tbe_premph = Q_factor( (Word16) hBWE_TD->tbe_premph ); Q_int_3_over_2_tbemem_dec = Q_factor_arr( hBWE_TD->int_3_over_2_tbemem_dec, 15 ); Q_mem_resamp_HB_32k = Q_factor_arr( hBWE_TD->mem_resamp_HB_32k, 7 ); Q_prev_fb_ener_adjust = Q_factor( (Word16) st->hBWE_FD->prev_fb_ener_adjust ); Q_fb_state_lpc_syn = Q_factor_arr( hBWE_TD->fb_state_lpc_syn, 10 ); st->prev_fb_ener_adjust_fx = (Word16) floatToFixed( st->hBWE_FD->prev_fb_ener_adjust, Q_prev_fb_ener_adjust ); floatToFixed_arr( hBWE_TD->fb_state_lpc_syn, hBWE_TD->fb_state_lpc_syn_fx, Q_fb_state_lpc_syn, 10 ); - Q_fb_tbe_demph = Q_factor( (Word16) hBWE_TD->fb_tbe_demph ); - hBWE_TD->fb_tbe_demph_fx = (Word16) floatToFixed( hBWE_TD->fb_tbe_demph, Q_fb_tbe_demph ); - hBWE_TD->tbe_demph_fx = (Word16) floatToFixed( hBWE_TD->tbe_demph, Q_tbe_demph ); - hBWE_TD->tbe_premph_fx = (Word16) floatToFixed( hBWE_TD->tbe_premph, Q_tbe_premph ); floatToFixed_arr( hBWE_TD->int_3_over_2_tbemem_dec, hBWE_TD->int_3_over_2_tbemem_dec_fx, Q_int_3_over_2_tbemem_dec, INTERP_3_2_MEM_LEN ); floatToFixed_arr( hBWE_TD->mem_resamp_HB_32k, hBWE_TD->mem_resamp_HB_32k_fx, Q_mem_resamp_HB_32k, 7 ); Q_genSHBsynth_Hilbert_Mem = Q_factor_arrL( hBWE_TD->genSHBsynth_Hilbert_Mem, 21 ); @@ -1049,34 +891,23 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( Q_state_lsyn_filt_dwn_shb = Q_factor_arr( hBWE_TD->state_lsyn_filt_dwn_shb, 6 ); Q_mem_resamp_HB = Q_factor_arr( hBWE_TD->mem_resamp_HB, 13 ); Q_syn_overlap = Q_factor_arr( hBWE_TD->syn_overlap, 20 ); - Q_tbe_demph = Q_factor( (Word16) hBWE_TD->tbe_demph ); - Q_tbe_premph = Q_factor( (Word16) hBWE_TD->tbe_premph ); Q_int_3_over_2_tbemem_dec = Q_factor_arr( hBWE_TD->int_3_over_2_tbemem_dec, 15 ); Q_mem_resamp_HB_32k = Q_factor_arr( hBWE_TD->mem_resamp_HB_32k, 7 ); Q_prev_fb_ener_adjust = Q_factor( (Word16) st->hBWE_FD->prev_fb_ener_adjust ); Q_fb_state_lpc_syn = Q_factor_arr( hBWE_TD->fb_state_lpc_syn, 10 ); - Q_fb_tbe_demph = Q_factor( (Word16) hBWE_TD->fb_tbe_demph ); Q_genSHBsynth_Hilbert_Mem = Q_factor_arrL( hBWE_TD->genSHBsynth_Hilbert_Mem, 21 ); Q_genSHBsynth_state_lsyn_filt_shb_local = Q_factor_arr( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local, 6 ); st->hBWE_TD->prev_tilt_para = 0.0f; - fixedToFloat_arr( st->hBWE_TD->cur_sub_Aq_fx, st->hBWE_TD->cur_sub_Aq, 15, M + 1 ); fixedToFloat_arr( hBWE_TD->state_lsyn_filt_shb_fx, hBWE_TD->state_lsyn_filt_shb, Q_state_lsyn_filt_shb, 6 ); fixedToFloat_arr( hBWE_TD->state_lsyn_filt_dwn_shb_fx, hBWE_TD->state_lsyn_filt_dwn_shb, Q_state_lsyn_filt_dwn_shb, 6 ); fixedToFloat_arr( hBWE_TD->mem_resamp_HB_fx, hBWE_TD->mem_resamp_HB, Q_mem_resamp_HB, 13 ); fixedToFloat_arr( hBWE_TD->syn_overlap_fx, hBWE_TD->syn_overlap, Q_syn_overlap, 20 ); fixedToFloat_arr( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local, Q_genSHBsynth_state_lsyn_filt_shb_local, HILBERT_MEM_SIZE ); fixedToFloat_arrL( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_Hilbert_Mem, Q_genSHBsynth_Hilbert_Mem, HILBERT_MEM_SIZE ); - hBWE_TD->tbe_demph = fixedToFloat( hBWE_TD->tbe_demph_fx, Q_tbe_demph ); - hBWE_TD->tbe_premph = fixedToFloat( hBWE_TD->tbe_premph_fx, Q_tbe_premph ); fixedToFloat_arr( hBWE_TD->int_3_over_2_tbemem_dec_fx, hBWE_TD->int_3_over_2_tbemem_dec, Q_int_3_over_2_tbemem_dec, 15 ); fixedToFloat_arr( hBWE_TD->mem_resamp_HB_32k_fx, hBWE_TD->mem_resamp_HB_32k, Q_mem_resamp_HB_32k, 7 ); // bool des = ( st->bwidth == WB && st->last_extl != WB_TBE ) || ( st->bwidth == SWB && st->last_extl != SWB_TBE ) || ( st->bwidth == FB && st->last_extl != FB_TBE ); - if ( ( st->bwidth == SWB || st->bwidth == FB ) && st->igf && ( st->bwidth == SWB || st->bwidth == FB ) ) - { - hBWE_TD->prev_pow_exc16kWhtnd = (float) hBWE_TD->prev_pow_exc16kWhtnd_fx / 32767; - } st->hBWE_FD->prev_fb_ener_adjust = fixedToFloat( st->prev_fb_ener_adjust_fx, Q_prev_fb_ener_adjust ); - hBWE_TD->fb_tbe_demph = fixedToFloat( hBWE_TD->fb_tbe_demph_fx, Q_fb_tbe_demph ); } st->preemph_fac_float = fixedToFloat( st->preemph_fac, 15 ); IF( st->hTECDec != NULL ) @@ -1090,45 +921,6 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( } IF( st->hTcxCfg ) { - st->hTcxCfg->preemph_fac_flt = fixedToFloat( st->hTcxCfg->preemph_fac, 15 ); - st->hTcxCfg->sq_rounding_flt = fixedToFloat( st->hTcxCfg->sq_rounding, 15 ); - st->hTcxCfg->bandwidth_flt = fixedToFloat( st->hTcxCfg->bandwidth, 15 ); - st->hTcxCfg->na_scale_flt = fixedToFloat( st->hTcxCfg->na_scale, 15 ); - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_length / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_window_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_window[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_window_flt[st->hTcxCfg->tcx_mdct_window_length - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_window[i].v.re, 15 ); - } - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_lengthFB / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_windowFB_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_windowFB[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_windowFB_flt[st->hTcxCfg->tcx_mdct_window_lengthFB - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_windowFB[i].v.re, 15 ); - } - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_trans_length / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_window_trans_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_trans[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_window_trans_flt[st->hTcxCfg->tcx_mdct_window_trans_length - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_trans[i].v.re, 15 ); - } - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_trans_lengthFB / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_window_transFB_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_transFB[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_window_transFB_flt[st->hTcxCfg->tcx_mdct_window_trans_lengthFB - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_transFB[i].v.re, 15 ); - } - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_half_length / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_window_half_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_half[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_window_half_flt[st->hTcxCfg->tcx_mdct_window_half_length - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_half[i].v.re, 15 ); - } - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_half_lengthFB / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_window_halfFB_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_halfFB[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_window_halfFB_flt[st->hTcxCfg->tcx_mdct_window_half_lengthFB - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_halfFB[i].v.re, 15 ); - } - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_min_length / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_window_minimum_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_minimum[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_window_minimum_flt[st->hTcxCfg->tcx_mdct_window_min_length - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_minimum[i].v.re, 15 ); - } FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_min_lengthFB / 2; i++ ) { st->hTcxCfg->tcx_mdct_window_minimumFB_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.im, 15 ); @@ -1138,26 +930,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( Word16 n0 = shr( imult1616( n, 9 ), 5 ); Word16 n1 = shr( imult1616( n, 23 ), 5 ); /* left slope length */ Word16 n2 = shr( imult1616( n, 14 ), 5 ); /* right slope length */ - FOR( i = 0; i < n0; i++ ) - { - st->hTcxCfg->tcx_aldo_window_1_flt[i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_1[i], 15 ); - } - FOR( i = n0; i < n / 2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_1_flt[i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_1_trunc[i - n0].v.im, 15 ); - } - FOR( i = 0; i < n1 - n / 2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_1_flt[n / 2 + i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_1_trunc[n1 - n / 2 - 1 - i].v.re, 15 ); - } - FOR( i = 0; i < n2 / 2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_2_flt[i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_2[i].v.im, 15 ); - } - FOR( i = n2 / 2; i < n2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_2_flt[i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_2[n2 - i - 1].v.re, 15 ); - } + n = NS2SA_fx2( st->output_Fs, FRAME_SIZE_NS ); n0 = shr( imult1616( n, 9 ), 5 ); n1 = shr( imult1616( n, 23 ), 5 ); /* left slope length */ @@ -1221,7 +994,6 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( st->hTcxDec->cummulative_damping_tcx_float = fixedToFloat( st->hTcxDec->cummulative_damping_tcx, 15 ); } fixedToFloat_arr( st->syn, st->syn_float, Q_syn, M + 1 ); - fixedToFloat_arr( st->lsp_old_fx, st->lsp_old, 15, M ); FOR( i = 0; i < M; i++ ) { st->mem_AR[i] = fixedToFloat( L_mult( st->mem_AR_fx[i], 100 ), 9 ); @@ -1252,9 +1024,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( Q_cldfbSynHB_cldfb_state = Q_factor_arrL( st->cldfbSynHB->cldfb_state, st->cldfbSynHB->cldfb_state_length ) - 1; fixedToFloat_arrL( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->cldfb_state, Q_cldfbSynHB_cldfb_state, st->cldfbSynHB->cldfb_state_length ); } - Word16 scale_fac = 15 - norm_s( st->old_Aq_12_8_fx[0] - 1 ); - // Scale_sig( st->old_Aq_12_8_fx, M + 1, scale_fac ); - fixedToFloat_arr( st->old_Aq_12_8_fx, st->old_Aq_12_8, scale_fac, M + 1 ); + IF( st->hBPF ) { Q_pst_old_syn = Q_syn; @@ -1263,22 +1033,15 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( st->hBPF->pst_mem_deemp_err = 0; } - // Q_lsf_cng = Q_factor( 6400 ); st->past_gpit_float = fixedToFloat( st->past_gpit, 0 ); st->past_gcode_float = fixedToFloat( st->past_gcode, 0 ); - //fixedToFloat_arr( st->lspold_cng, st->lspold_cng_float, 15, M ); fixedToFloat_arr( st->Aq_cng, st->Aq_cng_float, 2, M ); - //fixedToFloat_arr( st->lsp_q_cng, st->lsp_q_cng_float, 15, M ); - //fixedToFloat_arr( st->old_lsp_q_cng, st->old_lsp_q_cng_float, 15, M ); - fixedToFloat_arr( st->mem_syn_unv_back, st->mem_syn_unv_back_float, 0, M ); - //fixedToFloat_arr( st->mem_Aq, st->mem_Aq_float, 0, NB_SUBFR16k * ( M + 1 ) ); + if ( st->last_gain_syn_deemph == 16384 ) { st->last_gain_syn_deemph_float = 1; } st->last_concealed_gain_syn_deemph_float = fixedToFloat( st->last_concealed_gain_syn_deemph, 14 ); - st->lp_ener_bfi = fixedToFloat( st->lp_ener_FER_fx, 8 ); - st->old_enr_LP_float = fixedToFloat( st->old_enr_LP, Q_old_enr_LP ); st->enr_old = fixedToFloat( st->enr_old_fx, 0 ); st->lp_gainc = fixedToFloat( st->lp_gainc_fx, 3 ); st->lp_gainp = fixedToFloat( st->lp_gainp_fx, 14 ); @@ -1293,7 +1056,6 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( { st->dispMem[i] = 0; } - st->voice_fac_float = st->voice_fac; /* purely unvoiced */ IF( st->hTcxLtpDec != NULL ) { Q_tcxltp_mem_in = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_in_float, TCXLTP_MAX_DELAY ); @@ -1314,7 +1076,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( { FOR( i = 0; i < L_FRAME_MAX; i++ ) { - st->hPlcInfo->data_reci2[i] = fixedToFloat( st->hPlcInfo->data_reci2_fx[i], 0 ); + //st->hPlcInfo->data_reci2[i] = fixedToFloat( st->hPlcInfo->data_reci2_fx[i], 0 ); } } st->old_fpitchFB_float = fixedToFloat( st->old_fpitchFB, 16 ); @@ -1367,8 +1129,6 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( st->inv_gamma = GAMMA16k_INV; } - //floatToFixed_arr( st->lspold_uw_float, st->lspold_uw, Q15, M ); - for ( int p = 0; p < 2 * NB_SUBFR16k + 2; p++ ) { st->old_pitch_buf_fx[p] = (Word32) ( st->old_pitch_buf[p] * ONE_IN_Q16 ); @@ -1382,9 +1142,6 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( st->old_fpitch = (Word32) ( st->old_fpitch_float * ONE_IN_Q16 ); st->lp_gainp_fx = (Word16) floatToFixed( st->lp_gainp, Q14 ); - //floatToFixed_arr( st->old_lsp_q_cng_float, st->old_lsp_q_cng, Q15, M ); - //floatToFixed_arr( st->lsp_q_cng_float, st->lsp_q_cng, Q15, M ); - st->hTcxDec->gainHelper = (Word16) floatToFixed( st->hTcxDec->gainHelper_float, Q14 ); st->hTcxDec->gainHelper_e = 1; st->hTcxDec->stepCompensate = (Word16) floatToFixed( st->hTcxDec->stepCompensate_float, Q14 ); @@ -1394,7 +1151,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( st->old_fpitch = float_to_fix( st->old_fpitch_float, Q16 ); if ( st->hPlcInfo ) { - st->hPlcInfo->step_concealgain_fx = (Word16) floatToFixed( st->hPlcInfo->step_concealgain, Q15 ); + //st->hPlcInfo->step_concealgain_fx = (Word16) floatToFixed( st->hPlcInfo->step_concealgain, Q15 ); } st->hTcxDec->conceal_eof_gain = (Word16) floatToFixed( st->hTcxDec->conceal_eof_gain_float, Q14 ); st->hTcxDec->conCngLevelBackgroundTrace = (Word16) floatToFixed( st->hTcxDec->CngLevelBackgroundTrace_bfi, Q15 - st->hTcxDec->conCngLevelBackgroundTrace_e ); @@ -1405,8 +1162,8 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( } if ( st->hPlcInfo ) { - st->hPlcInfo->recovery_gain = (Word16) floatToFixed( st->hPlcInfo->recovery_gain_float, Q14 ); - st->hPlcInfo->step_concealgain_fx = (Word16) floatToFixed( st->hPlcInfo->step_concealgain, Q15 ); + //st->hPlcInfo->recovery_gain = (Word16) floatToFixed( st->hPlcInfo->recovery_gain_float, Q14 ); + //st->hPlcInfo->step_concealgain_fx = (Word16) floatToFixed( st->hPlcInfo->step_concealgain, Q15 ); } floatToFixed_arr( st->hTcxDec->NoiseLevelMemory_bfi, st->hTcxDec->conNoiseLevelMemory, Q15, PLC_MIN_STAT_BUFF_SIZE ); st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; @@ -1414,7 +1171,6 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( floatToFixed_arrL( st->old_pitch_buf, st->old_pitch_buf_fx, Q16, 2 * NB_SUBFR16k + 2 ); floatToFixed_arr( st->syn_float, st->syn, 0, M + 1 ); - st->lp_ener_bfi_fx = (Word16) floatToFixed( st->lp_ener_bfi, Q8 ); st->old_fpitch = floatToFixed( st->old_fpitch_float, Q16 ); st->preemph_fac = (Word16) floatToFixed( st->preemph_fac_float, Q15 ); if ( hTcxLtpDec->tcxltp ) @@ -1423,15 +1179,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( } floatToFixed_arr( st->hHQ_core->old_out + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), 0, NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); - IF( st->hTdCngDec != NULL ) - { - floatToFixed_arr( st->hTdCngDec->ho_lsp_circ, st->hTdCngDec->ho_lsp_circ_fx, Q15, HO_HIST_SIZE * M ); - floatToFixed_arrL( st->hTdCngDec->ho_env_circ, st->hTdCngDec->ho_env_circ_fx, Q6, HO_HIST_SIZE * NUM_ENV_CNG ); - floatToFixed_arrL( st->hTdCngDec->ho_ener_circ, st->hTdCngDec->ho_ener_circ_fx, Q6, HO_HIST_SIZE ); - } - floatToFixed_arr( st->lsp_old, st->lsp_old_fx, Q15, M ); - floatToFixed_arr( st->old_Aq_12_8, st->old_Aq_12_8_fx, Q12, M + 1 ); if ( !st->tcxonly ) { floatToFixed_arr( st->p_bpf_noise_buf_float, st->p_bpf_noise_buf, 0, L_FRAME_16k ); @@ -1487,14 +1235,9 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( } st->gamma = float_to_fix16( st->gamma_float, Q15 ); - // st->preemph_fac = float_to_fix16( st->preemph_fac_float, Q15 ); st->hTcxDec->cummulative_damping_tcx = float_to_fix16( st->hTcxDec->cummulative_damping_tcx_float, Q15 ); // st->Mode2_lp_gainp = float_to_fix(st->lp_gainp, Q16); st->Mode2_lp_gainp = float_to_fix( st->lp_gainp, Q29 ); - st->hTcxCfg->na_scale = float_to_fix16( st->hTcxCfg->na_scale_flt, Q15 ); - st->hTcxCfg->sq_rounding = float_to_fix16( st->hTcxCfg->sq_rounding_flt, Q15 ); - // st->inv_gamma = FL2WORD16_SCALE(1 / st->gamma_float, 1); - st->hTcxCfg->preemph_fac = FL2WORD16( st->hTcxCfg->preemph_fac_flt ); f2me_16( st->last_gain_syn_deemph_float, &st->last_gain_syn_deemph, &st->last_gain_syn_deemph_e ); f2me_16( st->last_concealed_gain_syn_deemph_float, &st->last_concealed_gain_syn_deemph, &st->last_concealed_gain_syn_deemph_e ); //st->last_concealed_gain_syn_deemph = float_to_fix16( st->last_concealed_gain_syn_deemph_float, Q14 ); @@ -1519,7 +1262,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( IF(st->enablePlcWaveadjust) { - f2me_buf(st->hPlcInfo->data_reci2, st->hPlcInfo->data_reci2_fx, &st->hPlcInfo->data_reci2_scale, st->hPlcInfo->L_frameTCX); + //f2me_buf(st->hPlcInfo->data_reci2, st->hPlcInfo->data_reci2_fx, &st->hPlcInfo->data_reci2_scale, st->hPlcInfo->L_frameTCX); } // u8bit to 16bit @@ -1548,10 +1291,6 @@ void fixed_to_float_stereo_tcx_core_dec( if ( EQ_16( st->core, ACELP_CORE ) ) { - for ( int p = 0; p < M + 1; p++ ) - { - st->old_Aq_12_8[p] = (float) st->old_Aq_12_8_fx[p] / ( 1u << ( 15 - ( norm_s( st->old_Aq_12_8_fx[0] - 1 ) ) ) ); - } for ( int p = 0; p < M + 1; p++ ) { st->syn_float[p] = (float) st->syn[p] / (float) pow( 2, st->Q_syn ); @@ -1581,7 +1320,6 @@ void fixed_to_float_stereo_tcx_core_dec( st->lp_gainc = (float) st->Mode2_lp_gainc / ONE_IN_Q16; st->lp_gainp = (float) st->Mode2_lp_gainp / ONE_IN_Q29; st->cummulative_damping_float = (float) st->cummulative_damping / MAX_16; - st->old_enr_LP_float = (float) st->old_enr_LP / ONE_IN_Q3; if ( !st->tcxonly ) { @@ -1593,17 +1331,6 @@ void fixed_to_float_stereo_tcx_core_dec( } } - if ( st->rate_switching_reset ) - { - q_Aq = 15 - ( norm_s( st->old_Aq_12_8_fx[0] - 1 ) ); - fixedToFloat_arr( st->old_Aq_12_8_fx, st->old_Aq_12_8, q_Aq, M + 1 ); - } - - for ( int p = 0; p < M; p++ ) - { - st->lsp_old[p] = (float) st->lsp_old_fx[p] / ONE_IN_Q15; - } - if ( st->lpcQuantization ) { st->safety_net = st->safety_net; @@ -1630,29 +1357,17 @@ void fixed_to_float_stereo_tcx_core_dec( st->hTcxDec->LastFrameLevel_bfi = fixedToFloat( st->hTcxDec->conLastFrameLevel, 15 - st->hTcxDec->conLastFrameLevel_e ); if ( st->hPlcInfo ) { - st->hPlcInfo->recovery_gain_float = fixedToFloat( st->hPlcInfo->recovery_gain, Q14 ); - st->hPlcInfo->step_concealgain = fixedToFloat( st->hPlcInfo->step_concealgain_fx, Q15 ); + //st->hPlcInfo->recovery_gain_float = fixedToFloat( st->hPlcInfo->recovery_gain, Q14 ); + //st->hPlcInfo->step_concealgain = fixedToFloat( st->hPlcInfo->step_concealgain_fx, Q15 ); } - st->lp_ener_bfi = fixedToFloat( st->lp_ener_bfi_fx, Q8 ); - st->enr_old = (float) st->enr_old_fx; - st->old_enr_LP_float = (float) ( st->old_enr_LP / pow( 2, Q3 ) ); - fixedToFloat_arr( hTcxDec->old_synth, hTcxDec->old_synth_float, 0, hTcxDec->old_synth_len ); fixedToFloat_arr( hTcxDec->synth_history_fx, hTcxDec->synth_history, 0, NS2SA_fx2( st->output_Fs, PH_ECU_MEM_NS ) ); st->hTcxDec->q_synth_history_fx = 0; fixedToFloat_arr( hTcxDec->old_synthFB_fx, hTcxDec->old_synthFB, 0, NS2SA_fx2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) + hTcxDec->old_synth_lenFB ); - fixedToFloat_arr( st->lsp_old_fx, st->lsp_old, Q15, M ); - - IF( !st->tcxonly && st->hTdCngDec != NULL ) - { - fixedToFloat_arr( st->hTdCngDec->ho_lsp_circ_fx, st->hTdCngDec->ho_lsp_circ, Q15, HO_HIST_SIZE * M ); - fixedToFloat_arrL( st->hTdCngDec->ho_env_circ_fx, st->hTdCngDec->ho_env_circ, Q6, HO_HIST_SIZE * NUM_ENV_CNG ); - fixedToFloat_arrL( st->hTdCngDec->ho_ener_circ_fx, st->hTdCngDec->ho_ener_circ, Q6, HO_HIST_SIZE ); - } if ( !st->tcxonly ) { diff --git a/lib_com/hp50.c b/lib_com/hp50.c index 0f950af36..cfedfc045 100644 --- a/lib_com/hp50.c +++ b/lib_com/hp50.c @@ -489,8 +489,8 @@ void hp20_fix32( b2_fx = 535877975l /* 0.998150511190452 Q29*/; } - Qprev_y1 = mem_fx[4]; - Qprev_y2 = mem_fx[5]; + Qprev_y1 = extract_l(mem_fx[4]); + Qprev_y2 = extract_l(mem_fx[5]); y1_fx64 = mem_fx[0]; y2_fx64 = mem_fx[1]; x0_fx64 = mem_fx[2]; @@ -547,7 +547,7 @@ void hp20_fix32( y0_fx64 = (y0_fx64 >> (min(Qy1, Qy2) - Qmin)) + (R3 >> (Qx0 - Qmin)) + (R4 >> (Qx1 - Qmin)) + (R5 >> (Qx2 - Qmin)); y0_fx64 = y0_fx64 >> 29; - signal_fx[i] = W_shr(y0_fx64, Qmin); + signal_fx[i] = W_extract_l(W_shr(y0_fx64, Qmin)); y2_fx64 = y1_fx64; y1_fx64 = y0_fx64; @@ -567,10 +567,10 @@ void hp20_fix32( Qprev_y2 -= (32 - Qy2); } - mem_fx[0] = y1_fx64; - mem_fx[1] = y2_fx64; - mem_fx[2] = x0_fx64; - mem_fx[3] = x1_fx64; + mem_fx[0] = W_extract_l(y1_fx64); + mem_fx[1] = W_extract_l(y2_fx64); + mem_fx[2] = W_extract_l(x0_fx64); + mem_fx[3] = W_extract_l(x1_fx64); mem_fx[4] = Qprev_y1; mem_fx[5] = Qprev_y2; diff --git a/lib_com/ivas_entropy_coder_common.c b/lib_com/ivas_entropy_coder_common.c index 4ebb05dfa..4d7b3c0d8 100644 --- a/lib_com/ivas_entropy_coder_common.c +++ b/lib_com/ivas_entropy_coder_common.c @@ -37,6 +37,9 @@ #include "math.h" #include "prot.h" #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif /*-----------------------------------------------------------------------------------------* diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 49d0b5f9c..557f29054 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -373,6 +373,13 @@ ivas_error mct_dec_reconfigure( const uint16_t b_nchan_change /* i : flag indicating different channel count */ ); +#ifdef IVAS_FLOAT_FIXED +ivas_error mct_dec_reconfigure_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const UWord16 b_nchan_change /* i : flag indicating different channel count */ +); +#endif + #ifndef IVAS_FLOAT_FIXED void destroy_sce_dec( SCE_DEC_HANDLE hSCE /* i/o: SCE decoder structure */ @@ -535,8 +542,7 @@ void decod_gen_2sbfr_ivas_fx( Word16 *bwe_exc, /* o : excitation for SWB TBE */ Word16 *gain_buf, /* o : floating pitch gain for each subframe */ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[], /* i : pitch values for primary channel */ - Word16 Q_exc + const Word16 tdm_Pri_pitch_buf[] /* i : pitch values for primary channel */ ); #endif @@ -2425,8 +2431,7 @@ void tdm_low_rate_dec_fx( Word16 *exc, /* i/o: adapt. excitation exc */ Word16 *exc2, /* i/o: adapt. excitation/total exc */ Word16 *bwe_exc, /* o : excitation for SWB TBE */ - const Word16 *lsf_new, /* i : ISFs at the end of the frame */ - Word16 Q_exc + const Word16 *lsf_new /* i : ISFs at the end of the frame */ ); #endif @@ -4731,6 +4736,13 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( const float *proto_matrix /* i : the prototype (upmix) matrix (only used if mode == 1) */ ); +#ifdef IVAS_FLOAT_FIXED +void ivas_dirac_dec_output_synthesis_get_interpolator_fx( + DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ + const UWord16 interp_length /* i : interpolator length */ +); +#endif + void ivas_dirac_dec_output_synthesis_get_interpolator( DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ const uint16_t interp_length /* i : interpolator length */ @@ -5695,14 +5707,18 @@ void pca_dec_s3( const int32_t index, float *q ); + #ifdef IVAS_FLOAT_FIXED void pca_dec_s3_fx( const Word32 index, Word16 *q); #endif + +#ifndef IVAS_FLOAT_FIXED int16_t ivas_get_bits_to_encode( int32_t val ); +#endif void ivas_huffman_encode( ivas_huffman_cfg_t *huff_cfg, diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 543c1ab50..f466200a8 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -545,8 +545,10 @@ void ivas_sba_config_fx( Word16 *element_mode /* o : element mode of the core coder */ ); -Word16 ivas_get_bits_to_encode_fx( - Word32 val); +#ifdef IVAS_FLOAT_FIXED +Word16 ivas_get_bits_to_encode( + Word32 val ); +#endif Word16 ivas_get_spar_table_idx_fx( const Word32 ivas_total_brate, /* i : IVAS total bitrate */ @@ -1973,4 +1975,19 @@ void ivas_mct_side_bits_fx( #endif // IVAS_FLOAT_FIXED +void ivas_spar_update_md_hist_fx( + ivas_spar_md_dec_state_t *hMdDec /* i/o: SPAR MD decoder handle */ +); + +void ivas_spar_smooth_md_dtx_fx( + ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ + const Word16 num_bands_out, /* i : number of output bands */ + const Word16 num_md_sub_frames /* i : number of metadata subframes */ +); + +void ivas_spar_setup_md_smoothing_fx( + ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ + const Word16 num_bands_out, /* i : number of output bands */ + const Word16 num_md_sub_frames /* i : number of metadata subframes */ +); #endif diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index dc967e9fe..61e86b2ad 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -46,6 +46,9 @@ #include "wmc_auto.h" #include "basop_util.h" #include "basop32.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif /*------------------------------------------------------------------------------------------* @@ -1990,10 +1993,10 @@ void ivas_get_spar_md_from_dirac_fx( { for ( int j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { - azi_dirac_fx[i][j] = azi_dirac[i][j] * ( 1 << 22 ); - ele_dirac_fx[i][j] = ele_dirac[i][j] * ( 1 << 22 ); + azi_dirac_fx[i][j] = (Word32)(azi_dirac[i][j] * ( 1 << 22 )); + ele_dirac_fx[i][j] = (Word32)(ele_dirac[i][j] * ( 1 << 22 )); } - diffuseness_fx[i] = diffuseness[i] * ( 1 << 30 ); + diffuseness_fx[i] = (Word32)(diffuseness[i] * ( 1 << 30 )); } int16_t num_ch, band, i, j; @@ -2205,7 +2208,7 @@ void ivas_get_spar_md_from_dirac_fx( temp = temp + response_fx[block][ch]; } //response_avg[ch] /= MAX_PARAM_SPATIAL_SUBFRAMES; - response_avg_fx[ch] = W_shr( temp, 2 ); + response_avg_fx[ch] = W_extract_l(W_shr( temp, 2 )); } /*normalize 1st order*/ @@ -5338,40 +5341,42 @@ void ivas_dirac_dec_get_response_fixed_Q( * Get number of bits required to encode the input value *-----------------------------------------------------------------------------------------*/ -int16_t ivas_get_bits_to_encode( - int32_t val ) +#ifdef IVAS_FLOAT_FIXED +Word16 ivas_get_bits_to_encode( + Word32 val ) { - int16_t bits_req = 0; + Word16 bits_req = 0; + move16(); assert( val >= 0 ); - while ( val ) + WHILE( val ) { bits_req++; - val >>= 1; + val = L_shr( val, 1 ); } return bits_req; } - -#ifdef IVAS_FLOAT_FIXED -Word16 ivas_get_bits_to_encode_fx( - Word32 val ) +#else +int16_t ivas_get_bits_to_encode( + int32_t val ) { - Word16 bits_req = 0; + int16_t bits_req = 0; - assert( GE_32( val, 0 ) ); + assert( val >= 0 ); - WHILE( val ) + while ( val ) { - bits_req = add( bits_req, 1 ); - val = L_shr( val, 1 ); + bits_req++; + val >>= 1; } return bits_req; } #endif + /*-----------------------------------------------------------------------------------------* * Function ivas_spar_set_bitrate_config() * @@ -5531,7 +5536,7 @@ static Word32 ceil32_fx(Word32 var1, Word16 q) IF(GT_32(ans, temp)) return ans; ELSE - return add(ans, 1); + return L_add(ans, 1); } #ifdef IVAS_FLOAT_FIXED void ivas_spar_set_bitrate_config_fx( diff --git a/lib_com/ivas_spar_com_quant_util.c b/lib_com/ivas_spar_com_quant_util.c index 11c90abac..7536018e0 100644 --- a/lib_com/ivas_spar_com_quant_util.c +++ b/lib_com/ivas_spar_com_quant_util.c @@ -108,7 +108,7 @@ void ivas_quantise_real_values_fx( } else if ( q_levels && max_value_fx != min_value_fx) { - Word32 nor_q_level = norm_l(q_levels - 1); + Word16 nor_q_level = norm_l(q_levels - 1); Word32 one_by_q_level = divide3232(L_shl(1, (nor_q_level)), L_shl((q_levels - 1), (nor_q_level))); one_by_q_level = L_shl(one_by_q_level, 16); q_step_fx = Mpy_32_32((max_value_fx - min_value_fx), one_by_q_level); @@ -318,12 +318,12 @@ void ivas_map_prior_coeffs_quant( trial1 = trial1 << 16; trial1 = round_fx(Mpy_32_32(trial1, one_by_q_lvl_PR_fx)); //pSpar_md_prior->band_coeffs_idx_mapped[i].pred_index_re[j] = (int16_t) round( ( qs.PR.q_levels[0] - 1 ) * pSpar_md_prior->band_coeffs_idx[i].pred_index_re[j] * one_by_q_lvl_PR ); - pSpar_md_prior->band_coeffs_idx_mapped[i].pred_index_re[j] = trial1; + pSpar_md_prior->band_coeffs_idx_mapped[i].pred_index_re[j] = extract_l(trial1); Word32 trial2 = (qs.P_r.q_levels[0] - 1) * pSpar_md_prior->band_coeffs_idx[i].decd_index_re[j]; trial2 = trial2 << 16; trial2 = round_fx(Mpy_32_32(trial2, one_by_q_lvl_P_r_fx)); //pSpar_md_prior->band_coeffs_idx_mapped[i].decd_index_re[j] = (int16_t) round( ( qs.P_r.q_levels[0] - 1 ) * pSpar_md_prior->band_coeffs_idx[i].decd_index_re[j] * one_by_q_lvl_P_r ); - pSpar_md_prior->band_coeffs_idx_mapped[i].decd_index_re[j] = trial2; + pSpar_md_prior->band_coeffs_idx_mapped[i].decd_index_re[j] = extract_l(trial2); } for ( j = 0; j < IVAS_SPAR_MAX_C_COEFF; j++ ) { @@ -331,7 +331,7 @@ void ivas_map_prior_coeffs_quant( trial1 = trial1 << 16; trial1 = round_fx(Mpy_32_32(trial1, one_by_q_lvl_C_fx)); //pSpar_md_prior->band_coeffs_idx_mapped[i].drct_index_re[j] = (int16_t) round( ( qs.C.q_levels[0] - 1 ) * pSpar_md_prior->band_coeffs_idx[i].drct_index_re[j] * one_by_q_lvl_C ); - pSpar_md_prior->band_coeffs_idx_mapped[i].drct_index_re[j] = trial1; + pSpar_md_prior->band_coeffs_idx_mapped[i].drct_index_re[j] = extract_l(trial1); } } } diff --git a/lib_com/prot.h b/lib_com/prot.h index 3d00ba7ee..ec3d3bc2c 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -4623,27 +4623,27 @@ void signaling_enc_rf( ); ivas_error acelp_core_dec( - Decoder_State *st, /* i/o: Decoder state structure */ - float output[], /* o : synthesis @internal Fs */ - float synth[], /* o : synthesis */ - float save_hb_synth[], /* o : HB synthesis */ - float bwe_exc_extended[], /* i/o: bandwidth extended excitation */ - float *voice_factors, /* o : voicing factors */ - float old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */ - const int16_t sharpFlag, /* i : formant sharpening flag */ - float pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */ - int16_t *unbits, /* o : number of unused bits */ - int16_t *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ - float tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */ - float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ - const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const int16_t last_element_mode, /* i : last element mode */ - const int32_t last_element_brate, /* i : last element bitrate */ - const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ - const int16_t nchan_out, /* i : number of output channels */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const int16_t read_sid_info /* i : read SID info flag */ + Decoder_State *st, /* i/o: Decoder state structure */ + float output[], /* o : synthesis @internal Fs */ + float synth[], /* o : synthesis */ + float save_hb_synth[], /* o : HB synthesis */ + float bwe_exc_extended[], /* i/o: bandwidth extended excitation */ + float *voice_factors, /* o : voicing factors */ + float old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */ + const int16_t sharpFlag, /* i : formant sharpening flag */ + float pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */ + int16_t *unbits, /* o : number of unused bits */ + int16_t *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ + STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ + const float tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */ + const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ + const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ + const int16_t last_element_mode, /* i : last element mode */ + const int32_t last_element_brate, /* i : last element bitrate */ + const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ + const int16_t nchan_out, /* i : number of output channels */ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ + const int16_t read_sid_info /* i : read SID info flag */ ); #ifdef IVAS_FLOAT_FIXED diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index d9e88c30a..4cdb96a23 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -2615,7 +2615,7 @@ void GenShapedSHBExcitation_ivas_fx( Word32 L_tmp; Word16 vf_tmp; - Word16 tmp, exp, tmp2; + Word16 tmp, exp, tmp2=0; Word16 voiceFacEst[NB_SUBFR16k]; Word16 zero_mem[LPC_SHB_ORDER]; Word32 syn_shb_ener_sf[4]; diff --git a/lib_com/tcx_mdct_window.c b/lib_com/tcx_mdct_window.c index 3351c99b7..5adb0348f 100644 --- a/lib_com/tcx_mdct_window.c +++ b/lib_com/tcx_mdct_window.c @@ -160,7 +160,7 @@ void mdct_window_sine_IVAS_updated( } else { - lerp(window_table, temp, n, buf_in_size); + lerp((Word16 *)window_table, temp, n, buf_in_size); } for (int i = 0; i < n / 2; i++) diff --git a/lib_dec/acelp_core_dec.c b/lib_dec/acelp_core_dec.c index c3160355e..f4de32ffd 100644 --- a/lib_dec/acelp_core_dec.c +++ b/lib_dec/acelp_core_dec.c @@ -68,8 +68,8 @@ ivas_error acelp_core_dec( int16_t *unbits, /* o : number of unused bits */ int16_t *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ - float tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */ - float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ + const float tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */ + const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ const int16_t last_element_mode, /* i : last element mode */ const int32_t last_element_brate, /* i : last element bitrate */ @@ -80,7 +80,7 @@ ivas_error acelp_core_dec( ) { float old_exc[L_EXC_DEC], *exc; /* excitation signal buffer */ - float syn_tmp[L_FRAME16k + L_SUBFR], *syn; /* synthesis signal buffer */ + float syn_tmp[L_FRAME16k + L_SUBFR] = { 0 }, *syn; /* synthesis signal buffer */ int16_t output_frame; /* frame length at output sampling freq. */ float lsf_new[M]; /* LSFs at the end of the frame */ float lsp_new[M]; /* LSPs at the end of the frame */ @@ -90,16 +90,11 @@ ivas_error acelp_core_dec( float mem_tmp[M]; /* temporary synthesis filter memory */ float enr_q; /* E information for FER protection */ float tmp_noise; /* Long term temporary noise energy */ - float Es_pred; /* predicted scaled innov. energy */ float FEC_pitch; /* FEC pitch */ float old_bwe_exc[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */ float *bwe_exc; /* Excitation for SWB TBE */ -#ifdef IVAS_FLOAT_FIXED - Word16 old_bwe_exc_fx[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */ - Word16 *bwe_exc_fx; /* Excitation for SWB TBE */ -#endif - int16_t i, j, int_fs; + int16_t i, int_fs; int16_t tc_subfr; int16_t allow_cn_step; float temp_buf[L_FRAME16k + L_SYN_MEM]; @@ -117,11 +112,6 @@ ivas_error acelp_core_dec( float exc3[L_FRAME16k]; float syn1_tmp[L_FRAME16k + 2], *syn1; 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 */ @@ -132,17 +122,6 @@ ivas_error acelp_core_dec( float *p_tdm_Pri_pitch_buf; int16_t local_element_mode; ivas_error error; -#ifdef IVAS_FLOAT_FIXED - Word16 syn_tmp_fx[L_FRAME16k + L_SUBFR], *syn_fx; - set_zero(Aq, NB_SUBFR16k * (M + 1)); - Word16 Aq_fx[NB_SUBFR16k * (M + 1)]; - set16_fx(Aq_fx, 0, NB_SUBFR16k * (M + 1)); - Word16 tmp_noise_fx; - set_zero(temp_buf, L_FRAME16k + L_SYN_MEM); - Word32 bpf_error_signal_fx[L_FRAME16k]; - Word16 tmp; - set_zero(old_exc2, L_FRAME16k + L_EXC_MEM); -#endif error = IVAS_ERR_OK; @@ -164,7 +143,7 @@ ivas_error acelp_core_dec( { 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 ); /* Only run parameter decoding in SID frames */ if ( st->core_brate == SID_2k40 ) @@ -177,46 +156,11 @@ ivas_error acelp_core_dec( 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]; } -#ifdef IVAS_FLOAT_FIXED - st->hFdCngDec->hFdCngCom->sidNoiseEstExp = 31 - Q4; - for ( int p = 0; p < NPART; p++ ) - { - st->hFdCngDec->hFdCngCom->sidNoiseEstLp[p] = (Word32) ( st->hFdCngDec->hFdCngCom->sidNoiseEstLp_flt[p] * ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) ) ); - st->hFdCngDec->hFdCngCom->sidNoiseEst[p] = (Word32) ( st->hFdCngDec->hFdCngCom->sidNoiseEst_flt[p] * ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) ) ); - } - 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, NULL, NULL, NULL, st, 0, 0 ); - - for ( int p = 0; p < ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); p++ ) - { - if ( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp <= 31 ) - { - st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->cngNoiseLevel[p] / ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) ) ); - } - else - { - st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->cngNoiseLevel[p] * ( 1u << ( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp - 31 ) ) ); - } - } - for ( int p = 0; p < NPART; p++ ) - { - st->hFdCngDec->hFdCngCom->sidNoiseEstLp_flt[p] = (float) st->hFdCngDec->hFdCngCom->sidNoiseEstLp[p] / ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) ); - } - for ( int p = 0; p < 24; p++ ) - { - st->hFdCngDec->partNoiseShape_float[p] = (float) st->hFdCngDec->partNoiseShape[p] / ( 1u << ( 31 - st->hFdCngDec->partNoiseShape_exp ) ); - } -#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 ); @@ -251,15 +195,7 @@ ivas_error acelp_core_dec( 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 ); - set32_fx( imagBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); - realBuffer_fx[i] = realBufferTmp_fx[i]; - imagBuffer_fx[i] = imagBufferTmp_fx[i]; - } -#endif // IVAS_FLOAT_FIXED + /*----------------------------------------------------------------* * Initialization *----------------------------------------------------------------*/ @@ -267,11 +203,6 @@ ivas_error acelp_core_dec( LSF_Q_prediction = -1; set_f( syn_tmp, 0, L_SUBFR ); syn = syn_tmp + L_SUBFR; -#ifdef IVAS_FLOAT_FIXED - set_f(syn_tmp, 0, L_FRAME16k + L_SUBFR); - set16_fx(syn_tmp_fx, 0, L_SUBFR); - syn_fx = syn_tmp_fx + L_SUBFR; -#endif syn1_tmp[0] = 0; syn1_tmp[1] = 0; syn1 = syn1_tmp + 2; @@ -322,22 +253,15 @@ ivas_error acelp_core_dec( { set_f( old_exc2, 0, L_EXC_MEM ); } - exc2 = old_exc2 + L_EXC_MEM; if ( st->hBWE_TD != NULL ) { mvr2r( st->hBWE_TD->old_bwe_exc, old_bwe_exc, PIT16k_MAX * 2 ); bwe_exc = old_bwe_exc + PIT16k_MAX * 2; -#ifdef IVAS_FLOAT_FIXED - bwe_exc_fx = old_bwe_exc_fx + PIT16k_MAX * 2; -#endif } else { bwe_exc = NULL; -#ifdef IVAS_FLOAT_FIXED - bwe_exc_fx = NULL; -#endif } last_pulse_pos = 0; @@ -602,53 +526,7 @@ ivas_error acelp_core_dec( { 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]; } -#ifdef IVAS_FLOAT_FIXED - //Word16 syn_fx[L_FRAME16k + L_SUBFR] = { 0 }; - st->Q_syn = 0; - /*for ( int p = 0; p < L_FRAME16k; p++ ) - { - syn_fx[L_SUBFR + p] = (Word16) ( syn[p] * ( 1u << st->Q_syn ) ); - }*/ - for (int p = 0; p < L_FRAME16k; p++) - { - syn_fx[p] = (Word16)(syn[p] * (1u << st->Q_syn)); - } - 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 ) ) ); - } - st->hFdCngDec->hFdCngCom->sidNoiseEstExp = 31 - Q4; - for ( int p = 0; p < NPART; p++ ) - { - st->hFdCngDec->hFdCngCom->sidNoiseEstLp[p] = (Word32)(st->hFdCngDec->hFdCngCom->sidNoiseEstLp_flt[p] * (1u << (31 - st->hFdCngDec->hFdCngCom->sidNoiseEstExp))); - st->hFdCngDec->hFdCngCom->sidNoiseEst[p] = (Word32) ( st->hFdCngDec->hFdCngCom->sidNoiseEst_flt[p] * ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) ) ); - } - - //ApplyFdCng_fx( syn_fx + L_SUBFR, st->Q_syn, NULL, realBuffer, imagBuffer, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); - ApplyFdCng_fx(syn_fx, st->Q_syn, NULL, realBuffer_fx, imagBuffer_fx, NULL, st, 0, (st->coder_type == AUDIO && !st->GSC_noisy_speech)); - - for ( int p = 0; p < ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); p++ ) - { - if ( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp <= 31 ) - { - st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->cngNoiseLevel[p] / ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) ) ); - } - else - { - st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->cngNoiseLevel[p] * ( 1u << ( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp - 31 ) ) ); - } - } - for ( int p = 0; p < NPART; p++ ) - { - st->hFdCngDec->hFdCngCom->sidNoiseEstLp_flt[p] = (float) st->hFdCngDec->hFdCngCom->sidNoiseEstLp[p] / ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) ); - } - for ( int p = 0; p < 24; p++ ) - { - st->hFdCngDec->partNoiseShape_float[p] = (float) st->hFdCngDec->partNoiseShape[p] / ( 1u << ( 31 - st->hFdCngDec->partNoiseShape_exp ) ); - } -#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 ) @@ -733,11 +611,11 @@ ivas_error acelp_core_dec( nb_bits = -1; } - config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); + config_acelp1( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); if ( st->coder_type == TRANSITION && tc_subfr < L_SUBFR && st->L_frame == L_FRAME ) { - config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); + config_acelp1( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); } } @@ -780,27 +658,7 @@ ivas_error acelp_core_dec( int16_t beta_index; beta_index = get_next_indice( st, TDM_IC_LSF_PRED_BITS ); -#ifdef IVAS_FLOAT_FIXED - Word16 lsf_new_fx[M]; - Word16 lsp_new_fx[M]; - Word16 tdm_lsfQ_PCh_fx[M]; - for (int i = 0; i < M; i++) - { - lsf_new_fx[i] = (lsf_new[i]) * 2.56; - tdm_lsfQ_PCh_fx[i] = (tdm_lsfQ_PCh[i]) * 2.56; - } - floatToFixed_arr(lsp_new, lsp_new_fx, 15, M); - - tdm_SCh_lsf_reuse_fx(DEC, st->element_brate, lsf_new_fx, lsp_new_fx, tdm_lsfQ_PCh_fx, NULL, &beta_index); - - for (int i = 0; i < M; i++) - { - lsf_new[i] = (lsf_new_fx[i]) / 2.56; - } - fixedToFloat_arr(lsp_new_fx, lsp_new, 15, M); -#else tdm_SCh_lsf_reuse( DEC, st->element_brate, lsf_new, lsp_new, tdm_lsfQ_PCh, NULL, &beta_index ); -#endif } else { @@ -1168,21 +1026,6 @@ ivas_error acelp_core_dec( } } -#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( Aq_fx + 2 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); - } - ELSE - { - Copy( Aq_fx + 3 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); - } - fixedToFloat_arr( st->hBWE_TD->cur_sub_Aq_fx, st->hBWE_TD->cur_sub_Aq, Q12, M + 1 ); - } -#else if ( st->hBWE_TD != NULL ) { if ( st->L_frame == L_FRAME ) @@ -1194,60 +1037,11 @@ ivas_error acelp_core_dec( 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 - Word16 pitch_buf_tmp[NB_SUBFR16k]; - /*----ftf conversions---*/ - st->Q_syn = 0; - floatToFixed_arr( syn, syn_fx, st->Q_syn, L_FRAME16k ); - tmp_noise_fx = (Word16) floatToFixed( tmp_noise, 0 ); - if ( st->last_bwidth == NB && st->hPFstat != NULL ) - { - floatToFixed_arr( pitch_buf, pitch_buf_tmp, Q6, NB_SUBFR16k ); - } - test(); - IF( EQ_16( st->last_bwidth, NB ) && st->hPFstat != NULL ) - { - IF( EQ_16( st->bwidth, NB ) ) - { - st->hPFstat->on = 1; -#ifdef IVAS_FLOAT_FIXED - Word16 prev_reset = st->hPFstat->reset; - move16(); - nb_post_filt( st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, st->coder_type, st->BER_detect, 0 ); - /*----ftf conversions---*/ - /*---------------------*/ -#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 - } - ELSE - { - st->hPFstat->on = 0; -#ifdef IVAS_FLOAT_FIXED - Word16 prev_reset = st->hPFstat->reset; - nb_post_filt( st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, AUDIO, st->BER_detect, 0 ); - /*----ftf conversions---*/ - /*---------------------*/ -#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 - } - } - 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 ) @@ -1265,153 +1059,27 @@ ivas_error acelp_core_dec( { 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 - floatToFixed_arr( syn, syn_fx, st->Q_syn, L_FRAME16k ); - Copy( syn_fx + st->L_frame - L_SYN_MEM, st->mem_syn_r, L_SYN_MEM ); - fixedToFloat_arr( st->mem_syn_r, st->mem_syn_r_float, st->Q_syn, 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_S - floatToFixed_arr( syn, syn_fx, st->Q_syn, L_FRAME16k ); - st->mem_deemph_fx = float_to_fix16_thrld( st->mem_deemph, st->Q_syn ); - st->preemph_fac = float_to_fix16( st->preemph_fac_float, Q15 ); - - deemph_fx( syn_fx, st->preemph_fac, st->L_frame, &( st->mem_deemph_fx ) ); - - st->mem_deemph = fix16_to_float( st->mem_deemph_fx, st->Q_syn ); - fixedToFloat_arr( syn_fx, syn, st->Q_syn, st->L_frame ); -#else deemph( syn, st->preemph_fac_float, st->L_frame, &( st->mem_deemph ) ); -#endif -#ifdef IVAS_FLOAT_FIXED_S - Word16 syn_fx_tmp2[L_FRAME_16k]; - unscale_AGC( syn_fx, st->Q_syn, syn_fx_tmp2, st->agc_mem_fx, st->L_frame ); // re-check : removed right shift inside - Copy( syn_fx_tmp2, syn_fx, st->L_frame ); - for ( i = 0; i < st->L_frame; i++ ) - { - syn[i] = fix16_to_float( syn_fx[i], st->Q_syn ); - } - st->agc_mem2[0] = me2f_16( st->agc_mem_fx[0], st->Q_syn - 1 ); - st->agc_mem2[1] = me2f_16( st->agc_mem_fx[1], st->Q_syn - 1 ); -#else AGC_dec( syn, st->agc_mem2, st->L_frame ); -#endif - -#ifdef IVAS_FLOAT_FIXED - floatToFixed_arr( syn, syn_fx, st->Q_syn, L_FRAME16k ); - IF( st->hTcxDec != NULL ) - { - Copy_Scale_sig( syn_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( syn_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, syn_fx, st->Q_syn, st->L_frame ); - Copy( syn_fx, temp_buf_fx + L_SYN_MEM, L_FRAME16k ); - - for ( i = 0; i < L_SYN_MEM; i++ ) - { - temp_buf_fx[i] = float_to_fix16_thrld( temp_buf[i], st->Q_syn ); - } - set16_fx( st->hPFstat->mem_zero, 0, M ); - /*---------------------*/ - - formant_post_filt_fx( st->hPFstat, temp_buf_fx + L_SYN_MEM, Aq_fx, syn_fx, st->L_frame, st->lp_noise, st->total_brate, 0 ); - - /*----ftf conversions---*/ - fixedToFloat_arr( syn_fx, syn, st->Q_syn, st->L_frame ); - /*---------------------*/ -#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 - /*----ftf conversions---*/ - floatToFixed_arr( syn, syn_fx, st->Q_syn, L_SUBFR ); - floatToFixed_arr( Aq, Aq_fx, Q12, NB_SUBFR16k * ( M + 1 ) ); - /*---------------------*/ - - Copy( st->hPFstat->mem_pf_in + L_SYN_MEM - M, temp_buf_fx, M ); - Copy( syn_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( syn_fx, temp_buf_fx, &st->hPFstat->gain_prec, L_SUBFR ); - Copy( temp_buf_fx, syn_fx, L_SUBFR / 2 ); - blend_subfr2( temp_buf_fx + L_SUBFR / 2, syn_fx + L_SUBFR / 2, syn_fx + L_SUBFR / 2 ); - - /*----ftf conversions---*/ - if ( st->hPFstat ) - { - fixedToFloat_arr( st->hPFstat->mem_stp, st->hPFstat->mem_stp_flt, st->Q_syn, L_SUBFR ); - } - fixedToFloat_arr( temp_buf_fx, temp_buf, st->Q_syn, L_FRAME16k + L_SYN_MEM ); - fixedToFloat_arr( syn_fx, syn, st->Q_syn, L_SUBFR ); - /*---------------------*/ -#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 ); @@ -1433,7 +1101,7 @@ ivas_error acelp_core_dec( } st->hPFstat->on = 0; } -#endif + /*----------------------------------------------------------------* * Comfort noise addition *----------------------------------------------------------------*/ @@ -1451,10 +1119,6 @@ ivas_error acelp_core_dec( noisy_speech_detection_flt( st->hFdCngDec, st->VAD, 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; -#ifdef IVAS_FLOAT_FIXED - st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx = L_add( Mpy_32_32( Q31_0_99, st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx ), - st->hFdCngDec->hFdCngCom->flag_noisy_speech * Q31_0_01 ); -#endif } if ( st->idchan == 0 ) @@ -1465,158 +1129,8 @@ ivas_error acelp_core_dec( if ( st->element_mode != IVAS_CPE_TD && !st->cng_ism_flag ) { /*Noise estimate*/ -#ifdef IVAS_FLOAT_FIXED - //Word16 syn_fx[L_FRAME16k + L_SUBFR] = { 0 }; - st->Q_syn = 0; - /*for ( int p = 0; p < L_FRAME16k; p++ ) - { - syn_fx[L_SUBFR + p] = (Word16) ( syn[p] * ( 1u << st->Q_syn ) ); - }*/ - for (int p = 0; p < L_FRAME16k; p++) - { - syn_fx[p] = (Word16)(syn[p] * (1u << st->Q_syn)); - } - for ( int p = 0; p < st->L_frame; p++ ) - { - st->hFdCngDec->hFdCngCom->periodog[p] = (Word32) ( st->hFdCngDec->hFdCngCom->periodog_flt[p] * ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->periodog_exp ) ) ); - } - st->hFdCngDec->hFdCngCom->fftBuffer_exp = 31 - Q4; - for ( int p = 0; p < st->hFdCngDec->hFdCngCom->fftlen; p++ ) - { - st->hFdCngDec->hFdCngCom->fftBuffer[p] = (Word32) ( st->hFdCngDec->hFdCngCom->fftBuffer_flt[p] * ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp ) ) ); - } - st->hFdCngDec->msNoiseEst_exp = 31 - Q4; // Q4 - for ( int p = 0; p < st->hFdCngDec->npart_shaping; p++ ) - { - st->hFdCngDec->msNoiseEst[p] = (Word32) ( st->hFdCngDec->msNoiseEst_float[p] * ( 1u << ( 31 - st->hFdCngDec->msNoiseEst_exp ) ) ); - st->hFdCngDec->msPeriodog[p] = (Word32) ( st->hFdCngDec->msPeriodog_float[p] * ( 1u << ( 31 - st->hFdCngDec->msPeriodog_exp ) ) ); - st->hFdCngDec->msPeriodog_ST_fx[p] = (Word32) ( st->hFdCngDec->msPeriodog_ST[p] * ( 1u << ( 31 - st->hFdCngDec->msPeriodog_ST_exp ) ) ); - } - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 31 - Q4; // Q4 - for ( int p = 0; p < FFTCLDFBLEN; p++ ) - { - st->hFdCngDec->hFdCngCom->cngNoiseLevel[p] = (Word32) ( st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[p] * ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) ) ); - } - - //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(syn_fx, st->Q_syn, NULL, realBuffer_fx, imagBuffer_fx, NULL, st, 0, (st->coder_type == AUDIO && !st->GSC_noisy_speech)); -/*==========================================================*/ - - if ( ( ( st->m_frame_type == ACTIVE_FRAME ) && ( ( st->bfi == 0 && - ( syn_fx == NULL || - ( *syn_fx( -FLT_MAX ) && - *( syn_fx + st->hFdCngDec->hFdCngCom->frameSize - 1 ) < FLT_MAX && - *( syn_fx + st->hFdCngDec->hFdCngCom->frameSize - 1 ) > ( -FLT_MAX ) ) ) && - ( ( ( ( st->element_mode != IVAS_CPE_TD && st->element_mode != IVAS_CPE_DFT && st->hFdCngDec->flag_dtx_mode ) || !st->VAD || ( st->ini_frame < 100 && st->is_ism_format ) ) && - !( st->cng_type == LP_CNG && st->hFdCngDec->flag_dtx_mode ) ) || - ( st->element_mode == IVAS_CPE_TD ) ) && - ( !st->BER_detect ) ) || - ( ( st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT ) && ( st->hFdCngDec->hFdCngCom->active_frame_counter > 0 ) ) || ( ( st->bfi == 1 ) && ( st->nbLostCmpt == 1 ) ) ) ) || - ( st->m_frame_type == ZERO_FRAME ) && ( st != NULL && st->cng_type == LP_CNG ) ) - { - { - for ( int p = 0; p < st->hFdCngDec->hFdCngCom->fftlen; p++ ) - { - st->hFdCngDec->hFdCngCom->fftBuffer_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->fftBuffer[p] / ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp ) ) ); - } - - for ( int p = 0; p < ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); p++ ) - { - st->hFdCngDec->bandNoiseShape_float[p] = ( (float) st->hFdCngDec->bandNoiseShape[p] / ( 1u << ( 31 - st->hFdCngDec->bandNoiseShape_exp ) ) ); - } - for ( int p = 0; p < st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand; p++ ) - { - st->hFdCngDec->hFdCngCom->periodog_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->periodog[p] / (float) ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->periodog_exp ) ) ); - } - for ( int p = 0; p < st->hFdCngDec->npart_shaping; p++ ) - { - st->hFdCngDec->msPsd_float[p] = ( (float) st->hFdCngDec->msPsd_fx[p] / ( 1u << ( 31 - st->hFdCngDec->msPsd_exp_fft ) ) ); - st->hFdCngDec->msNoiseEst_float[p] = (float) st->hFdCngDec->msNoiseEst[p] / ( 1u << ( 31 - st->hFdCngDec->msNoiseEst_exp ) ); - st->hFdCngDec->msPeriodog_float[p] = ( (float) st->hFdCngDec->msPeriodog[p] / ( 1u << ( 31 - st->hFdCngDec->msPeriodog_exp ) ) ); - st->hFdCngDec->msPeriodog_ST[p] = ( (float) st->hFdCngDec->msPeriodog_ST_fx[p] / ( 1u << ( 31 - st->hFdCngDec->msPeriodog_ST_exp ) ) ); - } - if ( st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT ) - { - for ( int p = 0; p < L_FRAME16k - st->hFdCngDec->hFdCngCom->startBand; p++ ) - { - st->hFdCngDec->smoothed_psd[st->hFdCngDec->hFdCngCom->startBand + p] = ( (float) st->hFdCngDec->smoothed_psd_fx[st->hFdCngDec->hFdCngCom->startBand + p] / ( 1u << ( 31 - st->hFdCngDec->msNoiseEst_exp ) ) ); - } - } - } - if ( !( ( st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT ) && ( st->hFdCngDec->hFdCngCom->active_frame_counter > 0 ) ) ) - { - st->hTcxDec->CngLevelBackgroundTrace_bfi = fix_to_float( st->hTcxDec->CngLevelBackgroundTrace_bfi_fx, ( 31 - st->hTcxDec->CngLevelBackgroundTrace_bfi_exp ) ); - st->cngTDLevel_float = fixedToFloat( st->cngTDLevel, ( 15 - st->cngTDLevel_e ) ); - for ( int p = 0; p < ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); p++ ) - { - st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->cngNoiseLevel[p] / ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) ) ); - } - IF( !( EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) ) - { - for ( int p = 0; p < MSNUMSUBFR * NPART_SHAPING; p++ ) - { - if ( ( st->hFdCngDec->msMinBuf[p] == MAX_32 ) ) - { - st->hFdCngDec->msMinBuf_float[p] = FLT_MAX; - } - else - { - st->hFdCngDec->msMinBuf_float[p] = (float) st->hFdCngDec->msMinBuf[p] / ( 1u << ( 31 - 6 ) ); // CNG_S = 6 - } - } - for ( int p = 0; p < st->hFdCngDec->npart_shaping; p++ ) - { - st->hFdCngDec->msPeriodogBuf_float[p] = ( (float) st->hFdCngDec->msPeriodogBuf[p] / ( 1u << Q9 ) ); - st->hFdCngDec->msPsdFirstMoment_float[p] = ( (float) st->hFdCngDec->msPsdFirstMoment[p] / ( 1u << Q9 ) ); - st->hFdCngDec->msPsdSecondMoment_float[p] = ( (float) st->hFdCngDec->msPsdSecondMoment[p] / ( 1u << Q19 ) ); - st->hFdCngDec->msNoiseFloor_float[p] = ( (float) st->hFdCngDec->msNoiseFloor[p] / ( 1u << Q9 ) ); - st->hFdCngDec->msAlpha_float[p] = ( (float) st->hFdCngDec->msAlpha[p] / ( 1u << Q31 ) ); - st->hFdCngDec->msBminWin_float[p] = ( (float) st->hFdCngDec->msBminWin[p] / ( 1u << Q27 ) ); - st->hFdCngDec->msBminSubWin_float[p] = ( (float) st->hFdCngDec->msBminSubWin[p] / ( 1u << Q27 ) ); - if ( st->hFdCngDec->msCurrentMin[p] == MAX_32 ) - { - st->hFdCngDec->msCurrentMin_float[p] = FLT_MAX; - } - else - { - st->hFdCngDec->msCurrentMin_float[p] = ( (float) st->hFdCngDec->msCurrentMin[p] / ( 1u << ( 31 - ( 6 + 1 + 4 ) ) ) ); // exp : CNG_S + 1 + 4 - } - if ( st->hFdCngDec->msCurrentMinOut[p] == MAX_32 ) - { - st->hFdCngDec->msCurrentMinOut_float[p] = FLT_MAX; - } - else - { - st->hFdCngDec->msCurrentMinOut_float[p] = ( (float) st->hFdCngDec->msCurrentMinOut[p] / ( 1u << ( 31 - 6 ) ) ); - } - if ( st->hFdCngDec->msCurrentMinSubWindow[p] == MAX_32 ) - { - st->hFdCngDec->msCurrentMinSubWindow_float[p] = FLT_MAX; - } - else - { - st->hFdCngDec->msCurrentMinSubWindow_float[p] = ( (float) st->hFdCngDec->msCurrentMinSubWindow[p] / ( 1u << ( 31 - 6 ) ) ); - } - } - } - if ( sum_f( st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt + st->hFdCngDec->hFdCngCom->startBand, st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ) > 0.01f ) - { - if ( st->element_mode != IVAS_CPE_MDCT || st->core == ACELP_CORE ) - { - int A_cng_q = 15 - norm_s( st->hFdCngDec->hFdCngCom->A_cng[0] ); - for ( int p = 0; p < M; p++ ) - { - st->hFdCngDec->hFdCngCom->A_cng_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->A_cng[p] / ( 1u << A_cng_q ) ); - //st->lspold_cng_float[p] = ( (float) st->lspold_cng[p] / ( 1u << Q15 ) ); - } - } - } - } - } -#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 ) @@ -1628,11 +1142,7 @@ ivas_error acelp_core_dec( { 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_fx( syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out ); -#endif hStereoCng->flag_cna_fade = 0; } else @@ -1643,11 +1153,7 @@ ivas_error acelp_core_dec( set_f( hStereoCng->olapBufferSynth22, 0.0f, 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_fx( syn, st, hStereoTD, flag_sec_CNA, 0, hStereoCng, nchan_out ); -#endif } } else if ( st->element_mode != IVAS_CPE_DFT ) @@ -1666,11 +1172,7 @@ ivas_error acelp_core_dec( { 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_fx( syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out ); -#endif hStereoCng->flag_cna_fade = 1; } else @@ -1693,151 +1195,7 @@ ivas_error acelp_core_dec( /*Noise estimate*/ if ( st->idchan == 0 && ( nchan_out == 2 || ( st->core_brate != FRAME_NO_DATA && st->core_brate != SID_2k40 ) ) ) { -#ifdef IVAS_FLOAT_FIXED - //Word16 syn_fx[L_FRAME16k + L_SUBFR] = { 0 }; - st->Q_syn = 0; - for ( int p = 0; p < L_FRAME16k; p++ ) - { - syn_fx[p] = (Word16) ( syn[p] * ( 1u << st->Q_syn ) ); - } - for ( int p = 0; p < st->L_frame; p++ ) - { - st->hFdCngDec->hFdCngCom->periodog[p] = (Word32) ( st->hFdCngDec->hFdCngCom->periodog_flt[p] * ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->periodog_exp ) ) ); - } - st->hFdCngDec->hFdCngCom->fftBuffer_exp = 31 - Q4; - for ( int p = 0; p < st->hFdCngDec->hFdCngCom->fftlen; p++ ) - { - st->hFdCngDec->hFdCngCom->fftBuffer[p] = (Word32) ( st->hFdCngDec->hFdCngCom->fftBuffer_flt[p] * ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp ) ) ); - } - st->hFdCngDec->msNoiseEst_exp = 31 - Q4; - for ( int p = 0; p < st->hFdCngDec->npart_shaping; p++ ) - { - st->hFdCngDec->msNoiseEst[p] = (Word32) ( st->hFdCngDec->msNoiseEst_float[p] * ( 1u << ( 31 - st->hFdCngDec->msNoiseEst_exp ) ) ); - st->hFdCngDec->msPeriodog[p] = (Word32) ( st->hFdCngDec->msPeriodog_float[p] * ( 1u << ( 31 - st->hFdCngDec->msPeriodog_exp ) ) ); - st->hFdCngDec->msPeriodog_ST_fx[p] = (Word32) ( st->hFdCngDec->msPeriodog_ST[p] * ( 1u << ( 31 - st->hFdCngDec->msPeriodog_ST_exp ) ) ); - } - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 31 - Q4; - for ( int p = 0; p < FFTCLDFBLEN; p++ ) - { - st->hFdCngDec->hFdCngCom->cngNoiseLevel[p] = (Word32) ( st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[p] * ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) ) ); - } - - ApplyFdCng_fx( syn_fx, st->Q_syn, NULL, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); - - if ( ( ( st->m_frame_type == ACTIVE_FRAME ) && ( ( st->bfi == 0 && - ( syn_fx == NULL || - ( *syn_fx( -FLT_MAX ) && - *( syn_fx + st->hFdCngDec->hFdCngCom->frameSize - 1 ) < FLT_MAX && - *( syn_fx + st->hFdCngDec->hFdCngCom->frameSize - 1 ) > ( -FLT_MAX ) ) ) && - ( ( ( ( st->element_mode != IVAS_CPE_TD && st->element_mode != IVAS_CPE_DFT && st->hFdCngDec->flag_dtx_mode ) || !st->VAD || ( st->ini_frame < 100 && st->is_ism_format ) ) && - !( st->cng_type == LP_CNG && st->hFdCngDec->flag_dtx_mode ) ) || - ( st->element_mode == IVAS_CPE_TD ) ) && - ( !st->BER_detect ) ) || - ( ( st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT ) && ( st->hFdCngDec->hFdCngCom->active_frame_counter > 0 ) ) || ( ( st->bfi == 1 ) && ( st->nbLostCmpt == 1 ) ) ) ) || - ( st->m_frame_type == ZERO_FRAME ) && ( st != NULL && st->cng_type == LP_CNG ) ) - { - { - for ( int p = 0; p < st->hFdCngDec->hFdCngCom->fftlen; p++ ) - { - st->hFdCngDec->hFdCngCom->fftBuffer_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->fftBuffer[p] / ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp ) ) ); - } - - for ( int p = 0; p < ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); p++ ) - { - st->hFdCngDec->bandNoiseShape_float[p] = ( (float) st->hFdCngDec->bandNoiseShape[p] / ( 1u << ( 31 - st->hFdCngDec->bandNoiseShape_exp ) ) ); - } - for ( int p = 0; p < st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand; p++ ) - { - st->hFdCngDec->hFdCngCom->periodog_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->periodog[p] / (float) ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->periodog_exp ) ) ); - } - for ( int p = 0; p < st->hFdCngDec->npart_shaping; p++ ) - { - st->hFdCngDec->msPsd_float[p] = ( (float) st->hFdCngDec->msPsd_fx[p] / ( 1u << ( 31 - st->hFdCngDec->msPsd_exp_fft ) ) ); - st->hFdCngDec->msNoiseEst_float[p] = (float) st->hFdCngDec->msNoiseEst[p] / ( 1u << ( 31 - st->hFdCngDec->msNoiseEst_exp ) ); - st->hFdCngDec->msPeriodog_float[p] = ( (float) st->hFdCngDec->msPeriodog[p] / ( 1u << ( 31 - st->hFdCngDec->msPeriodog_exp ) ) ); - st->hFdCngDec->msPeriodog_ST[p] = ( (float) st->hFdCngDec->msPeriodog_ST_fx[p] / ( 1u << ( 31 - st->hFdCngDec->msPeriodog_ST_exp ) ) ); - } - if ( st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT ) - { - for ( int p = 0; p < L_FRAME16k - st->hFdCngDec->hFdCngCom->startBand; p++ ) - { - st->hFdCngDec->smoothed_psd[st->hFdCngDec->hFdCngCom->startBand + p] = ( (float) st->hFdCngDec->smoothed_psd_fx[st->hFdCngDec->hFdCngCom->startBand + p] / ( 1u << ( 31 - st->hFdCngDec->msNoiseEst_exp ) ) ); - } - } - } - if ( !( ( st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT ) && ( st->hFdCngDec->hFdCngCom->active_frame_counter > 0 ) ) ) - { - st->hTcxDec->CngLevelBackgroundTrace_bfi = fix_to_float( st->hTcxDec->CngLevelBackgroundTrace_bfi_fx, ( 31 - st->hTcxDec->CngLevelBackgroundTrace_bfi_exp ) ); - st->cngTDLevel_float = fixedToFloat( st->cngTDLevel, ( 15 - st->cngTDLevel_e ) ); - for ( int p = 0; p < ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); p++ ) - { - st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->cngNoiseLevel[p] / ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) ) ); - } - IF( !( EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) ) - { - for ( int p = 0; p < MSNUMSUBFR * NPART_SHAPING; p++ ) - { - if ( ( st->hFdCngDec->msMinBuf[p] == MAX_32 ) ) - { - st->hFdCngDec->msMinBuf_float[p] = FLT_MAX; - } - else - { - st->hFdCngDec->msMinBuf_float[p] = (float) st->hFdCngDec->msMinBuf[p] / ( 1u << ( 31 - 6 ) ); // CNG_S = 6 - } - } - for ( int p = 0; p < st->hFdCngDec->npart_shaping; p++ ) - { - st->hFdCngDec->msPeriodogBuf_float[p] = ( (float) st->hFdCngDec->msPeriodogBuf[p] / ( 1u << Q9 ) ); - st->hFdCngDec->msPsdFirstMoment_float[p] = ( (float) st->hFdCngDec->msPsdFirstMoment[p] / ( 1u << Q9 ) ); - st->hFdCngDec->msPsdSecondMoment_float[p] = ( (float) st->hFdCngDec->msPsdSecondMoment[p] / ( 1u << Q19 ) ); - st->hFdCngDec->msNoiseFloor_float[p] = ( (float) st->hFdCngDec->msNoiseFloor[p] / ( 1u << Q9 ) ); - st->hFdCngDec->msAlpha_float[p] = ( (float) st->hFdCngDec->msAlpha[p] / ( 1u << Q31 ) ); - st->hFdCngDec->msBminWin_float[p] = ( (float) st->hFdCngDec->msBminWin[p] / ( 1u << Q27 ) ); - st->hFdCngDec->msBminSubWin_float[p] = ( (float) st->hFdCngDec->msBminSubWin[p] / ( 1u << Q27 ) ); - if ( st->hFdCngDec->msCurrentMin[p] == MAX_32 ) - { - st->hFdCngDec->msCurrentMin_float[p] = FLT_MAX; - } - else - { - st->hFdCngDec->msCurrentMin_float[p] = ( (float) st->hFdCngDec->msCurrentMin[p] / ( 1u << ( 31 - ( 6 + 1 + 4 ) ) ) ); // exp : CNG_S + 1 + 4 - } - if ( st->hFdCngDec->msCurrentMinOut[p] == MAX_32 ) - { - st->hFdCngDec->msCurrentMinOut_float[p] = FLT_MAX; - } - else - { - st->hFdCngDec->msCurrentMinOut_float[p] = ( (float) st->hFdCngDec->msCurrentMinOut[p] / ( 1u << ( 31 - 6 ) ) ); - } - if ( st->hFdCngDec->msCurrentMinSubWindow[p] == MAX_32 ) - { - st->hFdCngDec->msCurrentMinSubWindow_float[p] = FLT_MAX; - } - else - { - st->hFdCngDec->msCurrentMinSubWindow_float[p] = ( (float) st->hFdCngDec->msCurrentMinSubWindow[p] / ( 1u << ( 31 - 6 ) ) ); - } - } - } - if ( sum_f( st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt + st->hFdCngDec->hFdCngCom->startBand, st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ) > 0.01f ) - { - if ( st->element_mode != IVAS_CPE_MDCT || st->core == ACELP_CORE ) - { - int A_cng_q = 15 - norm_s( st->hFdCngDec->hFdCngCom->A_cng[0] ); - for ( int p = 0; p < M; p++ ) - { - st->hFdCngDec->hFdCngCom->A_cng_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->A_cng[p] / ( 1u << A_cng_q ) ); - //st->lspold_cng_float[p] = ( (float) st->lspold_cng[p] / ( 1u << Q15 ) ); - } - } - } - } - } -#else ApplyFdCng_flt( syn, NULL, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); -#endif // IVAS_FLOAT_FIXED } } } @@ -1874,29 +1232,8 @@ ivas_error acelp_core_dec( /* 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 ) { @@ -1905,63 +1242,10 @@ ivas_error acelp_core_dec( } /* analyze pitch coherence for bass post-filter */ - -#ifdef IVAS_FLOAT_FIXED - - Word32 pitch_buf_fx[12]; - - FOR( Word16 lp = 0; lp < 12; lp++ ) - { - st->old_pitch_buf_fx[lp] = (Word32) ( st->old_pitch_buf[lp] * ( 1u << 20 ) ); - } - Word16 lim = st->L_frame / 64; - for ( Word16 lp = 0; lp < lim; lp++ ) - { - pitch_buf_fx[lp] = (Word32) ( pitch_buf[lp] * ( 1u << 20 ) ); - } - bpf_pitch_coherence_fx( st, pitch_buf_fx ); - -#else bpf_pitch_coherence( st, pitch_buf ); -#endif if ( !( st->element_mode == IVAS_CPE_MDCT && st->bpf_off ) ) { -#ifdef IVAS_FLOAT_FIXED - ///////////////////////////////////////////////////////////////////////////// - Word16 pst_old_syn_exp; - Word16 tmp_syn_exp; - Word16 tmp_syn_fx[1]; // temporary. just one element because retro_interp4_5 only accesses syn[0] - - // Get exponents. - f2me_buf_16(st->hBPF->pst_old_syn, st->hBPF->pst_old_syn_fx, &pst_old_syn_exp, NBPSF_PIT_MAX); - f2me_16(syn[0], &tmp_syn_fx[0], &tmp_syn_exp); - tmp_syn_exp = s_max(tmp_syn_exp, pst_old_syn_exp); // max exp btween syn and pst_old_syn - - // Float to fix - for (i = 0; i < NBPSF_PIT_MAX; i++) - { - st->hBPF->pst_old_syn_fx[i] = (Word16)(st->hBPF->pst_old_syn[i] * pow(2, 15 - tmp_syn_exp)); - } - tmp_syn_fx[0] = (Word16)(syn[0] * pow(2, 15 - tmp_syn_exp)); - ///////////////////////////////////////////////////////////////////////////// - - test(); - IF( NE_16( st->L_frame, st->last_L_frame ) && NE_16( st->last_codec_mode, MODE2 ) ) - { - IF( EQ_16( st->L_frame, L_FRAME ) ) - { - retro_interp5_4_fx( st->hBPF->pst_old_syn_fx ); - } - ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) ) - { - retro_interp4_5_fx( tmp_syn_fx, st->hBPF->pst_old_syn_fx ); - } - } - - // Fixed to float - me2f_buf_16( st->hBPF->pst_old_syn_fx, tmp_syn_exp, st->hBPF->pst_old_syn, NBPSF_PIT_MAX ); -#else if ( st->L_frame != st->last_L_frame && st->last_codec_mode != MODE2 ) { if ( st->L_frame == L_FRAME ) @@ -1973,77 +1257,11 @@ ivas_error acelp_core_dec( retro_interp4_5( syn, st->hBPF->pst_old_syn ); } } -#endif - /* bass post-filter */ -#ifdef IVAS_FLOAT_FIXED - Word16 tmp_syn_fx2[L_FRAME16k + L_SUBFR]; - Word16 tmp_Q_syn; - Word16 tmp_pitch_buf_fx[NB_SUBFR16k]; - - // Float to fixed - tmp_Q_syn = -1; // Q0 + one guard bit = Q(-1) - st->hBPF->pst_mem_deemp_err_fx = (Word16)floatToFixed( st->hBPF->pst_mem_deemp_err, tmp_Q_syn ); - st->hBPF->psf_att_fx = float_to_fix16( st->hBPF->psf_att, Q15 ); - for ( i = 0; i < st->L_frame; i++ ) - { - tmp_syn_fx2[i] = (Word16)floatToFixed( syn[i], tmp_Q_syn ); - } - for ( i = 0; i < NBPSF_PIT_MAX; i++ ) - { - st->hBPF->pst_old_syn_fx[i] = (Word16)floatToFixed( st->hBPF->pst_old_syn[i], tmp_Q_syn ); - } - for ( i = 0; i < NB_SUBFR16k; i++ ) - { - tmp_pitch_buf_fx[i] = (Word16)floatToFixed( pitch_buf[i], Q6 ); - } - for ( i = 0; i < L_TRACK_HIST; i++ ) - { - st->hBPF->mem_mean_pit_fx[i] = float_to_fix16( st->hBPF->mem_mean_pit[i], 0 ); - } - Word16 bpf_error_signal_fx_temp[L_FRAME16k]; - for (i = 0; i < L_FRAME16k; i++) - { - bpf_error_signal_fx_temp[i] = extract_h(bpf_error_signal_fx[i]); - } - - bass_psfilter_fx( st->hBPF, - st->Opt_AMR_WB, - tmp_syn_fx2, - st->L_frame, - tmp_pitch_buf_fx, // Q6 - st->bpf_off, - st->stab_fac_fx, // Q15 - &st->stab_fac_smooth_fx, // Q15 - st->coder_type, - tmp_Q_syn, - bpf_error_signal_fx_temp); - - for (i = 0; i < L_FRAME16k; i++) - { - bpf_error_signal_fx[i] = L_deposit_h(bpf_error_signal_fx_temp[i]); - } - - // Fixed to float - st->hBPF->mem_mean_pit[0] = fix16_to_float( st->hBPF->mem_mean_pit_fx[0], Q4 ); - st->hBPF->psf_att = fix16_to_float( st->hBPF->psf_att_fx, Q15 ); - for ( i = 0; i < NBPSF_PIT_MAX; i++ ) - { - st->hBPF->pst_old_syn[i] = fixedToFloat( st->hBPF->pst_old_syn_fx[i], tmp_Q_syn ); - } - for ( i = 0; i < L_FRAME16k; i++ ) - { - bpf_error_signal[i] = fixedToFloat( bpf_error_signal_fx[i], tmp_Q_syn + 16 ); - } -#else + /* bass post-filter */ bass_psfilter( st->hBPF, st->Opt_AMR_WB, syn, st->L_frame, pitch_buf, st->bpf_off, st->stab_fac, &st->stab_fac_smooth, st->coder_type, bpf_error_signal ); -#endif } - Word32 syn_tmp_32_fx[L_FRAME16k + L_SUBFR], *syn_32_fx; - set32_fx(syn_tmp_32_fx, 0, L_FRAME16k + L_SUBFR); - syn_32_fx = syn_tmp_32_fx + L_SUBFR; - if ( st->element_mode != IVAS_CPE_DFT || use_cldfb_for_dft ) { float realBufferSave[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; @@ -2054,170 +1272,37 @@ ivas_error acelp_core_dec( pRealSave[i] = realBufferSave[i]; pImagSave[i] = imagBufferSave[i]; } - - if ( st->p_bpf_noise_buf_float) + 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]; - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - 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 ); - IF( st->p_bpf_noise_buf_32 ) - { - Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame ); - } - - floatToFixed_arr( syn, syn_fx, st->Q_syn, L_FRAME16k ); - for ( i = 0; i < L_FRAME16k; i++ ) - { - syn_32_fx[i] = L_shr( L_deposit_h( syn_fx[i] ), 4 ); - } - - 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 ); - - 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 ); - - 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, 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; - Word32 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); - 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); - } - } - 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); - } - - tmp = -1; - move16(); - IF( st->bpf_off ) - { - tmp = 0; - move16(); - } - - addBassPostFilter_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); - } -#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 */ - st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, 10 ); - } - ELSE IF( NE_16( st->cldfbSyn->bandsToZero, sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ) ) ) - { - /* 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) + 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) + 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*/ - IF( ( EQ_32( st->core_brate, FRAME_NO_DATA ) || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LE_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) ) - { - /* Float to fixed */ - f2me_buf( st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, &st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN ); - // NOTE: this should be removed later. - //st->hFdCngDec->hFdCngCom->q_cngNoiseLevel = 31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp; - - Word16 tmpBufferScale = 0; - generate_comfort_noise_dec_hf_ivas_fx( realBuffer_fx, imagBuffer_fx, /*realBuffer, imagBuffer,*/ &tmpBufferScale, st->hFdCngDec->hFdCngCom, st->cng_ism_flag ); - - /* 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 ); - } - } - - IF( st->hFdCngDec->hFdCngCom->regularStopBand < st->cldfbSyn->no_channels ) - { - st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand ); - } - ELSE - { - st->cldfbSyn->bandsToZero = 0; - } - } - } -#else - if (!st->cng_sba_flag || st->element_mode == IVAS_CPE_MDCT) + 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)) + 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); + generate_comfort_noise_dec_hf_flt( realBuffer, imagBuffer, st->hFdCngDec->hFdCngCom, st->cng_ism_flag ); - if (st->hFdCngDec->hFdCngCom->regularStopBand < st->cldfbSyn->no_channels) + if ( st->hFdCngDec->hFdCngCom->regularStopBand < st->cldfbSyn->no_channels ) { st->cldfbSyn->bandsToZero = st->cldfbSyn->no_channels - st->hFdCngDec->hFdCngCom->regularStopBand; } @@ -2227,70 +1312,10 @@ ivas_error acelp_core_dec( } } } -#endif if ( save_hb_synth != 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; - 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_imag = (float) max( max_imag, fabs( imagBuffer[i][j] ) ); - } - } - float 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 ); - floatToFixed_arrL( imagBuffer[i], imagBuffer_fx[i], Q_real, CLDFB_NO_CHANNELS_MAX ); - } - floatToFixed_arrL( st->cldfbSynHB->cldfb_state, st->cldfbSynHB->cldfb_state_fx, Q_real - 1, st->cldfbSynHB->p_filter_length ); - floatToFixed_arrL( save_hb_synth, save_hb_synth_fx, Q_real - 1, L_FRAME48k ); - - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - realBufferSave_fx[i][j] = realBuffer_fx[i][j]; - imagBufferSave_fx[i][j] = imagBuffer_fx[i][j]; - IF( j < st->hFdCngDec->hFdCngCom->numCoreBands && i < st->hFdCngDec->hFdCngCom->numSlots ) - { - realBuffer_fx[i][j] = 0; - imagBuffer_fx[i][j] = 0; - } - } - } - - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, st->cldfbSynHB ); - - fixedToFloat_arrL( synth_fx, synth, Q_real - 1, L_FRAME48k ); - fixedToFloat_arrL( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->cldfb_state, Q_real - 1, st->cldfbSynHB->p_filter_length ); - - /* restore lowband */ - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - realBuffer_fx[i][j] = realBufferSave_fx[i][j]; - 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 ); - cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, st->cldfbSyn ); - fixedToFloat_arrL( synth_fx, synth, Q_real - 1, L_FRAME48k ); - fixedToFloat_arrL( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->cldfb_state, Q_real - 1, st->cldfbSynHB->p_filter_length ); -#else for ( int16_t j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) @@ -2304,6 +1329,7 @@ ivas_error acelp_core_dec( } } } + cldfbSynthesis_ivas( realBuffer, imagBuffer, save_hb_synth, -1, st->cldfbSynHB ); /* restore lowband */ @@ -2317,159 +1343,30 @@ ivas_error acelp_core_dec( } 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; - 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_imag = (float)max(max_imag, fabs(imagBuffer[i][j])); - } - } - float 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); - floatToFixed_arrL(imagBuffer[i], imagBuffer_fx[i], Q_real, CLDFB_NO_CHANNELS_MAX); - } - floatToFixed_arrL(st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_fx, Q_real - 1, st->cldfbSyn->p_filter_length); - Word32 synth_fx[L_FRAME48k]; - floatToFixed_arrL(synth, synth_fx, Q_real - 1, L_FRAME48k); - - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, st->cldfbSyn ); - - fixedToFloat_arrL(synth_fx, synth, Q_real - 1, L_FRAME48k); - fixedToFloat_arrL(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_state, Q_real - 1, st->cldfbSyn->p_filter_length); -#else - cldfbSynthesis_ivas(realBuffer, imagBuffer, synth, -1, st->cldfbSyn); -#endif + cldfbSynthesis_ivas( realBuffer, imagBuffer, synth, -1, st->cldfbSyn ); } /* save synthesis - needed in case of core switching */ mvr2r( synth, st->previoussynth, output_frame ); - } else { 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, syn_fx, st->Q_syn, L_FRAME16k ); - for ( i = 0; i < L_FRAME16k; i++ ) - { - syn_32_fx[i] = L_shr( L_deposit_h( syn_fx[i] ), 4 ); - } - - 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 ); - - 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 ); - - 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; - Word32 cldfb_state_offset = sub(st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels); - - // 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); - 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); - } - } - 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); - } - - tmp = 0; - move16(); - IF(!st->bpf_off) - { - tmp = nSamples; - move16(); - } - addBassPostFilter_fx( tmp_bpf_error_signal_fx + st->L_frame - nSamples, 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); - } -#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; - 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_imag = (float) max( max_imag, fabs( imagBuffer[i][j] ) ); - } - } - float 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 ); - floatToFixed_arrL( imagBuffer[i], imagBuffer_fx[i], Q_real, CLDFB_NO_CHANNELS_MAX ); - } - floatToFixed_arrL( st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_fx, Q_real - 1, st->cldfbSyn->p_filter_length ); - Word32 synth_fx[L_FRAME48k]; - floatToFixed_arrL( synth, synth_fx, Q_real - 1, L_FRAME48k ); - - 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 ); - fixedToFloat_arrL( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_state, Q_real - 1, st->cldfbSyn->p_filter_length ); - -#else + /* synthesis of the combined signal - needed for DFT stereo -> TD stereo switching */ 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) + if ( st->p_bpf_noise_buf_float ) { mvr2r( bpf_error_signal, st->p_bpf_noise_buf_float, st->L_frame ); } @@ -2486,62 +1383,8 @@ ivas_error acelp_core_dec( /*-----------------------------------------------------------------* * Bandwidth extension 6kHz-7kHz *-----------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED - IF( st->hBWE_zero != NULL ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( EQ_16( st->L_frame, L_FRAME ) && NE_16( st->bwidth, NB ) && GE_16( output_frame, L_FRAME16k ) && - ( 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; - floatToFixed_arr( Aq, Aq_fx, Q12, NB_SUBFR16k * ( M + 1 ) ); - Word16 exc_fx[L_FRAME + L_SUBFR], exp_exc = 0, Q_exc = 0; - f2me_buf_16( exc, exc_fx, &exp_exc, L_FRAME ); - Q_exc = 15 - exp_exc; - Word16 Q_syn2 = 0; - Word16 synth_fx[L_FRAME48k]; - floatToFixed_arr( syn, syn_fx, Q_syn2, L_FRAME + L_SUBFR ); - floatToFixed_arr( synth, synth_fx, Q_syn2, L_FRAME + L_SUBFR ); - - floatToFixed_arr( st->hBWE_zero->delay_syn_hf, st->hBWE_zero->delay_syn_hf_fx, Q_syn2, NS2SA( 16000, DELAY_CLDFB_NS ) - 15 ); - floatToFixed_arr( st->hBWE_zero->mem_hp_interp, st->hBWE_zero->mem_hp_interp_fx, 0, INTERP_3_1_MEM_LEN ); - floatToFixed_arr( st->hBWE_zero->mem_syn_hf, st->hBWE_zero->mem_syn_hf_fx, 0, M ); - floatToFixed_arr( st->hBWE_zero->mem_hf, st->hBWE_zero->mem_hf_fx, -2 - tmp_exp, L_FIR - 1 ); - floatToFixed_arr( st->hBWE_zero->mem_hp400, st->hBWE_zero->mem_hp400_fx, Q_syn2, 6 ); - Word16 output_subfr = output_frame / NB_SUBFR; - - hf_synth_ivas_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc_fx, - syn_fx, synth_fx, Q_exc, Q_syn2, st->hBWE_zero->delay_syn_hf_fx, &tmp_exp, - st->hBWE_zero->mem_hp_interp_fx, st->extl, st->CNG_mode, st->element_mode ); - - IF( st->hBWE_FD != NULL ) - { - st->hBWE_FD->memExp1 = tmp_exp; - } - fixedToFloat_arr( synth_fx, synth, Q_syn2, output_subfr ); - fixedToFloat_arr( syn_fx, syn, Q_syn2 - 2, L_SUBFR ); - fixedToFloat_arr( st->hBWE_zero->delay_syn_hf_fx, st->hBWE_zero->delay_syn_hf, 0, NS2SA( 16000, DELAY_CLDFB_NS ) - 15 ); - fixedToFloat_arr( st->hBWE_zero->mem_hp_interp_fx, st->hBWE_zero->mem_hp_interp, 0, INTERP_3_1_MEM_LEN ); - fixedToFloat_arr( st->hBWE_zero->mem_syn_hf_fx, st->hBWE_zero->mem_syn_hf, 0, M ); - fixedToFloat_arr( st->hBWE_zero->mem_hf_fx, st->hBWE_zero->mem_hf, -2 - tmp_exp, L_FIR - 1 ); - fixedToFloat_arr( st->hBWE_zero->mem_hp400_fx, st->hBWE_zero->mem_hp400, Q_syn2, 6 ); - } - 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->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 ) ) ) ) @@ -2553,7 +1396,6 @@ ivas_error acelp_core_dec( hf_synth_reset( st->hBWE_zero ); } } -#endif /*-----------------------------------------------------------------* * Populate parameters for SWB TBE @@ -2569,52 +1411,7 @@ ivas_error acelp_core_dec( 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 - Word16 voice_factors_fx[5]; - Word32 tmp_bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]; - Word32 tmp_old_bwe_exc_extended_fx[NL_BUFF_OFFSET]; - Word16 e1, e2; - set32_fx( tmp_bwe_exc_extended_fx, 0, L_FRAME32k + NL_BUFF_OFFSET ); - - // Extract exponents. - f2me_buf_16( bwe_exc, bwe_exc_fx, &e1, L_FRAME32k ); - f2me_buf( st->hBWE_TD->old_bwe_exc_extended, tmp_old_bwe_exc_extended_fx, &e2, NL_BUFF_OFFSET ); - st->Q_exc = 15 - s_max( e1, e2 ); - st->Q_exc = s_min( st->Q_exc, 14 ); // non_linearity_fx function crashes if Q == 15 - // Float to fixed - for ( i = 0; i < ( st->L_frame == L_FRAME16k ? 5 : 4 ); i++ ) - { - voice_factors_fx[i] = float_to_fix16( voice_factors[i], Q15 ); - } - for ( i = 0; i < NL_BUFF_OFFSET; i++ ) - { - tmp_old_bwe_exc_extended_fx[i] = floatToFixed( st->hBWE_TD->old_bwe_exc_extended[i], 2 * st->Q_exc ); - } - for ( i = 0; i < L_FRAME32k; i++ ) - { - bwe_exc_fx[i] = (Word16)floatToFixed( bwe_exc[i], st->Q_exc ); - if (bwe_exc[i] != 0 && bwe_exc_fx[i] == 0) - { - // NOTE: This is done to avoid zero values when float values are too small. - // Else it will lead to a crash later in Interpolate_allpass_steep_32. - bwe_exc_fx[i] = 1; - } - } - - /* update buffer memory */ - Copy32( tmp_old_bwe_exc_extended_fx, tmp_bwe_exc_extended_fx, NL_BUFF_OFFSET ); - - 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 ); - - /* 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 ); -#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 ) @@ -2629,48 +1426,15 @@ ivas_error acelp_core_dec( updt_dec( st, old_exc, pitch_buf, Es_pred, Aq, lsf_new, lsp_new, voice_factors, old_bwe_exc, gain_buf ); -#ifdef IVAS_FLOAT_FIXED - IF( GT_32( st->core_brate, SID_2k40 ) && st->hTdCngDec != NULL && st->hFdCngDec != NULL ) + if ( st->core_brate > SID_2k40 && st->hTdCngDec != NULL && st->hFdCngDec != NULL ) { /* update CNG parameters in active frames */ - Word16 lsp_new_fx[M]; - Word16 exc_fx[L_EXC_DEC], Q_exc, exp_exc; - f2me_buf_16( exc, exc_fx, &exp_exc, st->L_frame ); - Q_exc = 15 - exp_exc; - floatToFixed_arr( lsp_new, lsp_new_fx, Q15, M ); - floatToFixed_arr( exc, exc_fx, Q_exc, st->L_frame ); - floatToFixed_arrL( st->hTdCngDec->ho_ener_circ, st->hTdCngDec->ho_ener_circ_fx, Q6, HO_HIST_SIZE ); - floatToFixed_arr( st->hTdCngDec->ho_lsp_circ, st->hTdCngDec->ho_lsp_circ_fx, Q15, HO_HIST_SIZE * M ); - floatToFixed_arrL( st->hTdCngDec->ho_env_circ, st->hTdCngDec->ho_env_circ_fx, Q6, HO_HIST_SIZE * NUM_ENV_CNG ); - - 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, Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, - st->hFdCngDec->hFdCngCom->CngBandwidth ); - - fixedToFloat_arr( lsp_new_fx, lsp_new, Q15, M ); - fixedToFloat_arr( exc_fx, exc, Q_exc, st->L_frame ); - fixedToFloat_arrL( st->hTdCngDec->ho_ener_circ_fx, st->hTdCngDec->ho_ener_circ, Q6, HO_HIST_SIZE ); - fixedToFloat_arr( st->hTdCngDec->ho_lsp_circ_fx, st->hTdCngDec->ho_lsp_circ, Q15, HO_HIST_SIZE * M ); - fixedToFloat_arrL( st->hTdCngDec->ho_env_circ_fx, st->hTdCngDec->ho_env_circ, Q6, HO_HIST_SIZE * NUM_ENV_CNG ); + + 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] = 0; - move16(); - IF( NE_16( st->L_frame, L_FRAME ) ) - { - st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 1; - 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); + st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = ( st->L_frame == L_FRAME ? 0 : 1 ); } -#endif pop_wmops(); return error; diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 2e3027b23..5ccf31132 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -1125,13 +1125,13 @@ 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, st->Q_exc ); + 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, st->Q_exc ); + 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 ) { @@ -1539,7 +1539,6 @@ ivas_error acelp_core_dec_ivas_fx( //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 ) ); } - //fixedToFloat_arr(st->hBWE_TD->cur_sub_Aq_fx, st->hBWE_TD->cur_sub_Aq, Q12, M + 1); } #else if (st->hBWE_TD != NULL) @@ -2976,13 +2975,12 @@ void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HANDLE hSte st->coder_type = st->coder_type; st->last_coder_type = st->last_coder_type; st->last_core_from_bs = st->last_core_from_bs; - floatToFixed_arr(st->lsp_old, st->lsp_old_fx, Q15, M); + //floatToFixed_arr(st->lsp_old, st->lsp_old_fx, Q15, M); st->lp_ener_fx = floatToFixed(st->lp_ener, Q6); for (i = 0; i < M; i++) { st->mem_MA_fx[i] = (Word16)(st->mem_MA[i] * 2.56f); st->mem_AR_fx[i] = (Word16)(st->mem_AR[i] * 2.56f); } - st->mem_preemp_preQ_fx = float_to_fix16(st->mem_preemp_preQ, Q_AVQ_OUT); floatToFixed_arrL(st->old_pitch_buf, st->old_pitch_buf_fx, Q16, 2 * NB_SUBFR16k + 2); if (hStereoCng) { @@ -3024,14 +3022,9 @@ void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HANDLE hSte /* After dec_exc */ - st->lp_ener_FER_fx = float_to_fix16(st->lp_ener_bfi, Q8); st->enr_old_fx = floatToFixed(st->enr_old, 0); - st->old_enr_LP = (Word16)floatToFixed((Word16)check_bounds_l((Word32)st->old_enr_LP_float, -32768, 32767), Q3); - st->lp_ener_FEC_av = floatToFixed(st->lp_ener_FEC_av_float, 0); - st->lp_ener_FEC_max = floatToFixed(st->lp_ener_FEC_max_float, 0); st->exc_pe_fx = (Word16)floatToFixed(st->exc_pe, st->Q_stat_noise); floatToFixed_arr(st->syn_float, st->syn, 0, M + 1); - //floatToFixed_arr(st->lspold_cng_float, st->lspold_cng, Q15, M); /* CLDFB */ Word16 old_len_ana, old_len_bpf; @@ -3136,16 +3129,6 @@ void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HANDLE hSte st->hTdCngDec->ho_hist_size = st->hTdCngDec->ho_hist_size; st->hTdCngDec->act_cnt2 = st->hTdCngDec->act_cnt2; st->hTdCngDec->act_cnt = st->hTdCngDec->act_cnt; - floatToFixed_arr(st->hTdCngDec->ho_lsp_circ, st->hTdCngDec->ho_lsp_circ_fx, Q15, HO_HIST_SIZE * M); - floatToFixed_arr(st->hTdCngDec->ho_lsp_hist, st->hTdCngDec->ho_lsp_hist_fx, Q15, HO_HIST_SIZE * M); - floatToFixed_arrL(st->hTdCngDec->ho_ener_circ, st->hTdCngDec->ho_ener_circ_fx, Q6, HO_HIST_SIZE); - floatToFixed_arrL(st->hTdCngDec->ho_ener_hist, st->hTdCngDec->ho_ener_hist_fx, Q6, HO_HIST_SIZE); - floatToFixed_arrL(st->hTdCngDec->ho_env_circ, st->hTdCngDec->ho_env_circ_fx, Q6, HO_HIST_SIZE * NUM_ENV_CNG); - floatToFixed_arrL(st->hTdCngDec->ho_env_hist, st->hTdCngDec->ho_env_hist_fx, Q6, HO_HIST_SIZE * NUM_ENV_CNG); - floatToFixed_arrL(st->hTdCngDec->old_env, st->hTdCngDec->old_env_fx, Q6, 20); - floatToFixed_arrL(st->hTdCngDec->lp_env, st->hTdCngDec->lp_env_fx, Q6, 20); - floatToFixed_arr(st->hTdCngDec->exc_mem, st->hTdCngDec->exc_mem_fx, st->Q_exc, 24); - floatToFixed_arr(st->hTdCngDec->exc_mem1, st->hTdCngDec->exc_mem1_fx, st->Q_exc, 30); } /*WI_DEC_HANDLE*/ @@ -3156,7 +3139,6 @@ void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HANDLE hSte /*TD_BWE_DEC_HANDLE*/ if (st->hBWE_TD) { - floatToFixed_arr(st->hBWE_TD->cur_sub_Aq, st->hBWE_TD->cur_sub_Aq_fx, Q12, M + 1); floatToFixed_arr(st->hBWE_TD->old_bwe_exc_extended, st->hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET); } @@ -3208,14 +3190,13 @@ void acelp_decoder_state_fix2float(Decoder_State *st, STEREO_CNG_DEC_HANDLE hSte st->last_core_from_bs = st->last_core_from_bs; st->prev_Q_syn = st->Q_syn; - fixedToFloat_arr(st->lsp_old_fx, st->lsp_old, Q15, M); + //fixedToFloat_arr(st->lsp_old_fx, st->lsp_old, Q15, M); st->lp_ener = fixedToFloat(st->lp_ener_fx, Q6); for (i = 0; i < M; i++) { st->mem_MA[i] = st->mem_MA_fx[i] / 2.56f; st->mem_AR[i] = st->mem_AR_fx[i] / 2.56f; } fixedToFloat_arrL(st->old_pitch_buf_fx, st->old_pitch_buf, Q16, 2 * NB_SUBFR16k + 2); - st->mem_preemp_preQ = fixedToFloat(st->mem_preemp_preQ_fx, Q_AVQ_OUT); if (hStereoCng) { fixedToFloat_arr(hStereoCng->olapBufferSynth22_fx, hStereoCng->olapBufferSynth22, st->Q_syn, FFTLEN); } @@ -3255,11 +3236,7 @@ void acelp_decoder_state_fix2float(Decoder_State *st, STEREO_CNG_DEC_HANDLE hSte /* After dec_exc */ - st->lp_ener_bfi = fixedToFloat(st->lp_ener_FER_fx, Q8); st->enr_old = fixedToFloat(st->enr_old_fx, 0); - st->old_enr_LP_float = fixedToFloat(st->old_enr_LP, Q3); - st->lp_ener_FEC_av_float = fixedToFloat(st->lp_ener_FEC_av, 0); - st->lp_ener_FEC_max_float = fixedToFloat(st->lp_ener_FEC_max, 0); fixedToFloat_arr(st->syn, st->syn_float, 0, M + 1); /* CLDFB */ @@ -3409,16 +3386,6 @@ void acelp_decoder_state_fix2float(Decoder_State *st, STEREO_CNG_DEC_HANDLE hSte st->hTdCngDec->ho_hist_size = st->hTdCngDec->ho_hist_size; st->hTdCngDec->act_cnt2 = st->hTdCngDec->act_cnt2; st->hTdCngDec->act_cnt = st->hTdCngDec->act_cnt; - fixedToFloat_arr(st->hTdCngDec->ho_lsp_circ_fx, st->hTdCngDec->ho_lsp_circ, Q15, HO_HIST_SIZE * M); - fixedToFloat_arr(st->hTdCngDec->ho_lsp_hist_fx, st->hTdCngDec->ho_lsp_hist, Q15, HO_HIST_SIZE * M); - fixedToFloat_arrL(st->hTdCngDec->ho_ener_circ_fx, st->hTdCngDec->ho_ener_circ, Q6, HO_HIST_SIZE); - fixedToFloat_arrL(st->hTdCngDec->ho_ener_hist_fx, st->hTdCngDec->ho_ener_hist, Q6, HO_HIST_SIZE); - fixedToFloat_arrL(st->hTdCngDec->ho_env_circ_fx, st->hTdCngDec->ho_env_circ, Q6, HO_HIST_SIZE * NUM_ENV_CNG); - fixedToFloat_arrL(st->hTdCngDec->ho_env_hist_fx, st->hTdCngDec->ho_env_hist, Q6, HO_HIST_SIZE * NUM_ENV_CNG); - fixedToFloat_arrL(st->hTdCngDec->old_env_fx, st->hTdCngDec->old_env, Q6, 20); - fixedToFloat_arrL(st->hTdCngDec->lp_env_fx, st->hTdCngDec->lp_env, Q6, 20); - fixedToFloat_arr(st->hTdCngDec->exc_mem_fx, st->hTdCngDec->exc_mem, st->Q_exc, 24); - fixedToFloat_arr(st->hTdCngDec->exc_mem1_fx, st->hTdCngDec->exc_mem1, st->Q_exc, 30); } /*WI_DEC_HANDLE*/ @@ -3429,7 +3396,6 @@ void acelp_decoder_state_fix2float(Decoder_State *st, STEREO_CNG_DEC_HANDLE hSte /*TD_BWE_DEC_HANDLE*/ if (st->hBWE_TD) { - fixedToFloat_arr(st->hBWE_TD->cur_sub_Aq_fx, st->hBWE_TD->cur_sub_Aq, Q12, M + 1); fixedToFloat_arr(st->hBWE_TD->old_bwe_exc_extended_fx, st->hBWE_TD->old_bwe_exc_extended, 0, NL_BUFF_OFFSET); } diff --git a/lib_dec/amr_wb_dec.c b/lib_dec/amr_wb_dec.c index 2a0db250d..0b046f119 100644 --- a/lib_dec/amr_wb_dec.c +++ b/lib_dec/amr_wb_dec.c @@ -165,218 +165,10 @@ ivas_error amr_wb_dec_flt( } /* Updates in case of HQ -> AMR-WB IO switching */ -#ifdef IVAS_FLOAT_FIXED_ -#if 1 /*Float to fix conversions*/ - Word16 nchan_out = -1; - Word16 last_element_brate = -1; - Word16 Q_mem_syn2, Q_mem_syn1, Q_mem_syn, Q_agc_mem, Q_syn, Q_pst_old_syn = 0, Q_pst_mem_deemp_err = 0, Q_hb_prev_synth_buffer, Q_mem_hf = 0, Q_mem_syn_hf = 0, Q_mem_hp400 = 0, Q_delay_syn_hf = 0, Q_mem_hp_interp = 0, - Q_old_syn_12k8_16k = 0, Q_prev_env = 0, Q_FBTCXdelayBuf = 15, Q_prev_synth_buffer, Q_syn_Overl = 15, Q_fer_samples = 15, Q_old_syn_Overl = 15, Q_olapBufferAna = 15, Q_old_exc, Q_mem_syn_r = 15, Q_olapBufferSynth = 15, - Q_olapBufferSynth2 = 15, Q_old_synthFB = 15, Q_mem_deemph = 15; /*Initializing with max values to avoid warnings*/ - Q_mem_syn2 = Q_factor_arr( st->mem_syn2, M ); - //Q_mem_syn1 = Q_factor_arr( st->mem_syn1, M ); - Q_mem_syn_r = Q_factor_arr( st->mem_syn_r_float, L_SYN_MEM ); - //Q_mem_syn = s_min( s_min( Q_mem_syn2, Q_mem_syn1 ), Q_mem_syn_r ); - Q_mem_syn = 0; - //Q_agc_mem = Q_factor_arr( st->agc_mem2, 2 ); - Q_syn = Q_factor_arr( st->syn_float, M + 1 ); - Q_mem_deemph = s_min( Q_syn, Q_factor( st->mem_deemph ) ) - 1; - Q_hb_prev_synth_buffer = Q_factor_arr( st->hb_prev_synth_buffer, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); - Q_prev_synth_buffer = Q_factor_arr( st->prev_synth_buffer, 96 ); - floatToFixed_arr16( st->mem_syn2, st->mem_syn2_fx, Q_mem_syn, M ); - //floatToFixed_arr16( st->mem_syn1, st->mem_syn1_fx, Q_mem_syn, M ); - //floatToFixed_arr16( st->agc_mem2, st->agc_mem_fx, Q_agc_mem, 2 ); - floatToFixed_arr16( st->syn_float, st->syn, Q_mem_deemph, M + 1 ); - st->mem_deemph_fx = (Word16) floatToFixed( st->mem_deemph, Q_mem_deemph ); - floatToFixed_arr( st->hb_prev_synth_buffer, st->hb_prev_synth_buffer_fx, Q_hb_prev_synth_buffer, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); - IF( st->hBPF ) - { - Q_pst_old_syn = Q_factor_arrL( st->hBPF->pst_old_syn, NBPSF_PIT_MAX ); - Q_pst_mem_deemp_err = Q_factor_L( st->hBPF->pst_mem_deemp_err ); - floatToFixed_arr32( st->hBPF->pst_old_syn, st->hBPF->pst_old_syn_32, Q_pst_old_syn, NBPSF_PIT_MAX ); - st->hBPF->pst_mem_deemp_err_32 = float_to_fix( st->hBPF->pst_mem_deemp_err, Q_pst_mem_deemp_err ); - } - IF( st->hBWE_zero ) - { - Q_mem_hf = Q_factor_arr( st->hBWE_zero->mem_hf, ( L_FIR - 1 ) ); - Q_mem_syn_hf = Q_factor_arr( st->hBWE_zero->mem_syn_hf, M ); - Q_mem_hp400 = Q_factor_arr( st->hBWE_zero->mem_hp400, 4 ); - Q_delay_syn_hf = Q_factor_arr( st->hBWE_zero->delay_syn_hf, NS2SA( 16000, DELAY_CLDFB_NS ) ); - Q_mem_hp_interp = Q_factor_arr( st->hBWE_zero->mem_hp_interp, INTERP_3_1_MEM_LEN ); - floatToFixed_arr16( st->hBWE_zero->mem_hf, st->hBWE_zero->mem_hf_fx, Q_mem_hf, ( L_FIR - 1 ) ); - floatToFixed_arr16( st->hBWE_zero->mem_syn_hf, st->hBWE_zero->mem_syn_hf_fx, Q_mem_syn_hf, M ); - floatToFixed_arr16( st->hBWE_zero->mem_hp400, st->hBWE_zero->mem_hp400_fx, Q_mem_hp400, 4 ); - floatToFixed_arr16( st->hBWE_zero->delay_syn_hf, st->hBWE_zero->delay_syn_hf_fx, Q_delay_syn_hf, NS2SA( 16000, DELAY_CLDFB_NS ) ); - floatToFixed_arr16( st->hBWE_zero->mem_hp_interp, st->hBWE_zero->mem_hp_interp_fx, Q_mem_hp_interp, INTERP_3_1_MEM_LEN ); - } - IF( st->hBWE_FD ) - { - Q_old_syn_12k8_16k = Q_factor_arr( st->hBWE_FD->old_syn_12k8_16k, 36 ); - floatToFixed_arr16( st->hBWE_FD->old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k_fx, Q_old_syn_12k8_16k, 36 ); - } - IF( st->hHQ_core ) - { - Q_prev_env = Q_factor_arrL( st->hHQ_core->prev_env, SFM_N_WB ); - Q_fer_samples = Q_factor_arr( st->hHQ_core->fer_samples, 960 ); - } - IF( st->hGSCDec ) - { - st->hGSCDec->Last_frame_ener_fx = floatToFixed( st->hGSCDec->Last_frame_ener, 0 ); /*Q-0*/ - } - IF( st->hTcxDec ) - { - Q_FBTCXdelayBuf = Q_factor_arr( st->hTcxDec->FBTCXdelayBuf_float, 111 ); - Q_prev_synth_buffer = s_min( Q_prev_synth_buffer, Q_FBTCXdelayBuf ); - Q_syn_Overl = Q_factor_arr( st->hTcxDec->syn_Overl_float, 320 ); - Q_old_syn_Overl = Q_factor_arr( st->hTcxDec->old_syn_Overl_float, L_FRAME32k / 2 ) - 1; - } - Q_syn_Overl = s_min( Q_fer_samples, Q_syn_Overl ) - 1; - IF( st->hHQ_core ) - { - floatToFixed_arr32( st->hHQ_core->prev_env, st->hHQ_core->prev_env_fx, Q_prev_env, SFM_N_WB ); - floatToFixed_arr32( st->hHQ_core->prev_normq, st->hHQ_core->prev_normq_fx, 14, SFM_N_WB ); /*Q-14*/ - floatToFixed_arr32( st->hHQ_core->last_ni_gain, st->hHQ_core->last_ni_gain_fx, 17, BANDS_MAX ); /*Q-17*/ - floatToFixed_arr16( st->hHQ_core->last_env, st->hHQ_core->last_env_fx, 1, BANDS_MAX ); /*Q-1*/ - floatToFixed_arr32( st->hHQ_core->prev_coeff_out, st->hHQ_core->prev_coeff_out_fx, Q12, L_HQ_WB_BWE ); /*Q-12*/ - floatToFixed_arr16( st->hHQ_core->fer_samples, st->hHQ_core->fer_samples_fx, Q_syn_Overl, 960 ); - st->hHQ_core->memfilt_lb_fx = float_to_fix16( st->hHQ_core->memfilt_lb, 0 ); - st->hHQ_core->mean_prev_hb_fx = float_to_fix( st->hHQ_core->mean_prev_hb, 0 ); - st->hHQ_core->smoothmem_fx = float_to_fix16( st->hHQ_core->smoothmem, 15 ); - st->hHQ_core->mean_prev_fx = floatToFixed( st->hHQ_core->mean_prev, 0 ); - st->hHQ_core->mean_prev_nc_fx = floatToFixed( st->hHQ_core->mean_prev_nc, 0 ); - st->hHQ_core->wmold_hb_fx = float_to_fix16( st->hHQ_core->wmold_hb, 15 ); - } - IF( st->hTcxDec ) - { - floatToFixed_arr16( st->hTcxDec->FBTCXdelayBuf_float, st->hTcxDec->FBTCXdelayBuf, Q_prev_synth_buffer, 111 ); - floatToFixed_arr16( st->hTcxDec->syn_Overl_float, st->hTcxDec->syn_Overl, Q_syn_Overl, 320 ); - floatToFixed_arr16( st->hTcxDec->old_syn_Overl_float, st->hTcxDec->old_syn_Overl, Q_old_syn_Overl, L_FRAME32k / 2 ); - } - floatToFixed_arr16( st->prev_synth_buffer, st->prev_synth_buffer_fx, Q_prev_synth_buffer, 96 ); - IF( st->cldfbAna ) - { - floatToFixed_arr32( st->cldfbAna->cldfb_state, st->cldfbAna->cldfb_state_fx, Q10, st->cldfbAna->cldfb_state_length ); - } - IF( st->cldfbSyn ) - { - floatToFixed_arr32( st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_fx, Q11, st->cldfbSyn->cldfb_state_length ); - } - Word16 Q_mem_syn_clas_estim = Q_factor_arr( st->mem_syn_clas_estim, 258 ) - 1; - floatToFixed_arr16( st->mem_syn_clas_estim, st->mem_syn_clas_estim_fx, Q_mem_syn_clas_estim, 258 ); - FOR( i = 0; i < M; i++ ) - { - st->lsp_old_fx[i] = float_to_fix16(st->lsp_old[i], 15); - st->mem_AR_fx[i] = (Word16)float_to_fix16( ( st->mem_AR[i] * 2.56f ), 0 ); - st->mem_MA_fx[i] = (Word16) ( ( st->mem_MA[i] * 2.56f ) ); - } - IF( st->hFdCngDec ) - { - Q_olapBufferAna = Q_factor_arr( st->hFdCngDec->hFdCngCom->olapBufferAna_flt, FFTLEN ) - 1; - floatToFixed_arr16( st->hFdCngDec->hFdCngCom->olapBufferAna_flt, st->hFdCngDec->hFdCngCom->olapBufferAna_fx, Q_olapBufferAna, L_FRAME32k ); - Q_olapBufferSynth = Q_factor_arrL( st->hFdCngDec->hFdCngCom->olapBufferSynth_flt, 640 ) - 2; - floatToFixed_arr32( st->hFdCngDec->hFdCngCom->olapBufferSynth_flt, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, Q_olapBufferSynth, 640 ); - Q_olapBufferSynth2 = Q_factor_arrL( st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, 640 ) - 1; - floatToFixed_arr32( st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, Q_olapBufferSynth2, 640 ); - } - IF( st->cldfbBPF ) - floatToFixed_arr32( st->cldfbBPF->cldfb_state, st->cldfbBPF->cldfb_state_fx, Q11, st->cldfbBPF->cldfb_state_length ); - //Q_old_exc = Q_factor_arr( st->old_exc, 480 ) - 1; - //floatToFixed_arr16( st->old_exc, st->old_exc_fx, Q_old_exc, 480 ); - floatToFixed_arr32( st->previoussynth, st->previoussynth_fx_32, 0, 960 ); - st->enr_old_fx = (Word32) st->enr_old; - st->log_energy_diff_lt_fx = float_to_fix( st->log_energy_diff_lt, Q15 ); - st->stab_fac_smooth_lt_fx = float_to_fix( st->stab_fac_smooth_lt, Q15 ); - st->lp_ener_fx = float_to_fix( st->lp_ener, Q6 ); - st->lp_gainc_fx = (Word16) L_min( 32767, float_to_fix( st->lp_gainc, 3 ) ); - floatToFixed_arr16( st->mem_syn_r_float, st->mem_syn_r, Q_mem_syn, L_SYN_MEM ); - IF( ( EQ_16( st->core, ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) ) - { - IF( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && LE_32( st->element_brate, IVAS_24k4 ) && GT_32( last_element_brate, IVAS_24k4 ) ) - { - Q_old_synthFB = Q_factor_arr( st->hTcxDec->old_synthFB, st->hTcxDec->old_synth_lenFB ) - 1; - floatToFixed_arr16( st->hTcxDec->old_synthFB, st->hTcxDec->old_synthFB_fx, Q_old_synthFB, st->hTcxDec->old_synth_lenFB ); - } - } -#endif - IF ( ( error = core_switching_pre_dec_ivas_fx( st, output_frame, -1, -1, EVS_MONO, -1 , Q_old_synthFB,&Q_olapBufferSynth, &Q_olapBufferSynth2) ) != IVAS_ERR_OK ) - { - return error; - } -#if 1 /*Fixed to float function changes*/ - //fixedToFloat_arr( st->mem_syn1_fx, st->mem_syn1, Q_mem_syn, M ); - fixedToFloat_arr( st->mem_syn1_fx, st->mem_syn1, -1, M ); - //fixedToFloat_arr( st->agc_mem_fx, st->agc_mem2, Q_agc_mem, 2 ); - st->mem_deemph = fixedToFloat( st->mem_deemph_fx, Q_mem_deemph ); - fixedToFloat_arr( st->hb_prev_synth_buffer_fx, st->hb_prev_synth_buffer, Q_hb_prev_synth_buffer, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); - fixedToFloat_arr( st->prev_synth_buffer_fx, st->prev_synth_buffer, Q_prev_synth_buffer, 96 ); - fixedToFloat_arr( st->mem_syn_clas_estim_fx, st->mem_syn_clas_estim, Q_mem_syn_clas_estim, 258 ); - st->enr_old = fixedToFloat( st->enr_old_fx, 0 ); - st->lp_gainc = fixedToFloat( st->lp_gainc_fx, 3 ); /*Q3*/ - FOR( i = 0; i < M; i++ ) - { - st->mem_MA[i] = (float) ( st->mem_MA_fx[i] / 2.56f ); - st->mem_AR[i] = (float) ( st->mem_AR_fx[i] / 2.56f ); - st->lsp_old[i] = fixedToFloat( st->lsp_old_fx[i], 15 ); - } - fixedToFloat_arr( st->mem_syn_r, st->mem_syn_r_float, Q_mem_syn, L_SYN_MEM ); - fixedToFloat_arr( st->mem_syn2_fx, st->mem_syn2, Q_mem_syn, M ); - //fixedToFloat_arr( st->old_exc_fx, st->old_exc, Q_old_exc, 480 ); - IF( st->hBPF ) - { - fixedToFloat_arrL( st->hBPF->pst_old_syn_32, st->hBPF->pst_old_syn, Q_pst_old_syn, NBPSF_PIT_MAX ); - st->hBPF->pst_mem_deemp_err = fixedToFloat( st->hBPF->pst_mem_deemp_err_32, Q_pst_mem_deemp_err ); - } - IF( st->hGSCDec ) - { - st->hGSCDec->Last_frame_ener = fixedToFloat( st->hGSCDec->Last_frame_ener_fx, 0 ); /*Q-0*/ - } - IF( st->hTcxDec ) - { - fixedToFloat_arr( st->hTcxDec->old_syn_Overl, st->hTcxDec->old_syn_Overl_float, Q_old_syn_Overl, L_FRAME32k / 2 ); - } - IF( st->hBWE_FD ) - fixedToFloat_arr( st->hBWE_FD->old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k, Q_old_syn_12k8_16k, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - IF( st->hBWE_zero ) - { - fixedToFloat_arr( st->hBWE_zero->mem_hf_fx, st->hBWE_zero->mem_hf, Q_mem_hf, ( L_FIR - 1 ) ); - fixedToFloat_arr( st->hBWE_zero->mem_syn_hf_fx, st->hBWE_zero->mem_syn_hf, Q_mem_syn_hf, M ); - fixedToFloat_arr( st->hBWE_zero->mem_hp400_fx, st->hBWE_zero->mem_hp400, Q_mem_hp400, 4 ); - fixedToFloat_arr( st->hBWE_zero->delay_syn_hf_fx, st->hBWE_zero->delay_syn_hf, Q_delay_syn_hf, NS2SA( 16000, DELAY_CLDFB_NS ) ); - fixedToFloat_arr( st->hBWE_zero->mem_hp_interp_fx, st->hBWE_zero->mem_hp_interp, Q_mem_hp_interp, INTERP_3_1_MEM_LEN ); - } - IF( st->cldfbAna ) - fixedToFloat_arrL( st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_state, Q10, st->cldfbAna->cldfb_state_length ); - IF( st->cldfbSyn ) - fixedToFloat_arrL( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_state, Q11, st->cldfbSyn->cldfb_state_length ); - IF( st->cldfbBPF ) - fixedToFloat_arrL( st->cldfbBPF->cldfb_state_fx, st->cldfbBPF->cldfb_state, Q11, st->cldfbBPF->cldfb_state_length ); - IF( st->hHQ_core ) - { - fixedToFloat_arrL( st->hHQ_core->prev_env_fx, st->hHQ_core->prev_env, Q_prev_env, SFM_N_WB ); - fixedToFloat_arrL( st->hHQ_core->prev_normq_fx, st->hHQ_core->prev_normq, 14, SFM_N_WB ); /*Q-14*/ - fixedToFloat_arrL( st->hHQ_core->last_ni_gain_fx, st->hHQ_core->last_ni_gain, 17, BANDS_MAX ); /*Q-17*/ - fixedToFloat_arr( st->hHQ_core->last_env_fx, st->hHQ_core->last_env, 1, BANDS_MAX ); /*Q-1*/ - fixedToFloat_arrL( st->hHQ_core->prev_coeff_out_fx, st->hHQ_core->prev_coeff_out, Q12, L_HQ_WB_BWE ); - st->hHQ_core->memfilt_lb = fixedToFloat( st->hHQ_core->memfilt_lb_fx, 0 ); - st->hHQ_core->mean_prev_hb = fixedToFloat( st->hHQ_core->mean_prev_hb_fx, 0 ); - st->hHQ_core->smoothmem = st->hHQ_core->smoothmem_fx / 32767.f; - st->hHQ_core->mean_prev = fixedToFloat( st->hHQ_core->mean_prev_fx, 0 ); - st->hHQ_core->mean_prev_nc = fixedToFloat( st->hHQ_core->mean_prev_nc_fx, 0 ); - st->hHQ_core->wmold_hb = st->hHQ_core->wmold_hb_fx / 32767.f; - fixedToFloat_arr( st->hHQ_core->fer_samples_fx, st->hHQ_core->fer_samples, Q_syn_Overl, 960 ); - } - IF( st->hFdCngDec ) - { - fixedToFloat_arr( st->hFdCngDec->hFdCngCom->olapBufferAna_fx, st->hFdCngDec->hFdCngCom->olapBufferAna_flt, Q_olapBufferAna, L_FRAME32k ); - fixedToFloat_arrL( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, Q_olapBufferSynth2, L_FRAME32k ); - fixedToFloat_arrL( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_flt, Q_olapBufferSynth, L_FRAME32k ); - } -#endif -#else if ( ( error = core_switching_pre_dec( st, output_frame, -1, -1, EVS_MONO, -1 ) ) != IVAS_ERR_OK ) { return error; } -#endif // IVAS_FLOAT_FIXED last_core_ori = st->last_core; @@ -838,10 +630,7 @@ ivas_error amr_wb_dec_flt( noisy_speech_detection_flt( st->hFdCngDec, st->VAD, 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; -#ifdef IVAS_FLOAT_FIXED - st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx = L_add( Mpy_32_32( Q31_0_99, st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx ), - st->hFdCngDec->hFdCngCom->flag_noisy_speech * Q31_0_01 ); -#endif + st->lp_noise_float = st->hFdCngDec->lp_noise_float; if ( st->flag_cna && ( st->psf_lp_noise >= 15.f ) ) diff --git a/lib_dec/core_dec_init.c b/lib_dec/core_dec_init.c index fab458a20..b01f2d058 100644 --- a/lib_dec/core_dec_init.c +++ b/lib_dec/core_dec_init.c @@ -187,105 +187,7 @@ void open_decoder_LPD_flt( { if (!is_init || st->element_mode != IVAS_CPE_MDCT) { -#ifdef IVAS_FLOAT_FIXED - init_tcx_cfg_fx( st->hTcxCfg, total_brate, st->sr_core, st->output_Fs, st->L_frame, st->bwidth, st->hTcxDec->L_frameTCX, st->fscale, st->preemph_fac, st->tcxonly, st->rf_flag, st->igf, st->hIGFDec->infoIGFStopFreq, st->element_mode, st->ini_frame, MCT_flag, fscaleFB ); - st->hTcxCfg->preemph_fac_flt = st->preemph_fac_float; - st->hTcxCfg->sq_rounding_flt = fix16_to_float( st->hTcxCfg->sq_rounding, 15 ); - st->hTcxCfg->bandwidth_flt = fix16_to_float( st->hTcxCfg->bandwidth, 15 ); - st->hTcxCfg->na_scale_flt = fix16_to_float( st->hTcxCfg->na_scale, 15 ); - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_length / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_window_flt[i] = fix16_to_float( st->hTcxCfg->tcx_mdct_window[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_window_flt[st->hTcxCfg->tcx_mdct_window_length - i - 1] = fix16_to_float( st->hTcxCfg->tcx_mdct_window[i].v.re, 15 ); - } - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_lengthFB / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_windowFB_flt[i] = fix16_to_float( st->hTcxCfg->tcx_mdct_windowFB[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_windowFB_flt[st->hTcxCfg->tcx_mdct_window_lengthFB - i - 1] = fix16_to_float( st->hTcxCfg->tcx_mdct_windowFB[i].v.re, 15 ); - } - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_trans_length / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_window_trans_flt[i] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_trans[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_window_trans_flt[st->hTcxCfg->tcx_mdct_window_trans_length - i - 1] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_trans[i].v.re, 15 ); - } - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_trans_lengthFB / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_window_transFB_flt[i] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_transFB[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_window_transFB_flt[st->hTcxCfg->tcx_mdct_window_trans_lengthFB - i - 1] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_transFB[i].v.re, 15 ); - } - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_half_length / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_window_half_flt[i] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_half[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_window_half_flt[st->hTcxCfg->tcx_mdct_window_half_length - i - 1] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_half[i].v.re, 15 ); - } - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_half_lengthFB / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_window_halfFB_flt[i] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_halfFB[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_window_halfFB_flt[st->hTcxCfg->tcx_mdct_window_half_lengthFB - i - 1] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_halfFB[i].v.re, 15 ); - } - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_min_length / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_window_minimum_flt[i] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_minimum[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_window_minimum_flt[st->hTcxCfg->tcx_mdct_window_min_length - i - 1] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_minimum[i].v.re, 15 ); - } - FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_min_lengthFB / 2; i++ ) - { - st->hTcxCfg->tcx_mdct_window_minimumFB_flt[i] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.im, 15 ); - st->hTcxCfg->tcx_mdct_window_minimumFB_flt[st->hTcxCfg->tcx_mdct_window_min_lengthFB - i - 1] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.re, 15 ); - } - Word16 n = st->L_frame; - Word16 n0 = shr( imult1616( n, 9 ), 5 ); - Word16 n1 = shr( imult1616( n, 23 ), 5 ); /* left slope length */ - Word16 n2 = shr( imult1616( n, 14 ), 5 ); /* right slope length */ - FOR( i = 0; i < n0; i++ ) - { - st->hTcxCfg->tcx_aldo_window_1_flt[i] = fix16_to_float( st->hTcxCfg->tcx_aldo_window_1[i], 15 ); - } - FOR( i = n0; i < n / 2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_1_flt[i] = fix16_to_float( st->hTcxCfg->tcx_aldo_window_1_trunc[i - n0].v.im, 15 ); - } - FOR( i = 0; i < n1 - n / 2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_1_flt[n / 2 + i] = fix16_to_float( st->hTcxCfg->tcx_aldo_window_1_trunc[n1 - n / 2 - 1 - i].v.re, 15 ); - } - FOR( i = 0; i < n2 / 2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_2_flt[i] = fix16_to_float( st->hTcxCfg->tcx_aldo_window_2[i].v.im, 15 ); - } - FOR( i = n2 / 2; i < n2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_2_flt[i] = fix16_to_float( st->hTcxCfg->tcx_aldo_window_2[n2 - i - 1].v.re, 15 ); - } - n = NS2SA_fx2( st->output_Fs, FRAME_SIZE_NS ); - n0 = shr( imult1616( n, 9 ), 5 ); - n1 = shr( imult1616( n, 23 ), 5 ); /* left slope length */ - n2 = shr( imult1616( n, 14 ), 5 ); /* right slope length */ - FOR( i = 0; i < n0; i++ ) - { - st->hTcxCfg->tcx_aldo_window_1_FB_flt[i] = fix16_to_float( st->hTcxCfg->tcx_aldo_window_1_FB[i], 15 ); - } - FOR( i = n0; i < n / 2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_1_FB_flt[i] = fix16_to_float( st->hTcxCfg->tcx_aldo_window_1_FB_trunc[i - n0].v.im, 15 ); - } - FOR( i = 0; i < n1 - n / 2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_1_FB_flt[n / 2 + i] = fix16_to_float( st->hTcxCfg->tcx_aldo_window_1_FB_trunc[n1 - n / 2 - i - 1].v.re, 15 ); - } - FOR( i = 0; i < n2 / 2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_2_FB_flt[i] = fix16_to_float( st->hTcxCfg->tcx_aldo_window_2_FB[i].v.im, 15 ); - } - FOR( i = n2 / 2; i < n2; i++ ) - { - st->hTcxCfg->tcx_aldo_window_2_FB_flt[i] = fix16_to_float( st->hTcxCfg->tcx_aldo_window_2_FB[n2 - i - 1].v.re, 15 ); - } - st->hTcxCfg->tcx_aldo_window_1_trunc_flt = st->hTcxCfg->tcx_aldo_window_1_flt + NS2SA( st->sr_core, N_ZERO_MDCT_NS ); - st->hTcxCfg->tcx_aldo_window_1_FB_trunc_flt = st->hTcxCfg->tcx_aldo_window_1_FB_flt + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ); -#else init_tcx_cfg(st->hTcxCfg, total_brate, st->sr_core, st->output_Fs, st->L_frame, st->bwidth, st->hTcxDec->L_frameTCX, st->fscale, encoderLookahead, encoderLookaheadFB, st->preemph_fac_float, st->tcxonly, st->rf_flag, st->igf, st->hIGFDec->infoIGFStopFreq, st->element_mode, st->ini_frame, MCT_flag); -#endif } else { @@ -318,15 +220,7 @@ void open_decoder_LPD_flt( if (st->hTcxDec != NULL) { -#ifdef IVAS_FLOAT_FIXED - reset_tcx_overl_buf_fx( st->hTcxDec ); - fixedToFloat_arr( hTcxDec->old_syn_Overl, hTcxDec->old_syn_Overl_float, 0, L_FRAME32k / 2 ); - fixedToFloat_arr( hTcxDec->syn_Overl_TDAC, hTcxDec->syn_Overl_TDAC_float, 0, L_FRAME32k / 2 ); - fixedToFloat_arr( hTcxDec->syn_Overl, hTcxDec->syn_Overl_float, 0, L_FRAME32k / 2 ); - fixedToFloat_arr( hTcxDec->syn_Overl_TDACFB, hTcxDec->syn_Overl_TDACFB_float, 0, L_FRAME_MAX / 2 ); -#else reset_tcx_overl_buf(st->hTcxDec); -#endif // IVAS_FLOAT_FIXED set_zero(st->hTcxDec->syn_OverlFB_float, L_FRAME_MAX / 2); set_zero(st->hTcxDec->old_synth_float, OLD_SYNTH_INTERNAL_DEC); @@ -386,30 +280,7 @@ void open_decoder_LPD_flt( { /* Switching from Mode 1 ACELP */ st->last_core_bfi = ACELP_CORE; -#ifdef IVAS_FLOAT_FIXED - Word16 delay_comp = NS2SA_fx2( st->output_Fs, DELAY_CLDFB_NS ); /*CLDFB delay*/ - Word16 Q_fer_samples = Q_factor_arr( st->hHQ_core->fer_samples + delay_comp, shr( st->hTcxDec->L_frameTCX, 1 ) ) - 1; - IF( st->prev_bfi != 0 && st->hTcxCfg != NULL ) - { - floatToFixed_arr( st->hHQ_core->fer_samples + delay_comp, st->hHQ_core->fer_samples_fx + delay_comp, Q_fer_samples, shr( st->hTcxDec->L_frameTCX, 1 ) ); - floatToFixed_arr( st->hTcxDec->syn_OverlFB_float, st->hTcxDec->syn_OverlFB, Q_fer_samples, L_FRAME_MAX / 2 ); - floatToFixed_arr( st->hTcxDec->syn_Overl_float, st->hTcxDec->syn_Overl, Q_fer_samples, L_FRAME32k / 2 ); - floatToFixed_arr( st->hHQ_core->old_out, st->hHQ_core->old_out_fx, Q_fer_samples - 1, L_FRAME48k ); - floatToFixed_arr( st->hHQ_core->old_outLB, st->hHQ_core->old_out_LB_fx, Q_fer_samples - 1, L_FRAME32k ); - floatToFixed_arr( st->hTcxDec->syn_Overl_TDACFB_float, st->hTcxDec->syn_Overl_TDACFB, Q_fer_samples - 1, L_FRAME_MAX / 2 ); - floatToFixed_arr( st->hTcxDec->syn_Overl_TDAC_float, st->hTcxDec->syn_Overl_TDAC, Q_fer_samples - 1, L_FRAME32k / 2 ); - acelp_plc_mdct_transition_fx( st ); - fixedToFloat_arr( st->hTcxDec->syn_OverlFB, st->hTcxDec->syn_OverlFB_float, Q_fer_samples, L_FRAME_MAX / 2 ); - fixedToFloat_arr( st->hTcxDec->syn_Overl, st->hTcxDec->syn_Overl_float, Q_fer_samples, L_FRAME32k / 2 ); - fixedToFloat_arr( st->hHQ_core->old_out_fx, st->hHQ_core->old_out, Q_fer_samples - 1, L_FRAME48k ); - fixedToFloat_arr( st->hHQ_core->old_out_LB_fx, st->hHQ_core->old_outLB, Q_fer_samples - 1, L_FRAME32k ); - fixedToFloat_arr( st->hTcxDec->syn_Overl_TDACFB, st->hTcxDec->syn_Overl_TDACFB_float, Q_fer_samples - 1, L_FRAME_MAX / 2 ); - fixedToFloat_arr( st->hTcxDec->syn_Overl_TDAC, st->hTcxDec->syn_Overl_TDAC_float, Q_fer_samples - 1, L_FRAME32k / 2 ); - } -#else acelp_plc_mdct_transition(st); - -#endif // IVAS_FLOAT_FIXED } if (st->last_codec_mode == MODE2 && @@ -435,16 +306,8 @@ void open_decoder_LPD_flt( /*OLA -> zero */ if (st->hTcxDec != NULL) { -#ifdef IVAS_FLOAT_FIXED - reset_tcx_overl_buf_fx( st->hTcxDec ); - fixedToFloat_arr( hTcxDec->old_syn_Overl, hTcxDec->old_syn_Overl_float, 0, L_FRAME32k / 2 ); - fixedToFloat_arr( hTcxDec->syn_Overl_TDAC, hTcxDec->syn_Overl_TDAC_float, 0, L_FRAME32k / 2 ); - fixedToFloat_arr( hTcxDec->syn_Overl, hTcxDec->syn_Overl_float, 0, L_FRAME32k / 2 ); - fixedToFloat_arr( hTcxDec->syn_Overl_TDACFB, hTcxDec->syn_Overl_TDACFB_float, 0, L_FRAME_MAX / 2 ); -#else reset_tcx_overl_buf(st->hTcxDec); -#endif // IVAS_FLOAT_FIXED } if (st->hTcxCfg != NULL) @@ -468,26 +331,12 @@ void open_decoder_LPD_flt( } /* reset CLDFB memories */ -#ifdef IVAS_FLOAT_FIXED - cldfb_reset_memory_fx( st->cldfbAna ); - fixedToFloat_arrL( st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_state, 0, st->cldfbAna->cldfb_state_length ); - cldfb_reset_memory_fx( st->cldfbBPF ); - fixedToFloat_arrL( st->cldfbBPF->cldfb_state_fx, st->cldfbBPF->cldfb_state, 0, st->cldfbBPF->cldfb_state_length ); - cldfb_reset_memory_fx( st->cldfbSyn ); - fixedToFloat_arrL( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_state, 0, st->cldfbSyn->cldfb_state_length ); -#else cldfb_reset_memory_ivas(st->cldfbAna); cldfb_reset_memory_ivas(st->cldfbBPF); cldfb_reset_memory_ivas(st->cldfbSyn); -#endif // IVAS_FLOAT_FIXED if (st->cldfbSynHB != NULL) { -#ifdef IVAS_FLOAT_FIXED - cldfb_reset_memory_fx( st->cldfbSynHB ); - fixedToFloat_arrL( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->cldfb_state, 0, st->cldfbSynHB->cldfb_state_length ); -#else cldfb_reset_memory_ivas(st->cldfbSynHB); -#endif } } else if ((st->L_frame != st->last_L_frame) && (st->L_frame <= L_FRAME16k) && (st->last_L_frame <= L_FRAME16k)) /* Rate switching between 12.8 and 16 kHz*/ @@ -701,23 +550,6 @@ void open_decoder_LPD_flt( if (is_init || MCT_flag || !(st->element_mode == IVAS_CPE_MDCT && st->element_mode == last_element_mode)) { -#ifdef IVAS_FLOAT_FIXED - st->hTcxDec->CngLevelBackgroundTrace_bfi_fx = PLC_MIN_CNG_LEV; - st->hTcxDec->CngLevelBackgroundTrace_bfi_exp = 16; - - hTcxDec->conCngLevelBackgroundTrace = PLC_MIN_CNG_LEV; /*Q15*/ move16(); - hTcxDec->conNoiseLevelIndex = PLC_MIN_STAT_BUFF_SIZE - 1; - move16(); - hTcxDec->conCurrLevelIndex = 0; - move16(); - hTcxDec->conLastFrameLevel = PLC_MIN_CNG_LEV; /*Q15*/ move16(); - set16_fx(hTcxDec->conNoiseLevelMemory, PLC_MIN_CNG_LEV, PLC_MIN_STAT_BUFF_SIZE); /*Q15*/ - set16_fx(hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE); - hTcxDec->conLastFrameLevel_e = 0; - hTcxDec->conCngLevelBackgroundTrace_e = 0; - - hTcxDec->cummulative_damping_tcx = 32767/*1.0f Q15*/; -#endif // IVAS_FLOAT_FIXED st->hTcxDec->CngLevelBackgroundTrace_bfi = PLC_MIN_CNG_LEV_FLT; st->hTcxDec->NoiseLevelIndex_bfi = PLC_MIN_STAT_BUFF_SIZE - 1; st->hTcxDec->CurrLevelIndex_bfi = 0; @@ -754,20 +586,7 @@ void open_decoder_LPD_flt( /* TCX-LTP */ if (hTcxLtpDec != NULL) { -#ifdef IVAS_FLOAT_FIXED - tcxltp_dec_init_fx( hTcxLtpDec, st->ini_frame, st->last_codec_mode, st->element_mode, st->pit_max, st->sr_core ); - IF( st->ini_frame == 0 || ( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) ) - { - IF( st->ini_frame == 0 ) - { - fixedToFloat_arr( hTcxLtpDec->tcxltp_mem_in, hTcxLtpDec->tcxltp_mem_in_float, 0, TCXLTP_MAX_DELAY ); - fixedToFloat_arr( hTcxLtpDec->tcxltp_mem_out, hTcxLtpDec->tcxltp_mem_out_float, 0, L_FRAME48k ); - hTcxLtpDec->tcxltp_gain_post_prev_float = fixedToFloat( hTcxLtpDec->tcxltp_gain_post_prev, 0 ); - } - } -#else tcxltp_dec_init(hTcxLtpDec, st->ini_frame, st->last_codec_mode, st->element_mode, st->pit_max, st->sr_core); -#endif // IVAS_FLOAT_FIXED } /* TCX */ @@ -794,17 +613,11 @@ void open_decoder_LPD_flt( if (st->tcxonly) { st->p_bpf_noise_buf_float = NULL; -#ifdef IVAS_FLOAT_FIXED - st->p_bpf_noise_buf_32 = NULL; -#endif } else { st->p_bpf_noise_buf_float = st->bpf_noise_buf_float; -#ifdef IVAS_FLOAT_FIXED - st->p_bpf_noise_buf_32 = st->bpf_noise_buf_32; -#endif } @@ -851,29 +664,7 @@ void open_decoder_LPD_flt( st->hTonalMDCTConc->lastBlockData.tonalConcealmentActive = 0; st->hTonalMDCTConc->lastBlockData.nSamples = 0; -#ifdef IVAS_FLOAT_FIXED - TonalMDCTConceal_Init_ivas_fx( st->hTonalMDCTConc, st->hTcxDec->L_frameTCX, st->L_frame, FDNS_NPTS, st->hTcxCfg ); - st->hTonalMDCTConc->lastBlockData.spectralData_float = st->hTonalMDCTConc->spectralDataBuffers_float[0]; - st->hTonalMDCTConc->secondLastBlockData.spectralData_float = st->hTonalMDCTConc->spectralDataBuffers_float[1]; - st->hTonalMDCTConc->secondLastPowerSpectrum_float = st->hTonalMDCTConc->secondLastBlockData.spectralData_float; - st->hTonalMDCTConc->lastBlockData.scaleFactors_float = st->hTonalMDCTConc->scaleFactorsBuffers_float[0]; - st->hTonalMDCTConc->secondLastBlockData.scaleFactors_float = st->hTonalMDCTConc->scaleFactorsBuffers_float[1]; - st->hTonalMDCTConc->pTCI_float = (TonalComponentsInfo_float *) st->hTonalMDCTConc->timeDataBuffer_float; - st->hTonalMDCTConc->lastPitchLag_float = 0; - FOR( i = 0; i < FDNS_NPTS; i++ ) - { - st->hTonalMDCTConc->scaleFactorsBackground_flt[i] = fix16_to_float( st->hTonalMDCTConc->scaleFactorsBackground[i], 15 ); - } - st->hTonalMDCTConc->scf_fadeout_flt = 1.0f; - st->hTonalMDCTConc->last_block_nrg_flt = 0.0f; - st->hTonalMDCTConc->curr_noise_nrg_flt = 0.0f; - st->hTonalMDCTConc->faded_signal_nrg_flt = 0.0f; - st->hTonalMDCTConc->secondLastPcmOut_float = &st->hTonalMDCTConc->timeDataBuffer_float[( 3 * L_FRAME_MAX ) / 2 - imult1616( 3, shr( s_min( L_FRAME_MAX, st->hTcxDec->L_frameTCX ), 1 ) )]; - st->hTonalMDCTConc->lastPcmOut_float = &st->hTonalMDCTConc->timeDataBuffer_float[( 3 * L_FRAME_MAX ) / 2 - s_min( L_FRAME_MAX, st->hTcxDec->L_frameTCX )]; - assert( sizeof( *st->hTonalMDCTConc->pTCI_float ) <= ( st->hTonalMDCTConc->lastPcmOut_float - st->hTonalMDCTConc->timeDataBuffer_float ) * sizeof( st->hTonalMDCTConc->timeDataBuffer_float[0] ) ); -#else - TonalMDCTConceal_Init_ivas(st->hTonalMDCTConc, st->hTcxDec->L_frameTCX, st->L_frame, FDNS_NPTS, st->hTcxCfg); -#endif // IVAS_FLOAT_FIXED + TonalMDCTConceal_Init_ivas(st->hTonalMDCTConc, st->hTcxDec->L_frameTCX, st->L_frame, FDNS_NPTS, st->hTcxCfg); } st->last_tns_active = 0; diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index b9aee1ac9..79717cbbc 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -1839,7 +1839,8 @@ void open_decoder_LPD_ivas_fx( st->hTonalMDCTConc->secondLastPowerSpectrum_float = st->hTonalMDCTConc->secondLastBlockData.spectralData_float; st->hTonalMDCTConc->lastBlockData.scaleFactors_float = st->hTonalMDCTConc->scaleFactorsBuffers_float[0]; st->hTonalMDCTConc->secondLastBlockData.scaleFactors_float = st->hTonalMDCTConc->scaleFactorsBuffers_float[1]; - st->hTonalMDCTConc->pTCI_float = (TonalComponentsInfo_float *) st->hTonalMDCTConc->timeDataBuffer_float; + //st->hTonalMDCTConc->pTCI_float = (TonalComponentsInfo_float *) st->hTonalMDCTConc->timeDataBuffer_float; + st->hTonalMDCTConc->pTCI_float = &st->hTonalMDCTConc->pTCI_float1; st->hTonalMDCTConc->lastPitchLag_float = 0; st->hTonalMDCTConc->scf_fadeout_flt = 1.0f; st->hTonalMDCTConc->last_block_nrg_flt = 0.0f; diff --git a/lib_dec/core_dec_reconf.c b/lib_dec/core_dec_reconf.c index 90153996a..56af9cc81 100644 --- a/lib_dec/core_dec_reconf.c +++ b/lib_dec/core_dec_reconf.c @@ -72,7 +72,11 @@ void reconfig_decoder_LPD_ivas( st->narrowBand = 0; } - BITS_ALLOC_init_config_acelp( st->total_brate, st->narrowBand, st->nb_subfr, &( st->acelp_cfg ) ); +#ifdef IVAS_FLOAT_FIXED + BITS_ALLOC_init_config_acelp(st->total_brate, st->narrowBand, st->nb_subfr, &(st->acelp_cfg)); +#endif // IVAS_Fixed + BITS_ALLOC_init_config_acelp_IVAS( st->total_brate, st->narrowBand, st->nb_subfr, &( st->acelp_cfg ) ); + /*Configuration of partial copy*/ st->acelp_cfg_rf.mode_index = 1; diff --git a/lib_dec/core_dec_reconf_fx.c b/lib_dec/core_dec_reconf_fx.c index a0eb87715..f4b09749a 100644 --- a/lib_dec/core_dec_reconf_fx.c +++ b/lib_dec/core_dec_reconf_fx.c @@ -91,10 +91,6 @@ void reconfig_decoder_LPD_ivas_fx( } } } - IF( st->hTcxCfg != NULL ) - { - st->hTcxCfg->na_scale_flt = fixedToFloat( st->hTcxCfg->na_scale, 15 ); - } /*if its not the first frame resample overlap buffer to new sampling rate */ IF( NE_16(st->ini_frame , 0 )) { diff --git a/lib_dec/core_dec_switch.c b/lib_dec/core_dec_switch.c index ee8ae2088..2d4d460c3 100644 --- a/lib_dec/core_dec_switch.c +++ b/lib_dec/core_dec_switch.c @@ -46,6 +46,24 @@ * * *-------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void open_decoder_LPD_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 total_brate, /* i : total bitrate */ + const Word32 last_total_brate, /* i : last total bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ + const Word16 last_element_mode, /* i : last element mode */ + const Word16 is_init, /* i : indicate call from init_decoder() to avoid double TC initialization */ + Word16* Q_syn_Overl_TDAC, + Word16* Q_fer_samples, + Word16* Q_syn_Overl, + Word16* Q_syn_Overl_TDACFB, + Word16* Q_syn_OverlFB, + Word16* Q_old_out, + Word16* Q_old_outLB, + Word16* Q_old_Aq_12_8); +#endif // IVAS_FLOAT_FIXED void mode_switch_decoder_LPD_flt( Decoder_State *st, /* i/o: decoder state structure */ @@ -103,6 +121,11 @@ void mode_switch_decoder_LPD_flt( if ( fscale != st->fscale || switchWB || bSwitchFromAmrwbIO || st->last_codec_mode == MODE1 || st->force_lpd_reset ) { + /* Init Decoder */ + Word16 Q_syn_Overl_TDAC = 0, Q_fer_samples = 0, Q_syn_Overl = 0, Q_syn_Overl_TDACFB = 0, Q_syn_OverlFB = 0, Q_old_out = 0, Q_old_outLB = 0, Q_old_Aq_12_8 = 0; +#ifdef IVAS_FLOAT_FIXED + open_decoder_LPD_ivas_fx(st, total_brate, last_total_brate, bwidth, MCT_flag, last_element_mode, 0, &Q_syn_Overl_TDAC, &Q_fer_samples, &Q_syn_Overl, &Q_syn_Overl_TDACFB, &Q_syn_OverlFB, &Q_old_out, &Q_old_outLB, &Q_old_Aq_12_8); +#endif open_decoder_LPD_flt( st, total_brate, last_total_brate, bwidth, MCT_flag, last_element_mode, 0 ); } else diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index e878a1cba..0d05192ac 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -577,9 +577,9 @@ ivas_error core_switching_pre_dec_ivas_fx( st->hHQ_core->no_att_hangover = 0; move16(); #if 1 /*To be removed later: Floating point initialization*/ - st->hHQ_core->energy_lt = 300.0f; - set_f( st->hHQ_core->prev_noise_level, 0.0f, 2 ); - st->hHQ_core->prev_ni_ratio = 0.5f; + //st->hHQ_core->energy_lt = 300.0f; + //set_f( st->hHQ_core->prev_noise_level, 0.0f, 2 ); + //st->hHQ_core->prev_ni_ratio = 0.5f; set_f( st->hHQ_core->prev_En_sb, 0.0f, NB_SWB_SUBBANDS ); #endif st->hHQ_core->energy_lt_fx = 2457600;/*300.0f Q13*/ diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index e5064a1fe..f20061d4e 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -2017,8 +2017,8 @@ ivas_error core_switching_post_dec_ivas_fx( set16_fx( st_fx->GainShape_Delay, 0, NUM_SHB_SUBFR / 2 ); swb_tbe_reset_synth_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx ); - st_fx->hBWE_TD->prev_pow_exc16kWhtnd_fx = 32767; /*Q15 1.f*/ - st_fx->hBWE_TD->prev_mix_factor_fx = 32767; /*Q15 1.f*/ + st_fx->hBWE_TD->prev_pow_exc16kWhtnd_fx32 = 1; /* Q0 1.f */ + st_fx->hBWE_TD->prev_mix_factor_fx = 32767; /* Q15 1.f */ IF( EQ_16( output_frame, L_FRAME16k ) ) { diff --git a/lib_dec/dec_LPD.c b/lib_dec/dec_LPD.c index 4ce51f46b..bcba3ef8e 100644 --- a/lib_dec/dec_LPD.c +++ b/lib_dec/dec_LPD.c @@ -589,97 +589,7 @@ void decoder_LPD_flt( } /* TCX decoder */ -#ifdef IVAS_FLOAT_FIXED - Word16 synth_fx[L_FRAME48k], synthFB_fx[L_FRAME48k], Aq_fx[(NB_SUBFR16k + 1) * (M + 1)]; - floatToFixed_arr(synth, synth_fx, 0, st->L_frame); - floatToFixed_arr(synthFB, synthFB_fx, 0, hTcxDec->L_frameTCX); - floatToFixed_arr(Aq, Aq_fx, Q12, M+1); - st->preemph_fac = float_to_fix16(st->preemph_fac_float, Q15); - st->hTcxLtpDec->tcxltp_gain = float_to_fix16( st->hTcxLtpDec->tcxltp_gain_float, Q15 ); - st->hTcxDec->cummulative_damping_tcx = float_to_fix16( st->hTcxDec->cummulative_damping_tcx_float, Q15 ); - - st->gamma = float_to_fix16(st->gamma_float, Q15); - //st->preemph_fac = float_to_fix16( st->preemph_fac_float, Q15 ); - st->hTcxDec->cummulative_damping_tcx = float_to_fix16(st->hTcxDec->cummulative_damping_tcx_float, Q15); - st->Mode2_lp_gainp = float_to_fix(st->lp_gainp, Q16); - st->hTcxCfg->na_scale = float_to_fix16(st->hTcxCfg->na_scale_flt, Q15); - st->hTcxCfg->sq_rounding = float_to_fix16(st->hTcxCfg->sq_rounding_flt, Q15); - st->hTcxLtpDec->tcxltp_gain = float_to_fix16(st->hTcxLtpDec->tcxltp_gain_float, Q15); - st->inv_gamma = FL2WORD16_SCALE(1 / st->gamma_float, 1); - st->hTcxCfg->preemph_fac = FL2WORD16(st->hTcxCfg->preemph_fac_flt); - f2me_16(st->last_gain_syn_deemph_float, &st->last_gain_syn_deemph, &st->last_gain_syn_deemph_e); - f2me_16(st->last_concealed_gain_syn_deemph_float, &st->last_concealed_gain_syn_deemph, &st->last_concealed_gain_syn_deemph_e); - f2me_16(st->hTcxDec->old_gaintcx_bfi_float, &st->hTcxDec->old_gaintcx_bfi, &st->hTcxDec->old_gaintcx_bfi_e); - - FOR(Word16 l = 0; l < N_LTP_GAIN_MEMS; l++) - { - st->hTcxDec->ltpGainMemory_fx[l] = float_to_fix16(st->hTcxDec->ltpGainMemory[l], Q15); - } - st->hTcxDec->tcxltp_last_gain_unmodified = float_to_fix16(st->hTcxDec->tcxltp_last_gain_unmodified_float, Q15); - st->old_fpitch = float_to_fix(st->old_fpitch_float, Q16); - st->hTonalMDCTConc->lastPitchLag = float_to_fix(st->hTonalMDCTConc->lastPitchLag_float, Q16); - IF( bfi && st->tonal_mdct_plc_active && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - FOR( Word16 ii = 0; ii < st->hTonalMDCTConc->pTCI_float->numIndexes; ii++ ) - { - float pd = st->hTonalMDCTConc->pTCI_float->phaseDiff_float[ii]; - if ( pd >= PI2 ) - pd = fmodf( pd, PI2 ) - PI2; - st->hTonalMDCTConc->pTCI_fix->phaseDiff[ii] = float_to_fix16( pd, Q12 ); - } - FOR( Word16 ii = 0; ii < MAX_NUMBER_OF_IDX * GROUP_LENGTH; ii++ ) - { - float pd = st->hTonalMDCTConc->pTCI_float->phase_currentFramePredicted_float[ii]; - pd = fmodf( pd, PI2 ); - st->hTonalMDCTConc->pTCI_fix->phase_currentFramePredicted[ii] = (Word16) ( pd * ( 1u << Q13 ) ); - } - } - IF(bfi && st->tonal_mdct_plc_active && NE_16(st->element_mode, IVAS_CPE_MDCT)) - { - FOR(Word16 i = 0; i < FDNS_NPTS; i++) - { - f2me_16(st->hTonalMDCTConc->secondLastBlockData.scaleFactors_float[i], &st->hTonalMDCTConc->secondLastBlockData.scaleFactors[i], &st->hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i]); - st->hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e = s_max(st->hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e, st->hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i]); - } - } - - IF(st->enablePlcWaveadjust) - { - f2me_buf(st->hPlcInfo->data_reci2, st->hPlcInfo->data_reci2_fx, &st->hPlcInfo->data_reci2_scale, st->hPlcInfo->L_frameTCX); - } - - // u8bit to 16bit - FOR(int l = 0; l < IGF_START_MX; l++) - { - st->hIGFDec->infoTCXNoise_evs[l] = (Word16)st->hIGFDec->infoTCXNoise[l]; - } - st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = float_to_fix16(st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt, 15); - - //decoder_tcx_fx( st, prm, Aq, Aind, &synth[0], &synthFB[0], bfi, 0, 0 ); - decoder_tcx_fx( st, prm, Aq_fx, Aind, &synth_fx[0], &synthFB_fx[0], bfi, 0, 0 ); - - fixedToFloat_arr(synth_fx, synth, 0, st->L_frame); - fixedToFloat_arr(synthFB_fx, synthFB, 0, hTcxDec->L_frameTCX); - FOR( Word16 l = 0; l < N_LTP_GAIN_MEMS; l++ ) - { - st->hTcxDec->ltpGainMemory[l] = fix16_to_float( st->hTcxDec->ltpGainMemory_fx[l], Q15 ); - } - st->hTonalMDCTConc->lastPitchLag_float = fix_to_float(st->hTonalMDCTConc->lastPitchLag, Q16); - st->hTonalMDCTConc->nFramesLost_float = fix16_to_float(st->hTonalMDCTConc->nFramesLost, Q1); - // 16bit to u8bit - FOR(Word16 l = 0; l < IGF_START_MX; l++) - { - st->hIGFDec->infoTCXNoise[l] = (uint8_t)st->hIGFDec->infoTCXNoise_evs[l]; - } - me2f_buf(st->hIGFDec->virtualSpec, st->hIGFDec->virtualSpec_e, st->hIGFDec->virtualSpecBuf, (N_MAX_TCX - IGF_START_MN)); - st->hTcxDec->tcxltp_third_last_pitch_float = fix_to_float(st->hTcxDec->tcxltp_third_last_pitch, 16); - st->hTcxDec->tcxltp_second_last_pitch_float = fix_to_float(st->hTcxDec->tcxltp_second_last_pitch, 16); - st->old_fpitch_float = fix_to_float(st->old_fpitch, 16); - st->old_fpitchFB_float = fix_to_float(st->old_fpitchFB, 16); - -#else decoder_tcx_flt( st, prm, Aq, Aind, &synth[0], &synthFB[0], bfi, 0, 0 ); -#endif } /*--------------------------------------------------------------------------------* @@ -705,95 +615,7 @@ void decoder_LPD_flt( IGFDecRestoreTCX10SubFrameData_flt( st->hIGFDec, k ); /* TCX decoder */ -#ifdef IVAS_FLOAT_FIXED - Word16 synth_fx[L_FRAME48k], synthFB_fx[L_FRAME48k], Aq_fx[(NB_SUBFR16k + 1) * (M + 1)]; - floatToFixed_arr(synth, synth_fx, 0, st->L_frame + k * L_frame / 2); - floatToFixed_arr(synthFB, synthFB_fx, 0, hTcxDec->L_frameTCX + k * L_frameTCX / 2); - floatToFixed_arr(Aq, Aq_fx, Q12, M + 1); - st->preemph_fac = float_to_fix16(st->preemph_fac_float, Q15); - st->hTcxLtpDec->tcxltp_gain = float_to_fix16( st->hTcxLtpDec->tcxltp_gain_float, Q15 ); - st->hTcxDec->cummulative_damping_tcx = float_to_fix16( st->hTcxDec->cummulative_damping_tcx_float, Q15 ); - - st->gamma = float_to_fix16(st->gamma_float, Q15); - //st->preemph_fac = float_to_fix16( st->preemph_fac_float, Q15 ); - st->hTcxDec->cummulative_damping_tcx = float_to_fix16(st->hTcxDec->cummulative_damping_tcx_float, Q15); - st->Mode2_lp_gainp = float_to_fix(st->lp_gainp, Q16); - st->hTcxCfg->na_scale = float_to_fix16(st->hTcxCfg->na_scale_flt, Q15); - st->hTcxCfg->sq_rounding = float_to_fix16(st->hTcxCfg->sq_rounding_flt, Q15); - st->hTcxLtpDec->tcxltp_gain = float_to_fix16(st->hTcxLtpDec->tcxltp_gain_float, Q15); - st->inv_gamma = FL2WORD16_SCALE(1 / st->gamma_float, 1); - st->hTcxCfg->preemph_fac = FL2WORD16(st->hTcxCfg->preemph_fac_flt); - f2me_16(st->last_gain_syn_deemph_float, &st->last_gain_syn_deemph, &st->last_gain_syn_deemph_e); - f2me_16(st->last_concealed_gain_syn_deemph_float, &st->last_concealed_gain_syn_deemph, &st->last_concealed_gain_syn_deemph_e); - f2me_16(st->hTcxDec->old_gaintcx_bfi_float, &st->hTcxDec->old_gaintcx_bfi, &st->hTcxDec->old_gaintcx_bfi_e); - FOR( Word16 l = 0; l < N_LTP_GAIN_MEMS; l++ ) - { - st->hTcxDec->ltpGainMemory_fx[l] = float_to_fix16( st->hTcxDec->ltpGainMemory[l], Q15 ); - } - st->hTcxDec->tcxltp_last_gain_unmodified = float_to_fix16( st->hTcxDec->tcxltp_last_gain_unmodified_float, Q15 ); - st->old_fpitch = float_to_fix( st->old_fpitch_float, Q16 ); - st->hTonalMDCTConc->lastPitchLag = float_to_fix(st->hTonalMDCTConc->lastPitchLag_float, Q16); - IF( bfi && st->tonal_mdct_plc_active && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - FOR( Word16 ii = 0; ii < st->hTonalMDCTConc->pTCI_float->numIndexes; ii++ ) - { - float pd = st->hTonalMDCTConc->pTCI_float->phaseDiff_float[ii]; - if ( pd >= PI2 ) - pd = fmodf( pd, PI2 ) - PI2; - st->hTonalMDCTConc->pTCI_fix->phaseDiff[ii] = float_to_fix16( pd, Q12 ); - } - FOR( Word16 ii = 0; ii < MAX_NUMBER_OF_IDX * GROUP_LENGTH; ii++ ) - { - float pd = st->hTonalMDCTConc->pTCI_float->phase_currentFramePredicted_float[ii]; - pd = fmodf( pd, PI2 ); - st->hTonalMDCTConc->pTCI_fix->phase_currentFramePredicted[ii] = (Word16) ( pd * ( 1u << Q13 ) ); - } - } - IF(bfi && st->tonal_mdct_plc_active && NE_16(st->element_mode, IVAS_CPE_MDCT)) - { - FOR(Word16 i = 0; i < FDNS_NPTS; i++) - { - f2me_16(st->hTonalMDCTConc->secondLastBlockData.scaleFactors_float[i], &st->hTonalMDCTConc->secondLastBlockData.scaleFactors[i], &st->hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i]); - st->hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e = s_max(st->hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e, st->hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i]); - } - } - - IF(st->enablePlcWaveadjust) - { - f2me_buf(st->hPlcInfo->data_reci2, st->hPlcInfo->data_reci2_fx, &st->hPlcInfo->data_reci2_scale, st->hPlcInfo->L_frameTCX); - } - - // u8bit to 16bit - FOR(int l = 0; l < IGF_START_MX; l++) - { - st->hIGFDec->infoTCXNoise_evs[l] = (Word16)st->hIGFDec->infoTCXNoise[l]; - } - st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = float_to_fix16(st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt, 15); - - //decoder_tcx_fx( st, prm, Aq, Aind, &synth[k * L_frame / 2], &synthFB[k * L_frameTCX / 2], bfi, k, 0 ); - decoder_tcx_fx( st, prm, Aq_fx, Aind, &synth_fx[k * L_frame / 2], &synthFB_fx[k * L_frameTCX / 2], bfi, k, 0 ); - - fixedToFloat_arr(synth_fx, synth, 0, st->L_frame + k * L_frame / 2); - fixedToFloat_arr(synthFB_fx, synthFB, 0, hTcxDec->L_frameTCX + k * L_frameTCX / 2); - FOR( Word16 l = 0; l < N_LTP_GAIN_MEMS; l++ ) - { - st->hTcxDec->ltpGainMemory[l] = fix16_to_float( st->hTcxDec->ltpGainMemory_fx[l], Q15 ); - } - st->hTonalMDCTConc->lastPitchLag_float = fix_to_float(st->hTonalMDCTConc->lastPitchLag, Q16); - st->hTonalMDCTConc->nFramesLost_float = fix16_to_float(st->hTonalMDCTConc->nFramesLost, Q1); - // 16bit to u8bit - FOR(Word16 l = 0; l < IGF_START_MX; l++) - { - st->hIGFDec->infoTCXNoise[l] = (uint8_t)st->hIGFDec->infoTCXNoise_evs[l]; - } - me2f_buf(st->hIGFDec->virtualSpec, st->hIGFDec->virtualSpec_e, st->hIGFDec->virtualSpecBuf, (N_MAX_TCX - IGF_START_MN)); - st->hTcxDec->tcxltp_third_last_pitch_float = fix_to_float(st->hTcxDec->tcxltp_third_last_pitch, 16); - st->hTcxDec->tcxltp_second_last_pitch_float = fix_to_float(st->hTcxDec->tcxltp_second_last_pitch, 16); - st->old_fpitch_float = fix_to_float(st->old_fpitch, 16); - st->old_fpitchFB_float = fix_to_float(st->old_fpitchFB, 16); -#else decoder_tcx_flt( st, prm, Aq, Aind, &synth[k * L_frame / 2], &synthFB[k * L_frameTCX / 2], bfi, k, 0 ); -#endif } } diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 48097cea3..e8818feac 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -883,7 +883,7 @@ void decoder_tcx_invQ( #ifdef IVAS_FLOAT_FIXED Word32 x_fx[N_MAX]; Word16 x_e; - st->hTcxCfg->preemph_fac = FL2WORD16(st->hTcxCfg->preemph_fac_flt); + //st->hTcxCfg->preemph_fac = FL2WORD16(st->hTcxCfg->preemph_fac_flt); st->inv_gamma = FL2WORD16_SCALE(1 / st->gamma_float, 1); tcx_arith_decode_envelope_fx( st, x_fx, &x_e, L_frame, L_spec, Aind, *prm_target, prm_sqQ, st->last_core_from_bs != ACELP_CORE, prm_hm, /* HM parameter area */ hTcxDec->tcx_hm_LtpPitchLag, &arith_bits, &signaling_bits, ( st->bwidth > WB ) ? 1 : 0 ); for (int k = 0; k < N_MAX; ++k) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index b2a8fce40..f7390efb4 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -1766,7 +1766,11 @@ void decoder_tcx_post_ivas_fx(Decoder_State *st_fx, } else if ( st_fx->nbLostCmpt > MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ) { - gainCNG *= 1.f - (float) ( st_fx->nbLostCmpt - MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ) / MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN; + Word16 tmp, q_tmp; + tmp = BASOP_Util_Divide1616_Scale(sub(st_fx->nbLostCmpt, MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME), MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN, &q_tmp); + q_tmp = sub(15, q_tmp); + gainCNG = extract_l(L_shr(L_mult0(gainCNG, sub(shl(1, q_tmp), tmp)), q_tmp)); + //gainCNG *= 1.f - (float) sub( st_fx->nbLostCmpt, MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ) / MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN; } } } diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index c8fed1e05..1a38df1ff 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -1576,8 +1576,8 @@ void con_tcx_ivas_fx( FOR (i = 0; i < L_frame + L_FIR_FER2 - 1; i++) { - random1 = own_random2_fx(&tmpSeed1); - random2 = own_random2_fx(&tmpSeed1); + random1 = own_random2_fx(tmpSeed1); + random2 = own_random2_fx(tmpSeed1); noise[i] = add(shr(random1, noise_e), shr(mult(alpha_coh, random2), noise_e)); } @@ -1588,8 +1588,8 @@ void con_tcx_ivas_fx( FOR (; i < L_frame + (L_frame / 2) + 2 * L_FIR_FER2; i++) { - random1 = own_random2_fx(&tmpSeed1); - random2 = own_random2_fx(&tmpSeed1); + random1 = own_random2_fx(tmpSeed1); + random2 = own_random2_fx(tmpSeed1); noise[i] = add(shr(random1, noise_e), shr(mult(alpha_coh, random2), noise_e)); } } @@ -1707,7 +1707,11 @@ void con_tcx_ivas_fx( } ELSE IF (GT_16(st->nbLostCmpt, MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME)) { - gainCNG *= 1.f - (float)(st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME) / MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN; + Word16 tmp, q_tmp; + tmp = BASOP_Util_Divide1616_Scale(sub(st->nbLostCmpt, MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME), MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN, &q_tmp); + q_tmp = sub(15, q_tmp); + gainCNG = extract_l(L_shr(L_mult0(gainCNG, sub(shl(1, q_tmp), tmp)), q_tmp)); + //gainCNG *= 1.f - (float)(st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME) / MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN; } } #endif diff --git a/lib_dec/evs_dec.c b/lib_dec/evs_dec.c index 28adaf8ac..76c2fe872 100644 --- a/lib_dec/evs_dec.c +++ b/lib_dec/evs_dec.c @@ -47,39 +47,6 @@ #include "ivas_prot_fx.h" #endif -#ifdef IVAS_FLOAT_FIXED -static Word16 norm_arr_l(float *arr, int size); -static Word16 norm(float num); - -static Word16 norm(float num) { - if ((Word32)num == 0) return 31; - return norm_l((Word32)num); -} -static Word16 norm_arr_l(float *arr, int size) -{ - Word16 q = 31; - for (int i = 0; i < size; i++) - if (arr[i] != 0) - { - q = min(q, norm(arr[i])); - } - return q; -} -static Word16 s_norm(float num) { - if ((Word16)num == 0) return 15; - return norm_s((Word16)num); -} -static Word16 norm_arr_s(float *arr, int size) -{ - Word16 q = 15; - for (int i = 0; i < size; i++) - if (arr[i] != 0) - { - q = min(q, s_norm(arr[i])); - } - return q; -} -#endif /*--------------------------------------------------------------------------* * evs_dec_flt() * @@ -106,9 +73,6 @@ ivas_error evs_dec_flt( float old_syn_12k8_16k[L_FRAME16k]; float tmp, tmpF; float pitch_buf[NB_SUBFR16k]; -#ifdef IVAS_FLOAT_FIXED - set_zero(pitch_buf, NB_SUBFR16k); -#endif int16_t unbits; int16_t hq_core_type; int16_t sid_bw; @@ -281,218 +245,10 @@ ivas_error evs_dec_flt( * Preprocessing (preparing) for ACELP/HQ core switching *---------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED_ -#if 1 /*Float to fix conversions*/ - Word16 nchan_out = -1; - Word16 last_element_brate = -1; - Word16 Q_mem_syn2, Q_mem_syn1, Q_mem_syn, Q_syn, Q_pst_old_syn = 0, Q_pst_mem_deemp_err = 0, Q_hb_prev_synth_buffer, Q_old_bwe_exc = 0, Q_mem_hf = 0, Q_mem_syn_hf = 0, Q_mem_hp400 = 0, Q_delay_syn_hf = 0, Q_mem_hp_interp = 0, - Q_old_syn_12k8_16k = 0, Q_prev_env = 0, Q_FBTCXdelayBuf = 15, Q_prev_synth_buffer, Q_syn_Overl = 15, Q_fer_samples = 15, Q_old_syn_Overl = 15, Q_olapBufferAna = 15, Q_mem_syn_r = 15, Q_olapBufferSynth = 15, - Q_olapBufferSynth2 = 15, Q_old_synthFB = 15, Q_mem_deemph = 15; /*Initializing with max values to avoid warnings*/ - Q_mem_syn2 = Q_factor_arr( st->mem_syn2, M ); - //Q_mem_syn1 = Q_factor_arr( st->mem_syn1, M ); - Q_mem_syn_r = Q_factor_arr( st->mem_syn_r_float, L_SYN_MEM ); - //Q_mem_syn = s_min( s_min( Q_mem_syn2, Q_mem_syn1 ), Q_mem_syn_r ); - Q_mem_syn = 0; - //Q_agc_mem = Q_factor_arr( st->agc_mem2, 2 ); - Q_syn = Q_factor_arr( st->syn_float, M + 1 ); - Q_mem_deemph = s_min( Q_syn, Q_factor( st->mem_deemph ) ) - 1; - Q_hb_prev_synth_buffer = Q_factor_arr( st->hb_prev_synth_buffer, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); - Q_prev_synth_buffer = Q_factor_arr( st->prev_synth_buffer, 96 ); - floatToFixed_arr16( st->mem_syn2, st->mem_syn2_fx, Q_mem_syn, M ); - //floatToFixed_arr16( st->mem_syn1, st->mem_syn1_fx, Q_mem_syn, M ); - //floatToFixed_arr16( st->agc_mem2, st->agc_mem_fx, Q_agc_mem, 2 ); - floatToFixed_arr16( st->syn_float, st->syn, Q_mem_deemph, M + 1 ); - st->mem_deemph_fx = (Word16) floatToFixed( st->mem_deemph, Q_mem_deemph ); - st->lp_noise = float_to_fix16( st->lp_noise_float, Q7 ); - floatToFixed_arr( st->hb_prev_synth_buffer, st->hb_prev_synth_buffer_fx, Q_hb_prev_synth_buffer, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); - IF( st->hBPF ) - { - Q_pst_old_syn = Q_factor_arrL( st->hBPF->pst_old_syn, NBPSF_PIT_MAX ); - Q_pst_mem_deemp_err = Q_factor_L( st->hBPF->pst_mem_deemp_err ); - floatToFixed_arr32( st->hBPF->pst_old_syn, st->hBPF->pst_old_syn_32, Q_pst_old_syn, NBPSF_PIT_MAX ); - st->hBPF->pst_mem_deemp_err_32 = float_to_fix( st->hBPF->pst_mem_deemp_err, Q_pst_mem_deemp_err ); - } - IF( st->hBWE_zero ) - { - Q_mem_hf = Q_factor_arr( st->hBWE_zero->mem_hf, ( L_FIR - 1 ) ); - Q_mem_syn_hf = Q_factor_arr( st->hBWE_zero->mem_syn_hf, M ); - Q_mem_hp400 = Q_factor_arr( st->hBWE_zero->mem_hp400, 4 ); - Q_delay_syn_hf = Q_factor_arr( st->hBWE_zero->delay_syn_hf, NS2SA( 16000, DELAY_CLDFB_NS ) ); - Q_mem_hp_interp = Q_factor_arr( st->hBWE_zero->mem_hp_interp, INTERP_3_1_MEM_LEN ); - floatToFixed_arr16( st->hBWE_zero->mem_hf, st->hBWE_zero->mem_hf_fx, Q_mem_hf, ( L_FIR - 1 ) ); - floatToFixed_arr16( st->hBWE_zero->mem_syn_hf, st->hBWE_zero->mem_syn_hf_fx, Q_mem_syn_hf, M ); - floatToFixed_arr16( st->hBWE_zero->mem_hp400, st->hBWE_zero->mem_hp400_fx, Q_mem_hp400, 4 ); - floatToFixed_arr16( st->hBWE_zero->delay_syn_hf, st->hBWE_zero->delay_syn_hf_fx, Q_delay_syn_hf, NS2SA( 16000, DELAY_CLDFB_NS ) ); - floatToFixed_arr16( st->hBWE_zero->mem_hp_interp, st->hBWE_zero->mem_hp_interp_fx, Q_mem_hp_interp, INTERP_3_1_MEM_LEN ); - } - IF( st->hBWE_FD ) - { - Q_old_syn_12k8_16k = Q_factor_arr( st->hBWE_FD->old_syn_12k8_16k, 36 ); - floatToFixed_arr16( st->hBWE_FD->old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k_fx, Q_old_syn_12k8_16k, 36 ); - } - IF( st->hHQ_core ) - { - Q_prev_env = Q_factor_arrL( st->hHQ_core->prev_env, SFM_N_WB ); - Q_fer_samples = Q_factor_arr( st->hHQ_core->fer_samples, 960 ); - } - IF( st->hGSCDec ) - { - st->hGSCDec->Last_frame_ener_fx = floatToFixed( st->hGSCDec->Last_frame_ener, 0 ); /*Q-0*/ - } - IF( st->hTcxDec ) - { - Q_FBTCXdelayBuf = Q_factor_arr( st->hTcxDec->FBTCXdelayBuf_float, 111 ); - Q_prev_synth_buffer = s_min( Q_prev_synth_buffer, Q_FBTCXdelayBuf ); - Q_syn_Overl = Q_factor_arr( st->hTcxDec->syn_Overl_float, 320 ); - Q_old_syn_Overl = Q_factor_arr( st->hTcxDec->old_syn_Overl_float, L_FRAME32k / 2 ) - 1; - } - Q_syn_Overl = s_min( Q_fer_samples, Q_syn_Overl ) - 1; - IF( st->hHQ_core ) - { - floatToFixed_arr32( st->hHQ_core->prev_env, st->hHQ_core->prev_env_fx, Q_prev_env, SFM_N_WB ); - floatToFixed_arr32( st->hHQ_core->prev_normq, st->hHQ_core->prev_normq_fx, 14, SFM_N_WB ); /*Q-14*/ - floatToFixed_arr32( st->hHQ_core->last_ni_gain, st->hHQ_core->last_ni_gain_fx, 17, BANDS_MAX ); /*Q-17*/ - floatToFixed_arr16( st->hHQ_core->last_env, st->hHQ_core->last_env_fx, 1, BANDS_MAX ); /*Q-1*/ - floatToFixed_arr32( st->hHQ_core->prev_coeff_out, st->hHQ_core->prev_coeff_out_fx, Q12, L_HQ_WB_BWE ); /*Q-12*/ - floatToFixed_arr16( st->hHQ_core->fer_samples, st->hHQ_core->fer_samples_fx, Q_syn_Overl, 960 ); - st->hHQ_core->memfilt_lb_fx = float_to_fix16( st->hHQ_core->memfilt_lb, 0 ); - st->hHQ_core->mean_prev_hb_fx = float_to_fix( st->hHQ_core->mean_prev_hb, 0 ); - st->hHQ_core->smoothmem_fx = float_to_fix16( st->hHQ_core->smoothmem, 15 ); - st->hHQ_core->mean_prev_fx = floatToFixed( st->hHQ_core->mean_prev, 0 ); - st->hHQ_core->mean_prev_nc_fx = floatToFixed( st->hHQ_core->mean_prev_nc, 0 ); - st->hHQ_core->wmold_hb_fx = float_to_fix16( st->hHQ_core->wmold_hb, 15 ); - } - IF( st->hTcxDec ) - { - floatToFixed_arr16( st->hTcxDec->FBTCXdelayBuf_float, st->hTcxDec->FBTCXdelayBuf, Q_prev_synth_buffer, 111 ); - floatToFixed_arr16( st->hTcxDec->syn_Overl_float, st->hTcxDec->syn_Overl, Q_syn_Overl, 320 ); - floatToFixed_arr16( st->hTcxDec->old_syn_Overl_float, st->hTcxDec->old_syn_Overl, Q_old_syn_Overl, L_FRAME32k / 2 ); - } - floatToFixed_arr16( st->prev_synth_buffer, st->prev_synth_buffer_fx, Q_prev_synth_buffer, 96 ); - IF( st->cldfbAna ) - { - floatToFixed_arr32( st->cldfbAna->cldfb_state, st->cldfbAna->cldfb_state_fx, Q10, st->cldfbAna->cldfb_state_length ); - } - IF( st->cldfbSyn ) - { - floatToFixed_arr32( st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_fx, Q11, st->cldfbSyn->cldfb_state_length ); - } - Word16 Q_mem_syn_clas_estim = Q_factor_arr( st->mem_syn_clas_estim, 258 ) - 1; - floatToFixed_arr16( st->mem_syn_clas_estim, st->mem_syn_clas_estim_fx, Q_mem_syn_clas_estim, 258 ); - FOR( i = 0; i < M; i++ ) - { - st->lsp_old_fx[i] = float_to_fix16( st->lsp_old[i], 15 ); - st->mem_AR_fx[i] = float_to_fix16( ( st->mem_AR[i] * 2.56f ), 0 ); - st->mem_MA_fx[i] = (Word16) ( ( st->mem_MA[i] * 2.56f ) ); - } - IF( st->hFdCngDec ) - { - Q_olapBufferAna = Q_factor_arr( st->hFdCngDec->hFdCngCom->olapBufferAna_flt, FFTLEN ) - 1; - floatToFixed_arr16( st->hFdCngDec->hFdCngCom->olapBufferAna_flt, st->hFdCngDec->hFdCngCom->olapBufferAna_fx, Q_olapBufferAna, L_FRAME32k ); - Q_olapBufferSynth = Q_factor_arrL( st->hFdCngDec->hFdCngCom->olapBufferSynth_flt, 640 ) - 2; - floatToFixed_arr32( st->hFdCngDec->hFdCngCom->olapBufferSynth_flt, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, Q_olapBufferSynth, 640 ); - Q_olapBufferSynth2 = Q_factor_arrL( st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, 640 ) - 1; - floatToFixed_arr32( st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, Q_olapBufferSynth2, 640 ); - } - IF( st->cldfbBPF ) - floatToFixed_arr32( st->cldfbBPF->cldfb_state, st->cldfbBPF->cldfb_state_fx, Q11, st->cldfbBPF->cldfb_state_length ); - //Q_old_exc = Q_factor_arr( st->old_exc, 480 ) - 1; - //floatToFixed_arr16( st->old_exc, st->old_exc_fx, Q_old_exc, 480 ); - floatToFixed_arr32( st->previoussynth, st->previoussynth_fx_32, 0, 960 ); - st->enr_old_fx = (Word32) st->enr_old; - st->log_energy_diff_lt_fx = float_to_fix( st->log_energy_diff_lt, Q15 ); - st->stab_fac_smooth_lt_fx = float_to_fix( st->stab_fac_smooth_lt, Q15 ); - st->lp_ener_fx = float_to_fix( st->lp_ener, Q6 ); - st->lp_gainc_fx = (Word16) L_min( 32767, float_to_fix( st->lp_gainc, 3 ) ); - floatToFixed_arr16( st->mem_syn_r_float, st->mem_syn_r, Q_mem_syn, L_SYN_MEM ); - IF( ( EQ_16( st->core, ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) ) - { - IF( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && LE_32( st->element_brate, IVAS_24k4 ) && GT_32( last_element_brate, IVAS_24k4 ) ) - { - Q_old_synthFB = Q_factor_arr( st->hTcxDec->old_synthFB, st->hTcxDec->old_synth_lenFB ) - 1; - floatToFixed_arr16( st->hTcxDec->old_synthFB, st->hTcxDec->old_synthFB_fx, Q_old_synthFB, st->hTcxDec->old_synth_lenFB ); - } - } -#endif - IF ( ( error = core_switching_pre_dec_ivas_fx( st, output_frame, -1, -1, EVS_MONO, -1 ,Q_old_synthFB, &Q_olapBufferSynth,&Q_olapBufferSynth2) ) != IVAS_ERR_OK ) - { - return error; - } -#if 1 /*Fixed to float function changes*/ - //fixedToFloat_arr( st->mem_syn1_fx, st->mem_syn1, Q_mem_syn, M ); - //fixedToFloat_arr( st->agc_mem_fx, st->agc_mem2, Q_agc_mem, 2 ); - st->mem_deemph = fixedToFloat( st->mem_deemph_fx, Q_mem_deemph ); - fixedToFloat_arr( st->hb_prev_synth_buffer_fx, st->hb_prev_synth_buffer, Q_hb_prev_synth_buffer, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); - fixedToFloat_arr( st->prev_synth_buffer_fx, st->prev_synth_buffer, Q_prev_synth_buffer, 96 ); - fixedToFloat_arr( st->mem_syn_clas_estim_fx, st->mem_syn_clas_estim, Q_mem_syn_clas_estim, 258 ); - st->enr_old = fixedToFloat( st->enr_old_fx, 0 ); - st->lp_gainc = fixedToFloat( st->lp_gainc_fx, 3 ); /*Q3*/ - FOR( i = 0; i < M; i++ ) - { - st->mem_MA[i] = (float) ( st->mem_MA_fx[i] / 2.56f ); - st->mem_AR[i] = (float)(st->mem_AR_fx[i] / 2.56f ); - st->lsp_old[i] = fixedToFloat( st->lsp_old_fx[i], 15 ); - } - fixedToFloat_arr( st->mem_syn_r, st->mem_syn_r_float, Q_mem_syn, L_SYN_MEM ); - fixedToFloat_arr( st->mem_syn2_fx, st->mem_syn2, Q_mem_syn, M ); - //fixedToFloat_arr( st->old_exc_fx, st->old_exc, Q_old_exc, 480 ); - IF( st->hBPF ) - { - fixedToFloat_arrL( st->hBPF->pst_old_syn_32, st->hBPF->pst_old_syn, Q_pst_old_syn, NBPSF_PIT_MAX ); - st->hBPF->pst_mem_deemp_err = fixedToFloat( st->hBPF->pst_mem_deemp_err_32, Q_pst_mem_deemp_err ); - } - IF( st->hGSCDec ) - { - st->hGSCDec->Last_frame_ener = fixedToFloat( st->hGSCDec->Last_frame_ener_fx, 0 ); /*Q-0*/ - } - IF( st->hTcxDec ) - { - fixedToFloat_arr( st->hTcxDec->old_syn_Overl, st->hTcxDec->old_syn_Overl_float, Q_old_syn_Overl, L_FRAME32k / 2 ); - } - IF( st->hBWE_FD ) - fixedToFloat_arr( st->hBWE_FD->old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k, Q_old_syn_12k8_16k, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - IF( st->hBWE_zero ) - { - fixedToFloat_arr( st->hBWE_zero->mem_hf_fx, st->hBWE_zero->mem_hf, Q_mem_hf, ( L_FIR - 1 ) ); - fixedToFloat_arr( st->hBWE_zero->mem_syn_hf_fx, st->hBWE_zero->mem_syn_hf, Q_mem_syn_hf, M ); - fixedToFloat_arr( st->hBWE_zero->mem_hp400_fx, st->hBWE_zero->mem_hp400, Q_mem_hp400, 4 ); - fixedToFloat_arr( st->hBWE_zero->delay_syn_hf_fx, st->hBWE_zero->delay_syn_hf, Q_delay_syn_hf, NS2SA( 16000, DELAY_CLDFB_NS ) ); - fixedToFloat_arr( st->hBWE_zero->mem_hp_interp_fx, st->hBWE_zero->mem_hp_interp, Q_mem_hp_interp, INTERP_3_1_MEM_LEN ); - } - IF( st->cldfbAna ) - fixedToFloat_arrL( st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_state, Q10, st->cldfbAna->cldfb_state_length ); - IF( st->cldfbSyn ) - fixedToFloat_arrL( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_state, Q11, st->cldfbSyn->cldfb_state_length ); - IF( st->cldfbBPF ) - fixedToFloat_arrL( st->cldfbBPF->cldfb_state_fx, st->cldfbBPF->cldfb_state, Q11, st->cldfbBPF->cldfb_state_length ); - IF( st->hHQ_core ) - { - fixedToFloat_arrL( st->hHQ_core->prev_env_fx, st->hHQ_core->prev_env, Q_prev_env, SFM_N_WB ); - fixedToFloat_arrL( st->hHQ_core->prev_normq_fx, st->hHQ_core->prev_normq, 14, SFM_N_WB ); /*Q-14*/ - fixedToFloat_arrL( st->hHQ_core->last_ni_gain_fx, st->hHQ_core->last_ni_gain, 17, BANDS_MAX ); /*Q-17*/ - fixedToFloat_arr( st->hHQ_core->last_env_fx, st->hHQ_core->last_env, 1, BANDS_MAX ); /*Q-1*/ - fixedToFloat_arrL( st->hHQ_core->prev_coeff_out_fx, st->hHQ_core->prev_coeff_out, Q12, L_HQ_WB_BWE ); - st->hHQ_core->memfilt_lb = fixedToFloat( st->hHQ_core->memfilt_lb_fx, 0 ); - st->hHQ_core->mean_prev_hb = fixedToFloat( st->hHQ_core->mean_prev_hb_fx, 0 ); - st->hHQ_core->smoothmem = st->hHQ_core->smoothmem_fx / 32767.f; - st->hHQ_core->mean_prev = fixedToFloat( st->hHQ_core->mean_prev_fx, 0 ); - st->hHQ_core->mean_prev_nc = fixedToFloat( st->hHQ_core->mean_prev_nc_fx, 0 ); - st->hHQ_core->wmold_hb = st->hHQ_core->wmold_hb_fx / 32767.f; - fixedToFloat_arr( st->hHQ_core->fer_samples_fx, st->hHQ_core->fer_samples, Q_syn_Overl, 960 ); - } - IF( st->hFdCngDec ) - { - fixedToFloat_arr( st->hFdCngDec->hFdCngCom->olapBufferAna_fx, st->hFdCngDec->hFdCngCom->olapBufferAna_flt, Q_olapBufferAna, L_FRAME32k ); - fixedToFloat_arrL( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, Q_olapBufferSynth2, L_FRAME32k ); - fixedToFloat_arrL( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_flt, Q_olapBufferSynth, L_FRAME32k ); - } -#endif -#else if ( ( error = core_switching_pre_dec( st, output_frame, -1, -1, EVS_MONO, -1 ) ) != IVAS_ERR_OK ) { return error; } -#endif // IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* * ACELP core decoding @@ -527,23 +283,7 @@ ivas_error evs_dec_flt( * Pre-processing for bandwidth switching *---------------------------------------------------------------------*/ push_wmops( "BWE_decoding" ); - -#ifdef IVAS_FLOAT_FIXED - Word32 old_syn_12k8_16k_fx[L_FRAME16k]; - Word16 norm = norm_arr_l(old_syn_12k8_16k, L_FRAME), q_old_syn, q_audio; - Word16 gb = find_guarded_bits_fx(L_FRAME16k); - floatToFixed_arrL(old_syn_12k8_16k, old_syn_12k8_16k_fx, 11, L_FRAME16k); - q_old_syn = norm - gb; - norm = norm_arr_s(st->t_audio_q, L_FRAME); - gb = find_guarded_bits_fx(L_FRAME); - floatToFixed_arr(st->t_audio_q, st->t_audio_q_fx, norm - gb, L_FRAME); - q_audio = norm - gb; - ivas_bw_switching_pre_proc_fx(st, -1, 1, old_syn_12k8_16k_fx, 11, q_audio); - st->enerLH = fixedToFloat(st->enerLH_fx, st->enerLH_fx_Q); // Q / 2 - st->enerLL = fixedToFloat(st->enerLL_fx, st->enerLL_fx_Q ); -#else bw_switching_pre_proc( st, old_syn_12k8_16k, -1, 1 ); -#endif /*---------------------------------------------------------------------* * WB TBE decoding @@ -959,7 +699,7 @@ ivas_error evs_dec_flt( mvr2r( st->hFdCngDec->hFdCngCom->timeDomainBuffer_flt, timeDomainBuffer, st->L_frame ); mvr2r( st->hFdCngDec->hFdCngCom->A_cng_flt, A, M + 1 ); - update_decoder_LPD_cng_flt( st, timeDomainBuffer, A, st->p_bpf_noise_buf_float); + update_decoder_LPD_cng_flt( st, timeDomainBuffer, A, st->p_bpf_noise_buf_float ); /* Generate additional comfort noise to mask potential coding artefacts */ if ( st->flag_cna ) @@ -996,7 +736,7 @@ ivas_error evs_dec_flt( set_f( st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, 0.f, st->hFdCngDec->hFdCngCom->fftlen ); } - if ( st->p_bpf_noise_buf_float) + if ( st->p_bpf_noise_buf_float ) { addBassPostFilter( st->p_bpf_noise_buf_float, -1, realBuffer, imagBuffer, st->cldfbBPF ); } @@ -1161,108 +901,8 @@ ivas_error evs_dec_flt( /*----------------------------------------------------------------* * Save synthesis for HQ FEC *----------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED - Word32 exp_max = 0; - Word32 output_fx[L_FRAME48k]; - if ( ( st->codec_mode == MODE1 && st->hTcxDec != NULL ) && ( ( st->core == ACELP_CORE && !( st->bfi == 1 && st->con_tcx == 1 ) ) || st->core == HQ_CORE ) ) - { - double max_prev_synth_buffer = 0.0f, max_old_out = 0.0f, max_delay_buf_out = 0.0f, max_ouput = 0.0f, max_synth_history = 0.0f; - Word32 exp_prev_synth_buffer = 0, exp_old_out = 0, exp_delay_buf_out = 0, exp_ouput = 0, exp_synth_history = 0; - - /*Find maximum values for all the buffers*/ - for ( i = 0; i < NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ); i++ ) - { - max_prev_synth_buffer = max( max_prev_synth_buffer, fabs( st->prev_synth_buffer[i] ) ); - } - if ( (Word16) max_prev_synth_buffer != 0 ) - { - frexp( max_prev_synth_buffer, &exp_prev_synth_buffer ); - } - - for ( i = NS2SA( st->output_Fs, N_ZERO_MDCT_NS ); i < NS2SA( st->output_Fs, N_ZERO_MDCT_NS ) + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ); i++ ) - { - max_old_out = max( max_old_out, fabs( st->hHQ_core->old_out[i] ) ); - } - if ( (Word16) max_old_out != 0 ) - { - frexp( max_old_out, &exp_old_out ); - } - - for ( i = 0; i < NS2SA( st->output_Fs, DELAY_CLDFB_NS ); i++ ) - { - max_delay_buf_out = max( max_delay_buf_out, fabs( st->delay_buf_out[i] ) ); - } - if ( (Word16) max_delay_buf_out != 0 ) - { - frexp( max_delay_buf_out, &exp_delay_buf_out ); - } - - for ( i = 0; i < output_frame; i++ ) - { - max_ouput = max( max_ouput, fabs( output[i] ) ); - } - if ( (Word16) max_ouput != 0 ) - { - frexp( max_ouput, &exp_ouput ); - } - - for ( i = output_frame; i < 2 * output_frame - NS2SA( st->output_Fs, DELAY_CLDFB_NS ) + NS2SA( st->output_Fs, PH_ECU_MEM_NS ); i++ ) - { - max_synth_history = max( max_synth_history, fabs( st->hTcxDec->synth_history[i] ) ); - } - - if ( (Word16) max_synth_history != 0 ) - { - frexp( max_synth_history, &exp_synth_history ); - } - - /*Find a commen maximum exp*/ - exp_max = max( exp_synth_history, exp_ouput ); - exp_max = max( exp_max, exp_prev_synth_buffer ); - exp_max = max( exp_max, exp_old_out ); - exp_max = max( exp_max, exp_delay_buf_out ); - - for ( i = 0; i < NS2SA( st->output_Fs, DELAY_CLDFB_NS ); i++ ) - { - f2fix_16( &st->delay_buf_out[i], &st->delay_buf_out_fx[i], exp_max ); - } - for ( i = NS2SA( st->output_Fs, N_ZERO_MDCT_NS ); i < NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ); i++ ) - { - f2fix_16( &st->hHQ_core->old_out[i], &st->hHQ_core->old_out_fx[i], exp_max ); - } - for ( i = 0; i < NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ); i++ ) - { - f2fix_16( &st->prev_synth_buffer[i], &st->prev_synth_buffer_fx[i], exp_max ); - } - for ( i = output_frame; i < 2 * output_frame - NS2SA( st->output_Fs, DELAY_CLDFB_NS ) + NS2SA( st->output_Fs, PH_ECU_MEM_NS ); i++ ) - { - f2fix_16( &st->hTcxDec->synth_history[i], &st->hTcxDec->synth_history_fx[i], exp_max ); - } - for ( i = 0; i < output_frame; i++ ) - { - f2fix( &output[i], &output_fx[i], exp_max ); - } - } - - save_synthesis_hq_fec_fx( st, output_fx, output_frame, NULL ); - - if ( ( st->codec_mode == MODE1 && st->hTcxDec != NULL ) && ( ( st->core == ACELP_CORE && !( st->bfi == 1 && st->con_tcx == 1 ) ) || st->core == HQ_CORE ) ) - { - /*dumps*/ - float track = 0; - for ( i = 0; i < 2 * output_frame; i++ ) - { - fix2f_16( &st->hTcxDec->synth_history_fx[i], &track, exp_max ); - fix2f_16( &st->hTcxDec->synth_history_fx[i], &st->hTcxDec->synth_history[i], exp_max ); -#ifdef DUMPS_ENABLED - dbgwrite_txt( &track, 1, "Fixed_code_synth_history_fx.txt", NULL ); - dbgwrite_txt( &st->hTcxDec->synth_history[i], 1, "Float_code_synth_history_fx.txt", NULL ); -#endif - } - } -#else save_synthesis_hq_fec( st, output, output_frame, NULL ); -#endif + /*----------------------------------------------------------------* * HP filtering @@ -1302,7 +942,6 @@ ivas_error evs_dec_flt( } - pop_wmops(); return error; } diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 8b48daa3d..f4ac3042e 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -3199,7 +3199,7 @@ void generate_masking_noise_lb_dirac( hFdCngCom->olapBufferSynth2_fx[i] = float_to_fix(hFdCngCom->olapBufferSynth2_flt[i], exp); } - SynthesisSTFT_dirac_fx(fftBuffer_fx, timeDomainBuffer_fx + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn, n_samples_out_loop, hFdCngCom); + SynthesisSTFT_dirac_fx(fftBuffer_fx, timeDomainBuffer_fx + n_samples_start, hFdCngCom->olapBufferSynth2_fx, (Word16 *)hFdCngCom->olapWinSyn, n_samples_out_loop, hFdCngCom); for (i = 0; i < hFdCngCom->fftlen; i++) { @@ -3274,7 +3274,7 @@ void generate_masking_noise_lb_dirac_fx( } Word16 exp; - Word16 div1 = BASOP_Util_Divide1616_Scale(negate(scaleTable_cn_dirac[i].scale_ivas), L_shl(10, Q11), &exp); + Word16 div1 = BASOP_Util_Divide1616_Scale(negate(scaleTable_cn_dirac[i].scale_ivas), shl(10, Q11), &exp); exp = add(exp, sub(sub( 15, 13) , sub(15, 11))); Word32 scale_temp = BASOP_util_Pow2(Mpy_32_16_1(LOG_10_BASE_2, div1), add(exp, 2), &exp); scale_temp = L_sub(scale_temp, L_shl(1, Q31 - exp)); @@ -3291,7 +3291,7 @@ void generate_masking_noise_lb_dirac_fx( WHILE ( GT_16(n_samples_out, 0 )) { n_samples_out_loop = s_min( hFdCngCom->frameSize, n_samples_out ); - IF ( NE_16(scale, 0 )) + IF ( NE_32(scale, 0 )) { /*Generate LF comfort noise only at first slot, for the whole frame*/ ptr_level = cngNoiseLevel; diff --git a/lib_dec/hq_core_dec.c b/lib_dec/hq_core_dec.c index aee3c0a70..c3d58e470 100644 --- a/lib_dec/hq_core_dec.c +++ b/lib_dec/hq_core_dec.c @@ -337,12 +337,12 @@ void hq_core_dec( Word16 synth_fx[L_FRAME48k]; Word16 Q_old_syn_Overl = -1; - Word16 Q_old_Aq_12_8 = 12; + //Word16 Q_old_Aq_12_8 = 12; floatToFixed_arrL( t_audio_q, t_audio_q_fx, Q_audio, L_FRAME48k_EXT ); floatToFixed_arr( hHQ_core->old_out, hHQ_core->old_out_fx, hHQ_core->Q_old_wtda, L_FRAME48k ); floatToFixed_arr( hHQ_core->old_outLB, hHQ_core->old_out_LB_fx, hHQ_core->Q_old_wtda_LB, L_FRAME32k ); floatToFixed_arr( st->hTcxDec->old_syn_Overl_float, st->hTcxDec->old_syn_Overl, Q_old_syn_Overl, L_FRAME32k / 2 ); - floatToFixed_arr( st->old_Aq_12_8, st->old_Aq_12_8_fx, Q_old_Aq_12_8, M + 1 ); + //floatToFixed_arr( st->old_Aq_12_8, st->old_Aq_12_8_fx, Q_old_Aq_12_8, M + 1 ); /* Initializations for TCX MDCT framework, to be used for switching frame */ tcx_cfg = st->hTcxCfg; @@ -678,7 +678,7 @@ void HQ_core_dec_init_flt( set_s( hHQ_core->mem_norm + 1, 39, SFM_N_ENV_STAB - 1 ); hHQ_core->mem_env_delta = 0; hHQ_core->no_att_hangover = 0; - hHQ_core->energy_lt = 300.0f; + //hHQ_core->energy_lt = 300.0f; hHQ_core->HqVoicing = 0; set_f( hHQ_core->fer_samples, 0, L_FRAME48k ); diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index c633007de..b4fcc5591 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -979,7 +979,7 @@ ivas_error init_decoder_ivas_fx( if ( st_fx->ivas_format != ISM_FORMAT ) { /* AVQ pre-quantizer memory */ - st_fx->mem_preemp_preQ = 0.0f; + //st_fx->mem_preemp_preQ = 0.0f; st_fx->last_nq_preQ = 0; st_fx->last_code_preq = 0; st_fx->use_acelp_preq = 0; @@ -1331,34 +1331,15 @@ ivas_error init_decoder_ivas_fx( #if 1 // Float To Fix conversions floatToFixed_arr(st_fx->hTdCngDec->shb_lpcCNG, st_fx->hTdCngDec->shb_lpcCNG_fx, 15, LPC_SHB_ORDER + 1); st_fx->hTdCngDec->shb_cng_gain_fx_32 = floatToFixed(st_fx->hTdCngDec->shb_cng_gain, 11); - floatToFixed_arr(st_fx->lsp_old, st_fx->lsp_old_fx, 15, M); + //floatToFixed_arr(st_fx->lsp_old, st_fx->lsp_old_fx, 15, M); #endif // Float to fix conversions td_cng_dec_init_ivas_fx( st_fx ); #if 1 // Fix to float conversions - //fixedToFloat_arr(st_fx->lspCNG_fx, st_fx->lspCNG, 15, M); st_fx->hTdCngDec->shb_cng_ener = fix_to_float(st_fx->hTdCngDec->shb_cng_ener_fx_32, 11); fixedToFloat_arr(st_fx->hTdCngDec->shb_lpcCNG_fx, st_fx->hTdCngDec->shb_lpcCNG, 15, LPC_SHB_ORDER + 1); st_fx->hTdCngDec->shb_cng_gain = fix_to_float(st_fx->hTdCngDec->shb_cng_gain_fx_32, 11); - st_fx->hTdCngDec->wb_cng_ener = fix_to_float(st_fx->hTdCngDec->wb_cng_ener_fx_32, 11); - st_fx->hTdCngDec->last_wb_cng_ener = fix_to_float(st_fx->hTdCngDec->last_wb_cng_ener_fx_32, 11); - st_fx->hTdCngDec->last_shb_cng_ener = fix_to_float(st_fx->hTdCngDec->last_shb_cng_ener_fx_32, 11); - fixedToFloat_arr(st_fx->hTdCngDec->ho_lsp_hist_fx, st_fx->hTdCngDec->ho_lsp_hist, 15, HO_HIST_SIZE * M); - fixedToFloat_arrL(st_fx->hTdCngDec->ho_ener_hist_fx, st_fx->hTdCngDec->ho_ener_hist, 15, HO_HIST_SIZE); - fixedToFloat_arrL(st_fx->hTdCngDec->ho_env_hist_fx, st_fx->hTdCngDec->ho_env_hist, 15, HO_HIST_SIZE * NUM_ENV_CNG); - fixedToFloat_arr(st_fx->hTdCngDec->ho_lsp_circ_fx, st_fx->hTdCngDec->ho_lsp_circ, 15, HO_HIST_SIZE * M); - fixedToFloat_arrL(st_fx->hTdCngDec->ho_ener_circ_fx, st_fx->hTdCngDec->ho_ener_circ, 15, HO_HIST_SIZE); - fixedToFloat_arrL(st_fx->hTdCngDec->ho_env_circ_fx, st_fx->hTdCngDec->ho_env_circ, 15, HO_HIST_SIZE * NUM_ENV_CNG); - fixedToFloat_arrL(st_fx->hTdCngDec->lp_env_fx, st_fx->hTdCngDec->lp_env, 15, NUM_ENV_CNG); - fixedToFloat_arr(st_fx->hTdCngDec->exc_mem_fx, st_fx->hTdCngDec->exc_mem, 15, 24); - fixedToFloat_arr(st_fx->hTdCngDec->exc_mem1_fx, st_fx->hTdCngDec->exc_mem1, 15, 30); - fixedToFloat_arrL(st_fx->hTdCngDec->old_env_fx, st_fx->hTdCngDec->old_env, 15, NUM_ENV_CNG); - fixedToFloat_arr(st_fx->hTdCngDec->lsp_shb_prev_fx, st_fx->hTdCngDec->lsp_shb_prev, 15, LPC_SHB_ORDER); - fixedToFloat_arr(st_fx->hTdCngDec->lsp_shb_prev_prev_fx, st_fx->hTdCngDec->lsp_shb_prev_prev, 15, LPC_SHB_ORDER); - fixedToFloat_arr(st_fx->hTdCngDec->interpol_3_2_cng_dec_fx, st_fx->hTdCngDec->interpol_3_2_cng_dec, 15, INTERP_3_2_MEM_LEN); - - #endif // Fix to float conversions #else td_cng_dec_init_flt( st_fx ); diff --git a/lib_dec/ivas_agc_dec_fx.c b/lib_dec/ivas_agc_dec_fx.c index 693ab84d8..c328a9d6d 100644 --- a/lib_dec/ivas_agc_dec_fx.c +++ b/lib_dec/ivas_agc_dec_fx.c @@ -328,13 +328,14 @@ void ivas_agc_read_bits_fx( IF( EQ_16( AGC_flag, 1 ) ) { per_ch_bit[0] = 1; + move16(); assert( EQ_16( AGC_BITS_PER_CH, ( pState->agc_com.betaE + 1 ) ) ); FOR( i = 0; i < n_channels; i++ ) { IF( EQ_16( per_ch_bit[i], 1 ) ) - { /* TODO: to replace get_next_indice with get_next_indice_fx when fixed point Decoder state struct used for fixed point implementation */ - pState->gain_data[i].absGainExpCurr = get_next_indice( st0, (Word16) pState->agc_com.betaE ); + { + pState->gain_data[i].absGainExpCurr = get_next_indice_fx( st0, (Word16) pState->agc_com.betaE ); } ELSE { diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index adbfc2e70..f330e7f64 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1878,7 +1878,7 @@ void ivas_binaural_add_LFE_fix( #ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED IF( st_ivas->hCrendWrapper != NULL ) { - st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe_fx = st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe * ( ONE_IN_Q14 ); + st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe_fx = (Word16)(st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe * ( ONE_IN_Q14 )); } #endif Word16 render_lfe, idx_lfe; diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index a8d0dc483..06acc068b 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -587,18 +587,18 @@ ivas_error ivas_core_dec( Q_syn_Overl = s_min( Q_fer_samples, Q_syn_Overl ) - 1; IF( st->hHQ_core ) { - floatToFixed_arr32( st->hHQ_core->prev_env, st->hHQ_core->prev_env_fx, Q_prev_env, SFM_N_WB ); - floatToFixed_arr32( st->hHQ_core->prev_normq, st->hHQ_core->prev_normq_fx, 14, SFM_N_WB ); /*Q-14*/ - floatToFixed_arr32( st->hHQ_core->last_ni_gain, st->hHQ_core->last_ni_gain_fx, 17, BANDS_MAX ); /*Q-17*/ - floatToFixed_arr16( st->hHQ_core->last_env, st->hHQ_core->last_env_fx, 1, BANDS_MAX ); /*Q-1*/ + //floatToFixed_arr32( st->hHQ_core->prev_env, st->hHQ_core->prev_env_fx, Q_prev_env, SFM_N_WB ); + //floatToFixed_arr32( st->hHQ_core->prev_normq, st->hHQ_core->prev_normq_fx, 14, SFM_N_WB ); /*Q-14*/ + //floatToFixed_arr32( st->hHQ_core->last_ni_gain, st->hHQ_core->last_ni_gain_fx, 17, BANDS_MAX ); /*Q-17*/ + //floatToFixed_arr16( st->hHQ_core->last_env, st->hHQ_core->last_env_fx, 1, BANDS_MAX ); /*Q-1*/ floatToFixed_arr32( st->hHQ_core->prev_coeff_out, st->hHQ_core->prev_coeff_out_fx, Q12, L_HQ_WB_BWE ); /*Q-12*/ floatToFixed_arr16( st->hHQ_core->fer_samples, st->hHQ_core->fer_samples_fx, Q_syn_Overl, 960 ); - st->hHQ_core->memfilt_lb_fx = float_to_fix16( st->hHQ_core->memfilt_lb, 0 ); - st->hHQ_core->mean_prev_hb_fx = float_to_fix( st->hHQ_core->mean_prev_hb, 0 ); - st->hHQ_core->smoothmem_fx = float_to_fix16( st->hHQ_core->smoothmem, 15 ); - st->hHQ_core->mean_prev_fx = floatToFixed( st->hHQ_core->mean_prev, 0 ); - st->hHQ_core->mean_prev_nc_fx = floatToFixed( st->hHQ_core->mean_prev_nc, 0 ); - st->hHQ_core->wmold_hb_fx = float_to_fix16( st->hHQ_core->wmold_hb, 15 ); + //st->hHQ_core->memfilt_lb_fx = float_to_fix16( st->hHQ_core->memfilt_lb, 0 ); + //st->hHQ_core->mean_prev_hb_fx = float_to_fix( st->hHQ_core->mean_prev_hb, 0 ); + //st->hHQ_core->smoothmem_fx = float_to_fix16( st->hHQ_core->smoothmem, 15 ); + //st->hHQ_core->mean_prev_fx = floatToFixed( st->hHQ_core->mean_prev, 0 ); + //st->hHQ_core->mean_prev_nc_fx = floatToFixed( st->hHQ_core->mean_prev_nc, 0 ); + //st->hHQ_core->wmold_hb_fx = float_to_fix16( st->hHQ_core->wmold_hb, 15 ); } IF( st->hTcxDec ) { @@ -619,7 +619,7 @@ ivas_error ivas_core_dec( FOR( i = 0; i < M; i++ ) { - st->lsp_old_fx[i] = float_to_fix16( st->lsp_old[i], 15 ); + //st->lsp_old_fx[i] = float_to_fix16( st->lsp_old[i], 15 ); st->mem_AR_fx[i] = float_to_fix16( ( st->mem_AR[i] * 2.56f ), 0 ); st->mem_MA_fx[i] = (Word16) ( ( st->mem_MA[i] * 2.56f ) ); } @@ -639,7 +639,7 @@ ivas_error ivas_core_dec( floatToFixed_arr32( st->previoussynth, st->previoussynth_fx_32, 0, 960 ); st->enr_old_fx = (Word32) st->enr_old; st->log_energy_diff_lt_fx = float_to_fix( st->log_energy_diff_lt, Q15 ); - st->stab_fac_smooth_lt_fx = float_to_fix( st->stab_fac_smooth_lt, Q15 ); + st->stab_fac_smooth_lt_fx = float_to_fix16( st->stab_fac_smooth_lt, Q15 ); st->lp_ener_fx = float_to_fix( st->lp_ener, Q6 ); st->lp_gainc_fx = (Word16) L_min( 32767, float_to_fix( st->lp_gainc, 3 ) ); //floatToFixed_arr16( st->mem_syn_r_float, st->mem_syn_r, Q_mem_syn, L_SYN_MEM ); @@ -667,7 +667,7 @@ ivas_error ivas_core_dec( { st->mem_MA[i] = (float) ( st->mem_MA_fx[i] / 2.56f ); st->mem_AR[i] = (float) ( st->mem_AR_fx[i] / 2.56f ); - st->lsp_old[i] = fixedToFloat( st->lsp_old_fx[i], 15 ); + //st->lsp_old[i] = fixedToFloat( st->lsp_old_fx[i], 15 ); } IF( st->hBPF ) @@ -701,17 +701,17 @@ ivas_error ivas_core_dec( fixedToFloat_arrL( st->cldfbBPF->cldfb_state_fx, st->cldfbBPF->cldfb_state, Q11, st->cldfbBPF->cldfb_state_length ); IF( st->hHQ_core ) { - fixedToFloat_arrL( st->hHQ_core->prev_env_fx, st->hHQ_core->prev_env, Q_prev_env, SFM_N_WB ); - fixedToFloat_arrL( st->hHQ_core->prev_normq_fx, st->hHQ_core->prev_normq, 14, SFM_N_WB ); /*Q-14*/ - fixedToFloat_arrL( st->hHQ_core->last_ni_gain_fx, st->hHQ_core->last_ni_gain, 17, BANDS_MAX ); /*Q-17*/ - fixedToFloat_arr( st->hHQ_core->last_env_fx, st->hHQ_core->last_env, 1, BANDS_MAX ); /*Q-1*/ + //fixedToFloat_arrL( st->hHQ_core->prev_env_fx, st->hHQ_core->prev_env, Q_prev_env, SFM_N_WB ); + //fixedToFloat_arrL( st->hHQ_core->prev_normq_fx, st->hHQ_core->prev_normq, 14, SFM_N_WB ); /*Q-14*/ + //fixedToFloat_arrL( st->hHQ_core->last_ni_gain_fx, st->hHQ_core->last_ni_gain, 17, BANDS_MAX ); /*Q-17*/ + //fixedToFloat_arr( st->hHQ_core->last_env_fx, st->hHQ_core->last_env, 1, BANDS_MAX ); /*Q-1*/ fixedToFloat_arrL( st->hHQ_core->prev_coeff_out_fx, st->hHQ_core->prev_coeff_out, Q12, L_HQ_WB_BWE ); - st->hHQ_core->memfilt_lb = fixedToFloat( st->hHQ_core->memfilt_lb_fx, 0 ); - st->hHQ_core->mean_prev_hb = fixedToFloat( st->hHQ_core->mean_prev_hb_fx, 0 ); - st->hHQ_core->smoothmem = st->hHQ_core->smoothmem_fx / 32767.f; - st->hHQ_core->mean_prev = fixedToFloat( st->hHQ_core->mean_prev_fx, 0 ); - st->hHQ_core->mean_prev_nc = fixedToFloat( st->hHQ_core->mean_prev_nc_fx, 0 ); - st->hHQ_core->wmold_hb = st->hHQ_core->wmold_hb_fx / 32767.f; + //st->hHQ_core->memfilt_lb = fixedToFloat( st->hHQ_core->memfilt_lb_fx, 0 ); + //st->hHQ_core->mean_prev_hb = fixedToFloat( st->hHQ_core->mean_prev_hb_fx, 0 ); + //st->hHQ_core->smoothmem = st->hHQ_core->smoothmem_fx / 32767.f; + //st->hHQ_core->mean_prev = fixedToFloat( st->hHQ_core->mean_prev_fx, 0 ); + //st->hHQ_core->mean_prev_nc = fixedToFloat( st->hHQ_core->mean_prev_nc_fx, 0 ); + //st->hHQ_core->wmold_hb = st->hHQ_core->wmold_hb_fx / 32767.f; fixedToFloat_arr( st->hHQ_core->fer_samples_fx, st->hHQ_core->fer_samples, Q_syn_Overl, 960 ); } IF( st->hFdCngDec ) @@ -845,26 +845,26 @@ ivas_error ivas_core_dec( floatToFixed_arr( hHQ_core->old_out, hHQ_core->old_out_fx, hHQ_core->Q_old_wtda, L_FRAME48k ); floatToFixed_arr( hHQ_core->old_outLB, hHQ_core->old_out_LB_fx, hHQ_core->Q_old_wtda_LB, L_FRAME32k ); floatToFixed_arr( st->hTcxDec->old_syn_Overl_float, st->hTcxDec->old_syn_Overl, -1, L_FRAME32k / 2 ); - floatToFixed_arr( hHQ_core->oldgapsynth, hHQ_core->oldgapsynth_fx, 0, L_FRAME32k ); - floatToFixed_arr( st->old_Aq_12_8, st->old_Aq_12_8_fx, Q12, M + 1 ); + //floatToFixed_arr( hHQ_core->oldgapsynth, hHQ_core->oldgapsynth_fx, 0, L_FRAME32k ); + //floatToFixed_arr( st->old_Aq_12_8, st->old_Aq_12_8_fx, Q12, M + 1 ); floatToFixed_arrL( st->old_pitch_buf, st->old_pitch_buf_fx, Q16, 2 * NB_SUBFR16k + 2 ); - floatToFixed_arrL( hHQ_core->prev_normq, hHQ_core->prev_normq_fx, Q14, SFM_N_WB ); - FOR( i = 0; i < SFM_N_WB; ++i ) - { - hHQ_core->prev_env_fx[i] = floatToFixed( hHQ_core->prev_env[i], hHQ_core->prev_env_Q[i] ); - } - hHQ_core->energy_lt_fx = floatToFixed( hHQ_core->energy_lt, Q13 ); - floatToFixed_arr( hHQ_core->prev_noise_level, hHQ_core->prev_noise_level_fx, Q15, 2 ); + //floatToFixed_arrL( hHQ_core->prev_normq, hHQ_core->prev_normq_fx, Q14, SFM_N_WB ); + //FOR( i = 0; i < SFM_N_WB; ++i ) + //{ + // hHQ_core->prev_env_fx[i] = floatToFixed( hHQ_core->prev_env[i], hHQ_core->prev_env_Q[i] ); + //} + //hHQ_core->energy_lt_fx = floatToFixed( hHQ_core->energy_lt, Q13 ); + //floatToFixed_arr( hHQ_core->prev_noise_level, hHQ_core->prev_noise_level_fx, Q15, 2 ); floatToFixed_arrL( hHQ_core->prev_coeff_out, hHQ_core->prev_coeff_out_fx, Q12, L_HQ_WB_BWE ); FOR( i = 0; i < 3; ++i ) { hHQ_core->old_is_transient[i] = hHQ_core->old_is_transient[i]; } - hHQ_core->prev_ni_ratio_fx = (Word16) floatToFixed( hHQ_core->prev_ni_ratio, Q15 ); - hHQ_core->mean_prev_nc_fx = floatToFixed( hHQ_core->mean_prev_nc, 0 ); - hHQ_core->wmold_hb_fx = (Word16) floatToFixed( hHQ_core->wmold_hb, Q15 ); - hHQ_core->mean_prev_hb_fx = floatToFixed( hHQ_core->mean_prev_hb, 0 ); - hHQ_core->memfilt_lb_fx = (Word16) floatToFixed( hHQ_core->memfilt_lb, 0 ); + //hHQ_core->prev_ni_ratio_fx = (Word16) floatToFixed( hHQ_core->prev_ni_ratio, Q15 ); + //hHQ_core->mean_prev_nc_fx = floatToFixed( hHQ_core->mean_prev_nc, 0 ); + //hHQ_core->wmold_hb_fx = (Word16) floatToFixed( hHQ_core->wmold_hb, Q15 ); + //hHQ_core->mean_prev_hb_fx = floatToFixed( hHQ_core->mean_prev_hb, 0 ); + //hHQ_core->memfilt_lb_fx = (Word16) floatToFixed( hHQ_core->memfilt_lb, 0 ); hHQ_core->HqVoicing = hHQ_core->HqVoicing; hHQ_core->ph_ecu_HqVoicing = hHQ_core->ph_ecu_HqVoicing; hHQ_core->prev_hqswb_clas = hHQ_core->prev_hqswb_clas; @@ -878,26 +878,26 @@ ivas_error ivas_core_dec( hHQ_core->mem_env_delta_hqfec = hHQ_core->mem_env_delta_hqfec; hHQ_core->no_att_hangover = hHQ_core->no_att_hangover; hHQ_core->oldHqVoicing = hHQ_core->oldHqVoicing; - floatToFixed_arr( hHQ_core->env_stab_state_p, hHQ_core->env_stab_state_p_fx, Q15, NUM_ENV_STAB_PLC_STATES ); + //floatToFixed_arr( hHQ_core->env_stab_state_p, hHQ_core->env_stab_state_p_fx, Q15, NUM_ENV_STAB_PLC_STATES ); hHQ_core->envstabplc_hocnt = hHQ_core->envstabplc_hocnt; floatToFixed_arr( st->hTcxDec->prev_good_synth - tmp_size, st->hTcxDec->prev_good_synth_fx - tmp_size, 0, 2 * output_frame + tmp_size ); hHQ_core->time_offs = hHQ_core->time_offs; - floatToFixed_arr( hHQ_core->X_sav, hHQ_core->X_sav_fx, hHQ_core->Q_X_sav, PH_ECU_SPEC_SIZE ); + //floatToFixed_arr( hHQ_core->X_sav, hHQ_core->X_sav_fx, hHQ_core->Q_X_sav, PH_ECU_SPEC_SIZE ); hHQ_core->num_p = hHQ_core->num_p; FOR( i = 0; i < MAX_PLOCS; ++i ) { hHQ_core->plocs[i] = hHQ_core->plocs[i]; } - floatToFixed_arrL( hHQ_core->plocsi, hHQ_core->plocsi_fx, Q16, MAX_PLOCS ); - hHQ_core->env_stab_fx = (Word16) floatToFixed( hHQ_core->env_stab, Q15 ); + //floatToFixed_arrL( hHQ_core->plocsi, hHQ_core->plocsi_fx, Q16, MAX_PLOCS ); + //hHQ_core->env_stab_fx = (Word16) floatToFixed( hHQ_core->env_stab, Q15 ); hHQ_core->last_fec = hHQ_core->last_fec; hHQ_core->ph_ecu_HqVoicing = hHQ_core->ph_ecu_HqVoicing; hHQ_core->ph_ecu_active = hHQ_core->ph_ecu_active; - floatToFixed_arr( hHQ_core->mag_chg_1st, hHQ_core->mag_chg_1st_fx, Q15, LGW_MAX ); - floatToFixed_arr( hHQ_core->Xavg, hHQ_core->Xavg_fx, 0, LGW_MAX ); - hHQ_core->mean_prev_fx = floatToFixed(hHQ_core->mean_prev, 0); - hHQ_core->beta_mute_fx = (Word16) floatToFixed( hHQ_core->beta_mute, Q15 ); - hHQ_core->env_stab_plc_fx = (Word16) floatToFixed( hHQ_core->env_stab_plc, Q15 ); + //floatToFixed_arr( hHQ_core->mag_chg_1st, hHQ_core->mag_chg_1st_fx, Q15, LGW_MAX ); + //floatToFixed_arr( hHQ_core->Xavg, hHQ_core->Xavg_fx, 0, LGW_MAX ); + //hHQ_core->mean_prev_fx = floatToFixed(hHQ_core->mean_prev, 0); + //hHQ_core->beta_mute_fx = (Word16) floatToFixed( hHQ_core->beta_mute, Q15 ); + //hHQ_core->env_stab_plc_fx = (Word16) floatToFixed( hHQ_core->env_stab_plc, Q15 ); floatToFixed_arr( st->t_audio_q, st->t_audio_q_fx, -1, L_FRAME ); #endif @@ -907,30 +907,30 @@ ivas_error ivas_core_dec( fixedToFloat_arr( output_fx, output[n], Q_output, L_FRAME48k ); #ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED - hHQ_core->mean_prev = fixedToFloat(hHQ_core->mean_prev_fx, 0); + //hHQ_core->mean_prev = fixedToFloat(hHQ_core->mean_prev_fx, 0); fixedToFloat_arr( hHQ_core->old_out_fx, hHQ_core->old_out, hHQ_core->Q_old_wtda, L_FRAME48k ); fixedToFloat_arr( hHQ_core->old_out_LB_fx, hHQ_core->old_outLB, hHQ_core->Q_old_wtda_LB, L_FRAME32k ); fixedToFloat_arr( st->hTcxDec->old_syn_Overl, st->hTcxDec->old_syn_Overl_float, -1, L_FRAME32k / 2 ); - fixedToFloat_arr( hHQ_core->oldgapsynth_fx, hHQ_core->oldgapsynth, 0, L_FRAME32k ); // Check - fixedToFloat_arr( st->old_Aq_12_8_fx, st->old_Aq_12_8, Q12, M + 1 ); // Check + //fixedToFloat_arr( hHQ_core->oldgapsynth_fx, hHQ_core->oldgapsynth, 0, L_FRAME32k ); // Check + //fixedToFloat_arr( st->old_Aq_12_8_fx, st->old_Aq_12_8, Q12, M + 1 ); // Check fixedToFloat_arrL( st->old_pitch_buf_fx, st->old_pitch_buf, Q16, 2 * NB_SUBFR16k + 2 ); - fixedToFloat_arrL( hHQ_core->prev_normq_fx, hHQ_core->prev_normq, Q14, SFM_N_WB ); - FOR( i = 0; i < SFM_N_WB; ++i ) - { - hHQ_core->prev_env[i] = fixedToFloat( hHQ_core->prev_env_fx[i], hHQ_core->prev_env_Q[i] ); - } - hHQ_core->energy_lt = fixedToFloat( hHQ_core->energy_lt_fx, Q13 ); - fixedToFloat_arr( hHQ_core->prev_noise_level_fx, hHQ_core->prev_noise_level, Q15, 2 ); + //fixedToFloat_arrL( hHQ_core->prev_normq_fx, hHQ_core->prev_normq, Q14, SFM_N_WB ); + //FOR( i = 0; i < SFM_N_WB; ++i ) + //{ + // hHQ_core->prev_env[i] = fixedToFloat( hHQ_core->prev_env_fx[i], hHQ_core->prev_env_Q[i] ); + //} + //hHQ_core->energy_lt = fixedToFloat( hHQ_core->energy_lt_fx, Q13 ); + //fixedToFloat_arr( hHQ_core->prev_noise_level_fx, hHQ_core->prev_noise_level, Q15, 2 ); fixedToFloat_arrL( hHQ_core->prev_coeff_out_fx, hHQ_core->prev_coeff_out, Q12, L_HQ_WB_BWE ); FOR( i = 0; i < 3; ++i ) { hHQ_core->prev_coeff_out[i] = hHQ_core->old_is_transient[i]; } - hHQ_core->prev_ni_ratio = fixedToFloat( hHQ_core->prev_ni_ratio_fx, Q15 ); - hHQ_core->mean_prev_nc = fixedToFloat( hHQ_core->mean_prev_nc_fx, 0 ); - hHQ_core->wmold_hb = fixedToFloat( hHQ_core->wmold_hb_fx, Q15 ); - hHQ_core->mean_prev_hb = fixedToFloat( hHQ_core->mean_prev_hb_fx, 0 ); - hHQ_core->memfilt_lb = fixedToFloat( hHQ_core->memfilt_lb_fx, 0 ); + //hHQ_core->prev_ni_ratio = fixedToFloat( hHQ_core->prev_ni_ratio_fx, Q15 ); + //hHQ_core->mean_prev_nc = fixedToFloat( hHQ_core->mean_prev_nc_fx, 0 ); + //hHQ_core->wmold_hb = fixedToFloat( hHQ_core->wmold_hb_fx, Q15 ); + //hHQ_core->mean_prev_hb = fixedToFloat( hHQ_core->mean_prev_hb_fx, 0 ); + //hHQ_core->memfilt_lb = fixedToFloat( hHQ_core->memfilt_lb_fx, 0 ); hHQ_core->HqVoicing = hHQ_core->HqVoicing; hHQ_core->ph_ecu_HqVoicing = hHQ_core->ph_ecu_HqVoicing; hHQ_core->prev_hqswb_clas = hHQ_core->prev_hqswb_clas; @@ -944,25 +944,25 @@ ivas_error ivas_core_dec( hHQ_core->mem_env_delta_hqfec = hHQ_core->mem_env_delta_hqfec; hHQ_core->no_att_hangover = hHQ_core->no_att_hangover; hHQ_core->oldHqVoicing = hHQ_core->oldHqVoicing; - fixedToFloat_arr( hHQ_core->env_stab_state_p_fx, hHQ_core->env_stab_state_p, Q15, NUM_ENV_STAB_PLC_STATES ); + //fixedToFloat_arr( hHQ_core->env_stab_state_p_fx, hHQ_core->env_stab_state_p, Q15, NUM_ENV_STAB_PLC_STATES ); hHQ_core->envstabplc_hocnt = hHQ_core->envstabplc_hocnt; fixedToFloat_arr( st->hTcxDec->prev_good_synth_fx - tmp_size, st->hTcxDec->prev_good_synth - tmp_size, 0, 2 * output_frame + tmp_size ); hHQ_core->time_offs = hHQ_core->time_offs; - fixedToFloat_arr( hHQ_core->X_sav_fx, hHQ_core->X_sav, hHQ_core->Q_X_sav, PH_ECU_SPEC_SIZE ); + //fixedToFloat_arr( hHQ_core->X_sav_fx, hHQ_core->X_sav, hHQ_core->Q_X_sav, PH_ECU_SPEC_SIZE ); hHQ_core->num_p = hHQ_core->num_p; FOR( i = 0; i < MAX_PLOCS; ++i ) { hHQ_core->plocs[i] = hHQ_core->plocs[i]; } - fixedToFloat_arrL( hHQ_core->plocsi_fx, hHQ_core->plocsi, Q16, MAX_PLOCS ); - hHQ_core->env_stab = fixedToFloat( hHQ_core->env_stab_fx, Q15 ); + //fixedToFloat_arrL( hHQ_core->plocsi_fx, hHQ_core->plocsi, Q16, MAX_PLOCS ); + //hHQ_core->env_stab = fixedToFloat( hHQ_core->env_stab_fx, Q15 ); hHQ_core->last_fec = hHQ_core->last_fec; hHQ_core->ph_ecu_HqVoicing = hHQ_core->ph_ecu_HqVoicing; hHQ_core->ph_ecu_active = hHQ_core->ph_ecu_active; - fixedToFloat_arr( hHQ_core->mag_chg_1st_fx, hHQ_core->mag_chg_1st, Q15, LGW_MAX ); - fixedToFloat_arr( hHQ_core->Xavg_fx, hHQ_core->Xavg, 0, LGW_MAX ); - hHQ_core->beta_mute = fixedToFloat( hHQ_core->beta_mute_fx, Q15 ); - hHQ_core->env_stab_plc = fixedToFloat( hHQ_core->env_stab_plc_fx, Q15 ); + //fixedToFloat_arr( hHQ_core->mag_chg_1st_fx, hHQ_core->mag_chg_1st, Q15, LGW_MAX ); + //fixedToFloat_arr( hHQ_core->Xavg_fx, hHQ_core->Xavg, 0, LGW_MAX ); + //hHQ_core->beta_mute = fixedToFloat( hHQ_core->beta_mute_fx, Q15 ); + //hHQ_core->env_stab_plc = fixedToFloat( hHQ_core->env_stab_plc_fx, Q15 ); fixedToFloat_arr( st->t_audio_q_fx, st->t_audio_q, -1, L_FRAME ); #endif #else @@ -978,11 +978,11 @@ ivas_error ivas_core_dec( { #ifdef IVAS_FLOAT_FIXED /* To be cleaned up once the caller function is converted // These changes are for system testing of fixed changes made */ - Word16 lsp_old_PCh_fx[M], tdm_lspQ_PCh_fx[M]; + Word16 /*lsp_old_PCh_fx[M], */tdm_lspQ_PCh_fx[M]; Word16 tdm_lsfQ_PCh_fx[M]/*, lsf_old_PCh_fx[M]*/; FOR( i = 0; i < M; i++ ) { - lsp_old_PCh_fx[i] = float_to_fix16( st->lsp_old[i], 15 ); + //lsp_old_PCh_fx[i] = float_to_fix16( st->lsp_old[i], 15 ); //lsf_old_PCh_fx[i] = (Word16) ( st->lsf_old[i] * 2.56f ); tdm_lsfQ_PCh_fx[i] = (Word16) ( tdm_lsfQ_PCh[i] * 2.56f ); } @@ -1000,7 +1000,7 @@ ivas_error ivas_core_dec( { old_pitch_buf_fx[i] = float_to_fix16( st->old_pitch_buf[i], Q_var ); } - td_stereo_param_updt_fx( lsp_old_PCh_fx, st->lsf_old_fx, old_pitch_buf_fx + st->nb_subfr, + td_stereo_param_updt_fx( st->lsp_old_fx, st->lsf_old_fx, old_pitch_buf_fx + st->nb_subfr, tdm_lspQ_PCh_fx, tdm_lsfQ_PCh_fx, tdm_Pri_pitch_buf_fx, st->flag_ACELP16k, hStereoTD->tdm_use_IAWB_Ave_lpc, Q_var ); for ( i = 0; i < M; i++ ) { @@ -1276,36 +1276,36 @@ ivas_error ivas_core_dec( { for (int i = 0; i < L_SHB_LAHEAD; i++) { - st->hBWE_TD->syn_overlap_fx_32[i] = st->hBWE_TD->syn_overlap[i] * (1 << 11); + st->hBWE_TD->syn_overlap_fx_32[i] = (Word32)(st->hBWE_TD->syn_overlap[i] * (1 << 11)); } for (int i = 0; i < INTERP_3_2_MEM_LEN; i++) { - st->hBWE_TD->int_3_over_2_tbemem_dec_fx_32[i] = st->hBWE_TD->int_3_over_2_tbemem_dec[i] * (1 << 11); + st->hBWE_TD->int_3_over_2_tbemem_dec_fx_32[i] = (Word32)(st->hBWE_TD->int_3_over_2_tbemem_dec[i] * (1 << 11)); } for (int i = 0; i < HILBERT_MEM_SIZE; i++) { - st->hBWE_TD->genSHBsynth_Hilbert_Mem_fx[i] = st->hBWE_TD->genSHBsynth_Hilbert_Mem[i] * (1 << 11); + st->hBWE_TD->genSHBsynth_Hilbert_Mem_fx[i] = (Word32)(st->hBWE_TD->genSHBsynth_Hilbert_Mem[i] * (1 << 11)); } for (int i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++) { - st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32[i] = st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local[i] * (1 << 11); + st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32[i] = (Word32)(st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local[i] * (1 << 11)); } for (int i = 0; i < L_SHB_TRANSITION_LENGTH; i++) { - st->hBWE_TD->old_tbe_synth_fx_32[i] = st->hBWE_TD->old_tbe_synth[i] * (1 << 11); + st->hBWE_TD->old_tbe_synth_fx_32[i] = (Word32)(st->hBWE_TD->old_tbe_synth[i] * (1 << 11)); } for (int i = 0; i < 2 * ALLPASSSECTIONS_STEEP + 1; i++) { - st->hBWE_TD->mem_resamp_HB_32k_fx_32[i] = st->hBWE_TD->mem_resamp_HB_32k[i] * (1 << 11); + st->hBWE_TD->mem_resamp_HB_32k_fx_32[i] = (Word32)(st->hBWE_TD->mem_resamp_HB_32k[i] * (1 << 11)); } for (int i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++) { - st->hBWE_TD->state_lsyn_filt_dwn_shb_fx_32[i] = st->hBWE_TD->state_lsyn_filt_dwn_shb[i] * (1 << 11); - st->hBWE_TD->state_lsyn_filt_shb_fx_32[i] = st->hBWE_TD->state_lsyn_filt_shb[i] * (1 << 11); + st->hBWE_TD->state_lsyn_filt_dwn_shb_fx_32[i] = (Word32)(st->hBWE_TD->state_lsyn_filt_dwn_shb[i] * (1 << 11)); + st->hBWE_TD->state_lsyn_filt_shb_fx_32[i] = (Word32)(st->hBWE_TD->state_lsyn_filt_shb[i] * (1 << 11)); } for (int i = 0; i < INTERP_3_1_MEM_LEN; i++) { - st->hBWE_TD->mem_resamp_HB_fx_32[i] = st->hBWE_TD->mem_resamp_HB[i] * (1 << 11); + st->hBWE_TD->mem_resamp_HB_fx_32[i] = (Word32)(st->hBWE_TD->mem_resamp_HB[i] * (1 << 11)); } } } @@ -1348,8 +1348,9 @@ ivas_error ivas_core_dec( floatToFixed_arr(synth[n], synth_fx16, Q_synth, L_FRAME48k); floatToFixed_arrL(output[n], output_fx32, 4, L_FRAME48k); - tmp = extract_l(L_shr(st->output_Fs, 13)); - Word16 Fs_kHz = shl(add(tmp, 1), 3); + Word16 s_tmp; + s_tmp = extract_l(L_shr(st->output_Fs, 13)); + Word16 Fs_kHz = shl(add(s_tmp, 1), 3); Word16 delta = 1; move16(); @@ -1368,11 +1369,11 @@ ivas_error ivas_core_dec( { floatToFixed_arr(st->hHQ_core->old_out, st->hHQ_core->old_out_fx, 0, L_FRAME48k); floatToFixed_arr(st->hHQ_core->fer_samples, st->hHQ_core->fer_samples_fx, 0, NS2SA(st->output_Fs, 3000000)); - FOR(i = 0; i < SFM_N_WB; ++i) - { - st->hHQ_core->prev_env_fx[i] = floatToFixed(st->hHQ_core->prev_env[i], st->hHQ_core->prev_env_Q[i]); - } - floatToFixed_arrL(st->hHQ_core->prev_normq, st->hHQ_core->prev_normq_fx, 14, SFM_N_WB); + //FOR(i = 0; i < SFM_N_WB; ++i) + //{ + // st->hHQ_core->prev_env_fx[i] = floatToFixed(st->hHQ_core->prev_env[i], st->hHQ_core->prev_env_Q[i]); + //} + //floatToFixed_arrL(st->hHQ_core->prev_normq, st->hHQ_core->prev_normq_fx, 14, SFM_N_WB); } floatToFixed_arr(st->previoussynth, st->previoussynth_fx, 0, L_FRAME48k); floatToFixed_arr(st->delay_buf_out, st->delay_buf_out_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP); @@ -1439,11 +1440,11 @@ ivas_error ivas_core_dec( test(); test(); test(); test(); IF ( (EQ_16(st->bwidth, SWB) || EQ_16(st->bwidth, FB) ) && (EQ_16(st->last_extl, SWB_TBE) || EQ_16(st->last_extl, FB_TBE) ) ) { - GenTransition_fixed( st->hBWE_TD, &hb_synth_fx[n], output_Fs, st->element_mode, st->L_frame, st->rf_flag, st->total_brate ); + GenTransition_fixed( st->hBWE_TD, hb_synth_fx[n], output_Fs, st->element_mode, st->L_frame, st->rf_flag, st->total_brate ); } ELSE IF (EQ_16(st->bwidth, WB) && EQ_16(st->last_extl, WB_TBE) ) { - GenTransition_WB_fixed( st->hBWE_TD, &hb_synth_fx[n], output_Fs ); + GenTransition_WB_fixed( st->hBWE_TD, hb_synth_fx[n], output_Fs ); move16(); } @@ -1550,11 +1551,11 @@ ivas_error ivas_core_dec( { fixedToFloat_arr(st->hHQ_core->old_out_fx, st->hHQ_core->old_out, 0, L_FRAME48k); fixedToFloat_arr(st->hHQ_core->fer_samples_fx, st->hHQ_core->fer_samples, 0, NS2SA(st->output_Fs, 3000000)); - FOR(i = 0; i < SFM_N_WB; ++i) - { - st->hHQ_core->prev_env[i] = fixedToFloat(st->hHQ_core->prev_env_fx[i], st->hHQ_core->prev_env_Q[i]); - } - fixedToFloat_arrL(st->hHQ_core->prev_normq_fx, st->hHQ_core->prev_normq, 14, SFM_N_WB); + //FOR(i = 0; i < SFM_N_WB; ++i) + //{ + // st->hHQ_core->prev_env[i] = fixedToFloat(st->hHQ_core->prev_env_fx[i], st->hHQ_core->prev_env_Q[i]); + //} + //fixedToFloat_arrL(st->hHQ_core->prev_normq_fx, st->hHQ_core->prev_normq, 14, SFM_N_WB); } fixedToFloat_arr(st->previoussynth_fx, st->previoussynth, 0, L_FRAME48k); @@ -1600,7 +1601,7 @@ ivas_error ivas_core_dec( { st->hBWE_FD->prev_mode = st->hBWE_FD->prev_mode; } - st->hBWE_FD->prev_Energy_wb = st->hBWE_FD->prev_Energy_wb_fx; + st->hBWE_FD->prev_Energy_wb = (float)st->hBWE_FD->prev_Energy_wb_fx; st->hBWE_FD->prev_L_swb_norm = st->hBWE_FD->prev_L_swb_norm; st->hBWE_FD->prev_flag = st->hBWE_FD->prev_flag; fixedToFloat_arr(st->hBWE_FD->mem_imdct_fx, st->hBWE_FD->mem_imdct, 0, L_FRAME48k); // setting to zero @@ -1623,7 +1624,6 @@ ivas_error ivas_core_dec( fixedToFloat_arr(st->hBWE_TD->mem_resamp_HB_32k_fx, st->hBWE_TD->mem_resamp_HB_32k, 0, 2 * ALLPASSSECTIONS_STEEP + 1); } fixedToFloat_arr(st->hBWE_TD->int_3_over_2_tbemem_dec_fx, st->hBWE_TD->int_3_over_2_tbemem_dec, 0, INTERP_3_2_MEM_LEN); - st->hBWE_TD->prev_pow_exc16kWhtnd = (float)st->hBWE_TD->prev_pow_exc16kWhtnd_fx / 32767; } ELSE IF(st->hBWE_TD != NULL && (st->last_core == TCX_20_CORE || st->last_core == TCX_10_CORE)) { @@ -1640,7 +1640,6 @@ ivas_error ivas_core_dec( reset_swb_tbe_synth = 1; fixedToFloat_arr(st->hBWE_TD->int_3_over_2_tbemem_dec_fx, st->hBWE_TD->int_3_over_2_tbemem_dec, 0, INTERP_3_2_MEM_LEN); // setting to zero fixedToFloat_arr(st->hBWE_TD->mem_resamp_HB_32k_fx, st->hBWE_TD->mem_resamp_HB_32k, 0, 2 * ALLPASSSECTIONS_STEEP + 1); // setting to zero - st->hBWE_TD->prev_pow_exc16kWhtnd = (float)st->hBWE_TD->prev_pow_exc16kWhtnd_fx / 32767; /*Q15 1.f*/ IF(EQ_16(st->bwidth, FB)) { @@ -1649,7 +1648,6 @@ ivas_error ivas_core_dec( st->hBWE_FD->prev_fb_ener_adjust = fixedToFloat(st->prev_fb_ener_adjust_fx, 0); } fixedToFloat_arr(st->hBWE_TD->fb_state_lpc_syn_fx, st->hBWE_TD->fb_state_lpc_syn, 0, LPC_SHB_ORDER); - st->hBWE_TD->fb_tbe_demph = fixedToFloat(st->hBWE_TD->fb_tbe_demph_fx, 0); // setting to zero } } /*------------TBEreset_dec_ivas_fx-end--------------------*/ @@ -1658,7 +1656,6 @@ ivas_error ivas_core_dec( IF(EQ_16(st->extl, FB_TBE) && (NE_16(st->last_extl, FB_TBE) || NE_16(st->L_frame, st->last_L_frame))) { fixedToFloat_arr(st->hBWE_TD->fb_state_lpc_syn_fx, st->hBWE_TD->fb_state_lpc_syn, 0, LPC_SHB_ORDER); - st->hBWE_TD->fb_tbe_demph = fixedToFloat(st->hBWE_TD->fb_tbe_demph_fx, 0); // setting to zero } @@ -1671,9 +1668,6 @@ ivas_error ivas_core_dec( IF(reset_swb_tbe) { fixedToFloat_arr(st->hBWE_TD->syn_overlap_fx, st->hBWE_TD->syn_overlap, 0, L_SHB_LAHEAD); // setting to zero - - st->hBWE_TD->tbe_demph = fixedToFloat(st->hBWE_TD->tbe_demph_fx, 0); // setting to zero - st->hBWE_TD->tbe_premph = fixedToFloat(st->hBWE_TD->tbe_premph_fx, 0); // setting to zero } IF(reset_swb_tbe_synth) { @@ -1688,12 +1682,6 @@ ivas_error ivas_core_dec( fixedToFloat_arr(st->hBWE_TD->mem_resamp_HB_fx, st->hBWE_TD->mem_resamp_HB, 0, INTERP_3_1_MEM_LEN); // setting to zero } } - /* Interp_3_2 CNG buffers reset */ - IF(st->hTdCngDec != NULL && EQ_32(st->output_Fs, 48000) && ((GT_32(st->last_core_brate, SID_2k40)) && (EQ_32(st->core_brate, FRAME_NO_DATA) || EQ_32(st->core_brate, SID_2k40)))) - { - fixedToFloat_arr(st->interpol_3_2_cng_dec_fx, st->hTdCngDec->interpol_3_2_cng_dec, 0, INTERP_3_2_MEM_LEN); - } - /*------------------reset-code-end-----------------------*/ free(synth_fx16); @@ -1764,35 +1752,19 @@ ivas_error ivas_core_dec( IF( hBWE_TD != NULL ) { - hBWE_TD->GainFrame_prevfrm_fx = floatToFixed( hBWE_TD->GainFrame_prevfrm, Q18 ); - floatToFixed_arr( hBWE_TD->state_lsyn_filt_shb, hBWE_TD->state_lsyn_filt_shb_fx, st->prev_Qx, 2 * ALLPASSSECTIONS_STEEP ); floatToFixed_arr( hBWE_TD->state_lsyn_filt_dwn_shb, hBWE_TD->state_lsyn_filt_dwn_shb_fx, st->prev_Qx, 2 * ALLPASSSECTIONS_STEEP ); floatToFixed_arr( hBWE_TD->mem_resamp_HB, hBWE_TD->state_32and48k_WB_upsample_fx, st->prev_Qx, 2 * ALLPASSSECTIONS_STEEP ); floatToFixed_arr( hBWE_TD->mem_resamp_HB, hBWE_TD->mem_resamp_HB_fx, st->prev_Qx, INTERP_3_1_MEM_LEN ); - floatToFixed_arr( &st->hBWE_TD->tilt_swb_fec, &st->hBWE_TD->tilt_swb_fec_fx, Q11, 1 ); - - floatToFixed_arr( st->hBWE_TD->cur_sub_Aq, st->hBWE_TD->cur_sub_Aq_fx, Q12, M + 1 ); - st->hBWE_TD->prev1_shb_ener_sf_fx = floatToFixed( st->hBWE_TD->prev1_shb_ener_sf, 0 ); // recheck - st->hBWE_TD->prev2_shb_ener_sf_fx = floatToFixed( st->hBWE_TD->prev2_shb_ener_sf, 0 ); // recheck - st->hBWE_TD->prev3_shb_ener_sf_fx = floatToFixed( st->hBWE_TD->prev3_shb_ener_sf, 0 ); // recheck - st->hBWE_TD->prev_res_shb_gshape_fx = float_to_fix16( st->hBWE_TD->prev_res_shb_gshape, Q14 ); // recheck - st->hBWE_TD->prev_mixFactors_fx = float_to_fix16( st->hBWE_TD->prev_mixFactors, Q15 ); // recheck - floatToFixed_arr( hBWE_TD->old_bwe_exc_extended, hBWE_TD->old_bwe_exc_extended_fx, st->prev_Q_bwe_exc - 16, NL_BUFF_OFFSET ); - hBWE_TD->tbe_premph_fx = (Word16) check_bounds_l( floatToFixed( hBWE_TD->tbe_premph, st->prev_Q_bwe_exc - 16 ), -32768, 32767 ); - hBWE_TD->tbe_demph_fx = (Word16) check_bounds_l( floatToFixed( hBWE_TD->tbe_demph, st->prev_Q_bwe_exc - 16 - NOISE_QADJ ), -32768, 32767 ); - hBWE_TD->fb_tbe_demph_fx = (Word16) check_bounds_l( floatToFixed( hBWE_TD->fb_tbe_demph, st->prev_Q_bwe_exc_fb ), -32768, 32767 ); - floatToFixed_arr( hBWE_TD->fb_state_lpc_syn, hBWE_TD->fb_state_lpc_syn_fx, st->prev_Q_bwe_exc_fb - 16 - 4, LPC_SHB_ORDER ); hBWE_TD->prev_wb_bwe_frame_pow_fx = floatToFixed( hBWE_TD->prev_wb_bwe_frame_pow, st->prev_frame_pow_exp ); floatToFixed_arr( hBWE_TD->old_tbe_synth, hBWE_TD->old_tbe_synth_fx, st->prev_Qx, L_SHB_TRANSITION_LENGTH ); - hBWE_TD->prev_pow_exc16kWhtnd_fx32 = floatToFixed( hBWE_TD->prev_pow_exc16kWhtnd, 0 ); floatToFixed_arr( hBWE_TD->syn_overlap, hBWE_TD->syn_overlap_fx, st->prev_Q_bwe_syn2, L_SHB_LAHEAD ); // Check for ( int i = 0; i < INTERP_3_2_MEM_LEN; i++ ) @@ -1830,14 +1802,8 @@ ivas_error ivas_core_dec( IF( st->hTdCngDec != NULL ) { - floatToFixed_arr( st->hTdCngDec->lsp_shb_prev_prev, st->hTdCngDec->lsp_shb_prev_prev_fx, Q15, LPC_SHB_ORDER ); - floatToFixed_arr( st->hTdCngDec->lsp_shb_prev, st->hTdCngDec->lsp_shb_prev_fx, Q15, LPC_SHB_ORDER ); - st->hTdCngDec->shb_cng_gain_fx_32 = float_to_fix(st->hTdCngDec->shb_cng_gain, Q11); st->hTdCngDec->shb_cng_ener_fx_32 = float_to_fix(st->hTdCngDec->shb_cng_ener, Q11); - st->hTdCngDec->last_shb_cng_ener_fx_32 = float_to_fix(st->hTdCngDec->last_shb_cng_ener, Q11); - st->hTdCngDec->wb_cng_ener_fx_32 = float_to_fix(st->hTdCngDec->wb_cng_ener, Q11); - st->hTdCngDec->last_wb_cng_ener_fx_32 = float_to_fix(st->hTdCngDec->last_wb_cng_ener, Q11); } if ( hStereoICBWE != NULL ) @@ -2017,33 +1983,15 @@ ivas_error ivas_core_dec( IF(hBWE_TD != NULL) { - hBWE_TD->GainFrame_prevfrm = fixedToFloat(hBWE_TD->GainFrame_prevfrm_fx, Q18); - fixedToFloat_arr(hBWE_TD->state_lsyn_filt_shb_fx, hBWE_TD->state_lsyn_filt_shb, st->prev_Qx, 2 * ALLPASSSECTIONS_STEEP); fixedToFloat_arr(hBWE_TD->state_lsyn_filt_dwn_shb_fx, hBWE_TD->state_lsyn_filt_dwn_shb, st->prev_Qx, 2 * ALLPASSSECTIONS_STEEP); fixedToFloat_arr(hBWE_TD->mem_resamp_HB_fx, hBWE_TD->mem_resamp_HB, st->prev_Qx, INTERP_3_1_MEM_LEN); - fixedToFloat_arr(&st->hBWE_TD->tilt_swb_fec_fx, &st->hBWE_TD->tilt_swb_fec, Q11, 1); - - fixedToFloat_arr(st->hBWE_TD->cur_sub_Aq_fx, st->hBWE_TD->cur_sub_Aq, Q12, M + 1); - st->hBWE_TD->prev1_shb_ener_sf = fixedToFloat(st->hBWE_TD->prev1_shb_ener_sf_fx, 0); // recheck - st->hBWE_TD->prev2_shb_ener_sf = fixedToFloat(st->hBWE_TD->prev2_shb_ener_sf_fx, 0); // recheck - st->hBWE_TD->prev3_shb_ener_sf = fixedToFloat(st->hBWE_TD->prev3_shb_ener_sf_fx, 0); // recheck - st->hBWE_TD->prev_res_shb_gshape = fixedToFloat(st->hBWE_TD->prev_res_shb_gshape_fx, Q14); // recheck - st->hBWE_TD->prev_mixFactors = fixedToFloat(st->hBWE_TD->prev_mixFactors_fx, Q15); // recheck - fixedToFloat_arr(hBWE_TD->old_bwe_exc_extended_fx, hBWE_TD->old_bwe_exc_extended, st->prev_Q_bwe_exc - 16, NL_BUFF_OFFSET); - hBWE_TD->tbe_premph = fixedToFloat(hBWE_TD->tbe_premph_fx, st->prev_Q_bwe_exc - 16); - hBWE_TD->tbe_demph = fixedToFloat(hBWE_TD->tbe_demph_fx, st->prev_Q_bwe_exc - 16 - NOISE_QADJ); if (st->prev_Q_bwe_exc_fb != 51) { - if (st->prev_Q_bwe_exc_fb > 31) - { - Scale_sig(&hBWE_TD->fb_tbe_demph_fx, 1, 31 - st->prev_Q_bwe_exc_fb); - } - hBWE_TD->fb_tbe_demph = fixedToFloat(hBWE_TD->fb_tbe_demph_fx, min(st->prev_Q_bwe_exc_fb, 31)); fixedToFloat_arr(hBWE_TD->fb_state_lpc_syn_fx, hBWE_TD->fb_state_lpc_syn, st->prev_Q_bwe_exc_fb - 16 - 4, LPC_SHB_ORDER); } else @@ -2053,7 +2001,6 @@ ivas_error ivas_core_dec( } hBWE_TD->prev_wb_bwe_frame_pow = fixedToFloat(hBWE_TD->prev_wb_bwe_frame_pow_fx, st->prev_frame_pow_exp); - hBWE_TD->prev_pow_exc16kWhtnd = fixedToFloat(hBWE_TD->prev_pow_exc16kWhtnd_fx32, 0); fixedToFloat_arr(hBWE_TD->syn_overlap_fx, hBWE_TD->syn_overlap, st->prev_Q_bwe_syn2, L_SHB_LAHEAD); // Check for (int i = 0; i < INTERP_3_2_MEM_LEN; i++) @@ -2095,15 +2042,9 @@ ivas_error ivas_core_dec( } IF(st->hTdCngDec != NULL) - { - fixedToFloat_arr(st->hTdCngDec->lsp_shb_prev_prev_fx, st->hTdCngDec->lsp_shb_prev_prev, Q15, LPC_SHB_ORDER); - fixedToFloat_arr(st->hTdCngDec->lsp_shb_prev_fx, st->hTdCngDec->lsp_shb_prev, Q15, LPC_SHB_ORDER); - + { st->hTdCngDec->shb_cng_gain = fix_to_float(st->hTdCngDec->shb_cng_gain_fx_32, Q11); st->hTdCngDec->shb_cng_ener = fix_to_float(st->hTdCngDec->shb_cng_ener_fx_32, Q11); - st->hTdCngDec->last_shb_cng_ener = fix_to_float(st->hTdCngDec->last_shb_cng_ener_fx_32, Q11); - st->hTdCngDec->wb_cng_ener = fix_to_float(st->hTdCngDec->wb_cng_ener_fx_32, Q11); - st->hTdCngDec->last_wb_cng_ener = fix_to_float(st->hTdCngDec->last_wb_cng_ener_fx_32, Q11); } if (hStereoICBWE != NULL) @@ -2441,7 +2382,7 @@ ivas_error ivas_core_dec( { FOR(int ind = 0; ind < L_FRAME32k; ind++) { - hCPE->hCoreCoder[ch_ind]->hHQ_core->old_outLB_fx[ind] = hCPE->hCoreCoder[ch_ind]->hHQ_core->old_outLB[ind] * (1 << 11); + hCPE->hCoreCoder[ch_ind]->hHQ_core->old_outLB_fx[ind] = (Word32)(hCPE->hCoreCoder[ch_ind]->hHQ_core->old_outLB[ind] * (1 << 11)); } FOR(int ind = 0; ind < L_FRAME48k; ind++) { @@ -2544,7 +2485,7 @@ ivas_error ivas_core_dec( { FOR(int ind = 0; ind < L_FRAME32k; ind++) { - hSCE->hCoreCoder[0]->hHQ_core->old_outLB_fx[ind] = hSCE->hCoreCoder[0]->hHQ_core->old_outLB[ind] * (1 << 11); + hSCE->hCoreCoder[0]->hHQ_core->old_outLB_fx[ind] = (Word32)(hSCE->hCoreCoder[0]->hHQ_core->old_outLB[ind] * (1 << 11)); } FOR(int ind = 0; ind < L_FRAME48k; ind++) { @@ -2578,10 +2519,10 @@ ivas_error ivas_core_dec( } } - Word32 exp_max = 0; + Word16 exp_max = 0; Word32 output_fx_loc[L_FRAME48k]; floatToFixed_arr(st->old_synth_sw, st->old_synth_sw_fx, -2, 429); - st->prev_tilt_code_dec_fx = floatToFixed(st->prev_tilt_code_dec, Q15); + st->prev_tilt_code_dec_fx = (Word16)floatToFixed(st->prev_tilt_code_dec, Q15); FOR(Word16 ind = 0; ind < 16; ind++) { st->mem_AR_fx[ind] = (Word16)(st->mem_AR[ind] * 2.56f); } @@ -2601,7 +2542,7 @@ ivas_error ivas_core_dec( { IF ( hCPE != NULL ) { - stereo_td2dft_update_fx( hCPE, n, &output_fx[n], &synth_fx[n], &hb_synth_fx[n], output_frame ); + stereo_td2dft_update_fx( hCPE, n, output_fx[n], synth_fx[n], hb_synth_fx[n], output_frame ); } } } @@ -2617,7 +2558,7 @@ ivas_error ivas_core_dec( IF (EQ_16(hCPE->nchan_out, 1) && EQ_16(hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF )) { /* mono output for non-residual coding modes uses CLDFB instead of DFT - requires DFT buffer update in case of bitrate switching */ - stereo_td2dft_update_fx( hCPE, n, &output_fx[n], &synth_fx[n], &hb_synth_fx[n], output_frame ); + stereo_td2dft_update_fx( hCPE, n, output_fx[n], synth_fx[n], hb_synth_fx[n], output_frame ); } } diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index c1a7d0d36..07fe4e1c6 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -143,10 +143,17 @@ ivas_error ivas_corecoder_dec_reconfig( if ( st_ivas->nCPE > 1 ) { +#ifdef IVAS_FLOAT_FIXED + if ( ( error = mct_dec_reconfigure_fx( st_ivas, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } +#else if ( ( error = mct_dec_reconfigure( st_ivas, 0 ) ) != IVAS_ERR_OK ) { return error; } +#endif } } else @@ -278,10 +285,17 @@ ivas_error ivas_corecoder_dec_reconfig( } else if ( st_ivas->hMCT != NULL && st_ivas->nCPE > 1 ) { +#ifdef IVAS_FLOAT_FIXED + if ( ( error = mct_dec_reconfigure_fx( st_ivas, st_ivas->nchan_transport != nchan_transport_old ) ) != IVAS_ERR_OK ) + { + return error; + } +#else if ( ( error = mct_dec_reconfigure( st_ivas, st_ivas->nchan_transport != nchan_transport_old ) ) != IVAS_ERR_OK ) { return error; } +#endif } /* special case, if we have a single CPE and had MCT before we need to init the MDCT stereo handles here */ @@ -588,7 +602,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx( /* resample CLDFB analysis instances */ FOR( i = 0; i < min( numCldfbAnalyses, numCldfbAnalyses_old ); i++ ) { - IF( EQ_32( L_mult0( L_mult0( st_ivas->cldfbAnaDec[i]->no_channels, st_ivas->cldfbAnaDec[i]->no_col ), FRAMES_PER_SEC ), hDecoderConfig->output_Fs ) ) + IF( EQ_32( L_mult0( extract_l(L_mult0( st_ivas->cldfbAnaDec[i]->no_channels, st_ivas->cldfbAnaDec[i]->no_col )), FRAMES_PER_SEC ), hDecoderConfig->output_Fs ) ) { resampleCldfb_ivas_fx( st_ivas->cldfbAnaDec[i], hDecoderConfig->output_Fs ); } diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index e6d910aa2..ae246cf6a 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -729,7 +729,7 @@ ivas_error ivas_cpe_dec_fx( floatToFixed_arr(hCPE->hStereoDft->hBpf->mem_mean_pit, hCPE->hStereoDft->hBpf->mem_mean_pit_fx, Q4, sizeof(hCPE->hStereoDft->hBpf->mem_mean_pit) / sizeof(hCPE->hStereoDft->hBpf->mem_mean_pit[0])); floatToFixed_arr(hCPE->hCoreCoder[0]->old_pitch_buf, hCPE->hCoreCoder[0]->old_pitch_buf_16_fx, Q6, sizeof(hCPE->hCoreCoder[0]->old_pitch_buf_16_fx) / sizeof(hCPE->hCoreCoder[0]->old_pitch_buf_16_fx[0])); hCPE->hStereoDft->hBpf->psf_att_fx = (Word16)floatToFixed(hCPE->hStereoDft->hBpf->psf_att, Q15); - hCPE->hStereoDft->stab_fac_smooth_res_fx = floatToFixed(hCPE->hStereoDft->stab_fac_smooth_res, Q31); + hCPE->hStereoDft->stab_fac_smooth_res_fx = (Word16)floatToFixed(hCPE->hStereoDft->stab_fac_smooth_res, Q15); stereo_dft_dec_res_fx(hCPE, res_buf_fx, Q8, output_fix); diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 400245996..1f3a3a0e0 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -4184,7 +4184,12 @@ void ivas_dirac_dec_render_sf( } } +#ifdef IVAS_FLOAT_FIXED + ivas_dirac_dec_output_synthesis_get_interpolator_fx( &hDirACRend->h_output_synthesis_psd_params, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); + fixedToFloat_arr( hDirACRend->h_output_synthesis_psd_params.interpolator_fx, hDirACRend->h_output_synthesis_psd_params.interpolator, Q15, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); +#else ivas_dirac_dec_output_synthesis_get_interpolator( &hDirACRend->h_output_synthesis_psd_params, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); +#endif if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 4dd43ef17..7d7b5baa5 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -162,6 +162,34 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( } +#ifdef IVAS_FLOAT_FIXED +/*-------------------------------------------------------------------* + * ivas_dirac_dec_output_synthesis_get_interpolator_fx() + * + * + *-------------------------------------------------------------------*/ + +void ivas_dirac_dec_output_synthesis_get_interpolator_fx( + DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ + const UWord16 interp_length /* i : interpolator length */ +) +{ + Word16 idx; + Word16 tmp, exp_diff = 0; + move16(); + + FOR( idx = 1; idx <= interp_length; ++idx ) + { + tmp = BASOP_Util_Divide3232_Scale( (Word32) idx, (Word32) interp_length, &exp_diff ); // (Q15 - exp_diff) + h_dirac_output_synthesis_params->interpolator_fx[idx - 1] = shl_sat( tmp, exp_diff ); // Q15 + move16(); + } + + return; +} +#endif + + /*-------------------------------------------------------------------* * ivas_dirac_dec_output_synthesis_get_interpolator() * diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index a3cc93a72..865f62712 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -78,7 +78,7 @@ static Word16 ceil_fx16( Word16 inp, Word16 Q ); static Word16 ceil_fx16( Word16 inp, Word16 Q ) { Word16 ret = shr( inp, Q ); - IF( inp & ( ( 1 << Q ) - 1 ) > 0 ) + IF( (inp & ( ( 1 << Q ) - 1 )) > 0 ) { ret = ret + 1; } @@ -1116,7 +1116,7 @@ ivas_error ivas_jbm_dec_tc( IF (hSCE != NULL) { hSCE->hCoreCoder[0]->log_energy_diff_lt = fixedToFloat(hSCE->hCoreCoder[0]->log_energy_diff_lt_fx, Q15); - hSCE->hCoreCoder[0]->stab_fac_smooth_lt = fixedToFloat(hSCE->hCoreCoder[0]->stab_fac_smooth_lt_fx, Q31); + hSCE->hCoreCoder[0]->stab_fac_smooth_lt = fixedToFloat(hSCE->hCoreCoder[0]->stab_fac_smooth_lt_fx, Q15); } fixedToFloat_arrL(&hCPE->prev_synth_fx[0][0], &hCPE->prev_synth[0][0], hCPE->q_prev_synth_fx, sizeof(hCPE->prev_synth) / sizeof(hCPE->prev_synth[0][0])); st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact = fixedToFloat( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact_fx, 15 ); @@ -2104,7 +2104,7 @@ ivas_error ivas_jbm_dec_tc( IF (hSCE != NULL) { hSCE->hCoreCoder[0]->log_energy_diff_lt = fixedToFloat(hSCE->hCoreCoder[0]->log_energy_diff_lt_fx, Q15); - hSCE->hCoreCoder[0]->stab_fac_smooth_lt = fixedToFloat(hSCE->hCoreCoder[0]->stab_fac_smooth_lt_fx, Q31); + hSCE->hCoreCoder[0]->stab_fac_smooth_lt = fixedToFloat(hSCE->hCoreCoder[0]->stab_fac_smooth_lt_fx, Q15); } fixedToFloat_arrL(&hCPE->prev_synth_fx[0][0], &hCPE->prev_synth[0][0], hCPE->q_prev_synth_fx, sizeof(hCPE->prev_synth) / sizeof(hCPE->prev_synth[0][0])); st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact = fixedToFloat( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact_fx, 15 ); @@ -3188,7 +3188,7 @@ ivas_error ivas_jbm_dec_tc( IF (hSCE != NULL) { hSCE->hCoreCoder[0]->log_energy_diff_lt = fixedToFloat(hSCE->hCoreCoder[0]->log_energy_diff_lt_fx, Q15); - hSCE->hCoreCoder[0]->stab_fac_smooth_lt = fixedToFloat(hSCE->hCoreCoder[0]->stab_fac_smooth_lt_fx, Q31); + hSCE->hCoreCoder[0]->stab_fac_smooth_lt = fixedToFloat(hSCE->hCoreCoder[0]->stab_fac_smooth_lt_fx, Q15); } fixedToFloat_arrL(&hCPE->prev_synth_fx[0][0], &hCPE->prev_synth[0][0], hCPE->q_prev_synth_fx, sizeof(hCPE->prev_synth) / sizeof(hCPE->prev_synth[0][0])); st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact = fixedToFloat( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact_fx, 15 ); @@ -3374,7 +3374,7 @@ ivas_error ivas_jbm_dec_tc( // cldfb Word32 *real_buf; Word32 *imag_buf; - Word16 num_freq_bands; + Word16 num_freq_bands = 0; if ( st_ivas->ivas_format == ISM_FORMAT ) { @@ -3660,7 +3660,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( if (st_ivas->hIsmRendererData != NULL) { FOR(int idx = 0; idx < len; idx++) { - st_ivas->hIsmRendererData->interpolator_fx[idx] = floatToFixed(st_ivas->hIsmRendererData->interpolator[idx], Q15); + st_ivas->hIsmRendererData->interpolator_fx[idx] = (Word16)floatToFixed(st_ivas->hIsmRendererData->interpolator[idx], Q15); } for (int i = 0; i < num_objects; i++) { for (int j = 0; j < MAX_OUTPUT_CHANNELS; j++) { @@ -3821,14 +3821,14 @@ void ivas_jbm_dec_feed_tc_to_renderer( if (st_ivas->hDiracDecBin != NULL && (st_ivas->hDiracDecBin->useTdDecorr)) { st_ivas->hTcBuffer->q_tc_fx = 14; - int16_t nSamplesLeftForTD, default_frame; - default_frame = (int16_t)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC); + Word16 nSamplesLeftForTD, default_frame; + default_frame = (Word16)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC); nSamplesLeftForTD = nSamplesForRendering; - int size = 0; + Word16 size = 0; while (nSamplesLeftForTD) { - int16_t nSamplesToDecorr = min(nSamplesLeftForTD, default_frame); + Word16 nSamplesToDecorr = min(nSamplesLeftForTD, default_frame); size += nSamplesToDecorr; nSamplesLeftForTD -= nSamplesToDecorr; } @@ -3907,7 +3907,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( int16_t nSamplesLeftForTD, default_frame; default_frame = (int16_t)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC); nSamplesLeftForTD = nSamplesForRendering; - int size = 0; + Word16 size = 0; while (nSamplesLeftForTD) { @@ -3957,7 +3957,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( if (st_ivas->hIsmRendererData != NULL) { FOR(int idx = 0; idx < len; idx++) { - st_ivas->hIsmRendererData->interpolator_fx[idx] = floatToFixed(st_ivas->hIsmRendererData->interpolator[idx], Q15); + st_ivas->hIsmRendererData->interpolator_fx[idx] = (Word16)floatToFixed(st_ivas->hIsmRendererData->interpolator[idx], Q15); } for (int i = 0; i < num_objects; i++) { for (int j = 0; j < MAX_OUTPUT_CHANNELS; j++) { @@ -4063,7 +4063,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( if (st_ivas->hIsmRendererData != NULL) { FOR(int idx = 0; idx < len; idx++) { - st_ivas->hIsmRendererData->interpolator_fx[idx] = floatToFixed(st_ivas->hIsmRendererData->interpolator[idx], Q15); + st_ivas->hIsmRendererData->interpolator_fx[idx] = (Word16)floatToFixed(st_ivas->hIsmRendererData->interpolator[idx], Q15); } for (int i = 0; i < num_objects; i++) { for (int j = 0; j < MAX_OUTPUT_CHANNELS; j++) { @@ -7793,9 +7793,9 @@ void ivas_jbm_dec_copy_tc_no_tsm_fx( IF( EQ_16( (Word16) st_ivas->ivas_format, (Word16) ISM_FORMAT ) ) { cldfb_real_buffer_fx = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx; - cldfb_real_e = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_e; + cldfb_real_e = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp; cldfb_imag_buffer_fx = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx; - cldfb_imag_e = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_e; + cldfb_imag_e = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp; num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands; ivas_ism_param_dec_tc_gain_ajust_fx( st_ivas, output_frame, output_frame / 2, tc_fx, &Q_tc ); diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index cc792a407..0d365e837 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -217,11 +217,8 @@ ivas_error ivas_mct_dec( sts[ch]->gamma = float_to_fix16( sts[ch]->gamma_float, Q15 ); sts[ch]->preemph_fac = float_to_fix16( sts[ch]->preemph_fac_float, Q15 ); sts[ch]->Mode2_lp_gainp = float_to_fix( sts[ch]->lp_gainp, Q16 ); - sts[ch]->hTcxCfg->na_scale = float_to_fix16( sts[ch]->hTcxCfg->na_scale_flt, Q15 ); - sts[ch]->hTcxCfg->sq_rounding = float_to_fix16( sts[ch]->hTcxCfg->sq_rounding_flt, Q15 ); sts[ch]->hTcxLtpDec->tcxltp_gain = float_to_fix16( sts[ch]->hTcxLtpDec->tcxltp_gain_float, Q15 ); sts[ch]->inv_gamma = float_to_fix16( 1 / sts[ch]->gamma_float, Q14 ); - sts[ch]->hTcxCfg->preemph_fac = float_to_fix16( sts[ch]->hTcxCfg->preemph_fac_flt, Q15 ); f2me_16( sts[ch]->last_gain_syn_deemph_float, &sts[ch]->last_gain_syn_deemph, &sts[ch]->last_gain_syn_deemph_e ); f2me_16( sts[ch]->last_concealed_gain_syn_deemph_float, &sts[ch]->last_concealed_gain_syn_deemph, &sts[ch]->last_concealed_gain_syn_deemph_e ); f2me_16( sts[ch]->hTcxDec->old_gaintcx_bfi_float, &sts[ch]->hTcxDec->old_gaintcx_bfi, &sts[ch]->hTcxDec->old_gaintcx_bfi_e ); @@ -872,13 +869,13 @@ ivas_error ivas_mct_dec( float pd = st->hTonalMDCTConc->pTCI_float->phaseDiff_float[i]; if (pd >= PI2) pd = fmodf(pd, PI2) - PI2; - st->hTonalMDCTConc->pTCI_fix->phaseDiff[i] = (Word16)floatToFixed(pd, Q12); + st->hTonalMDCTConc->pTCI_float->phaseDiff[i] = (Word16)floatToFixed(pd, Q12); } FOR( i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++) { float pd = st->hTonalMDCTConc->pTCI_float->phase_currentFramePredicted_float[i]; pd = fmodf(pd, PI2); - st->hTonalMDCTConc->pTCI_fix->phase_currentFramePredicted[i] = (Word16)(pd * (1u << Q13)); + st->hTonalMDCTConc->pTCI_float->phase_currentFramePredicted[i] = (Word16)(pd * (1u << Q13)); } //st->hTonalMDCTConc->nFramesLost = float_to_fix16( st->hTonalMDCTConc->nFramesLost, Q1 ); } @@ -893,11 +890,11 @@ ivas_error ivas_mct_dec( sts[ch]->preemph_fac = (Word16)floatToFixed( sts[ch]->preemph_fac_float, Q15 ); sts[ch]->Mode2_lp_gainp = floatToFixed( sts[ch]->lp_gainp, Q16 ); sts[ch]->stab_fac_fx = (Word16)floatToFixed( sts[ch]->stab_fac, Q15 ); - sts[ch]->hTcxCfg->na_scale = (Word16)floatToFixed( sts[ch]->hTcxCfg->na_scale_flt, Q15 ); - sts[ch]->hTcxCfg->sq_rounding = (Word16)floatToFixed( sts[ch]->hTcxCfg->sq_rounding_flt, Q15 ); + //sts[ch]->hTcxCfg->na_scale = (Word16)floatToFixed( sts[ch]->hTcxCfg->na_scale_flt, Q15 ); + //sts[ch]->hTcxCfg->sq_rounding = (Word16)floatToFixed( sts[ch]->hTcxCfg->sq_rounding_flt, Q15 ); sts[ch]->hTcxLtpDec->tcxltp_gain = (Word16)floatToFixed( sts[ch]->hTcxLtpDec->tcxltp_gain_float, Q15 ); sts[ch]->inv_gamma = (Word16)floatToFixed( 1 / sts[ch]->gamma_float, Q14 ); - sts[ch]->hTcxCfg->preemph_fac = (Word16)floatToFixed( sts[ch]->hTcxCfg->preemph_fac_flt, Q15 ); + //sts[ch]->hTcxCfg->preemph_fac = (Word16)floatToFixed( sts[ch]->hTcxCfg->preemph_fac_flt, Q15 ); f2me_16( sts[ch]->last_gain_syn_deemph_float, &sts[ch]->last_gain_syn_deemph, &sts[ch]->last_gain_syn_deemph_e ); f2me_16( sts[ch]->last_concealed_gain_syn_deemph_float, &sts[ch]->last_concealed_gain_syn_deemph, &sts[ch]->last_concealed_gain_syn_deemph_e ); f2me_16( sts[ch]->hTcxDec->old_gaintcx_bfi_float, &sts[ch]->hTcxDec->old_gaintcx_bfi, &sts[ch]->hTcxDec->old_gaintcx_bfi_e ); @@ -915,13 +912,13 @@ ivas_error ivas_mct_dec( sts[ch]->hTcxDec->cummulative_damping_tcx = float_to_fix16( sts[ch]->hTcxDec->cummulative_damping_tcx_float, Q15 ); } } - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - IF( sts[ch]->rate_switching_reset ) - { - floatToFixed_arr( sts[ch]->lsp_old, sts[ch]->lsp_old_fx, Q15, M ); - } - } + //FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + //{ + // IF( sts[ch]->rate_switching_reset ) + // { + // floatToFixed_arr( sts[ch]->lsp_old, sts[ch]->lsp_old_fx, Q15, M ); + // } + //} } IF(st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->targetEnergyPrev) f2me_buf(st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], &st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->sfbCnt); @@ -1175,11 +1172,11 @@ ivas_error ivas_mct_dec( } sts[ch]->hTcxDec->cummulative_damping_tcx_float = fix16_to_float( sts[ch]->hTcxDec->cummulative_damping_tcx, Q15 ); } - IF( sts[ch]->rate_switching_reset ) - { - Word16 old_Aq_12_8_e = norm_s( sts[ch]->old_Aq_12_8_fx[0] ); - fixedToFloat_arr( sts[ch]->old_Aq_12_8_fx, sts[ch]->old_Aq_12_8, ( 15 - old_Aq_12_8_e ), M + 1 ); - } + //IF( sts[ch]->rate_switching_reset ) + //{ + // Word16 old_Aq_12_8_e = norm_s( sts[ch]->old_Aq_12_8_fx[0] ); + // fixedToFloat_arr( sts[ch]->old_Aq_12_8_fx, sts[ch]->old_Aq_12_8, ( 15 - old_Aq_12_8_e ), M + 1 ); + //} IF(st->hTonalMDCTConc != NULL) { st->hTonalMDCTConc->scf_fadeout_flt = fixedToFloat(st->hTonalMDCTConc->scf_fadeout, 15); @@ -1300,11 +1297,11 @@ ivas_error ivas_mct_dec( { floatToFixed_arr(sts[n]->hHQ_core->old_out, sts[n]->hHQ_core->old_out_fx, 0, L_FRAME48k); floatToFixed_arr(sts[n]->hHQ_core->fer_samples, sts[n]->hHQ_core->fer_samples_fx, 0, NS2SA(sts[n]->output_Fs, 3000000)); - FOR(i = 0; i < SFM_N_WB; ++i) - { - sts[n]->hHQ_core->prev_env_fx[i] = floatToFixed(sts[n]->hHQ_core->prev_env[i], sts[n]->hHQ_core->prev_env_Q[i]); - } - floatToFixed_arrL(sts[n]->hHQ_core->prev_normq, sts[n]->hHQ_core->prev_normq_fx, 14, SFM_N_WB); + //FOR(i = 0; i < SFM_N_WB; ++i) + //{ + // sts[n]->hHQ_core->prev_env_fx[i] = floatToFixed(sts[n]->hHQ_core->prev_env[i], sts[n]->hHQ_core->prev_env_Q[i]); + //} + //floatToFixed_arrL(sts[n]->hHQ_core->prev_normq, sts[n]->hHQ_core->prev_normq_fx, 14, SFM_N_WB); } floatToFixed_arr(sts[n]->previoussynth, sts[n]->previoussynth_fx, 0, L_FRAME48k); floatToFixed_arr(sts[n]->delay_buf_out, sts[n]->delay_buf_out_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP); @@ -1343,10 +1340,6 @@ ivas_error ivas_mct_dec( { floatToFixed_arr(sts[n]->hWIDec->old_exc2, sts[n]->hWIDec->old_exc2_fx, sts[n]->Q_exc, L_EXC_MEM); } - if (sts[n]->hBWE_TD != NULL) - { - floatToFixed_arr(sts[n]->hBWE_TD->old_bwe_exc, sts[n]->hBWE_TD->old_bwe_exc_fx, sts[n]->Q_exc, PIT16k_MAX * 2); - } if (sts[n]->hMusicPF != NULL) { floatToFixed_arr(sts[n]->hMusicPF->dct_post_old_exc, sts[n]->hMusicPF->dct_post_old_exc_fx, sts[n]->Q_exc, DCT_L_POST - OFFSET2); @@ -1511,11 +1504,11 @@ ivas_error ivas_mct_dec( { fixedToFloat_arr(sts[n]->hHQ_core->old_out_fx, sts[n]->hHQ_core->old_out, 0, L_FRAME48k); fixedToFloat_arr(sts[n]->hHQ_core->fer_samples_fx, sts[n]->hHQ_core->fer_samples, 0, NS2SA(sts[n]->output_Fs, 3000000)); - FOR(i = 0; i < SFM_N_WB; ++i) - { - sts[n]->hHQ_core->prev_env[i] = fixedToFloat(sts[n]->hHQ_core->prev_env_fx[i], sts[n]->hHQ_core->prev_env_Q[i]); - } - fixedToFloat_arrL(sts[n]->hHQ_core->prev_normq_fx, sts[n]->hHQ_core->prev_normq, 14, SFM_N_WB); + //FOR(i = 0; i < SFM_N_WB; ++i) + //{ + // sts[n]->hHQ_core->prev_env[i] = fixedToFloat(sts[n]->hHQ_core->prev_env_fx[i], sts[n]->hHQ_core->prev_env_Q[i]); + //} + //fixedToFloat_arrL(sts[n]->hHQ_core->prev_normq_fx, sts[n]->hHQ_core->prev_normq, 14, SFM_N_WB); } fixedToFloat_arr(sts[n]->previoussynth_fx, sts[n]->previoussynth, 0, L_FRAME48k); @@ -1524,11 +1517,9 @@ ivas_error ivas_mct_dec( /*------------------reset-code-start---------------------*/ /*reset function flags*/ - Word8 reset_wb_tbe_extras = 0; Word8 reset_wb_tbe_synth = 0; Word8 reset_swb_tbe = 0; Word8 reset_swb_tbe_synth = 0; - Word8 reset_fb_tbe_synth = 0; if (sts[n]->hBWE_FD != NULL) { @@ -1581,55 +1572,28 @@ ivas_error ivas_mct_dec( reset_swb_tbe = 1; reset_swb_tbe_synth = 1; - fixedToFloat_arr(sts[n]->GainShape_Delay, sts[n]->hBWE_TD->GainShape_Delay, 0, NUM_SHB_SUBFR / 2); - IF(EQ_16(output_frame, L_FRAME16k)) { /* reset in case that SWB TBE layer is transmitted, but the output x`x`is 16kHz sampled */ fixedToFloat_arr(sts[n]->hBWE_TD->mem_resamp_HB_32k_fx, sts[n]->hBWE_TD->mem_resamp_HB_32k, 0, 2 * ALLPASSSECTIONS_STEEP + 1); } fixedToFloat_arr(sts[n]->hBWE_TD->int_3_over_2_tbemem_dec_fx, sts[n]->hBWE_TD->int_3_over_2_tbemem_dec, 0, INTERP_3_2_MEM_LEN); - sts[n]->hBWE_TD->prev_pow_exc16kWhtnd = (float)sts[n]->hBWE_TD->prev_pow_exc16kWhtnd_fx / 32767; - sts[n]->hBWE_TD->prev_mix_factor = (float)sts[n]->hBWE_TD->prev_mix_factor_fx / 32767; - } - ELSE IF((EQ_16(sts[n]->extl, SWB_TBE) || EQ_16(sts[n]->extl, FB_TBE)) && - (NE_32(sts[n]->last_total_brate, sts[n]->total_brate) || NE_16(sts[n]->last_bwidth, sts[n]->bwidth) || - NE_16(sts[n]->last_codec_mode, MODE1) || NE_16(sts[n]->rf_flag, sts[n]->rf_flag_last))) - { - fixedToFloat_arr(sts[n]->hBWE_TD->state_lpc_syn_fx, sts[n]->hBWE_TD->state_lpc_syn, 0, LPC_SHB_ORDER); // setting to zero - fixedToFloat_arr(sts[n]->hBWE_TD->state_syn_shbexc_fx, sts[n]->hBWE_TD->state_syn_shbexc, 0, L_SHB_LAHEAD); // setting to zero - fixedToFloat_arr(sts[n]->hBWE_TD->mem_stp_swb_fx, sts[n]->hBWE_TD->mem_stp_swb, 0, LPC_SHB_ORDER); // setting to zero - fixedToFloat_arr(sts[n]->hBWE_TD->mem_zero_swb_fx, sts[n]->hBWE_TD->mem_zero_swb, 0, LPC_SHB_ORDER); // setting to zero - sts[n]->hBWE_TD->gain_prec_swb = fixedToFloat(sts[n]->hBWE_TD->gain_prec_swb_fx, 14); /* Q14 = 1 */ } ELSE IF(sts[n]->hBWE_TD != NULL && (sts[n]->last_core == TCX_20_CORE || sts[n]->last_core == TCX_10_CORE)) { /*------------TBEreset_dec_ivas_fx-start------------------*/ - IF(NE_16(sts[n]->last_core, ACELP_CORE)) - { - fixedToFloat_arr(sts[n]->hBWE_TD->old_bwe_exc_fx, sts[n]->hBWE_TD->old_bwe_exc, 0, PIT16k_MAX * 2); // setting to zero - sts[n]->hBWE_TD->bwe_non_lin_prev_scale = fixedToFloat(sts[n]->hBWE_TD->bwe_non_lin_prev_scale_fx, 0); // setting to zero - } IF(EQ_16(sts[n]->bwidth, WB)) { - reset_wb_tbe_extras = 1; reset_wb_tbe_synth = 1; - fixedToFloat_arr(sts[n]->hBWE_TD->mem_genSHBexc_filt_down_shb_fx, sts[n]->hBWE_TD->mem_genSHBexc_filt_down_shb, 0, 7); // setting to zero - fixedToFloat_arr(sts[n]->hBWE_TD->state_lpc_syn_fx, sts[n]->hBWE_TD->state_lpc_syn, 0, 10); // setting to zero - fixedToFloat_arr(sts[n]->hBWE_TD->state_syn_shbexc_fx, sts[n]->hBWE_TD->state_syn_shbexc, 0, L_SHB_LAHEAD / 4); fixedToFloat_arr(sts[n]->hBWE_TD->syn_overlap_fx, sts[n]->hBWE_TD->syn_overlap, 0, L_SHB_LAHEAD); - fixedToFloat_arrL(sts[n]->hBWE_TD->mem_csfilt_fx, sts[n]->hBWE_TD->mem_csfilt, 0, 2); } ELSE IF(EQ_16(sts[n]->bwidth, SWB) || EQ_16(sts[n]->bwidth, FB)) { reset_swb_tbe = 1; reset_swb_tbe_synth = 1; - fixedToFloat_arr(sts[n]->GainShape_Delay, sts[n]->hBWE_TD->GainShape_Delay, 0, NUM_SHB_SUBFR / 2); // setting to zero fixedToFloat_arr(sts[n]->hBWE_TD->int_3_over_2_tbemem_dec_fx, sts[n]->hBWE_TD->int_3_over_2_tbemem_dec, 0, INTERP_3_2_MEM_LEN); // setting to zero fixedToFloat_arr(sts[n]->hBWE_TD->mem_resamp_HB_32k_fx, sts[n]->hBWE_TD->mem_resamp_HB_32k, 0, 2 * ALLPASSSECTIONS_STEEP + 1); // setting to zero - sts[n]->hBWE_TD->prev_pow_exc16kWhtnd = (float)sts[n]->hBWE_TD->prev_pow_exc16kWhtnd_fx / 32767; /*Q15 1.f*/ - sts[n]->hBWE_TD->prev_mix_factor = (float)sts[n]->hBWE_TD->prev_mix_factor_fx / 32767; /*Q15 1.f */ IF(EQ_16(sts[n]->bwidth, FB)) { @@ -1638,8 +1602,6 @@ ivas_error ivas_mct_dec( sts[n]->hBWE_FD->prev_fb_ener_adjust = fixedToFloat(sts[n]->prev_fb_ener_adjust_fx, 0); } fixedToFloat_arr(sts[n]->hBWE_TD->fb_state_lpc_syn_fx, sts[n]->hBWE_TD->fb_state_lpc_syn, 0, LPC_SHB_ORDER); - sts[n]->hBWE_TD->fb_tbe_demph = fixedToFloat(sts[n]->hBWE_TD->fb_tbe_demph_fx, 0); // setting to zero - reset_fb_tbe_synth = 1; } } /*------------TBEreset_dec_ivas_fx-end--------------------*/ @@ -1648,43 +1610,24 @@ ivas_error ivas_mct_dec( IF(EQ_16(sts[n]->extl, FB_TBE) && (NE_16(sts[n]->last_extl, FB_TBE) || NE_16(sts[n]->L_frame, sts[n]->last_L_frame))) { fixedToFloat_arr(sts[n]->hBWE_TD->fb_state_lpc_syn_fx, sts[n]->hBWE_TD->fb_state_lpc_syn, 0, LPC_SHB_ORDER); - sts[n]->hBWE_TD->fb_tbe_demph = fixedToFloat(sts[n]->hBWE_TD->fb_tbe_demph_fx, 0); // setting to zero - reset_fb_tbe_synth = 1; } IF(NE_16(sts[n]->last_extl, WB_TBE) && EQ_16(sts[n]->extl, WB_TBE)) { - reset_wb_tbe_extras = 1; reset_wb_tbe_synth = 1; - fixedToFloat_arr(sts[n]->hBWE_TD->state_syn_shbexc_fx, sts[n]->hBWE_TD->state_syn_shbexc, 0, L_SHB_LAHEAD / 4); // setting to zero fixedToFloat_arr(sts[n]->hBWE_TD->syn_overlap_fx, sts[n]->hBWE_TD->syn_overlap, 0, L_SHB_LAHEAD); // setting to zero - fixedToFloat_arrL(sts[n]->hBWE_TD->mem_csfilt_fx, sts[n]->hBWE_TD->mem_csfilt, 0, 2); // setting to zero } IF(reset_swb_tbe) { - fixedToFloat_arrL(sts[n]->hBWE_TD->mem_csfilt_fx, sts[n]->hBWE_TD->mem_csfilt, 0, 2); // setting to zero - fixedToFloat_arr(sts[n]->hBWE_TD->mem_genSHBexc_filt_down_shb_fx, sts[n]->hBWE_TD->mem_genSHBexc_filt_down_shb, 0, (2 * ALLPASSSECTIONS_STEEP + 1)); // setting to zero - fixedToFloat_arr(sts[n]->hBWE_TD->state_lpc_syn_fx, sts[n]->hBWE_TD->state_lpc_syn, 0, LPC_SHB_ORDER); // setting to zero fixedToFloat_arr(sts[n]->hBWE_TD->syn_overlap_fx, sts[n]->hBWE_TD->syn_overlap, 0, L_SHB_LAHEAD); // setting to zero - fixedToFloat_arr(sts[n]->hBWE_TD->state_syn_shbexc_fx, sts[n]->hBWE_TD->state_syn_shbexc, 0, L_SHB_LAHEAD); // setting to zero - fixedToFloat_arr(sts[n]->hBWE_TD->mem_stp_swb_fx, sts[n]->hBWE_TD->mem_stp_swb, 0, LPC_SHB_ORDER); // setting to zero - - sts[n]->hBWE_TD->tbe_demph = fixedToFloat(sts[n]->hBWE_TD->tbe_demph_fx, 0); // setting to zero - sts[n]->hBWE_TD->tbe_premph = fixedToFloat(sts[n]->hBWE_TD->tbe_premph_fx, 0); // setting to zero - sts[n]->hBWE_TD->gain_prec_swb = fixedToFloat(sts[n]->hBWE_TD->gain_prec_swb_fx, 14); // setting to zero } IF(reset_swb_tbe_synth) { fixedToFloat_arrL(sts[n]->hBWE_TD->genSHBsynth_Hilbert_Mem_fx, sts[n]->hBWE_TD->genSHBsynth_Hilbert_Mem, 0, HILBERT_MEM_SIZE); // setting to zero // setting to zero fixedToFloat_arr(sts[n]->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, sts[n]->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local, 0, 2 * ALLPASSSECTIONS_STEEP); // setting to zero } - IF(reset_wb_tbe_extras) - { - fixedToFloat_arr(sts[n]->hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, sts[n]->hBWE_TD->mem_genSHBexc_filt_down_wb2, 0, 2 * ALLPASSSECTIONS_STEEP + 1); // setting to zero - fixedToFloat_arr(sts[n]->hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, sts[n]->hBWE_TD->mem_genSHBexc_filt_down_wb3, 0, 2 * ALLPASSSECTIONS_STEEP + 1); // setting to zero - } IF(reset_wb_tbe_synth) { fixedToFloat_arr(sts[n]->hBWE_TD->state_lsyn_filt_shb_fx, sts[n]->hBWE_TD->state_lsyn_filt_shb, 0, 2 * ALLPASSSECTIONS_STEEP); // setting to zero @@ -1692,19 +1635,6 @@ ivas_error ivas_mct_dec( // fixedToFloat(sts[n]->hBWE_TD->state_32and48k_WB_upsample_fx, sts[n]->hBWE_TD->state_32and48k_WB_upsample,0, 2 * ALLPASSSECTIONS_STEEP); buffer not there in float code* fixedToFloat_arr(sts[n]->hBWE_TD->mem_resamp_HB_fx, sts[n]->hBWE_TD->mem_resamp_HB, 0, INTERP_3_1_MEM_LEN); // setting to zero } - IF(reset_fb_tbe_synth) - { - fixedToFloat_arrL(sts[n]->hBWE_TD->fbbwe_hpf_mem_fx[0], sts[n]->hBWE_TD->fbbwe_hpf_mem[0], 0, 4); // setting to zero - fixedToFloat_arrL(sts[n]->hBWE_TD->fbbwe_hpf_mem_fx[1], sts[n]->hBWE_TD->fbbwe_hpf_mem[1], 0, 4); // setting to zero - fixedToFloat_arrL(sts[n]->hBWE_TD->fbbwe_hpf_mem_fx[2], sts[n]->hBWE_TD->fbbwe_hpf_mem[2], 0, 4); // setting to zero - fixedToFloat_arrL(sts[n]->hBWE_TD->fbbwe_hpf_mem_fx[3], sts[n]->hBWE_TD->fbbwe_hpf_mem[3], 0, 4); // setting to zero - sts[n]->hBWE_TD->prev_fbbwe_ratio = fixedToFloat(sts[n]->hBWE_TD->prev_fbbwe_ratio_fx, 0); // scaling unknown setting to 1 - } - } - /* Interp_3_2 CNG buffers reset */ - IF(sts[n]->hTdCngDec != NULL && EQ_32(sts[n]->output_Fs, 48000) && ((GT_32(sts[n]->last_core_brate, SID_2k40)) && (EQ_32(sts[n]->core_brate, FRAME_NO_DATA) || EQ_32(sts[n]->core_brate, SID_2k40)))) - { - fixedToFloat_arr(sts[n]->interpol_3_2_cng_dec_fx, sts[n]->hTdCngDec->interpol_3_2_cng_dec, 0, INTERP_3_2_MEM_LEN); } /*------------------reset-code-end-----------------------*/ @@ -1972,6 +1902,185 @@ ivas_error create_mct_dec( * Reconfigure IVAS decoder MCT handle *-------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +ivas_error mct_dec_reconfigure_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const UWord16 b_nchan_change /* i : flag indicating different channel count */ +) +{ + MCT_DEC_HANDLE hMCT; + Decoder_State *st; + Word16 n, cpe_id, max_blocks; + Word32 cp_bitrate, L_tmp; + Word16 tmp_exp, tmp; + + hMCT = st_ivas->hMCT; + + /*-----------------------------------------------------------------* + * Allocate and initialize MCT BlockData handles + *-----------------------------------------------------------------*/ + IF ( b_nchan_change ) + { + /* Determine active channels */ + test(); test(); test(); test(); + IF ( ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) + { + hMCT->nchan_out_woLFE = st_ivas->nchan_transport; + move16(); + IF ( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) + { + hMCT->nchan_out_woLFE = add( hMCT->nchan_out_woLFE, st_ivas->nchan_ism ); + } + } + ELSE IF ( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) ) + { + hMCT->nchan_out_woLFE = sub( st_ivas->nchan_transport, st_ivas->hTransSetup.num_lfe ); + } + ELSE IF ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) + { + hMCT->nchan_out_woLFE = sub( st_ivas->nchan_transport, st_ivas->hTransSetup.num_lfe ); + } + ELSE + { + assert( !"IVAS format currently not supported for MCT" ); + } + } + + /* indicate LFE for appropriate core-coder channel */ + FOR ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + { + FOR ( n = 0; n < CPE_CHANNELS; n++ ) + { + st_ivas->hCPE[cpe_id]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_REGULAR; + } + } + + /* in case we have an uneven number of transport channels, indicate last channel ID as inactive */ + IF ( hMCT->nchan_out_woLFE % 2 ) + { + st_ivas->hCPE[st_ivas->nCPE - 1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; + } + + tmp = BASOP_Util_Divide3216_Scale(st_ivas->hDecoderConfig->ivas_total_brate, hMCT->nchan_out_woLFE, &tmp_exp ); + cp_bitrate = L_shl( tmp, tmp_exp + 2 ); + + IF ( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) + { + tmp = BASOP_Util_Divide3216_Scale(st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, &tmp_exp); + cp_bitrate = L_shl(tmp, tmp_exp + 2); + } + + /* set correct nominal bitrates and igf config already here, otherwise we + * run into a number of problems */ + FOR ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + { + st_ivas->hCPE[cpe_id]->element_brate = cp_bitrate; + move32(); + FOR ( n = 0; n < CPE_CHANNELS; n++ ) + { + st = st_ivas->hCPE[cpe_id]->hCoreCoder[n]; + + st->total_brate = st_ivas->hCPE[cpe_id]->element_brate; + move32(); + + IF ( NE_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) + { + tmp = BASOP_Util_Divide3232_Scale( st_ivas->hCPE[cpe_id]->element_brate, FRAMES_PER_SEC, &tmp_exp ); + st->bits_frame_nominal = shr( tmp, 15 - tmp_exp ); + st->igf = getIgfPresent_fx(st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->rf_flag); // no floating point so directly pluggable + + IF(st->igf) + { + IGFDecSetMode_ivas_fx(st->hIGFDec, st_ivas->hCPE[cpe_id]->element_brate, st->bwidth, st->element_mode, -1, -1, st->rf_flag); + } + } + } + } + + /*Initialize MCT block data */ + tmp = BASOP_Util_Divide1616_Scale(hMCT->nchan_out_woLFE, CPE_CHANNELS, &tmp_exp); + max_blocks = shr( tmp, 15 - tmp_exp ); + + FOR ( n = 0; n < max_blocks; n++ ) + { + IF ( b_nchan_change ) + { + IF ( hMCT->hBlockData[n] == NULL ) + { + IF ( ( hMCT->hBlockData[n] = (MCT_DEC_BLOCK_DATA_HANDLE) malloc( sizeof( MCT_BLOCK_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MCT block data structure\n" ) ); + } + + /*Initialize all parameters to zero*/ + hMCT->hBlockData[n]->ch1 = 0; + move16(); + hMCT->hBlockData[n]->ch2 = 0; + move16(); + + /* MDCT stereo initialization */ + IF ( ( hMCT->hBlockData[n]->hStereoMdct = (STEREO_MDCT_DEC_DATA_HANDLE) malloc( sizeof( STEREO_MDCT_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MDCT Stereo \n" ) ); + } + } + } + +#ifdef IVAS_FLOAT_FIXED + initMdctStereoDecData( hMCT->hBlockData[n]->hStereoMdct, st_ivas->hCPE[0]->hCoreCoder[0]->igf, st_ivas->hCPE[0]->hCoreCoder[0]->hIGFDec->igfData.igfInfo.grid, cp_bitrate, st_ivas->hCPE[0]->hCoreCoder[0]->bwidth ); +#endif + + hMCT->hBlockData[n]->hStereoMdct->use_itd = 0; + move16(); + } + + FOR ( ; n < MCT_MAX_BLOCKS; n++ ) + { + /* deallocate no longer needed blocks */ + IF ( hMCT->hBlockData[n] != NULL ) + { + IF ( hMCT->hBlockData[n]->hStereoMdct != NULL ) + { + free( hMCT->hBlockData[n]->hStereoMdct ); + hMCT->hBlockData[n]->hStereoMdct = NULL; + } + + free( hMCT->hBlockData[n] ); + hMCT->hBlockData[n] = NULL; + } + } + + /*-----------------------------------------------------------------* + * Initializations + *-----------------------------------------------------------------*/ + + IF ( b_nchan_change ) + { + hMCT->currBlockDataCnt = 0; + move16(); + + /*Initialize bits required to signal channel-pair index*/ + + Word32 log_tmp; + L_tmp = L_sub( L_shr( L_mult0( hMCT->nchan_out_woLFE, L_sub(hMCT->nchan_out_woLFE, 1) ), 1 ), 1 ); + tmp_exp = norm_l(L_tmp); + L_tmp = L_shl(L_tmp, tmp_exp); + log_tmp = BASOP_Util_Log2(L_tmp); // ( 31 - tmp_exp ) + log_tmp = L_add(log_tmp, L_shl((Q31 - tmp_exp), Q25)); // Q25 + // scale down from Q25 to Q0 + + tmp = extract_l(L_shr(log_tmp, Q25)); + tmp = add(tmp, 1); + hMCT->bitsChannelPairIndex = s_max(1, tmp); + + set_s( hMCT->chBitRatios, 0, MCT_MAX_CHANNELS ); + set_s( hMCT->lowE_ch, 0, MCT_MAX_CHANNELS ); + } + + return IVAS_ERR_OK; +} +#endif + ivas_error mct_dec_reconfigure( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const uint16_t b_nchan_change /* i : flag indicating different channel count */ diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index f83aa7108..5805a819b 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -1218,13 +1218,13 @@ void ivas_mdct_core_invQ_fx( float pd = sts[ch]->hTonalMDCTConc->pTCI_float->phaseDiff_float[i]; IF( pd >= PI2 ) pd = fmodf( pd, PI2 ) - PI2; - sts[ch]->hTonalMDCTConc->pTCI_fix->phaseDiff[i] = float_to_fix16( pd, Q12 ); + sts[ch]->hTonalMDCTConc->pTCI_float->phaseDiff[i] = float_to_fix16( pd, Q12 ); } FOR( Word16 i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++ ) { float pd = sts[ch]->hTonalMDCTConc->pTCI_float->phase_currentFramePredicted_float[i]; pd = fmodf( pd, PI2 ); - sts[ch]->hTonalMDCTConc->pTCI_fix->phase_currentFramePredicted[i] = (Word16) ( pd * ( 1u << Q13 ) ); + sts[ch]->hTonalMDCTConc->pTCI_float->phase_currentFramePredicted[i] = (Word16) ( pd * ( 1u << Q13 ) ); } FOR( Word16 i = 0; i < FDNS_NPTS; i++ ) { @@ -1234,7 +1234,7 @@ void ivas_mdct_core_invQ_fx( } IF( sts[ch]->enablePlcWaveadjust ) { - f2me_buf( sts[ch]->hPlcInfo->data_reci2, sts[ch]->hPlcInfo->data_reci2_fx, &sts[ch]->hPlcInfo->data_reci2_scale, sts[ch]->hPlcInfo->L_frameTCX ); + //f2me_buf( sts[ch]->hPlcInfo->data_reci2, sts[ch]->hPlcInfo->data_reci2_fx, &sts[ch]->hPlcInfo->data_reci2_scale, sts[ch]->hPlcInfo->L_frameTCX ); } } } @@ -1740,11 +1740,8 @@ void ivas_mdct_core_invQ( st->preemph_fac = float_to_fix16(st->preemph_fac_float, Q15); st->hTcxDec->cummulative_damping_tcx = float_to_fix16(st->hTcxDec->cummulative_damping_tcx_float, Q15); st->Mode2_lp_gainp = float_to_fix(st->lp_gainp, Q16); - st->hTcxCfg->na_scale = float_to_fix16(st->hTcxCfg->na_scale_flt, Q15); - st->hTcxCfg->sq_rounding = float_to_fix16(st->hTcxCfg->sq_rounding_flt, Q15); st->hTcxLtpDec->tcxltp_gain = float_to_fix16(st->hTcxLtpDec->tcxltp_gain_float, Q15); st->inv_gamma = FL2WORD16_SCALE(1 / st->gamma_float, 1); - st->hTcxCfg->preemph_fac = FL2WORD16(st->hTcxCfg->preemph_fac_flt); f2me_16(st->last_gain_syn_deemph_float, &st->last_gain_syn_deemph, &st->last_gain_syn_deemph_e); f2me_16(st->last_concealed_gain_syn_deemph_float, &st->last_concealed_gain_syn_deemph, &st->last_concealed_gain_syn_deemph_e); f2me_16(st->hTcxDec->old_gaintcx_bfi_float, &st->hTcxDec->old_gaintcx_bfi, &st->hTcxDec->old_gaintcx_bfi_e); @@ -1841,13 +1838,13 @@ void ivas_mdct_core_invQ( float pd = st->hTonalMDCTConc->pTCI_float->phaseDiff_float[i]; if (pd >= PI2) pd = fmodf(pd, PI2) - PI2; - st->hTonalMDCTConc->pTCI_fix->phaseDiff[i] = float_to_fix16(pd, Q12); + st->hTonalMDCTConc->pTCI_float->phaseDiff[i] = float_to_fix16(pd, Q12); } FOR(Word16 i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++) { float pd = st->hTonalMDCTConc->pTCI_float->phase_currentFramePredicted_float[i]; pd = fmodf(pd, PI2); - st->hTonalMDCTConc->pTCI_fix->phase_currentFramePredicted[i] = (Word16)(pd * (1u << Q13)); + st->hTonalMDCTConc->pTCI_float->phase_currentFramePredicted[i] = (Word16)(pd * (1u << Q13)); } FOR(Word16 i = 0; i < FDNS_NPTS; i++) { @@ -1860,7 +1857,7 @@ void ivas_mdct_core_invQ( st->hTonalMDCTConc->lastPitchLag = float_to_fix(st->hTonalMDCTConc->lastPitchLag_float, Q16); IF(st->enablePlcWaveadjust) { - f2me_buf(st->hPlcInfo->data_reci2, st->hPlcInfo->data_reci2_fx, &st->hPlcInfo->data_reci2_scale, st->hPlcInfo->L_frameTCX); + //f2me_buf(st->hPlcInfo->data_reci2, st->hPlcInfo->data_reci2_fx, &st->hPlcInfo->data_reci2_scale, st->hPlcInfo->L_frameTCX); } // u8bit to 16bit FOR(int l = 0; l < IGF_START_MX; l++) @@ -2001,13 +1998,13 @@ void ivas_mdct_core_reconstruct( FOR(Word16 ind = 0; ind < 640; ind++) { st->hHQ_core->old_out_LB_fx[ind] = (Word16)(st->hHQ_core->old_outLB[ind] / (1<<(-q_win))); } - FOR(Word16 ind = 0; ind < 17; ind++) { - st->old_Aq_12_8_fx_32[ind] = (Word32)(st->old_Aq_12_8[ind] * (1<<28)); - } - FOR( Word16 ind = 0; ind < M + 1; ind++ ) - { - st->old_Aq_12_8_fx[ind] = (Word16) ( st->old_Aq_12_8[ind] * 4096.f ); - } + //FOR(Word16 ind = 0; ind < 17; ind++) { + // st->old_Aq_12_8_fx_32[ind] = (Word32)(st->old_Aq_12_8[ind] * (1<<28)); + //} + //FOR( Word16 ind = 0; ind < M + 1; ind++ ) + //{ + // st->old_Aq_12_8_fx[ind] = (Word16) ( st->old_Aq_12_8[ind] * 4096.f ); + //} FOR(Word16 ind = 0; ind < 320; ind++) { st->hTcxDec->old_syn_Overl[ind] = (Word16)(st->hTcxDec->old_syn_Overl_float[ind] / (1<<(-q_win))); } @@ -2046,15 +2043,16 @@ void ivas_mdct_core_reconstruct( synthFB_fx[k * L_frameTCX[ch] + ind] = (Word16)(synthFB[k * L_frameTCX[ch] + ind] / (1<<(-q_win))); } + Copy_Scale_sig_16_32( st->old_Aq_12_8_fx, st->old_Aq_12_8_fx_32, M + 1, ( 28 - norm_s( st->old_Aq_12_8_fx[0] - 1 ) ) ); decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], &x_fx[0], q_x, xn_buf_fx, q_win, ( ( hCPE->nchan_out == 1 && st->hTcxDec->kernel_type[k] == MDST_IV ) || st->hTcxCfg->tcx_last_overlap_mode == TRANSITION_OVERLAP ) ? MDCT_IV : st->hTcxDec->kernel_type[k], fUseTns[ch][k], &synth_fx[k * L_frame[ch]], &synthFB_fx[k * L_frameTCX[ch]], bfi, k, 0 ); IF(st->igf) me2f_buf(x_fx, x_e, x[ch][k], s_max(st->hIGFDec->infoIGFStopLine, s_max(L_frameTCX[ch], L_spec[ch]) ) ); - FOR(Word16 ind = 0; ind < 17; ind++) { - st->old_Aq_12_8[ind] = (float)(st->old_Aq_12_8_fx[ind]) / (float)(1<<12); - } + //FOR(Word16 ind = 0; ind < 17; ind++) { + // st->old_Aq_12_8[ind] = (float)(st->old_Aq_12_8_fx[ind]) / (float)(1<<12); + //} FOR(Word16 ind = 0; ind < 640; ind++) { st->hHQ_core->old_outLB[ind] = (float)st->hHQ_core->old_out_LB_fx[ind] * (1<<(-q_win)); } @@ -2656,13 +2654,13 @@ void ivas_mdct_core_tns_ns( float pd = st->hTonalMDCTConc->pTCI_float->phaseDiff_float[i]; if (pd >= PI2) pd = fmodf(pd, PI2) - PI2; - st->hTonalMDCTConc->pTCI_fix->phaseDiff[i] = float_to_fix16(pd, Q12); + st->hTonalMDCTConc->pTCI_float->phaseDiff[i] = float_to_fix16(pd, Q12); } FOR(Word16 i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++) { float pd = st->hTonalMDCTConc->pTCI_float->phase_currentFramePredicted_float[i]; pd = fmodf(pd, PI2); - st->hTonalMDCTConc->pTCI_fix->phase_currentFramePredicted[i] = (Word16)(pd * (1u << Q13)); + st->hTonalMDCTConc->pTCI_float->phase_currentFramePredicted[i] = (Word16)(pd * (1u << Q13)); } FOR(Word16 i = 0; i < FDNS_NPTS; i++) { diff --git a/lib_dec/ivas_pca_dec_fx.c b/lib_dec/ivas_pca_dec_fx.c index 5c35be2c3..e19b1bda9 100644 --- a/lib_dec/ivas_pca_dec_fx.c +++ b/lib_dec/ivas_pca_dec_fx.c @@ -198,7 +198,7 @@ void ivas_pca_read_bits_fx( /*first bit in the PCA payload (first bit after 3 header bits) signals bypass/active*/ hPCA->pca_bypass = get_next_indice_fx( st0, 1 ); move16(); - IF( hPCA->pca_bypass == PCA_MODE_INACTIVE ) + IF( EQ_16( hPCA->pca_bypass, PCA_MODE_INACTIVE ) ) { return; } diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index f6b79f95a..119c173c3 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -405,34 +405,15 @@ ivas_error create_sce_dec( #if 1 // Float To Fix conversions floatToFixed_arr(st->hTdCngDec->shb_lpcCNG, st->hTdCngDec->shb_lpcCNG_fx, 15, LPC_SHB_ORDER + 1); st->hTdCngDec->shb_cng_gain_fx_32 = floatToFixed(st->hTdCngDec->shb_cng_gain, 11); - floatToFixed_arr(st->lsp_old, st->lsp_old_fx, 15, M); + //floatToFixed_arr(st->lsp_old, st->lsp_old_fx, 15, M); #endif // Float to fix conversions td_cng_dec_init_ivas_fx( st ); #if 1 // Fix to float conversions - //fixedToFloat_arr(st->lspCNG_fx, st->lspCNG, 15, M); st->hTdCngDec->shb_cng_ener = fix_to_float(st->hTdCngDec->shb_cng_ener_fx_32, 11); fixedToFloat_arr(st->hTdCngDec->shb_lpcCNG_fx, st->hTdCngDec->shb_lpcCNG, 15, LPC_SHB_ORDER + 1); st->hTdCngDec->shb_cng_gain = fix_to_float(st->hTdCngDec->shb_cng_gain_fx_32, 11); - st->hTdCngDec->wb_cng_ener = fix_to_float(st->hTdCngDec->wb_cng_ener_fx_32, 11); - st->hTdCngDec->last_wb_cng_ener = fix_to_float(st->hTdCngDec->last_wb_cng_ener_fx_32, 11); - st->hTdCngDec->last_shb_cng_ener = fix_to_float(st->hTdCngDec->last_shb_cng_ener_fx_32, 11); - fixedToFloat_arr(st->hTdCngDec->ho_lsp_hist_fx, st->hTdCngDec->ho_lsp_hist, 15, HO_HIST_SIZE * M); - fixedToFloat_arrL(st->hTdCngDec->ho_ener_hist_fx, st->hTdCngDec->ho_ener_hist, 15, HO_HIST_SIZE); - fixedToFloat_arrL(st->hTdCngDec->ho_env_hist_fx, st->hTdCngDec->ho_env_hist, 15, HO_HIST_SIZE * NUM_ENV_CNG); - fixedToFloat_arr(st->hTdCngDec->ho_lsp_circ_fx, st->hTdCngDec->ho_lsp_circ, 15, HO_HIST_SIZE * M); - fixedToFloat_arrL(st->hTdCngDec->ho_ener_circ_fx, st->hTdCngDec->ho_ener_circ, 15, HO_HIST_SIZE); - fixedToFloat_arrL(st->hTdCngDec->ho_env_circ_fx, st->hTdCngDec->ho_env_circ, 15, HO_HIST_SIZE * NUM_ENV_CNG); - fixedToFloat_arrL(st->hTdCngDec->lp_env_fx, st->hTdCngDec->lp_env, 15, NUM_ENV_CNG); - fixedToFloat_arr(st->hTdCngDec->exc_mem_fx, st->hTdCngDec->exc_mem, 15, 24); - fixedToFloat_arr(st->hTdCngDec->exc_mem1_fx, st->hTdCngDec->exc_mem1, 15, 30); - fixedToFloat_arrL(st->hTdCngDec->old_env_fx, st->hTdCngDec->old_env, 15, NUM_ENV_CNG); - fixedToFloat_arr(st->hTdCngDec->lsp_shb_prev_fx, st->hTdCngDec->lsp_shb_prev, 15, LPC_SHB_ORDER); - fixedToFloat_arr(st->hTdCngDec->lsp_shb_prev_prev_fx, st->hTdCngDec->lsp_shb_prev_prev, 15, LPC_SHB_ORDER); - fixedToFloat_arr(st->hTdCngDec->interpol_3_2_cng_dec_fx, st->hTdCngDec->interpol_3_2_cng_dec, 15, INTERP_3_2_MEM_LEN); - - #endif // Fix to float conversions #else td_cng_dec_init_flt( st ); diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 2f26de0b4..05d490f16 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -59,6 +59,9 @@ * Local function prototypes *--------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +static ivas_error ivas_spar_dec_MD_fx( Decoder_Struct *st_ivas, Decoder_State *st0 ); +#endif static ivas_error ivas_spar_dec_MD( Decoder_Struct *st_ivas, Decoder_State *st0 ); @@ -507,7 +510,11 @@ ivas_error ivas_spar_dec_fx( * Decode SPAR metadata *---------------------------------------------------------------------*/ - IF( ( error = ivas_spar_dec_MD( st_ivas, st0 ) ) != IVAS_ERR_OK ) + //IF( ( error = ivas_spar_dec_MD( st_ivas, st0 ) ) != IVAS_ERR_OK ) + //{ + // return error; + //} + IF( ( error = ivas_spar_dec_MD_fx( st_ivas, st0 ) ) != IVAS_ERR_OK ) { return error; } @@ -668,6 +675,42 @@ ivas_error ivas_spar_dec( * Get SPAR table index *---------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +static Word16 ivas_get_spar_table_idx_from_coded_idx( + const Word32 ivas_total_brate, /* i : IVAS total bitrate */ + const Word16 sba_order, /* i : Ambisonic (SBA) order */ + Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/ + Word16 *bitlen /* o : number of bits */ +) +{ + Word16 table_idx, ind1[IVAS_SPAR_BR_TABLE_LEN]; + Word16 i, j, ind2; + + j = 0; + move16(); + FOR( i = 0; i < IVAS_SPAR_BR_TABLE_LEN; i++ ) + { + ind1[j] = 0; + move16(); + test(); + IF( EQ_32( ivas_spar_br_table_consts[i].ivas_total_brate, ivas_total_brate ) && EQ_16( ivas_spar_br_table_consts[i].sba_order, sba_order ) ) + { + ind1[j++] = i; + move16(); + } + } + + assert( j > 0 ); + *bitlen = ivas_get_bits_to_encode( j - 1 ); + + ind2 = get_next_indice_fx( st0, *bitlen ); + + table_idx = ind1[ind2]; + move16(); + + return table_idx; +} +#else static int16_t ivas_get_spar_table_idx_from_coded_idx( const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t sba_order, /* i : Ambisonic (SBA) order */ @@ -697,6 +740,7 @@ static int16_t ivas_get_spar_table_idx_from_coded_idx( return table_idx; } +#endif /*---------------------------------------------------------------------* @@ -705,6 +749,23 @@ static int16_t ivas_get_spar_table_idx_from_coded_idx( * Get SPAR table index *---------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +static Word16 ivas_parse_spar_header( + const Word32 ivas_total_brate, /* i : IVAS total bitrate */ + const Word16 sba_order, /* i : Ambisonic (SBA) order */ + Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/ + Word16 *table_idx ) +{ + Word16 bitlen, bwidth; + + *table_idx = ivas_get_spar_table_idx_from_coded_idx( ivas_total_brate, sba_order, st0, &bitlen ); + + bwidth = ivas_spar_br_table_consts[( *table_idx )].bwidth; + move16(); + + return bwidth; +} +#else static int16_t ivas_parse_spar_header( const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t sba_order, /* i : Ambisonic (SBA) order */ @@ -719,6 +780,7 @@ static int16_t ivas_parse_spar_header( return bwidth; } +#endif #ifdef IVAS_FLOAT_FIXED static Word16 get_random_number_fx( @@ -1289,6 +1351,214 @@ int16_t ivas_is_res_channel( * IVAS SPAR MD decoder *-------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +static ivas_error ivas_spar_dec_MD_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Decoder_State *st0 /* i/o: decoder state structure - for bitstream handling*/ +) +{ + Word16 num_channels, table_idx, num_bands_out, bfi, sba_order; + Word32 ivas_total_brate; + Word16 num_md_sub_frames; + ivas_error error; + DECODER_CONFIG_HANDLE hDecoderConfig = st_ivas->hDecoderConfig; + SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; + + push_wmops( "ivas_spar_dec_MD" ); + + /*---------------------------------------------------------------------* + * Initialization + *---------------------------------------------------------------------*/ + +#ifndef IVAS_FLOAT_FIXED_TO_BE_REMOVED + Word16 i, j, k; +#endif + + sba_order = s_min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); + bfi = st_ivas->bfi; + move16(); + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + move32(); + num_channels = ivas_sba_get_nchan_metadata( sba_order, ivas_total_brate ); + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); + + num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; + move16(); + + test(); + IF( GT_32( ivas_total_brate, FRAME_NO_DATA ) && !bfi ) + { + IF( GT_32( ivas_total_brate, IVAS_SID_5k2 ) ) + { + ivas_parse_spar_header( hDecoderConfig->ivas_total_brate, sba_order, st0, &table_idx ); + + IF( hSpar->hMdDec->spar_hoa_md_flag ) + { + hSpar->hMdDec->spar_md.num_bands = IVAS_MAX_NUM_BANDS; + move16(); + } + ELSE + { + hSpar->hMdDec->spar_md.num_bands = s_min( SPAR_DIRAC_SPLIT_START_BAND, IVAS_MAX_NUM_BANDS ); + } + + IF( NE_16( hSpar->hMdDec->table_idx, table_idx ) ) + { + hSpar->hMdDec->table_idx = table_idx; + move16(); + IF( hSpar->hTdDecorr ) + { + hSpar->hTdDecorr->ducking_flag = ivas_spar_br_table_consts[table_idx].td_ducking; + move16(); + } + +// From here TBD + IF( ( error = ivas_spar_md_dec_init( hSpar->hMdDec, hDecoderConfig, num_channels, sba_order ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + + /*---------------------------------------------------------------------* + * Decode MD + *---------------------------------------------------------------------*/ + + ivas_spar_md_dec_process( st_ivas, st0, num_bands_out, sba_order ); + +// Till here TBD +#ifndef IVAS_FLOAT_FIXED_TO_BE_REMOVED + // float to fix + Word16 num_channels_tmp = hSpar->hMdDec->spar_md_cfg.num_umx_chs; + FOR( i = 0; i < num_channels_tmp; i++ ) + { + FOR( j = 0; j < num_channels_tmp; j++ ) + { + FOR( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) + { + hSpar->hMdDec->spar_coeffs_prev.C_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs_prev.C_re[i][j][k], Q22 ); + hSpar->hMdDec->spar_coeffs_prev.P_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs_prev.P_re[i][j][k], Q22 ); + hSpar->hMdDec->spar_coeffs_tar.C_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs_tar.C_re[i][j][k], Q22 ); + hSpar->hMdDec->spar_coeffs_tar.P_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs_tar.P_re[i][j][k], Q22 ); + hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs.C_re[i][j][k], Q22 ); + hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs.P_re[i][j][k], Q22 ); + } + } + } +#endif + + /*---------------------------------------------------------------------* + * read PCA bits + *---------------------------------------------------------------------*/ + + IF( hSpar->hPCA != NULL ) + { + ivas_pca_read_bits_fx( st0, hSpar->hPCA ); + } + + /*---------------------------------------------------------------------* + * Read AGC bits + *---------------------------------------------------------------------*/ + + test(); + test(); + IF( GT_32( ivas_total_brate, IVAS_SID_5k2 ) && !bfi && hSpar->hMdDec->dtx_vad ) + { + IF( EQ_16( hSpar->hMdDec->spar_md_cfg.nchan_transport, 1 ) ) + { + hSpar->AGC_flag = get_next_indice_fx( st0, 1 ); + } + + ivas_agc_read_bits_fx( hSpar->hAgcDec, st0, hSpar->hMdDec->spar_md_cfg.nchan_transport, hSpar->AGC_flag ); + } + + /*---------------------------------------------------------------------* + * MD smoothing + *---------------------------------------------------------------------*/ + + test(); + test(); + test(); + IF( EQ_16( st0->m_old_frame_type, ZERO_FRAME ) && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) && EQ_16( st0->prev_bfi, 0 ) && EQ_16( hSpar->hMdDec->spar_md_cfg.nchan_transport, 1 ) ) + { + ivas_spar_setup_md_smoothing_fx( hSpar->hMdDec, num_bands_out, num_md_sub_frames ); + } + ELSE + { + ivas_spar_update_md_hist_fx( hSpar->hMdDec ); + } + +#ifndef IVAS_FLOAT_FIXED_TO_BE_REMOVED + // fix to float + FOR( i = 0; i < num_channels_tmp; i++ ) + { + FOR( j = 0; j < num_channels_tmp; j++ ) + { + FOR( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) + { + hSpar->hMdDec->spar_coeffs_prev.C_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs_prev.C_re_fx[i][j][k], Q22 ); + hSpar->hMdDec->spar_coeffs_prev.P_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs_prev.P_re_fx[i][j][k], Q22 ); + hSpar->hMdDec->spar_coeffs_tar.C_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs_tar.C_re_fx[i][j][k], Q22 ); + hSpar->hMdDec->spar_coeffs_tar.P_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs_tar.P_re_fx[i][j][k], Q22 ); + hSpar->hMdDec->spar_coeffs.C_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][k], Q22 ); + hSpar->hMdDec->spar_coeffs.P_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][k], Q22 ); + } + } + } +#endif + } + ELSE + { +#ifndef IVAS_FLOAT_FIXED_TO_BE_REMOVED + // float to fix + Word16 num_channels_tmp = hSpar->hMdDec->spar_md_cfg.num_umx_chs; + FOR( i = 0; i < num_channels_tmp; i++ ) + { + FOR( j = 0; j < num_channels_tmp; j++ ) + { + FOR( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) + { + hSpar->hMdDec->spar_coeffs_prev.C_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs_prev.C_re[i][j][k], Q22 ); + hSpar->hMdDec->spar_coeffs_prev.P_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs_prev.P_re[i][j][k], Q22 ); + hSpar->hMdDec->spar_coeffs_tar.C_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs_tar.C_re[i][j][k], Q22 ); + hSpar->hMdDec->spar_coeffs_tar.P_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs_tar.P_re[i][j][k], Q22 ); + hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs.C_re[i][j][k], Q22 ); + hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs.P_re[i][j][k], Q22 ); + } + } + } +#endif + + IF( !bfi ) + { + ivas_spar_smooth_md_dtx_fx( hSpar->hMdDec, num_bands_out, num_md_sub_frames ); + } + + set_s( hSpar->hMdDec->valid_bands, 0, IVAS_MAX_NUM_BANDS ); +#ifndef IVAS_FLOAT_FIXED_TO_BE_REMOVED + FOR( i = 0; i < num_channels_tmp; i++ ) + { + FOR( j = 0; j < num_channels_tmp; j++ ) + { + FOR( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) + { + hSpar->hMdDec->spar_coeffs_prev.C_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs_prev.C_re_fx[i][j][k], Q22 ); + hSpar->hMdDec->spar_coeffs_prev.P_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs_prev.P_re_fx[i][j][k], Q22 ); + hSpar->hMdDec->spar_coeffs_tar.C_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs_tar.C_re_fx[i][j][k], Q22 ); + hSpar->hMdDec->spar_coeffs_tar.P_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs_tar.P_re_fx[i][j][k], Q22 ); + hSpar->hMdDec->spar_coeffs.C_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][k], Q22 ); + hSpar->hMdDec->spar_coeffs.P_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][k], Q22 ); + } + } + } +#endif + } + + + pop_wmops(); + return IVAS_ERR_OK; +} +#endif static ivas_error ivas_spar_dec_MD( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ Decoder_State *st0 /* i/o: decoder state structure - for bitstream handling*/ diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index aa98e0ae1..123a083d8 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -43,6 +43,7 @@ #include "ivas_stat_dec.h" #ifdef IVAS_FLOAT_FIXED #include "prot_fx2.h" +#include "ivas_prot_fx.h" #endif // IVAS_FLOAT_FIXED @@ -481,18 +482,23 @@ Word16 ivas_get_spar_dec_md_num_subframes( Word16 num_subframes; num_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; - IF ( sba_order > SBA_FOA_ORDER ) + move16(); + IF( GT_16( sba_order, SBA_FOA_ORDER ) ) { - IF ( ivas_total_brate >= IVAS_512k ) + IF( GE_32( ivas_total_brate, IVAS_512k ) ) { num_subframes = 1; + move16(); } } - IF ( ( ivas_total_brate <= IVAS_SID_5k2 && ivas_last_active_brate < IVAS_24k4 ) || ( ivas_total_brate > IVAS_SID_5k2 && ivas_total_brate < IVAS_24k4 ) ) + test(); + test(); + test(); + IF( ( LE_32( ivas_total_brate, IVAS_SID_5k2 ) && LT_32( ivas_last_active_brate, IVAS_24k4 ) ) || ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) && LT_32( ivas_total_brate, IVAS_24k4 ) ) ) { - num_subframes = 1; + move16(); } return ( num_subframes ); @@ -875,7 +881,7 @@ ivas_error ivas_spar_md_dec_init( int16_t i, j; int16_t nchan_transport; float pFC[IVAS_MAX_NUM_BANDS], PR_minmax[2]; - Word32 *pFC_fx, PR_minmax_fx[2]; + Word32 *pFC_fx=NULL, PR_minmax_fx[2]; ivas_error error; ivas_sba_get_spar_hoa_md_flag( sba_order, hDecoderConfig->ivas_total_brate, &hMdDec->spar_hoa_md_flag, &hMdDec->spar_hoa_dirac2spar_md_flag ); @@ -970,7 +976,7 @@ ivas_error ivas_spar_md_dec_init( set_zero( hMdDec->smooth_fac, IVAS_MAX_NUM_BANDS ); #ifdef IVAS_FLOAT_FIXED - set32_fx( hMdDec->smooth_fac_fx,0, IVAS_MAX_NUM_BANDS ); + set16_fx( hMdDec->smooth_fac_fx,0, IVAS_MAX_NUM_BANDS ); #endif for ( i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) { @@ -1257,13 +1263,13 @@ void ivas_spar_md_dec_process( { for (int jj = 0; jj < IVAS_SPAR_MAX_DMX_CHS - 1; jj++) { - hMdDec->spar_md.band_coeffs[i].C_re_fx[ii][jj] = hMdDec->spar_md.band_coeffs[i].C_re[ii][jj] * (1 << 22); + hMdDec->spar_md.band_coeffs[i].C_re_fx[ii][jj] = (Word32)(hMdDec->spar_md.band_coeffs[i].C_re[ii][jj] * (1 << 22)); } } for (int jj = 0; jj < IVAS_SPAR_MAX_DMX_CHS - 1; jj++) { - hMdDec->spar_md.band_coeffs[i].pred_re_fx[jj] = hMdDec->spar_md.band_coeffs[i].pred_re[jj] * (1 << 22); - hMdDec->spar_md.band_coeffs[i].P_re_fx[jj] = hMdDec->spar_md.band_coeffs[i].P_re[jj] * (1 << 22); + hMdDec->spar_md.band_coeffs[i].pred_re_fx[jj] = (Word32)(hMdDec->spar_md.band_coeffs[i].pred_re[jj] * (1 << 22)); + hMdDec->spar_md.band_coeffs[i].P_re_fx[jj] = (Word32)(hMdDec->spar_md.band_coeffs[i].P_re[jj] * (1 << 22)); } } ivas_spar_dec_parse_md_bs( hMdDec, st0, &nB, &bw, &dtx_vad, st_ivas->hDecoderConfig->ivas_total_brate, @@ -1456,6 +1462,88 @@ Word16 ivas_spar_chk_zero_coefs_fx( * Smooth MD during no data frame during DTX *-----------------------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void ivas_spar_smooth_md_dtx_fx( + ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ + const Word16 num_bands_out, /* i : number of output bands */ + const Word16 num_md_sub_frames /* i : number of metadata subframes */ +) +{ + Word16 j, k, b, dmx_ch; + Word16 ramp_fx; + Word32 tar_fx, prev_fx, new_val_fx; + Word16 tmp, tmp_e; + + tmp = BASOP_Util_Divide1616_Scale( hMdDec->dtx_md_smoothing_cntr, IVAS_DEFAULT_DTX_CNG_RAMP, &tmp_e ); + ramp_fx = shl_sat( tmp, tmp_e ); /* Q15 */ + + FOR( b = 0; b < num_bands_out; b++ ) + { + dmx_ch = hMdDec->spar_md_cfg.num_dmx_chans_per_band[b]; + move16(); + + FOR( j = 1; j < FOA_CHANNELS; j++ ) + { + FOR( k = dmx_ch; k < FOA_CHANNELS; k++ ) + { + prev_fx = hMdDec->spar_coeffs_prev.P_re_fx[j][k][b]; /* Q22 */ + move32(); + tar_fx = hMdDec->spar_coeffs_tar.P_re_fx[j][k][b]; /* Q22 */ + move32(); + new_val_fx = L_add( prev_fx, Mpy_32_16_1( L_sub( tar_fx, prev_fx ), ramp_fx ) ); /* Q22 + Q15 - Q15 = Q22*/ + hMdDec->spar_coeffs.P_re_fx[j][k][b] = new_val_fx; /* Q22 */ + move32(); + } + } + + FOR( j = 0; j < FOA_CHANNELS; j++ ) + { + FOR( k = 0; k < dmx_ch; k++ ) + { + prev_fx = hMdDec->spar_coeffs_prev.C_re_fx[j][k][b]; /* Q22 */ + move32(); + tar_fx = hMdDec->spar_coeffs_tar.C_re_fx[j][k][b]; /* Q22 */ + move32(); + new_val_fx = L_add( prev_fx, Mpy_32_16_1( L_sub( tar_fx, prev_fx ), ramp_fx ) ); /* Q22 + Q15 - Q15 = Q22*/ + hMdDec->spar_coeffs.C_re_fx[j][k][b] = new_val_fx; /* Q22 */ + move32(); + } + } + } + + /* expand MD to all time slots */ + FOR( Word16 i_ts = 1; i_ts < num_md_sub_frames; i_ts++ ) + { + FOR( b = 0; b < num_bands_out; b++ ) + { + dmx_ch = hMdDec->spar_md_cfg.num_dmx_chans_per_band[b]; + move16(); + + FOR( j = 1; j < FOA_CHANNELS; j++ ) + { + FOR( k = dmx_ch; k < FOA_CHANNELS; k++ ) + { + hMdDec->spar_coeffs.P_re_fx[j][k][b + i_ts * IVAS_MAX_NUM_BANDS] = hMdDec->spar_coeffs.P_re_fx[j][k][b]; /* Q22 */ + move32(); + } + } + + FOR( j = 0; j < FOA_CHANNELS; j++ ) + { + FOR( k = 0; k < dmx_ch; k++ ) + { + hMdDec->spar_coeffs.C_re_fx[j][k][b + i_ts * IVAS_MAX_NUM_BANDS] = hMdDec->spar_coeffs.C_re_fx[j][k][b]; /* Q22 */ + move32(); + } + } + } + } + + hMdDec->dtx_md_smoothing_cntr = s_min( add( hMdDec->dtx_md_smoothing_cntr, 1 ), IVAS_DEFAULT_DTX_CNG_RAMP ); + + return; +} +#endif void ivas_spar_smooth_md_dtx( ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ const int16_t num_bands_out, /* i : number of output bands */ @@ -1532,6 +1620,72 @@ void ivas_spar_smooth_md_dtx( * Set up smoothing of SPAR MD when SID update frame is received *-----------------------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void ivas_spar_setup_md_smoothing_fx( + ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ + const Word16 num_bands_out, /* i : number of output bands */ + const Word16 num_md_sub_frames /* i : number of metadata subframes */ +) +{ + /* copy the coeffs */ + Word16 num_channels, i, j, k; + + num_channels = hMdDec->spar_md_cfg.num_umx_chs; + move16(); + + FOR( i = 0; i < num_channels; i++ ) + { + FOR( j = 0; j < num_channels; j++ ) + { + FOR( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) + { + hMdDec->spar_coeffs_prev.C_re_fx[i][j][k] = hMdDec->spar_coeffs_tar.C_re_fx[i][j][k]; /* Q22 */ + move32(); + } + } + } + + FOR( i = 0; i < num_channels; i++ ) + { + FOR( j = 0; j < num_channels; j++ ) + { + FOR( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) + { + hMdDec->spar_coeffs_prev.P_re_fx[i][j][k] = hMdDec->spar_coeffs_tar.P_re_fx[i][j][k]; /* Q22 */ + move32(); + } + } + } + + FOR( i = 0; i < num_channels; i++ ) + { + FOR( j = 0; j < num_channels; j++ ) + { + FOR( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) + { + hMdDec->spar_coeffs_tar.C_re_fx[i][j][k] = hMdDec->spar_coeffs.C_re_fx[i][j][k]; /* Q22 */ + move32(); + } + } + } + + FOR( i = 0; i < num_channels; i++ ) + { + FOR( j = 0; j < num_channels; j++ ) + { + FOR( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) + { + hMdDec->spar_coeffs_tar.P_re_fx[i][j][k] = hMdDec->spar_coeffs.P_re_fx[i][j][k]; /* Q22 */ + move32(); + } + } + } + + ivas_spar_smooth_md_dtx_fx( hMdDec, num_bands_out, num_md_sub_frames ); + + return; +} +#endif void ivas_spar_setup_md_smoothing( ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ const int16_t num_bands_out, /* i : number of output bands */ @@ -1599,6 +1753,67 @@ void ivas_spar_setup_md_smoothing( * Update previous and target MD *-----------------------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void ivas_spar_update_md_hist_fx( + ivas_spar_md_dec_state_t *hMdDec /* i/o: SPAR MD decoder handle */ +) +{ + Word16 num_channels, i, j, k; + + num_channels = hMdDec->spar_md_cfg.num_umx_chs; + move16(); + + FOR( i = 0; i < num_channels; i++ ) + { + FOR( j = 0; j < num_channels; j++ ) + { + FOR( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) + { + hMdDec->spar_coeffs_prev.C_re_fx[i][j][k] = hMdDec->spar_coeffs.C_re_fx[i][j][k]; /* Q22 */ + move32(); + } + } + } + + FOR( i = 0; i < num_channels; i++ ) + { + FOR( j = 0; j < num_channels; j++ ) + { + FOR( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) + { + hMdDec->spar_coeffs_prev.P_re_fx[i][j][k] = hMdDec->spar_coeffs.P_re_fx[i][j][k]; /* Q22 */ + move32(); + } + } + } + + FOR( i = 0; i < num_channels; i++ ) + { + FOR( j = 0; j < num_channels; j++ ) + { + FOR( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) + { + hMdDec->spar_coeffs_tar.C_re_fx[i][j][k] = hMdDec->spar_coeffs.C_re_fx[i][j][k]; /* Q22 */ + move32(); + } + } + } + + FOR( i = 0; i < num_channels; i++ ) + { + FOR( j = 0; j < num_channels; j++ ) + { + FOR( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) + { + hMdDec->spar_coeffs_tar.P_re_fx[i][j][k] = hMdDec->spar_coeffs.P_re_fx[i][j][k]; /* Q22 */ + move32(); + } + } + } + + return; +} +#endif void ivas_spar_update_md_hist( ivas_spar_md_dec_state_t *hMdDec /* i/o: SPAR MD decoder handle */ ) @@ -3515,11 +3730,11 @@ void ivas_spar_to_dirac( dvx_fx[band] = Mpy_32_32(PR_fx[0], dvnorm_fx); dvy_fx[band] = Mpy_32_32(PR_fx[1], dvnorm_fx); dvz_fx[band] = Mpy_32_32(PR_fx[2], dvnorm_fx); - Word32 q_1 = (22) + (31 - q_dvnorm) - 31; + Word16 q_1 = (22) + (31 - q_dvnorm) - 31; Word32 temp = Mpy_32_32(dvx_fx[band], dvx_fx[band]) + Mpy_32_32(dvy_fx[band], dvy_fx[band] ); - Word32 q2 = q_1 + q_1 - 31; - Word32 q_temp = 31 - q2; + Word16 q2 = q_1 + q_1 - 31; + Word16 q_temp = 31 - q2; radius_fx = Sqrt32(temp, &q_temp); radius = sqrtf(dvx[band] * dvx[band] + dvy[band] * dvy[band]); @@ -3539,7 +3754,7 @@ void ivas_spar_to_dirac( Word32 azi_intermediate = Mpy_32_16_1(DEGREE_180_Q_22, check_azi_fx_res); azi_intermediate = azi_intermediate + ONE_IN_Q21; //Word16 azi_res = L_shr_r(azi_intermediate, 22); - Word16 azi_res = azi_intermediate / (1 << 22); + Word16 azi_res = extract_l(azi_intermediate / (1 << 22)); Word16 check_ele_fx = BASOP_util_atan2(dvz_fx[band], radius_fx, (9+ q_dvnorm)-q_temp); Word32 check_ele_fx_32 = L_shl(check_ele_fx, 16); @@ -3555,7 +3770,7 @@ void ivas_spar_to_dirac( Word32 ele_intermediate = Mpy_32_16_1(DEGREE_180_Q_22, check_ele_fx_res); ele_intermediate = ele_intermediate + ONE_IN_Q21; //Word16 ele_res = L_shr_r(ele_intermediate, 22); - Word16 ele_res = ele_intermediate/(1<<22); + Word16 ele_res = extract_l(ele_intermediate/(1<<22)); azi[band] = (int16_t)(max(-180.0f, min(180.0f, atan2f(dvy[band], dvx[band]) / EVS_PI * 180.0f)) + 0.5f); @@ -3569,7 +3784,7 @@ void ivas_spar_to_dirac( { float w_en_norm, f_scale; Word32 w_en_norm_fx, f_scale_fx; - Word32 q_w_en_norm_fx; + Word16 q_w_en_norm_fx; if ( active_w ) { if ( dtx_vad == 0 ) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 9b392f758..e18204ec1 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -245,7 +245,7 @@ typedef struct stereo_dft_dec_data_struct float ap_delay_mem[NS2SA( 16000, DELAY_BWE_TOTAL_NS )]; float ap_fade_mem[STEREO_DFT_ALLPASS_FADELEN_16k]; #ifdef IVAS_FLOAT_FIXED - Word32 stab_fac_smooth_res_fx; /* low-pass filtered stability factor */ + Word16 stab_fac_smooth_res_fx; /* low-pass filtered stability factor */ Word32 lt_pred_gain_fx; Word32 lt_pred_gain_variation_fx; Word32 lt_var_mean_ratio_fx; @@ -254,7 +254,7 @@ typedef struct stereo_dft_dec_data_struct Word16 q_lt_pred_gain; Word32 ap_delay_mem_fx[NS2SA( 16000, DELAY_BWE_TOTAL_NS )]; Word32 ap_fade_mem_fx[STEREO_DFT_ALLPASS_FADELEN_16k]; - Word32 q_ap_fade_mem_fx; + Word16 q_ap_fade_mem_fx; #endif int16_t ap_wasTransient; @@ -1017,7 +1017,7 @@ typedef struct cpe_dec_data_structure Word32 prev_hb_synth_fx[CPE_CHANNELS][NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS )]; Word32 prev_synth_fx[CPE_CHANNELS][NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS )]; - Word32 q_prev_synth_fx; + Word16 q_prev_synth_fx; Word32 *input_mem_fx[CPE_CHANNELS]; Word32 *input_mem_LB_fx[CPE_CHANNELS]; diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index 2ae65b97b..df8222925 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -377,10 +377,10 @@ void stereo_dft_dec_open( ) { /*Sizes*/ - hStereoDft->N = (Word32) ( STEREO_DFT_HOP_MAX * output_Fs / 48000 ); + hStereoDft->N = (Word16) ( STEREO_DFT_HOP_MAX * output_Fs / 48000 ); /*Init. DFT sizes*/ - hStereoDft->NFFT = (Word32) ( STEREO_DFT32MS_N_MAX * output_Fs / 48000 ); + hStereoDft->NFFT = (Word16) ( STEREO_DFT32MS_N_MAX * output_Fs / 48000 ); hStereoDft->dft_trigo_8k = dft_trigo_32k; hStereoDft->dft_trigo_12k8 = dft_trigo_12k8; diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 8ad035271..e2eb41381 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -149,7 +149,7 @@ void stereo_dft_dec_reset_fx( move32(); hStereoDft->stab_fac_smooth_res_fx = 0; - move32(); + move16(); bass_psfilter_init( hStereoDft->hBpf ); tcxltp_dec_init( hStereoDft->hTcxLtpDec, 0, MODE1, IVAS_CPE_DFT, PIT_MAX, 12800 ); diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index 46def24ac..93ff84bb6 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -261,11 +261,8 @@ void stereo_mdct_core_dec_fx( sts[ch]->gamma = float_to_fix16( sts[ch]->gamma_float, Q15 ); sts[ch]->preemph_fac = float_to_fix16( sts[ch]->preemph_fac_float, Q15 ); sts[ch]->Mode2_lp_gainp = float_to_fix( sts[ch]->lp_gainp, Q16 ); - sts[ch]->hTcxCfg->na_scale = float_to_fix16( sts[ch]->hTcxCfg->na_scale_flt, Q15 ); - sts[ch]->hTcxCfg->sq_rounding = float_to_fix16( sts[ch]->hTcxCfg->sq_rounding_flt, Q15 ); sts[ch]->hTcxLtpDec->tcxltp_gain = float_to_fix16( sts[ch]->hTcxLtpDec->tcxltp_gain_float, Q15 ); sts[ch]->inv_gamma = float_to_fix16( 1 / sts[ch]->gamma_float, Q14 ); - sts[ch]->hTcxCfg->preemph_fac = float_to_fix16( sts[ch]->hTcxCfg->preemph_fac_flt, Q15 ); f2me_16( sts[ch]->last_gain_syn_deemph_float, &sts[ch]->last_gain_syn_deemph, &sts[ch]->last_gain_syn_deemph_e ); f2me_16( sts[ch]->last_concealed_gain_syn_deemph_float, &sts[ch]->last_concealed_gain_syn_deemph, &sts[ch]->last_concealed_gain_syn_deemph_e ); f2me_16( sts[ch]->hTcxDec->old_gaintcx_bfi_float, &sts[ch]->hTcxDec->old_gaintcx_bfi, &sts[ch]->hTcxDec->old_gaintcx_bfi_e ); @@ -286,13 +283,13 @@ void stereo_mdct_core_dec_fx( sts[ch]->hTcxDec->cummulative_damping_tcx = float_to_fix16( sts[ch]->hTcxDec->cummulative_damping_tcx_float, Q15 ); } } - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - IF( sts[ch]->rate_switching_reset ) - { - floatToFixed_arr( sts[ch]->lsp_old, sts[ch]->lsp_old_fx, Q15, M ); - } - } + //FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + //{ + // IF( sts[ch]->rate_switching_reset ) + // { + // floatToFixed_arr( sts[ch]->lsp_old, sts[ch]->lsp_old_fx, Q15, M ); + // } + //} IF( sts[0]->bfi && ( hCPE->hStereoMdct->mdct_stereo_mode[0] > SMDCT_DUAL_MONO || hCPE->hStereoMdct->mdct_stereo_mode[1] > SMDCT_DUAL_MONO ) ) { floatToFixed_arr( sts[0]->hTonalMDCTConc->lastBlockData.spectralData_float, sts[0]->hTonalMDCTConc->lastBlockData.spectralData, ( 15 - sts[0]->hTonalMDCTConc->lastBlockData.spectralData_exp ), L_FRAME_MAX ); @@ -346,14 +343,14 @@ void stereo_mdct_core_dec_fx( sts[ch]->hTcxDec->cummulative_damping_tcx_float = fix16_to_float( sts[ch]->hTcxDec->cummulative_damping_tcx, Q15 ); } } - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - IF( sts[ch]->rate_switching_reset ) - { - Word16 old_Aq_12_8_e = norm_s( sts[ch]->old_Aq_12_8_fx[0] ); - fixedToFloat_arr( sts[ch]->old_Aq_12_8_fx, sts[ch]->old_Aq_12_8, ( 15 - old_Aq_12_8_e ), M + 1 ); - } - } + //FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + //{ + // IF( sts[ch]->rate_switching_reset ) + // { + // Word16 old_Aq_12_8_e = norm_s( sts[ch]->old_Aq_12_8_fx[0] ); + // fixedToFloat_arr( sts[ch]->old_Aq_12_8_fx, sts[ch]->old_Aq_12_8, ( 15 - old_Aq_12_8_e ), M + 1 ); + // } + //} IF( sts[0]->bfi && ( hCPE->hStereoMdct->mdct_stereo_mode[0] > SMDCT_DUAL_MONO || hCPE->hStereoMdct->mdct_stereo_mode[1] > SMDCT_DUAL_MONO ) ) { fixedToFloat_arr( sts[0]->hTonalMDCTConc->lastBlockData.spectralData, sts[0]->hTonalMDCTConc->lastBlockData.spectralData_float, ( 15 - sts[0]->hTonalMDCTConc->lastBlockData.spectralData_exp ), sts[0]->L_frameTCX_past ); @@ -683,13 +680,13 @@ void stereo_mdct_core_dec_fx( float pd = st->hTonalMDCTConc->pTCI_float->phaseDiff_float[i]; if ( pd >= PI2 ) pd = fmodf( pd, PI2 ) - PI2; - st->hTonalMDCTConc->pTCI_fix->phaseDiff[i] = float_to_fix16( pd, Q12 ); + st->hTonalMDCTConc->pTCI_float->phaseDiff[i] = float_to_fix16( pd, Q12 ); } FOR( Word16 i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++ ) { float pd = st->hTonalMDCTConc->pTCI_float->phase_currentFramePredicted_float[i]; pd = fmodf( pd, PI2 ); - st->hTonalMDCTConc->pTCI_fix->phase_currentFramePredicted[i] = (Word16) ( pd * ( 1u << Q13 ) ); + st->hTonalMDCTConc->pTCI_float->phase_currentFramePredicted[i] = (Word16) ( pd * ( 1u << Q13 ) ); } //st->hTonalMDCTConc->nFramesLost = float_to_fix16( st->hTonalMDCTConc->nFramesLost, Q1 ); } @@ -788,8 +785,6 @@ void stereo_mdct_core_dec_fx( Word16 signal_outFB_tmp_fx[2][1200]; Word16 e_sig = 17; - Word16 e_lsp = 0; - Word16 e_lsf = 0;; Word32 *x_fx_[2][2]; Word16 q_x = Q11; Word16 x_e_; @@ -861,7 +856,7 @@ void stereo_mdct_core_dec_fx( st->Mode2_lp_gainc = (Word32) (st->lp_gainc * ONE_IN_Q16); st->Mode2_lp_gainp= (Word32) (st->lp_gainp * ONE_IN_Q29); st->cummulative_damping = (Word16) (st->cummulative_damping_float * MAX_16); - st->old_enr_LP = (Word16) (st->old_enr_LP_float * ONE_IN_Q3); + //st->old_enr_LP = (Word16) (st->old_enr_LP_float * ONE_IN_Q3); if ( !st->tcxonly ) { @@ -869,7 +864,7 @@ void stereo_mdct_core_dec_fx( } IF(st->hBPF) floatToFixed_arr( st->hBPF->pst_old_syn, st->hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); - floatToFixed_arr( st->lsp_old, st->lsp_old_fx, Q15, M ); + //floatToFixed_arr( st->lsp_old, st->lsp_old_fx, Q15, M ); IF(st->hBPF) st->mem_error = floatToFixed( st->hBPF->pst_mem_deemp_err, Q16 ); @@ -896,8 +891,8 @@ void stereo_mdct_core_dec_fx( IF(st->hTonalMDCTConc) floatToFixed_arr(st->hTonalMDCTConc->secondLastPcmOut_float, st->hTonalMDCTConc->secondLastPcmOut, -2, st->hTonalMDCTConc->nSamples / 2); if ( st->hPlcInfo ) { - st->hPlcInfo->step_concealgain_fx = float_to_fix16( st->hPlcInfo->step_concealgain, Q15 ); - st->hPlcInfo->recovery_gain_float = float_to_fix16( st->hPlcInfo->recovery_gain, Q14 ); + //st->hPlcInfo->step_concealgain_fx = float_to_fix16( st->hPlcInfo->step_concealgain, Q15 ); + //st->hPlcInfo->recovery_gain_float = float_to_fix16( st->hPlcInfo->recovery_gain, Q14 ); } IF(st->hTcxDec) st->hTcxDec->conceal_eof_gain = float_to_fix16( st->hTcxDec->conceal_eof_gain_float, Q14 ); @@ -926,14 +921,17 @@ void stereo_mdct_core_dec_fx( IF(st->hFdCngDec && st->hFdCngDec->hFdCngCom) floatToFixed_arr(st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, 15, 17); } - FOR( Word16 ind = 0; ind < M + 1; ind++ ) - { - hCPE->hCoreCoder[0]->old_Aq_12_8_fx[ind] = (Word16) ( hCPE->hCoreCoder[0]->old_Aq_12_8[ind] * 4096.f ); - hCPE->hCoreCoder[1]->old_Aq_12_8_fx[ind] = (Word16) ( hCPE->hCoreCoder[1]->old_Aq_12_8[ind] * 4096.f ); - hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32[ind] = (Word32)(hCPE->hCoreCoder[0]->old_Aq_12_8[ind] * (1<<28)); - hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32[ind] = (Word32)(hCPE->hCoreCoder[1]->old_Aq_12_8[ind] * (1<<28)); - } + //FOR( Word16 ind = 0; ind < M + 1; ind++ ) + //{ + // hCPE->hCoreCoder[0]->old_Aq_12_8_fx[ind] = (Word16) ( hCPE->hCoreCoder[0]->old_Aq_12_8[ind] * 4096.f ); + // hCPE->hCoreCoder[1]->old_Aq_12_8_fx[ind] = (Word16) ( hCPE->hCoreCoder[1]->old_Aq_12_8[ind] * 4096.f ); + // hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32[ind] = (Word32)(hCPE->hCoreCoder[0]->old_Aq_12_8[ind] * (1<<28)); + // hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32[ind] = (Word32)(hCPE->hCoreCoder[1]->old_Aq_12_8[ind] * (1<<28)); + //} // + Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, M + 1, ( 28 - norm_s( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0] - 1 ) ) ); + Copy_Scale_sig_16_32( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, M + 1, ( 28 - norm_s( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0] - 1 ) ) ); + ivas_mdct_core_reconstruct_fx( hCPE, x_fx_, signal_outFB_tmp_fx, fUseTns, 0, q_x, e_sig ); // IF(hCPE->hStereoMdct) hCPE->hStereoMdct->lastCoh = fix16_to_float(hCPE->hStereoMdct->lastCoh_fx, 14); @@ -954,9 +952,9 @@ void stereo_mdct_core_dec_fx( st->hTcxDec->tcxltp_last_gain_unmodified_float = fix16_to_float( st->hTcxDec->tcxltp_last_gain_unmodified, Q15 ); st->hTcxLtpDec->tcxltp_gain_float = fix16_to_float( st->hTcxLtpDec->tcxltp_gain, Q15 ); st->hTcxDec->conceal_eof_gain_float = fix16_to_float( st->hTcxDec->conceal_eof_gain, Q14 ); - FOR(Word16 ind = 0; ind < 17; ind++) { - st->old_Aq_12_8[ind] = (float)(st->old_Aq_12_8_fx[ind]) / (float)(1<<12); - } + //FOR(Word16 ind = 0; ind < 17; ind++) { + // st->old_Aq_12_8[ind] = (float)(st->old_Aq_12_8_fx[ind]) / (float)(1<<12); + //} IF(st->hBPF) st->hBPF->pst_mem_deemp_err = fixedToFloat( st->mem_error, Q16 ); for ( int p = 0; p < st->L_frame; p++ ) @@ -967,12 +965,12 @@ void stereo_mdct_core_dec_fx( st->lp_gainc = (float) st->Mode2_lp_gainc / ONE_IN_Q16; st->lp_gainp = (float) st->Mode2_lp_gainp / ONE_IN_Q29; st->cummulative_damping_float = (float) st->cummulative_damping / MAX_16; - st->old_enr_LP_float = (float) st->old_enr_LP / ONE_IN_Q3; + //st->old_enr_LP_float = (float) st->old_enr_LP / ONE_IN_Q3; 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 * pow( 2, st->Q_syn ); - st->hTcxDec->syn_Overl_TDAC_float[p] = (float) st->hTcxDec->syn_Overl_TDAC[p] * 2 * pow( 2, st->Q_syn ); + st->hTcxDec->syn_Overl_TDACFB_float[p] = (float)((float) st->hTcxDec->syn_Overl_TDACFB[p] * 2 * pow( 2, st->Q_syn )); + st->hTcxDec->syn_Overl_TDAC_float[p] = (float)((float) st->hTcxDec->syn_Overl_TDAC[p] * 2 * pow( 2, st->Q_syn )); } for ( int p = 0; p < 640; p++ ) { @@ -998,8 +996,8 @@ void stereo_mdct_core_dec_fx( if ( st->hPlcInfo ) { - st->hPlcInfo->recovery_gain_float = fix16_to_float( st->hPlcInfo->recovery_gain, Q14 ); - st->hPlcInfo->step_concealgain = fix16_to_float( st->hPlcInfo->step_concealgain_fx, Q15 ); + //st->hPlcInfo->recovery_gain_float = fix16_to_float( st->hPlcInfo->recovery_gain, Q14 ); + //st->hPlcInfo->step_concealgain = fix16_to_float( st->hPlcInfo->step_concealgain_fx, Q15 ); } fixedToFloat_arrL( st->old_pitch_buf_fx, st->old_pitch_buf, Q16, 2 * NB_SUBFR16k + 2 ); IF(st->hTcxDec) st->hTcxDec->CngLevelBackgroundTrace_bfi = me2f_16(st->hTcxDec->conCngLevelBackgroundTrace, st->hTcxDec->conCngLevelBackgroundTrace_e); diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index e7b6b59d5..c570e8abd 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -1060,7 +1060,7 @@ ivas_error stereo_memory_dec( st->hTcxDec->old_synthFB = st->hTcxDec->synth_history + NS2SA( st->output_Fs, PH_ECU_MEM_NS ); st->hTcxDec->prev_good_synth = st->hTcxDec->old_synthFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ); #ifdef IVAS_FLOAT_FIXED - set32_fx(st->hTcxDec->FBTCXdelayBuf, 0, 111); + set16_fx(st->hTcxDec->FBTCXdelayBuf, 0, 111); st->hTcxDec->old_synthFB_fx = st->hTcxDec->synth_history_fx + NS2SA(st->output_Fs, PH_ECU_MEM_NS); st->hTcxDec->prev_good_synth_fx = st->hTcxDec->old_synthFB_fx + NS2SA(st->output_Fs, PH_ECU_LOOKAHEAD_NS); #endif @@ -3964,7 +3964,7 @@ void stereo_switching_dec( #ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED IF( hCPE->hStereoTCA != NULL ) { - hCPE->hStereoTCA->prevTargetGain_fx = hCPE->hStereoTCA->prevTargetGain * ONE_IN_Q29; + hCPE->hStereoTCA->prevTargetGain_fx = (Word32)(hCPE->hStereoTCA->prevTargetGain * ONE_IN_Q29); } #endif Word16 i, n; @@ -4045,7 +4045,7 @@ void stereo_switching_dec( { Word64 temp_result = (Word64) hCPE->hCoreCoder[1]->prev_synth_buffer_fx[i] * tmpF_fx; // 16bit buffer - hCPE->hCoreCoder[1]->prev_synth_buffer_fx[i] = saturate( W_shr( temp_result, 27 ) ); + hCPE->hCoreCoder[1]->prev_synth_buffer_fx[i] = saturate( W_extract_l(W_shr( temp_result, 27 )) ); // 32bit buffer hCPE->hCoreCoder[1]->prev_synth_buffer32_fx[i] = W_sat_l( W_shr( temp_result, 27 ) ); } diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 54c87e520..2a4e4f5b3 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -386,26 +386,26 @@ void stereo_tcx_core_dec_fx( { IF( !( st->rf_flag && st->use_partial_copy && ( EQ_16( st->rf_frame_type, RF_TCXTD1 ) || EQ_16( st->rf_frame_type, RF_TCXTD2 ) ) ) ) { - IF( st->hTonalMDCTConc != NULL && st->last_core == TCX_20_CORE && st->second_last_core == TCX_20_CORE && ( ( st->old_fpitch_float <= 0.5f * st->L_frame ) || ( st->hTcxDec->tcxltp_last_gain_unmodified_float <= 0.4f ) ) + IF( st->hTonalMDCTConc != NULL && st->last_core == TCX_20_CORE && st->second_last_core == TCX_20_CORE && ( ( st->old_fpitch <= L_shl(st->L_frame, 15) ) || ( st->hTcxDec->tcxltp_last_gain_unmodified <= 13107 /*0.4f*/ ) ) /* it is fine to call the detection even if no ltp information is available, meaning that st->old_fpitch == st->tcxltp_second_last_pitch == st->L_frame */ - && ( st->old_fpitch_float == st->hTcxDec->tcxltp_second_last_pitch_float ) && !st->last_tns_active && !st->second_last_tns_active ) + && ( st->old_fpitch == st->hTcxDec->tcxltp_second_last_pitch ) && !st->last_tns_active && !st->second_last_tns_active ) { - st->hTonalMDCTConc->pTCI_float->numIndexes = st->hTonalMDCTConc->pTCI_fix->numIndexes; - FOR( i = 0; i < st->hTonalMDCTConc->pTCI_fix->numIndexes; ++i ) + //st->hTonalMDCTConc->pTCI_float->numIndexes = st->hTonalMDCTConc->pTCI_float->numIndexes; + FOR( i = 0; i < st->hTonalMDCTConc->pTCI_float->numIndexes; ++i ) { - st->hTonalMDCTConc->pTCI_float->indexOfTonalPeak[i] = st->hTonalMDCTConc->pTCI_fix->indexOfTonalPeak[i]; - st->hTonalMDCTConc->pTCI_float->lowerIndex[i] = st->hTonalMDCTConc->pTCI_fix->lowerIndex[i]; - st->hTonalMDCTConc->pTCI_float->upperIndex[i] = st->hTonalMDCTConc->pTCI_fix->upperIndex[i]; + st->hTonalMDCTConc->pTCI_float->indexOfTonalPeak[i] = st->hTonalMDCTConc->pTCI_float->indexOfTonalPeak[i]; + st->hTonalMDCTConc->pTCI_float->lowerIndex[i] = st->hTonalMDCTConc->pTCI_float->lowerIndex[i]; + st->hTonalMDCTConc->pTCI_float->upperIndex[i] = st->hTonalMDCTConc->pTCI_float->upperIndex[i]; } - FOR( i = 0; i < st->hTonalMDCTConc->pTCI_fix->numIndexes; i++ ) + FOR( i = 0; i < st->hTonalMDCTConc->pTCI_float->numIndexes; i++ ) { - st->hTonalMDCTConc->pTCI_float->phaseDiff_float[i] = fixedToFloat( st->hTonalMDCTConc->pTCI_fix->phaseDiff[i], Q12 ); + st->hTonalMDCTConc->pTCI_float->phaseDiff_float[i] = fixedToFloat( st->hTonalMDCTConc->pTCI_float->phaseDiff[i], Q12 ); } FOR( i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++ ) { - st->hTonalMDCTConc->pTCI_float->phase_currentFramePredicted_float[i] = fixedToFloat( st->hTonalMDCTConc->pTCI_fix->phase_currentFramePredicted[i], Q13 ); + st->hTonalMDCTConc->pTCI_float->phase_currentFramePredicted_float[i] = fixedToFloat( st->hTonalMDCTConc->pTCI_float->phase_currentFramePredicted[i], Q13 ); } } } @@ -497,7 +497,7 @@ void stereo_tcx_core_dec_fx( lsfBase = PlcGetLsfBase( st->lpcQuantization, st->narrowBand, st->sr_core ); - dlpc_bfi( st->L_frame, lsfnew_uw_fx, st->lsfold_uw, st->last_good, st->nbLostCmpt, st->mem_MA_fx, st->mem_AR_fx, &( st->stab_fac_fx ), st->lsf_adaptive_mean_fx, st->numlpc, st->lsf_cng, st->plcBackgroundNoiseUpdated, st->lsf_q_cng, st->old_lsf_q_cng, lsfBase, (Word8) st->tcxonly ); + dlpc_bfi( st->L_frame, lsfnew_uw_fx, st->lsfold_uw, st->last_good, st->nbLostCmpt, st->mem_MA_fx, st->mem_AR_fx, &( st->stab_fac_fx ), st->lsf_adaptive_mean_fx, st->numlpc, st->lsf_cng, (Word8)st->plcBackgroundNoiseUpdated, st->lsf_q_cng, st->old_lsf_q_cng, lsfBase, (Word8) st->tcxonly ); hTcxDec->envWeighted = 0; @@ -721,7 +721,7 @@ void stereo_tcx_core_dec_fx( /* note: codec_mode is forced to MODE2, since FEC_clas_estim() considers only TCX being in Mode2*/ Word16 prev_codec_mode = st->codec_mode; st->codec_mode = MODE2; - FEC_clas_estim_fx( st, 0, st->L_frame, &st->clas_dec, st->tcxonly ? GENERIC : st->core_ext_mode, pitch_C, synth_fx, &st->lp_ener_bfi_fx, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0 /*st->core_brate*/, st->Q_syn, NULL, st->mem_syn_clas_estim_fx, &st->classifier_Q_mem_syn, hTcxLtpDec->tcxltp ? hTcxDec->tcxltp_last_gain_unmodified : MIN_16, CLASSIFIER_TCX, bfi, st->last_core_brate, -1 ); + FEC_clas_estim_fx( st, 0, st->L_frame, &st->clas_dec, st->tcxonly ? GENERIC : st->core_ext_mode, pitch_C, synth_fx, &st->lp_ener_FER_fx, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0 /*st->core_brate*/, st->Q_syn, NULL, st->mem_syn_clas_estim_fx, &st->classifier_Q_mem_syn, hTcxLtpDec->tcxltp ? hTcxDec->tcxltp_last_gain_unmodified : MIN_16, CLASSIFIER_TCX, bfi, st->last_core_brate, -1 ); st->codec_mode = prev_codec_mode; } } diff --git a/lib_dec/ivas_td_low_rate_dec.c b/lib_dec/ivas_td_low_rate_dec.c index 67c87d77b..0ceb967a1 100644 --- a/lib_dec/ivas_td_low_rate_dec.c +++ b/lib_dec/ivas_td_low_rate_dec.c @@ -202,7 +202,7 @@ void tdm_low_rate_dec( for (int i = 0; i < M; i++) { lsf_new_fx[i] = (Word16)(lsf_new[i] * 2.56f); } - tdm_low_rate_dec_fx(st, dct_epit_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, st->Q_exc); + tdm_low_rate_dec_fx(st, dct_epit_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx); fixedToFloat_arr(dct_epit_fx, dct_epit, st->Q_exc, L_FRAME); //*tmp_noise = fixedToFloat(tmp_noise_fx, Q3); fixedToFloat_arr(pitch_buf_fx, pitch_buf, Q6, NB_SUBFR16k); @@ -238,8 +238,7 @@ void tdm_low_rate_dec_fx( Word16 *exc, /* i/o: adapt. excitation exc Q_exc */ Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc */ Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc */ - const Word16 *lsf_new, /* i : ISFs at the end of the frame Q8/100 (2.56x) */ - Word16 Q_exc + const Word16 *lsf_new /* i : ISFs at the end of the frame Q8/100 (2.56x) */ ) { Word16 tmp_nb_bits_tot, pit_band_idx; @@ -305,7 +304,7 @@ void tdm_low_rate_dec_fx( } //gsc_dec(st, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st->coder_type, &last_bin, lsf_new, exc_wo_nf, tmp_noise); - gsc_dec_ivas_fx(st, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st->coder_type, &last_bin, lsf_new, exc_wo_nf_fx, Q_exc); + gsc_dec_ivas_fx(st, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st->coder_type, &last_bin, lsf_new, exc_wo_nf_fx, st->Q_exc); /*--------------------------------------------------------------------------------------* * iDCT transform @@ -322,7 +321,7 @@ void tdm_low_rate_dec_fx( *----------------------------------------------------------------------*/ //pre_echo_att(&hGSCDec->Last_frame_ener, exc, attack_flag, st->last_coder_type, st->L_frame); - pre_echo_att_fx(&hGSCDec->Last_frame_ener_fx, exc, attack_flag, Q_exc, st->last_coder_type, st->L_frame); + pre_echo_att_fx(&hGSCDec->Last_frame_ener_fx, exc, attack_flag, st->Q_exc, st->last_coder_type, st->L_frame); /*--------------------------------------------------------------------------------------* @@ -543,7 +542,7 @@ void decod_gen_2sbfr( else { p_bwe_exc_fx = NULL; } - decod_gen_2sbfr_ivas_fx( st, sharpFlag, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, p_bwe_exc_fx, gain_buf_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, st->Q_exc); + decod_gen_2sbfr_ivas_fx( st, sharpFlag, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, p_bwe_exc_fx, gain_buf_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx); fixedToFloat_arr( pitch_buf_fx, pitch_buf, Q6, NB_SUBFR16k ); fixedToFloat_arr( voice_factors_fx, voice_factors, Q15, 5 ); fixedToFloat_arr( exc_fx, exc, st->Q_exc, L_FRAME ); @@ -587,8 +586,8 @@ void decod_gen_2sbfr_ivas_fx( Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc */ Word16 *gain_buf, /* o : floating pitch gain for each subframe Q14 */ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[], /* i : pitch values for primary channel Q6 */ - Word16 Q_exc ) + const Word16 tdm_Pri_pitch_buf[] /* i : pitch values for primary channel Q6 */ + ) { Word16 T0, T0_frac, T0_min, T0_max; /* integer pitch variables */ // float gain_pit = 0.0f; /* pitch gain */ @@ -611,7 +610,7 @@ void decod_gen_2sbfr_ivas_fx( Word16 code[2 * L_SUBFR]; /* algebraic codevector */ const Word16 *p_Aq; /* Pointer to frame LP coefficient */ Word16 *pt_pitch; /* pointer to floating pitch */ - Word16 i_subfr, i; /* tmp variables */ + Word16 i_subfr; /* tmp variables */ Word16 L_frame; Word16 pitch_limit_flag; // float error; @@ -679,7 +678,7 @@ void decod_gen_2sbfr_ivas_fx( gain_dec_lbr_fx( st, GENERIC, i_subfr, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, gc_mem, gp_mem, 2 * L_SUBFR ); // st->tilt_code = est_tilt(exc + i_subfr, gain_pit, code, gain_code, &voice_fac, 2 * L_SUBFR, 0); // st->tilt_code_fx = est_tilt_fx(exc + i_subfr, gain_pit, code, gain_code, &voice_fac, Q_exc/*, 2 * L_SUBFR, 0*/); - st->tilt_code_fx = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, Q_exc, 2 * L_SUBFR, 0 ); + st->tilt_code_fx = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, st->Q_exc, 2 * L_SUBFR, 0 ); /* update LP filtered gains for the case of frame erasures */ // lp_gain_updt(i_subfr, gain_pit, norm_gain_code, &st->lp_gainp, &st->lp_gainc, L_frame); @@ -690,18 +689,21 @@ void decod_gen_2sbfr_ivas_fx( /*----------------------------------------------------------------------* * Find the total excitation *----------------------------------------------------------------------*/ + + IF(EQ_16(st->L_frame, L_FRAME)) + { + Rescale_exc(st->hMusicPF->dct_post_old_exc_fx, &exc[i_subfr], (bwe_exc != NULL) ? &bwe_exc[i_subfr * HIBND_ACB_L_FAC] : NULL, st->hGSCDec->last_exc_dct_in_fx, + L_SUBFR, L_SUBFR* HIBND_ACB_L_FAC, gain_code, &(st->Q_exc), st->Q_subfr, exc2, i_subfr, st->coder_type); + } + ELSE + { + Rescale_exc(st->hMusicPF->dct_post_old_exc_fx, &exc[i_subfr], (bwe_exc != NULL) ? &bwe_exc[i_subfr * 2] : NULL, st->hGSCDec->last_exc_dct_in_fx, + L_SUBFR, L_SUBFR * 2, gain_code, &(st->Q_exc), st->Q_subfr, exc2, i_subfr, st->coder_type); + } Word16 gain_code16 = round_fx(L_shl(gain_code, st->Q_exc)); /*Q_exc*/ - for ( i = 0; i < 2 * L_SUBFR; i++ ) - { - // exc2[i + i_subfr] = gain_pit * exc[i + i_subfr]; - Word32 L_tmp = L_shl(L_mult(gain_pit, exc[i + i_subfr]), 1); /*Q16+Q_exc*/ - exc2[i + i_subfr] = round_fx(L_tmp); /*Q_exc*/ - // exc[i + i_subfr] = exc2[i + i_subfr] + gain_code * code[i]; - L_tmp = L_add(L_tmp, L_shl(L_mult(gain_code16, code[i]), 6)); /*Q16+Q_exc*/ - exc[i + i_subfr] = round_fx(L_tmp); /*Q_exc*/ - } + Acelp_dec_total_exc(exc, exc2, gain_code16, gain_pit, i_subfr, code, L_SUBFR); /*-----------------------------------------------------------------* * Prepare TBE excitation @@ -709,7 +711,7 @@ void decod_gen_2sbfr_ivas_fx( // prep_tbe_exc(L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc, 0, NULL, T0, GENERIC, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag); // prep_tbe_exc_fx(L_frame, /*L_SUBFR,*/ i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc, 0, NULL, Q_exc, T0, T0_frac, GENERIC, st->core_brate/*, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag*/); - prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc, 0, NULL, Q_exc, T0, T0_frac, GENERIC, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag ); + prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc, 0, NULL, st->Q_exc, T0, T0_frac, GENERIC, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag ); voice_factors[i_subfr / L_SUBFR + 1] = voice_factors[i_subfr / L_SUBFR]; @@ -720,11 +722,11 @@ void decod_gen_2sbfr_ivas_fx( // enhancer(MODE1, st->core_brate, -1, 0, GENERIC, L_frame, voice_fac, st->stab_fac, norm_gain_code, gain_inov, &st->gc_threshold, code, exc2 + i_subfr, gain_pit, st->dispMem); // enhancer_fx(MODE1, st->core_brate, -1, 0, GENERIC, L_frame, voice_fac, st->stab_fac, norm_gain_code, gain_inov, &st->gc_threshold, code, exc2 + i_subfr, gain_pit, st->dispMem); - enhancer_fx( st->core_brate, 0, GENERIC, i_subfr, L_frame, voice_fac, st->stab_fac_fx, norm_gain_code, gain_inov, &st->gc_threshold_fx, code, exc2, gain_pit, &st->dm_fx, Q_exc ); + enhancer_fx( st->core_brate, 0, GENERIC, i_subfr, L_frame, voice_fac, st->stab_fac_fx, norm_gain_code, gain_inov, &st->gc_threshold_fx, code, exc2, gain_pit, &st->dm_fx, st->Q_exc); // enhancer(MODE1, st->core_brate, -1, 0, GENERIC, L_frame, voice_fac, st->stab_fac, norm_gain_code, gain_inov, &st->gc_threshold, code + L_SUBFR, exc2 + i_subfr + L_SUBFR, gain_pit, st->dispMem); // enhancer_fx(MODE1, st->core_brate, -1, 0, GENERIC, L_frame, voice_fac, st->stab_fac, norm_gain_code, gain_inov, &st->gc_threshold, code + L_SUBFR, exc2 + i_subfr + L_SUBFR, gain_pit, st->dispMem); - enhancer_fx( st->core_brate, 0, GENERIC, i_subfr, L_frame, voice_fac, st->stab_fac_fx, norm_gain_code, gain_inov, &st->gc_threshold_fx, code + L_SUBFR, exc2 + L_SUBFR, gain_pit, &st->dm_fx, Q_exc ); + enhancer_fx( st->core_brate, 0, GENERIC, i_subfr, L_frame, voice_fac, st->stab_fac_fx, norm_gain_code, gain_inov, &st->gc_threshold_fx, code + L_SUBFR, exc2 + L_SUBFR, gain_pit, &st->dm_fx, st->Q_exc); p_Aq += 2 * ( M + 1 ); diff --git a/lib_dec/lsf_dec.c b/lib_dec/lsf_dec.c index a5b791a27..d475c7292 100644 --- a/lib_dec/lsf_dec.c +++ b/lib_dec/lsf_dec.c @@ -520,15 +520,15 @@ void lsf_end_dec( Word16 pred3_fx[M]; for (int i = 0; i < M; i++) { - tdm_lsfQ_PCh_fx[i] = (tdm_lsfQ_PCh[i]) * 2.56; - pred3_fx[i] = (pred3[i]) * 2.56; + tdm_lsfQ_PCh_fx[i] = (Word16)((tdm_lsfQ_PCh[i]) * 2.56f); + pred3_fx[i] = (Word16)((pred3[i]) * 2.56f); } tdm_SCh_LSF_intra_pred_fx(st->element_brate, tdm_lsfQ_PCh_fx, pred3_fx); for (int i = 0; i < M; i++) { - pred3[i] = (pred3_fx[i]) / 2.56; + pred3[i] = (pred3_fx[i]) / 2.56f; } #else tdm_SCh_LSF_intra_pred( st->element_brate, tdm_lsfQ_PCh, pred3 ); diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 7d630efd1..b176dc455 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -309,10 +309,13 @@ typedef struct uint16_t lowerIndex[MAX_NUMBER_OF_IDX]; uint16_t upperIndex[MAX_NUMBER_OF_IDX]; - Float32 phaseDiff_float[MAX_NUMBER_OF_IDX]; /* This one can be stored with 16 bits in range 0..2*PI */ - - Float32 phase_currentFramePredicted_float[MAX_NUMBER_OF_IDX * GROUP_LENGTH]; /* This one can be stored with 16 bits in range 0..2*PI, but the code has to be adapted to use moduo(2*PI) after adding */ + Word16 phaseDiff[MAX_NUMBER_OF_IDX]; // Q12 /* This one can be stored with 16 bits in range 0..2*PI */ + + Word16 phase_currentFramePredicted[MAX_NUMBER_OF_IDX*GROUP_LENGTH]; // Q13 /* This one can be stored with 16 bits in range [-pi;pi] 2Q13, but the code has to be adapted to use moduo(2*PI) after adding */ + Float32 phaseDiff_float[MAX_NUMBER_OF_IDX]; /* This one can be stored with 16 bits in range 0..2*PI */ + + Float32 phase_currentFramePredicted_float[MAX_NUMBER_OF_IDX * GROUP_LENGTH]; /* This one can be stored with 16 bits in range 0..2*PI, but the code has to be adapted to use moduo(2*PI) after adding */ } TonalComponentsInfo_float; typedef struct @@ -390,8 +393,8 @@ typedef struct tonalmdctconceal #if 0 //Memory ovelap issue #endif - TonalComponentsInfo_float *pTCI_float; - TonalComponentsInfo_fix *pTCI_fix; + TonalComponentsInfo_float *pTCI_float; + TonalComponentsInfo_float pTCI_float1; } TonalMDCTConceal_INSTANCE, *TonalMDCTConcealPtr; @@ -1127,7 +1130,9 @@ typedef struct hq_nbfec_structure typedef struct hq_dec_structure { +#ifndef IVAS_DISABLE float old_out[L_FRAME48k]; /* HQ core - previous synthesis for OLA */ +#endif #ifdef IVAS_FLOAT_FIXED Word32 oldOut_fx[L_FRAME48k]; /* HQ core - previous synthesis for OLA */ #endif @@ -1163,14 +1168,18 @@ typedef struct hq_dec_structure //int16_t no_att_hangover; Word16 no_att_hangover; /* Q0 */ - + +#ifndef IVAS_DISABLE float energy_lt; +#endif Word32 energy_lt_fx; /* Q13 */ //int16_t hq_generic_seed; Word16 hq_generic_seed; +#ifndef IVAS_DISABLE float prev_noise_level[2]; +#endif Word16 prev_noise_level_fx[2]; /* Q15 */ //int16_t prev_hqswb_clas; @@ -1178,9 +1187,11 @@ typedef struct hq_dec_structure //int16_t prev_R; /* the table of bit allocation of last frame */ Word16 prev_R; /* the table of bit allocation of last frame */ - + +#ifndef IVAS_DISABLE float prev_coeff_out[L_HQ_WB_BWE]; /* the highest coefficients of last frame */ - int16_t prev_SWB_peak_pos[SPT_SHORTEN_SBNUM]; +#endif + int16_t prev_SWB_peak_pos[SPT_SHORTEN_SBNUM]; Word32 prev_coeff_out_fx[L_HQ_WB_BWE]; /* Q12 */ /* the coefficients of last frame */ Word16 prev_SWB_peak_pos_fx[SPT_SHORTEN_SBNUM]; @@ -1431,7 +1442,7 @@ typedef struct td_bwe_dec_structure Word16 state_32and48k_WB_upsample_fx[2 * ALLPASSSECTIONS_STEEP]; /* !!! this memory in FLP is called mem_resamp_HB */ float prev_pow_exc16kWhtnd; /* power of the LB excitation signal in the previous frame */ - Word16 prev_pow_exc16kWhtnd_fx; /* power of the LB excitation signal in the previous frame */ + //Word16 prev_pow_exc16kWhtnd_fx; /* power of the LB excitation signal in the previous frame */ - Don't use this Word32 prev_pow_exc16kWhtnd_fx32; /* power of the LB excitation signal in the previous frame */ float prev_mix_factor; /* mixing factor in the previous frame */ Word16 prev_mix_factor_fx; /* mixing factor in the previous frame */ @@ -1919,7 +1930,7 @@ typedef struct Decoder_State float log_energy_old; #ifdef IVAS_FLOAT_FIXED Word32 log_energy_diff_lt_fx;/*In range of word16*//*Q-15*/ - Word32 stab_fac_smooth_lt_fx;/*In range of word16*//*Q-15*/ + Word16 stab_fac_smooth_lt_fx;/*In range of word16*//*Q-15*/ Word32 log_energy_old_fx; #endif float log_energy_diff_lt; @@ -1993,7 +2004,6 @@ typedef struct Decoder_State //Word16 seed_fx; /* FEC - seed for random generator for excitation Q0*/ float lp_ener_bfi; /* FEC - long-term active-signal average energy */ - Word16 lp_ener_bfi_fx; /* FEC - long-term active-signal average energy */ int16_t last_good; /* FEC - clas of last good received */ @@ -2416,7 +2426,9 @@ typedef struct Decoder_State int16_t last_is_cng; +#ifndef IVAS_FLOAT_FIXED float *acelp_zir; +#endif // !IVAS_FLOAT_FIXED float syn_float[M + 1]; Word16 syn[M + 1]; diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index 085e52221..f5f679035 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -385,7 +385,7 @@ Word16 ivas_wb_bwe_dec_fx( { /* IVAS_fmToDo: wtda() does not support L_FRAME length; thus temporarily resample the signal */ /* IVAS_fmToDo: delay output[] by 1.25ms ? */ - lerp( output, ysynth_fx, L_FRAME16k, st_fx->L_frame ); + lerp( (Word16 *)output, ysynth_fx, L_FRAME16k, st_fx->L_frame ); wtda_fx( ysynth_fx, &new_input_fx_exp, L_wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx, &hBWE_FD->old_wtda_swb_fx_exp, ALDO_WINDOW, ALDO_WINDOW, /*st->L_frame*/ L_FRAME16k ); *Qpost = sub( new_input_fx_exp, 15 ); diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c index a9df85450..dacab808e 100644 --- a/lib_dec/swb_tbe_dec.c +++ b/lib_dec/swb_tbe_dec.c @@ -1094,7 +1094,7 @@ void ivas_swb_tbe_dec_fx( /* find tilt */ calc_tilt_bwe_fx_loc( old_syn_12k8_16k_fx, &tilt_swb_fec_32_fx, &tilt_swb_fec_fx_q, L_FRAME ); - tilt_swb_fec_fx = L_shr( tilt_swb_fec_32_fx, ( tilt_swb_fec_fx_q - 11 ) ); + tilt_swb_fec_fx = extract_l(L_shr( tilt_swb_fec_32_fx, ( tilt_swb_fec_fx_q - 11 ) )); IF( st->bfi && st->clas_dec != UNVOICED_CLAS ) { @@ -1615,7 +1615,7 @@ void ivas_swb_tbe_dec_fx( IF( st->extl_brate == SWB_TBE_1k10 || st->extl_brate == SWB_TBE_1k75 ) { Word32 vind_temp = ( L_add( mixFactors_fx, 1 ) * ( ( 1 << NUM_BITS_SHB_VF ) - 1 ) ); // check addition of 1 - vind = L_shr( vind_temp, 15 ); /* 3 for mpy by 8.0f, -15 to bring it to Q0 */ /*mixFactors*7*/ + vind = extract_l(L_shr( vind_temp, 15 )); /* 3 for mpy by 8.0f, -15 to bring it to Q0 */ /*mixFactors*7*/ /* i: mixFactors_fx in Q15 */ /* o: vind in Q0 */ } diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index f7a9fac44..3d3e1c1c6 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -4868,8 +4868,8 @@ void TBEreset_dec_ivas_fx( set16_fx( st->GainShape_Delay, 0, NUM_SHB_SUBFR / 2 ); set16_fx( hBWE_TD->int_3_over_2_tbemem_dec_fx, 0, INTERP_3_2_MEM_LEN ); set16_fx( hBWE_TD->mem_resamp_HB_32k_fx, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); - hBWE_TD->prev_pow_exc16kWhtnd_fx = 32767; /*Q15 1.f*/ - hBWE_TD->prev_mix_factor_fx = 32767; /*Q15 1.f */ + hBWE_TD->prev_pow_exc16kWhtnd_fx32 = 1; /* Q0 1.f */ + hBWE_TD->prev_mix_factor_fx = 32767; /* Q15 1.f */ swb_tbe_reset_synth_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx ); diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index c5879539b..be2aace7d 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -84,7 +84,7 @@ ivas_error TonalMDCTConceal_Init( hTonalMDCTConc->secondLastBlockData.blockIsConcealed = 0; move16(); - hTonalMDCTConc->pTCI_fix = (TonalComponentsInfo_fix *)hTonalMDCTConc->timeDataBuffer; + //hTonalMDCTConc->pTCI_fix = (TonalComponentsInfo_fix *)hTonalMDCTConc->timeDataBuffer; move16(); @@ -117,7 +117,7 @@ ivas_error TonalMDCTConceal_Init( hTonalMDCTConc->faded_signal_nrg_flt = 0.0f; #endif - /* Offset the pointer to the end of buffer, so that pTCI_fix is not destroyed when + /* Offset the pointer to the end of buffer, so that pTCI_float is not destroyed when new time samples are stored in lastPcmOut */ move16(); move16(); /* just the second half of the second last pcm output is needed */ @@ -127,7 +127,7 @@ ivas_error TonalMDCTConceal_Init( /* If the second last frame was lost, we reuse saved TonalComponentsInfo and don't update pcm buffers */ #if 1 //TO do enable when only fix code is present currently disabled due to float array in structure - assert(sizeof(*hTonalMDCTConc->pTCI_fix) <= (hTonalMDCTConc->lastPcmOut-hTonalMDCTConc->timeDataBuffer)*sizeof(hTonalMDCTConc->timeDataBuffer[0])); + //assert(sizeof(*hTonalMDCTConc->pTCI_float) <= (hTonalMDCTConc->lastPcmOut-hTonalMDCTConc->timeDataBuffer)*sizeof(hTonalMDCTConc->timeDataBuffer[0])); #endif return IVAS_ERR_OK; } @@ -178,7 +178,10 @@ ivas_error TonalMDCTConceal_Init_ivas_fx( move16(); hTonalMDCTConc->secondLastBlockData.blockIsConcealed = 0; move16(); - hTonalMDCTConc->pTCI_fix = (TonalComponentsInfo_fix *) hTonalMDCTConc->timeDataBuffer; + //hTonalMDCTConc->pTCI_float = (TonalComponentsInfo_fix *) hTonalMDCTConc->timeDataBuffer; + + //hTonalMDCTConc->pTCI_float = &hTonalMDCTConc->pTCI_fix1; + move16(); hTonalMDCTConc->lastPitchLag = L_deposit_l( 0 ); @@ -218,7 +221,7 @@ ivas_error TonalMDCTConceal_Init_ivas_fx( hTonalMDCTConc->faded_signal_nrg_exp = 0; move16(); - /* Offset the pointer to the end of buffer, so that pTCI_fix is not destroyed when + /* Offset the pointer to the end of buffer, so that pTCI_float is not destroyed when new time samples are stored in lastPcmOut */ move16(); move16(); @@ -228,7 +231,7 @@ ivas_error TonalMDCTConceal_Init_ivas_fx( /* If the second last frame was lost, we reuse saved TonalComponentsInfo and don't update pcm buffers */ #if 1 // TO do enable when only fix code is present currently disabled due to float array in structure - assert( sizeof( *hTonalMDCTConc->pTCI_fix ) <= ( hTonalMDCTConc->lastPcmOut - hTonalMDCTConc->timeDataBuffer ) * sizeof( hTonalMDCTConc->timeDataBuffer[0] ) ); + //assert( sizeof( *hTonalMDCTConc->pTCI_float ) <= ( hTonalMDCTConc->lastPcmOut - hTonalMDCTConc->timeDataBuffer ) * sizeof( hTonalMDCTConc->timeDataBuffer[0] ) ); /* TODO: remove float code*/ assert( sizeof( *hTonalMDCTConc->pTCI_float ) <= ( hTonalMDCTConc->lastPcmOut_float - hTonalMDCTConc->timeDataBuffer_float ) * sizeof( hTonalMDCTConc->timeDataBuffer_float[0] ) ); @@ -612,11 +615,11 @@ static void FindPhases( /* o: currenc phase [-p - pCurrentPhase = hTonalMDCTConc->pTCI_fix->phase_currentFramePredicted; + pCurrentPhase = hTonalMDCTConc->pTCI_float->phase_currentFramePredicted; /* for each index/index group */ - FOR( i = 0; i < hTonalMDCTConc->pTCI_fix->numIndexes; i++) + FOR( i = 0; i < hTonalMDCTConc->pTCI_float->numIndexes; i++) { - FOR (l = hTonalMDCTConc->pTCI_fix->lowerIndex[i]; l <= hTonalMDCTConc->pTCI_fix->upperIndex[i]; l++) + FOR (l = hTonalMDCTConc->pTCI_float->lowerIndex[i]; l <= hTonalMDCTConc->pTCI_float->upperIndex[i]; l++) { /* in contrast to the float code, the parameter secondLastMDST[l] needs not to be negated - due to a different implementation of @@ -651,16 +654,16 @@ static void FindPhaseDifferences( /* o: Phase j = J; move16(); - phaseDiff = hTonalMDCTConc->pTCI_fix->phaseDiff; + phaseDiff = hTonalMDCTConc->pTCI_float->phaseDiff; - FOR (i = 0; i < hTonalMDCTConc->pTCI_fix->numIndexes; i++) + FOR (i = 0; i < hTonalMDCTConc->pTCI_float->numIndexes; i++) { m = MM; move16(); n = N; move16(); - k = hTonalMDCTConc->pTCI_fix->indexOfTonalPeak[i]; + k = hTonalMDCTConc->pTCI_float->indexOfTonalPeak[i]; move16(); IF (GE_32(Mpy_32_16_1(powerSpectrum[k-1],512/*1.0f Q9*/),Mpy_32_16_1(powerSpectrum[k+1], MAXRATIO))) @@ -792,10 +795,10 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( set32_fx(powerSpectrum+hTonalMDCTConc->nSamples, 0, sub(hTonalMDCTConc->nSamplesCore, hTonalMDCTConc->nSamples)); } - //DetectTonalComponents(hTonalMDCTConc->pTCI_fix->indexOfTonalPeak, - // hTonalMDCTConc->pTCI_fix->lowerIndex, - // hTonalMDCTConc->pTCI_fix->upperIndex, - // &hTonalMDCTConc->pTCI_fix->numIndexes, + //DetectTonalComponents(hTonalMDCTConc->pTCI_float->indexOfTonalPeak, + // hTonalMDCTConc->pTCI_float->lowerIndex, + // hTonalMDCTConc->pTCI_float->upperIndex, + // &hTonalMDCTConc->pTCI_float->numIndexes, // hTonalMDCTConc->lastPitchLag, // pitchLag, // hTonalMDCTConc->lastBlockData.spectralData, @@ -808,10 +811,10 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( // hTonalMDCTConc->nSamplesCore, // floorPowerSpectrum); - ivas_DetectTonalComponents_fx(hTonalMDCTConc->pTCI_fix->indexOfTonalPeak, - hTonalMDCTConc->pTCI_fix->lowerIndex, - hTonalMDCTConc->pTCI_fix->upperIndex, - &hTonalMDCTConc->pTCI_fix->numIndexes, + ivas_DetectTonalComponents_fx(hTonalMDCTConc->pTCI_float->indexOfTonalPeak, + hTonalMDCTConc->pTCI_float->lowerIndex, + hTonalMDCTConc->pTCI_float->upperIndex, + &hTonalMDCTConc->pTCI_float->numIndexes, hTonalMDCTConc->lastPitchLag, pitchLag, hTonalMDCTConc->lastBlockData.spectralData, @@ -827,7 +830,7 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( FindPhaseDifferences(hTonalMDCTConc, powerSpectrum); - IF (hTonalMDCTConc->pTCI_fix->numIndexes > 0) + IF (hTonalMDCTConc->pTCI_float->numIndexes > 0) { hTonalMDCTConc->secondLastPowerSpectrum = hTonalMDCTConc->secondLastBlockData.spectralData; @@ -942,10 +945,10 @@ static void CalcPowerSpecAndDetectTonalComponents( set32_fx(powerSpectrum+hTonalMDCTConc->nSamples, 0, sub(hTonalMDCTConc->nSamplesCore, hTonalMDCTConc->nSamples)); } - DetectTonalComponents(hTonalMDCTConc->pTCI_fix->indexOfTonalPeak, - hTonalMDCTConc->pTCI_fix->lowerIndex, - hTonalMDCTConc->pTCI_fix->upperIndex, - &hTonalMDCTConc->pTCI_fix->numIndexes, + DetectTonalComponents(hTonalMDCTConc->pTCI_float->indexOfTonalPeak, + hTonalMDCTConc->pTCI_float->lowerIndex, + hTonalMDCTConc->pTCI_float->upperIndex, + &hTonalMDCTConc->pTCI_float->numIndexes, hTonalMDCTConc->lastPitchLag, pitchLag, hTonalMDCTConc->lastBlockData.spectralData, @@ -961,7 +964,7 @@ static void CalcPowerSpecAndDetectTonalComponents( FindPhaseDifferences(hTonalMDCTConc, powerSpectrum); - IF (hTonalMDCTConc->pTCI_fix->numIndexes > 0) + IF (hTonalMDCTConc->pTCI_float->numIndexes > 0) { hTonalMDCTConc->secondLastPowerSpectrum = hTonalMDCTConc->secondLastBlockData.spectralData; @@ -1163,12 +1166,12 @@ void TonalMDCTConceal_Detect( move32(); } - RefineTonalComponents(hTonalMDCTConc->pTCI_fix->indexOfTonalPeak, - hTonalMDCTConc->pTCI_fix->lowerIndex, - hTonalMDCTConc->pTCI_fix->upperIndex, - hTonalMDCTConc->pTCI_fix->phaseDiff, - hTonalMDCTConc->pTCI_fix->phase_currentFramePredicted, - &hTonalMDCTConc->pTCI_fix->numIndexes, + RefineTonalComponents(hTonalMDCTConc->pTCI_float->indexOfTonalPeak, + hTonalMDCTConc->pTCI_float->lowerIndex, + hTonalMDCTConc->pTCI_float->upperIndex, + hTonalMDCTConc->pTCI_float->phaseDiff, + hTonalMDCTConc->pTCI_float->phase_currentFramePredicted, + &hTonalMDCTConc->pTCI_float->numIndexes, hTonalMDCTConc->lastPitchLag, pitchLag, hTonalMDCTConc->lastBlockData.spectralData, @@ -1186,11 +1189,11 @@ void TonalMDCTConceal_Detect( } ELSE { - hTonalMDCTConc->pTCI_fix->numIndexes = 0; + hTonalMDCTConc->pTCI_float->numIndexes = 0; move16(); } - *numIndices = hTonalMDCTConc->pTCI_fix->numIndexes; + *numIndices = hTonalMDCTConc->pTCI_float->numIndexes; move16(); @@ -1306,12 +1309,12 @@ void TonalMDCTConceal_Detect_ivas_fx( move32(); } - RefineTonalComponents(hTonalMDCTConc->pTCI_fix->indexOfTonalPeak, - hTonalMDCTConc->pTCI_fix->lowerIndex, - hTonalMDCTConc->pTCI_fix->upperIndex, - hTonalMDCTConc->pTCI_fix->phaseDiff, - hTonalMDCTConc->pTCI_fix->phase_currentFramePredicted, - &hTonalMDCTConc->pTCI_fix->numIndexes, + RefineTonalComponents(hTonalMDCTConc->pTCI_float->indexOfTonalPeak, + hTonalMDCTConc->pTCI_float->lowerIndex, + hTonalMDCTConc->pTCI_float->upperIndex, + hTonalMDCTConc->pTCI_float->phaseDiff, + hTonalMDCTConc->pTCI_float->phase_currentFramePredicted, + &hTonalMDCTConc->pTCI_float->numIndexes, hTonalMDCTConc->lastPitchLag, pitchLag, hTonalMDCTConc->lastBlockData.spectralData, @@ -1329,11 +1332,11 @@ void TonalMDCTConceal_Detect_ivas_fx( } ELSE { - hTonalMDCTConc->pTCI_fix->numIndexes = 0; + hTonalMDCTConc->pTCI_float->numIndexes = 0; move16(); } - *numIndices = hTonalMDCTConc->pTCI_fix->numIndexes; + *numIndices = hTonalMDCTConc->pTCI_float->numIndexes; move16(); @@ -2178,15 +2181,15 @@ void TonalMDCTConceal_InsertNoise( } else { - assert(hTonalMDCTConc->pTCI_fix->numIndexes > 0); + assert(hTonalMDCTConc->pTCI_float->numIndexes > 0); /* initialize bins of tonal components with zero: basically not necessary, but currently the whole spectrum is rescaled in mdct_noiseShaping() and then there would be a processing of uninitialized values */ - for (i = 0; i < hTonalMDCTConc->pTCI_fix->numIndexes; i++) + for (i = 0; i < hTonalMDCTConc->pTCI_float->numIndexes; i++) { - for (l = hTonalMDCTConc->pTCI_fix->lowerIndex[i]; l <= hTonalMDCTConc->pTCI_fix->upperIndex[i]; l++) + for (l = hTonalMDCTConc->pTCI_float->lowerIndex[i]; l <= hTonalMDCTConc->pTCI_float->upperIndex[i]; l++) { mdctSpectrum[l] = 0; if (l < crossOverFreq) @@ -2200,7 +2203,7 @@ void TonalMDCTConceal_InsertNoise( /* if fadeout has not started yet, only apply sign scrambling */ if (crossfadeGain == 1.0f) { - for (l = 0; l < hTonalMDCTConc->pTCI_fix->lowerIndex[0]; l++) + for (l = 0; l < hTonalMDCTConc->pTCI_float->lowerIndex[0]; l++) { if (concealment_noise[l] > 0) { @@ -2211,9 +2214,9 @@ void TonalMDCTConceal_InsertNoise( mdctSpectrum[l] = -hTonalMDCTConc->lastBlockData.spectralData[l]; } } - for (i = 1; i < hTonalMDCTConc->pTCI_fix->numIndexes; i++) + for (i = 1; i < hTonalMDCTConc->pTCI_float->numIndexes; i++) { - for (l = hTonalMDCTConc->pTCI_fix->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI_fix->lowerIndex[i]; l++) + for (l = hTonalMDCTConc->pTCI_float->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI_float->lowerIndex[i]; l++) { if (concealment_noise[l] > 0) { @@ -2226,7 +2229,7 @@ void TonalMDCTConceal_InsertNoise( } } - for (l = hTonalMDCTConc->pTCI_fix->upperIndex[hTonalMDCTConc->pTCI_fix->numIndexes - 1] + 1; l < crossOverFreq; l++) + for (l = hTonalMDCTConc->pTCI_float->upperIndex[hTonalMDCTConc->pTCI_float->numIndexes - 1] + 1; l < crossOverFreq; l++) { if (concealment_noise[l] > 0) { @@ -2248,7 +2251,7 @@ void TonalMDCTConceal_InsertNoise( { g *= (float)sqrt(cngLevelBackgroundTrace_bfi / hTonalMDCTConc->curr_noise_nrg_flt); - for (l = 0; l < hTonalMDCTConc->pTCI_fix->lowerIndex[0]; l++) + for (l = 0; l < hTonalMDCTConc->pTCI_float->lowerIndex[0]; l++) { x = hTonalMDCTConc->lastBlockData.spectralData[l]; y = concealment_noise[l]; @@ -2263,9 +2266,9 @@ void TonalMDCTConceal_InsertNoise( } hTonalMDCTConc->faded_signal_nrg_flt += mdctSpectrum[l] * mdctSpectrum[l]; } - for (i = 1; i < hTonalMDCTConc->pTCI_fix->numIndexes; i++) + for (i = 1; i < hTonalMDCTConc->pTCI_float->numIndexes; i++) { - for (l = hTonalMDCTConc->pTCI_fix->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI_fix->lowerIndex[i]; l++) + for (l = hTonalMDCTConc->pTCI_float->upperIndex[i - 1] + 1; l < hTonalMDCTConc->pTCI_float->lowerIndex[i]; l++) { x = hTonalMDCTConc->lastBlockData.spectralData[l]; y = concealment_noise[l]; @@ -2282,7 +2285,7 @@ void TonalMDCTConceal_InsertNoise( } } - for (l = hTonalMDCTConc->pTCI_fix->upperIndex[hTonalMDCTConc->pTCI_fix->numIndexes - 1] + 1; l < crossOverFreq; l++) + for (l = hTonalMDCTConc->pTCI_float->upperIndex[hTonalMDCTConc->pTCI_float->numIndexes - 1] + 1; l < crossOverFreq; l++) { x = hTonalMDCTConc->lastBlockData.spectralData[l]; y = concealment_noise[l]; @@ -2442,16 +2445,16 @@ void TonalMDCTConceal_InsertNoise( ELSE { Word16 l; - assert(hTonalMDCTConc->pTCI_fix->numIndexes > 0); + assert(hTonalMDCTConc->pTCI_float->numIndexes > 0); - FOR (l = hTonalMDCTConc->pTCI_fix->lowerIndex[0]; l <= hTonalMDCTConc->pTCI_fix->upperIndex[0]; l++) + FOR (l = hTonalMDCTConc->pTCI_float->lowerIndex[0]; l <= hTonalMDCTConc->pTCI_float->upperIndex[0]; l++) { mdctSpectrum[l] = L_deposit_l(0); } ld = sub(14,norm_s(hTonalMDCTConc->lastBlockData.nSamples)); fac = shr(-32768,ld); - FOR (l = 0; l < hTonalMDCTConc->pTCI_fix->lowerIndex[0]; l++) + FOR (l = 0; l < hTonalMDCTConc->pTCI_float->lowerIndex[0]; l++) { Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; Word32 y; @@ -2467,19 +2470,19 @@ void TonalMDCTConceal_InsertNoise( tilt = mult_r(tilt,tiltFactor); } - FOR (i = 1; i < hTonalMDCTConc->pTCI_fix->numIndexes; i++) + FOR (i = 1; i < hTonalMDCTConc->pTCI_float->numIndexes; i++) { - /*tilt *= (float)pow(tiltFactor, hTonalMDCTConc->pTCI_fix->upperIndex[i-1]-hTonalMDCTConc->pTCI_fix->lowerIndex[i-1]+1);*/ - tmp= round_fx(BASOP_Util_fPow(L_deposit_h(tiltFactor), 0, L_deposit_h(hTonalMDCTConc->pTCI_fix->upperIndex[i-1]-hTonalMDCTConc->pTCI_fix->lowerIndex[i-1]+1),15, &exp)); + /*tilt *= (float)pow(tiltFactor, hTonalMDCTConc->pTCI_float->upperIndex[i-1]-hTonalMDCTConc->pTCI_float->lowerIndex[i-1]+1);*/ + tmp= round_fx(BASOP_Util_fPow(L_deposit_h(tiltFactor), 0, L_deposit_h(hTonalMDCTConc->pTCI_float->upperIndex[i-1]-hTonalMDCTConc->pTCI_float->lowerIndex[i-1]+1),15, &exp)); tmp = shl(tmp, exp); tilt = mult_r(tilt,tmp); - FOR (l = hTonalMDCTConc->pTCI_fix->lowerIndex[i]; l <= hTonalMDCTConc->pTCI_fix->upperIndex[i]; l++) + FOR (l = hTonalMDCTConc->pTCI_float->lowerIndex[i]; l <= hTonalMDCTConc->pTCI_float->upperIndex[i]; l++) { mdctSpectrum[l] = L_deposit_l(0); } - FOR (l = hTonalMDCTConc->pTCI_fix->upperIndex[i-1]+1; l < hTonalMDCTConc->pTCI_fix->lowerIndex[i]; l++) + FOR (l = hTonalMDCTConc->pTCI_float->upperIndex[i-1]+1; l < hTonalMDCTConc->pTCI_float->lowerIndex[i]; l++) { Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; Word32 y; @@ -2496,13 +2499,13 @@ void TonalMDCTConceal_InsertNoise( } } - tmp = round_fx(BASOP_Util_fPow(L_deposit_h(tiltFactor), 0, L_deposit_h(hTonalMDCTConc->pTCI_fix->upperIndex[hTonalMDCTConc->pTCI_fix->numIndexes-1]-hTonalMDCTConc->pTCI_fix->lowerIndex[hTonalMDCTConc->pTCI_fix->numIndexes-1]+1),15, &exp)); + tmp = round_fx(BASOP_Util_fPow(L_deposit_h(tiltFactor), 0, L_deposit_h(hTonalMDCTConc->pTCI_float->upperIndex[hTonalMDCTConc->pTCI_float->numIndexes-1]-hTonalMDCTConc->pTCI_float->lowerIndex[hTonalMDCTConc->pTCI_float->numIndexes-1]+1),15, &exp)); BASOP_SATURATE_WARNING_OFF_EVS /*next op may result in 32768*/ tmp = shl(tmp, exp); BASOP_SATURATE_WARNING_ON_EVS tilt = mult_r(tilt,tmp); - FOR (l = add(hTonalMDCTConc->pTCI_fix->upperIndex[hTonalMDCTConc->pTCI_fix->numIndexes-1], 1); l < crossOverFreq; l++) + FOR (l = add(hTonalMDCTConc->pTCI_float->upperIndex[hTonalMDCTConc->pTCI_float->numIndexes-1], 1); l < crossOverFreq; l++) { Word16 x = hTonalMDCTConc->lastBlockData.spectralData[l]; Word32 y; @@ -2572,7 +2575,7 @@ void TonalMDCTConceal_InsertNoise( exp = 0; } - FOR (l = 0; l < hTonalMDCTConc->pTCI_fix->lowerIndex[0]; l++) + FOR (l = 0; l < hTonalMDCTConc->pTCI_float->lowerIndex[0]; l++) { Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[l]; Word32 const y = mdctSpectrum[l]; @@ -2591,9 +2594,9 @@ void TonalMDCTConceal_InsertNoise( move32(); } - FOR (i = 1; i < hTonalMDCTConc->pTCI_fix->numIndexes; i++) + FOR (i = 1; i < hTonalMDCTConc->pTCI_float->numIndexes; i++) { - FOR (l = hTonalMDCTConc->pTCI_fix->upperIndex[i-1]+1; l < hTonalMDCTConc->pTCI_fix->lowerIndex[i]; l++) + FOR (l = hTonalMDCTConc->pTCI_float->upperIndex[i-1]+1; l < hTonalMDCTConc->pTCI_float->lowerIndex[i]; l++) { Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[l]; Word32 const y = mdctSpectrum[l]; @@ -2617,15 +2620,15 @@ void TonalMDCTConceal_InsertNoise( necessary, but currently the whole spectrum is rescaled in mdct_noiseShaping() and then there would be a processing of uninitialized values */ - FOR (i = 0; i < hTonalMDCTConc->pTCI_fix->numIndexes; i++) + FOR (i = 0; i < hTonalMDCTConc->pTCI_float->numIndexes; i++) { - FOR (l = hTonalMDCTConc->pTCI_fix->lowerIndex[i]; l <= hTonalMDCTConc->pTCI_fix->upperIndex[i]; l++) + FOR (l = hTonalMDCTConc->pTCI_float->lowerIndex[i]; l <= hTonalMDCTConc->pTCI_float->upperIndex[i]; l++) { mdctSpectrum[l] = L_deposit_l(0); } } - FOR (l = add(hTonalMDCTConc->pTCI_fix->upperIndex[hTonalMDCTConc->pTCI_fix->numIndexes-1], 1); l < crossOverFreq; l++) + FOR (l = add(hTonalMDCTConc->pTCI_float->upperIndex[hTonalMDCTConc->pTCI_float->numIndexes-1], 1); l < crossOverFreq; l++) { Word16 const x = hTonalMDCTConc->lastBlockData.spectralData[l]; Word32 const y = mdctSpectrum[l]; @@ -2678,11 +2681,11 @@ void TonalMDCTConceal_Apply( IF (hTonalMDCTConc->lastBlockData.blockIsValid & hTonalMDCTConc->secondLastBlockData.blockIsValid) { - assert(hTonalMDCTConc->pTCI_fix->numIndexes > 0); + assert(hTonalMDCTConc->pTCI_float->numIndexes > 0); nSamples = hTonalMDCTConc->nNonZeroSamples; move16(); - assert(hTonalMDCTConc->pTCI_fix->upperIndex[hTonalMDCTConc->pTCI_fix->numIndexes-1] < nSamples); + assert(hTonalMDCTConc->pTCI_float->upperIndex[hTonalMDCTConc->pTCI_float->numIndexes-1] < nSamples); #ifdef IVAS_CODE_MDCT_GSHAPE IF (psychParamsCurrent == NULL) @@ -2701,8 +2704,8 @@ void TonalMDCTConceal_Apply( } #endif - phaseDiff = hTonalMDCTConc->pTCI_fix->phaseDiff; /* if multiple frame loss occurs use the phase from the last frame and continue rotating */ - pCurrentPhase = hTonalMDCTConc->pTCI_fix->phase_currentFramePredicted; + phaseDiff = hTonalMDCTConc->pTCI_float->phaseDiff; /* if multiple frame loss occurs use the phase from the last frame and continue rotating */ + pCurrentPhase = hTonalMDCTConc->pTCI_float->phase_currentFramePredicted; exp = sub(*mdctSpectrum_exp, add(add(hTonalMDCTConc->secondLastPowerSpectrum_exp, add(hTonalMDCTConc->secondLastBlockData.gain_tcx_exp,1)),hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e)); @@ -2718,7 +2721,7 @@ void TonalMDCTConceal_Apply( } } /* for each index group */ - FOR (i = 0; i < hTonalMDCTConc->pTCI_fix->numIndexes; i++) + FOR (i = 0; i < hTonalMDCTConc->pTCI_float->numIndexes; i++) { /*phaseToAdd = hTonalMDCTConc->nFramesLost*phaseDiff[i]; */ phaseToAdd = L_mult0(hTonalMDCTConc->nFramesLost,phaseDiff[i]); /*Q1*3Q12=2Q13*/ @@ -2733,7 +2736,7 @@ void TonalMDCTConceal_Apply( phaseToAdd = L_add(phaseToAdd, 51472l/*2*EVS_PI Q13*/); } - FOR (l = hTonalMDCTConc->pTCI_fix->lowerIndex[i]; l <= hTonalMDCTConc->pTCI_fix->upperIndex[i]; l++) + FOR (l = hTonalMDCTConc->pTCI_float->lowerIndex[i]; l <= hTonalMDCTConc->pTCI_float->upperIndex[i]; l++) { /* *pCurrentPhase and phaseToAdd are in range -PI..PI */ currentPhase = L_mac0(phaseToAdd, (*pCurrentPhase++), 1); /*2Q13+2Q13=3Q13*/ @@ -2767,7 +2770,7 @@ void TonalMDCTConceal_Apply_ivas_fx( const PsychoacousticParameters *psychParamsCurrent ) { - /* TODO: change pTCI_float to pTCI_fix in this function. */ + /* TODO: change pTCI_float to pTCI_float in this function. */ Word16 i, l; Word16 *phaseDiff, *pCurrentPhase; @@ -2874,8 +2877,8 @@ void TonalMDCTConceal_Apply_ivas_fx( powerSpectrum_exp = max_e; move16(); - phaseDiff = hTonalMDCTConc->pTCI_fix->phaseDiff; /* if multiple frame loss occurs use the phase from the last frame and continue rotating */ - pCurrentPhase = hTonalMDCTConc->pTCI_fix->phase_currentFramePredicted; + phaseDiff = hTonalMDCTConc->pTCI_float->phaseDiff; /* if multiple frame loss occurs use the phase from the last frame and continue rotating */ + pCurrentPhase = hTonalMDCTConc->pTCI_float->phase_currentFramePredicted; IF(!hTonalMDCTConc->lastBlockData.blockIsConcealed) { @@ -3061,7 +3064,7 @@ void TonalMdctConceal_create_concealment_noise( max_noise_line = crossOverFreq; if (st->tonal_mdct_plc_active) { - max_noise_line = max(max_noise_line, hTonalMDCTConc->pTCI_fix->upperIndex[hTonalMDCTConc->pTCI_fix->numIndexes - 1] + 1); + max_noise_line = max(max_noise_line, hTonalMDCTConc->pTCI_float->upperIndex[hTonalMDCTConc->pTCI_float->numIndexes - 1] + 1); } /* first lost frame is handled separately */ @@ -3143,7 +3146,7 @@ void TonalMdctConceal_create_concealment_noise( } if (st->tonal_mdct_plc_active) { - for (i = crossOverFreq; i < max(crossOverFreq, hTonalMDCTConc->pTCI_fix->lowerIndex[hTonalMDCTConc->pTCI_fix->numIndexes - 1]); ++i) + for (i = crossOverFreq; i < max(crossOverFreq, hTonalMDCTConc->pTCI_float->lowerIndex[hTonalMDCTConc->pTCI_float->numIndexes - 1]); ++i) { concealment_noise[i] *= 0.0f; } diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index 49b7eed64..049dca937 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -794,7 +794,7 @@ static void ivas_updt_bw_switching_fx( return; } -static Word32 sum_32_32_fx(Word32 *x, Word16 length) +static Word32 sum_32_32_fx(const Word32 *x, Word16 length) { Word64 sum = 0; Word16 i; @@ -968,14 +968,14 @@ void ivas_updt_dec_common_fx( st_fx->log_energy_diff_lt = fixedToFloat(st_fx->log_energy_diff_lt_fx, Q15); if (st_fx->core == HQ_CORE) { - st_fx->stab_fac_fx = extract_l(L_min(MAX_16, L_shr(L_add(STAB_FAC_EST1_FX, Madd_32_16(Mpy_32_16_1(STAB_FAC_EST2_FX , st_fx->hHQ_core->mem_env_delta), STAB_FAC_EST3_FX, st_fx->log_energy_diff_lt_fx)), Q15))); + st_fx->stab_fac_fx = extract_l(L_min(MAX_16, L_add(L_shr(STAB_FAC_EST1_FX, Q15), Madd_32_32(L_shr(Mpy_32_16_1(STAB_FAC_EST2_FX , st_fx->hHQ_core->mem_env_delta), Q15), STAB_FAC_EST3_FX, st_fx->log_energy_diff_lt_fx)))); st_fx->stab_fac_fx = s_max(0, st_fx->stab_fac_fx); } - st_fx->stab_fac_smooth_lt_fx = L_add(L_mult(ENV_SMOOTH_FAC_FX , st_fx->stab_fac_fx), - L_mult(sub(MAX_16, ENV_SMOOTH_FAC_FX) , st_fx->stab_fac_smooth_lt_fx)); + st_fx->stab_fac_smooth_lt_fx = extract_h(L_add(L_mult(ENV_SMOOTH_FAC_FX , st_fx->stab_fac_fx), + L_mult(sub(MAX_16, ENV_SMOOTH_FAC_FX) , st_fx->stab_fac_smooth_lt_fx))); //To be deleted - st_fx->stab_fac_smooth_lt = fixedToFloat(st_fx->stab_fac_smooth_lt_fx, Q31); + st_fx->stab_fac_smooth_lt = fixedToFloat(st_fx->stab_fac_smooth_lt_fx, Q15); } #endif IF( ((LE_32(st_fx->core_brate,SID_2k40))&&EQ_16(st_fx->cng_type,FD_CNG)) diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index e613c9096..be8ab41ae 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -587,7 +587,7 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx( /* check while condition */ /* MSBs coding */ - lookup = &ari_lookup_s17_LC[t] + (1 << (NBITS_CONTEXT+NBITS_RATEQ)); /* address calculation not counted */ + lookup = (Word8 *)(&ari_lookup_s17_LC[t] + (1 << (NBITS_CONTEXT+NBITS_RATEQ))); /* address calculation not counted */ WHILE (GE_16(s_max(a1, b1), A_THRES)) { pki = lookup[lev1]; diff --git a/lib_enc/acelp_core_enc.c b/lib_enc/acelp_core_enc.c index 258add9ae..40d21e326 100644 --- a/lib_enc/acelp_core_enc.c +++ b/lib_enc/acelp_core_enc.c @@ -424,9 +424,9 @@ ivas_error acelp_core_enc( Word16 lsf_wgts_fx[M]; for (int i = 0; i < M; i++) { - lsf_new_fx[i] = (lsf_new[i]) * 2.56; - tdm_lsfQ_PCh_fx[i] = (tdm_lsfQ_PCh[i]) * 2.56; - lsf_wgts_fx[i] = (lsf_wgts[i]) * 2.56; + lsf_new_fx[i] = (Word16)((lsf_new[i]) * 2.56f); + tdm_lsfQ_PCh_fx[i] = (Word16)((tdm_lsfQ_PCh[i]) * 2.56f); + lsf_wgts_fx[i] = (Word16)((lsf_wgts[i]) * 2.56f); } floatToFixed_arr(lsp_new, lsp_new_fx, 15, M); @@ -434,8 +434,8 @@ ivas_error acelp_core_enc( for (int i = 0; i < M; i++) { - lsf_new[i] = (lsf_new_fx[i]) / 2.56; - lsf_wgts[i] = (lsf_wgts_fx[i]) / 2.56; + lsf_new[i] = (Word16)((lsf_new_fx[i]) / 2.56f); + lsf_wgts[i] = (Word16)((lsf_wgts_fx[i]) / 2.56f); } fixedToFloat_arr(lsp_new_fx, lsp_new, 15, M); #else diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c index ffb88f484..e33f32092 100644 --- a/lib_enc/cod_ace_fx.c +++ b/lib_enc/cod_ace_fx.c @@ -275,7 +275,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision */ * Encode the algebraic innovation * *----------------------------------------------------------------------*/ - E_ACELP_innovative_codebook_fx( exc, T0, T0_frac, T0_res, gain_pit, hLPDmem->tilt_code, acelp_cfg, i_subfr, p_Aq, h1, xn, cn, y1, y2, st->acelp_autocorr, &prm, code, shift ,st->L_frame, st->last_L_frame, st->total_brate); + E_ACELP_innovative_codebook_fx( exc, T0, T0_frac, T0_res, gain_pit, hLPDmem->tilt_code, acelp_cfg, i_subfr, p_Aq, h1, xn, cn, y1, y2, (Word8)st->acelp_autocorr, &prm, code, shift ,st->L_frame, st->last_L_frame, st->total_brate); E_ACELP_xy2_corr(xn, y1, y2, &g_corr, L_SUBFR, Q_xn); diff --git a/lib_enc/core_enc_2div_fx.c b/lib_enc/core_enc_2div_fx.c index f448d3830..a458ba3d6 100644 --- a/lib_enc/core_enc_2div_fx.c +++ b/lib_enc/core_enc_2div_fx.c @@ -239,7 +239,7 @@ void core_encode_twodiv_fx( shr(hTcxEnc->L_frameTCX, 1), shr(st->hTcxCfg->tcx_coded_lines, 1), target_bits, - st->tcxonly, + (Word8)st->tcxonly, spectrum[n], &spectrum_e[n], hTcxEnc->tnsData+n, @@ -318,7 +318,7 @@ void core_encode_twodiv_fx( hTcxEnc->L_frameTCX, st->hTcxCfg->tcx_coded_lines, target_bits, - st->tcxonly, + (Word8)st->tcxonly, spectrum[0], &spectrum_e[0], &hTcxEnc->tnsData[0], diff --git a/lib_enc/core_enc_ol_fx.c b/lib_enc/core_enc_ol_fx.c index 62f022bb3..a9f8dfafb 100644 --- a/lib_enc/core_enc_ol_fx.c +++ b/lib_enc/core_enc_ol_fx.c @@ -267,7 +267,7 @@ void core_encode_openloop_fx( Q_new, shift, pitch_buf, voice_factors, ptr_bwe_exc); IF (st->hPlcExt) { - st->glr_idx[0] = encSideSpecPowDiffuseDetector_fx(st->hPlcExt->last_lsf_ref, st->hPlcExt->last_lsf_con, st->last_sr_core, &(st->prev_lsf4_mean), st->glr, coder_type); + st->glr_idx[0] = encSideSpecPowDiffuseDetector_fx(st->hPlcExt->last_lsf_ref, st->hPlcExt->last_lsf_con, st->last_sr_core, &(st->prev_lsf4_mean), (Word8)st->glr, coder_type); Copy(lsf_q, st->hPlcExt->last_lsf_ref, M); Copy(st->hPlcExt->lsf_con, st->hPlcExt->last_lsf_con, M); @@ -395,7 +395,7 @@ void core_encode_openloop_fx( hTcxEnc->L_frameTCX, st->hTcxCfg->tcx_coded_lines, target_bits, - st->tcxonly, + (Word8)st->tcxonly, spectrum_long, &spectrum_long_e, param_core, @@ -871,7 +871,7 @@ void core_acelp_tcx20_switching_fx( /* LTP */ tcx_ltp_encode_fx(hTcxEnc->tcxltp, - st->tcxonly, + (Word8)st->tcxonly, TCX_20, st->L_frame, L_SUBFR, diff --git a/lib_enc/enc_gen_voic_rf_fx.c b/lib_enc/enc_gen_voic_rf_fx.c index f5c574ee5..afd51342d 100644 --- a/lib_enc/enc_gen_voic_rf_fx.c +++ b/lib_enc/enc_gen_voic_rf_fx.c @@ -370,7 +370,7 @@ void coder_acelp_rf_fx( prm_rf = &hRF->rf_indx_fcb[0][nSubfr]; E_ACELP_innovative_codebook_fx( exc_rf,T0,T0_frac,T0_res, gain_pit, hRF->rf_tilt_code, - acelp_cfg, i_subfr,p_Aq,h1,xn,cn,y1,y2,st->acelp_autocorr, + acelp_cfg, i_subfr,p_Aq,h1,xn,cn,y1,y2,(Word8)st->acelp_autocorr, &prm_rf,code,shift,st->L_frame, st->last_L_frame,st->total_brate); } ELSE diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index 1b7bcd264..d17bbb113 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -141,7 +141,7 @@ void encod_unvoiced_fx( * Encode the algebraic innovation * *----------------------------------------------------------------------*/ - E_ACELP_innovative_codebook_fx(exc_fx, *pt_pitch_fx, 0, 1, gain_pit_fx, hLPDmem->tilt_code, acelp_cfg, i_subfr, p_Aq_fx, h1_fx, xn_fx, cn_fx, y1, y2_fx, st_fx->acelp_autocorr, &prm, code_fx, shift, st_fx->L_frame, st_fx->last_L_frame, st_fx->total_brate); + E_ACELP_innovative_codebook_fx(exc_fx, *pt_pitch_fx, 0, 1, gain_pit_fx, hLPDmem->tilt_code, acelp_cfg, i_subfr, p_Aq_fx, h1_fx, xn_fx, cn_fx, y1, y2_fx, (Word8)st_fx->acelp_autocorr, &prm, code_fx, shift, st_fx->L_frame, st_fx->last_L_frame, st_fx->total_brate); E_ACELP_xy2_corr(xn_fx, y1, y2_fx, &g_corr, L_SUBFR, Q_xn); diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index 6df5c076a..d31267152 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -122,7 +122,7 @@ void core_signal_analysis_high_bitrate_fx( IF (EQ_16(st->element_mode, IVAS_CPE_DFT)) { //PMT("tcx_ltp_encode_fx should be verified for IVAS") - tcx_ltp_encode_fx(hTcxEnc->tcxltp, st->tcxonly, hTcxEnc->tcxMode, + tcx_ltp_encode_fx(hTcxEnc->tcxltp, (Word8)st->tcxonly, hTcxEnc->tcxMode, L_frame, L_SUBFR, st->speech_enc + st->encoderLookahead_enc, hTcxEnc->speech_ltp + st->encoderLookahead_enc, st->speech_enc + st->encoderLookahead_enc, T_op[1], ¶m_core[1 + NOISE_FILL_RANGES], ltpBits, @@ -134,7 +134,7 @@ void core_signal_analysis_high_bitrate_fx( } ELSE { - tcx_ltp_encode_fx(hTcxEnc->tcxltp, st->tcxonly, hTcxEnc->tcxMode, + tcx_ltp_encode_fx(hTcxEnc->tcxltp, (Word8)st->tcxonly, hTcxEnc->tcxMode, L_frame, L_SUBFR, st->speech_enc + st->encoderLookahead_enc, hTcxEnc->speech_ltp + st->encoderLookahead_enc, st->speech_enc + st->encoderLookahead_enc, T_op[1], ¶m_core[1 + NOISE_FILL_RANGES], ltpBits, diff --git a/lib_enc/igf_scf_enc_fx.c b/lib_enc/igf_scf_enc_fx.c index 8621640fe..77b74fd7f 100644 --- a/lib_enc/igf_scf_enc_fx.c +++ b/lib_enc/igf_scf_enc_fx.c @@ -235,7 +235,7 @@ static void encode_sfe_vector( arith_encode_residual(hPrivateData, ptr, res, - hPrivateData->cf_se01, + (Word16 *)hPrivateData->cf_se01, hPrivateData->cf_off_se01); } ELSE @@ -252,7 +252,7 @@ static void encode_sfe_vector( arith_encode_residual(hPrivateData, ptr, res, - hPrivateData->cf_se02 + index1, + (Word16 *)(hPrivateData->cf_se02 + index1), hPrivateData->cf_off_se02[index2]); } } @@ -267,7 +267,7 @@ static void encode_sfe_vector( arith_encode_residual(hPrivateData, ptr, res, - hPrivateData->cf_se10, + (Word16 *)hPrivateData->cf_se10, hPrivateData->cf_off_se10); } ELSE @@ -291,7 +291,7 @@ static void encode_sfe_vector( arith_encode_residual(hPrivateData, ptr, res, - hPrivateData->cf_se11 + index1, + (Word16 *)(hPrivateData->cf_se11 + index1), hPrivateData->cf_off_se11[index2]); } } diff --git a/lib_enc/ivas_agc_enc.c b/lib_enc/ivas_agc_enc.c index 8fbeabc18..0af4eb00c 100644 --- a/lib_enc/ivas_agc_enc.c +++ b/lib_enc/ivas_agc_enc.c @@ -920,7 +920,7 @@ void ivas_agc_enc_process_fx( temp_16 = BASOP_Util_Divide3232_Scale( temp1, temp2, &div_e ); IF( LT_16( div_e, 0 ) ) { - temp_16 = shr( temp_16, abs( div_e ) ); + temp_16 = shr( temp_16, (Word16)abs( div_e ) ); div_e = 0; } temp_16 = ceil_fx( temp_16, 15 - div_e ); diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index b9511bc6b..d5f4fbf66 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -861,8 +861,8 @@ static void calculate_energy_buffer_fx( Word32 chan_width_bins_fx; Word16 band_res_dft_fx, chan_width_f_fx, start, stop; - Word32 temp_q1 = norm_l( input_Fs ) - 1; - Word32 temp_q2 = norm_s( hCPE->hStereoDft->NFFT ); + Word16 temp_q1 = norm_l( input_Fs ) - 1; + Word16 temp_q2 = norm_s( hCPE->hStereoDft->NFFT ); band_res_dft_fx = div_l( L_shl( input_Fs, temp_q1 ), shl( hCPE->hStereoDft->NFFT, temp_q2 ) ); chan_width_f_fx = div_l( 24000, CLDFB_NO_CHANNELS_MAX ); diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index b6fb7a18e..e5d92d6fd 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -1102,7 +1102,7 @@ ivas_error create_cpe_enc_fx( IF (st->hFdCngEnc != NULL) { - st->hFdCngEnc->hFdCngCom->CngBitrate = sub(hCPE->element_brate, 1); + st->hFdCngEnc->hFdCngCom->CngBitrate = L_sub(hCPE->element_brate, 1); } hCPE->hCoreCoder[n] = st; diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index c6ebfe917..fafd5cb69 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -974,7 +974,7 @@ ivas_error ivas_init_encoder_fx( IF (NE_16(ivas_format, MONO_FORMAT)) { /* In IVAS, ensure that minimum coded bandwidth is WB */ - hEncoderConfig->max_bwidth = L_max(hEncoderConfig->max_bwidth, WB); + hEncoderConfig->max_bwidth = extract_l(L_max(hEncoderConfig->max_bwidth, WB)); } st_ivas->ism_mode = ISM_MODE_NONE; st_ivas->mc_mode = MC_MODE_NONE; diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index e6d54ba79..7b938eae1 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -296,7 +296,7 @@ ivas_error ivas_spar_enc_open_fx( hSpar->spar_reconfig_flag = 0; input_Fs = hEncoderConfig->input_Fs; - sba_order_internal = L_min(st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER); + sba_order_internal = extract_l(L_min(st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER)); nchan_inp = ivas_sba_get_nchan_metadata(sba_order_internal, hEncoderConfig->ivas_total_brate); assert(nchan_inp <= hEncoderConfig->nchan_inp); ivas_total_brate = hEncoderConfig->ivas_total_brate; diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index b633a1f3b..79482e455 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -495,7 +495,7 @@ static void ivas_spar_set_enc_config_fx( FOR(i = 0; i < nchan_transport; i++) { - IF(NE_16(max_freq_per_chan, NULL)) + IF(max_freq_per_chan != NULL) { hMdEnc->spar_md_cfg.max_freq_per_chan[i] = (max_freq_per_chan[i] != 0) ? max_freq_per_chan[i] : max_freq_per_chan[0]; } diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 37742b73f..c52fcf51e 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -545,7 +545,7 @@ typedef struct stereo_tca_enc_data_structure Word32 corrEstPrev_fx[3][2 * L_NCSHIFT_DS + 1]; /* Prev correlation vector */ Word32 corrEstLT_fx[2 * L_NCSHIFT_DS + 1]; /* Long term correlation vector smoothed */ - Word16 ica_envVarLT_fx; //Q20 + Word32 ica_envVarLT_fx; //Q20 Word32 C_mem_fx[2 * L_NCSHIFT_DS + 1]; Word32 E1_mem_fx, E2_mem_fx; Word32 delay_0_mem_fx[MAX_DELAYREGLEN]; diff --git a/lib_enc/ivas_stereo_classifier.c b/lib_enc/ivas_stereo_classifier.c index b0cf30923..4825edc60 100644 --- a/lib_enc/ivas_stereo_classifier.c +++ b/lib_enc/ivas_stereo_classifier.c @@ -288,7 +288,7 @@ void stereo_classifier_init_fx( { /* initialization of features for xtalk classifier and UNCLR classifier */ hStereoClassif->clas_ch1 = 0; - set_zero_fx(hStereoClassif->pitch_ch1, 3); + set16_fx(hStereoClassif->pitch_ch1, 0, 3); set_zero_fx(hStereoClassif->voicing_ch1_fx, 3); hStereoClassif->cor_map_sum_ch1_fx = 0; set_zero_fx(hStereoClassif->lsf_ch1_fx, M); @@ -312,7 +312,7 @@ void stereo_classifier_init_fx( hStereoClassif->vad_relE = 0; //Q31 hStereoClassif->is_speech_fx = 0; //Q31 - set_zero_fx(hStereoClassif->aEn_raw, CPE_CHANNELS); + set16_fx(hStereoClassif->aEn_raw, 0, CPE_CHANNELS); hStereoClassif->Etot_dn_fx = 0; hStereoClassif->Etot_up_fx = 0; diff --git a/lib_enc/ivas_stereo_ica_enc.c b/lib_enc/ivas_stereo_ica_enc.c index 85dc65140..3403edd73 100644 --- a/lib_enc/ivas_stereo_ica_enc.c +++ b/lib_enc/ivas_stereo_ica_enc.c @@ -1310,7 +1310,7 @@ void stereo_tca_init_enc_fx( set32_fx(hStereoTCA->memChanR_fx, 0, add(L_MEM_RECALC_48K, L_MEM_RECALC_48k_SCH)); set32_fx(hStereoTCA->memChanL_DS_fx, 0, ADDED_MEM_DS); set32_fx(hStereoTCA->memChanR_DS_fx, 0, ADDED_MEM_DS); - hStereoTCA->mem_tempF_fx = 0.; + hStereoTCA->mem_tempF_fx = 0; set32_fx(hStereoTCA->corrEstPrev_fx[0], 0, add(shl(L_NCSHIFT_DS, 1), 1)); set32_fx(hStereoTCA->corrEstPrev_fx[1], 0, add(shl(L_NCSHIFT_DS, 1), 1)); set32_fx(hStereoTCA->corrEstPrev_fx[2], 0, add(shl(L_NCSHIFT_DS, 1), 1)); diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 09c79945b..02aff644c 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -2602,7 +2602,7 @@ static ivas_error sanitizeBitrateISM_fx( IF (extMetadataApi) { - hEncoderConfig->ism_extended_metadata_flag = GE_32(hEncoderConfig->ivas_total_brate, ISM_EXTENDED_METADATA_BRATE); + hEncoderConfig->ism_extended_metadata_flag = (Word16)GE_32(hEncoderConfig->ivas_total_brate, ISM_EXTENDED_METADATA_BRATE); } ELSE { diff --git a/lib_enc/lsf_enc.c b/lib_enc/lsf_enc.c index 128e7fb3e..951d1145f 100644 --- a/lib_enc/lsf_enc.c +++ b/lib_enc/lsf_enc.c @@ -559,15 +559,15 @@ void lsf_end_enc( Word16 pred3_fx[M]; for (int i = 0; i < M; i++) { - tdm_lsfQ_PCh_fx[i] = (tdm_lsfQ_PCh[i]) * 2.56; - pred3_fx[i] = (pred3[i]) * 2.56; + tdm_lsfQ_PCh_fx[i] = (Word16)((tdm_lsfQ_PCh[i]) * 2.56f); + pred3_fx[i] = (Word16)((pred3[i]) * 2.56f); } tdm_SCh_LSF_intra_pred_fx(st->element_brate, tdm_lsfQ_PCh_fx, pred3_fx); for (int i = 0; i < M; i++) { - pred3[i] = (pred3_fx[i]) / 2.56; + pred3[i] = (pred3_fx[i]) / 2.56f; } #else tdm_SCh_LSF_intra_pred( st->element_brate, tdm_lsfQ_PCh, pred3 ); diff --git a/lib_enc/qlpc_stoch_fx.c b/lib_enc/qlpc_stoch_fx.c index 32244b2b7..7169ffc8b 100644 --- a/lib_enc/qlpc_stoch_fx.c +++ b/lib_enc/qlpc_stoch_fx.c @@ -186,7 +186,7 @@ void lpc_quantization_fx( { lsp2lsf_fx(lspmid, lsfmid, M, extract_l(st->sr_core)); - midlsf_enc_fx(st->lsf_old_fx, lsf_q, lsfmid, &lsfmid_idx, M, st->Bin_E_old_fx, Q_ener, st->narrowBand, st->sr_core, coder_type ); + midlsf_enc_fx(st->lsf_old_fx, lsf_q, lsfmid, &lsfmid_idx, M, st->Bin_E_old_fx, Q_ener, (Word8)st->narrowBand, st->sr_core, coder_type ); param_lpc[nb_indices++] = lsfmid_idx; move16(); midlsf_dec (st->lsf_old_fx, lsf_q, lsfmid_idx, lsfmid_q, coder_type ,NULL,0,1 ); diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 76dc25558..b53a256e1 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -337,7 +337,7 @@ typedef struct cldfb_vad_structure Word32 lt_noise_sp_center_diff_counter_fx; /* number of the member lt_noise_sp_center_diff_sum*/ Word16 lt_noise_sp_center0_fx; /* long time noise sp_center0*/ Word16 lt_noise_sp_center3_fx; /* long time noise sp_center3*/ - Word16 lt_bg_highf_eng_fx; /* average of long time high frequency energy*/ + Word32 lt_bg_highf_eng_fx; /* average of long time high frequency energy*/ int16_t update_num_with_snr_fx; /* the number of the background update with SNR*/ int16_t update_num_with_snr; /* the number of the background update with SNR*/ diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 31ab5a3e1..7050f8b64 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -2463,7 +2463,7 @@ static ivas_error ivas_er_init_handle( move16(); IF ( EQ_16(i , 2) ) { - reflections->user_origin_fx[i] = ER_LIST_HEIGHT_FX; + reflections->user_origin_fx[i] = (Word32)ER_LIST_HEIGHT_FX; move16(); } } @@ -2874,19 +2874,19 @@ ivas_error ivas_rend_openCrend( #endif hCrend->reflections->max_frame_size = (int16_t) ( output_Fs / FRAMES_PER_SEC ); #ifdef IVAS_FLOAT_FIXED - hRendCfg->roomAcoustics.dimensions.x_fx = hRendCfg->roomAcoustics.dimensions.x * 4194304; // Q10.22, min value:1, max :999.0 - hRendCfg->roomAcoustics.dimensions.y_fx = hRendCfg->roomAcoustics.dimensions.y * 4194304; // Q10.22 - hRendCfg->roomAcoustics.dimensions.z_fx = hRendCfg->roomAcoustics.dimensions.z * 4194304; // Q10.22 + hRendCfg->roomAcoustics.dimensions.x_fx = (Word32)(hRendCfg->roomAcoustics.dimensions.x * 4194304); // Q10.22, min value:1, max :999.0 + hRendCfg->roomAcoustics.dimensions.y_fx = (Word32)(hRendCfg->roomAcoustics.dimensions.y * 4194304); // Q10.22 + hRendCfg->roomAcoustics.dimensions.z_fx = (Word32)(hRendCfg->roomAcoustics.dimensions.z * 4194304); // Q10.22 for ( int i = 0; i < 6; i++ ) { - hRendCfg->roomAcoustics.AbsCoeff_fx[i] = hRendCfg->roomAcoustics.AbsCoeff[i] * 1073741824; // Q2.30 min :0 max 1 + hRendCfg->roomAcoustics.AbsCoeff_fx[i] = (Word32)(hRendCfg->roomAcoustics.AbsCoeff[i] * 1073741824); // Q2.30 min :0 max 1 } - hRendCfg->roomAcoustics.ListenerOrigin.x_fx = hRendCfg->roomAcoustics.ListenerOrigin.x * 4194304; //( 2147483648 >> 2 ); - hRendCfg->roomAcoustics.ListenerOrigin.y_fx = hRendCfg->roomAcoustics.ListenerOrigin.y * ( 4194304 ); - hRendCfg->roomAcoustics.ListenerOrigin.z_fx = hRendCfg->roomAcoustics.ListenerOrigin.z * ( 4194304 ); + hRendCfg->roomAcoustics.ListenerOrigin.x_fx = (Word32)(hRendCfg->roomAcoustics.ListenerOrigin.x * 4194304); //( 2147483648 >> 2 ); + hRendCfg->roomAcoustics.ListenerOrigin.y_fx = (Word32)(hRendCfg->roomAcoustics.ListenerOrigin.y * ( 4194304 )); + hRendCfg->roomAcoustics.ListenerOrigin.z_fx = (Word32)(hRendCfg->roomAcoustics.ListenerOrigin.z * ( 4194304 )); #endif diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 0328f0d1b..7599eccba 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -47,6 +47,7 @@ #include "prot_fx1.h" /* Function prototypes */ #include "prot_fx2.h" /* Function prototypes */ #endif + /*------------------------------------------------------------------------- * Local constants *------------------------------------------------------------------------*/ @@ -64,6 +65,18 @@ * Local function prototypes *------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +static void computeTargetPSDs_direct_fx( const Word16 num_channels, const Word16 num_freq_bands, const Word32 *direct_power_factor, const Word32 *reference_power, const Word16 *q_reference_power, const Word32 *direct_responses, const Word32 *direct_responses_square, Word32 *cy_auto_dir_smooth, Word16 *q_cy_auto_dir_smooth, Word32 *cy_cross_dir_smooth, Word16 *q_cy_cross_dir_smooth ); + +static void computeTargetPSDs_direct_subframe_fx( const Word16 num_channels, const Word16 num_freq_bands, const Word32 *direct_power_factor, const Word32 *reference_power, const Word32 *direct_responses, const Word32 *direct_responses_square, Word32 *cy_auto_dir_smooth, Word32 *cy_cross_dir_smooth ); + +static void computeTargetPSDs_diffuse_fx( const Word16 num_channels, const Word16 num_freq_bands, const Word16 start_band, const Word32 *diffuse_power_factor, const Word32 *reference_power, const Word16 *q_reference_power, const Word32 *diffuse_responses_square, Word32 *cy_auto_diff_smooth, Word16 *q_cy_auto_diff_smooth ); + +static void computeTargetPSDs_diffuse_subframe_fx( const Word16 num_channels, const Word16 num_freq_bands, const Word16 start_band, const Word32 *diffuse_power_factor, const Word32 *reference_power, const Word32 *diffuse_responses_square, Word32 *cy_auto_diff_smooth ); + +static void computeTargetPSDs_diffuse_with_onsets_fx( const Word16 num_channels, const Word16 num_freq_bands, const Word16 num_decorr_freq_bands, const Word16 *proto_frame_diff_index, const Word32 *diffuse_power_factor, const Word32 *reference_power, const Word16 *q_reference_power, const Word32 *diffuse_responses_square, const Word32 *onset_filter, Word32 *cy_auto_diff_smooth, Word16 *q_cy_auto_diff_smooth ); +#endif + static void computeTargetPSDs_direct( const int16_t num_channels, const int16_t num_freq_bands, const float *direct_power_factor, const float *reference_power, const float *direct_responses, const float *direct_responses_square, float *cy_auto_dir_smooth, float *cy_cross_dir_smooth ); static void computeTargetPSDs_direct_subframe( const int16_t num_channels, const int16_t num_freq_bands, const float *direct_power_factor, const float *reference_power, const float *direct_responses, const float *direct_responses_square, float *cy_auto_dir_smooth, float *cy_cross_dir_smooth ); @@ -151,9 +164,9 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } - IF ((dirac_output_synthesis_state->diffuse_responses_square_fx = (Word16 *)malloc(2 * sizeof(Word16))) == NULL) + IF( ( dirac_output_synthesis_state->diffuse_responses_square_fx = (Word32 *) malloc( 2 * sizeof( Word32 ) ) ) == NULL ) { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n")); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } } ELSE IF ( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) @@ -163,9 +176,9 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } - IF ((dirac_output_synthesis_state->diffuse_responses_square_fx = (Word16 *)malloc(hDirACRend->hOutSetup.nchan_out_woLFE * sizeof(Word16))) == NULL) + IF( ( dirac_output_synthesis_state->diffuse_responses_square_fx = (Word32 *) malloc( hDirACRend->hOutSetup.nchan_out_woLFE * sizeof( Word32 ) ) ) == NULL ) { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n")); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } } @@ -230,9 +243,9 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } - IF ((dirac_output_synthesis_state->cy_cross_dir_smooth_prev_fx = (Word16 *)malloc(size * sizeof(Word16))) == NULL) + IF( ( dirac_output_synthesis_state->cy_cross_dir_smooth_prev_fx = (Word32 *) malloc( size * sizeof( Word32 ) ) ) == NULL ) { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n")); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } IF ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { @@ -243,9 +256,9 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } dirac_output_synthesis_state->cy_auto_dir_smooth_prev_fx = NULL; - IF ((dirac_output_synthesis_state->cy_auto_diff_smooth_prev_fx = (Word16 *)malloc(dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_diff * sizeof(Word16))) == NULL) + IF( ( dirac_output_synthesis_state->cy_auto_diff_smooth_prev_fx = (Word32 *) malloc( dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_diff * sizeof( Word32 ) ) ) == NULL ) { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n")); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } } ELSE @@ -270,23 +283,23 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } } - IF ((dirac_output_synthesis_state->cy_auto_dir_smooth_prev_fx = (Word16 *)malloc(hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir * sizeof(Word16))) == NULL) + IF( ( dirac_output_synthesis_state->cy_auto_dir_smooth_prev_fx = (Word32 *) malloc( hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir * sizeof( Word32 ) ) ) == NULL ) { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n")); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } - IF(hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_SHD) + IF( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_SHD ) { - IF((dirac_output_synthesis_state->cy_auto_diff_smooth_prev_fx = (Word16 *)malloc(hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir * sizeof(Word16))) == NULL) + IF( ( dirac_output_synthesis_state->cy_auto_diff_smooth_prev_fx = (Word32 *) malloc( hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir * sizeof( Word32 ) ) ) == NULL ) { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n")); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } } ELSE { - IF((dirac_output_synthesis_state->cy_auto_diff_smooth_prev_fx = (Word16 *)malloc(hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff * sizeof(Word16))) == NULL) + IF( ( dirac_output_synthesis_state->cy_auto_diff_smooth_prev_fx = (Word32 *) malloc( hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff * sizeof( Word32 ) ) ) == NULL ) { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n")); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } } } @@ -450,9 +463,9 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( /*dirac_output_synthesis_state->diffuse_responses_square[ch_idx] = pow(dirac_output_synthesis_params->diffuse_response_function[ch_idx]/max_response, 2.0f);*/ tmp_fx = hDirACRend->diffuse_response_function_fx[ch_idx]; - dirac_output_synthesis_state->diffuse_responses_square_fx[ch_idx] = mult(tmp_fx , tmp_fx); + dirac_output_synthesis_state->diffuse_responses_square_fx[ch_idx] = L_deposit_h( mult( tmp_fx, tmp_fx ) ); /*TODO : remove floating code*/ - dirac_output_synthesis_state->diffuse_responses_square[ch_idx] = fix16_to_float(dirac_output_synthesis_state->diffuse_responses_square_fx[ch_idx] , 15); + dirac_output_synthesis_state->diffuse_responses_square[ch_idx] = fixedToFloat( dirac_output_synthesis_state->diffuse_responses_square_fx[ch_idx], Q31 ); } } @@ -487,15 +500,16 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( diff_nrg_decorr_fx = L_add(diff_nrg_decorr_fx, diff_nrg_fx); } } - Word16 exp_1 = 0, exp_2 = 0; - dirac_output_synthesis_params->diffuse_compensation_factor_fx = BASOP_Util_Divide3232_Scale(diff_nrg_total_fx, diff_nrg_trans_fx, &exp_1); + Word16 exp_1 = 0, exp_2 = 0, tmp; + tmp = BASOP_Util_Divide3232_Scale( diff_nrg_total_fx, diff_nrg_trans_fx, &exp_1 ); // (Q15 - exp_diff) + dirac_output_synthesis_params->diffuse_compensation_factor_fx = L_shl( L_deposit_l( tmp ), add( Q12, exp_1 ) ); // Q27 /*TODO : remove float code*/ - dirac_output_synthesis_params->diffuse_compensation_factor = me2f_16(dirac_output_synthesis_params->diffuse_compensation_factor_fx , exp_1); + dirac_output_synthesis_params->diffuse_compensation_factor = fixedToFloat( dirac_output_synthesis_params->diffuse_compensation_factor_fx, Q27 ); - dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx = BASOP_Util_Divide3232_Scale(diff_nrg_total_fx, diff_nrg_decorr_fx, &exp_2); + tmp = BASOP_Util_Divide3232_Scale( diff_nrg_total_fx, diff_nrg_decorr_fx, &exp_2 ); // (Q15 - exp_diff) + dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx = L_shl( L_deposit_l( tmp ), add( Q14, exp_2 ) ); // Q29 /*TODO : remove float code*/ - dirac_output_synthesis_params->diffuse_compensation_factor_decorr = me2f_16(dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx , exp_2); - + dirac_output_synthesis_params->diffuse_compensation_factor_decorr = fixedToFloat( dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx, Q29 ); } ELSE { @@ -918,12 +932,12 @@ void ivas_dirac_dec_output_synthesis_init_fx( } #ifdef IVAS_FLOAT_FIXED - IF (h_dirac_output_synthesis_state->cy_auto_dir_smooth_prev_fx != NULL) + IF( h_dirac_output_synthesis_state->cy_auto_dir_smooth_prev_fx != NULL ) { - set16_fx(h_dirac_output_synthesis_state->cy_auto_dir_smooth_prev_fx, 0, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir); + set32_fx( h_dirac_output_synthesis_state->cy_auto_dir_smooth_prev_fx, 0, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir ); } - IF (hodirac_flag) + IF( hodirac_flag ) { size = hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir * DIRAC_HO_NUMSECTORS; } @@ -931,19 +945,19 @@ void ivas_dirac_dec_output_synthesis_init_fx( { size = hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir; } - set16_fx(h_dirac_output_synthesis_state->cy_cross_dir_smooth_prev_fx, 0, size); + set32_fx( h_dirac_output_synthesis_state->cy_cross_dir_smooth_prev_fx, 0, size ); - IF (hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD) + IF( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { - set16_fx(h_dirac_output_synthesis_state->cy_auto_diff_smooth_prev_fx, 0, h_dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_diff); + set32_fx( h_dirac_output_synthesis_state->cy_auto_diff_smooth_prev_fx, 0, h_dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_diff ); } - ELSE IF (hDirACRend->synthesisConf != DIRAC_SYNTHESIS_PSD_SHD) + ELSE IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_PSD_SHD ) { - set16_fx(h_dirac_output_synthesis_state->cy_auto_diff_smooth_prev_fx, 0, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff); + set32_fx( h_dirac_output_synthesis_state->cy_auto_diff_smooth_prev_fx, 0, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff ); } ELSE { - set16_fx(h_dirac_output_synthesis_state->cy_auto_diff_smooth_prev_fx, 0, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir); + set32_fx( h_dirac_output_synthesis_state->cy_auto_diff_smooth_prev_fx, 0, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir ); } IF (h_dirac_output_synthesis_state->proto_power_smooth_prev_fx != NULL) @@ -1276,6 +1290,10 @@ void ivas_dirac_dec_output_synthesis_process_slot( int16_t diff_start_band; DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params; DIRAC_OUTPUT_SYNTHESIS_STATE *h_dirac_output_synthesis_state; +#ifdef IVAS_FLOAT_FIXED + Word32 *reference_power_fx = NULL, *onset_fx = NULL; + Word16 q_reference_power, q_onset; +#endif h_dirac_output_synthesis_params = &( hDirACRend->h_output_synthesis_psd_params ); h_dirac_output_synthesis_state = &( hDirACRend->h_output_synthesis_psd_state ); @@ -1459,6 +1477,37 @@ void ivas_dirac_dec_output_synthesis_process_slot( diff_start_band = 0; if ( h_dirac_output_synthesis_params->use_onset_filters ) { +#ifdef IVAS_FLOAT_FIXED + h_dirac_output_synthesis_state->diffuse_power_factor_q = Q31; + floatToFixed_arrL( h_dirac_output_synthesis_state->diffuse_power_factor, h_dirac_output_synthesis_state->diffuse_power_factor_fx, h_dirac_output_synthesis_state->diffuse_power_factor_q, h_dirac_output_synthesis_params->max_band_decorr ); + + reference_power_fx = hDirACRend->stack_mem.reference_power_fx; + q_reference_power = L_get_q_buf( (float *) reference_power, num_freq_bands ); + floatToFixed_arrL( (float *) reference_power, reference_power_fx, q_reference_power, num_freq_bands ); + + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = L_get_q_buf( h_dirac_output_synthesis_state->cy_auto_diff_smooth, num_channels_dir * num_freq_bands ); + floatToFixed_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, num_channels_dir * num_freq_bands ); + + h_dirac_output_synthesis_state->diffuse_responses_square_q = Q31; + floatToFixed_arrL( h_dirac_output_synthesis_state->diffuse_responses_square, h_dirac_output_synthesis_state->diffuse_responses_square_fx, h_dirac_output_synthesis_state->diffuse_responses_square_q, num_channels_dir ); + + onset_fx = hDirACRend->stack_mem.onset_filter_fx; + q_onset = Q30; + floatToFixed_arrL( (float *) onset, onset_fx, q_onset, ( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) ? hDirACRend->num_outputs_diff * num_freq_bands : 2 * num_freq_bands ); +#endif + +#ifdef IVAS_FLOAT_FIXED + computeTargetPSDs_diffuse_with_onsets_fx( num_channels_dir, + num_freq_bands, h_dirac_output_synthesis_params->max_band_decorr, + hDirACRend->proto_index_diff, + h_dirac_output_synthesis_state->diffuse_power_factor_fx, + reference_power_fx, + &q_reference_power, + h_dirac_output_synthesis_state->diffuse_responses_square_fx, + onset_fx, + h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, + &h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ); +#else computeTargetPSDs_diffuse_with_onsets( num_channels_dir, num_freq_bands, h_dirac_output_synthesis_params->max_band_decorr, hDirACRend->proto_index_diff, @@ -1467,6 +1516,11 @@ void ivas_dirac_dec_output_synthesis_process_slot( h_dirac_output_synthesis_state->diffuse_responses_square, onset, h_dirac_output_synthesis_state->cy_auto_diff_smooth ); +#endif + +#ifdef IVAS_FLOAT_FIXED + fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, num_channels_dir * num_freq_bands ); +#endif diff_start_band = h_dirac_output_synthesis_params->max_band_decorr; } @@ -1474,9 +1528,62 @@ void ivas_dirac_dec_output_synthesis_process_slot( /* process other PSDs only slot wise for 4 transport channels */ if ( dec_param_estim == TRUE ) { +#ifdef IVAS_FLOAT_FIXED + h_dirac_output_synthesis_state->direct_power_factor_q = Q31; + floatToFixed_arrL( h_dirac_output_synthesis_state->direct_power_factor, h_dirac_output_synthesis_state->direct_power_factor_fx, h_dirac_output_synthesis_state->direct_power_factor_q, num_freq_bands ); + + reference_power_fx = hDirACRend->stack_mem.reference_power_fx; + q_reference_power = L_get_q_buf( (float *) reference_power, num_freq_bands ); + floatToFixed_arrL( (float *) reference_power, reference_power_fx, q_reference_power, num_freq_bands ); + + h_dirac_output_synthesis_state->q_cy_auto_dir_smooth = L_get_q_buf( h_dirac_output_synthesis_state->cy_auto_dir_smooth, num_channels_dir * num_freq_bands ); + floatToFixed_arrL( h_dirac_output_synthesis_state->cy_auto_dir_smooth, h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, num_channels_dir * num_freq_bands ); + + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = L_get_q_buf( h_dirac_output_synthesis_state->cy_cross_dir_smooth, num_channels_dir * num_freq_bands ); + floatToFixed_arrL( h_dirac_output_synthesis_state->cy_cross_dir_smooth, h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, num_channels_dir * num_freq_bands ); + + h_dirac_output_synthesis_state->direct_responses_q = Q31; + floatToFixed_arrL( h_dirac_output_synthesis_state->direct_responses, h_dirac_output_synthesis_state->direct_responses_fx, h_dirac_output_synthesis_state->direct_responses_q, num_channels_dir * num_freq_bands ); + + h_dirac_output_synthesis_state->direct_responses_square_q = Q31; + floatToFixed_arrL( h_dirac_output_synthesis_state->direct_responses_square, h_dirac_output_synthesis_state->direct_responses_square_fx, h_dirac_output_synthesis_state->direct_responses_square_q, num_channels_dir * num_freq_bands ); +#endif + +#ifdef IVAS_FLOAT_FIXED + computeTargetPSDs_direct_fx( num_channels_dir, num_freq_bands, h_dirac_output_synthesis_state->direct_power_factor_fx, reference_power_fx, &q_reference_power, h_dirac_output_synthesis_state->direct_responses_fx, h_dirac_output_synthesis_state->direct_responses_square_fx, h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, &h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, &h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ); +#else computeTargetPSDs_direct( num_channels_dir, num_freq_bands, h_dirac_output_synthesis_state->direct_power_factor, reference_power, h_dirac_output_synthesis_state->direct_responses, h_dirac_output_synthesis_state->direct_responses_square, h_dirac_output_synthesis_state->cy_auto_dir_smooth, h_dirac_output_synthesis_state->cy_cross_dir_smooth ); +#endif + +#ifdef IVAS_FLOAT_FIXED + fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, h_dirac_output_synthesis_state->cy_auto_dir_smooth, h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, num_channels_dir * num_freq_bands ); + fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, h_dirac_output_synthesis_state->cy_cross_dir_smooth, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, num_channels_dir * num_freq_bands ); +#endif + +#ifdef IVAS_FLOAT_FIXED + h_dirac_output_synthesis_state->diffuse_power_factor_q = Q31; + floatToFixed_arrL( h_dirac_output_synthesis_state->diffuse_power_factor, h_dirac_output_synthesis_state->diffuse_power_factor_fx, h_dirac_output_synthesis_state->diffuse_power_factor_q, num_freq_bands ); + + reference_power_fx = hDirACRend->stack_mem.reference_power_fx; + q_reference_power = L_get_q_buf( (float *) reference_power, num_freq_bands ); + floatToFixed_arrL( (float *) reference_power, reference_power_fx, q_reference_power, num_freq_bands ); + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = L_get_q_buf( h_dirac_output_synthesis_state->cy_auto_diff_smooth, num_channels_dir * num_freq_bands ); + floatToFixed_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, num_channels_dir * num_freq_bands ); + + h_dirac_output_synthesis_state->diffuse_responses_square_q = Q31; + floatToFixed_arrL( h_dirac_output_synthesis_state->diffuse_responses_square, h_dirac_output_synthesis_state->diffuse_responses_square_fx, h_dirac_output_synthesis_state->diffuse_responses_square_q, num_channels_dir ); +#endif + +#ifdef IVAS_FLOAT_FIXED + computeTargetPSDs_diffuse_fx( num_channels_dir, num_freq_bands, diff_start_band, h_dirac_output_synthesis_state->diffuse_power_factor_fx, reference_power_fx, &q_reference_power, h_dirac_output_synthesis_state->diffuse_responses_square_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, &h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ); +#else computeTargetPSDs_diffuse( num_channels_dir, num_freq_bands, diff_start_band, h_dirac_output_synthesis_state->diffuse_power_factor, reference_power, h_dirac_output_synthesis_state->diffuse_responses_square, h_dirac_output_synthesis_state->cy_auto_diff_smooth ); +#endif + +#ifdef IVAS_FLOAT_FIXED + fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, num_channels_dir * num_freq_bands ); +#endif } return; @@ -4032,6 +4139,54 @@ void ivas_lfe_synth_with_filters( * Local functions *------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +static void computeTargetPSDs_direct_fx( + const Word16 num_channels, + const Word16 num_freq_bands, + const Word32 *direct_power_factor, + const Word32 *reference_power, + const Word16 *q_reference_power, + const Word32 *direct_responses, + const Word32 *direct_responses_square, + Word32 *cy_auto_dir_smooth, + Word16 *q_cy_auto_dir_smooth, + Word32 *cy_cross_dir_smooth, + Word16 *q_cy_cross_dir_smooth ) +{ + Word16 ch_idx, cur_idx; + + /* segment auxiliary buffer */ + Word32 direct_power[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ + Word32 aux_buffer_res[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ + + /* estimate direct and diffuse power */ + v_mult_fixed( direct_power_factor, reference_power, direct_power, num_freq_bands ); // (Q31, q_reference_power) -> q_reference_power + + /* compute target auto and cross PSDs of current frame (smoothed) */ + FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + { + cur_idx = imult1616( ch_idx, num_freq_bands ); + + v_mult_fixed( direct_power, &direct_responses_square[cur_idx], aux_buffer_res, num_freq_bands ); // (q_reference_power, Q31) -> q_reference_power + Scale_sig32( aux_buffer_res, num_freq_bands, sub( *q_cy_auto_dir_smooth, *q_reference_power ) ); // q_cy_auto_dir_smooth + v_add_fixed( &cy_auto_dir_smooth[cur_idx], aux_buffer_res, &cy_auto_dir_smooth[cur_idx], num_freq_bands, Q1 ); // (q_cy_auto_dir_smooth - Q1) + + v_mult_fixed( direct_power, &direct_responses[cur_idx], aux_buffer_res, num_freq_bands ); // (q_reference_power, Q31) -> q_reference_power + Scale_sig32( aux_buffer_res, num_freq_bands, sub( *q_cy_cross_dir_smooth, *q_reference_power ) ); // q_cy_cross_dir_smooth + v_add_fixed( &cy_cross_dir_smooth[cur_idx], aux_buffer_res, &cy_cross_dir_smooth[cur_idx], num_freq_bands, Q1 ); // (q_cy_cross_dir_smooth - Q1) + } + + /* Q adjustment */ + *q_cy_auto_dir_smooth = sub( *q_cy_auto_dir_smooth, Q1 ); + move16(); + *q_cy_cross_dir_smooth = sub( *q_cy_cross_dir_smooth, Q1 ); + move16(); + + return; +} +#endif + + static void computeTargetPSDs_direct( const int16_t num_channels, const int16_t num_freq_bands, @@ -4067,6 +4222,39 @@ static void computeTargetPSDs_direct( } +#ifdef IVAS_FLOAT_FIXED +static void computeTargetPSDs_direct_subframe_fx( + const Word16 num_channels, + const Word16 num_freq_bands, + const Word32 *direct_power_factor, + const Word32 *reference_power, + const Word32 *direct_responses, + const Word32 *direct_responses_square, + Word32 *cy_auto_dir_smooth, + Word32 *cy_cross_dir_smooth ) +{ + Word16 ch_idx, cur_idx; + + /* segment auxiliary buffer */ + Word32 direct_power[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ + + /* estimate direct and diffuse power */ + v_mult_fixed( direct_power_factor, reference_power, direct_power, num_freq_bands ); + + /* compute target auto and cross PSDs of current frame (smoothed) */ + FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + { + cur_idx = imult1616( ch_idx, num_freq_bands ); + + v_mult_fixed( direct_power, &direct_responses_square[cur_idx], &cy_auto_dir_smooth[cur_idx], num_freq_bands ); + v_mult_fixed( direct_power, &direct_responses[cur_idx], &cy_cross_dir_smooth[cur_idx], num_freq_bands ); + } + + return; +} +#endif + + static void computeTargetPSDs_direct_subframe( const int16_t num_channels, const int16_t num_freq_bands, @@ -4098,6 +4286,47 @@ static void computeTargetPSDs_direct_subframe( } +#ifdef IVAS_FLOAT_FIXED +static void computeTargetPSDs_diffuse_fx( + const Word16 num_channels, + const Word16 num_freq_bands, + const Word16 start_band, + const Word32 *diffuse_power_factor, + const Word32 *reference_power, + const Word16 *q_reference_power, + const Word32 *diffuse_responses_square, + Word32 *cy_auto_diff_smooth, + Word16 *q_cy_auto_diff_smooth ) +{ + Word16 ch_idx, cur_idx; + + /* segment auxiliary buffer */ + Word32 diffuse_power[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ + Word32 aux_buffer_res[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ + + /* estimate direct and diffuse power */ + v_mult_fixed( diffuse_power_factor, reference_power, diffuse_power, num_freq_bands ); // (Q31, q_reference_power) -> q_reference_power + + /* compute target auto and cross PSDs of current frame (smoothed) */ + FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + { + cur_idx = imult1616( ch_idx, num_freq_bands ); + + v_multc_fixed( &diffuse_power[start_band], diffuse_responses_square[ch_idx], aux_buffer_res, num_freq_bands - start_band ); // (q_cy_auto_diff_smooth, Q31) -> q_cy_auto_diff_smooth + Scale_sig32( aux_buffer_res, num_freq_bands - start_band, sub( *q_cy_auto_diff_smooth, *q_reference_power ) ); // q_cy_auto_diff_smooth + Scale_sig32( &cy_auto_diff_smooth[cur_idx], start_band, negate( Q1 ) ); // (q_cy_auto_diff_smooth - Q1) + v_add_fixed( &cy_auto_diff_smooth[cur_idx + start_band], aux_buffer_res, &cy_auto_diff_smooth[cur_idx + start_band], num_freq_bands - start_band, Q1 ); // (q_cy_auto_diff_smooth - Q1) + } + + /* Q adjustment */ + *q_cy_auto_diff_smooth = sub( *q_cy_auto_diff_smooth, Q1 ); + move16(); + + return; +} +#endif + + static void computeTargetPSDs_diffuse( const int16_t num_channels, const int16_t num_freq_bands, @@ -4128,6 +4357,35 @@ static void computeTargetPSDs_diffuse( } +#ifdef IVAS_FLOAT_FIXED +static void computeTargetPSDs_diffuse_subframe_fx( + const Word16 num_channels, + const Word16 num_freq_bands, + const Word16 start_band, + const Word32 *diffuse_power_factor, + const Word32 *reference_power, + const Word32 *diffuse_responses_square, + Word32 *cy_auto_diff_smooth ) +{ + Word16 ch_idx, cur_idx; + Word32 diffuse_power[CLDFB_NO_CHANNELS_MAX]; /* segment auxiliary buffer; size: num_freq_bands. */ + + /* estimate direct and diffuse power */ + v_mult_fixed( diffuse_power_factor, reference_power, diffuse_power, num_freq_bands ); + + /* compute target auto and cross PSDs of current frame (smoothed) */ + FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + { + cur_idx = imult1616( ch_idx, num_freq_bands ); + + v_multc_fixed( &diffuse_power[start_band], diffuse_responses_square[ch_idx], &cy_auto_diff_smooth[cur_idx + start_band], num_freq_bands - start_band ); + } + + return; +} +#endif + + static void computeTargetPSDs_diffuse_subframe( const int16_t num_channels, const int16_t num_freq_bands, @@ -4155,6 +4413,57 @@ static void computeTargetPSDs_diffuse_subframe( } +#ifdef IVAS_FLOAT_FIXED +static void computeTargetPSDs_diffuse_with_onsets_fx( + const Word16 num_channels, + const Word16 num_freq_bands, + const Word16 num_decorr_freq_bands, + const Word16 *proto_frame_diff_index, + const Word32 *diffuse_power_factor, + const Word32 *reference_power, + const Word16 *q_reference_power, + const Word32 *diffuse_responses_square, + const Word32 *onset_filter, + Word32 *cy_auto_diff_smooth, + Word16 *q_cy_auto_diff_smooth ) +{ + Word16 ch_idx, cur_idx, diff_idx; + Word32 diffuse_response_p4, aux_buffer_res1[CLDFB_NO_CHANNELS_MAX]; + /* segment auxiliary buffer */ + Word32 diffuse_power[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ + Word32 aux_buffer_res[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ + + /* estimate direct and diffuse power */ + v_mult_fixed( diffuse_power_factor, reference_power, diffuse_power, num_decorr_freq_bands ); // (Q31, q_reference_power) -> q_reference_power + + /* compute target auto and cross PSDs of current frame (smoothed) */ + FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + { + diffuse_response_p4 = Mpy_32_32( diffuse_responses_square[ch_idx], diffuse_responses_square[ch_idx] ); // (Q31, Q31) -> Q31 + + cur_idx = imult1616( ch_idx, num_freq_bands ); + diff_idx = imult1616( proto_frame_diff_index[ch_idx], num_freq_bands ); + + v_multc_fixed( &onset_filter[diff_idx], diffuse_responses_square[ch_idx], aux_buffer_res1, num_decorr_freq_bands ); // (Q30, Q31) -> Q30 + v_multc_fixed( &onset_filter[diff_idx], INT_MIN, aux_buffer_res, num_decorr_freq_bands ); // (Q30, Q31) -> Q30 + v_addc_fixed( aux_buffer_res, ONE_IN_Q30, aux_buffer_res, num_decorr_freq_bands ); // Q30 + v_multc_fixed( aux_buffer_res, diffuse_response_p4, aux_buffer_res, num_decorr_freq_bands ); // (Q30, Q31) -> Q30 + v_add_fixed( aux_buffer_res1, aux_buffer_res, aux_buffer_res, num_decorr_freq_bands, 0 ); // Q30 + v_mult_fixed( aux_buffer_res, diffuse_power, aux_buffer_res, num_decorr_freq_bands ); // (Q30, q_reference_power) -> q_reference_power - Q1 + Scale_sig32( aux_buffer_res, num_decorr_freq_bands, sub( *q_cy_auto_diff_smooth, sub( *q_reference_power, Q1 ) ) ); // q_cy_auto_diff_smooth + v_add_fixed( &cy_auto_diff_smooth[cur_idx], aux_buffer_res, &cy_auto_diff_smooth[cur_idx], num_decorr_freq_bands, Q1 ); // (q_cy_auto_diff_smooth - Q1) + Scale_sig32( &cy_auto_diff_smooth[cur_idx + num_decorr_freq_bands], sub( num_freq_bands, num_decorr_freq_bands ), negate( Q1 ) ); // (q_cy_auto_diff_smooth - Q1) + } + + /* Q adjustment */ + *q_cy_auto_diff_smooth = sub( *q_cy_auto_diff_smooth, Q1 ); + move16(); + + return; +} +#endif + + static void computeTargetPSDs_diffuse_with_onsets( const int16_t num_channels, const int16_t num_freq_bands, diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 623c434e2..9fa8f3960 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -1440,6 +1440,9 @@ ivas_error ivas_dirac_alloc_mem( /* PSD related buffers */ hDirAC_mem->cy_auto_dir_smooth = NULL; +#ifdef IVAS_FLOAT_FIXED + hDirAC_mem->cy_auto_dir_smooth_fx = NULL; +#endif hDirAC_mem->proto_power_smooth = NULL; hDirAC_mem->proto_power_diff_smooth = NULL; hDirAC_mem->direct_responses_square = NULL; @@ -1454,6 +1457,13 @@ ivas_error ivas_dirac_alloc_mem( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } set_zero( hDirAC_mem->cy_auto_dir_smooth, size ); +#ifdef IVAS_FLOAT_FIXED + if ( ( hDirAC_mem->cy_auto_dir_smooth_fx = (Word32 *) malloc( sizeof( Word32 ) * size ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); + } + set_zero_fx( hDirAC_mem->cy_auto_dir_smooth_fx, size ); +#endif if ( ( hDirAC_mem->proto_power_smooth = (float *) malloc( sizeof( float ) * size ) ) == NULL ) { @@ -1491,6 +1501,11 @@ ivas_error ivas_dirac_alloc_mem( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth = hDirAC_mem->proto_power_smooth; hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth = hDirAC_mem->proto_power_diff_smooth; hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth = hDirAC_mem->cy_auto_dir_smooth; +#ifdef IVAS_FLOAT_FIXED + hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx = hDirAC_mem->cy_auto_dir_smooth_fx; + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth = 0; + move16(); +#endif hDirACRend->h_output_synthesis_psd_state.direct_responses_square = hDirAC_mem->direct_responses_square; #ifdef IVAS_FLOAT_FIXED hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx = hDirAC_mem->direct_responses_square_fx; @@ -1502,6 +1517,13 @@ ivas_error ivas_dirac_alloc_mem( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } set_zero( hDirAC_mem->cy_cross_dir_smooth, size ); +#ifdef IVAS_FLOAT_FIXED + if ( ( hDirAC_mem->cy_cross_dir_smooth_fx = (Word32 *) malloc( sizeof( Word32 ) * size_ho ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); + } + set_zero_fx( hDirAC_mem->cy_cross_dir_smooth_fx, size ); +#endif if ( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) { @@ -1510,6 +1532,13 @@ ivas_error ivas_dirac_alloc_mem( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } set_zero( hDirAC_mem->cy_auto_diff_smooth, size ); +#ifdef IVAS_FLOAT_FIXED + if ( ( hDirAC_mem->cy_auto_diff_smooth_fx = (Word32 *) malloc( sizeof( Word32 ) * size ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); + } + set_zero_fx( hDirAC_mem->cy_auto_diff_smooth_fx, size ); +#endif } else { @@ -1518,9 +1547,24 @@ ivas_error ivas_dirac_alloc_mem( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } set_zero( hDirAC_mem->cy_auto_diff_smooth, num_outputs_diff * num_freq_bands_diff ); +#ifdef IVAS_FLOAT_FIXED + if ( ( hDirAC_mem->cy_auto_diff_smooth_fx = (Word32 *) malloc( sizeof( Word32 ) * num_outputs_diff * num_freq_bands_diff ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); + } + set_zero_fx( hDirAC_mem->cy_auto_diff_smooth_fx, num_outputs_diff * num_freq_bands_diff ); +#endif } hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth = hDirAC_mem->cy_cross_dir_smooth; hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth = hDirAC_mem->cy_auto_diff_smooth; +#ifdef IVAS_FLOAT_FIXED + hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx = hDirAC_mem->cy_cross_dir_smooth_fx; + hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx = hDirAC_mem->cy_auto_diff_smooth_fx; + hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth = 0; + move16(); + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth = 0; + move16(); +#endif /*Responses (gains/factors)*/ if ( ( hDirAC_mem->direct_responses = (float *) malloc( sizeof( float ) * size_ho ) ) == NULL ) @@ -1617,6 +1661,10 @@ ivas_error ivas_dirac_alloc_mem( hDirAC_mem->reference_power = NULL; hDirAC_mem->onset_filter = NULL; +#ifdef IVAS_FLOAT_FIXED + hDirAC_mem->reference_power_fx = NULL; + hDirAC_mem->onset_filter_fx = NULL; +#endif if ( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) { if ( renderer_type != RENDERER_BINAURAL_PARAMETRIC && renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && renderer_type != RENDERER_STEREO_PARAMETRIC ) @@ -1625,12 +1673,24 @@ ivas_error ivas_dirac_alloc_mem( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } +#ifdef IVAS_FLOAT_FIXED + if ( ( hDirAC_mem->reference_power_fx = (Word32 *) malloc( sizeof( Word32 ) * 2 * num_freq_bands ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); + } +#endif if ( hDirACRend->proto_signal_decorr_on ) { if ( ( hDirAC_mem->onset_filter = (float *) malloc( sizeof( float ) * num_outputs_diff * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } +#ifdef IVAS_FLOAT_FIXED + if ( ( hDirAC_mem->onset_filter_fx = (Word32 *) malloc( sizeof( Word32 ) * num_outputs_diff * num_freq_bands ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); + } +#endif } } } @@ -1642,6 +1702,12 @@ ivas_error ivas_dirac_alloc_mem( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } +#ifdef IVAS_FLOAT_FIXED + if ( ( hDirAC_mem->reference_power_fx = (Word32 *) malloc( sizeof( Word32 ) * 5 * num_freq_bands ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); + } +#endif } if ( hDirACRend->proto_signal_decorr_on ) @@ -1650,6 +1716,12 @@ ivas_error ivas_dirac_alloc_mem( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } +#ifdef IVAS_FLOAT_FIXED + if ( ( hDirAC_mem->onset_filter_fx = (Word32 *) malloc( sizeof( Word32 ) * 2 * num_freq_bands ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); + } +#endif } } @@ -1670,6 +1742,10 @@ void ivas_dirac_free_mem_fx( { free(hDirAC_mem->cy_auto_dir_smooth); } + IF( hDirAC_mem->cy_auto_dir_smooth_fx != NULL ) + { + free( hDirAC_mem->cy_auto_dir_smooth_fx ); + } IF (hDirAC_mem->proto_power_smooth != NULL) { free(hDirAC_mem->proto_power_smooth); @@ -1694,10 +1770,18 @@ void ivas_dirac_free_mem_fx( { free(hDirAC_mem->cy_cross_dir_smooth); } + IF( hDirAC_mem->cy_cross_dir_smooth_fx != NULL ) + { + free( hDirAC_mem->cy_cross_dir_smooth_fx ); + } IF (hDirAC_mem->cy_auto_diff_smooth != NULL) { free(hDirAC_mem->cy_auto_diff_smooth); } + IF( hDirAC_mem->cy_auto_diff_smooth_fx != NULL ) + { + free( hDirAC_mem->cy_auto_diff_smooth_fx ); + } IF (hDirAC_mem->direct_responses != NULL) { free(hDirAC_mem->direct_responses); @@ -1734,6 +1818,14 @@ void ivas_dirac_free_mem_fx( { free(hDirAC_mem->onset_filter); } + IF (hDirAC_mem->reference_power_fx != NULL) + { + free(hDirAC_mem->reference_power_fx); + } + IF (hDirAC_mem->onset_filter_fx != NULL) + { + free(hDirAC_mem->onset_filter_fx); + } return; } @@ -3516,7 +3608,12 @@ static void ivas_masa_ext_dirac_render_sf( } } +#ifdef IVAS_FLOAT_FIXED + ivas_dirac_dec_output_synthesis_get_interpolator_fx( &hDirACRend->h_output_synthesis_psd_params, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); + fixedToFloat_arr( hDirACRend->h_output_synthesis_psd_params.interpolator_fx, hDirACRend->h_output_synthesis_psd_params.interpolator, Q15, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); +#else ivas_dirac_dec_output_synthesis_get_interpolator( &hDirACRend->h_output_synthesis_psd_params, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); +#endif if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index d588bb708..beb5277a3 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -2107,7 +2107,7 @@ ivas_error ivas_reverb_open( } for (int i = 0; i < 64; i++) { - pCoeffs_fx[i] = pCoeffs[i] * ( 1 << 14); + pCoeffs_fx[i] = (Word16)(pCoeffs[i] * ( 1 << 14)); } if ( ( error = compute_t60_coeffs_fx( ¶ms, nr_fc_fft_filter, output_Fs ) ) != IVAS_ERR_OK ) { diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 9bb629f03..3de047271 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -284,9 +284,18 @@ typedef struct dirac_dec_stack_mem float *cy_auto_dir_smooth; float *cy_cross_dir_smooth; float *cy_auto_diff_smooth; +#ifdef IVAS_FLOAT_FIXED + Word32 *cy_auto_dir_smooth_fx; + Word32 *cy_cross_dir_smooth_fx; + Word32 *cy_auto_diff_smooth_fx; +#endif float *reference_power; float *onset_filter; +#ifdef IVAS_FLOAT_FIXED + Word32 *reference_power_fx; + Word32 *onset_filter_fx; +#endif } DIRAC_DEC_STACK_MEM, *DIRAC_DEC_STACK_MEM_HANDLE; @@ -301,7 +310,7 @@ typedef struct dirac_output_synthesis_params_structure float *alpha_synthesis; float *alpha_synthesis_fast; #ifdef IVAS_FLOAT_FIXED - Word16 *interpolator_fx; + Word16 *interpolator_fx; // Q15 Word16 *alpha_synthesis_fx; Word16 *alpha_synthesis_fast_fx; #endif @@ -313,8 +322,8 @@ typedef struct dirac_output_synthesis_params_structure float diffuse_compensation_factor; float diffuse_compensation_factor_decorr; #ifdef IVAS_FLOAT_FIXED - Word16 diffuse_compensation_factor_fx; - Word16 diffuse_compensation_factor_decorr_fx; + Word32 diffuse_compensation_factor_fx; // Q27 + Word32 diffuse_compensation_factor_decorr_fx; // Q29 #endif } DIRAC_OUTPUT_SYNTHESIS_PARAMS; @@ -366,14 +375,15 @@ typedef struct dirac_output_synthesis_state_structure Word16 direct_responses_q; Word32 *direct_responses_square_fx; Word16 direct_responses_square_q; - Word16 *diffuse_responses_square_fx; /* squared diffuse responses. Size: num_channels. */ + Word32 *diffuse_responses_square_fx; /* squared diffuse responses. Size: num_channels. */ + Word16 diffuse_responses_square_q; /* only pointer to local buffers */ Word32 *direct_power_factor_fx; Word32 *diffuse_power_factor_fx; - - Word16 Q_direct_power_factor; - Word16 Q_diffuse_power_factor; + + Word16 direct_power_factor_q; + Word16 diffuse_power_factor_q; Word16 *proto_power_smooth_fx; /* Smoothed power of the prototype signals. Size: num_freq_bands*num_channels. */ Word16 *proto_power_smooth_prev_fx; /* Smoothed power of the prototype signals of the previous synthesis block. Size: num_freq_bands*num_channels. */ @@ -390,14 +400,18 @@ typedef struct dirac_output_synthesis_state_structure Word16 *gains_diff_prev_fx; /* Diffuse sound gains of previous synthesis block. Size: num_freq_bands*num_channel. */ /* only pointer to local buffers */ - Word16 *cy_auto_dir_smooth_fx; /* Target auto PSD of direct sound. Size: num_freq_bands*num_channels. */ - Word16 *cy_cross_dir_smooth_fx; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ - Word16 *cy_auto_diff_smooth_fx; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ + Word32 *cy_auto_dir_smooth_fx; /* Target auto PSD of direct sound. Size: num_freq_bands*num_channels. */ + Word32 *cy_cross_dir_smooth_fx; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ + Word32 *cy_auto_diff_smooth_fx; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ + + Word16 q_cy_auto_dir_smooth; /* Target auto PSD of direct sound. Size: num_freq_bands*num_channels. */ + Word16 q_cy_cross_dir_smooth; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ + Word16 q_cy_auto_diff_smooth; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ /* PSD memories */ - Word16 *cy_auto_dir_smooth_prev_fx; /* Target auto PSD of direct sound of previous synthesis block. Size: num_freq_bands*num_channels. */ - Word16 *cy_cross_dir_smooth_prev_fx; /* Target cross PSD of direct sound of previous synthesis block. Size: num_freq_bands*num_channels. */ - Word16 *cy_auto_diff_smooth_prev_fx; /* Target auto PSD of diffuse sound of previous synthesis block. Size: num_freq_bands*num_channels. */ + Word32 *cy_auto_dir_smooth_prev_fx; /* Target auto PSD of direct sound of previous synthesis block. Size: num_freq_bands*num_channels. */ + Word32 *cy_cross_dir_smooth_prev_fx; /* Target cross PSD of direct sound of previous synthesis block. Size: num_freq_bands*num_channels. */ + Word32 *cy_auto_diff_smooth_prev_fx; /* Target auto PSD of diffuse sound of previous synthesis block. Size: num_freq_bands*num_channels. */ const Word16 *onset_filter_fx; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 21bb1e7fc..4cfac7946 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -3961,7 +3961,7 @@ static ivas_error initSbaPanGainsForMcOut( ivas_output_init( &hOutSetup, outConfig ); break; case IVAS_AUDIO_CONFIG_LS_CUSTOM: - ivas_ls_custom_setup( &hOutSetup, outSetupCustom ); + ivas_ls_custom_setup( &hOutSetup, (LSSETUP_CUSTOM_STRUCT *)outSetupCustom ); break; default: assert( !"Invalid speaker config" ); @@ -10417,12 +10417,12 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( set_f( hDirACRend->frequency_axis, 0.0f, hSpatParamRendCom->num_freq_bands ); #ifdef IVAS_FLOAT_FIXED - hDirACRend->frequency_axis_fx = (Word16 *)malloc(hSpatParamRendCom->num_freq_bands * sizeof(Word16)); - ivas_dirac_dec_get_frequency_axis_fx(hDirACRend->frequency_axis_fx, output_Fs, hSpatParamRendCom->num_freq_bands ); + hDirACRend->frequency_axis_fx = (Word16 *) malloc( hSpatParamRendCom->num_freq_bands * sizeof( Word16 ) ); + ivas_dirac_dec_get_frequency_axis_fx( hDirACRend->frequency_axis_fx, output_Fs, hSpatParamRendCom->num_freq_bands ); FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) { - hDirACRend->frequency_axis[i] = (float)hDirACRend->frequency_axis_fx[i]; + hDirACRend->frequency_axis[i] = (float) hDirACRend->frequency_axis_fx[i]; } #else ivas_dirac_dec_get_frequency_axis( hDirACRend->frequency_axis, output_Fs, hSpatParamRendCom->num_freq_bands ); @@ -10551,6 +10551,12 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( } /* direct/diffuse responses */ +#ifdef IVAS_FLOAT_FIXED + IF( ( hDirACRend->diffuse_response_function_fx = (Word16 *) malloc( sizeof( Word16 ) * hDirACRend->num_outputs_dir ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); + } +#endif if ( ( hDirACRend->diffuse_response_function = (float *) malloc( sizeof( float ) * hDirACRend->num_outputs_dir ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); @@ -10558,13 +10564,31 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( if ( ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_LS ) || ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_SHD ) || ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_MONO ) ) { +#ifdef IVAS_FLOAT_FIXED + initDiffuseResponses_fx( hDirACRend->diffuse_response_function_fx, nchan_out_woLFE, hDirACRend->hOutSetup.output_config, + hDirACRend->hOutSetup, hDirACRend->hOutSetup.ambisonics_order, MASA_FORMAT, &hDirACRend->num_ele_spk_no_diffuse_rendering, IVAS_AUDIO_CONFIG_INVALID ); + FOR( i = 0; i < hDirACRend->num_outputs_dir; i++ ) + { + hDirACRend->diffuse_response_function[i] = fix16_to_float( hDirACRend->diffuse_response_function_fx[i], Q15 ); + } +#else initDiffuseResponses( hDirACRend->diffuse_response_function, nchan_out_woLFE, hDirACRend->hOutSetup.output_config, hDirACRend->hOutSetup, hDirACRend->hOutSetup.ambisonics_order, MASA_FORMAT, &hDirACRend->num_ele_spk_no_diffuse_rendering, IVAS_AUDIO_CONFIG_INVALID ); +#endif } else { +#ifdef IVAS_FLOAT_FIXED + initDiffuseResponses_fx( hDirACRend->diffuse_response_function_fx, hDirACRend->num_outputs_dir, IVAS_AUDIO_CONFIG_FOA, + hDirACRend->hOutSetup, hDirACRend->hOutSetup.ambisonics_order, MASA_FORMAT, &hDirACRend->num_ele_spk_no_diffuse_rendering, IVAS_AUDIO_CONFIG_INVALID ); + FOR( i = 0; i < hDirACRend->num_outputs_dir; i++ ) + { + hDirACRend->diffuse_response_function[i] = fix16_to_float( hDirACRend->diffuse_response_function_fx[i], Q15 ); + } +#else initDiffuseResponses( hDirACRend->diffuse_response_function, hDirACRend->num_outputs_dir, IVAS_AUDIO_CONFIG_FOA, hDirACRend->hOutSetup, hDirACRend->hOutSetup.ambisonics_order, MASA_FORMAT, &hDirACRend->num_ele_spk_no_diffuse_rendering, IVAS_AUDIO_CONFIG_INVALID ); +#endif } hDirACRend->hoa_encoder = NULL; @@ -10634,6 +10658,7 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( if ( hDirACRend->proto_signal_decorr_on ) { #ifdef IVAS_FLOAT_FIXED + hDirACRend->frequency_axis[i] = (float)hDirACRend->frequency_axis_fx[i]; if ( ( error = ivas_dirac_dec_decorr_open_fx( &( hDirACRend->h_freq_domain_decorr_ap_params ), &( hDirACRend->h_freq_domain_decorr_ap_state ), hSpatParamRendCom->num_freq_bands, @@ -10665,10 +10690,17 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( } /* output synthesis */ +#ifdef IVAS_FLOAT_FIXED + if ( ( ivas_dirac_dec_output_synthesis_open_fx( hSpatParamRendCom, hDirACRend, RENDERER_DIRAC, nchan_transport, output_Fs, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } +#else if ( ( ivas_dirac_dec_output_synthesis_open( hSpatParamRendCom, hDirACRend, RENDERER_DIRAC, nchan_transport, output_Fs, 0 ) ) != IVAS_ERR_OK ) { return error; } +#endif hDirACRend->h_output_synthesis_psd_params.use_onset_filters = hDirACRend->proto_signal_decorr_on; if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_SHD || hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) @@ -10826,7 +10858,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( for ( int i = 0; i < nBins; i++ ) { - frequency_axis[i] = (float)frequency_axis_fx[i]; + frequency_axis[i] = (float) frequency_axis_fx[i]; } if ( ( error = ivas_dirac_dec_decorr_open_fx( &( hDiracDecBin->h_freq_domain_decorr_ap_params ), &( hDiracDecBin->h_freq_domain_decorr_ap_state ), -- GitLab From ce8071db3030dbf732e2842acb141479d0a494e1 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 11 Apr 2024 22:41:16 +0530 Subject: [PATCH 2/2] Makefile change revert --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ef8fa2d3a..311cb8b9b 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ endif # C compiler flags CFLAGS += -std=c99 -pedantic -Wcast-qual -Wall -W -Wextra -Wno-long-long \ - -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wconversion \ + -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \ -Werror-implicit-function-declaration \ -Wno-implicit-fallthrough -ffp-contract=off -- GitLab