From af9f344159a8b34f2d918ce189347924beb19857 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 27 May 2024 13:59:42 +0530 Subject: [PATCH] High MLD fix for MASA, Float code cleanup [x] High MLD fix for MASA format in negative 10dB input case [x] Float code cleanup in ivas_init_dec.c, ivas_mc_dec_reconfig, ivas_dirac_dec_render_sf [x] Fix for LTV crash issue for 10dB case: stereo at 24.4 kbps, 32kHz in, 32kHz out, DTX on --- apps/decoder.c | 2 +- lib_com/float_to_fix_ops.c | 453 +--------- lib_com/ivas_prot_fx.h | 12 + lib_com/ivas_sba_config.c | 10 +- lib_com/prot_fx2.h | 4 - lib_dec/acelp_core_dec_ivas_fx.c | 76 +- lib_dec/core_dec_init_fx.c | 7 +- lib_dec/igf_dec_fx.c | 4 +- lib_dec/ivas_core_dec.c | 115 ++- lib_dec/ivas_corecoder_dec_reconfig.c | 2 +- lib_dec/ivas_cpe_dec_fx.c | 2 +- lib_dec/ivas_dirac_dec.c | 103 +-- lib_dec/ivas_init_dec.c | 903 ++++++++++++++----- lib_dec/ivas_jbm_dec.c | 43 - lib_dec/ivas_mc_paramupmix_dec.c | 14 - lib_dec/ivas_mct_dec.c | 682 ++------------ lib_dec/ivas_omasa_dec.c | 9 - lib_dec/ivas_osba_dec.c | 15 +- lib_dec/ivas_sba_dec.c | 8 - lib_dec/ivas_sce_dec_fx.c | 2 +- lib_dec/ivas_stat_dec.h | 6 +- lib_dec/lib_dec_fx.c | 11 +- lib_dec/swb_tbe_dec.c | 14 +- lib_enc/ivas_lfe_enc.c | 3 + lib_rend/ivas_dirac_dec_binaural_functions.c | 8 +- lib_rend/ivas_dirac_decorr_dec.c | 30 +- lib_rend/ivas_dirac_output_synthesis_dec.c | 8 +- lib_rend/ivas_dirac_rend.c | 37 +- lib_rend/ivas_hrtf.c | 18 +- lib_rend/ivas_prot_rend.h | 5 + lib_rend/ivas_rotation.c | 18 +- lib_rend/ivas_stat_rend.h | 61 +- lib_rend/lib_rend.c | 8 +- lib_util/hrtf_file_reader.c | 9 +- 34 files changed, 957 insertions(+), 1745 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 5c7bf1765..5c2c1e9ce 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -452,7 +452,7 @@ int main( { renderConfig.directivity_fx[i * 3] = (Word16) ( renderConfig.directivity[i * 3] * ( 1u << 6 ) ); renderConfig.directivity_fx[i * 3 + 1] = (Word16) ( renderConfig.directivity[i * 3 + 1] * ( 1u << 6 ) ); - renderConfig.directivity_fx[i * 3 + 2] = (Word16) ( renderConfig.directivity[i * 3 + 2] * ( 1u << 15 ) ); + renderConfig.directivity_fx[i * 3 + 2] = (Word16) ( renderConfig.directivity[i * 3 + 2] * ( (1u << 15)-1 ) ); } #endif // IVAS_FLOAT_FIXED diff --git a/lib_com/float_to_fix_ops.c b/lib_com/float_to_fix_ops.c index 41d1d6b2f..cc820e04e 100644 --- a/lib_com/float_to_fix_ops.c +++ b/lib_com/float_to_fix_ops.c @@ -310,69 +310,21 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( ( st->idchan == 1 && st->element_mode == IVAS_CPE_MDCT && last_element_mode != IVAS_CPE_MDCT ); if ( reconf ) { - - //H_IGF_GRID hGrid; - //IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData; - //hPrivateData = &st->hIGFDec->igfData; - //H_IGF_INFO hIGFInfo = &hPrivateData->igfInfo; - //ACELP_config *pConfigAcelp = &( st->acelp_cfg ); - Word16 i = 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_pst_old_syn = 0, - //delay_comp = 0; + Word16 Q_cldfbAna_cldfb_state = 0, Q_cldfbBPF_cldfb_state = 0, Q_cldfbSyn_cldfb_state = 0, Q_cldfbSynHB_cldfb_state = 0;//, if ( tofix ) { - //hGrid = &hIGFInfo->grid[IGF_GRID_LB_NORM]; - //floatToFixed_arr( &hGrid->whiteningThreshold_flt[0][0], &hGrid->whiteningThreshold[0][0], 13, IGF_MAX_TILES * 2 ); - //hGrid->gFactor = (Word16) floatToFixed( hGrid->gFactor_flt, 14 ); - //hGrid->fFactor = (Word16) floatToFixed( hGrid->fFactor_flt, 14 ); - //hGrid->lFactor = (Word16) floatToFixed( hGrid->lFactor_flt, 14 ); - //hGrid = &hIGFInfo->grid[IGF_GRID_LB_TRAN]; - //floatToFixed_arr( &hGrid->whiteningThreshold_flt[0][0], &hGrid->whiteningThreshold[0][0], 13, IGF_MAX_TILES * 2 ); - //hGrid->gFactor = (Word16) floatToFixed( hGrid->gFactor_flt, 14 ); - //hGrid->fFactor = (Word16) floatToFixed( hGrid->fFactor_flt, 14 ); - //hGrid->lFactor = (Word16) floatToFixed( hGrid->lFactor_flt, 14 ); - //hGrid = &hIGFInfo->grid[IGF_GRID_LB_SHORT]; - //floatToFixed_arr( &hGrid->whiteningThreshold_flt[0][0], &hGrid->whiteningThreshold[0][0], 13, IGF_MAX_TILES * 2 ); - //hGrid->gFactor = (Word16) floatToFixed( hGrid->gFactor_flt, 14 ); - //hGrid->fFactor = (Word16) floatToFixed( hGrid->fFactor_flt, 14 ); - //hGrid->lFactor = (Word16) floatToFixed( hGrid->lFactor_flt, 14 ); - //delay_comp = NS2SA_fx2( st->output_Fs, DELAY_CLDFB_NS ); /*CLDFB delay*/ - //st->sr_core = getCoreSamplerateMode2( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->flag_ACELP16k, st->rf_flag, st->is_ism_format ); - //st->L_frame = extract_l( Mult_32_16( st->sr_core, 0x0290 ) ); IF( st->hTcxDec ) { - //st->hTcxDec->Q_old_syn_Overl = Q_factor_arr( st->hTcxDec->old_syn_Overl_float, L_FRAME32k / 2 ) - 1; - //st->hTcxDec->Q_syn_Overl_TDAC = Q_factor_arr( st->hTcxDec->syn_Overl_TDAC_float, L_FRAME32k / 2 ) - 1; - //st->hTcxDec->Q_syn_Overl = Q_factor_arr( st->hTcxDec->syn_Overl_float, L_FRAME32k / 2 ) - 1; - //st->hTcxDec->Q_syn_Overl_TDACFB = Q_factor_arr( st->hTcxDec->syn_Overl_TDACFB_float, L_FRAME32k / 2 ); - //st->hTcxDec->Q_syn_OverlFB = Q_factor_arr( st->hTcxDec->syn_OverlFB_float, L_FRAME_MAX / 2 ); - //Q_old_synth = Q_syn; - //Q_synth_history = Q_factor_arr( st->hTcxDec->synth_history, L_PROT48k + L_FRAME_MAX ); - //floatToFixed_arr( st->hTcxDec->old_syn_Overl_float, st->hTcxDec->old_syn_Overl, st->hTcxDec->Q_old_syn_Overl, L_FRAME32k / 2 ); - //floatToFixed_arr( st->hTcxDec->syn_Overl_TDAC_float, st->hTcxDec->syn_Overl_TDAC, st->hTcxDec->Q_syn_Overl_TDAC, L_FRAME32k / 2 ); - //floatToFixed_arr( st->hTcxDec->syn_Overl_float, st->hTcxDec->syn_Overl, st->hTcxDec->Q_syn_Overl, L_FRAME32k / 2 ); - //floatToFixed_arr( st->hTcxDec->syn_Overl_TDACFB_float, st->hTcxDec->syn_Overl_TDACFB, st->hTcxDec->Q_syn_Overl_TDACFB, L_FRAME_MAX / 2 ); - //floatToFixed_arr( st->hTcxDec->syn_OverlFB_float, st->hTcxDec->syn_OverlFB, st->hTcxDec->Q_syn_OverlFB, L_FRAME_MAX / 2 ); - //floatToFixed_arr( st->hTcxDec->old_synth_float, st->hTcxDec->old_synth, Q_old_synth, OLD_SYNTH_INTERNAL_DEC ); - //floatToFixed_arr( st->hTcxDec->synth_history, st->hTcxDec->synth_history_fx, Q_synth_history, L_PROT48k + L_FRAME_MAX ); st->hTcxDec->L_frameTCX = extract_l( Mult_32_16( st->output_Fs, 0x0290 ) ); - //st->hTcxDec->tcxltp_last_gain_unmodified = (Word16) floatToFixed( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 ); st->output_frame_fx = st->hTcxDec->L_frameTCX; - //st->hTcxDec->CngLevelBackgroundTrace_bfi_fx = floatToFixed( st->hTcxDec->CngLevelBackgroundTrace_bfi, 15 ); - //st->hTcxDec->conCngLevelBackgroundTrace = floatToFixed( st->hTcxDec->CngLevelBackgroundTrace_bfi, 15 ); - //st->hTcxDec->conceal_eof_gain = (Word16) floatToFixed( st->hTcxDec->conceal_eof_gain_float, 14 ); } IF( st->hHQ_core ) { //st->hHQ_core->Q_old_out = Q_factor_arr( st->hHQ_core->old_out, L_FRAME48k ); //st->hHQ_core->Q_old_outLB = Q_factor_arr( st->hHQ_core->old_outLB, L_FRAME32k ); st->hHQ_core->Q_fer_samples = 0; - //floatToFixed_arr( st->hHQ_core->old_out, st->hHQ_core->old_out_fx, st->hHQ_core->Q_old_out, L_FRAME48k ); - //floatToFixed_arr( st->hHQ_core->old_outLB, st->hHQ_core->old_out_LB_fx, st->hHQ_core->Q_old_outLB, L_FRAME32k ); } IF( st->cldfbAna ) { @@ -394,76 +346,10 @@ 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 ); } - - IF( st->hTcxLtpDec ) - { - //Q_tcxltp_mem_in = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_in_float, TCXLTP_MAX_DELAY ); - //Q_tcxltp_mem_out = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_out_float, L_FRAME48k ); - //floatToFixed_arr( st->hTcxLtpDec->tcxltp_mem_in_float, st->hTcxLtpDec->tcxltp_mem_in, Q_tcxltp_mem_in, TCXLTP_MAX_DELAY ); - //floatToFixed_arr( st->hTcxLtpDec->tcxltp_mem_out_float, st->hTcxLtpDec->tcxltp_mem_out, Q_tcxltp_mem_out, L_FRAME48k ); - } - - st->last_gain_syn_deemph = 0; - //IF( hBWE_TD ) - //{ - // 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 ); - //} } else { - //hGrid = &hIGFInfo->grid[IGF_GRID_LB_NORM]; - //fixedToFloat_arr( &hGrid->whiteningThreshold[0][0], &hGrid->whiteningThreshold_flt[0][0], 13, IGF_MAX_TILES * 2 ); - //hGrid->gFactor_flt = fixedToFloat( hGrid->gFactor, 14 ); - //hGrid->fFactor_flt = fixedToFloat( hGrid->fFactor, 14 ); - //hGrid->lFactor_flt = fixedToFloat( hGrid->lFactor, 14 ); - //hGrid = &hIGFInfo->grid[IGF_GRID_LB_TRAN]; - //fixedToFloat_arr( &hGrid->whiteningThreshold[0][0], &hGrid->whiteningThreshold_flt[0][0], 13, IGF_MAX_TILES * 2 ); - //hGrid->gFactor_flt = fixedToFloat( hGrid->gFactor, 14 ); - //hGrid->fFactor_flt = fixedToFloat( hGrid->fFactor, 14 ); - //hGrid->lFactor_flt = fixedToFloat( hGrid->lFactor, 14 ); - //hGrid = &hIGFInfo->grid[IGF_GRID_LB_SHORT]; - //fixedToFloat_arr( &hGrid->whiteningThreshold[0][0], &hGrid->whiteningThreshold_flt[0][0], 13, IGF_MAX_TILES * 2 ); - //hGrid->gFactor_flt = fixedToFloat( hGrid->gFactor, 14 ); - //hGrid->fFactor_flt = fixedToFloat( hGrid->fFactor, 14 ); - //hGrid->lFactor_flt = fixedToFloat( hGrid->lFactor, 14 ); - //IF( st->hIGFDec ) - //{ - // //st->hIGFDec->virtualSpec_float = &st->hIGFDec->virtualSpecBuf[0]; - // //st->hIGFDec->igfData.pSpecFlat_float = &st->hIGFDec->igfData.pSpecFlatBuf[0]; - // //st->hIGFDec->igfData.igfInfo.nfSeed = &st->hIGFDec->igfData.igfInfo.nfSeedBuf[0]; - //} - //st->TcxBandwidth_float = fixedToFloat( st->TcxBandwidth, 15 ); - - //IF( st->hBWE_TD != NULL ) - //{ - // Q_syn_overlap = Q_factor_arr( hBWE_TD->syn_overlap, 20 ); - // fixedToFloat_arr( hBWE_TD->syn_overlap_fx, hBWE_TD->syn_overlap, Q_syn_overlap, 20 ); - //} - IF( st->hTcxDec ) - { - //Q_old_synth = Q_syn; - //Q_synth_history = Q_factor_arr( st->hTcxDec->synth_history, L_PROT48k + L_FRAME_MAX ); - //st->hTcxDec->Q_old_syn_Overl = Q_factor_arr( st->hTcxDec->old_syn_Overl_float, L_FRAME32k / 2 ) - 1; - //fixedToFloat_arr( st->hTcxDec->old_syn_Overl, st->hTcxDec->old_syn_Overl_float, st->hTcxDec->Q_old_syn_Overl, L_FRAME32k / 2 ); - //fixedToFloat_arr( st->hTcxDec->syn_Overl_TDAC, st->hTcxDec->syn_Overl_TDAC_float, st->hTcxDec->Q_syn_Overl_TDAC, 320 ); - //fixedToFloat_arr( st->hTcxDec->syn_Overl, st->hTcxDec->syn_Overl_float, st->hTcxDec->Q_syn_Overl, 320 ); - //fixedToFloat_arr( st->hTcxDec->syn_Overl_TDACFB, st->hTcxDec->syn_Overl_TDACFB_float, st->hTcxDec->Q_syn_Overl_TDACFB, 480 ); - //fixedToFloat_arr( st->hTcxDec->syn_OverlFB, st->hTcxDec->syn_OverlFB_float, st->hTcxDec->Q_syn_OverlFB, 480 ); - //fixedToFloat_arr( st->hTcxDec->old_synth, st->hTcxDec->old_synth_float, Q_old_synth, OLD_SYNTH_INTERNAL_DEC ); - //fixedToFloat_arr( st->hTcxDec->synth_history_fx, st->hTcxDec->synth_history, Q_synth_history, L_PROT48k + L_FRAME_MAX ); - //st->hTcxDec->q_synth_history_fx = Q_synth_history; - //st->hTcxDec->conceal_eof_gain_float = fixedToFloat( st->hTcxDec->conceal_eof_gain, 14 ); - //st->hTcxDec->CngLevelBackgroundTrace_bfi = fixedToFloat( st->hTcxDec->CngLevelBackgroundTrace_bfi_fx, 15 ); - //st->hTcxDec->CngLevelBackgroundTrace_bfi = fix16_to_float( st->hTcxDec->conCngLevelBackgroundTrace,15-st->hTcxDec->conCngLevelBackgroundTrace_e ); - } - - IF( st->hHQ_core ) - { - //fixedToFloat_arr( st->hHQ_core->old_out_fx, st->hHQ_core->old_out, st->hHQ_core->Q_old_out, L_FRAME48k ); - //fixedToFloat_arr( st->hHQ_core->old_out_LB_fx, st->hHQ_core->old_outLB, st->hHQ_core->Q_old_outLB, L_FRAME32k ); - } IF( st->cldfbAna ) { Q_cldfbAna_cldfb_state = Q_factor_arrL( st->cldfbAna->cldfb_state, st->cldfbAna->cldfb_state_length ) - 1; @@ -484,21 +370,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; fixedToFloat_arrL( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->cldfb_state, Q_cldfbSynHB_cldfb_state, st->cldfbSynHB->cldfb_state_length ); } - - IF( st->hTcxLtpDec != NULL ) - { - //Q_tcxltp_mem_in = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_in_float, TCXLTP_MAX_DELAY ); - //Q_tcxltp_mem_out = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_out_float, L_FRAME48k ); - //fixedToFloat_arr( st->hTcxLtpDec->tcxltp_mem_in, st->hTcxLtpDec->tcxltp_mem_in_float, Q_tcxltp_mem_in, TCXLTP_MAX_DELAY ); - //fixedToFloat_arr( st->hTcxLtpDec->tcxltp_mem_out, st->hTcxLtpDec->tcxltp_mem_out_float, Q_tcxltp_mem_out, L_FRAME48k ); - } - IF( st->hTonalMDCTConc ) - { - FOR( i = 0; i < FDNS_NPTS; i++ ) - { - //st->hTonalMDCTConc->scaleFactorsBackground_flt[i] = fixedToFloat( st->hTonalMDCTConc->scaleFactorsBackground[i], 15 ); - } - } } } } @@ -509,390 +380,70 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( Word16 last_element_mode, const FRAME_MODE frameMode) { - TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec; - TCX_DEC_HANDLE hTcxDec = st->hTcxDec; - Word16 i = 0; //bfi = 0; - UNUSED_PARAM(frameMode); - //IF(EQ_32(frameMode, FRAMEMODE_NORMAL)) - //{ - // bfi = 0; - //} - - //IF(EQ_32(frameMode, FRAMEMODE_MISSING)) - //{ - // bfi = 1; - //} bool reconf = ( st->bits_frame_nominal != st->last_bits_frame_nominal ) || ( st->bwidth != st->last_bwidth ) || ( st->last_core != TCX_20_CORE && st->last_core != TCX_10_CORE && !( st->prev_bfi == 1 && st->last_core == ACELP_CORE && st->last_con_tcx == 1 ) ) || ( st->idchan == 1 && st->element_mode == IVAS_CPE_MDCT && last_element_mode != IVAS_CPE_MDCT ); if ( reconf ) { - - //H_IGF_GRID hGrid; - //IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData; - //hPrivateData = &st->hIGFDec->igfData; - //H_IGF_INFO hIGFInfo = &hPrivateData->igfInfo; - //ACELP_config *pConfigAcelp = &( st->acelp_cfg ); - Word16 /*i = 0,*/ - /* Q_syn = 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_pst_old_syn = 0, - //delay_comp = 0; + Word16 Q_cldfbSynHB_cldfb_state = 0;//, if ( tofix ) { - //hGrid = &hIGFInfo->grid[IGF_GRID_LB_NORM]; - //floatToFixed_arr( &hGrid->whiteningThreshold_flt[0][0], &hGrid->whiteningThreshold[0][0], 13, IGF_MAX_TILES * 2 ); - //hGrid->gFactor = (Word16) floatToFixed( hGrid->gFactor_flt, 14 ); - //hGrid->fFactor = (Word16) floatToFixed( hGrid->fFactor_flt, 14 ); - //hGrid->lFactor = (Word16) floatToFixed( hGrid->lFactor_flt, 14 ); - //hGrid = &hIGFInfo->grid[IGF_GRID_LB_TRAN]; - //floatToFixed_arr( &hGrid->whiteningThreshold_flt[0][0], &hGrid->whiteningThreshold[0][0], 13, IGF_MAX_TILES * 2 ); - //hGrid->gFactor = (Word16) floatToFixed( hGrid->gFactor_flt, 14 ); - //hGrid->fFactor = (Word16) floatToFixed( hGrid->fFactor_flt, 14 ); - //hGrid->lFactor = (Word16) floatToFixed( hGrid->lFactor_flt, 14 ); - //hGrid = &hIGFInfo->grid[IGF_GRID_LB_SHORT]; - //floatToFixed_arr( &hGrid->whiteningThreshold_flt[0][0], &hGrid->whiteningThreshold[0][0], 13, IGF_MAX_TILES * 2 ); - //hGrid->gFactor = (Word16) floatToFixed( hGrid->gFactor_flt, 14 ); - //hGrid->fFactor = (Word16) floatToFixed( hGrid->fFactor_flt, 14 ); - //hGrid->lFactor = (Word16) floatToFixed( hGrid->lFactor_flt, 14 ); - //delay_comp = NS2SA_fx2( st->output_Fs, DELAY_CLDFB_NS ); /*CLDFB delay*/ - //st->sr_core = getCoreSamplerateMode2( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->flag_ACELP16k, st->rf_flag, st->is_ism_format ); - //st->L_frame = extract_l( Mult_32_16( st->sr_core, 0x0290 ) ); - //Q_syn = 0; IF( st->hTcxDec ) { - //st->hTcxDec->Q_old_syn_Overl = 0; - //st->hTcxDec->Q_syn_Overl_TDAC = 0; - //st->hTcxDec->Q_syn_Overl = 0; - //st->hTcxDec->Q_syn_Overl_TDACFB = 0; - //st->hTcxDec->Q_syn_OverlFB = 0; - //Q_old_synth = 0; - //floatToFixed_arr( st->hTcxDec->old_syn_Overl_float, st->hTcxDec->old_syn_Overl, st->hTcxDec->Q_old_syn_Overl, L_FRAME32k / 2 ); - //floatToFixed_arr( st->hTcxDec->syn_Overl_TDAC_float, st->hTcxDec->syn_Overl_TDAC, st->hTcxDec->Q_syn_Overl_TDAC, L_FRAME32k / 2 ); - //floatToFixed_arr( st->hTcxDec->syn_Overl_float, st->hTcxDec->syn_Overl, st->hTcxDec->Q_syn_Overl, L_FRAME32k / 2 ); - //floatToFixed_arr( st->hTcxDec->syn_Overl_TDACFB_float, st->hTcxDec->syn_Overl_TDACFB, st->hTcxDec->Q_syn_Overl_TDACFB, L_FRAME_MAX / 2 ); - //floatToFixed_arr( st->hTcxDec->syn_OverlFB_float, st->hTcxDec->syn_OverlFB, st->hTcxDec->Q_syn_OverlFB, L_FRAME_MAX / 2 ); - //floatToFixed_arr( st->hTcxDec->old_synth_float, st->hTcxDec->old_synth, Q_old_synth, OLD_SYNTH_INTERNAL_DEC ); - //floatToFixed_arr( st->hTcxDec->synth_history, st->hTcxDec->synth_history_fx, Q_synth_history, L_PROT48k + L_FRAME_MAX ); st->hTcxDec->L_frameTCX = extract_l( Mult_32_16( st->output_Fs, 0x0290 ) ); - //st->hTcxDec->tcxltp_last_gain_unmodified = (Word16) floatToFixed( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 ); st->output_frame_fx = st->hTcxDec->L_frameTCX; - //st->hTcxDec->CngLevelBackgroundTrace_bfi_fx = floatToFixed( st->hTcxDec->CngLevelBackgroundTrace_bfi, 15 ); - //st->hTcxDec->conCngLevelBackgroundTrace = floatToFixed( st->hTcxDec->CngLevelBackgroundTrace_bfi, 15 ); - //st->hTcxDec->conceal_eof_gain = (Word16) floatToFixed( st->hTcxDec->conceal_eof_gain_float, 14 ); } IF( st->hHQ_core ) { st->hHQ_core->Q_old_out = 0; st->hHQ_core->Q_old_outLB = 0; st->hHQ_core->Q_fer_samples = 0; - //floatToFixed_arr( st->hHQ_core->old_out, st->hHQ_core->old_out_fx, st->hHQ_core->Q_old_out, L_FRAME48k ); - //floatToFixed_arr( st->hHQ_core->old_outLB, st->hHQ_core->old_out_LB_fx, st->hHQ_core->Q_old_outLB, L_FRAME32k ); - } - IF( st->cldfbAna ) - { - Q_cldfbAna_cldfb_state = Q_factor_arrL( st->cldfbAna->cldfb_state, st->cldfbAna->cldfb_state_length ) - 1; - floatToFixed_arrL( st->cldfbAna->cldfb_state, st->cldfbAna->cldfb_state_fx, Q_cldfbAna_cldfb_state, st->cldfbAna->cldfb_state_length ); - } - IF( st->cldfbBPF ) - { - Q_cldfbBPF_cldfb_state = Q_factor_arrL( st->cldfbBPF->cldfb_state, st->cldfbBPF->cldfb_state_length ) - 1; - floatToFixed_arrL( st->cldfbBPF->cldfb_state, st->cldfbBPF->cldfb_state_fx, Q_cldfbBPF_cldfb_state, st->cldfbBPF->cldfb_state_length ); - } - IF( st->cldfbSyn ) - { - Q_cldfbSyn_cldfb_state = Q_factor_arrL( st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_length ) - 1; - floatToFixed_arrL( st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_fx, Q_cldfbSyn_cldfb_state, st->cldfbSyn->cldfb_state_length ); } IF( st->cldfbSynHB ) { 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 ); } - IF( st->hTcxLtpDec ) - { - //Q_tcxltp_mem_in = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_in_float, TCXLTP_MAX_DELAY ); - //Q_tcxltp_mem_out = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_out_float, L_FRAME48k ); - //floatToFixed_arr( st->hTcxLtpDec->tcxltp_mem_in_float, st->hTcxLtpDec->tcxltp_mem_in, Q_tcxltp_mem_in, TCXLTP_MAX_DELAY ); - //floatToFixed_arr( st->hTcxLtpDec->tcxltp_mem_out_float, st->hTcxLtpDec->tcxltp_mem_out, Q_tcxltp_mem_out, L_FRAME48k ); - } st->last_gain_syn_deemph = 0; - //IF( hBWE_TD ) - //{ - // 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 ); - //} } else { - //Q_syn = st->Q_syn; - //hGrid = &hIGFInfo->grid[IGF_GRID_LB_NORM]; - //fixedToFloat_arr( &hGrid->whiteningThreshold[0][0], &hGrid->whiteningThreshold_flt[0][0], 13, IGF_MAX_TILES * 2 ); - //hGrid->gFactor_flt = fixedToFloat( hGrid->gFactor, 14 ); - //hGrid->fFactor_flt = fixedToFloat( hGrid->fFactor, 14 ); - //hGrid->lFactor_flt = fixedToFloat( hGrid->lFactor, 14 ); - //hGrid = &hIGFInfo->grid[IGF_GRID_LB_TRAN]; - //fixedToFloat_arr( &hGrid->whiteningThreshold[0][0], &hGrid->whiteningThreshold_flt[0][0], 13, IGF_MAX_TILES * 2 ); - //hGrid->gFactor_flt = fixedToFloat( hGrid->gFactor, 14 ); - //hGrid->fFactor_flt = fixedToFloat( hGrid->fFactor, 14 ); - //hGrid->lFactor_flt = fixedToFloat( hGrid->lFactor, 14 ); - //hGrid = &hIGFInfo->grid[IGF_GRID_LB_SHORT]; - //fixedToFloat_arr( &hGrid->whiteningThreshold[0][0], &hGrid->whiteningThreshold_flt[0][0], 13, IGF_MAX_TILES * 2 ); - //hGrid->gFactor_flt = fixedToFloat( hGrid->gFactor, 14 ); - //hGrid->fFactor_flt = fixedToFloat( hGrid->fFactor, 14 ); - //hGrid->lFactor_flt = fixedToFloat( hGrid->lFactor, 14 ); - IF( st->hIGFDec ) - { - //st->hIGFDec->virtualSpec_float = &st->hIGFDec->virtualSpecBuf[0]; - //st->hIGFDec->igfData.pSpecFlat_float = &st->hIGFDec->igfData.pSpecFlatBuf[0]; - //st->hIGFDec->igfData.igfInfo.nfSeed = &st->hIGFDec->igfData.igfInfo.nfSeedBuf[0]; - } - //IF( st->hBWE_TD != NULL ) - //{ - // Q_syn_overlap = Q_factor_arr( hBWE_TD->syn_overlap, 20 ); - // fixedToFloat_arr( hBWE_TD->syn_overlap_fx, hBWE_TD->syn_overlap, Q_syn_overlap, 20 ); - //} IF( st->hTcxDec ) { - //Q_old_synth = Q_syn; - //st->hTcxDec->Q_old_syn_Overl = st->Q_syn + 1; - //fixedToFloat_arr( st->hTcxDec->old_syn_Overl, st->hTcxDec->old_syn_Overl_float, st->hTcxDec->Q_old_syn_Overl, L_FRAME32k / 2 ); - //fixedToFloat_arr( st->hTcxDec->syn_Overl_TDAC, st->hTcxDec->syn_Overl_TDAC_float, st->hTcxDec->Q_syn_Overl_TDAC, 320 ); - //fixedToFloat_arr( st->hTcxDec->syn_Overl, st->hTcxDec->syn_Overl_float, st->hTcxDec->Q_syn_Overl, 320 ); - //fixedToFloat_arr( st->hTcxDec->syn_Overl_TDACFB, st->hTcxDec->syn_Overl_TDACFB_float, st->hTcxDec->Q_syn_Overl_TDACFB, 480 ); - //fixedToFloat_arr( st->hTcxDec->syn_OverlFB, st->hTcxDec->syn_OverlFB_float, st->hTcxDec->Q_syn_OverlFB, 480 ); - //fixedToFloat_arr( st->hTcxDec->old_synth, st->hTcxDec->old_synth_float, Q_old_synth, OLD_SYNTH_INTERNAL_DEC ); - //fixedToFloat_arr( st->hTcxDec->synth_history_fx, st->hTcxDec->synth_history, Q_synth_history, L_PROT48k + L_FRAME_MAX ); - //st->hTcxDec->q_synth_history_fx = Q_synth_history; - //st->hTcxDec->conceal_eof_gain_float = fixedToFloat( st->hTcxDec->conceal_eof_gain, 14 ); st->hTcxDec->conCngLevelBackgroundTrace_e = 0; - //st->hTcxDec->CngLevelBackgroundTrace_bfi = fix16_to_float( st->hTcxDec->conCngLevelBackgroundTrace,15 - st->hTcxDec->conCngLevelBackgroundTrace_e); - //st->hTcxDec->CngLevelBackgroundTrace_bfi = fixedToFloat( st->hTcxDec->CngLevelBackgroundTrace_bfi_fx, 15 ); - //st->hTcxDec->conCngLevelBackgroundTrace = (Word16) st->hTcxDec->CngLevelBackgroundTrace_bfi_fx; st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; st->hTcxDec->conLastFrameLevel = st->hTcxDec->LastFrameLevel_bfi_fx; - //st->hTcxDec->conLastFrameLevel_e = 0; - } - - IF( st->hHQ_core ) - { - //fixedToFloat_arr( st->hHQ_core->old_out_fx, st->hHQ_core->old_out, st->hHQ_core->Q_old_wtda, L_FRAME48k ); - //fixedToFloat_arr( st->hHQ_core->old_out_LB_fx, st->hHQ_core->old_outLB, st->hHQ_core->Q_old_outLB, L_FRAME32k ); - } - IF( st->cldfbAna ) - { - Q_cldfbAna_cldfb_state = Q_factor_arrL( st->cldfbAna->cldfb_state, st->cldfbAna->cldfb_state_length ) - 1; - fixedToFloat_arrL( st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_state, Q_cldfbAna_cldfb_state, st->cldfbAna->cldfb_state_length ); - } - IF( st->cldfbBPF ) - { - Q_cldfbBPF_cldfb_state = Q_factor_arrL( st->cldfbBPF->cldfb_state, st->cldfbBPF->cldfb_state_length ) - 1; - fixedToFloat_arrL( st->cldfbBPF->cldfb_state_fx, st->cldfbBPF->cldfb_state, Q_cldfbBPF_cldfb_state, st->cldfbBPF->cldfb_state_length ); - } - IF( st->cldfbSyn ) - { - Q_cldfbSyn_cldfb_state = Q_factor_arrL( st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_length ) - 1; - fixedToFloat_arrL( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_state, Q_cldfbSyn_cldfb_state, st->cldfbSyn->cldfb_state_length ); } IF( st->cldfbSynHB ) { 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 ); } - - IF( st->hTcxLtpDec != NULL ) - { - //Q_tcxltp_mem_in = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_in_float, TCXLTP_MAX_DELAY ); - //Q_tcxltp_mem_out = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_out_float, L_FRAME48k ); - //fixedToFloat_arr( st->hTcxLtpDec->tcxltp_mem_in, st->hTcxLtpDec->tcxltp_mem_in_float, Q_tcxltp_mem_in, TCXLTP_MAX_DELAY ); - //fixedToFloat_arr( st->hTcxLtpDec->tcxltp_mem_out, st->hTcxLtpDec->tcxltp_mem_out_float, Q_tcxltp_mem_out, L_FRAME48k ); - } - IF( st->hTonalMDCTConc ) - { - FOR( i = 0; i < FDNS_NPTS; i++ ) - { - //st->hTonalMDCTConc->scaleFactorsBackground_flt[i] = fixedToFloat( st->hTonalMDCTConc->scaleFactorsBackground[i], 15 ); - } - } } } if ( tofix ) { - /*==========*/ - for ( int p = 0; p < hTcxDec->old_synth_len; p++ ) - { - //hTcxDec->old_synth[p] = (Word16) ( hTcxDec->old_synth_float[p] ); - } - for ( int p = 0; p < hTcxDec->old_synth_lenFB; p++ ) - { - //hTcxDec->old_synthFB_fx[p] = (Word16) ( hTcxDec->old_synthFB[p] ); - } - - //st->hTcxDec->tcxltp_last_gain_unmodified = (Word16) floatToFixed( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 ); - //if ( st->hTonalMDCTConc != NULL ) - //{ - // floatToFixed_arr( st->hTonalMDCTConc->secondLastPcmOut_float, st->hTonalMDCTConc->secondLastPcmOut, 0, st->hTonalMDCTConc->nSamples ); - //} - st->Q_syn = 0; - - //for ( int p = 0; p < st->L_frame; p++ ) - //{ - // st->hTcxDec->old_excFB_fx[p] = (Word16) ( st->hTcxDec->old_excFB[p] * ( 1u << st->Q_exc ) ); - //} st->prev_Q_syn = st->Q_syn; - //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 ); - //if ( st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) - //{ - // set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); - //} st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; - if ( hTcxLtpDec->tcxltp ) - { - //hTcxDec->tcxltp_last_gain_unmodified = (Word16) floatToFixed( hTcxDec->tcxltp_last_gain_unmodified_float, Q15 ); - } - - //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->tcxonly ) - //{ - // floatToFixed_arr( st->p_bpf_noise_buf_float, st->p_bpf_noise_buf, 0, L_FRAME_16k ); - //} st->mem_error = st->hBPF->pst_mem_deemp_err_fx; - - if ( st->hFdCngDec != NULL && ( st->sr_core == INT_FS_12k8 || st->sr_core == INT_FS_16k ) && st->total_brate <= MAX_ACELP_BRATE ) - { - //for ( int p = 0; p < PERIODOGLEN; p++ ) - //{ - // st->hFdCngDec->hFdCngCom->periodog[p] = (Word32) ( st->hFdCngDec->hFdCngCom->periodog_flt[p] * ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->periodog_exp ) ) ); - //} - - //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->sidNoiseEstExp = 31 - Q4; - //st->hFdCngDec->partNoiseShape_exp = 31 - Q4; - //for ( int p = 0; p < NPART; p++ ) - //{ - // st->hFdCngDec->hFdCngCom->sidNoiseEst[p] = (Word32) ( st->hFdCngDec->hFdCngCom->sidNoiseEst_flt[p] * ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) ) ); - //} - //for ( int p = 0; p < 24; p++ ) - //{ - //st->hFdCngDec->partNoiseShape[p] = (Word32) ( st->hFdCngDec->partNoiseShape_float[p] * ( 1u << ( 31 - st->hFdCngDec->partNoiseShape_exp ) ) ); - //} - } // 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); - - //floatToFixed_arr(st->hTcxDec->old_syn_Overl_float, st->hTcxDec->old_syn_Overl, st->Q_syn + 1, L_FRAME32k / 2); - //floatToFixed_arr(st->hTcxDec->syn_Overl_TDAC_float, st->hTcxDec->syn_Overl_TDAC, st->Q_syn, 320); - //floatToFixed_arr(st->hTcxDec->syn_Overl_float, st->hTcxDec->syn_Overl, st->Q_syn+1, 320); - //floatToFixed_arr(st->hTcxDec->syn_Overl_TDACFB_float, st->hTcxDec->syn_Overl_TDACFB, st->Q_syn, 480); - //floatToFixed_arr(st->hTcxDec->syn_OverlFB_float, st->hTcxDec->syn_OverlFB, st->Q_syn, 480); - } -} - -void fixed_to_float_stereo_tcx_core_dec( - Decoder_State *st, - Word16 *signal_out ) -{ - //TCX_DEC_HANDLE hTcxDec = st->hTcxDec; - //Word16 q_Aq; - //st->hTcxDec->tcxltp_last_gain_unmodified_float = (Word16) fixedToFloat( st->hTcxDec->tcxltp_last_gain_unmodified, Q15 ); - - if ( EQ_16( st->core, ACELP_CORE ) ) - { - if (st->hHQ_core->Q_old_wtda >= 0) - { - for ( int p = 0; p < 960; p++ ) - { - //st->hHQ_core->old_outLB[p] = (float) st->hHQ_core->old_out_LB_fx[p] / ( 1u << st->hHQ_core->Q_old_wtda ); - //st->hHQ_core->old_out[p] = (float) st->hHQ_core->old_out_fx[p] / ( 1u << st->hHQ_core->Q_old_wtda ); - } - } - else{ - for ( int p = 0; p < 960; p++ ) - { - //st->hHQ_core->old_outLB[p] = (float) st->hHQ_core->old_out_LB_fx[p] * ( 1u << (-st->hHQ_core->Q_old_wtda) ); - //st->hHQ_core->old_out[p] = (float) st->hHQ_core->old_out_fx[p] * ( 1u << (-st->hHQ_core->Q_old_wtda) ); - } - } - } - - st->hBPF->pst_mem_deemp_err_fx = (Word16)st->mem_error; - /*=================================*/ - if ( st->hFdCngDec != NULL && ( st->sr_core == INT_FS_12k8 || st->sr_core == INT_FS_16k ) && st->total_brate <= MAX_ACELP_BRATE ) - { - if ( st->element_mode != IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_TD && st->idchan == 0 ) ) - { - if ( ( ( st->m_frame_type == ACTIVE_FRAME ) && ( ( st->bfi == 0 && - ( signal_out == NULL || - ( *signal_out < MAXVAL_WORD16 && * signal_out>( MINVAL_WORD16 ) && - *( signal_out + st->hFdCngDec->hFdCngCom->frameSize - 1 ) < MAXVAL_WORD16 && - *( signal_out + st->hFdCngDec->hFdCngCom->frameSize - 1 ) > ( MINVAL_WORD16 ) ) ) && - ( ( ( ( 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 ) ) - { - for ( int p = 0; p < st->hFdCngDec->npart_shaping; p++ ) - { - //st->hFdCngDec->msNoiseEst_float[p] = (float) st->hFdCngDec->msNoiseEst[p] / ( 1u << ( 31 - st->hFdCngDec->msNoiseEst_exp ) ); - - } - } - } - } - IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) ) - { - - //FOR( Word16 ind = 0; ind < 640; ind++ ) - //{ - // st->hHQ_core->old_outLB[ind] = (float) st->hHQ_core->old_out_LB_fx[ind] / ( (float) pow( 2, st->hHQ_core->Q_old_wtda ) ); - //} - //FOR( Word16 ind = 0; ind < 960; ind++ ) - //{ - // st->hHQ_core->old_out[ind] = (float) st->hHQ_core->old_out_fx[ind] / ( (float) pow( 2, st->hHQ_core->Q_old_wtda ) ); - //} - FOR( Word16 ind = 0; ind < L_FRAME32k / 2; ind++ ) - { - //st->hTcxDec->syn_Overl_float[ind] = (float) st->hTcxDec->syn_Overl[ind] / ( (float) pow( 2, st->Q_syn + 1 ) ); - } - FOR( Word16 ind = 0; ind < L_FRAME_MAX / 2; ind++ ) - { - //st->hTcxDec->syn_OverlFB_float[ind] = (float) st->hTcxDec->syn_OverlFB[ind] / ( (float) pow( 2, st->Q_syn ) ); - } } } #endif // IVAS_FLOAT_FIXED diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index a9b72e067..78faac5ae 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2146,10 +2146,22 @@ void ivas_dirac_dec_output_synthesis_cov_close_fx( DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state /* i/o: handle for the covariance synthesis state */ ); +ivas_error ivas_init_decoder_front_fx( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + ivas_error ivas_init_decoder_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); +void destroy_core_dec_fx( + DEC_CORE_HANDLE hCoreCoder /* i/o: core decoder structure */ +); + +void ivas_destroy_dec_fx( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + ivas_error ivas_ism_dec_config_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const ISM_MODE last_ism_mode, /* i/o: last ISM mode */ diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index c901dd2d9..308813ea9 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -167,8 +167,8 @@ void ivas_sba_config_fx( ELSE { *nSCE = 0; - *nCPE = shr( *nchan_transport, 2 ); - IF( NE_16( mult( 2, ( *nCPE ) ), *nchan_transport ) ) + *nCPE = shr( *nchan_transport, 1 ); + IF( NE_16( i_mult( 2, ( *nCPE ) ), *nchan_transport ) ) { *nCPE = add( *nCPE, 1 ); } @@ -320,18 +320,18 @@ Word16 ivas_sba_get_nchan_metadata( { Word16 nb_channels; - IF ( EQ_16(sba_order , SBA_FOA_ORDER) ) + IF( EQ_16( sba_order, SBA_FOA_ORDER ) ) { nb_channels = FOA_CHANNELS; move16(); } ELSE { - IF ( GE_32(ivas_total_brate , IVAS_512k) ) + IF( GE_32( ivas_total_brate, IVAS_512k ) ) { nb_channels = IVAS_SPAR_MAX_CH; move16(); - nb_channels = s_min( nb_channels, imult1616(add( sba_order , 1 ) , add( sba_order , 1 )) ); + nb_channels = s_min( nb_channels, imult1616( add( sba_order, 1 ), add( sba_order, 1 ) ) ); } ELSE { diff --git a/lib_com/prot_fx2.h b/lib_com/prot_fx2.h index 3eebc5bc4..6c37b6b07 100644 --- a/lib_com/prot_fx2.h +++ b/lib_com/prot_fx2.h @@ -74,10 +74,6 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( Word16 last_element_mode, const FRAME_MODE frameMode); -void fixed_to_float_stereo_tcx_core_dec( - Decoder_State *st, - Word16 *signal_out -); // Float to Word32 Word32 float_to_fix( float number, Word32 Q ); // Word32 to Float diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 35cec94d9..bf525061e 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -1658,15 +1658,15 @@ ivas_error acelp_core_dec_ivas_fx( } } Word32 max_val = max(max_real, max_imag); - Q_imag = norm_s((Word16)max_val); + Q_imag = norm_l(max_val) - 3/* Guard bits */; Q_real = Q_imag; for (i = 0; i < CLDFB_NO_COL_MAX; i++) { - Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real); - Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_imag); + scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real); + scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_imag); } - Scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, ( Q_real - 1 ) - Q10 ); // (Q_real-1) + scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, ( Q_real - 1 ) - Q10 ); // (Q_real-1) Scale_sig32(save_hb_synth_fx, L_FRAME48k, Q_real - 1); FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) @@ -1716,26 +1716,26 @@ ivas_error acelp_core_dec_ivas_fx( } } Word32 max_val = max(max_real, max_imag); - Q_imag = norm_s((Word16)max_val); + Q_imag = norm_l(max_val) - 3/* Guard bits */; Q_real = Q_imag; for (i = 0; i < CLDFB_NO_COL_MAX; i++) { - Scale_sig32(realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real); - Scale_sig32(imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real); + scale_sig32(realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real); + scale_sig32(imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real); } - Scale_sig32(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, (Q_real - 1) - Q10); //(Q_real - 1) + scale_sig32(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, (Q_real - 1) - Q10); //(Q_real - 1) #ifndef MSAN_FIX Scale_sig32( synth_fx, L_FRAME48k, Q_real - 1); #endif cldfbSynthesis_ivas_fx(realBuffer_fx, imagBuffer_fx, synth_fx, -1, st->cldfbSyn); #ifdef MSAN_FIX - Scale_sig32(synth_fx, output_frame, -(Q_real - 1)); + scale_sig32(synth_fx, output_frame, -(Q_real - 1)); #else Scale_sig32(synth_fx, L_FRAME48k, -(Q_real - 1)); #endif - Scale_sig32(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, Q10 - (Q_real - 1)); //Q10 + scale_sig32(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, Q10 - (Q_real - 1)); //Q10 } /* save synthesis - needed in case of core switching */ @@ -1802,15 +1802,15 @@ ivas_error acelp_core_dec_ivas_fx( } } Word32 max_val = max(max_real, max_imag); - Q_imag = norm_s((Word16)max_val); + Q_imag = norm_l(max_val) - 3/* Guard bits */; Q_real = Q_imag; for (i = 0; i < CLDFB_NO_COL_MAX; i++) { - Scale_sig32(realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real); - Scale_sig32(imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real); + scale_sig32(realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real); + scale_sig32(imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real); } - Scale_sig32(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, (Q_real - 1) - Q10); //(Q_real - 1) + scale_sig32(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, (Q_real - 1) - Q10); //(Q_real - 1) #ifndef MSAN_FIX Scale_sig32( synth_fx, L_FRAME48k, Q_real - 1); #endif @@ -1970,63 +1970,15 @@ ivas_error acelp_core_dec_ivas_fx( } void acelp_decoder_state_float2fix(Decoder_State *st/*, STEREO_CNG_DEC_HANDLE hStereoCng*/) { - - - /* CLDFB */ - Word16 old_len_ana, old_len_bpf; - // 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; - - //Word16 new_len; - //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); if(st->cldfbSynHB) floatToFixed_arrL(st->cldfbSynHB->cldfb_state, st->cldfbSynHB->cldfb_state_fx, Q10, st->cldfbSynHB->p_filter_length); - floatToFixed_arrL(st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_fx, Q10, st->cldfbSyn->p_filter_length); } void acelp_decoder_state_fix2float(Decoder_State *st) { - - st->prev_Q_syn = st->Q_syn; - /* CLDFB */ - Word16 new_len; - new_len = 9 * (int16_t)(st->L_frame * FRAMES_PER_SEC * INV_CLDFB_BANDWIDTH + 0.5f); - 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); if (st->cldfbSynHB) fixedToFloat_arrL(st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->cldfb_state, Q10, st->cldfbSynHB->p_filter_length); - fixedToFloat_arrL(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_state, Q10, st->cldfbSyn->p_filter_length); - //FdCng - if ( st->hFdCngDec ) - { - if ((st->hFdCngDec != NULL || st->idchan == 1) && st->element_mode != IVAS_CPE_MDCT) - { - if (st->element_mode == IVAS_CPE_TD || st->flag_cna || (st->cng_type == FD_CNG && st->total_brate <= ACELP_32k) || (st->cng_type == LP_CNG && st->core_brate <= SID_2k40)) - { - if (st->element_mode != IVAS_CPE_TD && !st->cng_ism_flag) - { - if ( - ((st->m_frame_type == ACTIVE_FRAME) && ((st->bfi == 0 && - ((((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)) - ) - { - //fixedToFloat_arrL(st->hFdCngDec->msNoiseEst, st->hFdCngDec->msNoiseEst_float, Q31 - st->hFdCngDec->msNoiseEst_exp, st->hFdCngDec->npart_shaping); - } - } - } - } - } } static void rescale_fdCngDec(HANDLE_FD_CNG_DEC hFdCngDec, Word16 Exp_diff) { diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index 045c54345..b20c34570 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -1119,7 +1119,6 @@ void open_decoder_LPD_ivas_fx( Word16 mem_syn_r_size_new; Word16 mem_syn_r_size_old; Word16 fscaleFB; - //Word16 encoderLookahead, encoderLookaheadFB; BPF_DEC_HANDLE hBPF; TD_BWE_DEC_HANDLE hBWE_TD; TCX_LTP_DEC_HANDLE hTcxLtpDec; @@ -1182,9 +1181,7 @@ void open_decoder_LPD_ivas_fx( { st->narrowBand = 1; } - // To be replaced with basops - //encoderLookahead = mult( L_LOOK_12k8<<6 , st->fscale ); - //encoderLookaheadFB = mult(L_LOOK_12k8<<6 , fscaleFB ); + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) { st->pit_res_max = initPitchLagParameters( INT_FS_12k8, &st->pit_min, &st->pit_fr1, &st->pit_fr1b, &st->pit_fr2, &st->pit_max ); @@ -1701,8 +1698,6 @@ void open_decoder_LPD_ivas_fx( IF( is_init || MCT_flag || !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( st->element_mode, last_element_mode ) ) ) { - //st->hTcxDec->CngLevelBackgroundTrace_bfi_fx = PLC_MIN_CNG_LEV; - //st->hTcxDec->CngLevelBackgroundTrace_bfi_exp = 16; st->hTcxDec->NoiseLevelIndex_bfi = PLC_MIN_STAT_BUFF_SIZE - 1; st->hTcxDec->CurrLevelIndex_bfi = 0; st->hTcxDec->LastFrameLevel_bfi_fx = PLC_MIN_CNG_LEV; diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 8a9d8fc87..0442b2c68 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -2860,7 +2860,9 @@ static void IGF_getWhiteSpectralData_ivas( move16(); max_out_e = 0; move16(); - s_l = sub( s_l, 2 ); + /* find the gaurd bits for a length of (i + level + 1) - (i - level)*/ + Word16 guard_bits = add( find_guarded_bits_fx( add( i_mult( 2, level ), 1 ) ), 1 ) / 2; + s_l = sub( s_l, guard_bits ); FOR( i = start; i < stop - level; i++ ) { diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index f82732ab3..157c6180c 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -172,6 +172,22 @@ ivas_error ivas_core_dec( } } + FOR(n = 0; n < n_channels; n++) + { + st = sts[n]; + IF( st->cldfbAna ) + { + floatToFixed_arr32( st->cldfbAna->cldfb_state, st->cldfbAna->cldfb_state_fx, Q10, st->cldfbAna->cldfb_size ); + } + + IF( st->cldfbBPF ) + floatToFixed_arr32( st->cldfbBPF->cldfb_state, st->cldfbBPF->cldfb_state_fx, Q11, st->cldfbBPF->cldfb_size ); + IF( st->cldfbSyn ) + { + floatToFixed_arr32( st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_fx, Q11, st->cldfbSyn->cldfb_size ); + } + } + output_Fs = sts[0]->output_Fs; output_frame = extract_l( Mpy_32_16_1( output_Fs, INV_FRAME_PER_SEC_Q15 ) ); @@ -369,38 +385,14 @@ ivas_error ivas_core_dec( /*---------------------------------------------------------------------* * Preprocessing (preparing) for ACELP/HQ core switching *---------------------------------------------------------------------*/ - -#if 1 /*Float to fix conversions*/ Word16 Q_olapBufferSynth = 15, Q_olapBufferSynth2 = 15; /*Initializing with max values to avoid warnings*/ - 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 ); - } - - IF( st->cldfbBPF ) - floatToFixed_arr32( st->cldfbBPF->cldfb_state, st->cldfbBPF->cldfb_state_fx, Q11, st->cldfbBPF->cldfb_state_length ); - -#endif Copy_Scale_sig_16_32( st->previoussynth_fx, st->previoussynth_fx_32, L_FRAME48k, 0 ); IF ( ( error = core_switching_pre_dec_ivas_fx( st, output_frame, sts[0]->last_core_brate, nchan_out, last_element_mode, last_element_brate, st->Q_syn, &Q_olapBufferSynth, &Q_olapBufferSynth2) ) != IVAS_ERR_OK ) { return error; } -#if 1 /*Fixed to float function changes*/ - - 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 ); -#endif flag_sec_CNA = -1; IF ( hCPE != NULL ) @@ -428,6 +420,12 @@ ivas_error ivas_core_dec( } /* float2fix, to be removed */ + IF(st->cldfbAna) + scale_sig32(st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_size, sub(Q11, Q10)); + IF(st->cldfbBPF) + scale_sig32(st->cldfbBPF->cldfb_state_fx, st->cldfbBPF->cldfb_size, sub(Q10, Q11)); + IF(st->cldfbSyn) + scale_sig32(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_size, sub(Q10, Q11)); acelp_decoder_state_float2fix(st); IF( st->hFdCngDec != NULL ) @@ -447,6 +445,13 @@ ivas_error ivas_core_dec( Copy_Scale_sig_16_32(output_16_fx[n],output_32_fx[n],L_FRAME48k, Q11 - st->Q_syn2); Scale_sig(output_16_fx[n], L_FRAME48k, -st->Q_syn2); acelp_decoder_state_fix2float(st); + IF(st->cldfbAna) + scale_sig32(st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_size, sub(Q10, Q11)); /* 9 * (Word16)(st->L_frame * FRAMES_PER_SEC * INV_CLDFB_BANDWIDTH + 0.5f) */ + IF(st->cldfbBPF) + scale_sig32(st->cldfbBPF->cldfb_state_fx, st->cldfbBPF->cldfb_size, sub(Q11, Q10)); + IF(st->cldfbSyn) + scale_sig32(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_size, sub(Q11, Q10)); + st->prev_Q_syn = st->Q_syn; if ( save_hb_synth_32_fx ) { @@ -477,7 +482,7 @@ ivas_error ivas_core_dec( Copy_Scale_sig_16_32( output_16_fx[n], output_32_fx[n], L_FRAME48k, Q11 ); stereo_tcx_dec_mode_switch_reconf_To_fixed_2( st, 0, last_element_mode, frameMode[n] ); - fixed_to_float_stereo_tcx_core_dec( st, output_16_fx[n] ); + st->hBPF->pst_mem_deemp_err_fx = (Word16)st->mem_error; } if ( st->core == HQ_CORE ) @@ -513,6 +518,17 @@ ivas_error ivas_core_dec( } /* n_channels loop */ + FOR(n = 0; n < n_channels; n++) + { + st = sts[n]; + IF( st->cldfbAna ) + fixedToFloat_arrL( st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_state, Q10, st->cldfbAna->cldfb_size ); + IF( st->cldfbBPF ) + fixedToFloat_arrL( st->cldfbBPF->cldfb_state_fx, st->cldfbBPF->cldfb_state, Q11, st->cldfbBPF->cldfb_size ); + IF( st->cldfbSyn ) + fixedToFloat_arrL( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_state, Q11, st->cldfbSyn->cldfb_size ); + } + /*---------------------------------------------------------------------* * MDCT stereo: joint TCX Core Decoding *---------------------------------------------------------------------*/ @@ -542,8 +558,8 @@ ivas_error ivas_core_dec( st->prev_Q_syn = st->Q_syn; - Scale_sig(st->hHQ_core->old_out_LB_fx, L_FRAME32k, st->Q_syn - st->hHQ_core->Q_old_wtda_LB); - Scale_sig(st->hHQ_core->old_out_fx, L_FRAME48k, st->Q_syn - st->hHQ_core->Q_old_wtda); + Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, st->Q_syn - st->hHQ_core->Q_old_wtda_LB ); + Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, st->Q_syn - st->hHQ_core->Q_old_wtda ); IF( st->hTcxDec ) st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; @@ -564,16 +580,16 @@ ivas_error ivas_core_dec( st = hCPE->hCoreCoder[ch]; - st->hHQ_core->Q_old_wtda_LB = st->Q_syn; - st->hHQ_core->Q_old_wtda = st->Q_syn; + st->hHQ_core->Q_old_wtda_LB = st->Q_syn; + st->hHQ_core->Q_old_wtda = st->Q_syn; } #ifdef MSAN_FIX Scale_sig( synth_16_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX, e_sig - 15 ); Scale_sig( synth_16_fx[1], hCPE->hCoreCoder[1]->hTcxDec->L_frameTCX, e_sig - 15 ); #else - Scale_sig(synth_16_fx[0],L_FRAME48k,e_sig - 15); - Scale_sig(synth_16_fx[1],L_FRAME48k,e_sig - 15); + Scale_sig( synth_16_fx[0], L_FRAME48k, e_sig - 15 ); + Scale_sig( synth_16_fx[1], L_FRAME48k, e_sig - 15 ); #endif #endif } @@ -581,8 +597,6 @@ ivas_error ivas_core_dec( /* for inactive frames with mono output, copy and (if necessary) downmix buffers */ ELSE IF( hCPE->nchan_out == 1 ) { -#ifdef IVAS_FLOAT_FIXED - sts[0] = hCPE->hCoreCoder[0]; sts[1] = hCPE->hCoreCoder[1]; @@ -598,10 +612,6 @@ ivas_error ivas_core_dec( sts[0]->hHQ_core->Q_old_wtda = 15 - sts[0]->hHQ_core->exp_old_out; sts[1]->hHQ_core->Q_old_wtda = 15 - sts[1]->hHQ_core->exp_old_out; } - -#else - updateBuffersForDmxMdctStereo( hCPE, output_frame, output, synth ); -#endif } test(); IF ( EQ_16(sts[0]->bfi, 0) && EQ_16(sts[0]->prev_bfi, 1 )) @@ -650,10 +660,6 @@ ivas_error ivas_core_dec( * TD-BWE for ACELP to TCX transitions *---------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED - - /*cldfb struct*/ - /*------------------fix-to-fix-start---------------------*/ /*core_switching_post_dec*/ Q_synth = 0; if (st->hHQ_core != NULL) @@ -702,11 +708,9 @@ ivas_error ivas_core_dec( floatToFixed_arrL(st->cldfbBPF->cldfb_state, st->cldfbBPF->cldfb_state_fx, 11, st->cldfbBPF->cldfb_size); } - /*-------------------cldfb-end---------------------------*/ Word16 q_audio, old_syn_fx; old_syn_fx = Q11; q_audio = Q12; -#endif test(); test(); test(); test(); IF ( EQ_16(st->last_core, ACELP_CORE) && (EQ_16(st->core, TCX_20_CORE) || EQ_16(st->core, TCX_10_CORE) || EQ_16(st->core, HQ_CORE) ) && st->hBWE_TD != NULL ) { @@ -748,7 +752,7 @@ ivas_error ivas_core_dec( test(); test(); test(); IF (sba_dirac_stereo_flag && NE_16(st->element_mode, IVAS_CPE_MDCT) && !(EQ_32(st->core_brate, SID_2k40) && EQ_16(st->cng_type, FD_CNG))) { - Copy_Scale_sig_16_32(synth_16_fx[n], hSCE->save_synth_fx, output_frame, hSCE->q_save_synth_fx - Q_synth); + Copy_Scale_sig_16_32(synth_16_fx[n], hSCE->save_synth_fx, output_frame, hSCE->q_save_synth_fx - Q_synth); } IF ( ( error = core_switching_post_dec_ivas_fx( st, synth_16_fx[n], output_32_fx[n], p_output_mem_16, ( st_ivas != NULL ) ? st_ivas->ivas_format : UNDEFINED_FORMAT, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, ( hCPE != NULL ) ? hCPE->last_element_mode : IVAS_SCE, &Q_synth ) ) != IVAS_ERR_OK ) @@ -778,14 +782,12 @@ ivas_error ivas_core_dec( Copy_Scale_sig_16_32(st->delay_buf_out_fx, st->delay_buf_out32_fx, HQ_DELTA_MAX * HQ_DELAY_COMP, Q11); Scale_sig32(output_32_fx[n], L_FRAME48k, Q11 - Q4); -#ifdef IVAS_FLOAT_FIXED - /*-------------------cldfb-start-------------------------*/ /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ if (st->cldfbAna != NULL) { - fixedToFloat_arrL(st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_state, 10, st->cldfbAna->cldfb_state_length); + fixedToFloat_arrL(st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_state, 10, st->cldfbAna->cldfb_size); } if (st->cldfbSyn != NULL) { @@ -793,10 +795,9 @@ ivas_error ivas_core_dec( } if (st->cldfbBPF != NULL) { - fixedToFloat_arrL(st->cldfbBPF->cldfb_state_fx, st->cldfbBPF->cldfb_state, 11, st->cldfbBPF->cldfb_state_length); + fixedToFloat_arrL(st->cldfbBPF->cldfb_state_fx, st->cldfbBPF->cldfb_state, 11, st->cldfbBPF->cldfb_size); } - /*-------------------cldfb-end---------------------------*/ #ifdef MSAN_FIX Scale_sig(synth_16_fx[n], output_frame, negate(Q_synth)); #else @@ -815,14 +816,12 @@ ivas_error ivas_core_dec( st->hBWE_FD->prev_L_swb_norm = st->hBWE_FD->prev_L_swb_norm; st->hBWE_FD->prev_flag = st->hBWE_FD->prev_flag; } -#endif + /*---------------------------------------------------------------------* * WB TBE decoding * WB BWE decoding *---------------------------------------------------------------------*/ - -#ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED Word16 Q_input, Q_hb_synth_fx, Q_synth_fx; Word16 Q_syn_hb; @@ -834,9 +833,8 @@ ivas_error ivas_core_dec( FD_BWE_DEC_HANDLE hBWE_FD; hBWE_FD = st->hBWE_FD; - Copy_Scale_sig_32_16(output_32_fx[n], output_16_fx[n], L_FRAME48k, negate(Q11)); - Copy_Scale_sig_32_16(hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, negate(Q11)); -#endif + Copy_Scale_sig_32_16( output_32_fx[n], output_16_fx[n], L_FRAME48k, negate( Q11 ) ); + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, negate( Q11 ) ); test(); test(); test(); @@ -1133,9 +1131,7 @@ ivas_error ivas_core_dec( test(); test(); test(); IF ( GE_16(output_frame, L_FRAME32k) && GT_16(st->extl, SWB_CNG) && EQ_16(st->core, ACELP_CORE) && st->hTdCngDec != NULL ) { -#ifdef IVAS_FLOAT_FIXED - Word16 exp, fra; -#endif + Word16 exp, fra; SWITCH(output_frame) { case L_FRAME8k: @@ -1178,8 +1174,6 @@ ivas_error ivas_core_dec( * - core switching in DFT stereo * - updates for potential TD->DFT stereo switching *----------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED - if (hCPE != NULL) { FOR(int ch_ind = 0; ch_ind < n_channels; ch_ind++) @@ -1208,7 +1202,6 @@ ivas_error ivas_core_dec( Word16 exp_max = 0; Word32 output_fx_loc[L_FRAME48k]; -#endif IF ( NE_16(st->element_mode, IVAS_CPE_DFT )) { diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index aa32ce707..8d0f2014a 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -198,7 +198,7 @@ ivas_error ivas_corecoder_dec_reconfig_fx( { IF( st_ivas->hCPE[cpe_id]->hCoreCoder[n] != NULL ) { - destroy_core_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); + destroy_core_dec_fx( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); free( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); st_ivas->hCPE[cpe_id]->hCoreCoder[n] = NULL; diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index cdb223d87..5ffceb2c1 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -1146,7 +1146,7 @@ void destroy_cpe_dec( IF( st != NULL ) { - destroy_core_dec( st ); + destroy_core_dec_fx( st ); free( st ); st = NULL; diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index ec86f6303..612d7b82d 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -789,7 +789,6 @@ static ivas_error ivas_dirac_rend_config_fx( IF( EQ_16( flag_config, DIRAC_OPEN ) ) { hDirACRend->buffer_energy_fx = NULL; - hDirACRend->buffer_energy = NULL; } IF( ( EQ_16( flag_config, DIRAC_OPEN ) && hDirAC->hConfig->dec_param_estim == TRUE ) || ( EQ_16( flag_config, DIRAC_RECONFIGURE ) && ( hDirAC->hConfig->dec_param_estim == TRUE && dec_param_estim_old == FALSE ) ) ) @@ -806,6 +805,7 @@ static ivas_error ivas_dirac_rend_config_fx( set32_fx( hDirACRend->buffer_intensity_real_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX ); } } + set16_fx( hDirACRend->q_buffer_intensity_real, Q31, DIRAC_NO_COL_AVG_DIFF ); IF( hDirACRend->buffer_energy_fx == NULL ) { IF( ( hDirACRend->buffer_energy_fx = (Word32 *) malloc( DIRAC_NO_COL_AVG_DIFF * CLDFB_NO_CHANNELS_MAX * sizeof( Word32 ) ) ) == NULL ) @@ -814,27 +814,7 @@ static ivas_error ivas_dirac_rend_config_fx( } } set32_fx( hDirACRend->buffer_energy_fx, 0, DIRAC_NO_COL_AVG_DIFF * CLDFB_NO_CHANNELS_MAX ); -#ifdef TRUE - for ( i = 0; i < DIRAC_NUM_DIMS; i++ ) - { - for ( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) - { - if ( ( hDirACRend->buffer_intensity_real[i][j] = (float *) malloc( CLDFB_NO_CHANNELS_MAX * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } - set_f( hDirACRend->buffer_intensity_real[i][j], 0.0f, CLDFB_NO_CHANNELS_MAX ); - } - } - if ( hDirACRend->buffer_energy == NULL ) - { - if ( ( hDirACRend->buffer_energy = (float *) malloc( DIRAC_NO_COL_AVG_DIFF * CLDFB_NO_CHANNELS_MAX * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } - } - set_f( hDirACRend->buffer_energy, 0.0f, DIRAC_NO_COL_AVG_DIFF * CLDFB_NO_CHANNELS_MAX ); -#endif + set16_fx( hDirACRend->q_buffer_energy, Q31, DIRAC_NO_COL_AVG_DIFF ); } ELSE IF( ( EQ_16( flag_config, DIRAC_OPEN ) && hDirAC->hConfig->dec_param_estim == FALSE ) || ( EQ_16( flag_config, DIRAC_RECONFIGURE ) && ( hDirAC->hConfig->dec_param_estim == FALSE && dec_param_estim_old == TRUE ) ) ) { @@ -854,24 +834,6 @@ static ivas_error ivas_dirac_rend_config_fx( free( hDirACRend->buffer_energy_fx ); hDirACRend->buffer_energy_fx = NULL; } -#ifdef TRUE - for ( i = 0; i < DIRAC_NUM_DIMS; i++ ) - { - for ( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) - { - if ( flag_config == DIRAC_RECONFIGURE && hDirACRend->buffer_intensity_real[i][j] ) - { - free( hDirACRend->buffer_intensity_real[i][j] ); - } - hDirACRend->buffer_intensity_real[i][j] = NULL; - } - } - if ( hDirACRend->buffer_energy != NULL ) - { - free( hDirACRend->buffer_energy ); - hDirACRend->buffer_energy = NULL; - } -#endif } /* output synthesis */ ivas_dirac_dec_output_synthesis_init_fx( hSpatParamRendCom, hDirACRend, nchan_out_woLFE, hodirac_flag ); @@ -3541,21 +3503,6 @@ void ivas_dirac_dec_render_sf_fx( set_zero_fx( surCohRatio_fx, CLDFB_NO_CHANNELS_MAX ); //////////////////////////////////////////////////////////////////////////// to be removed /////////////////////////////////////////////////////////////////// - IF( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] ) - { - p_Rmat_fx = &st_ivas->hCombinedOrientationData->Rmat_fx[st_ivas->hCombinedOrientationData->subframe_idx][0][0]; - floatToFixed_arrL32( &st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx][0][0], p_Rmat_fx, Q29, 9 ); - } - ELSE - { - p_Rmat_fx = 0; - } - - IF( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] ) - { - floatToFixed_arrL32( &st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx][0][0], &st_ivas->hCombinedOrientationData->Rmat_fx[st_ivas->hCombinedOrientationData->subframe_idx][0][0], Q29, 9 ); - } - FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[hSpatParamRendCom->subframes_rendered]; slot_idx++ ) { IF( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) @@ -3617,23 +3564,6 @@ void ivas_dirac_dec_render_sf_fx( BREAK; } } - IF( EQ_16( hDirAC->hConfig->dec_param_estim, TRUE ) ) - { - // Word16 val = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; - FOR( i = 0; i < 32; i++ ) - { - Word16 exp1 = 0, exp2 = 0, exp3 = 0; - f2me_buf( hDirACRend->buffer_intensity_real[0][i], hDirACRend->buffer_intensity_real_fx[0][i], &exp1, hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); - f2me_buf( hDirACRend->buffer_intensity_real[1][i], hDirACRend->buffer_intensity_real_fx[1][i], &exp2, hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); - f2me_buf( hDirACRend->buffer_intensity_real[2][i], hDirACRend->buffer_intensity_real_fx[2][i], &exp3, hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); - hDirACRend->q_buffer_intensity_real[i] = sub( 31, s_max( s_max( exp1, exp2 ), exp3 ) ); - scale_sig32( hDirACRend->buffer_intensity_real_fx[0][i], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band], sub( hDirACRend->q_buffer_intensity_real[i], sub( 31, exp1 ) ) ); - scale_sig32( hDirACRend->buffer_intensity_real_fx[1][i], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band], sub( hDirACRend->q_buffer_intensity_real[i], sub( 31, exp2 ) ) ); - scale_sig32( hDirACRend->buffer_intensity_real_fx[2][i], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band], sub( hDirACRend->q_buffer_intensity_real[i], sub( 31, exp3 ) ) ); - f2me_buf( &hDirACRend->buffer_energy[i * hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]], &hDirACRend->buffer_energy_fx[i * hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]], &hDirACRend->q_buffer_energy[i], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); - hDirACRend->q_buffer_energy[i] = sub( 31, hDirACRend->q_buffer_energy[i] ); - } - } IF( L_or( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ), EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) ) ) { @@ -4918,15 +4848,7 @@ void ivas_dirac_dec_render_sf_fx( /* Perform binaural rendering */ Word16 input_q = Q6; - move16(); - - IF( st_ivas->hCombinedOrientationData != NULL ) - { - FOR( i = 0; i < 3; i++ ) - { - scale_sig32( st_ivas->hCombinedOrientationData->Rmat_fx[st_ivas->hCombinedOrientationData->subframe_idx][i], 3, Q1 ); /* Q29 -> Q30 */ - } - } + move16(); ivas_binRenderer_fx( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, @@ -4934,14 +4856,6 @@ void ivas_dirac_dec_render_sf_fx( Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, &input_q ); - IF( st_ivas->hCombinedOrientationData != NULL ) - { - FOR( i = 0; i < 3; i++ ) - { - scale_sig32( st_ivas->hCombinedOrientationData->Rmat_fx[st_ivas->hCombinedOrientationData->subframe_idx][i], 3, -Q1 ); /* Q30 -> Q29 */ - } - } - Scale_sig32( Cldfb_RealBuffer_Binaural_fx[0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); @@ -5265,17 +5179,6 @@ void ivas_dirac_dec_render_sf_fx( } } - IF( EQ_16( hDirAC->hConfig->dec_param_estim, TRUE ) ) - { - FOR( i = 0; i < DIRAC_NO_COL_AVG_DIFF; i++ ) - { - fixedToFloat_arrL32( hDirACRend->buffer_intensity_real_fx[0][i], hDirACRend->buffer_intensity_real[0][i], hDirACRend->q_buffer_intensity_real[i], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); - fixedToFloat_arrL32( hDirACRend->buffer_intensity_real_fx[1][i], hDirACRend->buffer_intensity_real[1][i], hDirACRend->q_buffer_intensity_real[i], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); - fixedToFloat_arrL32( hDirACRend->buffer_intensity_real_fx[2][i], hDirACRend->buffer_intensity_real[2][i], hDirACRend->q_buffer_intensity_real[i], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); - fixedToFloat_arrL32( &hDirACRend->buffer_energy_fx[i * num_freq_bands], &hDirACRend->buffer_energy[i * num_freq_bands], hDirACRend->q_buffer_energy[i], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); - } - } - IF( EQ_16( hDirACRend->proto_signal_decorr_on, 1 ) ) { IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 9e57b7245..52bad0aba 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -45,6 +45,7 @@ #include "prot_fx1.h" #include "prot_fx2.h" #include "ivas_prot_fx.h" +#define IVAS_FLOAT_FIXED_TO_BE_REMOVED #endif // IVAS_FLOAT_FIXED @@ -158,7 +159,7 @@ ivas_error ivas_dec_setup( { /* set Ambisonic (SBA) order used for analysis and coding */ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); -#ifdef IVAS_FLOAT_FIXED0 +#ifdef IVAS_FLOAT_FIXED ivas_sba_config_fx( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init ); #else ivas_sba_config(ivas_total_brate, st_ivas->sba_analysis_order, -1, &(st_ivas->nchan_transport), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init); @@ -208,15 +209,6 @@ ivas_error ivas_dec_setup( { IF( LT_16( n_samples_granularity, st_ivas->hTcBuffer->n_samples_granularity ) ) { - - IF( st_ivas->hCombinedOrientationData ) - FOR( Word16 ind1 = 0; ind1 < 3; ind1++ ) - { - FOR( Word16 ind2 = 0; ind2 < 3; ind2++ ) - { - st_ivas->hCombinedOrientationData->Rmat_fx[0][ind1][ind2] = (Word32) ( st_ivas->hCombinedOrientationData->Rmat[0][ind1][ind2] * ( 1 << 15 ) ); - } - } if ( st_ivas->hSbaIsmData ) { for ( Word16 ch_idx = 0; ch_idx < st_ivas->hSbaIsmData->delayBuffer_nchan; ch_idx++ ) @@ -1027,8 +1019,8 @@ void copy_decoder_config( * * Set decoder parameters to initial values *-------------------------------------------------------------------*/ - -ivas_error ivas_init_decoder_front( +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_init_decoder_front_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { @@ -1058,21 +1050,16 @@ ivas_error ivas_init_decoder_front( IF ( st_ivas->hDecoderConfig->Opt_LsCustom ) { -#ifdef IVAS_FLOAT_FIXED IF ( ( error = ivas_ls_custom_open_fx( &( st_ivas->hLsSetupCustom ) ) ) == IVAS_ERR_OK ) { +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED set_zero((st_ivas->hLsSetupCustom)->ls_azimuth, MAX_OUTPUT_CHANNELS ); set_zero((st_ivas->hLsSetupCustom)->ls_elevation, MAX_OUTPUT_CHANNELS ); -#ifdef IVAS_FLOAT_FIXED +#endif set_zero_fx((st_ivas->hLsSetupCustom)->ls_azimuth_fx, MAX_OUTPUT_CHANNELS ); set_zero_fx((st_ivas->hLsSetupCustom)->ls_elevation_fx, MAX_OUTPUT_CHANNELS ); -#endif - //set_f( ( st_ivas->hLsSetupCustom )->separate_ch_gains, 0.0f, MAX_OUTPUT_CHANNELS ); } ELSE -#else - IF ( ( error = ivas_ls_custom_open( &( st_ivas->hLsSetupCustom ) ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -1082,7 +1069,6 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize Head-Tracking handle *--------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED IF( st_ivas->hDecoderConfig->Opt_Headrotation ) { IF( ( error = ivas_headTrack_open_fx( &( st_ivas->hHeadTrackData ) ) ) != IVAS_ERR_OK ) @@ -1095,19 +1081,7 @@ ivas_error ivas_init_decoder_front( return error; } } -#else - IF( st_ivas->hDecoderConfig->Opt_Headrotation ) - { - IF( ( error = ivas_headTrack_open( &( st_ivas->hHeadTrackData ) ) ) != IVAS_ERR_OK ) - { - return error; - } - IF( ( error = ivas_orient_trk_SetTrackingType( st_ivas->hHeadTrackData->OrientationTracker, st_ivas->hDecoderConfig->orientation_tracking ) ) != IVAS_ERR_OK ) - { - return error; - } - } -#endif + /*-------------------------------------------------------------------* * Allocate and initialize external orientation handle *--------------------------------------------------------------------*/ @@ -1118,7 +1092,7 @@ ivas_error ivas_init_decoder_front( { return error; } -#ifdef IVAS_FLOAT_FIXED +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED for ( Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { st_ivas->hExtOrientationData->Quaternions[i].w = fixedToFloat_32( st_ivas->hExtOrientationData->Quaternions[i].w_fx, st_ivas->hExtOrientationData->Quaternions[i].q_fact ); @@ -1140,7 +1114,7 @@ ivas_error ivas_init_decoder_front( { return error; } -#ifdef IVAS_FLOAT_FIXED +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED for ( Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { st_ivas->hCombinedOrientationData->Quaternions[i].w = fixedToFloat_32( st_ivas->hCombinedOrientationData->Quaternions[i].w_fx, st_ivas->hCombinedOrientationData->Quaternions[i].q_fact ); @@ -1151,20 +1125,6 @@ ivas_error ivas_init_decoder_front( st_ivas->hCombinedOrientationData->listenerPos[i].x = fixedToFloat_32( st_ivas->hCombinedOrientationData->listenerPos[i].x_fx, st_ivas->hCombinedOrientationData->listenerPos[i].q_fact ); st_ivas->hCombinedOrientationData->listenerPos[i].y = fixedToFloat_32( st_ivas->hCombinedOrientationData->listenerPos[i].y_fx, st_ivas->hCombinedOrientationData->listenerPos[i].q_fact ); st_ivas->hCombinedOrientationData->listenerPos[i].z = fixedToFloat_32( st_ivas->hCombinedOrientationData->listenerPos[i].z_fx, st_ivas->hCombinedOrientationData->listenerPos[i].q_fact ); - for ( Word16 j = 0; j < 3; j++ ) - { - for ( Word16 k = 0; k < 3; k++ ) - { - st_ivas->hCombinedOrientationData->Rmat[i][j][k] = (float) fixedToFloat_32( st_ivas->hCombinedOrientationData->Rmat_fx[i][j][k], 30 ); - } - } - } - for ( Word16 j = 0; j < 3; j++ ) - { - for ( Word16 k = 0; k < 3; k++ ) - { - st_ivas->hCombinedOrientationData->Rmat_prev[j][k] = (float) fixedToFloat_32( st_ivas->hCombinedOrientationData->Rmat_prev_fx[j][k], 30 ); - } } #endif } @@ -1175,7 +1135,6 @@ ivas_error ivas_init_decoder_front( IF ( st_ivas->hDecoderConfig->Opt_HRTF_binary ) { -#ifdef IVAS_FLOAT_FIXED IF( ( error = ivas_HRTF_binary_open_fx( &( st_ivas->hHrtfTD ) ) ) != IVAS_ERR_OK ) { return error; @@ -1185,34 +1144,147 @@ ivas_error ivas_init_decoder_front( { return error; } -#else - if ( ( error = ivas_HRTF_binary_open( &( st_ivas->hHrtfTD ) ) ) != IVAS_ERR_OK ) + + IF ( ( error = ivas_HRTF_fastconv_binary_open_fx( &st_ivas->hHrtfFastConv ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = ivas_HRTF_CRend_binary_open( &( st_ivas->hSetOfHRTF ) ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_HRTF_parambin_binary_open_fx( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) { return error; } -#endif + } - IF ( ( error = ivas_HRTF_fastconv_binary_open( &st_ivas->hHrtfFastConv ) ) != IVAS_ERR_OK ) + /*-------------------------------------------------------------------* + * Allocate and initialize Binaural Renderer configuration handle + *--------------------------------------------------------------------*/ + + IF ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB + ) + { + IF ( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ) != IVAS_ERR_OK ) { return error; } -#ifdef IVAS_FLOAT_FIXED - IF( ( error = ivas_HRTF_parambin_binary_open_fx( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) + IF((error = ivas_render_config_init_from_rom_fx(&st_ivas->hRenderConfig)) != IVAS_ERR_OK) + { + return error; + } + +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED + IF ( ( error = ivas_render_config_init_from_rom( &st_ivas->hRenderConfig ) ) != IVAS_ERR_OK ) { return error; } +#endif + } + + return error; +} #else +ivas_error ivas_init_decoder_front( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + ivas_error error; + + error = IVAS_ERR_OK; + + /*-----------------------------------------------------------------* + * Resets + *-----------------------------------------------------------------*/ + + st_ivas->nSCE = 0; + st_ivas->nCPE = 0; + st_ivas->nchan_transport = -1; + + st_ivas->ism_mode = ISM_MODE_NONE; + st_ivas->mc_mode = MC_MODE_NONE; + + st_ivas->sba_dirac_stereo_flag = 0; + + /* HRTF binauralization latency in ns */ + st_ivas->binaural_latency_ns = 0; + + /*-------------------------------------------------------------------* + * Allocate and initialize Custom loudspeaker layout handle + *--------------------------------------------------------------------*/ + + IF ( st_ivas->hDecoderConfig->Opt_LsCustom ) + { + IF ( ( error = ivas_ls_custom_open( &( st_ivas->hLsSetupCustom ) ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /*-------------------------------------------------------------------* + * Allocate and initialize Head-Tracking handle + *--------------------------------------------------------------------*/ + + IF( st_ivas->hDecoderConfig->Opt_Headrotation ) + { + IF( ( error = ivas_headTrack_open( &( st_ivas->hHeadTrackData ) ) ) != IVAS_ERR_OK ) + { + return error; + } + IF( ( error = ivas_orient_trk_SetTrackingType( st_ivas->hHeadTrackData->OrientationTracker, st_ivas->hDecoderConfig->orientation_tracking ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /*-------------------------------------------------------------------* + * Allocate and initialize external orientation handle + *--------------------------------------------------------------------*/ + + IF ( st_ivas->hDecoderConfig->Opt_ExternalOrientation ) + { + IF ( ( error = ivas_external_orientation_open( &( st_ivas->hExtOrientationData ), st_ivas->hDecoderConfig->render_framesize ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /*-------------------------------------------------------------------* + * Allocate and initialize combined orientation handle + *--------------------------------------------------------------------*/ + + IF ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) + { + IF ( ( error = ivas_combined_orientation_open( &( st_ivas->hCombinedOrientationData ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->render_framesize ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /*-------------------------------------------------------------------* + * Allocate HRTF binary handle + *--------------------------------------------------------------------*/ + + IF ( st_ivas->hDecoderConfig->Opt_HRTF_binary ) + { + if ( ( error = ivas_HRTF_binary_open( &( st_ivas->hHrtfTD ) ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( error = ivas_HRTF_CRend_binary_open( &( st_ivas->hSetOfHRTF ) ) ) != IVAS_ERR_OK ) + { + return error; + } + + IF ( ( error = ivas_HRTF_fastconv_binary_open( &st_ivas->hHrtfFastConv ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( ( error = ivas_HRTF_parambin_binary_open( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) { return error; } -#endif } /*-------------------------------------------------------------------* @@ -1227,12 +1299,6 @@ ivas_error ivas_init_decoder_front( return error; } -#ifdef IVAS_FLOAT_FIXED - IF((error = ivas_render_config_init_from_rom_fx(&st_ivas->hRenderConfig)) != IVAS_ERR_OK) - { - return error; - } -#endif /*FLOAT CODE*/ IF ( ( error = ivas_render_config_init_from_rom( &st_ivas->hRenderConfig ) ) != IVAS_ERR_OK ) { @@ -1243,7 +1309,7 @@ ivas_error ivas_init_decoder_front( return error; } - +#endif /*-------------------------------------------------------------------* * ivas_init_decoder() @@ -1347,17 +1413,17 @@ ivas_error ivas_init_decoder_fx( } IF ( ( error = ivas_ls_custom_output_init_fx( st_ivas ) ) == IVAS_ERR_OK ) { -#ifndef IVAS_FLOAT_FIXED - st_ivas->hOutSetup.ls_azimuth = st_ivas->hLsSetupCustom->ls_azimuth; - st_ivas->hOutSetup.ls_elevation = st_ivas->hLsSetupCustom->ls_elevation; - st_ivas->hIntSetup.ls_azimuth = st_ivas->hLsSetupCustom->ls_azimuth; - st_ivas->hIntSetup.ls_elevation = st_ivas->hLsSetupCustom->ls_elevation; -#else +//#ifndef IVAS_FLOAT_FIXED +// st_ivas->hOutSetup.ls_azimuth = st_ivas->hLsSetupCustom->ls_azimuth; +// st_ivas->hOutSetup.ls_elevation = st_ivas->hLsSetupCustom->ls_elevation; +// st_ivas->hIntSetup.ls_azimuth = st_ivas->hLsSetupCustom->ls_azimuth; +// st_ivas->hIntSetup.ls_elevation = st_ivas->hLsSetupCustom->ls_elevation; +//#else st_ivas->hOutSetup.ls_azimuth_fx = st_ivas->hLsSetupCustom->ls_azimuth_fx; st_ivas->hOutSetup.ls_elevation_fx = st_ivas->hLsSetupCustom->ls_elevation_fx; st_ivas->hIntSetup.ls_azimuth_fx = st_ivas->hLsSetupCustom->ls_azimuth_fx; st_ivas->hIntSetup.ls_elevation_fx = st_ivas->hLsSetupCustom->ls_elevation_fx; -#endif +//#endif } ELSE @@ -3713,23 +3779,12 @@ ivas_error ivas_init_decoder( * * Close core decoder handles *-------------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED void destroy_core_dec( DEC_CORE_HANDLE hCoreCoder /* i/o: core decoder structure */ ) { -#ifdef IVAS_FLOAT_FIXED - IF( EQ_16( hCoreCoder->element_mode, EVS_MONO ) ) - { - destroy_cldfb_decoder_fx( hCoreCoder ); - } - ELSE - { - destroy_cldfb_decoder_ivas_fx( hCoreCoder ); - } -#else destroy_cldfb_decoder_flt( hCoreCoder ); -#endif // IVAS_FLOAT_FIXED IF ( hCoreCoder->hGSCDec != NULL ) { @@ -3859,59 +3914,288 @@ void destroy_core_dec( return; } - - -/*------------------------------------------------------------------------- - * ivas_initialize_handles_dec() - * - * NULL initialization of handles - *-------------------------------------------------------------------------*/ - -void ivas_initialize_handles_dec( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#else +void destroy_core_dec_fx( + DEC_CORE_HANDLE hCoreCoder /* i/o: core decoder structure */ ) { - Word16 i; + IF( EQ_16( hCoreCoder->element_mode, EVS_MONO ) ) + { + destroy_cldfb_decoder_fx( hCoreCoder ); + } + ELSE + { + destroy_cldfb_decoder_ivas_fx( hCoreCoder ); + } - FOR ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) + IF ( hCoreCoder->hGSCDec != NULL ) { - st_ivas->cldfbAnaDec[i] = NULL; + free( hCoreCoder->hGSCDec ); + hCoreCoder->hGSCDec = NULL; } - FOR ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + IF ( hCoreCoder->hPFstat != NULL ) { - st_ivas->cldfbSynDec[i] = NULL; + free( hCoreCoder->hPFstat ); + hCoreCoder->hPFstat = NULL; } - /* SCE handles */ - FOR ( i = 0; i < MAX_SCE; i++ ) + IF ( hCoreCoder->hMusicPF != NULL ) { - st_ivas->hSCE[i] = NULL; + free( hCoreCoder->hMusicPF ); + hCoreCoder->hMusicPF = NULL; } - /* CPE handles */ - FOR ( i = 0; i < MAX_CPE; i++ ) + IF ( hCoreCoder->hBPF != NULL ) { - st_ivas->hCPE[i] = NULL; + free( hCoreCoder->hBPF ); + hCoreCoder->hBPF = NULL; } - st_ivas->bit_stream = NULL; - //st_ivas->mem_hp20_out = NULL; -#ifdef IVAS_FLOAT_FIXED - st_ivas->mem_hp20_out_fx = NULL; -#endif // IVAS_FLOAT_FIXED - st_ivas->hLimiter = NULL; + IF ( hCoreCoder->hBWE_zero != NULL ) + { + free( hCoreCoder->hBWE_zero ); + hCoreCoder->hBWE_zero = NULL; + } - /* ISM metadata handles */ - FOR ( i = 0; i < MAX_NUM_OBJECTS; i++ ) + IF ( hCoreCoder->hTdCngDec != NULL ) { - st_ivas->hIsmMetaData[i] = NULL; + free( hCoreCoder->hTdCngDec ); + hCoreCoder->hTdCngDec = NULL; } - /* spatial coding handles */ - st_ivas->hDirAC = NULL; - st_ivas->hParamIsmDec = NULL; - st_ivas->hSpar = NULL; + IF ( hCoreCoder->hSC_VBR != NULL ) + { + free( hCoreCoder->hSC_VBR ); + hCoreCoder->hSC_VBR = NULL; + } + + IF ( hCoreCoder->hAmrwb_IO != NULL ) + { + free( hCoreCoder->hAmrwb_IO ); + hCoreCoder->hAmrwb_IO = NULL; + } + + IF ( hCoreCoder->hBWE_TD != NULL ) + { + free( hCoreCoder->hBWE_TD ); + hCoreCoder->hBWE_TD = NULL; + } + + IF ( hCoreCoder->hBWE_FD != NULL ) + { + free( hCoreCoder->hBWE_FD ); + hCoreCoder->hBWE_FD = NULL; + } + + IF ( hCoreCoder->hBWE_FD_HR != NULL ) + { + free( hCoreCoder->hBWE_FD_HR ); + hCoreCoder->hBWE_FD_HR = NULL; + } + + IF ( hCoreCoder->hWIDec != NULL ) + { + free( hCoreCoder->hWIDec ); + hCoreCoder->hWIDec = NULL; + } + + IF ( hCoreCoder->hTECDec != NULL ) + { + free( hCoreCoder->hTECDec ); + hCoreCoder->hTECDec = NULL; + } + + IF ( hCoreCoder->hTcxLtpDec != NULL ) + { + free( hCoreCoder->hTcxLtpDec ); + hCoreCoder->hTcxLtpDec = NULL; + } + + IF ( hCoreCoder->hTcxDec != NULL ) + { + free( hCoreCoder->hTcxDec ); + hCoreCoder->hTcxDec = NULL; + } + + IF ( hCoreCoder->hTcxCfg != NULL ) + { + free( hCoreCoder->hTcxCfg ); + hCoreCoder->hTcxCfg = NULL; + } + + IF ( hCoreCoder->hTonalMDCTConc != NULL ) + { + free( hCoreCoder->hTonalMDCTConc ); + hCoreCoder->hTonalMDCTConc = NULL; + } + + IF ( hCoreCoder->hIGFDec != NULL ) + { + free( hCoreCoder->hIGFDec ); + hCoreCoder->hIGFDec = NULL; + } + + IF ( hCoreCoder->hPlcInfo != NULL ) + { + free( hCoreCoder->hPlcInfo ); + hCoreCoder->hPlcInfo = NULL; + } + + IF ( hCoreCoder->hHQ_core != NULL ) + { + free( hCoreCoder->hHQ_core ); + hCoreCoder->hHQ_core = NULL; + } + + IF ( hCoreCoder->hHQ_nbfec != NULL ) + { + free( hCoreCoder->hHQ_nbfec ); + hCoreCoder->hHQ_nbfec = NULL; + } + + return; +} +#endif + +/*------------------------------------------------------------------------- + * ivas_initialize_handles_dec() + * + * NULL initialization of handles + *-------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED +void ivas_initialize_handles_dec( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + Word16 i; + + FOR ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) + { + st_ivas->cldfbAnaDec[i] = NULL; + } + + FOR ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + { + st_ivas->cldfbSynDec[i] = NULL; + } + + /* SCE handles */ + FOR ( i = 0; i < MAX_SCE; i++ ) + { + st_ivas->hSCE[i] = NULL; + } + + /* CPE handles */ + FOR ( i = 0; i < MAX_CPE; i++ ) + { + st_ivas->hCPE[i] = NULL; + } + + st_ivas->bit_stream = NULL; + st_ivas->mem_hp20_out = NULL; + st_ivas->hLimiter = NULL; + + /* ISM metadata handles */ + FOR ( i = 0; i < MAX_NUM_OBJECTS; i++ ) + { + st_ivas->hIsmMetaData[i] = NULL; + } + + /* spatial coding handles */ + st_ivas->hDirAC = NULL; + st_ivas->hParamIsmDec = NULL; + st_ivas->hSpar = NULL; + st_ivas->hMasa = NULL; + st_ivas->hQMetaData = NULL; + st_ivas->hMCT = NULL; + st_ivas->hMCParamUpmix = NULL; + st_ivas->hParamMC = NULL; + st_ivas->hLFE = NULL; + + /* rendering handles */ + st_ivas->hBinRenderer = NULL; + st_ivas->hDiracDecBin = NULL; + st_ivas->hDirACRend = NULL; + st_ivas->hSpatParamRendCom = NULL; + st_ivas->hLsSetUpConversion = NULL; + st_ivas->hEFAPdata = NULL; + st_ivas->hVBAPdata = NULL; + st_ivas->hIsmRendererData = NULL; + st_ivas->hBinRendererTd = NULL; + st_ivas->hMonoDmxRenderer = NULL; + st_ivas->hCrendWrapper = NULL; + st_ivas->hReverb = NULL; + st_ivas->hSetOfHRTF = NULL; + st_ivas->hHrtfFastConv = NULL; + st_ivas->hHrtfParambin = NULL; + st_ivas->hoa_dec_mtx = NULL; + st_ivas->hMasaIsmData = NULL; + st_ivas->hSbaIsmData = NULL; + + st_ivas->hHeadTrackData = NULL; + st_ivas->hHrtfTD = NULL; + st_ivas->hLsSetupCustom = NULL; + st_ivas->hRenderConfig = NULL; + st_ivas->hExtOrientationData = NULL; + st_ivas->hCombinedOrientationData = NULL; + + + /* JBM handles */ + st_ivas->hTcBuffer = NULL; + st_ivas->hJbmMetadata = NULL; + + /* floating-point output audio buffers */ + FOR ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) + { + st_ivas->p_output_f[i] = NULL; + } + + return; +} +#else +void ivas_initialize_handles_dec( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + Word16 i; + + FOR ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) + { + st_ivas->cldfbAnaDec[i] = NULL; + } + + FOR ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + { + st_ivas->cldfbSynDec[i] = NULL; + } + + /* SCE handles */ + FOR ( i = 0; i < MAX_SCE; i++ ) + { + st_ivas->hSCE[i] = NULL; + } + + /* CPE handles */ + FOR ( i = 0; i < MAX_CPE; i++ ) + { + st_ivas->hCPE[i] = NULL; + } + + st_ivas->bit_stream = NULL; + st_ivas->mem_hp20_out_fx = NULL; + st_ivas->hLimiter = NULL; + + /* ISM metadata handles */ + FOR ( i = 0; i < MAX_NUM_OBJECTS; i++ ) + { + st_ivas->hIsmMetaData[i] = NULL; + } + + /* spatial coding handles */ + st_ivas->hDirAC = NULL; + st_ivas->hParamIsmDec = NULL; + st_ivas->hSpar = NULL; st_ivas->hMasa = NULL; st_ivas->hQMetaData = NULL; st_ivas->hMCT = NULL; @@ -3919,58 +4203,270 @@ void ivas_initialize_handles_dec( st_ivas->hParamMC = NULL; st_ivas->hLFE = NULL; - /* rendering handles */ - st_ivas->hBinRenderer = NULL; - st_ivas->hDiracDecBin = NULL; - st_ivas->hDirACRend = NULL; - st_ivas->hSpatParamRendCom = NULL; - st_ivas->hLsSetUpConversion = NULL; - st_ivas->hEFAPdata = NULL; - st_ivas->hVBAPdata = NULL; - st_ivas->hIsmRendererData = NULL; - st_ivas->hBinRendererTd = NULL; - st_ivas->hMonoDmxRenderer = NULL; - st_ivas->hCrendWrapper = NULL; - st_ivas->hReverb = NULL; - st_ivas->hSetOfHRTF = NULL; - st_ivas->hHrtfFastConv = NULL; - st_ivas->hHrtfParambin = NULL; - st_ivas->hoa_dec_mtx = NULL; - st_ivas->hMasaIsmData = NULL; - st_ivas->hSbaIsmData = NULL; + /* rendering handles */ + st_ivas->hBinRenderer = NULL; + st_ivas->hDiracDecBin = NULL; + st_ivas->hDirACRend = NULL; + st_ivas->hSpatParamRendCom = NULL; + st_ivas->hLsSetUpConversion = NULL; + st_ivas->hEFAPdata = NULL; + st_ivas->hVBAPdata = NULL; + st_ivas->hIsmRendererData = NULL; + st_ivas->hBinRendererTd = NULL; + st_ivas->hMonoDmxRenderer = NULL; + st_ivas->hCrendWrapper = NULL; + st_ivas->hReverb = NULL; + st_ivas->hSetOfHRTF = NULL; + st_ivas->hHrtfFastConv = NULL; + st_ivas->hHrtfParambin = NULL; + st_ivas->hoa_dec_mtx = NULL; + st_ivas->hMasaIsmData = NULL; + st_ivas->hSbaIsmData = NULL; + + st_ivas->hHeadTrackData = NULL; + st_ivas->hHrtfTD = NULL; + st_ivas->hLsSetupCustom = NULL; + st_ivas->hRenderConfig = NULL; + st_ivas->hExtOrientationData = NULL; + st_ivas->hCombinedOrientationData = NULL; + + + /* JBM handles */ + st_ivas->hTcBuffer = NULL; + st_ivas->hJbmMetadata = NULL; + + /* floating-point output audio buffers */ + FOR ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) + { +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED + st_ivas->p_output_f[i] = NULL; +#endif + st_ivas->p_output_fx[i] = NULL; + } + + return; +} +#endif + +/*------------------------------------------------------------------------- + * ivas_destroy_dec() + * + * Close IVAS decoder handles + *-------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED +void ivas_destroy_dec( + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ +) +{ + Word16 i; + + /* CLDFB handles */ + FOR ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) + { + IF ( st_ivas->cldfbAnaDec[i] != NULL ) + { + deleteCldfb_ivas( &( st_ivas->cldfbAnaDec[i] ) ); + } + } + + FOR ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + { + IF ( st_ivas->cldfbSynDec[i] != NULL ) + { + deleteCldfb_ivas( &( st_ivas->cldfbSynDec[i] ) ); + } + } + + /* SCE handles */ + FOR ( i = 0; i < MAX_SCE; i++ ) + { + IF ( st_ivas->hSCE[i] != NULL ) + { + destroy_sce_dec( st_ivas->hSCE[i] ); + st_ivas->hSCE[i] = NULL; + } + } + + /* CPE handles */ + FOR ( i = 0; i < MAX_CPE; i++ ) + { + IF ( st_ivas->hCPE[i] != NULL ) + { + /* set pointer to NULL as core coder already deallocated in destroy_sce_dec() */ + IF ( st_ivas->sba_dirac_stereo_flag && st_ivas->nchan_transport == 1 ) + { + st_ivas->hCPE[i]->hCoreCoder[0] = NULL; + st_ivas->hCPE[i]->hCoreCoder[1] = NULL; + } + destroy_cpe_dec( st_ivas->hCPE[i] ); + st_ivas->hCPE[i] = NULL; + } + } + + /* HP20 filter handles */ + IF(st_ivas->mem_hp20_out != NULL) + { + FOR(i = 0; i < getNumChanSynthesis(st_ivas); i++) + { + free(st_ivas->mem_hp20_out[i]); + st_ivas->mem_hp20_out[i] = NULL; + } + free(st_ivas->mem_hp20_out); + st_ivas->mem_hp20_out = NULL; + } + /* ISM metadata handles */ + ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); + + /* ISM renderer handle */ + ivas_ism_renderer_close( &( st_ivas->hIsmRendererData ) ); + + /* DirAC handle */ + IF ( st_ivas->ivas_format == ISM_FORMAT ) + { + ivas_param_ism_dec_close( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config ); + } + ELSE + { + ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); + ivas_spat_hSpatParamRendCom_close(&(st_ivas->hSpatParamRendCom)); + ivas_dirac_dec_close(&(st_ivas->hDirAC)); + } + + /* SPAR handle */ + ivas_spar_dec_close( &( st_ivas->hSpar ), st_ivas->hDecoderConfig->output_Fs, 0 ); - st_ivas->hHeadTrackData = NULL; - st_ivas->hHrtfTD = NULL; - st_ivas->hLsSetupCustom = NULL; - st_ivas->hRenderConfig = NULL; - st_ivas->hExtOrientationData = NULL; - st_ivas->hCombinedOrientationData = NULL; + /* HOA decoder matrix */ + IF ( st_ivas->hoa_dec_mtx != NULL ) + { + free( st_ivas->hoa_dec_mtx ); + st_ivas->hoa_dec_mtx = NULL; + } + /* MASA decoder structure */ + ivas_masa_dec_close( &( st_ivas->hMasa ) ); - /* JBM handles */ - st_ivas->hTcBuffer = NULL; - st_ivas->hJbmMetadata = NULL; + /* Qmetadata handle */ + ivas_qmetadata_close( &st_ivas->hQMetaData ); + + /* MCT handle */ + ivas_mct_dec_close( &st_ivas->hMCT ); + + /* LFE handle */ + ivas_lfe_dec_close( &( st_ivas->hLFE ) ); + + /* Param-Upmix MC handle */ + ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) ); + + /* Parametric MC handle */ + ivas_param_mc_dec_close( &st_ivas->hParamMC ); + + /* EFAP handle */ + efap_free_data( &st_ivas->hEFAPdata ); + + /* VBAP handle */ + vbap_free_data( &( st_ivas->hVBAPdata ) ); + + /* Fastconv binaural renderer handle */ + ivas_binRenderer_close( &st_ivas->hBinRenderer ); + + /* Parametric binaural renderer handle */ + ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); + + /* Crend handle */ + + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); + + /* Reverb handle */ + ivas_reverb_close( &st_ivas->hReverb ); + + /* LS config converter handle */ + ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion ); + + /* Custom LS configuration handle */ + IF ( st_ivas->hLsSetupCustom != NULL ) + { + free( st_ivas->hLsSetupCustom ); + st_ivas->hLsSetupCustom = NULL; + } + + /* Mono downmix structure */ + ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer ); + + /* OSBA structure */ + ivas_osba_data_close( &st_ivas->hSbaIsmData ); + + /* OMASA structure */ + ivas_omasa_data_close( &st_ivas->hMasaIsmData ); + + /* Head track data handle */ + ivas_headTrack_close( &st_ivas->hHeadTrackData ); + + /* External orientation data handle */ + ivas_external_orientation_close( &st_ivas->hExtOrientationData ); + + /* Combined orientation data handle */ + ivas_combined_orientation_close( &st_ivas->hCombinedOrientationData ); + + /* Time Domain binaural renderer handle */ + IF ( st_ivas->hBinRendererTd != NULL ) + { + ivas_td_binaural_close( &st_ivas->hBinRendererTd ); + } + ELSE IF ( st_ivas->hHrtfTD != NULL ) + { + BSplineModelEvalDealloc( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval ); + ivas_HRTF_binary_close( &st_ivas->hHrtfTD ); + } + + /* CRend binaural renderer handle */ + ivas_HRTF_CRend_binary_close( &st_ivas->hSetOfHRTF ); + + /* Fastconv HRTF memories */ + ivas_binaural_hrtf_close( &st_ivas->hHrtfFastConv ); + + /* Fastconv HRTF filters */ + ivas_HRTF_fastconv_binary_close( &st_ivas->hHrtfFastConv ); + + /* Parametric binauralizer HRTF filters */ + ivas_HRTF_parambin_binary_close(&st_ivas->hHrtfParambin); + + /* Config. Renderer */ + ivas_render_config_close( &( st_ivas->hRenderConfig ) ); + + /* Limiter struct */ + ivas_limiter_close( &( st_ivas->hLimiter ) ); + + IF ( st_ivas->hDecoderConfig != NULL ) + { + free( st_ivas->hDecoderConfig ); + st_ivas->hDecoderConfig = NULL; + } + + ivas_jbm_dec_tc_buffer_close( &st_ivas->hTcBuffer ); + + IF ( st_ivas->hJbmMetadata != NULL ) + { + free( st_ivas->hJbmMetadata ); + st_ivas->hJbmMetadata = NULL; + } /* floating-point output audio buffers */ FOR ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { - st_ivas->p_output_f[i] = NULL; -#ifdef IVAS_FLOAT_FIXED - st_ivas->p_output_fx[i] = NULL; -#endif + IF ( st_ivas->p_output_f[i] != NULL ) + { + free( st_ivas->p_output_f[i] ); + st_ivas->p_output_f[i] = NULL; + } } + /* main IVAS handle */ + free( st_ivas ); + return; } - - -/*------------------------------------------------------------------------- - * ivas_destroy_dec() - * - * Close IVAS decoder handles - *-------------------------------------------------------------------------*/ - -void ivas_destroy_dec( +#else +void ivas_destroy_dec_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ) { @@ -3981,7 +4477,7 @@ void ivas_destroy_dec( { IF ( st_ivas->cldfbAnaDec[i] != NULL ) { - deleteCldfb_ivas( &( st_ivas->cldfbAnaDec[i] ) ); + deleteCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ) ); } } @@ -3989,7 +4485,7 @@ void ivas_destroy_dec( { IF ( st_ivas->cldfbSynDec[i] != NULL ) { - deleteCldfb_ivas( &( st_ivas->cldfbSynDec[i] ) ); + deleteCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ) ); } } @@ -4020,7 +4516,6 @@ void ivas_destroy_dec( } /* HP20 filter handles */ -#ifdef IVAS_FLOAT_FIXED IF( st_ivas->mem_hp20_out_fx != NULL ) { FOR( i = 0; i < getNumChanSynthesis( st_ivas ); i++ ) @@ -4031,18 +4526,6 @@ void ivas_destroy_dec( free( st_ivas->mem_hp20_out_fx ); st_ivas->mem_hp20_out_fx = NULL; } -#else - IF(st_ivas->mem_hp20_out != NULL) - { - FOR(i = 0; i < getNumChanSynthesis(st_ivas); i++) - { - free(st_ivas->mem_hp20_out[i]); - st_ivas->mem_hp20_out[i] = NULL; - } - free(st_ivas->mem_hp20_out); - st_ivas->mem_hp20_out = NULL; - } -#endif /* ISM metadata handles */ ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); @@ -4052,23 +4535,13 @@ void ivas_destroy_dec( /* DirAC handle */ IF ( st_ivas->ivas_format == ISM_FORMAT ) { -#ifdef IVAS_FLOAT_FIXED ivas_param_ism_dec_close_fx( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config ); -#else - ivas_param_ism_dec_close( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config ); -#endif } ELSE { -#ifdef IVAS_FLOAT_FIXED ivas_dirac_rend_close_fx(&(st_ivas->hDirACRend)); ivas_spat_hSpatParamRendCom_close_fx( &( st_ivas->hSpatParamRendCom ) ); ivas_dirac_dec_close_fx( &( st_ivas->hDirAC ) ); -#else - ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); - ivas_spat_hSpatParamRendCom_close(&(st_ivas->hSpatParamRendCom)); - ivas_dirac_dec_close(&(st_ivas->hDirAC)); -#endif } /* SPAR handle */ @@ -4082,11 +4555,7 @@ void ivas_destroy_dec( } /* MASA decoder structure */ -#ifdef IVAS_FLOAT_FIXED ivas_masa_dec_close_fx( &( st_ivas->hMasa ) ); -#else - ivas_masa_dec_close( &( st_ivas->hMasa ) ); -#endif /* Qmetadata handle */ ivas_qmetadata_close( &st_ivas->hQMetaData ); @@ -4095,38 +4564,22 @@ void ivas_destroy_dec( ivas_mct_dec_close( &st_ivas->hMCT ); /* LFE handle */ -#ifdef IVAS_FLOAT_FIXED ivas_lfe_dec_close_fx( &( st_ivas->hLFE ) ); -#else - ivas_lfe_dec_close( &( st_ivas->hLFE ) ); -#endif // IVAS_FLOAT_FIXED /* Param-Upmix MC handle */ ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) ); /* Parametric MC handle */ -#ifdef IVAS_FLOAT_FIXED ivas_param_mc_dec_close_fx( &st_ivas->hParamMC ); -#else - ivas_param_mc_dec_close( &st_ivas->hParamMC ); -#endif /* EFAP handle */ efap_free_data( &st_ivas->hEFAPdata ); /* VBAP handle */ -#ifdef IVAS_FLOAT_FIXED vbap_free_data_fx(&(st_ivas->hVBAPdata)); -#else - vbap_free_data( &( st_ivas->hVBAPdata ) ); -#endif /* Fastconv binaural renderer handle */ -#ifdef IVAS_FLOAT_FIXED ivas_binRenderer_close_fx( &st_ivas->hBinRenderer ); -#else - ivas_binRenderer_close( &st_ivas->hBinRenderer ); -#endif /* Parametric binaural renderer handle */ ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); @@ -4139,11 +4592,7 @@ void ivas_destroy_dec( ivas_reverb_close( &st_ivas->hReverb ); /* LS config converter handle */ -#ifdef IVAS_FLOAT_FIXED ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion ); -#else - ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion ); -#endif /* Custom LS configuration handle */ IF ( st_ivas->hLsSetupCustom != NULL ) @@ -4156,18 +4605,10 @@ void ivas_destroy_dec( ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer ); /* OSBA structure */ -#ifdef IVAS_FLOAT_FIXED ivas_osba_data_close_fx( &st_ivas->hSbaIsmData ); -#else - ivas_osba_data_close( &st_ivas->hSbaIsmData ); -#endif /* OMASA structure */ -#ifdef IVAS_FLOAT_FIXED ivas_omasa_data_close_fx( &st_ivas->hMasaIsmData ); -#else - ivas_omasa_data_close( &st_ivas->hMasaIsmData ); -#endif /* Head track data handle */ ivas_headTrack_close( &st_ivas->hHeadTrackData ); @@ -4181,48 +4622,28 @@ void ivas_destroy_dec( /* Time Domain binaural renderer handle */ IF ( st_ivas->hBinRendererTd != NULL ) { -#ifdef IVAS_FLOAT_FIXED ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd ); -#else - ivas_td_binaural_close( &st_ivas->hBinRendererTd ); -#endif } ELSE IF ( st_ivas->hHrtfTD != NULL ) { +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED BSplineModelEvalDealloc( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval ); -#ifdef IVAS_FLOAT_FIXED - BSplineModelEvalDealloc_fx( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval ); #endif -#ifdef IVAS_FLOAT_FIXED + BSplineModelEvalDealloc_fx( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval ); ivas_HRTF_binary_close_fx( &st_ivas->hHrtfTD ); -#else - ivas_HRTF_binary_close( &st_ivas->hHrtfTD ); -#endif } /* CRend binaural renderer handle */ -#ifdef IVAS_FLOAT_FIXED ivas_HRTF_CRend_binary_close_fx( &st_ivas->hSetOfHRTF ); -#else - ivas_HRTF_CRend_binary_close( &st_ivas->hSetOfHRTF ); -#endif /* Fastconv HRTF memories */ ivas_binaural_hrtf_close( &st_ivas->hHrtfFastConv ); -#ifdef IVAS_FLOAT_FIXED /* Fastconv HRTF filters */ ivas_HRTF_fastconv_binary_close_fx( &st_ivas->hHrtfFastConv ); /* Parametric binauralizer HRTF filters */ ivas_HRTF_parambin_binary_close_fx( &st_ivas->hHrtfParambin ); -#else - /* Fastconv HRTF filters */ - ivas_HRTF_fastconv_binary_close( &st_ivas->hHrtfFastConv ); - - /* Parametric binauralizer HRTF filters */ - ivas_HRTF_parambin_binary_close(&st_ivas->hHrtfParambin); -#endif /* Config. Renderer */ ivas_render_config_close( &( st_ivas->hRenderConfig ) ); @@ -4247,18 +4668,18 @@ void ivas_destroy_dec( /* floating-point output audio buffers */ FOR ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED IF ( st_ivas->p_output_f[i] != NULL ) { free( st_ivas->p_output_f[i] ); st_ivas->p_output_f[i] = NULL; } -#ifdef IVAS_FLOAT_FIXED +#endif IF(st_ivas->p_output_fx[i] != NULL) { free(st_ivas->p_output_fx[i]); st_ivas->p_output_fx[i] = NULL; } -#endif } /* main IVAS handle */ @@ -4266,7 +4687,7 @@ void ivas_destroy_dec( return; } - +#endif /*-------------------------------------------------------------------* * ivas_init_dec_get_num_cldfb_instances() diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 2666c13d5..ad50220ce 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -3333,14 +3333,6 @@ ivas_error ivas_jbm_dec_render( st_ivas->hTcBuffer->tc_fx[ind1][ind2] = (Word32) ( st_ivas->hTcBuffer->tc[ind1][ind2] * ( 1 << q ) ); } } - IF( st_ivas->hCombinedOrientationData ) - FOR( Word16 ind1 = 0; ind1 < 3; ind1++ ) - { - FOR( Word16 ind2 = 0; ind2 < 3; ind2++ ) - { - st_ivas->hCombinedOrientationData->Rmat_fx[0][ind1][ind2] = (Word32) ( st_ivas->hCombinedOrientationData->Rmat[0][ind1][ind2] * ( 1 << 15 ) ); - } - } ivas_ism_render_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ); FOR( Word16 ind1 = 0; ind1 < s_max( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe, s_max( st_ivas->nchan_transport, st_ivas->nchan_ism ) ); ind1++ ) @@ -3764,15 +3756,6 @@ ivas_error ivas_jbm_dec_render( } } - IF( st_ivas->hCombinedOrientationData ) - FOR( Word16 ind1 = 0; ind1 < 3; ind1++ ) - { - FOR( Word16 ind2 = 0; ind2 < 3; ind2++ ) - { - st_ivas->hCombinedOrientationData->Rmat_fx[0][ind1][ind2] = (Word32) ( st_ivas->hCombinedOrientationData->Rmat[0][ind1][ind2] * ( 1 << 15 ) ); - } - } - ivas_ism_render_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ); FOR( Word16 ind1 = 0; ind1 < s_max( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe, s_max( st_ivas->nchan_transport, st_ivas->nchan_ism ) ); ind1++ ) { @@ -3805,16 +3788,6 @@ ivas_error ivas_jbm_dec_render( } } } - IF(st_ivas->hCombinedOrientationData) - { - FOR(Word16 ind1 = 0; ind1 < 3; ind1++) - { - FOR(Word16 ind2 = 0; ind2 < 3; ind2++) - { - st_ivas->hCombinedOrientationData->Rmat_fx[0][ind1][ind2] = (Word32)(st_ivas->hCombinedOrientationData->Rmat[0][ind1][ind2] * (1 << 15)); - } - } - } IF((error = ivas_osba_render_sf_fx(st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx)) != IVAS_ERR_OK) { return error; @@ -4508,22 +4481,6 @@ ivas_error ivas_jbm_dec_render( } } //ftf for ivas_binRenderer_fx - if (st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM) - { - if (st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && st_ivas->hBinRenderer->rotInCldfb) - { - if (st_ivas->hBinRenderer->hInputSetup->is_loudspeaker_setup == 0) - { - for (i = 0; i < 3; i++) - { - for (j = 0; j < 3; j++) - { - st_ivas->hCombinedOrientationData->Rmat_fx[st_ivas->hCombinedOrientationData->subframe_idx][i][j] = (Word32)floatToFixed(st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx][i][j], 30); - } - } - } - } - } /* CLDFB synthesis */ for (int ch = 0; ch < nchan_out_cldfb; ch++) { diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index fe17075e1..2e30eff0c 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -783,20 +783,6 @@ static void ivas_mc_paramupmix_dec_sf( } } - - //to be deleted - if (st_ivas->hCombinedOrientationData) - { - for ( i = 0; i < 3; i++) - { - for (int j = 0; j < 3; j++) - { - - st_ivas->hCombinedOrientationData->Rmat_fx[st_ivas->hCombinedOrientationData->subframe_idx][i][j] = (Word32)float_to_fix(st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx][i][j], 30); - } - } - } - /* Implement binaural rendering */ Word16 input_q = 6; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 183e03395..eac88cf6d 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -54,6 +54,8 @@ *-----------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED +static ivas_error ivas_mc_dec_reconfig_fx( Decoder_Struct *st_ivas, UWord16 *nSamplesRendered, Word16 *data ); +#else static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, uint16_t *nSamplesRendered, int16_t *data ); #endif @@ -1366,7 +1368,7 @@ ivas_error ivas_mc_dec_config_fx( st_ivas->hRenderConfig->directivity_fx[i * 3 + 2] = shl_sat( st_ivas->hRenderConfig->directivity_fx[i * 3 + 2], 9 ); } } - IF ( ( error = ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_mc_dec_reconfig_fx( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { return error; } @@ -1433,13 +1435,15 @@ ivas_error ivas_mc_dec_config( } #endif + /*------------------------------------------------------------------------- * ivas_mc_dec_reconfig() * * reconfigure the MC format decoder *-------------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED -static ivas_error ivas_mc_dec_reconfig( +static ivas_error ivas_mc_dec_reconfig_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ UWord16 *nSamplesRendered, /* o : number of samples flushed from the last frame (JBM) */ Word16 *data /* o : output synthesis signal */ @@ -2072,11 +2076,10 @@ static ivas_error ivas_mc_dec_reconfig( return error; } #else - static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the last frame (JBM) */ - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ ) { int16_t nchan_transport_old, nSCE_old, nCPE_old, sba_dirac_stereo_flag_old, nchan_hp20_old; @@ -2104,12 +2107,7 @@ static ivas_error ivas_mc_dec_reconfig( ivas_init_dec_get_num_cldfb_instances() returns the correct counts */ mc_mode = st_ivas->mc_mode; st_ivas->mc_mode = last_mc_mode; -#ifdef IVAS_FLOAT_FIXED - ivas_init_dec_get_num_cldfb_instances_ivas_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); -#else ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); -#endif // IVAS_FLOAT_FIXED - st_ivas->mc_mode = mc_mode; nSCE_old = st_ivas->nSCE; @@ -2139,166 +2137,42 @@ static ivas_error ivas_mc_dec_reconfig( /* side effect of the renderer selection can be a changed internal config */ ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); - /* transfer subframe info from DirAC or ParamMC to central tc buffer */ - if ( last_mc_mode == MC_MODE_PARAMMC ) - { - st_ivas->hTcBuffer->nb_subframes = st_ivas->hParamMC->nb_subframes; - st_ivas->hTcBuffer->subframes_rendered = st_ivas->hParamMC->subframes_rendered; - st_ivas->hTcBuffer->num_slots = st_ivas->hParamMC->num_slots; - st_ivas->hTcBuffer->slots_rendered = st_ivas->hParamMC->slots_rendered; -#ifdef IVAS_FLOAT_FIXED - Copy( st_ivas->hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); -#else - mvs2s( st_ivas->hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); -#endif - } - else if ( last_mc_mode == MC_MODE_MCMASA && st_ivas->hSpatParamRendCom != NULL ) - { - st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes; - st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; - st_ivas->hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots; - st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; -#ifdef IVAS_FLOAT_FIXED - Copy( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); -#else - mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); -#endif - } - - /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv - render what still fits in the new granularity */ -#ifdef IVAS_FLOAT_FIXED - tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); -#else - tc_granularity_new = ivas_jbm_dec_get_render_granularity_flt( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); -#endif - if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) - { -#ifdef IVAS_FLOAT_FIXED -#if 1 /*Float to fixed conversion*/ - DECODER_TC_BUFFER_HANDLE hTcBuffer; - hTcBuffer = st_ivas->hTcBuffer; - IF( st_ivas->hCombinedOrientationData ) - FOR( Word16 ind1 = 0; ind1 < 3; ind1++ ) - { - FOR( Word16 ind2 = 0; ind2 < 3; ind2++ ) - { - st_ivas->hCombinedOrientationData->Rmat_fx[0][ind1][ind2] = (Word32) ( st_ivas->hCombinedOrientationData->Rmat[0][ind1][ind2] * ( 1 << 15 ) ); - } - } - if ( st_ivas->hSbaIsmData ) - { - for ( Word16 ch_idx = 0; ch_idx < st_ivas->hSbaIsmData->delayBuffer_nchan; ch_idx++ ) - { - floatToFixed_arr32( st_ivas->hSbaIsmData->delayBuffer[ch_idx], st_ivas->hSbaIsmData->delayBuffer_fx[ch_idx], Q11, st_ivas->hSbaIsmData->delayBuffer_size ); - } - } - SPAR_DEC_HANDLE hSpar; - hSpar = st_ivas->hSpar; - uint16_t nchan_internal; - nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); - DECODER_CONFIG_HANDLE hDecoderConfig; - hDecoderConfig = st_ivas->hDecoderConfig; - Word16 numch_in = 0, numch_out, num_md_sub_frames; - ; - Word16 numch_out_dirac = hDecoderConfig->nchan_out; - IF( hSpar ) - { - numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; - numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - hSpar->hMdDec->Q_mixer_mat = 30; - - for ( Word16 in_ch = 0; in_ch < numch_in; in_ch++ ) - { - for ( Word16 i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ ) - { - st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] = (Word32) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] * ( 1LL << ( Q11 ) ) ); - } - } - if ( ( hDecoderConfig->ivas_total_brate < IVAS_24k4 ) && ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 ) || ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) ) ) - { - for ( Word16 i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) - { - floatToFixed_arrL( hSpar->hMdDec->smooth_buf[i], hSpar->hMdDec->smooth_buf_fx[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); - } - floatToFixed_arr( hSpar->hMdDec->smooth_fac, hSpar->hMdDec->smooth_fac_fx, Q15, IVAS_MAX_NUM_BANDS ); - } - FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) - { - IF( st_ivas->cldfbSynDec[out_ch] ) - { - FOR( Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++ ) - { - st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx[i] = float_to_fix( st_ivas->cldfbSynDec[out_ch]->cldfb_state[i] , Q11 ); - } - } - } - } - Word16 n_tc; - if (st_ivas->ivas_format == MASA_ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT) - n_tc = st_ivas->nchan_ism; - else - n_tc = st_ivas->hTcBuffer->nchan_transport_internal; - for (int ch = 0; ch < n_tc; ch++) - { - floatToFixed_arrL(st_ivas->hTcBuffer->tc[ch], st_ivas->hTcBuffer->tc_fx[ch], Q11, L_FRAME48k); - } -#endif - if ( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, data ) ) != IVAS_ERR_OK ) - { - return error; - } -#if 1 /*Fixed to float */ - if ( hTcBuffer->tc_buffer ) - fixedToFloat_arrL( hTcBuffer->tc_buffer_fx, hTcBuffer->tc_buffer, Q11, hTcBuffer->tc_buff_len ); - IF( hSpar ) - { - FOR( Word16 in_ch = 0; in_ch < numch_in; in_ch++ ) - { - FOR( Word16 i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ ) - { - st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] ) / ( 1LL << ( Q11 ) ) ); - } - } + /* transfer subframe info from DirAC or ParamMC to central tc buffer */ + if ( last_mc_mode == MC_MODE_PARAMMC ) + { + st_ivas->hTcBuffer->nb_subframes = st_ivas->hParamMC->nb_subframes; + st_ivas->hTcBuffer->subframes_rendered = st_ivas->hParamMC->subframes_rendered; + st_ivas->hTcBuffer->num_slots = st_ivas->hParamMC->num_slots; + st_ivas->hTcBuffer->slots_rendered = st_ivas->hParamMC->slots_rendered; + mvs2s( st_ivas->hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + } + else if ( last_mc_mode == MC_MODE_MCMASA && st_ivas->hSpatParamRendCom != NULL ) + { + st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes; + st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; + st_ivas->hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots; + st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; + mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + } - // fix2float (to be cleaned) - IF( ( LT_32( hDecoderConfig->ivas_total_brate, IVAS_24k4 ) ) && ( ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) ) || ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) ) - { - fixedToFloat_arr( hSpar->hMdDec->smooth_fac_fx, hSpar->hMdDec->smooth_fac, Q15, IVAS_MAX_NUM_BANDS ); - FOR( Word16 i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) - { - fixedToFloat_arrL( hSpar->hMdDec->smooth_buf_fx[i], hSpar->hMdDec->smooth_buf[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); - } - } - // fix2float end - FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) - { - IF( st_ivas->cldfbSynDec[out_ch] ) - { - FOR( Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++ ) - { - st_ivas->cldfbSynDec[out_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx[i] ) / (float) ( 1LL << ( Q11 ) ) ); - } - } - } - } -#endif -#else + /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv + render what still fits in the new granularity */ + tc_granularity_new = ivas_jbm_dec_get_render_granularity_flt( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); + if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) + { if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, data ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif // IVAS_FLOAT_FIXED + { + return error; } - /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ - else if ( tc_granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) + } + /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ + else if ( tc_granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) + { + if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) { - if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } + } if ( st_ivas->mc_mode == MC_MODE_MCT ) { @@ -2314,60 +2188,34 @@ static ivas_error ivas_mc_dec_reconfig( ivas_param_mc_dec_close( &st_ivas->hParamMC ); /* remove ls conversion if it was allocated by ParamMC */ -#ifdef IVAS_FLOAT_FIXED - ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion ); -#else ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion ); -#endif } if ( last_mc_mode == MC_MODE_PARAMUPMIX ) { ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) ); -#ifdef IVAS_FLOAT_FIXED - ivas_ls_setup_conversion_close_fx( &( st_ivas->hLsSetUpConversion ) ); -#else ivas_ls_setup_conversion_close( &( st_ivas->hLsSetUpConversion ) ); -#endif } /* De-allocate McMasa-related handles */ -#ifdef IVAS_FLOAT_FIXED - ivas_masa_dec_close_fx( &( st_ivas->hMasa ) ); -#else ivas_masa_dec_close( &( st_ivas->hMasa ) ); -#endif - ivas_qmetadata_close( &st_ivas->hQMetaData ); + if ( st_ivas->hDirAC != NULL ) { -#ifdef IVAS_FLOAT_FIXED - ivas_dirac_rend_close_fx( &( st_ivas->hDirACRend ) ); - ivas_spat_hSpatParamRendCom_close_fx(&(st_ivas->hSpatParamRendCom)); - ivas_dirac_dec_close_fx(&(st_ivas->hDirAC)); - vbap_free_data_fx(&(st_ivas->hVBAPdata)); -#else - ivas_dirac_rend_close(&(st_ivas->hDirACRend)); - ivas_spat_hSpatParamRendCom_close(&(st_ivas->hSpatParamRendCom)); - ivas_dirac_dec_close(&(st_ivas->hDirAC)); + ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); + ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) ); + ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); vbap_free_data( &( st_ivas->hVBAPdata ) ); -#endif } /* init LS conversion if the renderer type asks for it */ if ( st_ivas->renderer_type == RENDERER_MC && st_ivas->hLsSetUpConversion == NULL ) { -#ifdef IVAS_FLOAT_FIXED - if ( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } -#else if ( ( error = ivas_ls_setup_conversion_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } -#endif } } } @@ -2385,34 +2233,19 @@ static ivas_error ivas_mc_dec_reconfig( ivas_param_mc_dec_close( &st_ivas->hParamMC ); /* remove ls conversion if it was allocated by ParamMC */ -#ifdef IVAS_FLOAT_FIXED - ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion ); -#else ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion ); -#endif } -#ifdef IVAS_FLOAT_FIXED - ivas_masa_dec_close_fx( &( st_ivas->hMasa ) ); -#else ivas_masa_dec_close( &( st_ivas->hMasa ) ); -#endif ivas_qmetadata_close( &st_ivas->hQMetaData ); /* init LS conversion if the renderer type asks for it */ if ( ( st_ivas->renderer_type == RENDERER_MC ) && st_ivas->hLsSetUpConversion == NULL ) { -#ifdef IVAS_FLOAT_FIXED - if ( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } -#else if ( ( error = ivas_ls_setup_conversion_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } -#endif } if ( ( error = ivas_mc_paramupmix_dec_open( st_ivas ) ) != IVAS_ERR_OK ) @@ -2428,11 +2261,7 @@ static ivas_error ivas_mc_dec_reconfig( /* remove old ls conversion for MCT if open, gets reopened correctly within ivas_param_mc_dec_open when needed */ if ( renderer_type_old == RENDERER_MC && st_ivas->hLsSetUpConversion != NULL ) { -#ifdef IVAS_FLOAT_FIXED - ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion ); -#else ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion ); -#endif } if ( ( error = ivas_param_mc_dec_open( st_ivas ) ) != IVAS_ERR_OK ) @@ -2442,170 +2271,23 @@ static ivas_error ivas_mc_dec_reconfig( } else { -#ifdef IVAS_FLOAT_FIXED -#if 1 /*TODO: To be removed later (i/o: Float to fixed conversions) */ - PARAM_MC_DEC_HANDLE hParamMC; - hParamMC = st_ivas->hParamMC; - Word16 nchan_out_transport, nchan_out_cov; - MC_LS_SETUP mc_ls_setup; - Word16 nchan_transport; - mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ); - st_ivas->nchan_transport = ivas_param_mc_getNumTransportChannels( ivas_total_brate, mc_ls_setup ); - nchan_transport = st_ivas->nchan_transport; - nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; - Word16 cx_e=0, cy_e=0, mmo_e=0, mmro_e=0; - if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) - { - nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; - } - else - { - nchan_out_cov = nchan_out_transport; - } - if ( st_ivas->hLsSetUpConversion ) - { - for ( Word16 k = 0; k < nchan_out_transport; k++ ) - { - //floatToFixed_arr32( st_ivas->hLsSetUpConversion->dmxMtx[k], st_ivas->hLsSetUpConversion->dmxMtx_fx[k], Q30, nchan_out_cov ); - } - } - if ( st_ivas->hParamMC ) - { - floatToFixed_arr( hParamMC->icc_q, hParamMC->icc_q_fx, Q15, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe ); - floatToFixed_arr( hParamMC->icld_q, hParamMC->icld_q_fx, Q8, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe ); - //if ( hParamMC->ls_conv_dmx_matrix ) - // floatToFixed_arr32( hParamMC->ls_conv_dmx_matrix, hParamMC->ls_conv_dmx_matrix_fx, Q31, nchan_out_cov * nchan_out_transport ); - Word32 max_cx_old_fx, max_cy_old_fx, max_mix_matrix_old_fx, max_mix_matrix_res_old_fx; - float max_cx_old = hParamMC->h_output_synthesis_cov_state.cx_old[0][0], max_cy_old = hParamMC->h_output_synthesis_cov_state.cy_old[0][0], max_mix_matrix_old = hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[0][0], max_mix_matrix_res_old = hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[0][0]; - for ( int i = 0; i < hParamMC->hMetadataPMC->num_parameter_bands; i++ ) - { - if ( hParamMC->h_output_synthesis_cov_state.cx_old[i] ) - { - for ( int j = 0; j < nchan_transport_old * nchan_transport_old; j++ ) - max_cx_old = max( max_cx_old, hParamMC->h_output_synthesis_cov_state.cx_old[i][j] ); - for ( int j = 0; j < nchan_out_cov * nchan_out_cov; j++ ) - max_cy_old = max( max_cy_old, hParamMC->h_output_synthesis_cov_state.cy_old[i][j] ); - for ( int j = 0; j < nchan_transport_old * nchan_out_cov; j++ ) - max_mix_matrix_old = max( max_mix_matrix_old, hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[i][j] ); - } - } - for ( int i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - if ( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[i] ) - { - for ( int j = 0; j < nchan_out_cov * nchan_out_cov; j++ ) - max_mix_matrix_res_old = max( max_mix_matrix_res_old, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[i][j] ); - } - } - f2me( max_cx_old, &max_cx_old_fx, &cx_e ); - f2me( max_cy_old, &max_cy_old_fx, &cy_e ); - f2me( max_mix_matrix_old, &max_mix_matrix_old_fx, &mmo_e ); - f2me( max_mix_matrix_res_old, &max_mix_matrix_res_old_fx, &mmro_e ); - if ( mmo_e < 0 ) - mmo_e = 0; - if ( mmro_e < 0 ) - mmro_e = 0; - for ( int i = 0; i < hParamMC->hMetadataPMC->num_parameter_bands; i++ ) - { - if ( hParamMC->h_output_synthesis_cov_state.cx_old[i] ) - { - - floatToFixed_arrL( hParamMC->h_output_synthesis_cov_state.cx_old[i], hParamMC->h_output_synthesis_cov_state.cx_old_fx[i], 31 - cx_e, nchan_transport_old * nchan_transport_old ); - floatToFixed_arrL( hParamMC->h_output_synthesis_cov_state.cy_old[i], hParamMC->h_output_synthesis_cov_state.cy_old_fx[i], 31 - cy_e, nchan_out_cov * nchan_out_cov ); - floatToFixed_arrL( hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[i], hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[i], 31 - mmo_e, nchan_transport_old * nchan_out_cov ); - } - } - for ( int i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - if ( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[i] ) - { - floatToFixed_arrL( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[i], hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_fx[i], 31 - mmro_e, nchan_out_cov * nchan_out_cov ); - } - } - floatToFixed_arr16( hParamMC->h_output_synthesis_params.interpolator, hParamMC->h_output_synthesis_params.interpolator_fx, 15, DEFAULT_JBM_CLDFB_TIMESLOTS ); - floatToFixed_arrL( hParamMC->proto_matrix_int, hParamMC->proto_matrix_int_fx, Q31, nchan_out_transport * nchan_transport ); - FOR( Word16 i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++ ) - { - if ( hParamMC->diff_proto_info ) - floatToFixed_arrL( hParamMC->diff_proto_info->proto_fac[i], hParamMC->diff_proto_info->proto_fac_fx[i], 31, hParamMC->diff_proto_info->num_source_chan_diff[i] ); - } - } -#endif - if ( ( error = ivas_param_mc_dec_reconfig_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } -#if 1 - if ( hParamMC ) - { - fixedToFloat_arr( hParamMC->icc_q_fx, hParamMC->icc_q, Q15, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe ); - fixedToFloat_arr( hParamMC->icld_q_fx, hParamMC->icld_q, Q8, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe ); - fixedToFloat_arr( hParamMC->h_output_synthesis_params.interpolator_fx, hParamMC->h_output_synthesis_params.interpolator, 15, DEFAULT_JBM_CLDFB_TIMESLOTS ); - for ( int i = 0; i < hParamMC->hMetadataPMC->num_parameter_bands; i++ ) - { - if ( hParamMC->h_output_synthesis_cov_state.cx_old[i] ) - { - fixedToFloat_arrL( hParamMC->h_output_synthesis_cov_state.cx_old_fx[i], hParamMC->h_output_synthesis_cov_state.cx_old[i], 31 - cx_e, nchan_transport_old * nchan_transport_old ); - fixedToFloat_arrL( hParamMC->h_output_synthesis_cov_state.cy_old_fx[i], hParamMC->h_output_synthesis_cov_state.cy_old[i], 31 - cy_e, nchan_out_cov * nchan_out_cov ); - fixedToFloat_arrL( hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[i], hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[i], 31 - mmo_e, nchan_transport_old * nchan_out_cov ); - } - } - for ( int i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - if ( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[i] ) - { - fixedToFloat_arrL( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_fx[i], hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[i], 31 - mmro_e, nchan_out_cov * nchan_out_cov ); - } - } - fixedToFloat_arrL( hParamMC->h_output_synthesis_params.proto_matrix_fx, hParamMC->h_output_synthesis_params.proto_matrix, 31, nchan_transport * nchan_out_cov ); - FOR( Word16 i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++ ) - { - fixedToFloat_arrL( hParamMC->diff_proto_info->proto_fac_fx[i], hParamMC->diff_proto_info->proto_fac[i], 31, hParamMC->diff_proto_info->num_source_chan_diff[i] ); - } - if ( st_ivas->hLsSetUpConversion ) - { - for (Word16 k = 0; k < nchan_transport; k++ ) - { - for ( int16_t i = 0; i < nchan_out_cov; i++ ) - { - //st_ivas->hLsSetUpConversion->dmxMtx[k][i] = fixedToFloat( st_ivas->hLsSetUpConversion->dmxMtx_fx[k][i], Q30 ); - } - } - } - fixedToFloat_arrL( hParamMC->proto_matrix_int_fx, hParamMC->proto_matrix_int, Q31, nchan_out_transport * nchan_transport ); - //if ( hParamMC->ls_conv_dmx_matrix ) - // fixedToFloat_arrL( hParamMC->ls_conv_dmx_matrix_fx, hParamMC->ls_conv_dmx_matrix, Q31, nchan_out_transport * nchan_out_cov ); - } -#endif -#else if ( ( error = ivas_param_mc_dec_reconfig( st_ivas ) ) != IVAS_ERR_OK ) { return error; } -#endif // IVAS_FLOAT_FIXED } /* De-allocate McMasa-related handles */ -#ifdef IVAS_FLOAT_FIXED - ivas_masa_dec_close_fx( &( st_ivas->hMasa ) ); -#else ivas_masa_dec_close( &( st_ivas->hMasa ) ); -#endif ivas_qmetadata_close( &st_ivas->hQMetaData ); if ( st_ivas->hDirAC != NULL ) { -#ifdef IVAS_FLOAT_FIXED - ivas_dirac_rend_close_fx(&(st_ivas->hDirACRend)); - ivas_spat_hSpatParamRendCom_close_fx(&(st_ivas->hSpatParamRendCom)); - ivas_dirac_dec_close_fx(&(st_ivas->hDirAC)); - vbap_free_data_fx(&(st_ivas->hVBAPdata)); -#else ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); - ivas_spat_hSpatParamRendCom_close(&(st_ivas->hSpatParamRendCom)); - ivas_dirac_dec_close(&(st_ivas->hDirAC)); + ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) ); + ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); + vbap_free_data( &( st_ivas->hVBAPdata ) ); -#endif } if ( last_mc_mode == MC_MODE_MCT ) @@ -2621,19 +2303,11 @@ static ivas_error ivas_mc_dec_reconfig( } /* LFE handle */ -#ifdef IVAS_FLOAT_FIXED - ivas_lfe_dec_close_fx( &( st_ivas->hLFE ) ); -#else ivas_lfe_dec_close( &( st_ivas->hLFE ) ); -#endif // IVAS_FLOAT_FIXED } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { -#ifdef IVAS_FLOAT_FIXED - ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); -#else ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); -#endif if ( last_mc_mode != MC_MODE_MCMASA ) { @@ -2651,11 +2325,7 @@ static ivas_error ivas_mc_dec_reconfig( /* LS conversion */ if ( st_ivas->hLsSetUpConversion != NULL ) { -#ifdef IVAS_FLOAT_FIXED - ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion ); -#else ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion ); -#endif } ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) ); @@ -2672,11 +2342,7 @@ static ivas_error ivas_mc_dec_reconfig( } /* LFE handle */ -#ifdef IVAS_FLOAT_FIXED - ivas_lfe_dec_close_fx( &( st_ivas->hLFE ) ); -#else ivas_lfe_dec_close( &( st_ivas->hLFE ) ); -#endif // IVAS_FLOAT_FIXED } if ( st_ivas->mc_mode != MC_MODE_MCMASA ) @@ -2719,20 +2385,7 @@ static ivas_error ivas_mc_dec_reconfig( } st->igf = 0; -#ifdef IVAS_FLOAT_FIXED - init_igf_dec( st->hIGFDec ); -#if 1/*TODO: To be removed later(floating point initialization)*/ -#ifndef IVAS_FLOAT_FIXED - st->hIGFDec->virtualSpec_float = &st->hIGFDec->virtualSpecBuf[0]; - st->hIGFDec->igfData.pSpecFlat_float = &st->hIGFDec->igfData.pSpecFlatBuf[0]; - set_f( st->hIGFDec->igfData.pSpecFlatBuf, 0, IGF_START_MX ); -#endif - FOR(Word16 l = 0; l < IGF_START_MX; l++ ) - st->hIGFDec->infoTCXNoiseBuf[l] = (uint8_t) st->hIGFDec->infoTCXNoise_evs[l]; -#endif -#else init_igf_dec_flt( st->hIGFDec ); -#endif // IVAS_FLOAT_FIXED } if ( st->hHQ_core == NULL ) @@ -2743,14 +2396,7 @@ static ivas_error ivas_mc_dec_reconfig( } /* HQ core initialization */ -#if 1 HQ_core_dec_init_flt( st->hHQ_core ); -#endif -#ifdef IVAS_FLOAT_FIXED - HQ_core_dec_init_fx(st->hHQ_core); -#endif // IVAS_FLOAT_FIXED - - } /* check if we have a doubly used hTxcCfg, if so, allocate a distint one for the old MCT LFE channel */ @@ -2768,13 +2414,8 @@ static ivas_error ivas_mc_dec_reconfig( { uint8_t separateChannelEnabled; int16_t separateChannelIndex; -#ifdef IVAS_FLOAT_FIXED - ivas_mcmasa_set_separate_channel_mode_fx( &separateChannelEnabled, &separateChannelIndex, ivas_total_brate ); - ivas_mcmasa_split_brate_fx( separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &new_brate_SCE, &new_brate_CPE ); -#else ivas_mcmasa_set_separate_channel_mode( &separateChannelEnabled, &separateChannelIndex, ivas_total_brate ); ivas_mcmasa_split_brate( separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &new_brate_SCE, &new_brate_CPE ); -#endif } else if ( st_ivas->mc_mode == MC_MODE_MCT ) { @@ -2792,17 +2433,10 @@ static ivas_error ivas_mc_dec_reconfig( new_brate_CPE = ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS; } -#ifdef IVAS_FLOAT_FIXED - IF ( ( error = ivas_corecoder_dec_reconfig_fx( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, new_brate_SCE, new_brate_CPE ) ) != IVAS_ERR_OK ) - { - return error; - } -#else if ( ( error = ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, new_brate_SCE, new_brate_CPE ) ) != IVAS_ERR_OK ) { return error; } -#endif if ( last_mc_mode == MC_MODE_MCT && st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->nchan_transport > CPE_CHANNELS ) { @@ -2815,38 +2449,19 @@ static ivas_error ivas_mc_dec_reconfig( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TCX-LTP handle\n" ) ); } -#ifdef IVAS_FLOAT_FIXED - tcxltp_dec_init_fx( st->hTcxLtpDec, 0, 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( st->hTcxLtpDec->tcxltp_mem_in, st->hTcxLtpDec->tcxltp_mem_in_float, 0, TCXLTP_MAX_DELAY ); - //fixedToFloat_arr( st->hTcxLtpDec->tcxltp_mem_out, st->hTcxLtpDec->tcxltp_mem_out_float, 0, L_FRAME48k ); - } - } -#else tcxltp_dec_init( st->hTcxLtpDec, 0, st->last_codec_mode, st->element_mode, st->pit_max, st->sr_core ); -#endif // IVAS_FLOAT_FIXED } } /*-----------------------------------------------------------------* * re-configure HP20 memories *-----------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED - if ( (error = ivas_hp20_dec_reconfig_fx(st_ivas, nchan_hp20_old ) ) != IVAS_ERR_OK) - { - return error; - } -#else // IVAS_FLOAT_FIXED - /*To be removed later: Contains memory allocations for floating point buffers*/ + if ( ( error = ivas_hp20_dec_reconfig( st_ivas, nchan_hp20_old ) ) != IVAS_ERR_OK ) { return error; } -#endif + /*-----------------------------------------------------------------* * Allocate the LFE handle that is coded separately after the allocation of the core coders *-----------------------------------------------------------------*/ @@ -2867,22 +2482,13 @@ static ivas_error ivas_mc_dec_reconfig( } } -#ifdef IVAS_FLOAT_FIXED - IF ( ( error = ivas_create_lfe_dec_fx( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, binauralization_delay_ns ) ) != IVAS_ERR_OK ) -#else if ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, binauralization_delay_ns ) ) != IVAS_ERR_OK ) -#endif // IVAS_FLOAT_FIXED { return error; } -#ifndef IVAS_FLOAT_FIXED set_zero( st_ivas->hLFE->prevsynth_buf, LFE_PLC_BUFLEN ); set_zero( st_ivas->hLFE->prior_out_buffer, L_FRAME48k ); -#else - set32_fx(st_ivas->hLFE->prevsynth_buf_fx, 0, LFE_PLC_BUFLEN); - set32_fx(st_ivas->hLFE->prior_out_buffer_fx, 0, L_FRAME48k); -#endif // IVAS_FLOAT_FIXED } /*-----------------------------------------------------------------* @@ -2896,11 +2502,7 @@ static ivas_error ivas_mc_dec_reconfig( if ( st_ivas->hDirAC != NULL ) { /* reconfigure existing DirAC dec */ -#ifdef IVAS_FLOAT_FIXED - if ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) -#else if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -2908,11 +2510,7 @@ static ivas_error ivas_mc_dec_reconfig( else { /* init a new DirAC dec */ -#ifdef IVAS_FLOAT_FIXED - if ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) -#else if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -2920,21 +2518,11 @@ static ivas_error ivas_mc_dec_reconfig( } else if ( st_ivas->renderer_type == RENDERER_DISABLE && st_ivas->hDirAC != NULL ) { -#ifdef IVAS_FLOAT_FIXED - ivas_dirac_rend_close_fx( &( st_ivas->hDirACRend ) ); -#else ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); -#endif // IVAS_FLOAT_FIXED + ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) ); + ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); -#ifdef IVAS_FLOAT_FIXED - ivas_spat_hSpatParamRendCom_close_fx(&(st_ivas->hSpatParamRendCom)); - ivas_dirac_dec_close_fx(&(st_ivas->hDirAC)); - vbap_free_data_fx(&(st_ivas->hVBAPdata)); -#else - ivas_spat_hSpatParamRendCom_close(&(st_ivas->hSpatParamRendCom)); - ivas_dirac_dec_close(&(st_ivas->hDirAC)); vbap_free_data( &( st_ivas->hVBAPdata ) ); -#endif } } @@ -2945,8 +2533,7 @@ static ivas_error ivas_mc_dec_reconfig( output_config = st_ivas->hDecoderConfig->output_config; /* binaural renderers*/ - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB - ) + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { /* remove unneeded binaural renderers */ if ( st_ivas->hBinRenderer != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) ) @@ -2962,11 +2549,7 @@ static ivas_error ivas_mc_dec_reconfig( if ( st_ivas->hBinRendererTd != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) ) { -#ifdef IVAS_FLOAT_FIXED - ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd ); -#else ivas_td_binaural_close( &st_ivas->hBinRendererTd ); -#endif // IVAS_FLOAT_FIXED st_ivas->hHrtfTD = NULL; } @@ -2988,84 +2571,11 @@ static ivas_error ivas_mc_dec_reconfig( } else if ( st_ivas->hBinRendererTd == NULL && st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { -#ifdef IVAS_FLOAT_FIXED -#if 1 /*Cleanup changes: float to fixed */ - Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; - Word16 num_src; - FOR( Word16 i = 0; i < 4; i++ ) - { - st_ivas->hRenderConfig->directivity_fx[i * 3] = (Word16) floatToFixed( st_ivas->hRenderConfig->directivity[i * 3], 6 ); - st_ivas->hRenderConfig->directivity_fx[i * 3 + 1] = (Word16) floatToFixed( st_ivas->hRenderConfig->directivity[i * 3 + 1], 6 ); - st_ivas->hRenderConfig->directivity_fx[i * 3 + 2] = (Word16) floatToFixed( st_ivas->hRenderConfig->directivity[i * 3 + 2], 15 ); - } -#endif - IF( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ) != IVAS_ERR_OK ) - { - return error; - } -#if 1 // Cleanup changes for ivas_td_binaural_open: fixed to float - st_ivas->hBinRendererTd->Gain = 1.0f; /*1.0f Q15*/ - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Pos_fx, st_ivas->hBinRendererTd->Listener_p->Pos, st_ivas->hBinRendererTd->Listener_p->Pos_q, 3 ); - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Vel_fx, st_ivas->hBinRendererTd->Listener_p->Vel, Q30, 3 ); - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Front_fx, st_ivas->hBinRendererTd->Listener_p->Front, Q30, 3 ); - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Up_fx, st_ivas->hBinRendererTd->Listener_p->Up, Q30, 3 ); - fixedToFloat_arrL( st_ivas->hBinRendererTd->Listener_p->Right_fx, st_ivas->hBinRendererTd->Listener_p->Right, Q30, 3 ); - TDREND_DirAtten_t *DirAtten_p = st_ivas->hBinRendererTd->DirAtten_p; - DirAtten_p->ConeInnerAngle = fix_to_float( DirAtten_p->ConeInnerAngle_fx, Q22 ); - DirAtten_p->ConeOuterAngle = fix_to_float( DirAtten_p->ConeOuterAngle_fx, Q22 ); - DirAtten_p->ConeOuterGain = fix_to_float( DirAtten_p->ConeOuterGain_fx, Q30 ); - Word16 nchan_rend = num_src; - IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && NE_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) - { - nchan_rend--; /* Skip LFE channel -- added to the others */ - } - FOR( Word16 nS = 0; nS < nchan_rend; nS++ ) - { - TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]]; - IF( Src_p->SrcSpatial_p != NULL ) - { - Src_p->SrcSpatial_p->DirAtten.ConeInnerAngle = 360.0f; - Src_p->SrcSpatial_p->DirAtten.ConeOuterAngle = 360.0f; - Src_p->SrcSpatial_p->DirAtten.ConeOuterGain = 1.0f; - Src_p->SrcSpatial_p->DistAtten.RefDist = 1.0f; - Src_p->SrcSpatial_p->DistAtten.MaxDist = 15.75f; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ - Src_p->SrcSpatial_p->DistAtten.RollOffFactor = 1.0f; - FOR( Word16 nC = 0; nC < SPAT_BIN_MAX_INPUT_CHANNELS; nC++ ) - { - fixedToFloat_arrL( Src_p->SrcSpatial_p->Pos_p_fx + nC * 3, Src_p->SrcSpatial_p->Pos_p + nC * 3, 15, 3 ); - fixedToFloat_arrL( Src_p->SrcSpatial_p->Front_p_fx + nC * 3, Src_p->SrcSpatial_p->Front_p + nC * 3, 15, 3 ); - } - } - FOR( Word16 nC = 0; nC < SPAT_BIN_MAX_INPUT_CHANNELS; nC++ ) - { - Src_p->SrcRend_p->SrcGainMin_p[nC] = 0.0f; - Src_p->SrcRend_p->SrcGainMax_p[nC] = 1.0f; - } - set_f( Src_p->mem_itd, 0.0f, ITD_MEM_LEN ); - set_f( Src_p->mem_hrf_left, 0.0f, SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1 ); - set_f( Src_p->mem_hrf_right, 0.0f, SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1 ); - set_f( Src_p->hrf_left_prev, 0.0f, SFX_SPAT_BIN_MAX_FILTER_LENGTH ); - set_f( Src_p->hrf_right_prev, 0.0f, SFX_SPAT_BIN_MAX_FILTER_LENGTH ); - Src_p->hrf_left_prev[0] = 1; - Src_p->hrf_right_prev[0] = 1; - Src_p->azim_prev = 0.0f; - Src_p->elev_prev = 0.0f; - Src_p->Gain = 1.0f; - Src_p->prevGain = 1.0f; - TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p; - fixedToFloat_arrL( SrcSpatial_p->Pos_p_fx, SrcSpatial_p->Pos_p, 31, 3 ); - fixedToFloat_arrL( SrcSpatial_p->Front_p_fx, SrcSpatial_p->Front_p, 31, 3 ); - SrcSpatial_p->DirAtten.ConeInnerAngle = fix_to_float( SrcSpatial_p->DirAtten.ConeInnerAngle_fx, Q22 ); - SrcSpatial_p->DirAtten.ConeOuterAngle = fix_to_float( SrcSpatial_p->DirAtten.ConeOuterAngle_fx, Q22 ); - SrcSpatial_p->DirAtten.ConeOuterGain = fix_to_float( SrcSpatial_p->DirAtten.ConeOuterGain_fx, Q30 ); - } -#endif -#else if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } -#endif + if ( st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { if ( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper ) ) != IVAS_ERR_OK ) @@ -3083,30 +2593,10 @@ static ivas_error ivas_mc_dec_reconfig( } else if ( st_ivas->hCrendWrapper == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { -#ifdef IVAS_FLOAT_FIXED /*Cleanup changes: float to fixed*/ - RENDER_CONFIG_DATA *hRendCfg = st_ivas->hRenderConfig; - HRTFS_CREND_HANDLE hSetOfHRTF = st_ivas->hSetOfHRTF; - IF( hSetOfHRTF ) - { - hSetOfHRTF->hHRTF_brir_combined->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_brir_combined->latency_s, 31 ); - hSetOfHRTF->hHRTF_hrir_foa->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_hrir_foa->latency_s, 31 ); - hSetOfHRTF->hHRTF_hrir_combined->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_hrir_combined->latency_s, 31 ); - hSetOfHRTF->hHRTF_hrir_hoa3->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_hrir_hoa3->latency_s, 31 ); - hSetOfHRTF->hHRTF_hrir_hoa2->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_hrir_hoa2->latency_s, 31 ); - } -#endif // 1 if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } -#ifdef IVAS_FLOAT_FIXED/*Cleanup changes: fixed to float*/ - IF(st_ivas->hCrendWrapper && st_ivas->hCrendWrapper->hHrtfCrend != NULL ) - { - st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe = fixedToFloat( st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe_fx, 14 ); - st_ivas->hCrendWrapper->hHrtfCrend->latency_s = fixedToFloat( st_ivas->hCrendWrapper->hHrtfCrend->latency_s_fx, 31 ); - fixedToFloat_arr( st_ivas->hCrendWrapper->hHrtfCrend->inv_diffuse_weight_fx, st_ivas->hCrendWrapper->hHrtfCrend->inv_diffuse_weight, 15, 16 ); - } -#endif st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; } } @@ -3125,46 +2615,10 @@ static ivas_error ivas_mc_dec_reconfig( * CLDFB instances *-----------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED1 -#if 1 /*Cleanup changes: float to fixed*/ - Word16 i, Q_cldfbSynDec = 21; - FOR( i = 0; i < 16; i++ ) - { - IF( st_ivas->cldfbAnaDec[i] ) - floatToFixed_arrL( st_ivas->cldfbAnaDec[i]->cldfb_state, st_ivas->cldfbAnaDec[i]->cldfb_state_fx, 11, sub( st_ivas->cldfbAnaDec[i]->p_filter_length, st_ivas->cldfbAnaDec[i]->no_channels ) ); - } - IF( st_ivas->hSpar ) - { - st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q = Q_factor_arr( st_ivas->hSpar->hFbMixer->cldfb_cross_fade, CLDFB_NO_COL_MAX ); - floatToFixed_arr( st_ivas->hSpar->hFbMixer->cldfb_cross_fade, st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q, CLDFB_NO_COL_MAX ); - } - IF( st_ivas->cldfbSynDec[0] ) - { - Q_cldfbSynDec = s_min( Q_cldfbSynDec, Q_factor_arrL( st_ivas->cldfbSynDec[0]->cldfb_state, sub( st_ivas->cldfbSynDec[0]->p_filter_length, st_ivas->cldfbSynDec[0]->no_channels ) ) ); - floatToFixed_arrL( st_ivas->cldfbSynDec[0]->cldfb_state, st_ivas->cldfbSynDec[0]->cldfb_state_fx, Q_cldfbSynDec, sub( st_ivas->cldfbAnaDec[i]->p_filter_length, st_ivas->cldfbAnaDec[i]->no_channels ) ); - } -#endif - if ( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ) ) != IVAS_ERR_OK ) - { - return error; - } -#if 1 /*CCleanup changes:fixed to float changes*/ - FOR( i = 0; i < 16; i++ ) - { - IF( st_ivas->cldfbAnaDec[i] ) - fixedToFloat_arrL( st_ivas->cldfbAnaDec[i]->cldfb_state_fx, st_ivas->cldfbAnaDec[i]->cldfb_state, 11, sub( st_ivas->cldfbAnaDec[i]->p_filter_length, st_ivas->cldfbAnaDec[i]->no_channels ) ); - } - IF( st_ivas->cldfbSynDec[0] ) - { - fixedToFloat_arrL( st_ivas->cldfbSynDec[0]->cldfb_state_fx, st_ivas->cldfbSynDec[0]->cldfb_state, Q_cldfbSynDec, sub( st_ivas->cldfbAnaDec[i]->p_filter_length, st_ivas->cldfbAnaDec[i]->no_channels ) ); - } -#endif -#else if ( ( error = ivas_cldfb_dec_reconfig( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ) ) != IVAS_ERR_OK ) { return error; } -#endif // IVAS_FLOAT_FIXED /*-----------------------------------------------------------------* * JBM TC buffers @@ -3176,11 +2630,7 @@ static ivas_error ivas_mc_dec_reconfig( hTcBuffer = st_ivas->hTcBuffer; tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); -#ifdef IVAS_FLOAT_FIXED - tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); -#else tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas ); -#endif // IVAS_FLOAT_FIXED tc_nchan_allocate_new = tc_nchan_tc_new; tc_nchan_full_new = tc_nchan_tc_new; @@ -3212,17 +2662,10 @@ static ivas_error ivas_mc_dec_reconfig( hTcBuffer->nchan_buffer_full != tc_nchan_full_new || hTcBuffer->nchan_transport_internal != tc_nchan_allocate_new || tc_granularity_new != hTcBuffer->n_samples_granularity ) { -#ifdef IVAS_FLOAT_FIXED - if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ) != IVAS_ERR_OK ) - { - return error; - } -#else if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ) != IVAS_ERR_OK ) { return error; } -#endif // IVAS_FLOAT_FIXED } /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ if ( st_ivas->hSpatParamRendCom != NULL ) @@ -3231,11 +2674,7 @@ static ivas_error ivas_mc_dec_reconfig( st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; st_ivas->hSpatParamRendCom->num_slots = st_ivas->hTcBuffer->num_slots; st_ivas->hSpatParamRendCom->slots_rendered = st_ivas->hTcBuffer->slots_rendered; -#ifdef IVAS_FLOAT_FIXED - Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); -#else mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); -#endif // IVAS_FLOAT_FIXED } else if ( st_ivas->hParamMC != NULL ) { @@ -3243,11 +2682,7 @@ static ivas_error ivas_mc_dec_reconfig( st_ivas->hParamMC->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; st_ivas->hParamMC->num_slots = st_ivas->hTcBuffer->num_slots; st_ivas->hParamMC->slots_rendered = st_ivas->hTcBuffer->slots_rendered; -#ifdef IVAS_FLOAT_FIXED - Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hParamMC->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); -#else mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hParamMC->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); -#endif } } @@ -3256,23 +2691,12 @@ static ivas_error ivas_mc_dec_reconfig( * floating-point output audio buffers *-----------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED - nchan_out_buff = ivas_get_nchan_buffers_dec_ivas_fx( st_ivas, -1, -1 ); -#else - nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); - -#endif + nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); -#ifdef IVAS_FLOAT_FIXED - IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) { return error; } -#endif // IVAS_FLOAT_FIXED - if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) - { - return error; - } return error; } diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index af6a0705f..3ccf653e9 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -327,15 +327,6 @@ ivas_error ivas_omasa_dec_config_fx( { IF(LT_16(n_samples_granularity, st_ivas->hTcBuffer->n_samples_granularity)) { - - IF(st_ivas->hCombinedOrientationData) - FOR(Word16 ind1 = 0; ind1 < 3; ind1++) - { - FOR(Word16 ind2 = 0; ind2 < 3; ind2++) - { - st_ivas->hCombinedOrientationData->Rmat_fx[0][ind1][ind2] = (Word32)(st_ivas->hCombinedOrientationData->Rmat[0][ind1][ind2] * (1 << 15)); - } - } if (st_ivas->hSbaIsmData) { for (Word16 ch_idx = 0; ch_idx < st_ivas->hSbaIsmData->delayBuffer_nchan; ch_idx++) diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 3ea7685a7..771685410 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -53,6 +53,7 @@ * Allocate and initialize SBA_ISM rendering handle *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_osba_data_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ) @@ -86,8 +87,7 @@ ivas_error ivas_osba_data_open( return IVAS_ERR_OK; } - -#ifdef IVAS_FLOAT_FIXED +#else ivas_error ivas_osba_data_open_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ) @@ -136,12 +136,14 @@ ivas_error ivas_osba_data_open_fx( } #endif + /*-------------------------------------------------------------------* * ivas_osba_data_close() * * Deallocate SBA_ISM rendering handle *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_osba_data_close( SBA_ISM_DATA_HANDLE *hSbaIsmData /* i/o: OSBA rendering handle */ ) @@ -168,8 +170,7 @@ void ivas_osba_data_close( return; } - -#ifdef IVAS_FLOAT_FIXED +#else void ivas_osba_data_close_fx( SBA_ISM_DATA_HANDLE *hSbaIsmData /* i/o: OSBA rendering handle */ ) @@ -210,6 +211,7 @@ void ivas_osba_data_close_fx( } #endif + /*--------------------------------------------------------------------------* * ivas_osba_dirac_td_binaural_jbm() * @@ -311,6 +313,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( * * ISM metadata decoding in OSBA format. *-------------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED ivas_error ivas_osba_ism_metadata_dec_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -336,7 +339,6 @@ ivas_error ivas_osba_ism_metadata_dec_fx( return IVAS_ERR_OK; } #else - ivas_error ivas_osba_ism_metadata_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int32_t ism_total_brate, /* i : ISM total bitrate */ @@ -361,11 +363,14 @@ ivas_error ivas_osba_ism_metadata_dec( return IVAS_ERR_OK; } #endif + + /*-------------------------------------------------------------------------* * ivas_osba_render_sf() * * Object + SBA rendering process. *-------------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED ivas_error ivas_osba_render_sf_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 6cae8ac1e..608dafe55 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -1025,14 +1025,6 @@ ivas_error ivas_sba_dec_reconfigure_fx( st_ivas->hIsmMetaData[ind1]->elevation_fx = (Word32) ( st_ivas->hIsmMetaData[ind1]->elevation * ( 1 << 22 ) ); } } - IF( st_ivas->hCombinedOrientationData ) - FOR( Word16 ind1 = 0; ind1 < 3; ind1++ ) - { - FOR( Word16 ind2 = 0; ind2 < 3; ind2++ ) - { - st_ivas->hCombinedOrientationData->Rmat_fx[0][ind1][ind2] = (Word32) ( st_ivas->hCombinedOrientationData->Rmat[0][ind1][ind2] * ( 1 << 15 ) ); - } - } if ( st_ivas->hSbaIsmData ) { for ( Word16 ch_idx = 0; ch_idx < st_ivas->hSbaIsmData->delayBuffer_nchan; ch_idx++ ) diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index b448f259f..9974fcc2a 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -443,7 +443,7 @@ void destroy_sce_dec( IF( st != NULL ) { - destroy_core_dec( st ); + destroy_core_dec_fx( st ); free( st ); st = NULL; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index ca390f894..3594b9492 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1076,10 +1076,10 @@ typedef struct ivas_spar_dec_lib_t /* Data structure for SBA_ISM rendering */ typedef struct ivas_osba_data { -#ifdef IVAS_FLOAT_FIXED - Word32 **delayBuffer_fx; -#endif // IVAS_FLOAT_FIXED float **delayBuffer; +#ifdef IVAS_FLOAT_FIXED + Word32 **delayBuffer_fx; /* Q11 */ +#endif int16_t delayBuffer_size; int16_t delayBuffer_nchan; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 95a3d4a25..ab8475dfe 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -294,7 +294,7 @@ void IVAS_DEC_Close( IF( ( *phIvasDec )->st_ivas ) { - ivas_destroy_dec( ( *phIvasDec )->st_ivas ); + ivas_destroy_dec_fx( ( *phIvasDec )->st_ivas ); ( *phIvasDec )->st_ivas = NULL; } @@ -451,7 +451,7 @@ ivas_error IVAS_DEC_Configure( /* Set decoder parameters to initial values */ - IF( ( error = ivas_init_decoder_front( st_ivas ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_init_decoder_front_fx( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -869,13 +869,6 @@ ivas_error IVAS_DEC_GetSamples( hIvasDec->st_ivas->hCombinedOrientationData->Quaternions[i].x = fixedToFloat_32( hIvasDec->st_ivas->hCombinedOrientationData->Quaternions[i].x_fx, hIvasDec->st_ivas->hCombinedOrientationData->Quaternions[i].q_fact ); hIvasDec->st_ivas->hCombinedOrientationData->Quaternions[i].y = fixedToFloat_32( hIvasDec->st_ivas->hCombinedOrientationData->Quaternions[i].y_fx, hIvasDec->st_ivas->hCombinedOrientationData->Quaternions[i].q_fact ); hIvasDec->st_ivas->hCombinedOrientationData->Quaternions[i].z = fixedToFloat_32( hIvasDec->st_ivas->hCombinedOrientationData->Quaternions[i].z_fx, hIvasDec->st_ivas->hCombinedOrientationData->Quaternions[i].q_fact ); - for (Word16 j = 0; j < 3; j++ ) - { - for ( Word16 k = 0; k < 3; k++ ) - { - hIvasDec->st_ivas->hCombinedOrientationData->Rmat[i][j][k] = (float) fixedToFloat_32( hIvasDec->st_ivas->hCombinedOrientationData->Rmat_fx[i][j][k], 30 ); - } - } } hIvasDec->updateOrientation = false; } diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c index 671e069fe..824311873 100644 --- a/lib_dec/swb_tbe_dec.c +++ b/lib_dec/swb_tbe_dec.c @@ -1864,7 +1864,7 @@ void ivas_swb_tbe_dec_fx( #endif } } - ener_fx = s_max( 1, round_fx( L_shl( L_ener, sub( 19, shl( Q_bwe_exc, 1 ) ) ) ) ); /* Q3: 2*Q_bwe_exc+19-2*Q_bwe_exc-16 */ + ener_fx = s_max( 1, round_fx( L_shl( L_ener, sub( 18, shl( Q_bwe_exc, 1 ) ) ) ) ); /* Q2: 2*Q_bwe_exc+18-2*Q_bwe_exc-16 */ /* WB/SWB bandwidth switching */ IF( st->bws_cnt > 0 ) @@ -1911,10 +1911,10 @@ void ivas_swb_tbe_dec_fx( IF( ener_fx != 0 ) { - L_tmp = L_shl( L_mult0( ener_fx, st->tilt_wb_fx ), sub( st->Q_syn2, 14 ) ); /* 3+11 +st->Q_syn2 -14 = st->Q_syn2*/ + L_tmp = L_shl( L_mult0( ener_fx, st->tilt_wb_fx ), sub( st->Q_syn2, 13 ) ); /* 2+11 +st->Q_syn2 -13 = st->Q_syn2*/ exp_ener = norm_s( ener_fx ); - tmp = shl( ener_fx, exp_ener ); /*Q(3+exp)*/ - inv_ener = div_s( 16384, tmp ); /*Q(15+14-3-exp) = 26- exp*/ + tmp = shl( ener_fx, exp_ener ); /*Q(2+exp)*/ + inv_ener = shr(div_s( 16384, tmp ), 1); /*Q(15+14-2-exp-1) = 26 - exp*/ test(); IF( GT_32( L_tmp, st->enerLH_fx ) ) /*st->Q_syn2*/ @@ -1996,9 +1996,9 @@ void ivas_swb_tbe_dec_fx( { ener_fx = s_max( 1, ener_fx ); exp_ener = norm_s( ener_fx ); - tmp = shl( ener_fx, exp_ener ); /*Q(3+exp)*/ - inv_ener = div_s( 16384, tmp ); /*Q(15+14-3-exp)*/ - prev_ener_ratio_fx = L_shr( L_mult0( st->prev_ener_shb_fx, inv_ener ), sub( 9, exp_ener ) ); /*Q: 1+26-exp-9+exp = 18 */ + tmp = shl( ener_fx, exp_ener ); /*Q(2+exp)*/ + inv_ener = div_s( 16384, tmp ); /*Q(15+14-2-exp)*/ + prev_ener_ratio_fx = L_shr( L_mult0( st->prev_ener_shb_fx, inv_ener ), add( sub( 9, exp_ener ), 1 ) ); /*Q: 1+27-exp-9+exp-1 = 18 */ } IF( st->nbLostCmpt == 1 ) diff --git a/lib_enc/ivas_lfe_enc.c b/lib_enc/ivas_lfe_enc.c index b36d349cb..d248f6266 100644 --- a/lib_enc/ivas_lfe_enc.c +++ b/lib_enc/ivas_lfe_enc.c @@ -839,6 +839,9 @@ ivas_error ivas_create_lfe_enc( } ivas_lfe_window_init( hLFE->pWindow_state, input_Fs, input_frame ); +#ifdef IVAS_FLOAT_FIXED + ivas_lfe_window_init_fx( hLFE->pWindow_state, input_Fs, input_frame ); +#endif /* Initialization for entropy coding */ hLFE->cum_freq_models[0][0] = ivas_str_lfe_freq_models.entropy_coder_model_fine_sg1; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 037435a67..9fc7edc06 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -3803,9 +3803,9 @@ static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked_fx( Word32 switchOrderFactor, origOrderFactor; Word16 e_switchOrderFactor, e_origOrderFactor; - hHeadTrackData->lrSwitchInterpVal_fx = L_add( hHeadTrackData->lrSwitchInterpVal_fx, 2684354 ); /* Corresponds to 0.5 seconds interpolation time */ // Q14 + hHeadTrackData->lrSwitchInterpVal_fx = L_add( hHeadTrackData->lrSwitchInterpVal_fx, 2684354 /* 0.0025f in Q30 */ ); /* Corresponds to 0.5 seconds interpolation time */ /* Q30 */ - IF( GT_32( hHeadTrackData->lrSwitchInterpVal_fx, 1072668096 ) ) + IF( GT_32( hHeadTrackData->lrSwitchInterpVal_fx, 1072668096 /* 0.999f in Q30 */ ) ) { /* Stop interpolation, reset values */ hHeadTrackData->lrSwitchInterpVal_fx = 0; @@ -3813,8 +3813,8 @@ static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked_fx( } /* Gains for determining portion of switched channel order and original channel order */ - tmpVal = Mpy_32_16_1( hHeadTrackData->lrSwitchInterpVal_fx, (Word16) hHeadTrackData->lrSwitchedNext ); // Q15 - tmpVal = L_add( tmpVal, Mpy_32_16_1( L_sub( ONE_IN_Q30, hHeadTrackData->lrSwitchInterpVal_fx ), (Word16) hHeadTrackData->lrSwitchedCurrent ) ); // Q15 + tmpVal = Mpy_32_16_1( hHeadTrackData->lrSwitchInterpVal_fx, (Word16) hHeadTrackData->lrSwitchedNext ); /* Q15 */ + tmpVal = L_add( tmpVal, Mpy_32_16_1( L_sub( ONE_IN_Q30, hHeadTrackData->lrSwitchInterpVal_fx ), (Word16) hHeadTrackData->lrSwitchedCurrent ) ); /* Q15 */ e_switchOrderFactor = 0; e_origOrderFactor = 0; diff --git a/lib_rend/ivas_dirac_decorr_dec.c b/lib_rend/ivas_dirac_decorr_dec.c index 657e633a3..398a63688 100644 --- a/lib_rend/ivas_dirac_decorr_dec.c +++ b/lib_rend/ivas_dirac_decorr_dec.c @@ -949,6 +949,10 @@ void ivas_dirac_dec_decorr_process_fx( Word32 *decorr_buffer_start_ptr_fx, *decorr_buffer_ptr_fx; Word32 input_real_fx, input_imag_fx, filter_frame_imag_fx, filter_frame_real_fx; Word16 q_aux_buffer, q_onset_dec, q_frame_f; + Word16 max_band_decorr_temp = h_freq_domain_decorr_ap_params->h_onset_detection_power_params.max_band_decorr; + Word16 q_shift, guarded_bits; + Word32 max_abs_val = 0; + push_wmops( "dirac_decorr_process" ); @@ -991,10 +995,8 @@ void ivas_dirac_dec_decorr_process_fx( /* compute power */ q_onset_dec = h_freq_domain_decorr_ap_state->h_onset_detection_power_state.q_onset_detector; - Word16 max_band_decorr_temp = h_freq_domain_decorr_ap_params->h_onset_detection_power_params.max_band_decorr; - - Word16 q_shift, guarded_bits; guarded_bits = find_guarded_bits_fx( 2 ); +#if 0 FOR( ch_idx = 0; ch_idx < num_protos_dir; ch_idx++ ) { v_mult_fixed( &input_frame_fx[2 * ch_idx * num_freq_bands], &input_frame_fx[2 * ch_idx * num_freq_bands], &aux_buffer_fx[2 * ch_idx * max_band_decorr_temp], 2 * max_band_decorr_temp ); @@ -1008,6 +1010,28 @@ void ivas_dirac_dec_decorr_process_fx( aux_buffer_fx[j] = L_shl( aux_buffer_fx[j], q_shift ); } q_aux_buffer += q_shift; +#else + (void)maximum_abs_32_fx(&input_frame_fx[0], 2 * num_protos_dir * num_freq_bands, &max_abs_val); + q_shift = getScaleFactor32( &input_frame_fx[0], 2 * num_protos_dir * num_freq_bands ) - guarded_bits; + IF (LT_16(q_shift , sub(0, guarded_bits)) && NE_32(max_abs_val, 0)) + { + q_shift = sub(0, guarded_bits); + } + ELSE IF (EQ_32(max_abs_val, 0)) + { + q_shift = 0; + } + FOR ( ch_idx = 0; ch_idx < num_protos_dir; ch_idx++) + { + v_shr(&input_frame_fx[2 * ch_idx * num_freq_bands], negate(q_shift), &aux_buffer_fx[2 * ch_idx * num_freq_bands], 2 * num_freq_bands); + } + FOR( ch_idx = 0; ch_idx < num_protos_dir; ch_idx++ ) + { + v_mult_fixed( &aux_buffer_fx[2 * ch_idx * num_freq_bands], &aux_buffer_fx[2 * ch_idx * num_freq_bands], &aux_buffer_fx[2 * ch_idx * max_band_decorr_temp], 2 * max_band_decorr_temp ); + } + q_aux_buffer = q_input_frame + q_input_frame + q_shift + q_shift - 31; + +#endif FOR( ch_idx = 0; ch_idx < num_protos_dir; ch_idx++ ) { diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index a7ad619dd..36bb841ac 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -4021,7 +4021,7 @@ static void ivas_dirac_dec_get_response_split_order_fx( const Word16 elevation, Word32 *response, const Word16 shd_rot_max_order, - const Word32 *p_Rmat /*Q29*/, + const Word32 *p_Rmat /* Q30 */, Word16 *q_response ) { Word16 index_azimuth, index_elevation; @@ -4152,9 +4152,9 @@ static void ivas_dirac_dec_get_response_split_order_fx( dv_2 = L_shr( Mpy_32_16_1( dirac_gains_trg_term_int[el][0], e ), 1 ); // Q28 /*Rotation mtx multiplication*/ - dv_r_0 = Madd_32_32( Madd_32_32( Mpy_32_32( p_Rmat[0], dv_0 ), p_Rmat[1], dv_1 ), p_Rmat[2], dv_2 ); // Q26 - dv_r_1 = Madd_32_32( Madd_32_32( Mpy_32_32( p_Rmat[3], dv_0 ), p_Rmat[4], dv_1 ), p_Rmat[5], dv_2 ); // Q26 - dv_r_2 = Madd_32_32( Madd_32_32( Mpy_32_32( p_Rmat[6], dv_0 ), p_Rmat[7], dv_1 ), p_Rmat[8], dv_2 ); // Q26 + dv_r_0 = Madd_32_32( Madd_32_32( Mpy_32_32( L_shr( p_Rmat[0], Q1 ), dv_0 ), L_shr( p_Rmat[1], Q1 ), dv_1 ), L_shr( p_Rmat[2], Q1 ), dv_2 ); // Q26 + dv_r_1 = Madd_32_32( Madd_32_32( Mpy_32_32( L_shr( p_Rmat[3], Q1 ), dv_0 ), L_shr( p_Rmat[4], Q1 ), dv_1 ), L_shr( p_Rmat[5], Q1 ), dv_2 ); // Q26 + dv_r_2 = Madd_32_32( Madd_32_32( Mpy_32_32( L_shr( p_Rmat[6], Q1 ), dv_0 ), L_shr( p_Rmat[7], Q1 ), dv_1 ), L_shr( p_Rmat[8], Q1 ), dv_2 ); // Q26 tmp = BASOP_util_atan2( dv_r_1, dv_r_0, 0 ); // Q13 index_azimuth = shr( mult( tmp, _180_OVER_PI_Q9 ), 7 ); // Q0; diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index accca0e5b..ee6289366 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -743,13 +743,6 @@ void ivas_dirac_rend_close_fx( { FOR (j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++) { -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED - IF (hDirACRend->buffer_intensity_real[i][j] != NULL) - { - free(hDirACRend->buffer_intensity_real[i][j]); - hDirACRend->buffer_intensity_real[i][j] = NULL; - } -#endif IF (hDirACRend->buffer_intensity_real_fx[i][j] != NULL) { free(hDirACRend->buffer_intensity_real_fx[i][j]); @@ -757,13 +750,6 @@ void ivas_dirac_rend_close_fx( } } } -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED - IF (hDirACRend->buffer_energy != NULL) - { - free(hDirACRend->buffer_energy); - hDirACRend->buffer_energy = NULL; - } -#endif IF (hDirACRend->buffer_energy_fx != NULL) { free(hDirACRend->buffer_energy_fx); @@ -782,9 +768,7 @@ void ivas_dirac_rend_close_fx( return; } - #else - void ivas_dirac_rend_close( DIRAC_REND_HANDLE *hDirACRend_out ) { @@ -1374,8 +1358,6 @@ ivas_error ivas_dirac_alloc_mem( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q = Q31; hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q = Q31; hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q = Q31; - set_s( hDirACRend->q_buffer_energy, Q31, CLDFB_NO_CHANNELS_MAX ); - set_s( hDirACRend->q_buffer_intensity_real, Q31, CLDFB_NO_CHANNELS_MAX ); #endif /* Target and smoothed nrg factors/gains */ @@ -1520,6 +1502,9 @@ ivas_error ivas_dirac_alloc_mem( hDirAC_mem->proto_diffuse_buffer_f_len = 2 * MAX_PARAM_SPATIAL_SUBFRAMES * num_outputs_diff * num_freq_bands; #endif } +#ifdef MSAN_FIX + set_zero_fx(hDirAC_mem->proto_diffuse_buffer_f_fx, hDirAC_mem->proto_diffuse_buffer_f_len); +#endif } } hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f = hDirAC_mem->proto_direct_buffer_f; @@ -2212,7 +2197,7 @@ void protoSignalComputation_shd_fx( const Word16 num_inputs, const Word16 num_outputs_diff, const Word16 num_freq_bands, - Word32 *p_Rmat_fx, /* Q29*/ + Word32 *p_Rmat_fx, /* Q30 */ Word16 q_cldfb ) { Word16 l, k; @@ -2267,9 +2252,9 @@ void protoSignalComputation_shd_fx( move32(); p_proto_direct_buffer_fx[add( i_mult( 2, l ), 1 )] = im1; move32(); - p_proto_direct_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = L_shl( Mpy_32_32( p_Rmat_fx[0], re2 ), 2 ); // left shift is done to maintain constant Q factor for p_proto_direct_buffer_fx + p_proto_direct_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = L_shl( Mpy_32_32( p_Rmat_fx[0], re2 ), Q1 ); // left shift is done to maintain constant Q factor for p_proto_direct_buffer_fx move32(); - p_proto_direct_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = L_shl( Mpy_32_32( p_Rmat_fx[0], im2 ), 2 ); // left shift is done to maintain constant Q factor for p_proto_direct_buffer_fx + p_proto_direct_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = L_shl( Mpy_32_32( p_Rmat_fx[0], im2 ), Q1 ); // left shift is done to maintain constant Q factor for p_proto_direct_buffer_fx move32(); } *proto_direct_buffer_f_q = q_cldfb; @@ -2357,7 +2342,7 @@ void protoSignalComputation_shd_fx( *p_k_fx[k] = Madd_32_32( Madd_32_32( Mpy_32_32( p_Rmat_fx[add( idx, 1 )], re1 ), p_Rmat_fx[add( idx, 2 )], re2 ), p_Rmat_fx[idx], re3 ); move32(); - *p_k_fx[k] = L_shl( *p_k_fx[k], 2 ); // left shift is done to maintain constant Q factor for p_k_fx + *p_k_fx[k] = L_shl( *p_k_fx[k], Q1 ); // left shift is done to maintain constant Q factor for p_k_fx move32(); reference_power_fx[idx1] = Mpy_32_32( *p_k_fx[k], *p_k_fx[k] ); move32(); @@ -2365,7 +2350,7 @@ void protoSignalComputation_shd_fx( *p_k_fx[k] = Madd_32_32( Madd_32_32( Mpy_32_32( p_Rmat_fx[add( idx, 1 )], im1 ), p_Rmat_fx[add( idx, 2 )], im2 ), p_Rmat_fx[idx], im3 ); move32(); - *p_k_fx[k] = L_shl( *p_k_fx[k], 2 ); // left shift is done to maintain constant Q factor + *p_k_fx[k] = L_shl( *p_k_fx[k], Q1 ); // left shift is done to maintain constant Q factor move32(); reference_power_fx[idx1] = Mpy_32_32( *p_k_fx[k], *p_k_fx[k] ); move32(); @@ -5169,9 +5154,9 @@ void rotateAziEle_DirAC_fx( move32(); } - dv_r_0_fx = Madd_32_32( Madd_32_32( Mpy_32_32( p_Rmat_fx[0], dv_0_fx ), p_Rmat_fx[1], dv_1_fx ), p_Rmat_fx[2], dv_2_fx ); // Q29 - dv_r_1_fx = Madd_32_32( Madd_32_32( Mpy_32_32( p_Rmat_fx[3], dv_0_fx ), p_Rmat_fx[4], dv_1_fx ), p_Rmat_fx[5], dv_2_fx ); // Q29 - dv_r_2_fx = Madd_32_32( Madd_32_32( Mpy_32_32( p_Rmat_fx[6], dv_0_fx ), p_Rmat_fx[7], dv_1_fx ), p_Rmat_fx[8], dv_2_fx ); // Q29 + dv_r_0_fx = Madd_32_32( Madd_32_32( Mpy_32_32( L_shr(p_Rmat_fx[0], Q1), dv_0_fx ), L_shr(p_Rmat_fx[1], Q1), dv_1_fx ), L_shr(p_Rmat_fx[2], Q1), dv_2_fx ); // Q29 + dv_r_1_fx = Madd_32_32( Madd_32_32( Mpy_32_32( L_shr(p_Rmat_fx[3], Q1), dv_0_fx ), L_shr(p_Rmat_fx[4], Q1), dv_1_fx ), L_shr(p_Rmat_fx[5], Q1), dv_2_fx ); // Q29 + dv_r_2_fx = Madd_32_32( Madd_32_32( Mpy_32_32( L_shr(p_Rmat_fx[6], Q1), dv_0_fx ), L_shr(p_Rmat_fx[7], Q1), dv_1_fx ), L_shr(p_Rmat_fx[8], Q1), dv_2_fx ); // Q29 /*Conversion spherical to cartesian coordinates*/ temp = BASOP_util_atan2( dv_r_1_fx, dv_r_0_fx, 0 ); // Q13 diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf.c index f01ea233f..6a76c438d 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -201,8 +201,8 @@ void ivas_HRTF_CRend_binary_close( * * Allocate HRTF binary handle for FASTCONV renderer *-----------------------------------------------------------------------*/ - -ivas_error ivas_HRTF_fastconv_binary_open( +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_HRTF_fastconv_binary_open_fx( HRTFS_FASTCONV **hHrtfFastConv ) { *hHrtfFastConv = (HRTFS_FASTCONV *) malloc( sizeof( HRTFS_FASTCONV ) ); @@ -210,14 +210,22 @@ ivas_error ivas_HRTF_fastconv_binary_open( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FASTCONV HRTF tables!" ); } -#ifdef IVAS_FLOAT_FIXED ivas_init_binaural_hrtf_fx( *hHrtfFastConv ); + return IVAS_ERR_OK; +} #else +ivas_error ivas_HRTF_fastconv_binary_open( + HRTFS_FASTCONV **hHrtfFastConv ) +{ + *hHrtfFastConv = (HRTFS_FASTCONV *) malloc( sizeof( HRTFS_FASTCONV ) ); + if ( *hHrtfFastConv == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FASTCONV HRTF tables!" ); + } ivas_init_binaural_hrtf( *hHrtfFastConv ); -#endif return IVAS_ERR_OK; } - +#endif /*-----------------------------------------------------------------------* * ivas_HRTF_fastconv_binary_close() diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index c9a125cae..8e25239b7 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -1105,6 +1105,11 @@ ivas_error ivas_HRTF_fastconv_binary_open( ); #ifdef IVAS_FLOAT_FIXED + +ivas_error ivas_HRTF_fastconv_binary_open_fx( + HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ +); + void ivas_HRTF_fastconv_binary_close_fx( HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ ); diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index d5e8ee954..df75987f4 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -1950,7 +1950,7 @@ ivas_error ivas_combined_orientation_open( move16(); ( *hCombinedOrientationData )->interpolationCoefficient_fx = ONE_IN_Q30; move32(); - ( *hCombinedOrientationData )->interpolationIncrement_Fx = ONE_IN_Q30; + ( *hCombinedOrientationData )->interpolationIncrement_fx = ONE_IN_Q30; move32(); IF( EQ_16( num_subframes, 1 ) ) { @@ -2258,7 +2258,7 @@ ivas_error combine_external_and_head_orientations( hCombinedOrientationData->isInterpolationOngoing = FALSE; hCombinedOrientationData->interpolationCoefficient_fx = ONE_IN_Q30; move32(); - hCombinedOrientationData->interpolationIncrement_Fx = ONE_IN_Q30; + hCombinedOrientationData->interpolationIncrement_fx = ONE_IN_Q30; move32(); hCombinedOrientationData->Quaternions_ext_interpolation_start = identity; hCombinedOrientationData->Quaternions_ext_interpolation_target = identity; @@ -2326,7 +2326,7 @@ ivas_error combine_external_and_head_orientations( hCombinedOrientationData->Quaternions_ext_interpolation_target.q_fact = Q29; move16(); QuaternionSlerp_fx( hCombinedOrientationData->Quaternions_ext_interpolation_start, hCombinedOrientationData->Quaternions_ext_interpolation_target, hCombinedOrientationData->interpolationCoefficient_fx, &hCombinedOrientationData->Quaternions[i] ); - hCombinedOrientationData->interpolationCoefficient_fx = L_add( hCombinedOrientationData->interpolationIncrement_Fx, hCombinedOrientationData->interpolationCoefficient_fx ); + hCombinedOrientationData->interpolationCoefficient_fx = L_add( hCombinedOrientationData->interpolationIncrement_fx, hCombinedOrientationData->interpolationCoefficient_fx ); } ELSE { @@ -2334,7 +2334,7 @@ ivas_error combine_external_and_head_orientations( hCombinedOrientationData->isInterpolationOngoing = FALSE; hCombinedOrientationData->interpolationCoefficient_fx = ONE_IN_Q30; move32(); - hCombinedOrientationData->interpolationIncrement_Fx = ONE_IN_Q30; + hCombinedOrientationData->interpolationIncrement_fx = ONE_IN_Q30; move32(); external_target_interpolation( hExtOrientationData, hCombinedOrientationData, i ); Word16 l_shift = 0; @@ -2835,16 +2835,14 @@ static void external_target_interpolation( move16(); Word32 tmp; /* Calculate the interpolation increment and coefficient */ - // hCombinedOrientationData->interpolationIncrement_Fx = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, L_shl( L_deposit_l(hExtOrientationData->numFramesToTargetOrientation[i]), 2 ), &tmp_e ); // Multiplying with MAX_PARAM_SPATIAL_SUBFRAMES tmp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, L_shl( L_deposit_l( hExtOrientationData->numFramesToTargetOrientation[i] ), 2 ), &tmp_e ); - hCombinedOrientationData->interpolationIncrement_Fx = L_shl( tmp, sub( tmp_e, 31 ) ); // Q30 - hCombinedOrientationData->interpolationCoefficient_fx = hCombinedOrientationData->interpolationIncrement_Fx; + hCombinedOrientationData->interpolationIncrement_fx = L_shl( tmp, sub( tmp_e, 31 ) ); /* Q30 */ + hCombinedOrientationData->interpolationCoefficient_fx = hCombinedOrientationData->interpolationIncrement_fx; move32(); } /* Interpolate */ hCombinedOrientationData->isInterpolationOngoing = TRUE; - // hCombinedOrientationData->interpolationCoefficient_fx = float_to_fix( hCombinedOrientationData->interpolationCoefficient, Q30 ); hCombinedOrientationData->Quaternions_ext_interpolation_start.w_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_start.w_fx, hCombinedOrientationData->Quaternions_ext_interpolation_start.q_fact - Q29 ); hCombinedOrientationData->Quaternions_ext_interpolation_start.x_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_start.x_fx, hCombinedOrientationData->Quaternions_ext_interpolation_start.q_fact - Q29 ); hCombinedOrientationData->Quaternions_ext_interpolation_start.y_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_start.y_fx, hCombinedOrientationData->Quaternions_ext_interpolation_start.q_fact - Q29 ); @@ -2860,7 +2858,7 @@ static void external_target_interpolation( hCombinedOrientationData->Quaternions_ext_interpolation_target.q_fact = Q29; move16(); QuaternionSlerp_fx( hCombinedOrientationData->Quaternions_ext_interpolation_start, hCombinedOrientationData->Quaternions_ext_interpolation_target, hCombinedOrientationData->interpolationCoefficient_fx, &hCombinedOrientationData->Quaternions[i] ); - hCombinedOrientationData->interpolationCoefficient_fx = L_add_sat( hCombinedOrientationData->interpolationCoefficient_fx, hCombinedOrientationData->interpolationIncrement_Fx ); + hCombinedOrientationData->interpolationCoefficient_fx = L_add_sat( hCombinedOrientationData->interpolationCoefficient_fx, hCombinedOrientationData->interpolationIncrement_fx ); } ELSE { @@ -2868,7 +2866,7 @@ static void external_target_interpolation( hCombinedOrientationData->isInterpolationOngoing = FALSE; hCombinedOrientationData->interpolationCoefficient_fx = ONE_IN_Q30; move32(); - hCombinedOrientationData->interpolationIncrement_Fx = ONE_IN_Q30; + hCombinedOrientationData->interpolationIncrement_fx = ONE_IN_Q30; move32(); hCombinedOrientationData->Quaternions[i] = hExtOrientationData->Quaternions[i]; } diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index f699b4416..28893b458 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -638,13 +638,14 @@ typedef struct ivas_dirac_rend_data_structure /*Parameter estimation*/ int16_t index_buffer_intensity; +#ifndef IVAS_FLOAT_FIXED float *buffer_intensity_real[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF]; float *buffer_energy; -#ifdef IVAS_FLOAT_FIXED - Word32 *buffer_intensity_real_fx[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF]; - Word16 q_buffer_intensity_real[CLDFB_NO_CHANNELS_MAX]; - Word32 *buffer_energy_fx; - Word16 q_buffer_energy[CLDFB_NO_CHANNELS_MAX]; +#else + Word32 *buffer_intensity_real_fx[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF]; /* Q(q_buffer_intensity_real[]) */ + Word16 q_buffer_intensity_real[DIRAC_NO_COL_AVG_DIFF]; + Word32 *buffer_energy_fx; /* Q(q_buffer_energy[]) */ + Word16 q_buffer_energy[DIRAC_NO_COL_AVG_DIFF]; #endif #ifndef IVAS_FLOAT_FIXED @@ -653,10 +654,10 @@ typedef struct ivas_dirac_rend_data_structure float *hoa_encoder; const float *hoa_decoder; #else - Word16 *frequency_axis_fx; /* Q0 */ - Word16 *diffuse_response_function_fx; /* Q15 */ - Word32 *hoa_encoder_fx; /* Q29 */ - const Word32 *hoa_decoder; /* Q29 */ + Word16 *frequency_axis_fx; /* Q0 */ + Word16 *diffuse_response_function_fx; /* Q15 */ + Word32 *hoa_encoder_fx; /* Q29 */ + const Word32 *hoa_decoder; /* Q29 */ #endif /*Decoder parameters */ /*Prototypes*/ @@ -1169,27 +1170,36 @@ typedef struct ivas_external_orientation_struct typedef struct ivas_combined_orientation_struct { Word16 enableCombinedOrientation[MAX_PARAM_SPATIAL_SUBFRAMES]; +#ifndef IVAS_FLOAT_FIXED float interpolationCoefficient; float interpolationIncrement; +#else + Word32 lrSwitchInterpVal_fx; /* Q30 */ + Word32 interpolationCoefficient_fx; /* Q30 */ +#endif Word16 maximumFramesToTargetOrientation; UWord8 lrSwitchedNext; UWord8 lrSwitchedCurrent; +#ifndef IVAS_FLOAT_FIXED float lrSwitchInterpVal; +#else + Word32 interpolationIncrement_fx; /* Q30 */ +#endif bool isInterpolationOngoing; IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES]; IVAS_QUATERNION Quaternion_prev_extOrientation; IVAS_QUATERNION Quaternions_ext_interpolation_start; IVAS_QUATERNION Quaternions_ext_interpolation_target; - Word32 Rmat_fx[MAX_PARAM_SPATIAL_SUBFRAMES][3][3]; +#ifndef IVAS_FLOAT_FIXED float Rmat[MAX_PARAM_SPATIAL_SUBFRAMES][3][3]; float Rmat_prev[3][3]; - Word32 Rmat_prev_fx[3][3]; +#else + Word32 Rmat_fx[MAX_PARAM_SPATIAL_SUBFRAMES][3][3]; /* Q30 */ + Word32 Rmat_prev_fx[3][3]; /* Q30 */ +#endif float chEneIIR[2][MASA_FREQUENCY_BANDS]; /* independent of the format. MASA bands are suitable for the task and readily available in ROM. */ float procChEneIIR[2][MASA_FREQUENCY_BANDS]; #ifdef IVAS_FLOAT_FIXED - Word32 lrSwitchInterpVal_fx; - Word32 interpolationCoefficient_fx; - Word32 interpolationIncrement_Fx; Word32 chEneIIR_fx[2][MASA_FREQUENCY_BANDS]; /* independent of the format. MASA bands are suitable for the task and readily available in ROM. */ Word16 q_chEneIIR; Word32 procChEneIIR_fx[2][MASA_FREQUENCY_BANDS]; @@ -1660,10 +1670,10 @@ typedef struct typedef struct { +#ifndef IVAS_FLOAT_FIXED float val; -#ifdef IVAS_FLOAT_FIXED +#else Word32 val_fx; - Word16 val_q; #endif int16_t i; @@ -1856,14 +1866,16 @@ typedef struct typedef struct { float *InputFrame_p; /* Input frame pointer */ +#ifdef IVAS_FLOAT_FIXED + Word32 *InputFrame_p_fx; /* Input frame pointer */ /* Q(InputFrame_p_q) */ + Word16 InputFrame_p_q; +#endif TDREND_SRC_SPATIAL_t *SrcSpatial_p; TDREND_SRC_REND_t *SrcRend_p; int16_t itd; int16_t previtd; int16_t filterlength; #ifdef IVAS_FLOAT_FIXED - Word32 *InputFrame_p_fx; /* Input frame pointer */ - Word16 InputFrame_p_q; Word32 mem_itd_fx[ITD_MEM_LEN]; Word32 mem_hrf_left_fx[SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1]; Word32 mem_hrf_right_fx[SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1]; @@ -2083,7 +2095,9 @@ typedef struct ivas_hrtfs_fastconv_struct float ***leftBRIRImag; float ***rightBRIRReal; float ***rightBRIRImag; +#ifndef IVAS_FLOAT_FIXED float FASTCONV_BRIR_latency_s; +#endif #ifdef IVAS_FLOAT_FIXED Word32 ***leftHRIRReal_HOA2_fx; @@ -2096,7 +2110,9 @@ typedef struct ivas_hrtfs_fastconv_struct float ***leftHRIRImag_HOA2; float ***rightHRIRReal_HOA2; float ***rightHRIRImag_HOA2; +#ifndef IVAS_FLOAT_FIXED float FASTCONV_HOA2_latency_s; +#endif #ifdef IVAS_FLOAT_FIXED Word32 ***leftHRIRReal_FOA_fx; @@ -2109,16 +2125,19 @@ typedef struct ivas_hrtfs_fastconv_struct float ***leftHRIRImag_FOA; float ***rightHRIRReal_FOA; float ***rightHRIRImag_FOA; +#ifndef IVAS_FLOAT_FIXED float FASTCONV_FOA_latency_s; +#endif int16_t allocate_init_flag; /*Memory allocation flag 0: if the hrtf pointers are allocated at application level , 1: of allocated at ivas_binaural_hrtf_open() */ #ifdef IVAS_FLOAT_FIXED - Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; - Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; -#endif + Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ + Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ +#else float fastconvReverberationTimes[CLDFB_NO_CHANNELS_MAX]; float fastconvReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX]; +#endif } HRTFS_FASTCONV, *HRTFS_FASTCONV_HANDLE; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 09c3f0b80..5865e0184 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -13116,6 +13116,7 @@ void IVAS_REND_Close( return; } + #ifdef IVAS_FLOAT_FIXED static ivas_error ivas_masa_ext_rend_dirac_rend_init( input_masa *inputMasa ) @@ -13497,17 +13498,11 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( } -#if 1 /*TODO :To be removed later(after dependecy on buffer_energyis completely removed)*/ - hDirACRend->buffer_energy = NULL; -#endif hDirACRend->buffer_energy_fx = NULL; FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) { FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) { -#if 1 /*TODO :To be removed later(after dependecy on buffer_energyis completely removed)*/ - hDirACRend->buffer_intensity_real[i][j] = NULL; -#endif hDirACRend->buffer_intensity_real_fx[i][j] = NULL; } } @@ -13901,6 +13896,7 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( } #endif + #ifndef IVAS_FLOAT_FIXED static ivas_error ivas_masa_ext_rend_parambin_init( input_masa *inputMasa /* i/o: MASA external renderer structure */ diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 8575ffd29..777e21e1e 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1432,6 +1432,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( float f_tmp; float f_tmp_ntaps_sba[BINAURAL_NTAPS]; float f_tmp_ntaps_max[BINAURAL_NTAPS_MAX]; + float f_tmp_brir_reverb[CLDFB_NO_CHANNELS_MAX]; char *hrtf_data_rptr; ( *hHRTF )->allocate_init_flag = 0; ivas_allocate_binaural_hrtf_fx( *hHRTF, 0, input_cfg, rend_type, ( *hHRTF )->allocate_init_flag ); @@ -1733,13 +1734,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata( } hrtf_data_rptr += sizeof( uint16_t ); - memcpy( ( *hHRTF )->fastconvReverberationTimes, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); + memcpy( f_tmp_brir_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); - floatToFixed_arrL( ( *hHRTF )->fastconvReverberationTimes, ( *hHRTF )->fastconvReverberationTimes_fx, Q31, CLDFB_NO_CHANNELS_MAX ); + floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationTimes_fx, Q31, CLDFB_NO_CHANNELS_MAX ); - memcpy( ( *hHRTF )->fastconvReverberationEneCorrections, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); + memcpy( f_tmp_brir_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); - floatToFixed_arrL( ( *hHRTF )->fastconvReverberationEneCorrections, ( *hHRTF )->fastconvReverberationEneCorrections_fx, Q31, CLDFB_NO_CHANNELS_MAX ); + floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationEneCorrections_fx, Q31, CLDFB_NO_CHANNELS_MAX ); } return IVAS_ERR_OK; -- GitLab