From 5ff03c262f46e8d5a0cbc079cab949445ce1ba35 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 25 Apr 2024 10:09:16 +0530 Subject: [PATCH] Cleanup of unnecessary float buffers, float struct elements and dependencies. --- lib_com/float_to_fix_ops.c | 198 +- lib_com/igf_base.c | 6 +- lib_com/ivas_prot.h | 4 +- lib_com/prot_fx2.h | 2 +- lib_com/stat_com.h | 4 +- lib_dec/acelp_core_dec_ivas_fx.c | 4 +- lib_dec/core_dec_switch.c | 3 +- lib_dec/core_switching_dec_fx.c | 6 +- lib_dec/fd_cng_dec.c | 12 +- lib_dec/fd_cng_dec_fx.c | 2 +- lib_dec/hq_core_dec.c | 4 +- lib_dec/igf_dec.c | 29 +- lib_dec/igf_dec_fx.c | 16 +- lib_dec/ivas_core_dec.c | 298 +-- lib_dec/ivas_cpe_dec_fx.c | 19 +- lib_dec/ivas_jbm_dec.c | 2028 +++++++++++------- lib_dec/ivas_mct_dec.c | 6 +- lib_dec/ivas_mct_dec_mct_fx.c | 12 +- lib_dec/ivas_mdct_core_dec.c | 4 - lib_dec/ivas_sce_dec_fx.c | 5 +- lib_dec/ivas_stereo_cng_dec.c | 14 +- lib_dec/ivas_stereo_mdct_core_dec_fx.c | 1 + lib_dec/ivas_stereo_switching_dec.c | 2 +- lib_dec/ivas_tcx_core_dec.c | 11 +- lib_dec/stat_dec.h | 28 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 4 +- 26 files changed, 1665 insertions(+), 1057 deletions(-) diff --git a/lib_com/float_to_fix_ops.c b/lib_com/float_to_fix_ops.c index fbe22060b..4a1d8af75 100644 --- a/lib_com/float_to_fix_ops.c +++ b/lib_com/float_to_fix_ops.c @@ -263,16 +263,16 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( if ( reconf ) { - H_IGF_GRID hGrid; + //H_IGF_GRID hGrid; IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData; hPrivateData = &st->hIGFDec->igfData; - H_IGF_INFO hIGFInfo = &hPrivateData->igfInfo; + //H_IGF_INFO hIGFInfo = &hPrivateData->igfInfo; //ACELP_config *pConfigAcelp = &( st->acelp_cfg ); Word16 i = 0, Q_old_synth = 0, Q_syn = 0, Q_synth_history = 0, /*Q_fer_samples = 0,*/ - Q_cldfbAna_cldfb_state = 0, Q_cldfbBPF_cldfb_state = 0, Q_cldfbSyn_cldfb_state = 0, Q_cldfbSynHB_cldfb_state = 0, + Q_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; + //delay_comp = 0; Word16 Q_lsf_cng = Q_factor( 6400 ); Word16 Q_tcxltp_mem_in = 0, Q_tcxltp_mem_out = 0; @@ -281,24 +281,24 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( 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 ) ); + //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 ) { @@ -369,26 +369,26 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( } 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 ); + //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->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 ); @@ -484,16 +484,16 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( if ( reconf ) { - H_IGF_GRID hGrid; + //H_IGF_GRID hGrid; IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData; hPrivateData = &st->hIGFDec->igfData; - H_IGF_INFO hIGFInfo = &hPrivateData->igfInfo; + //H_IGF_INFO hIGFInfo = &hPrivateData->igfInfo; //ACELP_config *pConfigAcelp = &( st->acelp_cfg ); Word16 /*i = 0,*/ Q_old_synth = 0, Q_syn = 0, Q_synth_history = 0, Q_old_exc = 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_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; + //delay_comp = 0; Word16 Q_tcxltp_mem_in = 0, Q_tcxltp_mem_out = 0; TD_BWE_DEC_HANDLE hBWE_TD = st->hBWE_TD; @@ -501,24 +501,24 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( 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 ) ); + //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 ) @@ -591,26 +591,26 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( { Q_old_exc = st->Q_exc; 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 ); + //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->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 ) { @@ -703,10 +703,10 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( 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 ) ); - } + //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 ); @@ -781,7 +781,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( 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); + //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); @@ -793,7 +793,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( void fixed_to_float_stereo_tcx_core_dec( Decoder_State *st, - float *signal_out ) + Word16 *signal_out ) { TCX_DEC_HANDLE hTcxDec = st->hTcxDec; //Word16 q_Aq; @@ -815,17 +815,17 @@ void fixed_to_float_stereo_tcx_core_dec( 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 ); } - for ( int p = 0; p < st->L_frame; p++ ) - { - st->hTcxDec->old_excFB[p] = (float) ( st->hTcxDec->old_excFB_fx[p] ) / ( 1u << st->Q_exc ); - } + //for ( int p = 0; p < st->L_frame; p++ ) + //{ + // st->hTcxDec->old_excFB[p] = (float) ( st->hTcxDec->old_excFB_fx[p] ) / ( 1u << st->Q_exc ); + //} } - if ( st->lpcQuantization ) - { - st->safety_net = st->safety_net; - st->mid_lsf_int = st->mid_lsf_int; - } + //if ( st->lpcQuantization ) + //{ + // st->safety_net = st->safety_net; + // st->mid_lsf_int = st->mid_lsf_int; + //} hTcxDec->tcxltp_last_gain_unmodified_float = fixedToFloat( hTcxDec->tcxltp_last_gain_unmodified, Q15 ); @@ -852,9 +852,9 @@ void fixed_to_float_stereo_tcx_core_dec( { if ( ( ( st->m_frame_type == ACTIVE_FRAME ) && ( ( st->bfi == 0 && ( signal_out == NULL || - ( *signal_out( -FLT_MAX ) && - *( signal_out + st->hFdCngDec->hFdCngCom->frameSize - 1 ) < FLT_MAX && - *( signal_out + st->hFdCngDec->hFdCngCom->frameSize - 1 ) > ( -FLT_MAX ) ) ) && + ( *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 ) ) && @@ -904,7 +904,7 @@ void fixed_to_float_stereo_tcx_core_dec( } } - me2f_buf(st->hIGFDec->virtualSpec, st->hIGFDec->virtualSpec_e, st->hIGFDec->virtualSpecBuf, (N_MAX_TCX - IGF_START_MN)); + //me2f_buf(st->hIGFDec->virtualSpec, st->hIGFDec->virtualSpec_e, st->hIGFDec->virtualSpecBuf, (N_MAX_TCX - IGF_START_MN)); IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) ) { diff --git a/lib_com/igf_base.c b/lib_com/igf_base.c index e0eed1b7b..39ec2187c 100644 --- a/lib_com/igf_base.c +++ b/lib_com/igf_base.c @@ -508,9 +508,9 @@ static void IGF_gridSetUp_flt( } #ifdef IVAS_FLOAT_FIXED - hGrid->fFactor = float_to_fix16(hGrid->fFactor_flt, Q14); - hGrid->lFactor = float_to_fix16(hGrid->lFactor_flt, Q14); - hGrid->gFactor = float_to_fix16(hGrid->gFactor_flt, Q14); + //hGrid->fFactor = float_to_fix16(hGrid->fFactor_flt, Q14); + //hGrid->lFactor = float_to_fix16(hGrid->lFactor_flt, Q14); + //hGrid->gFactor = float_to_fix16(hGrid->gFactor_flt, Q14); #endif return; diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 5c2428173..26fdae54b 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -510,9 +510,9 @@ ivas_error ivas_core_dec( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ const int16_t n_channels, /* i : number of channels to be decoded */ - float *output[], /* o : output synthesis signal */ + Word32 *output_fx[], /* o : output synthesis signal */ float outputHB[][L_FRAME48k], /* o : output HB synthesis signal */ - float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers */ + Word32 DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers */ const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ ); diff --git a/lib_com/prot_fx2.h b/lib_com/prot_fx2.h index b7530b674..4d748545e 100644 --- a/lib_com/prot_fx2.h +++ b/lib_com/prot_fx2.h @@ -76,7 +76,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( void fixed_to_float_stereo_tcx_core_dec( Decoder_State *st, - float *signal_out + Word16 *signal_out ); // Float to Word32 Word32 float_to_fix( float number, Word32 Q ); diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index bc6b565f8..f9401cca2 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -418,8 +418,8 @@ typedef struct #endif Word32 fftBuffer[FFTLEN]; Word16 fftBuffer_exp; - Word16 *olapBufferAna; /* points to FD_CNG_DEC->olapBufferAna[320] in case of decoder */ - Word16 olapBufferAna_fx[FFTLEN]; /* points to FD_CNG_DEC->olapBufferAna[320] in case of decoder */ + Word16 *olapBufferAna; /* points to FD_CNG_DEC->olapBufferAna[FFTLEN] in case of decoder */ + Word16 olapBufferAna_fx[FFTLEN]; /* points to FD_CNG_DEC->olapBufferAna[FFTLEN] in case of decoder */ Word16 olapBufferSynth[FFTLEN]; Word16 *olapBufferSynth2; /* points to FD_CNG_DEC->olapBufferSynth2[FFTLEN] in case of decoder */ const PWord16 * olapWinAna; diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index f59965da9..d8c97fabf 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -2639,7 +2639,7 @@ void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HANDLE hSte floatToFixed_arr(st->hFdCngDec->hFdCngCom->exc_cng_flt, st->hFdCngDec->hFdCngCom->exc_cng, st->Q_exc_cng, L_FRAME16k); floatToFixed_arr(st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->fftlenShift, FFTLEN); - st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = float_to_fix16(st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt, Q15); + //st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = float_to_fix16(st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt, Q15); floatToFixed_arrL( st->hFdCngDec->bandNoiseShape_float, st->hFdCngDec->bandNoiseShape, Q31 - st->hFdCngDec->bandNoiseShape_exp, FFTLEN2); /*CNA: ApplyFdCng*/ if ((st->hFdCngDec != NULL || st->idchan == 1) && st->element_mode != IVAS_CPE_MDCT) @@ -2702,7 +2702,7 @@ void acelp_decoder_state_fix2float(Decoder_State *st, STEREO_CNG_DEC_HANDLE hSte fixedToFloat_arr( st->hFdCngDec->hFdCngCom->A_cng, st->hFdCngDec->hFdCngCom->A_cng_flt, Q12, M + 1 ); fixedToFloat_arr(st->hFdCngDec->hFdCngCom->exc_cng, st->hFdCngDec->hFdCngCom->exc_cng_flt, st->Q_exc_cng, L_FRAME16k); fixedToFloat_arr(st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, st->hFdCngDec->hFdCngCom->fftlenShift, FFTLEN); - st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt = fixedToFloat(st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, Q15); + //st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt = fixedToFloat(st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, Q15); fixedToFloat_arrL(st->hFdCngDec->bandNoiseShape, st->hFdCngDec->bandNoiseShape_float, Q31 - st->hFdCngDec->bandNoiseShape_exp, FFTLEN2); //fixedToFloat_arrL(st->hFdCngDec->partNoiseShape, st->hFdCngDec->partNoiseShape_float, Q31 - st->hFdCngDec->partNoiseShape_exp, NPART); /*CNA: ApplyFdCng*/ diff --git a/lib_dec/core_dec_switch.c b/lib_dec/core_dec_switch.c index dc331314c..5f6f16c35 100644 --- a/lib_dec/core_dec_switch.c +++ b/lib_dec/core_dec_switch.c @@ -64,7 +64,7 @@ void open_decoder_LPD_ivas_fx( Word16* Q_old_outLB, Word16* Q_old_Aq_12_8); #endif // IVAS_FLOAT_FIXED - +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) void mode_switch_decoder_LPD_flt( Decoder_State *st, /* i/o: decoder state structure */ const int16_t bwidth, /* i : audio bandwidth */ @@ -261,3 +261,4 @@ void mode_switch_decoder_LPD_flt( return; } +#endif diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 8f3b24184..3bfc1a4f0 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1706,7 +1706,7 @@ ivas_error core_switching_post_dec_ivas_fx( test(); IF( ( ( NE_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_core_brate, FRAME_NO_DATA ) ) || ( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) && NE_16( st_fx->element_mode, IVAS_CPE_TD ) ) || EQ_16( nchan_out, 1 ) ) && !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( st_fx->idchan, 1 ) && ( EQ_16( nchan_out, 1 ) || EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) ) { - Scale_sig32( output_fx, L_FRAME48k, 10 - 4 ); + Scale_sig32( output_fx, L_FRAME48k, Q10 - Q4 ); core_switch_lb_upsamp_fx( st_fx, output_fx ); } @@ -1758,7 +1758,7 @@ ivas_error core_switching_post_dec_ivas_fx( FOR( i = 0; i < delta; i++ ) { st_fx->cldfbAna->cldfb_state_fx[offset - delta + i] = - Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], 10 - 4 ), alpha ); + Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q4 ), alpha ); IF( alpha < sub( 32767, tmp ) ) { alpha = add( alpha, tmp ); @@ -1803,7 +1803,7 @@ ivas_error core_switching_post_dec_ivas_fx( FOR( i = 0; i < delta; i++ ) { st_fx->cldfbAna->cldfb_state_fx[offset - delta + i] = - Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], 10 - 4 ), alpha ); + Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q4 ), alpha ); IF( alpha < sub( 32767, tmp ) ) { alpha = add( alpha, tmp ); diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 4e9610987..d0fc708eb 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -181,8 +181,11 @@ void initFdCngDec_flt( hFdCngDec->first_cna_noise_update_cnt = 0; hFdCngDec->cna_nbands = CNA_INIT_NBANDS; mvs2s( cna_init_bands, hFdCngDec->cna_band_limits, CNA_INIT_NBANDS + 1 ); - hFdCngDec->cna_act_fact = 1.0f; + + hFdCngDec->cna_act_fact_fx = MAX_WORD16; + hFdCngDec->cna_rescale_fact_fx = 0; #if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) + hFdCngDec->cna_act_fact = 1.0f; hFdCngDec->cna_rescale_fact = 0.0f; #endif hFdCngDec->cna_seed = 5687; @@ -2196,7 +2199,7 @@ void generate_masking_noise_update_seed_flt( return; } - +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) /*------------------------------------------------------------------- * generate_masking_noise_mdct_flt() * @@ -2284,7 +2287,7 @@ void generate_masking_noise_mdct_flt( return; } - +#endif /*------------------------------------------------------------------- * generate_stereo_masking_noise() * @@ -3092,6 +3095,7 @@ void generate_masking_noise_lb_dirac_fx( return; } #endif +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) /*------------------------------------------------------------------- * generate_masking_noise_hf_cldfb() * @@ -3191,7 +3195,7 @@ void generate_masking_noise_dirac( return; } - +#endif #ifdef IVAS_FLOAT_FIXED void generate_masking_noise_dirac_fx( HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 77e872866..5743b96d9 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -77,7 +77,7 @@ void ivas_initFdCngDec_fx( hFdCngDec = st->hFdCngDec; ivas_initFdCngCom_fx( hFdCngDec->hFdCngCom, scale ); - set16_fx( hFdCngDec->olapBufferAna, 0, 320 ); + set16_fx( hFdCngDec->olapBufferAna, 0, FFTLEN); hFdCngDec->hFdCngCom->olapBufferAna = hFdCngDec->olapBufferAna; move16(); set16_fx( hFdCngDec->olapBufferSynth2, 0, FFTLEN ); diff --git a/lib_dec/hq_core_dec.c b/lib_dec/hq_core_dec.c index bbb7d8174..6e85b92aa 100644 --- a/lib_dec/hq_core_dec.c +++ b/lib_dec/hq_core_dec.c @@ -670,8 +670,10 @@ void HQ_core_dec_init_flt( set_f( hHQ_core->prev_noise_level, 0.0f, 2 ); #endif hHQ_core->prev_R = 0; +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) set_f( hHQ_core->prev_coeff_out, 0, L_HQ_WB_BWE ); - set_s( hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); +#endif + set_s( hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); /* HQ GENERIC */ hHQ_core->hq_generic_seed = RANDOM_INITSEED; diff --git a/lib_dec/igf_dec.c b/lib_dec/igf_dec.c index 8a9032b80..390d99e15 100644 --- a/lib_dec/igf_dec.c +++ b/lib_dec/igf_dec.c @@ -303,7 +303,7 @@ static void IGF_setLinesToZero_flt( return; } - +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) /*-------------------------------------------------------------------* * IGF_prep_flt() * @@ -945,7 +945,7 @@ static void IGF_getWhiteSpectralData_flt( return; } - +#endif /*-------------------------------------------------------------------* * IGF_RefineGrid_flt() @@ -1355,7 +1355,7 @@ void IGFDecApplyStereo_flt( return; } #endif - +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) /*-------------------------------------------------------------------* * IGFDecSetMode_flt() * @@ -1421,7 +1421,7 @@ void IGFDecSetMode_flt( return; } - +#endif /*-------------------------------------------------------------------* * IGFDecUpdateInfo_flt() @@ -1440,12 +1440,12 @@ void IGFDecUpdateInfo_flt( hIGFDec->flag_sparse = &hIGFDec->flag_sparseBuf[0]; hIGFDec->infoTCXNoise = &hIGFDec->infoTCXNoiseBuf[0]; +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) hIGFDec->virtualSpec_float = &hIGFDec->virtualSpecBuf[0]; -#ifdef IVAS_FLOAT_FIXED - hIGFDec->virtualSpec_fx = &hIGFDec->virtualSpec[0]; -#endif hIGFDec->igfData.pSpecFlat_float = &hIGFDec->igfData.pSpecFlatBuf[0]; +#endif #ifdef IVAS_FLOAT_FIXED + hIGFDec->virtualSpec_fx = &hIGFDec->virtualSpec[0]; hIGFDec->igfData.pSpecFlat = &hIGFDec->igfData.pSpecFlatBuf_fx[0]; #endif hIGFDec->igfData.igfInfo.nfSeed = &hIGFDec->igfData.igfInfo.nfSeedBuf[0]; @@ -1494,7 +1494,7 @@ void IGFDecReplicateTCX10State_flt( } #endif - +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) /*-------------------------------------------------------------------* * IGFDecCopyLPCFlatSpectrum_flt() * @@ -1524,7 +1524,7 @@ void IGFDecCopyLPCFlatSpectrum_flt( return; } - +#endif /*-------------------------------------------------------------------* * IGFDecStoreTCX10SubFrameData_flt() @@ -1583,11 +1583,13 @@ void IGFDecRestoreTCX10SubFrameData_flt( hIGFDec->flatteningTrigger = hPrivateData->igf_flatteningTrigger_subframe[subFrameIdx]; hIGFDec->flag_sparse = &hIGFDec->flag_sparseBuf[subFrameIdx * ( N_MAX_TCX - IGF_START_MN ) / 2]; hIGFDec->infoTCXNoise = &hIGFDec->infoTCXNoiseBuf[subFrameIdx * ( IGF_START_MX ) / 2]; +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) hIGFDec->virtualSpec_float = &hIGFDec->virtualSpecBuf[subFrameIdx * ( N_MAX_TCX - IGF_START_MN ) / 2]; + hIGFDec->igfData.pSpecFlat_float = &hIGFDec->igfData.pSpecFlatBuf[subFrameIdx * IGF_START_MX / 2]; +#endif #ifdef IVAS_FLOAT_FIXED hIGFDec->virtualSpec_fx = &hIGFDec->virtualSpec[subFrameIdx * ( N_MAX_TCX - IGF_START_MN ) / 2]; #endif - hIGFDec->igfData.pSpecFlat_float = &hIGFDec->igfData.pSpecFlatBuf[subFrameIdx * IGF_START_MX / 2]; #ifdef IVAS_FLOAT_FIXED hIGFDec->igfData.pSpecFlat = &hIGFDec->igfData.pSpecFlatBuf_fx[subFrameIdx * IGF_START_MX / 2]; #endif @@ -1607,15 +1609,20 @@ void init_igf_dec_flt( ) { set_c( (int8_t *) ( hIGFDec->infoTCXNoiseBuf ), 0, IGF_START_MX ); +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) set_f( hIGFDec->igfData.pSpecFlatBuf, 0, IGF_START_MX ); +#endif hIGFDec->igfData.igfInfo.nfSeedBuf[0] = 9733; hIGFDec->igfData.igfInfo.nfSeedBuf[1] = 9733; hIGFDec->igfData.igfInfo.nfSeed = &hIGFDec->igfData.igfInfo.nfSeedBuf[0]; +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) hIGFDec->igfData.pSpecFlat_float = &hIGFDec->igfData.pSpecFlatBuf[0]; +#endif hIGFDec->flag_sparse = &hIGFDec->flag_sparseBuf[0]; hIGFDec->infoTCXNoise = &hIGFDec->infoTCXNoiseBuf[0]; +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) hIGFDec->virtualSpec_float = &hIGFDec->virtualSpecBuf[0]; - +#endif return; } diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index bfbda82c7..9a3aaa8e1 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -4050,8 +4050,10 @@ void IGFDecUpdateInfo_ivas_fx( hIGFDec->igfData.pSpecFlat = &hIGFDec->igfData.pSpecFlatBuf_fx[0]; /* TODO: remove float init */ +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) hIGFDec->virtualSpec_float = &hIGFDec->virtualSpecBuf[0]; hIGFDec->igfData.pSpecFlat_float = &hIGFDec->igfData.pSpecFlatBuf[0]; +#endif hIGFDec->igfData.igfInfo.nfSeed = &hIGFDec->igfData.igfInfo.nfSeedBuf[0]; @@ -4089,7 +4091,7 @@ void IGFDecReplicateTCX10State_fx( /* TODO: remove float dependency */ //mvr2r( &hIGFDec->virtualSpecBuf[( N_MAX_TCX - IGF_START_MN ) / 2], &hIGFDec->virtualSpecBuf[0], ( N_MAX_TCX - IGF_START_MN ) / 2 ); - mvr2r( &hIGFDec->igfData.pSpecFlatBuf[IGF_START_MX / 2], &hIGFDec->igfData.pSpecFlatBuf[0], IGF_START_MX / 2 ); + //mvr2r( &hIGFDec->igfData.pSpecFlatBuf[IGF_START_MX / 2], &hIGFDec->igfData.pSpecFlatBuf[0], IGF_START_MX / 2 ); Copy32( &hIGFDec->virtualSpec[( N_MAX_TCX - IGF_START_MN ) / 2], &hIGFDec->virtualSpec[0], ( N_MAX_TCX - IGF_START_MN ) / 2 ); Copy32( &hIGFDec->igfData.pSpecFlatBuf_fx[IGF_START_MX / 2], &hIGFDec->igfData.pSpecFlatBuf_fx[0], IGF_START_MX / 2 ); @@ -4152,11 +4154,11 @@ void IGFDecCopyLPCFlatSpectrum_fx( Copy32( pSpectrumFlat, hPrivateData->pSpecFlat, hGrid->startLine ); - /* TODO: remove float dependency */ - for ( i = hGrid->minSrcSubband - IGF_MID_WHITENING_LEVEL2; i < hGrid->startLine; i++ ) - { - hPrivateData->pSpecFlat_float[i] = me2f( hPrivateData->pSpecFlat[i], hPrivateData->pSpecFlat_exp ); - } + ///* TODO: remove float dependency */ + //for ( i = hGrid->minSrcSubband - IGF_MID_WHITENING_LEVEL2; i < hGrid->startLine; i++ ) + //{ + // hPrivateData->pSpecFlat_float[i] = me2f( hPrivateData->pSpecFlat[i], hPrivateData->pSpecFlat_exp ); + //} } } @@ -4236,8 +4238,10 @@ void IGFDecRestoreTCX10SubFrameData_fx( hIGFDec->igfData.pSpecFlat = &hIGFDec->igfData.pSpecFlatBuf_fx[subFrameIdx * IGF_START_MX / 2]; /* TODO: remove float init */ +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) hIGFDec->virtualSpec_float = &hIGFDec->virtualSpecBuf[subFrameIdx * ( N_MAX_TCX - IGF_START_MN ) / 2]; hIGFDec->igfData.pSpecFlat_float = &hIGFDec->igfData.pSpecFlatBuf[subFrameIdx * IGF_START_MX / 2]; +#endif hIGFDec->igfData.igfInfo.nfSeed = &hIGFDec->igfData.igfInfo.nfSeedBuf[subFrameIdx]; diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index f3d44cf00..525b529c4 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -89,15 +89,15 @@ static Word16 norm_arr_s(float *arr, int size) *-------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED ivas_error ivas_core_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - SCE_DEC_HANDLE hSCE, /* i/o: SCE decoder structure */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ - const int16_t n_channels, /* i : number of channels to be decoded */ - float *output[], /* o : output synthesis signal */ - float hb_synth[][L_FRAME48k], /* o : output HB synthesis signal */ - float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + SCE_DEC_HANDLE hSCE, /* i/o: SCE decoder structure */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ + const int16_t n_channels, /* i : number of channels to be decoded */ + Word32 *output_32_fx[], /* o : output synthesis signal */ + float hb_synth[][L_FRAME48k], /* o : output HB synthesis signal */ + Word32 DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers */ + const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ ) { int16_t i, n, output_frame; @@ -107,6 +107,9 @@ ivas_error ivas_core_dec( int16_t sharpFlag[CPE_CHANNELS]; float synth[CPE_CHANNELS][L_FRAME48k]; float tmp_buffer[L_FRAME48k]; + //float output[CPE_CHANNELS][L_FRAME48k]; + //fixedToFloat_arrL(output_32_fx[0],output[0],Q11,L_FRAME48k); + //if(n_channels > 1)fixedToFloat_arrL(output_32_fx[1],output[1],Q11,L_FRAME48k); #ifdef IVAS_FLOAT_FIXED //Word32 synth_fx[CPE_CHANNELS][L_FRAME48k]; set_zero( tmp_buffer, L_FRAME48k ); @@ -159,15 +162,21 @@ ivas_error ivas_core_dec( ivas_error error; Word32 L_tmp; Word16 Q_synth; + //Word32 *output_32p_fx[CPE_CHANNELS]; + Word16 output_16_fx[CPE_CHANNELS][L_FRAME48k]; + //Word32 output_32_fx[CPE_CHANNELS][L_FRAME48k]; + //output_32p_fx[0] = output_32_fx[0]; + //output_32p_fx[1] = output_32_fx[1]; FOR( i = 0; i < CPE_CHANNELS; i++ ) { set16_fx( pitch_buf_fx[i], 0, NB_SUBFR16k ); + set16_fx( output_16_fx[i], 0, L_FRAME48k ); } #ifdef IVAS_FLOAT_FIXED Word16 hb_synth_fx[6][L_FRAME48k]; /*not sure about number of channels so kept it as 6 will change it later*/ - Word16 output_16fx[CPE_CHANNELS][L_FRAME48k]; + //Word16 output_16fx[CPE_CHANNELS][L_FRAME48k]; Word16 synth_16fx[CPE_CHANNELS][L_FRAME48k]; Word32 pitch_buf_32fx[CPE_CHANNELS][NB_SUBFR16k]; Word16 tdm_lsfQ_PCh_fx[M], tdm_lspQ_PCh_fx[M]; @@ -498,7 +507,7 @@ ivas_error ivas_core_dec( #if 1 /*Float to fix conversions*/ Word16 Q_hb_prev_synth_buffer, - Q_FBTCXdelayBuf = 15, /*Q_prev_synth_buffer, */Q_syn_Overl = 15, Q_fer_samples = 15, Q_old_syn_Overl = 15, /*Q_olapBufferAna = 15,*/ Q_olapBufferSynth = 15, + /*Q_FBTCXdelayBuf = 15,*/ /*Q_prev_synth_buffer, */Q_syn_Overl = 15, Q_fer_samples = 15, Q_old_syn_Overl = 15, /*Q_olapBufferAna = 15,*/ Q_olapBufferSynth = 15, Q_olapBufferSynth2 = 15, Q_old_synthFB = 15; /*Initializing with max values to avoid warnings*/ Q_hb_prev_synth_buffer = Q_factor_arr( st->hb_prev_synth_buffer, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); @@ -520,7 +529,7 @@ ivas_error ivas_core_dec( Q_syn_Overl = s_min( Q_fer_samples, Q_syn_Overl ) - 1; IF( st->hHQ_core ) { - floatToFixed_arr32( st->hHQ_core->prev_coeff_out, st->hHQ_core->prev_coeff_out_fx, Q12, L_HQ_WB_BWE ); /*Q-12*/ + } IF( st->hTcxDec ) { @@ -584,7 +593,7 @@ ivas_error ivas_core_dec( fixedToFloat_arrL( st->cldfbBPF->cldfb_state_fx, st->cldfbBPF->cldfb_state, Q11, st->cldfbBPF->cldfb_state_length ); IF( st->hHQ_core ) { - fixedToFloat_arrL( st->hHQ_core->prev_coeff_out_fx, st->hHQ_core->prev_coeff_out, Q12, L_HQ_WB_BWE ); + } IF( st->hFdCngDec ) { @@ -607,10 +616,8 @@ ivas_error ivas_core_dec( IF ( st->core == ACELP_CORE ) { /* ACELP core decoder */ - - Word16 output_fx[L_FRAME48k], synth_fxl[L_FRAME48k], old_syn_12k8_16k_fx_16[L_FRAME16k]; - - set_s(output_fx, 0, L_FRAME48k); + Word16 /*output_fx[L_FRAME48k],*/ synth_fxl[L_FRAME48k], old_syn_12k8_16k_fx_16[L_FRAME16k]; + set_s(output_16_fx[n], 0, L_FRAME48k); Word16 save_hb_synth_fx_arr[L_FRAME48k], *save_hb_synth_fx; if (save_hb_synth) { save_hb_synth_fx = save_hb_synth_fx_arr; @@ -625,15 +632,16 @@ ivas_error ivas_core_dec( //if (hStereoTD) { // floatToFixed_arr(hStereoTD->tdm_Pri_pitch_buf, hStereoTD->tdm_Pri_pitch_buf_fx, Q6, NB_SUBFR); //} - - IF ( ( error = acelp_core_dec_ivas_fx( st, output_fx, synth_fxl, save_hb_synth_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16, sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lspQ_PCh_fx, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hCPE == NULL ? NULL : hCPE->hStereoCng, read_sid_info ) ) != IVAS_ERR_OK ) + IF ( ( error = acelp_core_dec_ivas_fx( st, output_16_fx[n], synth_fxl, save_hb_synth_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16, sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lspQ_PCh_fx, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hCPE == NULL ? NULL : hCPE->hStereoCng, read_sid_info ) ) != IVAS_ERR_OK ) { return error; } /* fix2float, to be removed */ + 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, hCPE == NULL ? NULL : hCPE->hStereoCng); - fixedToFloat_arr(output_fx, output[n], st->Q_syn2, L_FRAME48k); + //fixedToFloat_arr(output_16_fx[n], output[n], 0, L_FRAME48k); fixedToFloat_arr(synth_fxl, synth[n], 0, L_FRAME48k); if (save_hb_synth) { fixedToFloat_arr(save_hb_synth_fx, save_hb_synth, 0, L_FRAME48k); @@ -656,23 +664,24 @@ ivas_error ivas_core_dec( Scale_sig(st->hPFstat->mem_stp, L_SUBFR, -Qsyn_temp); Scale_sig(st->hPFstat->mem_pf_in, L_SUBFR, -Qsyn_temp); - stereo_tcx_core_dec_fx( st, frameMode[n], output_16fx[n], synth_16fx[n], pitch_buf_32fx[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hCPE == NULL ? NULL : hCPE->hStereoCng, nchan_out, st_ivas == NULL ? 0 : st_ivas->ivas_format ); + stereo_tcx_core_dec_fx( st, frameMode[n], output_16_fx[n], synth_16fx[n], pitch_buf_32fx[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hCPE == NULL ? NULL : hCPE->hStereoCng, nchan_out, st_ivas == NULL ? 0 : st_ivas->ivas_format ); - fixedToFloat_arr( output_16fx[n], output[n], 0, st->L_frame ); + //fixedToFloat_arr( output_16_fx[n], output[n], 0, st->L_frame ); + Copy_Scale_sig_16_32(output_16_fx[n],output_32_fx[n],L_FRAME48k,Q11); fixedToFloat_arr( synth_16fx[n], synth[n], 0, st->hTcxDec->L_frameTCX ); //fixedToFloat_arrL( pitch_buf_32fx[n], pitch_buf[n], Q6, NB_SUBFR16k ); Copy_Scale_sig_32_16(pitch_buf_32fx[n], pitch_buf_fx[n],NB_SUBFR16k,0); 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[n] ); + fixed_to_float_stereo_tcx_core_dec( st, output_16_fx[n] ); } if ( st->core == HQ_CORE ) { /* HQ core decoder */ Word16 synth_fxl[L_FRAME48k]; - Word16 output_fx[L_FRAME48k]; + //Word16 output_fx[L_FRAME48k]; Q_synth = 0; Word16 Q_output = 0; HQ_DEC_HANDLE hHQ_core; @@ -684,30 +693,26 @@ ivas_error ivas_core_dec( st->hHQ_core->Q_old_wtda_LB = -1; floatToFixed_arr( synth[n], synth_fxl, st->Q_syn, L_FRAME48k ); - floatToFixed_arr( output[n], output_fx, st->Q_syn, L_FRAME48k ); + //floatToFixed_arr( output[n], output_16_fx[n], st->Q_syn, L_FRAME48k ); #ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED floatToFixed_arr( hHQ_core->old_out, hHQ_core->old_out_fx, hHQ_core->Q_old_wtda, L_FRAME48k ); floatToFixed_arr( hHQ_core->old_outLB, hHQ_core->old_out_LB_fx, hHQ_core->Q_old_wtda_LB, L_FRAME32k ); floatToFixed_arr( st->hTcxDec->old_syn_Overl_float, st->hTcxDec->old_syn_Overl, -1, L_FRAME32k / 2 ); - floatToFixed_arrL( hHQ_core->prev_coeff_out, hHQ_core->prev_coeff_out_fx, Q12, L_HQ_WB_BWE ); floatToFixed_arr( st->hTcxDec->prev_good_synth - tmp_size, st->hTcxDec->prev_good_synth_fx - tmp_size, 0, 2 * output_frame + tmp_size ); #endif - ivas_hq_core_dec_fx( st, synth_fxl, &Q_synth, output_frame, NORMAL_HQ_CORE, core_switching_flag[n], output_fx, &Q_output ); + ivas_hq_core_dec_fx( st, synth_fxl, &Q_synth, output_frame, NORMAL_HQ_CORE, core_switching_flag[n], output_16_fx[n], &Q_output ); + Copy_Scale_sig_16_32(output_16_fx[n], output_32_fx[n], L_FRAME48k, Q11 - Q_output); + Scale_sig(output_16_fx[n], L_FRAME48k, -Q_output); fixedToFloat_arr( synth_fxl, synth[n], Q_synth, L_FRAME48k ); - fixedToFloat_arr( output_fx, output[n], Q_output, L_FRAME48k ); + //fixedToFloat_arr( output_16_fx[n], output[n], 0, L_FRAME48k ); #ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED fixedToFloat_arr( hHQ_core->old_out_fx, hHQ_core->old_out, hHQ_core->Q_old_wtda, L_FRAME48k ); fixedToFloat_arr( hHQ_core->old_out_LB_fx, hHQ_core->old_outLB, hHQ_core->Q_old_wtda_LB, L_FRAME32k ); fixedToFloat_arr( st->hTcxDec->old_syn_Overl, st->hTcxDec->old_syn_Overl_float, -1, L_FRAME32k / 2 ); - fixedToFloat_arrL( hHQ_core->prev_coeff_out_fx, hHQ_core->prev_coeff_out, Q12, L_HQ_WB_BWE ); - FOR( i = 0; i < 3; ++i ) - { - hHQ_core->prev_coeff_out[i] = hHQ_core->old_is_transient[i]; - } fixedToFloat_arr( st->hTcxDec->prev_good_synth_fx - tmp_size, st->hTcxDec->prev_good_synth - tmp_size, 0, 2 * output_frame + tmp_size ); #endif @@ -760,7 +765,7 @@ ivas_error ivas_core_dec( #ifdef IVAS_FLOAT_FIXED #if 1 Word16 e_sig = 17; - Word32 *output_fx[CPE_CHANNELS]; + //Word32 *output_fx[CPE_CHANNELS]; Word16 synth_fx_16[CPE_CHANNELS][L_FRAME48k]; Word16 ch; sts = hCPE->hCoreCoder; @@ -770,7 +775,7 @@ ivas_error ivas_core_dec( will_estimate_noise_on_channel[1] = sts[1]->core == TCX_20_CORE && !sts[1]->VAD; FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { - output_fx[ch] = malloc( sizeof( Word32 ) * L_FRAME48k ); + //output_fx[ch] = malloc( sizeof( Word32 ) * L_FRAME48k ); // synth_fx[ch] = malloc(sizeof(Word16) * L_FRAME48k); stereo_tcx_dec_mode_switch_reconf_To_fixed( sts[ch], 1, hCPE->last_element_mode ); @@ -802,10 +807,10 @@ ivas_error ivas_core_dec( IF( st->hTcxDec ) st->hTcxDec->tcxltp_last_gain_unmodified = (Word16) floatToFixed( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 ); - if ( !sts[0]->bfi && ( will_estimate_noise_on_channel[0] || will_estimate_noise_on_channel[1] ) ) - { - sts[ch]->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx = floatToFixed( sts[ch]->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt, 31 ); - } + //if ( !sts[0]->bfi && ( will_estimate_noise_on_channel[0] || will_estimate_noise_on_channel[1] ) ) + //{ + // sts[ch]->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx = floatToFixed( sts[ch]->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt, 31 ); + //} IF( will_estimate_noise_on_channel[0] || will_estimate_noise_on_channel[1] || sts[ch]->bfi ) { for ( int p = 0; p < s_min( sts[ch]->hFdCngDec->hFdCngCom->fftlen, 640 ); p++ ) @@ -824,7 +829,7 @@ ivas_error ivas_core_dec( { st->hFdCngDec->hFdCngCom->cngNoiseLevel[ind] = (Word32) ( st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[ind] * ( 1LL << ( 31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) ) ); } - st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = float_to_fix16( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt, 15 ); + //st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = float_to_fix16( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt, 15 ); } } @@ -844,8 +849,8 @@ ivas_error ivas_core_dec( IF( st->hTcxDec ) floatToFixed_arr( st->hTcxDec->old_syn_Overl_float, st->hTcxDec->old_syn_Overl, -1 - st->Q_syn, L_FRAME32k / 2 ); - IF( st->hTcxDec ) - floatToFixed_arr( st->hTcxDec->old_excFB, st->hTcxDec->old_excFB_fx, st->Q_exc, s_min( 960, st->L_frame ) ); + //IF( st->hTcxDec ) + //floatToFixed_arr( st->hTcxDec->old_excFB, st->hTcxDec->old_excFB_fx, st->Q_exc, s_min( 960, st->L_frame ) ); if ( !st->tcxonly ) { @@ -902,7 +907,7 @@ ivas_error ivas_core_dec( floatToFixed_arr( sts[1]->hTonalMDCTConc->lastBlockData.spectralData_float, sts[1]->hTonalMDCTConc->lastBlockData.spectralData, ( 15 - sts[1]->hTonalMDCTConc->lastBlockData.spectralData_exp ), L_FRAME_MAX ); } #endif - stereo_mdct_core_dec_fx( st_ivas, hCPE, output_fx, synth_fx_16 ); + stereo_mdct_core_dec_fx( st_ivas, hCPE, output_32_fx, synth_fx_16 ); #if 1 // Fix to float conversion IF( sts[0]->bfi && ( hCPE->hStereoMdct->mdct_stereo_mode[0] > SMDCT_DUAL_MONO || hCPE->hStereoMdct->mdct_stereo_mode[1] > SMDCT_DUAL_MONO ) ) { @@ -918,7 +923,7 @@ ivas_error ivas_core_dec( FOR( ch = 0; ch < 2; ch++ ) { stereo_tcx_dec_mode_switch_reconf_To_fixed( sts[ch], 0, hCPE->last_element_mode ); - me2f_buf( sts[ch]->hIGFDec->virtualSpec, sts[ch]->hIGFDec->virtualSpec_e, sts[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); + //me2f_buf( sts[ch]->hIGFDec->virtualSpec, sts[ch]->hIGFDec->virtualSpec_e, sts[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); st = hCPE->hCoreCoder[ch]; fixedToFloat_arr( st->hTcxDec->syn_OverlFB, st->hTcxDec->syn_OverlFB_float, st->Q_syn, L_FRAME_MAX / 2 ); fixedToFloat_arr( st->hTcxDec->syn_Overl, st->hTcxDec->syn_Overl_float, st->Q_syn, L_FRAME32k / 2 ); @@ -951,10 +956,10 @@ ivas_error ivas_core_dec( } } - if ( !sts[0]->bfi && ( will_estimate_noise_on_channel[0] || will_estimate_noise_on_channel[1] ) ) - { - sts[ch]->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt = fixedToFloat( sts[ch]->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx, 31 ); - } + //if ( !sts[0]->bfi && ( will_estimate_noise_on_channel[0] || will_estimate_noise_on_channel[1] ) ) + //{ + // sts[ch]->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt = fixedToFloat( sts[ch]->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx, 31 ); + //} IF( will_estimate_noise_on_channel[0] || will_estimate_noise_on_channel[1] || sts[ch]->bfi ) { @@ -1003,10 +1008,10 @@ ivas_error ivas_core_dec( } } } - for ( int p = 0; p < s_min( 960, st->L_frame ); p++ ) - { - st->hTcxDec->old_excFB[p] = (float) ( st->hTcxDec->old_excFB_fx[p] ) / ( 1u << st->Q_exc ); - } + //for ( int p = 0; p < s_min( 960, st->L_frame ); p++ ) + //{ + // st->hTcxDec->old_excFB[p] = (float) ( st->hTcxDec->old_excFB_fx[p] ) / ( 1u << st->Q_exc ); + //} for ( int p = 0; p < s_min( 320, st->L_frame / 2 ); p++ ) { @@ -1045,8 +1050,8 @@ ivas_error ivas_core_dec( fixedToFloat_arr( synth_fx_16[0], synth[0], 15 - e_sig, 960 ); fixedToFloat_arr( synth_fx_16[1], synth[1], 15 - e_sig, 960 ); - fixedToFloat_arrL( output_fx[0], output[0], Q11, 960 ); - fixedToFloat_arrL( output_fx[1], output[1], Q11, 960 ); + //fixedToFloat_arrL( output_32_fx[0], output[0], Q11, 960 ); + //fixedToFloat_arrL( output_32_fx[1], output[1], Q11, 960 ); #endif #else stereo_mdct_core_dec( st_ivas, hCPE, output, synth ); @@ -1060,9 +1065,9 @@ ivas_error ivas_core_dec( /* To be cleaned up once the caller function is converted // These changes are for system testing of fixed changes made */ double max_synth = 0.0f; Word16 Q_syn = 15, synth_fxl[CPE_CHANNELS][L_FRAME48k]; - double max_output = 0.0f; - Word16 Q_output = 31; - Word32 output_fx[CPE_CHANNELS][L_FRAME48k]; + //double max_output = 0.0f; + //Word16 Q_output = 31; + //Word32 output_fx[CPE_CHANNELS][L_FRAME48k]; sts[0] = hCPE->hCoreCoder[0]; sts[1] = hCPE->hCoreCoder[1]; @@ -1083,19 +1088,19 @@ ivas_error ivas_core_dec( synth_fxl[0][jj] = float_to_fix16( synth[0][jj], Q_syn ); } - for ( int jj = 0; jj < output_frame; jj++ ) - { - max_output = max( max_output, fabs( output[0][jj] ) ); - } - if ( (Word32) max_output != 0 ) - { - Q_output = norm_l( (Word32) max_output ); - } + //for ( int jj = 0; jj < output_frame; jj++ ) + //{ + // max_output = max( max_output, fabs( output[0][jj] ) ); + //} + //if ( (Word32) max_output != 0 ) + //{ + // Q_output = norm_l( (Word32) max_output ); + //} - for ( int jj = 0; jj < output_frame; jj++ ) - { - output_fx[0][jj] = float_to_fix( output[0][jj], Q_output ); - } + //for ( int jj = 0; jj < output_frame; jj++ ) + //{ + // output_32_fx[0][jj] = float_to_fix( output[0][jj], Q11 ); + //} } if ( hCPE->last_element_brate <= IVAS_SID_5k2 ) @@ -1108,7 +1113,7 @@ ivas_error ivas_core_dec( f2me_buf_16( sts[0]->hHQ_core->old_out, sts[0]->hHQ_core->old_out_fx, &sts[0]->hHQ_core->exp_old_out, L_FRAME48k ); f2me_buf_16( sts[1]->hHQ_core->old_out, sts[1]->hHQ_core->old_out_fx, &sts[1]->hHQ_core->exp_old_out, L_FRAME48k ); } - updateBuffersForDmxMdctStereo_fx( hCPE, output_frame, output_fx[0], output_fx[1], synth_fxl ); + updateBuffersForDmxMdctStereo_fx( hCPE, output_frame, output_32_fx[0], output_32_fx[1], synth_fxl ); if ( hCPE->last_element_brate <= IVAS_SID_5k2 ) { @@ -1118,13 +1123,13 @@ ivas_error ivas_core_dec( me2f_buf_16( sts[1]->hHQ_core->old_out_fx, sts[1]->hHQ_core->exp_old_out, sts[1]->hHQ_core->old_out, L_FRAME48k ); } - for ( i = 1; i < CPE_CHANNELS; i++ ) - { - for ( int jj = 0; jj < L_FRAME48k; jj++ ) - { - output[i][jj] = fix_to_float( output_fx[i][jj], Q_output ); - } - } + //for ( i = 1; i < CPE_CHANNELS; i++ ) + //{ + // for ( int jj = 0; jj < L_FRAME48k; jj++ ) + // { + // output[i][jj] = fix_to_float( output_32_fx[i][jj], Q11 ); + // } + //} for ( i = 1; i < CPE_CHANNELS; i++ ) { @@ -1182,29 +1187,30 @@ ivas_error ivas_core_dec( { #ifdef IVAS_FLOAT_FIXED /* To be cleaned up once the caller function is converted // These changes are for system testing of fixed changes made */ - Word32 output_fx[CPE_CHANNELS][L_FRAME16k]; + //Word32 output_fx[CPE_CHANNELS][L_FRAME16k]; Word16 Q_c_PS_LT = 31, Q_output = 31; double max_output_fx = 0; - for ( i = 0; i < CPE_CHANNELS; i++ ) - { - for ( int jj = 0; jj < L_FRAME16k; jj++ ) - { - max_output_fx = max( max_output_fx, fabs( output[i][jj] ) ); - } - } + //for ( i = 0; i < CPE_CHANNELS; i++ ) + //{ + // for ( int jj = 0; jj < L_FRAME16k; jj++ ) + // { + // max_output_fx = max( max_output_fx, fabs( output[i][jj] ) ); + // } + //} if ( (Word32) max_output_fx != 0 ) { Q_output = norm_l( (Word32) max_output_fx ); } - for ( i = 0; i < CPE_CHANNELS; i++ ) - { - for ( int jj = 0; jj < L_FRAME16k; jj++ ) - { - output_fx[i][jj] = float_to_fix( output[i][jj], Q_output ); - } - } + Q_output = 11; + //for ( i = 0; i < CPE_CHANNELS; i++ ) + //{ + // for ( int jj = 0; jj < L_FRAME16k; jj++ ) + // { + // output_32_fx[i][jj] = float_to_fix( output[i][jj], Q11 ); + // } + //} if ( (Word32) hCPE->hStereoCng->c_PS_LT != 0 ) { @@ -1212,7 +1218,7 @@ ivas_error ivas_core_dec( } Word32 c_PS_LT_fx = float_to_fix( hCPE->hStereoCng->c_PS_LT, Q_c_PS_LT ); - stereo_cng_compute_PScorr_fx( output_fx[0], output_fx[1], &Q_output, &c_PS_LT_fx, Q_c_PS_LT, sts[0]->L_frame, sts[1]->L_frame ); + stereo_cng_compute_PScorr_fx( output_32_fx[0], output_32_fx[1], &Q_output, &c_PS_LT_fx, Q_c_PS_LT, sts[0]->L_frame, sts[1]->L_frame ); hCPE->hStereoCng->c_PS_LT = fix_to_float( c_PS_LT_fx, Q_c_PS_LT ); #ifdef DUMPS_ENABLED @@ -1286,7 +1292,7 @@ ivas_error ivas_core_dec( Word16 *output_mem_fx; synth_fx16 = (Word16 *)malloc(L_FRAME48k * sizeof(Word16)); - Word32 output_fx32[L_FRAME48k]; + //Word32 output_fx32[L_FRAME48k]; output_mem_fx = (Word16 *)malloc(NS2SA(st->output_Fs, 3125000) * sizeof(Word16)); IF(p_output_mem != NULL) @@ -1299,7 +1305,8 @@ ivas_error ivas_core_dec( } floatToFixed_arr(synth[n], synth_fx16, Q_synth, L_FRAME48k); - floatToFixed_arrL(output[n], output_fx32, 4, L_FRAME48k); + //floatToFixed_arrL(output[n], output_32_fx[n], Q11, L_FRAME48k); + Scale_sig32(output_32_fx[n], L_FRAME48k, Q4 - Q11); Word16 s_tmp; s_tmp = extract_l(L_shr(st->output_Fs, 13)); @@ -1389,7 +1396,7 @@ ivas_error ivas_core_dec( Copy_Scale_sig_16_32(synth_fx16, hSCE->save_synth_fx, output_frame, 0); } - IF ( ( error = core_switching_post_dec_ivas_fx( st, synth_fx16, output_fx32, output_mem_fx, ( 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 ) + IF ( ( error = core_switching_post_dec_ivas_fx( st, synth_fx16, output_32_fx[n], output_mem_fx, ( 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 ) { return error; } @@ -1414,6 +1421,7 @@ ivas_error ivas_core_dec( ivas_bw_switching_pre_proc_fx( st, last_element_brate, nchan_out, old_syn_12k8_16k_fx[n], old_syn_fx, q_audio ); 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 if (st->last_core == ACELP_CORE && (st->core == TCX_20_CORE || st->core == TCX_10_CORE || st->core == HQ_CORE) && st->hBWE_TD != NULL) @@ -1448,7 +1456,7 @@ ivas_error ivas_core_dec( /*-------------------cldfb-end---------------------------*/ fixedToFloat_arr(synth_fx16, synth[n], Q_synth, L_FRAME48k); - fixedToFloat_arrL(output_fx32, output[n], 4, L_FRAME48k); + //fixedToFloat_arrL(output_32_fx[n], output[n], Q11, L_FRAME48k); IF(st->hHQ_core != NULL) { fixedToFloat_arr(st->hHQ_core->old_out_fx, st->hHQ_core->old_out, 0, L_FRAME48k); @@ -1486,7 +1494,8 @@ ivas_error ivas_core_dec( #ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED Word16 hb_synth_fx_16[CPE_CHANNELS][L_FRAME48k]; - Word16 output_fx_16[CPE_CHANNELS][L_FRAME48k]; + //Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k]; + //Word16 output_fx_16[CPE_CHANNELS][L_FRAME48k]; Word16 synth_fx_16[CPE_CHANNELS][L_FRAME48k]; Word16 Q_input, Q_hb_synth_fx, Q_synth_fx; @@ -1504,8 +1513,13 @@ ivas_error ivas_core_dec( FD_BWE_DEC_HANDLE hBWE_FD; hBWE_FD = st->hBWE_FD; + + //floatToFixed_arrL( old_syn_12k8_16k[n], old_syn_12k8_16k_fx, Q11, L_FRAME16k ); // Can be removed got from last fn + + //floatToFixed_arrL( bwe_exc_extended[n], bwe_exc_extended_fx[n], 2 * st->Q_exc, L_FRAME32k + NL_BUFF_OFFSET ); + Copy_Scale_sig_32_16(output_32_fx[n], output_16_fx[n], L_FRAME48k, -Q11); floatToFixed_arr( hb_synth[n], hb_synth_fx_16[n], Q_hb_synth_fx, L_FRAME48k ); - floatToFixed_arr( output[n], output_fx_16[n], Q_input, L_FRAME48k ); + //floatToFixed_arr( output[n], output_16_fx[n], Q_input, L_FRAME48k ); floatToFixed_arr( synth[n], synth_fx_16[n], Q_synth_fx, L_FRAME48k ); IF( hBWE_TD != NULL ) @@ -1532,12 +1546,12 @@ ivas_error ivas_core_dec( ELSE IF( EQ_16( st->extl, WB_BWE ) && EQ_16( st->bws_cnt, 0 ) ) { /* WB BWE decoder */ - Q_hb_synth_fx = ivas_wb_bwe_dec_fx( st, output_fx_16[n], synth_fx_16[n], hb_synth_fx_16[n], use_cldfb_for_dft, output_frame, voice_factors_fx[n], pitch_buf_fx[n], &Q_synth_fx ); + Q_hb_synth_fx = ivas_wb_bwe_dec_fx( st, output_16_fx[n], synth_fx_16[n], hb_synth_fx_16[n], use_cldfb_for_dft, output_frame, voice_factors_fx[n], pitch_buf_fx[n], &Q_synth_fx ); } /* Memories Re-Scaling */ Copy_Scale_sig_16_32( hb_synth_fx_16[n], hb_synth_fx32, L_FRAME48k, Q11 - Q_hb_synth_fx ); - Copy_Scale_sig_16_32( output_fx_16[n], output_fx32, L_FRAME48k, Q11 - Q_input ); + Copy_Scale_sig_16_32( output_16_fx[n], output_32_fx[n], L_FRAME48k, Q11 - Q_input ); Copy_Scale_sig_16_32( synth_fx_16[n], synth_fx32, L_FRAME48k, Q11 - Q_synth_fx ); IF( hBWE_FD != NULL ) @@ -1588,7 +1602,7 @@ ivas_error ivas_core_dec( ELSE IF( EQ_16( st->extl, SWB_BWE ) || EQ_16( st->extl, FB_BWE ) || ( GE_32( output_Fs, 32000 ) && EQ_16( st->core, ACELP_CORE ) && GT_16( st->bwidth, NB ) && GT_16( st->bws_cnt, 0 ) && !st->ppp_mode_dec && !( EQ_16( st->nelp_mode_dec, 1 ) && EQ_16( st->bfi, 1 ) ) ) ) { /* SWB BWE decoder */ - Q_syn_hb = swb_bwe_dec_fx32( st, output_fx32, synth_fx32, hb_synth_fx32, use_cldfb_for_dft, output_frame ); + Q_syn_hb = swb_bwe_dec_fx32( st, output_32_fx[n], synth_fx32, hb_synth_fx32, use_cldfb_for_dft, output_frame ); // Output Scale_sig32( hb_synth_fx32, output_frame, Q11 - Q_syn_hb ); @@ -1655,7 +1669,7 @@ ivas_error ivas_core_dec( #ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED fixedToFloat_arrL(hb_synth_fx32, hb_synth[n], Q11, L_FRAME48k); - fixedToFloat_arrL(output_fx32, output[n], Q11, L_FRAME48k); + //fixedToFloat_arrL(output_32_fx[n], output[n], Q11, L_FRAME48k); fixedToFloat_arrL(synth_fx32, synth[n], Q11, L_FRAME48k); IF(hBWE_TD != NULL) @@ -1934,7 +1948,7 @@ ivas_error ivas_core_dec( *----------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED // TO DO delete below - Word32 output_fx[CPE_CHANNELS][L_FRAME48k]; + //Word32 output_fx[CPE_CHANNELS][L_FRAME48k]; Word32 synth_fxg[CPE_CHANNELS][L_FRAME48k]; //Word32 hb_synth_fxg[CPE_CHANNELS][L_FRAME48k]; @@ -1942,24 +1956,24 @@ ivas_error ivas_core_dec( { FOR(int ind = 0; ind < L_FRAME48k; ind++) { - output_fx[ch_ind][ind] = (Word32)(output[ch_ind][ind] * (1 << 11)); + //output_32_fx[ch_ind][ind] = (Word32)(output[ch_ind][ind] * (1 << 11)); synth_fxg[ch_ind][ind] = (Word32)(synth[ch_ind][ind] * (1 << 11)); hb_synth_fxg[ch_ind][ind] = (Word32)(hb_synth[ch_ind][ind] * (1 << 11)); } } - Word16 q_DFT[2] = { 3, 3 }; - Word32 DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX]; + //Word16 q_DFT[2] = { 3, 3 }; + //Word32 DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX]; - IF(DFT != NULL) - { - FOR(int ind = 0; ind < CPE_CHANNELS; ind++) - { - FOR(int jj = 0; jj < STEREO_DFT_BUF_MAX; jj++) - { - DFT_fx[ind][jj] = (Word32)(DFT[ind][jj] * (1 << q_DFT[ind])); - } - } - } + //IF(DFT != NULL) + //{ + // FOR(int ind = 0; ind < CPE_CHANNELS; ind++) + // { + // FOR(int jj = 0; jj < STEREO_DFT_BUF_MAX; jj++) + // { + // DFT_fx[ind][jj] = (Word32)(DFT[ind][jj] * (1 << q_DFT[ind])); + // } + // } + //} if (hCPE != NULL) { @@ -2111,7 +2125,7 @@ ivas_error ivas_core_dec( { IF ( hCPE != NULL ) { - stereo_td2dft_update_fx( hCPE, n, output_fx[n], synth_fxg[n], hb_synth_fxg[n], output_frame ); + stereo_td2dft_update_fx( hCPE, n, output_32_fx[n], synth_fxg[n], hb_synth_fxg[n], output_frame ); } } } @@ -2120,18 +2134,28 @@ ivas_error ivas_core_dec( Word16 q = 11; IF ( EQ_16(hCPE->last_element_mode, IVAS_CPE_MDCT )) { - stereo_mdct2dft_update_fx( hCPE, output_fx[0], synth_fxg[0] ); + stereo_mdct2dft_update_fx( hCPE, output_32_fx[0], synth_fxg[0] ); + } + Word16 q_DFT[2] = { 3, 3 }; + + stereo_dft_dec_core_switching_fx( hCPE, output_32_fx[0], synth_fxg[0], hb_synth_fxg[0], DFT_fx, output_frame, use_cldfb_for_dft, 0, &q, q_DFT ); + + hCPE->hStereoDft->q_dft = s_min( q_DFT[0], q_DFT[1] ); + + IF( DFT_fx != NULL ) + { + Scale_sig32( DFT_fx[0], STEREO_DFT_BUF_MAX, sub(hCPE->hStereoDft->q_dft , q_DFT[0]) ); + Scale_sig32( DFT_fx[1], STEREO_DFT_BUF_MAX, sub(hCPE->hStereoDft->q_dft , q_DFT[1]) ); } - stereo_dft_dec_core_switching_fx( hCPE, output_fx[0], synth_fxg[0], hb_synth_fxg[0], DFT_fx, output_frame, use_cldfb_for_dft, 0, &q, q_DFT ); - IF (EQ_16(hCPE->nchan_out, 1) && EQ_16(hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF )) + IF( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF ) ) { /* mono output for non-residual coding modes uses CLDFB instead of DFT - requires DFT buffer update in case of bitrate switching */ - stereo_td2dft_update_fx( hCPE, n, output_fx[n], synth_fxg[n], hb_synth_fxg[n], output_frame ); + stereo_td2dft_update_fx( hCPE, n, output_32_fx[n], synth_fxg[n], hb_synth_fxg[n], output_frame ); } } - Copy32( synth_fxg[n], output_fx[n], output_frame ); + Copy32( synth_fxg[n], output_32_fx[n], output_frame ); /*--------------------------------------------------------* * Common updates @@ -2147,7 +2171,7 @@ ivas_error ivas_core_dec( Copy_Scale_sig32_16( st->prev_synth_buffer32_fx, st->prev_synth_buffer_fx, NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); st->q_prev_synth_buffer_fx = 0; - exp_ouput = Find_Max_Norm32(output_fx[n], output_frame); + exp_ouput = Find_Max_Norm32(output_32_fx[n], output_frame); exp_ouput += 11; exp_prev_synth_buffer = Find_Max_Norm16(st->prev_synth_buffer_fx, NS2SA(48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS)); exp_prev_synth_buffer += st->q_prev_synth_buffer_fx; @@ -2162,7 +2186,7 @@ ivas_error ivas_core_dec( exp_max = s_min(exp_max, exp_old_out); move16(); exp_max = s_min(exp_max, exp_delay_buf_out); move16(); - Copy32(output_fx[n], output_fx_loc, output_frame); + Copy32(output_32_fx[n], output_fx_loc, output_frame); Scale_sig32(output_fx_loc, output_frame, exp_max - 11); Scale_sig(st->delay_buf_out_fx, NS2SA(st->output_Fs, DELAY_CLDFB_NS), exp_max - 0); @@ -2178,7 +2202,7 @@ ivas_error ivas_core_dec( /* Updates */ - ivas_updt_dec_common_fx( st, NORMAL_HQ_CORE, -1, output_fx[n], 11 ); + ivas_updt_dec_common_fx( st, NORMAL_HQ_CORE, -1, output_32_fx[n], 11 ); Scale_sig( st->delay_buf_out_fx, NS2SA( st->output_Fs, DELAY_CLDFB_NS ), -exp_max ); @@ -2188,21 +2212,21 @@ ivas_error ivas_core_dec( { FOR( i = 0; i < L_FRAME48k; i++ ) { - output[ch_ind][i] = fixedToFloat(output_fx[ch_ind][i], 11); + //output[ch_ind][i] = fixedToFloat(output_32_fx[ch_ind][i], 11); synth[ch_ind][i] = (float) synth_fxg[ch_ind][i] / (float) ( 1 << 11 ); hb_synth[ch_ind][i] = (float) hb_synth_fxg[ch_ind][i] / (float) ( 1 << 11 ); } } - IF( DFT != NULL ) - { - FOR( i = 0; i < CPE_CHANNELS; i++ ) - { - FOR( Word16 jj = 0; jj < STEREO_DFT_BUF_MAX; jj++ ) - { - DFT[i][jj] = (float) DFT_fx[i][jj] / (float) ( 1 << q_DFT[i] ); - } - } - } + //IF( DFT != NULL ) + //{ + // FOR( i = 0; i < CPE_CHANNELS; i++ ) + // { + // FOR( Word16 jj = 0; jj < STEREO_DFT_BUF_MAX; jj++ ) + // { + // DFT[i][jj] = (float) DFT_fx[i][jj] / (float) ( 1 << q_DFT[i] ); + // } + // } + //} if ( hCPE != NULL ) { diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index f9aeb211f..807281206 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -677,11 +677,15 @@ ivas_error ivas_cpe_dec_fx( } } + floatToFixed_arrL( output_flt[0], output[0], Q11, L_FRAME48k ); + floatToFixed_arrL( output_flt[1], output[1], Q11, L_FRAME48k ); #endif - IF( ( error = ivas_core_dec( st_ivas, NULL, hCPE, st_ivas->hMCT, n_channels, output_flt, outputHB, NULL, st_ivas->sba_dirac_stereo_flag ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_core_dec( st_ivas, NULL, hCPE, st_ivas->hMCT, n_channels, output, outputHB, NULL, st_ivas->sba_dirac_stereo_flag ) ) != IVAS_ERR_OK ) { return error; } + fixedToFloat_arrL(output[0], output_flt[0], Q11, L_FRAME48k); + fixedToFloat_arrL(output[1], output_flt[1], Q11, L_FRAME48k); } IF( st_ivas->hMCT ) @@ -742,12 +746,21 @@ ivas_error ivas_cpe_dec_fx( } #endif + set32_fx( DFT_fx[0], 0, STEREO_DFT_BUF_MAX ); + set32_fx( DFT_fx[1], 0, STEREO_DFT_BUF_MAX ); /* core decoder */ - IF( ( error = ivas_core_dec( NULL, NULL, hCPE, st_ivas->hMCT, n_channels, output_flt, outputHB, DFT, 0 ) ) != IVAS_ERR_OK ) + floatToFixed_arrL(output_flt[0], output[0], Q11, L_FRAME48k); + floatToFixed_arrL(output_flt[1], output[1], Q11, L_FRAME48k); + IF( ( error = ivas_core_dec( NULL, NULL, hCPE, st_ivas->hMCT, n_channels, output, outputHB, DFT_fx, 0 ) ) != IVAS_ERR_OK ) { return error; } + fixedToFloat_arrL(output[0], output_flt[0], Q11, L_FRAME48k); + fixedToFloat_arrL(output[1], output_flt[1], Q11, L_FRAME48k); + + fixedToFloat_arrL(DFT_fx[0], DFT[0], hCPE->hStereoDft->q_dft, STEREO_DFT_BUF_MAX); + fixedToFloat_arrL(DFT_fx[1], DFT[1], hCPE->hStereoDft->q_dft, STEREO_DFT_BUF_MAX); /* DFT Stereo residual decoding */ IF( GT_16( hCPE->hStereoDft->res_cod_band_max, 0 ) && !st_ivas->bfi ) @@ -1011,7 +1024,6 @@ ivas_error ivas_cpe_dec_fx( } // sts[0]->hFdCngDec->cna_rescale_fact_fx = (Word16)floatToFixed(sts[0]->hFdCngDec->cna_rescale_fact, 15); - sts[0]->hFdCngDec->cna_act_fact_fx = (Word16)floatToFixed(sts[0]->hFdCngDec->cna_act_fact, 15); floatToFixed_arrL(&sts[0]->hFdCngDec->smoothed_psd[0], &sts[0]->hFdCngDec->smoothed_psd_fx[0], sts[0]->hFdCngDec->q_smoothed_psd, sizeof(sts[0]->hFdCngDec->smoothed_psd_fx) / sizeof(sts[0]->hFdCngDec->smoothed_psd_fx[0])); floatToFixed_arrL(&DFT[0][0], &DFT_fx[0][0], hCPE->hStereoDft->q_dft , sizeof(DFT) / sizeof(DFT[0][0])); floatToFixed_arrL(&hCPE->hStereoDft->res_cod_mem[0], &hCPE->hStereoDft->res_cod_mem_fx[0], hCPE->hStereoDft->q_dft, sizeof(hCPE->hStereoDft->res_cod_mem_fx) / sizeof(hCPE->hStereoDft->res_cod_mem_fx[0])); @@ -1059,7 +1071,6 @@ ivas_error ivas_cpe_dec_fx( stereo_dft_dec_fx( hCPE->hStereoDft, sts[0], DFT_fx, hCPE->input_mem_fx[1], hCPE->hStereoCng, 0, 0, 0, 0, 0, 0, MAX_PARAM_SPATIAL_SUBFRAMES ); { // sts[0]->hFdCngDec->cna_rescale_fact = fixedToFloat(sts[0]->hFdCngDec->cna_rescale_fact_fx, 15); - sts[0]->hFdCngDec->cna_act_fact = fixedToFloat(sts[0]->hFdCngDec->cna_act_fact_fx, 15); fixedToFloat_arrL(&sts[0]->hFdCngDec->smoothed_psd_fx[0], &sts[0]->hFdCngDec->smoothed_psd[0], sts[0]->hFdCngDec->q_smoothed_psd, sizeof(sts[0]->hFdCngDec->smoothed_psd_fx) / sizeof(sts[0]->hFdCngDec->smoothed_psd_fx[0])); fixedToFloat_arrL(&DFT_fx[0][0], &DFT[0][0], hCPE->hStereoDft->q_dft , sizeof(DFT) / sizeof(DFT[0][0])); for (int ii = 0; ii < sizeof(hCPE->hStereoDft->hb_nrg_subr_fx) / sizeof(hCPE->hStereoDft->hb_nrg_subr_fx[0]); ii++) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index ec1c6f4b8..d761e1c72 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -97,12 +97,11 @@ ivas_error ivas_jbm_dec_tc( float *data /* o : transport channel signals */ ) { - int16_t n, output_frame, nchan_out; - Decoder_State *st; /* used for bitstream handling */ + int16_t n, output_frame, nchan_out, i, j; + Decoder_State *st, **sts; /* used for bitstream handling */ float *p_output[MAX_TRANSPORT_CHANNELS]; /* 'float' buffer for output synthesis */ #ifdef IVAS_FLOAT_FIXED - Word32 *p_output_fix[MAX_TRANSPORT_CHANNELS]; /* 'float' buffer for output synthesis */ - Word32 *p_output_fx[MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS]; /* 'float' buffer for output synthesis */ + Word32 *p_output_fx[MAX_TRANSPORT_CHANNELS]; /* 'float' buffer for output synthesis */ #endif int16_t nchan_remapped; int16_t nb_bits_metadata[MAX_SCE + 1]; @@ -111,7 +110,10 @@ ivas_error ivas_jbm_dec_tc( ivas_error error; int16_t num_md_sub_frames; int32_t ism_total_brate; - + + MCT_DEC_HANDLE hMCT; + CPE_DEC_HANDLE hCPE; + SCE_DEC_HANDLE hSCE; push_wmops( "ivas_jbm_dec_tc" ); /*----------------------------------------------------------------* @@ -133,10 +135,10 @@ ivas_error ivas_jbm_dec_tc( set_zero( p_output[n], L_FRAME48k ); } #ifdef IVAS_FLOAT_FIXED - p_output_fix[n] = st_ivas->p_output_fx[n]; - if ( p_output_fix[n] != NULL ) + p_output_fx[n] = st_ivas->p_output_fx[n]; + if ( p_output_fx[n] != NULL ) { - set_l( p_output_fix[n], 0, L_FRAME48k ); + set_l( p_output_fx[n], 0, L_FRAME48k ); } #endif } @@ -167,7 +169,7 @@ ivas_error ivas_jbm_dec_tc( /* zero output when first frame(s) is lost */ for ( n = 0; n < nchan_out; n++ ) { - set_l( p_output_fix[n], 0, output_frame ); + set_l( p_output_fx[n], 0, output_frame ); } #endif } @@ -175,25 +177,20 @@ ivas_error ivas_jbm_dec_tc( { st_ivas->hCPE[0]->element_brate = ivas_total_brate; #ifdef IVAS_FLOAT_FIXED - Word32 *output_fx[2]; Word16 q_output = 11; - output_fx[0] = malloc( sizeof( Word32 ) * L_FRAME48k ); - output_fx[1] = malloc( sizeof( Word32 ) * L_FRAME48k ); - set32_fx( &output_fx[0][0], 0, L_FRAME48k ); - set32_fx( &output_fx[1][0], 0, L_FRAME48k ); + set32_fx( &p_output_fx[0][0], 0, L_FRAME48k ); + set32_fx( &p_output_fx[1][0], 0, L_FRAME48k ); - IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, &output_fx[0], output_frame, 0, &q_output ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, 0, &q_output ) ) != IVAS_ERR_OK ) { return error; } for ( int k = 0; k < L_FRAME48k; k++ ) { - p_output[0][k] = (float) output_fx[0][k] / ( 1 << q_output ); - p_output[1][k] = (float) output_fx[1][k] / ( 1 << q_output ); + p_output[0][k] = (float) p_output_fx[0][k] / ( 1 << q_output ); + p_output[1][k] = (float) p_output_fx[1][k] / ( 1 << q_output ); } - free( output_fx[0] ); - free( output_fx[1] ); #else if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, 0 ) ) != IVAS_ERR_OK ) { @@ -205,15 +202,14 @@ ivas_error ivas_jbm_dec_tc( for ( n = 0; n < min( nchan_out, st_ivas->nchan_transport ); n++ ) { #ifdef IVAS_FLOAT_FIXED - Word32 p_output_fix[L_FRAME48k]; - for ( int i = 0; i < output_frame; i++ ) + for ( i = 0; i < output_frame; i++ ) { - p_output_fix[i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); + p_output_fx[n][i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); } - hp20_fix32( p_output_fix, output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); - for ( int i = 0; i < output_frame; i++ ) + hp20_fix32( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + for ( i = 0; i < output_frame; i++ ) { - p_output[n][i] = (float) p_output_fix[i] / ( 1 << 11 ); + p_output[n][i] = (float) p_output_fx[n][i] / ( 1 << 11 ); } #else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); @@ -223,11 +219,10 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->renderer_type == RENDERER_MC && st_ivas->hDecoderConfig->nchan_out == 1 ) { #ifdef IVAS_FLOAT_FIXED - Word16 i, j, q = Q16; + Word16 q = Q16; q = q - find_guarded_bits_fx( st_ivas->nchan_transport ); FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { - p_output_fx[i] = malloc( L_FRAME48k * sizeof( Word32 ) ); floatToFixed_arrL( p_output[i], p_output_fx[i], q, output_frame ); } FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) @@ -241,7 +236,6 @@ ivas_error ivas_jbm_dec_tc( FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], q, output_frame ); - free( p_output_fx[i] ); } #else ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, output_frame, p_output, p_output ); @@ -296,21 +290,19 @@ ivas_error ivas_jbm_dec_tc( #endif // IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED - Word32 *output_fx[1]; - output_fx[0] = malloc( sizeof( Word32 ) * L_FRAME48k ); - set32_fx( output_fx[0], 0, L_FRAME48k ); + set32_fx( p_output_fx[st_ivas->hISMDTX.sce_id_dtx], 0, L_FRAME48k ); //for ( int k = 0; k < 45; k++ ) //{ // st_ivas->hSCE[st_ivas->hISMDTX.sce_id_dtx]->prev_hb_synth_fx[k] = (Word32) ( st_ivas->hSCE[st_ivas->hISMDTX.sce_id_dtx]->prev_hb_synth[k] * ONE_IN_Q11 ); //} - IF( ( error = ivas_sce_dec_fx( st_ivas, st_ivas->hISMDTX.sce_id_dtx, &output_fx[0], output_frame, nb_bits_metadata[st_ivas->hISMDTX.sce_id_dtx] ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_sce_dec_fx( st_ivas, st_ivas->hISMDTX.sce_id_dtx, &p_output_fx[st_ivas->hISMDTX.sce_id_dtx], output_frame, nb_bits_metadata[st_ivas->hISMDTX.sce_id_dtx] ) ) != IVAS_ERR_OK ) { return error; } for ( int k = 0; k < output_frame; k++ ) { - p_output[st_ivas->hISMDTX.sce_id_dtx][k] = (float) output_fx[0][k] / ONE_IN_Q11; + p_output[st_ivas->hISMDTX.sce_id_dtx][k] = (float) p_output_fx[st_ivas->hISMDTX.sce_id_dtx][k] / ONE_IN_Q11; } for ( int k = 0; k < 96; k++ ) { @@ -318,7 +310,6 @@ ivas_error ivas_jbm_dec_tc( //if ( k < 45 ) // st_ivas->hSCE[st_ivas->hISMDTX.sce_id_dtx]->prev_hb_synth[k] = (float) st_ivas->hSCE[st_ivas->hISMDTX.sce_id_dtx]->prev_hb_synth_fx[k] / ONE_IN_Q11; } - free( output_fx[0] ); #else /* decode dominant object first so the noise energy of the other objects can be limited */ if ( ( error = ivas_sce_dec( st_ivas, st_ivas->hISMDTX.sce_id_dtx, &p_output[st_ivas->hISMDTX.sce_id_dtx], output_frame, nb_bits_metadata[st_ivas->hISMDTX.sce_id_dtx] ) ) != IVAS_ERR_OK ) @@ -443,22 +434,20 @@ ivas_error ivas_jbm_dec_tc( if ( !( ( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) && n == st_ivas->hISMDTX.sce_id_dtx ) ) { #ifdef IVAS_FLOAT_FIXED - Word32 *output_fx[1]; - output_fx[0] = malloc( sizeof( Word32 ) * L_FRAME48k ); - set32_fx( output_fx[0], 0, L_FRAME48k ); + set32_fx( p_output_fx[n], 0, L_FRAME48k ); //for ( int k = 0; k < 45; k++ ) //{ // st_ivas->hSCE[n]->prev_hb_synth_fx[k] = (Word32) ( st_ivas->hSCE[n]->prev_hb_synth[k] * ONE_IN_Q11 ); //} - IF( ( error = ivas_sce_dec_fx( st_ivas, n, &output_fx[0], output_frame, nb_bits_metadata[n] ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_sce_dec_fx( st_ivas, n, &p_output_fx[n], output_frame, nb_bits_metadata[n] ) ) != IVAS_ERR_OK ) { return error; } for ( int k = 0; k < output_frame; k++ ) { - p_output[n][k] = (float) output_fx[0][k] / ONE_IN_Q11; + p_output[n][k] = (float) p_output_fx[n][k] / ONE_IN_Q11; } for ( int k = 0; k < 96; k++ ) { @@ -466,7 +455,6 @@ ivas_error ivas_jbm_dec_tc( //if ( k < 45 ) // st_ivas->hSCE[n]->prev_hb_synth[k] = (float) st_ivas->hSCE[n]->prev_hb_synth_fx[k] / ONE_IN_Q11; } - free( output_fx[0] ); #else if ( ( error = ivas_sce_dec( st_ivas, n, &p_output[n], output_frame, nb_bits_metadata[n] ) ) != IVAS_ERR_OK ) { @@ -477,15 +465,14 @@ ivas_error ivas_jbm_dec_tc( /* HP filtering */ #ifdef IVAS_FLOAT_FIXED - Word32 p_output_fix[L_FRAME48k]; - for ( int i = 0; i < output_frame; i++ ) + for ( i = 0; i < output_frame; i++ ) { - p_output_fix[i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); + p_output_fx[n][i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); } - hp20_fix32( p_output_fix, output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); - for ( int i = 0; i < output_frame; i++ ) + hp20_fix32( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + for ( i = 0; i < output_frame; i++ ) { - p_output[n][i] = (float) p_output_fix[i] / ( 1 << 11 ); + p_output[n][i] = (float) p_output_fx[n][i] / ( 1 << 11 ); } #else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); @@ -495,12 +482,10 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { #ifdef IVAS_FLOAT_FIXED - Word32 *output_fx[12]; for ( int lp = 0; lp < 12; lp++ ) { if ( p_output[lp] != NULL ) { - output_fx[lp] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); } } for ( int lp = 0; lp < 12; lp++ ) @@ -509,22 +494,15 @@ ivas_error ivas_jbm_dec_tc( { for ( int lp2 = 0; lp2 < output_frame; lp2++ ) { - output_fx[lp][lp2] = (Word32) ( p_output[lp][lp2] * ( 1u << 11 ) ); + p_output_fx[lp][lp2] = (Word32) ( p_output[lp][lp2] * ( 1u << 11 ) ); } } } - ivas_mono_downmix_render_passive_fx( st_ivas, output_fx, output_frame ); + ivas_mono_downmix_render_passive_fx( st_ivas, p_output_fx, output_frame ); for ( int lp = 0; lp < 960; lp++ ) { - p_output[0][lp] = (float) output_fx[0][lp] / ( 1u << 8 ); - } - for ( int lp = 0; lp < 12; lp++ ) - { - if ( p_output[lp] != NULL ) - { - free( output_fx[lp] ); - } + p_output[0][lp] = (float) p_output_fx[0][lp] / ( 1u << 8 ); } #else ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); @@ -534,36 +512,27 @@ ivas_error ivas_jbm_dec_tc( { /* loudness correction */ #ifdef IVAS_FLOAT_FIXED - Word32 *p_output_fx[12]; for ( int lp = 0; lp < st_ivas->nchan_transport; lp++ ) { if ( p_output[lp] != NULL ) { - p_output_fx[lp] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); } } Word16 Q_p_output = 31; - for ( int i = 0; i < st_ivas->nchan_transport; i++ ) + for ( i = 0; i < st_ivas->nchan_transport; i++ ) { Q_p_output = s_min( Q_p_output, Q_factor_arrL( p_output[i], output_frame ) ); } - for ( int i = 0; i < st_ivas->nchan_transport; i++ ) + for ( i = 0; i < st_ivas->nchan_transport; i++ ) { floatToFixed_arrL( p_output[i], p_output_fx[i], Q_p_output, output_frame ); } ivas_dirac_dec_binaural_sba_gain_fx( p_output_fx, st_ivas->nchan_transport, output_frame ); /*returns Q-1*/ Q_p_output = Q_p_output - 1; - for ( int i = 0; i < st_ivas->nchan_transport; i++ ) + for ( i = 0; i < st_ivas->nchan_transport; i++ ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], Q_p_output, output_frame ); } - for ( int lp = 0; lp < st_ivas->nchan_transport; lp++ ) - { - if ( p_output_fx[lp] != NULL ) - { - free( p_output_fx[lp] ); - } - } #else ivas_dirac_dec_binaural_sba_gain( p_output, st_ivas->nchan_transport, output_frame ); #endif // IVAS_FLOAT_FIXED @@ -583,16 +552,16 @@ ivas_error ivas_jbm_dec_tc( // Float to fix conversion starts here. IF( st_ivas->hMasa->hMasaLfeSynth != NULL ) { - FOR( Word32 j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio_fx[j] = float_to_fix16( st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio[j], Q14 ); } } IF( st_ivas->hSpatParamRendCom != NULL ) { - FOR( Word16 i = 0; i < st_ivas->hSpatParamRendCom->dirac_md_buffer_length; i++ ) + FOR( i = 0; i < st_ivas->hSpatParamRendCom->dirac_md_buffer_length; i++ ) { - FOR( Word16 j = 0; j < st_ivas->hSpatParamRendCom->num_freq_bands; j++ ) + FOR( j = 0; j < st_ivas->hSpatParamRendCom->num_freq_bands; j++ ) { st_ivas->hSpatParamRendCom->diffuseness_vector_fx[i][j] = float_to_fix( st_ivas->hSpatParamRendCom->diffuseness_vector[i][j], 30 ); st_ivas->hSpatParamRendCom->energy_ratio1_fx[i][j] = float_to_fix( st_ivas->hSpatParamRendCom->energy_ratio1[i][j], 30 ); @@ -616,9 +585,9 @@ ivas_error ivas_jbm_dec_tc( // Fix to float conversion starts here. IF( st_ivas->hSpatParamRendCom != NULL ) { - FOR( Word16 i = 0; i < st_ivas->hSpatParamRendCom->dirac_md_buffer_length; i++ ) + FOR( i = 0; i < st_ivas->hSpatParamRendCom->dirac_md_buffer_length; i++ ) { - FOR( Word16 j = 0; j < st_ivas->hSpatParamRendCom->num_freq_bands; j++ ) + FOR( j = 0; j < st_ivas->hSpatParamRendCom->num_freq_bands; j++ ) { st_ivas->hSpatParamRendCom->energy_ratio1[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->energy_ratio1_fx[i][j], 30 ); st_ivas->hSpatParamRendCom->diffuseness_vector[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->diffuseness_vector_fx[i][j], 30 ); @@ -634,7 +603,7 @@ ivas_error ivas_jbm_dec_tc( } FOR( Word16 d = 0; d < max( st_ivas->hMasa->config.numberOfDirections, st_ivas->hQMetaData->no_directions ); d++ ) { - FOR( Word16 j = 0; j < max( st_ivas->hMasa->config.numCodingBands, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); j++ ) + FOR( j = 0; j < max( st_ivas->hMasa->config.numCodingBands, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); j++ ) { FOR( Word16 k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++ ) { @@ -647,14 +616,14 @@ ivas_error ivas_jbm_dec_tc( st_ivas->hMasa->data.dir_decode_quality = fix16_to_float( st_ivas->hMasa->data.dir_decode_quality_fx, Q14 ); IF( st_ivas->hMasa->hMasaLfeSynth != NULL ) { - for ( int j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + for ( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio[j] = fix16_to_float( st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio_fx[j], Q14 ); } } IF( st_ivas->hSpatParamRendCom != NULL ) { - FOR( Word16 i = 0; i < st_ivas->hSpatParamRendCom->numIsmDirections; i++ ) + FOR( i = 0; i < st_ivas->hSpatParamRendCom->numIsmDirections; i++ ) { FOR( Word16 block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) { @@ -701,55 +670,42 @@ ivas_error ivas_jbm_dec_tc( /* core-decoding of transport channels */ #ifdef IVAS_FLOAT_FIXED - Word32 *output_fx[12]; Word16 q_output = 11; IF( EQ_16( st_ivas->nSCE, 1 ) ) { - output_fx[0] = malloc( sizeof( Word32 ) * L_FRAME48k ); - set32_fx( output_fx[0], 0, L_FRAME48k ); + set32_fx( p_output_fx[0], 0, L_FRAME48k ); //for ( int k = 0; k < 45; k++ ) //{ // st_ivas->hSCE[0]->prev_hb_synth_fx[k] = (Word32) ( st_ivas->hSCE[0]->prev_hb_synth[k] * ( 1 << q_output ) ); //} - IF( ( error = ivas_sce_dec_fx( st_ivas, 0, &output_fx[0], output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } for ( int k = 0; k < output_frame; k++ ) { - p_output[0][k] = (float) output_fx[0][k] / ( 1 << q_output ); - } - for ( int k = 0; k < 96; k++ ) - { - //st_ivas->hSCE[0]->hCoreCoder[0]->prev_synth_buffer[k] = (float) st_ivas->hSCE[0]->hCoreCoder[0]->prev_synth_buffer32_fx[k] / ( 1 << q_output ); - //if ( k < 45 ) - // st_ivas->hSCE[0]->prev_hb_synth[k] = (float) st_ivas->hSCE[0]->prev_hb_synth_fx[k] / ( 1 << q_output ); + p_output[0][k] = (float) p_output_fx[0][k] / ( 1 << q_output ); } - free( output_fx[0] ); } ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) { - output_fx[0] = malloc( sizeof( Word32 ) * L_FRAME48k ); - output_fx[1] = malloc( sizeof( Word32 ) * L_FRAME48k ); - set32_fx( &output_fx[0][0], 0, L_FRAME48k ); - set32_fx( &output_fx[1][0], 0, L_FRAME48k ); + set32_fx( &p_output_fx[0][0], 0, L_FRAME48k ); + set32_fx( &p_output_fx[1][0], 0, L_FRAME48k ); - IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, &output_fx[0], output_frame, nb_bits_metadata[0], &q_output ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0], &q_output ) ) != IVAS_ERR_OK ) { return error; } for ( int k = 0; k < L_FRAME48k; k++ ) { - p_output[0][k] = (float) output_fx[0][k] / ( 1 << q_output ); - p_output[1][k] = (float) output_fx[1][k] / ( 1 << q_output ); + p_output[0][k] = (float) p_output_fx[0][k] / ( 1 << q_output ); + p_output[1][k] = (float) p_output_fx[1][k] / ( 1 << q_output ); } - free( output_fx[0] ); - free( output_fx[1] ); } #else if ( st_ivas->nSCE == 1 ) @@ -771,14 +727,9 @@ ivas_error ivas_jbm_dec_tc( { #ifdef IVAS_FLOAT_FIXED #if 1 // Float to fix - - Decoder_State *st, **sts; - MCT_DEC_HANDLE hMCT; - CPE_DEC_HANDLE hCPE; Word16 ch, nCPE, cpe_id; - Word16 q_output = 11; - Word16 k, l, i, j; + Word16 k, l; nCPE = st_ivas->nCPE; move16(); @@ -786,7 +737,6 @@ ivas_error ivas_jbm_dec_tc( FOR( i = 0; i < 12; i++ ) if ( p_output[i] ) { - p_output_fx[i] = malloc( sizeof( Word32 ) * L_FRAME48k ); floatToFixed_arrL( p_output[i], p_output_fx[i], Q11, L_FRAME48k ); } FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) @@ -856,10 +806,10 @@ ivas_error ivas_jbm_dec_tc( IF( st->hTcxDec ) st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; IF( st->hTcxDec ) - 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 ) ); - } + //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 ) ); + //} IF( st->hFdCngDec && st->hFdCngDec->hFdCngCom ) floatToFixed_arr( st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, 15, 17 ); // st->stab_fac_fx = float_to_fix16(st->stab_fac, Q15); @@ -989,10 +939,10 @@ ivas_error ivas_jbm_dec_tc( { sts[ch]->hIGFDec->infoTCXNoise[l] = (uint8_t) sts[ch]->hIGFDec->infoTCXNoise_evs[l]; } - IF( !sts[0]->bfi || ( sts[0]->bfi && sts[ch]->core != ACELP_CORE ) ) - { - me2f_buf( sts[ch]->hIGFDec->virtualSpec, sts[ch]->hIGFDec->virtualSpec_e, sts[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); - } + //IF( !sts[0]->bfi || ( sts[0]->bfi && sts[ch]->core != ACELP_CORE ) ) + //{ + // me2f_buf( sts[ch]->hIGFDec->virtualSpec, sts[ch]->hIGFDec->virtualSpec_e, sts[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); + //} } IF( st->hTonalMDCTConc != NULL ) { @@ -1043,10 +993,10 @@ ivas_error ivas_jbm_dec_tc( fixedToFloat_arr( st->hTonalMDCTConc->secondLastPcmOut, st->hTonalMDCTConc->secondLastPcmOut_float, 0, st->hTonalMDCTConc->nSamples / 2 ); fixedToFloat_arr( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synthFB, st->Q_syn, st->hTcxDec->old_synth_lenFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); fixedToFloat_arr( st->hTcxDec->old_synth, st->hTcxDec->old_synth_float, st->Q_syn, 1280 ); - for ( int p = 0; p < st->L_frame; p++ ) - { - st->hTcxDec->old_excFB[p] = (float) ( st->hTcxDec->old_excFB_fx[p] ) / ( 1u << st->Q_exc ); - } + //for ( int p = 0; p < st->L_frame; p++ ) + //{ + // st->hTcxDec->old_excFB[p] = (float) ( st->hTcxDec->old_excFB_fx[p] ) / ( 1u << st->Q_exc ); + //} // st->preemph_fac_float = (float)st->preemph_fac / MAX_16; // st->lp_gainc = (float)st->Mode2_lp_gainc / ONE_IN_Q16; // st->lp_gainp = (float)st->Mode2_lp_gainp / ONE_IN_Q29; @@ -1100,10 +1050,6 @@ ivas_error ivas_jbm_dec_tc( /*------------------reset-code-start---------------------*/ - /*reset function flags*/ - Word8 reset_wb_tbe_synth = 0; - Word8 reset_swb_tbe = 0; - /* reset WB BWE buffers */ IF( NE_16( sts[n]->last_extl, WB_BWE ) && EQ_16( sts[n]->extl, WB_BWE ) && sts[n]->hBWE_FD != NULL ) @@ -1206,7 +1152,7 @@ ivas_error ivas_jbm_dec_tc( { IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->igf ) { - me2f_buf( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec_e, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); + //me2f_buf( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec_e, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); FOR( l = 0; l < IGF_START_MX; l++ ) { st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise[l] = (uint8_t) st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise_evs[l]; @@ -1226,7 +1172,6 @@ ivas_error ivas_jbm_dec_tc( if ( p_output[i] ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], Q11, L_FRAME48k ); - free( p_output_fx[i] ); } #endif // Fix to float #else @@ -1249,21 +1194,19 @@ ivas_error ivas_jbm_dec_tc( num_md_sub_frames = ivas_get_spar_dec_md_num_subframes(st_ivas->sba_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate); #if 1 /*Float to Fixed changes */ - FOR( Word16 i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) + FOR( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) { - output_fx[i] = malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ); - FOR( Word16 j = 0; j < output_frame; j++ ) + FOR( j = 0; j < output_frame; j++ ) { - output_fx[i][j] = (Word32) ( p_output[i][j] * ONE_IN_Q14 ); + p_output_fx[i][j] = (Word32) ( p_output[i][j] * ONE_IN_Q14 ); } } - Word16 ch, i; SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; Word16 num_bands_out, nchan_transport; num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; nchan_out = nchan_transport; - Word16 j, b, i_ts, num_out_ch; + Word16 b, i_ts, num_out_ch; num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; Word16 Q_C_re_fx = 31, Q_P_re_fx = 31; hSpar->hMdDec->Q_mixer_mat = 31; @@ -1343,28 +1286,23 @@ ivas_error ivas_jbm_dec_tc( } } #endif - ivas_agc_dec_process_fx( st_ivas->hSpar->hAgcDec, ( output_fx ), ( output_fx ), st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); + ivas_agc_dec_process_fx( st_ivas->hSpar->hAgcDec, ( p_output_fx ), ( p_output_fx ), st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); IF (st_ivas->hSpar->hPCA != NULL) { - ivas_pca_dec_fx(st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, output_fx); + ivas_pca_dec_fx(st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, p_output_fx); } ivas_spar_dec_gen_umx_mat_fx(st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, num_md_sub_frames); #if 1 /*Fixed to float changes */ - FOR(Word16 i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++) + FOR( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++) { - FOR(Word16 j = 0; j < output_frame; j++) + FOR( j = 0; j < output_frame; j++) { - p_output[i][j] = (float)output_fx[i][j] / ONE_IN_Q11; + p_output[i][j] = (float)p_output_fx[i][j] / ONE_IN_Q11; } } - FOR(Word16 i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++) - { - free(output_fx[i]); - } - FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) { FOR(i = 0; i < num_out_ch; i++) @@ -1401,8 +1339,8 @@ ivas_error ivas_jbm_dec_tc( // frame_counter = frame_counter; float max_val = 0.0; int i_max_val_psd, i_max_val_op; - CPE_DEC_HANDLE hCPE = st_ivas->hCPE[0]; - SCE_DEC_HANDLE hSCE = st_ivas->hSCE[0]; + hCPE = st_ivas->hCPE[0]; + hSCE = st_ivas->hSCE[0]; for ( int ii = 0; ii < sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[0] ); ii++ ) { if ( max_val < fabs( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[ii] ) ) @@ -1439,7 +1377,6 @@ ivas_error ivas_jbm_dec_tc( hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; } // st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact_fx = (Word16)floatToFixed(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact, 15); - st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_act_fact_fx = (Word16)floatToFixed(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_act_fact, 15); floatToFixed_arrL(&st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx[0], st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->q_smoothed_psd, sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx) / sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx[0])); //floatToFixed_arrL(&hCPE->prev_hb_synth[0][0], &hCPE->prev_hb_synth_fx[0][0], hCPE->hStereoDft->q_dft, sizeof(hCPE->prev_hb_synth_fx) / sizeof(hCPE->prev_hb_synth_fx[0][0])); for (int ii = 0; ii < sizeof(hCPE->hStereoDft->hb_nrg_subr_fx) / sizeof(hCPE->hStereoDft->hb_nrg_subr_fx[0]); ii++) @@ -1485,7 +1422,7 @@ ivas_error ivas_jbm_dec_tc( //floatToFixed_arr( &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx[0], Q15, sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx[0] ) ); for ( int ii = 0; ii < 2; ii++ ) { - floatToFixed_arrL( &p_output[ii][0], &p_output_fix[ii][0], hCPE->hStereoDft->q_dft, ( 48000 / FRAMES_PER_SEC ) ); + floatToFixed_arrL( &p_output[ii][0], &p_output_fx[ii][0], hCPE->hStereoDft->q_dft, ( 48000 / FRAMES_PER_SEC ) ); } q = hCPE->hStereoDft->q_dft; floatToFixed_arrL(&hCPE->input_mem_BPF[0][0], &hCPE->input_mem_BPF_fx[0][0], q, STEREO_DFT32MS_OVL_16k); @@ -1537,11 +1474,10 @@ ivas_error ivas_jbm_dec_tc( } floatToFixed_arrL(&hCPE->prev_synth[0][0], &hCPE->prev_synth_fx[0][0], hCPE->q_prev_synth_fx, sizeof(hCPE->prev_synth) / sizeof(hCPE->prev_synth[0][0])); - ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fix, output_frame, st_ivas->ivas_format == MC_FORMAT ); + ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame, st_ivas->ivas_format == MC_FORMAT ); fixedToFloat_arrL(&hCPE->prev_synth_fx[0][0], &hCPE->prev_synth[0][0], hCPE->q_prev_synth_fx, sizeof(hCPE->prev_synth) / sizeof(hCPE->prev_synth[0][0])); // st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact = fixedToFloat( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact_fx, 15 ); - st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_act_fact = fixedToFloat( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_act_fact_fx, 15 ); fixedToFloat_arrL( &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[0], st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->q_smoothed_psd, sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx[0] ) ); for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_subr_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_subr_fx[0] ); ii++ ) { @@ -1560,7 +1496,7 @@ ivas_error ivas_jbm_dec_tc( //fixedToFloat_arr( &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state[0], Q15, sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx[0] ) ); for ( int ii = 0; ii < 2; ii++ ) { - fixedToFloat_arrL( &p_output_fix[ii][0], &p_output[ii][0], hCPE->hStereoDft->q_dft, ( 48000 / FRAMES_PER_SEC ) ); + fixedToFloat_arrL( &p_output_fx[ii][0], &p_output[ii][0], hCPE->hStereoDft->q_dft, ( 48000 / FRAMES_PER_SEC ) ); } fixedToFloat_arrL(&hCPE->input_mem_BPF_fx[0][0], &hCPE->input_mem_BPF[0][0], q, STEREO_DFT32MS_OVL_16k); fixedToFloat_arrL(&hCPE->input_mem_fx[0][0], &hCPE->input_mem[0][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS )); @@ -1615,15 +1551,14 @@ ivas_error ivas_jbm_dec_tc( for ( n = 0; n < nchan_remapped; n++ ) { #ifdef IVAS_FLOAT_FIXED - Word32 p_output_fix[L_FRAME48k]; - for ( int i = 0; i < output_frame; i++ ) + for ( i = 0; i < output_frame; i++ ) { - p_output_fix[i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); + p_output_fx[n][i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); } - hp20_fix32( p_output_fix, output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); - for ( int i = 0; i < output_frame; i++ ) + hp20_fix32( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + for ( i = 0; i < output_frame; i++ ) { - p_output[n][i] = (float) p_output_fix[i] / ( 1 << 11 ); + p_output[n][i] = (float) p_output_fx[n][i] / ( 1 << 11 ); } #else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); @@ -1634,36 +1569,21 @@ ivas_error ivas_jbm_dec_tc( { #ifdef IVAS_FLOAT_FIXED #if 1 - Word32 *p_output_fx[12]; Word16 Q_sba = 31; - FOR( Word16 lp = 0; lp < 12; lp++ ) - { - IF( p_output[lp] != NULL ) - { - p_output_fx[lp] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); - } - } - FOR( Word16 i = 2; i <= 3; i++ ) + FOR( i = 2; i <= 3; i++ ) { Q_sba = s_min( Q_sba, Q_factor_arrL( p_output[i], output_frame ) ); } - FOR( Word16 i = 2; i <= 3; i++ ) + FOR( i = 2; i <= 3; i++ ) { floatToFixed_arrL( p_output[i], p_output_fx[i], Q_sba, output_frame ); } #endif nchan_remapped = ivas_sba_remapTCs_fx( p_output_fx, st_ivas, output_frame ); - FOR( Word16 i = 2; i <= 3; i++ ) + FOR( i = 2; i <= 3; i++ ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], Q_sba, output_frame ); } - FOR( Word16 lp = 0; lp < 12; lp++ ) - { - IF( p_output[lp] != NULL ) - { - free( p_output_fx[lp] ); - } - } #else nchan_remapped = ivas_sba_remapTCs( p_output, st_ivas, output_frame ); #endif // IVAS_FLOAT_FIXED @@ -1673,7 +1593,7 @@ ivas_error ivas_jbm_dec_tc( num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); #ifdef IVAS_FLOAT_FIXED #if 1 - Word16 ch, i; + Word16 ch; SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; Word16 Q_p_output = 14; Word16 num_bands_out, nchan_transport; @@ -1684,10 +1604,10 @@ ivas_error ivas_jbm_dec_tc( { FOR(i = 0; i < output_frame; i++) { - p_output_fix[ch][i] = floatToFixed(p_output[ch][i], Q_p_output); + p_output_fx[ch][i] = floatToFixed(p_output[ch][i], Q_p_output); } } - Word16 j, b, i_ts, num_out_ch; + Word16 b, i_ts, num_out_ch; num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; Word16 Q_C_re_fx = 31, Q_P_re_fx = 31; hSpar->hMdDec->Q_mixer_mat = 31; @@ -1767,7 +1687,7 @@ ivas_error ivas_jbm_dec_tc( } } #endif - ivas_sba_mix_matrix_determiner_fx(st_ivas->hSpar, p_output_fix, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames); + ivas_sba_mix_matrix_determiner_fx(st_ivas->hSpar, p_output_fx, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames); #if 1 /*Fixed to float changes */ FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) { @@ -1786,7 +1706,7 @@ ivas_error ivas_jbm_dec_tc( { FOR(j = 0; j < output_frame; j++) { - p_output[c][j] = (float)p_output_fix[c][j]; + p_output[c][j] = (float)p_output_fx[c][j]; } } #endif @@ -1801,21 +1721,21 @@ ivas_error ivas_jbm_dec_tc( if (st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport == 3) size += 1; - FOR(Word16 i = 0; i < size; i++) + FOR( i = 0; i < size; i++) { - FOR(Word16 j = 0; j < output_frame; j++) + FOR( j = 0; j < output_frame; j++) { - p_output_fix[i][j] = (Word32)(p_output[i][j] * ONE_IN_Q14); + p_output_fx[i][j] = (Word32)(p_output[i][j] * ONE_IN_Q14); } } - ivas_spar_dec_agc_pca_fx( st_ivas, p_output_fix, output_frame ); + ivas_spar_dec_agc_pca_fx( st_ivas, p_output_fx, output_frame ); - FOR(Word16 i = 0; i < size; i++) + FOR( i = 0; i < size; i++) { - FOR(Word16 j = 0; j < output_frame; j++) + FOR( j = 0; j < output_frame; j++) { - p_output[i][j] = (float)p_output_fix[i][j] / ONE_IN_Q11; + p_output[i][j] = (float)p_output_fx[i][j] / ONE_IN_Q11; } //dbgwrite_txt_flt(p_output[i], output_frame, "p_output.txt"); } @@ -1829,22 +1749,20 @@ ivas_error ivas_jbm_dec_tc( { #ifdef IVAS_FLOAT_FIXED Word16 q_shift = 0; - FOR( Word16 i = 0; i < 2; i++ ) + FOR( i = 0; i < 2; i++ ) { - output_fx[i] = (Word32 *) malloc( output_frame * sizeof( Word32 ) ); - FOR( Word16 j = 0; j < output_frame; j++ ) + FOR( j = 0; j < output_frame; j++ ) { - output_fx[i][j] = float_to_fix( p_output[i][j], Q11 ); + p_output_fx[i][j] = float_to_fix( p_output[i][j], Q11 ); } } - ivas_masa_prerender_fx( st_ivas, output_fx, &q_shift, output_frame, nchan_remapped ); - FOR( Word16 i = 0; i < 2; i++ ) + ivas_masa_prerender_fx( st_ivas, p_output_fx, &q_shift, output_frame, nchan_remapped ); + FOR( i = 0; i < 2; i++ ) { - FOR( Word16 j = 0; j < output_frame; j++ ) + FOR( j = 0; j < output_frame; j++ ) { - p_output[i][j] = fix_to_float( output_fx[i][j], Q11 + q_shift ); + p_output[i][j] = fix_to_float( p_output_fx[i][j], Q11 + q_shift ); } - free( output_fx[i] ); } #else ivas_masa_prerender( st_ivas, p_output, output_frame, nchan_remapped ); @@ -1856,21 +1774,21 @@ ivas_error ivas_jbm_dec_tc( #ifdef IVAS_FLOAT_FIXED Word16 Q_p_output = 31; - for ( int i = 0; i < st_ivas->nchan_transport; i++ ) + for ( i = 0; i < st_ivas->nchan_transport; i++ ) { Q_p_output = s_min( Q_p_output, Q_factor_arrL( p_output[i], output_frame ) ); } - for ( int i = 0; i < st_ivas->nchan_transport; i++ ) + for ( i = 0; i < st_ivas->nchan_transport; i++ ) { - floatToFixed_arrL( p_output[i], p_output_fix[i], Q_p_output, output_frame ); + floatToFixed_arrL( p_output[i], p_output_fx[i], Q_p_output, output_frame ); } - ivas_dirac_dec_binaural_sba_gain_fx(p_output_fix, nchan_remapped, output_frame); + ivas_dirac_dec_binaural_sba_gain_fx(p_output_fx, nchan_remapped, output_frame); Q_p_output = Q_p_output - 1; - for (int i = 0; i < st_ivas->nchan_transport; i++) + for ( i = 0; i < st_ivas->nchan_transport; i++) { - fixedToFloat_arrL(p_output_fix[i], p_output[i], Q_p_output, output_frame); + fixedToFloat_arrL(p_output_fx[i], p_output[i], Q_p_output, output_frame); } #else ivas_dirac_dec_binaural_sba_gain( p_output, nchan_remapped, output_frame ); @@ -1901,12 +1819,7 @@ ivas_error ivas_jbm_dec_tc( /* set ISM parameters and decode ISM metadata in OMASA format */ #ifdef IVAS_FLOAT_FIXED - Word32 *output_fx[MAX_TRANSPORT_CHANNELS]; Word16 q_output = 11; - for ( int i = 0; i < MAX_TRANSPORT_CHANNELS; i++ ) - { - output_fx[i] = malloc( sizeof( Word32 ) * L_FRAME48k ); - } // NOTE: the following is done to calculate the number of hIsmMetaData indices Word16 tmp_nchan_ism; if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) @@ -1918,16 +1831,16 @@ ivas_error ivas_jbm_dec_tc( ///////////////////////////////////// Float to fix conversion starts here. /////////////////////////////////// IF( st_ivas->hMasa->hMasaLfeSynth != NULL ) { - FOR( Word32 j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio_fx[j] = float_to_fix16( st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio[j], Q14 ); } } IF( st_ivas->hSpatParamRendCom != NULL ) { - FOR( Word16 i = 0; i < st_ivas->hSpatParamRendCom->dirac_md_buffer_length; i++ ) + FOR( i = 0; i < st_ivas->hSpatParamRendCom->dirac_md_buffer_length; i++ ) { - FOR( Word16 j = 0; j < st_ivas->hSpatParamRendCom->num_freq_bands; j++ ) + FOR( j = 0; j < st_ivas->hSpatParamRendCom->num_freq_bands; j++ ) { st_ivas->hSpatParamRendCom->diffuseness_vector_fx[i][j] = float_to_fix( st_ivas->hSpatParamRendCom->diffuseness_vector[i][j], 30 ); st_ivas->hSpatParamRendCom->energy_ratio1_fx[i][j] = float_to_fix( st_ivas->hSpatParamRendCom->energy_ratio1[i][j], 30 ); @@ -1955,7 +1868,7 @@ ivas_error ivas_jbm_dec_tc( } FOR( n = 0; n < tmp_nchan_ism; n++ ) { - set32_fx( output_fx[n], 0, L_FRAME48k ); + set32_fx( p_output_fx[n], 0, L_FRAME48k ); //FOR( int k = 0; k < 45; k++ ) //{ // st_ivas->hSCE[n]->prev_hb_synth_fx[k] = (Word32) ( st_ivas->hSCE[n]->prev_hb_synth[k] * ONE_IN_Q11 ); @@ -1981,14 +1894,14 @@ ivas_error ivas_jbm_dec_tc( FOR( n = 0; n < nchan_transport_ism; n++ ) { - IF( ( error = ivas_sce_dec_fx( st_ivas, n, &output_fx[st_ivas->nchan_transport + n], output_frame, nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_sce_dec_fx( st_ivas, n, &p_output_fx[st_ivas->nchan_transport + n], output_frame, nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; } } /* decode MASA channels */ - IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, output_fx, output_frame, nb_bits_metadata[0], &q_output ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, p_output_fx, output_frame, nb_bits_metadata[0], &q_output ) ) != IVAS_ERR_OK ) { return error; } @@ -1996,27 +1909,27 @@ ivas_error ivas_jbm_dec_tc( /* shifting both the channels from variable q_output to constant Q-factor (Q11) */ FOR( int k = 0; k < output_frame; k++ ) { - output_fx[0][k] = L_shr( output_fx[0][k], 11 - q_output ); + p_output_fx[0][k] = L_shr( p_output_fx[0][k], 11 - q_output ); move32(); - output_fx[1][k] = L_shr( output_fx[1][k], 11 - q_output ); + p_output_fx[1][k] = L_shr( p_output_fx[1][k], 11 - q_output ); move32(); } IF( EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) ) { - Copy32( output_fx[0], output_fx[1], output_frame ); /* Copy mono signal to stereo output channels */ + Copy32( p_output_fx[0], p_output_fx[1], output_frame ); /* Copy mono signal to stereo output channels */ } FOR( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) { - hp20_fix32( output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + hp20_fix32( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); } Word16 output_q = 11; move16(); IF( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { - ivas_mono_downmix_render_passive_fx( st_ivas, output_fx, output_frame ); + ivas_mono_downmix_render_passive_fx( st_ivas, p_output_fx, output_frame ); output_q = 8; move16(); @@ -2029,7 +1942,7 @@ ivas_error ivas_jbm_dec_tc( return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for combined MASA and ISM format" ); } - ivas_omasa_rearrange_channels_fx( output_fx, nchan_transport_ism, output_frame ); + ivas_omasa_rearrange_channels_fx( p_output_fx, nchan_transport_ism, output_frame ); output_q = 11; move16(); @@ -2039,9 +1952,9 @@ ivas_error ivas_jbm_dec_tc( //////////////////////////// Fix to float conversion starts here. /////////////////////////////////// IF( st_ivas->hSpatParamRendCom != NULL ) { - FOR( Word16 i = 0; i < st_ivas->hSpatParamRendCom->dirac_md_buffer_length; i++ ) + FOR( i = 0; i < st_ivas->hSpatParamRendCom->dirac_md_buffer_length; i++ ) { - FOR( Word16 j = 0; j < st_ivas->hSpatParamRendCom->num_freq_bands; j++ ) + FOR( j = 0; j < st_ivas->hSpatParamRendCom->num_freq_bands; j++ ) { st_ivas->hSpatParamRendCom->energy_ratio1[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->energy_ratio1_fx[i][j], 30 ); st_ivas->hSpatParamRendCom->diffuseness_vector[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->diffuseness_vector_fx[i][j], 30 ); @@ -2057,7 +1970,7 @@ ivas_error ivas_jbm_dec_tc( } FOR( Word16 d = 0; d < max( st_ivas->hMasa->config.numberOfDirections, st_ivas->hQMetaData->no_directions ); d++ ) { - FOR( Word16 j = 0; j < max( st_ivas->hMasa->config.numCodingBands, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); j++ ) + FOR( j = 0; j < max( st_ivas->hMasa->config.numCodingBands, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); j++ ) { FOR( Word16 k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++ ) { @@ -2070,14 +1983,14 @@ ivas_error ivas_jbm_dec_tc( st_ivas->hMasa->data.dir_decode_quality = fix16_to_float( st_ivas->hMasa->data.dir_decode_quality_fx, Q14 ); IF( st_ivas->hMasa->hMasaLfeSynth != NULL ) { - FOR( Word16 j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio[j] = fix16_to_float( st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio_fx[j], Q14 ); } } IF( st_ivas->hSpatParamRendCom != NULL ) { - FOR( Word16 i = 0; i < st_ivas->hSpatParamRendCom->numIsmDirections; i++ ) + FOR( i = 0; i < st_ivas->hSpatParamRendCom->numIsmDirections; i++ ) { FOR( Word16 block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) { @@ -2111,16 +2024,11 @@ ivas_error ivas_jbm_dec_tc( } FOR( n = 0; n < s_max( getNumChanSynthesis( st_ivas ), nchan_transport_ism + st_ivas->nchan_transport ); n++ ) { - FOR( int i = 0; i < output_frame; i++ ) + FOR( i = 0; i < output_frame; i++ ) { - p_output[n][i] = (float) output_fx[n][i] / ( 1 << output_q ); + p_output[n][i] = (float) p_output_fx[n][i] / ( 1 << output_q ); } } - ///// FREE ///// - FOR( int i = 0; i < MAX_TRANSPORT_CHANNELS; i++ ) - { - free( output_fx[i] ); - } /////////////////////////////////// Fixed to float conversion ends here. /////////////////////////////////// #else /* MASA metadata decoding */ @@ -2223,26 +2131,24 @@ ivas_error ivas_jbm_dec_tc( /* core-decoding of transport channels */ #ifdef IVAS_FLOAT_FIXED - Word32 *output_fx[12]; Word16 q_output = 11; IF( EQ_16( st_ivas->nSCE, 1 ) ) { - output_fx[0] = malloc( sizeof( Word32 ) * L_FRAME48k ); - set32_fx( output_fx[0], 0, L_FRAME48k ); + set32_fx( p_output_fx[0], 0, L_FRAME48k ); //for ( int k = 0; k < 45; k++ ) //{ // st_ivas->hSCE[0]->prev_hb_synth_fx[k] = (Word32) ( st_ivas->hSCE[0]->prev_hb_synth[k] * ( 1 << q_output ) ); //} - IF( ( error = ivas_sce_dec_fx( st_ivas, 0, &output_fx[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; } for ( int k = 0; k < output_frame; k++ ) { - p_output[0][k] = (float) output_fx[0][k] / ( 1 << q_output ); + p_output[0][k] = (float) p_output_fx[0][k] / ( 1 << q_output ); } for ( int k = 0; k < 96; k++ ) { @@ -2250,25 +2156,20 @@ ivas_error ivas_jbm_dec_tc( //if ( k < 45 ) // st_ivas->hSCE[0]->prev_hb_synth[k] = (float) st_ivas->hSCE[0]->prev_hb_synth_fx[k] / ( 1 << q_output ); } - free( output_fx[0] ); } ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) { - output_fx[0] = malloc( sizeof( Word32 ) * L_FRAME48k ); - output_fx[1] = malloc( sizeof( Word32 ) * L_FRAME48k ); - IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, &output_fx[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1], &q_output ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1], &q_output ) ) != IVAS_ERR_OK ) { return error; } for ( int k = 0; k < output_frame; k++ ) { - p_output[0][k] = (float) output_fx[0][k] / ( 1 << q_output ); - p_output[1][k] = (float) output_fx[1][k] / ( 1 << q_output ); + p_output[0][k] = (float) p_output_fx[0][k] / ( 1 << q_output ); + p_output[1][k] = (float) p_output_fx[1][k] / ( 1 << q_output ); } - free( output_fx[0] ); - free( output_fx[1] ); } #else if ( st_ivas->nSCE == 1 ) @@ -2290,14 +2191,8 @@ ivas_error ivas_jbm_dec_tc( { #ifdef IVAS_FLOAT_FIXED #if 1 // Float to fix - - Decoder_State *st, **sts; - MCT_DEC_HANDLE hMCT; - CPE_DEC_HANDLE hCPE; - Word16 ch, nCPE, cpe_id; - Word16 q_output = 11; - Word16 k, l, i, j; + Word16 k, l; nCPE = st_ivas->nCPE; move16(); @@ -2305,7 +2200,6 @@ ivas_error ivas_jbm_dec_tc( FOR( i = 0; i < 12; i++ ) if ( p_output[i] ) { - p_output_fx[i] = malloc( sizeof( Word32 ) * L_FRAME48k ); floatToFixed_arrL( p_output[i], p_output_fx[i], Q11, L_FRAME48k ); } FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) @@ -2377,10 +2271,10 @@ ivas_error ivas_jbm_dec_tc( IF( st->hTcxDec ) st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; IF( st->hTcxDec ) - 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 ) ); - } + //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 ) ); + //} IF( st->hFdCngDec && st->hFdCngDec->hFdCngCom ) floatToFixed_arr( st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, 15, 17 ); // st->stab_fac_fx = float_to_fix16(st->stab_fac, Q15); @@ -2512,10 +2406,10 @@ ivas_error ivas_jbm_dec_tc( sts[ch]->hIGFDec->infoTCXNoise[l] = (uint8_t) sts[ch]->hIGFDec->infoTCXNoise_evs[l]; } - IF( !sts[0]->bfi || ( sts[0]->bfi && sts[ch]->core != ACELP_CORE ) ) - { - me2f_buf( sts[ch]->hIGFDec->virtualSpec, sts[ch]->hIGFDec->virtualSpec_e, sts[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); - } + //IF( !sts[0]->bfi || ( sts[0]->bfi && sts[ch]->core != ACELP_CORE ) ) + //{ + // me2f_buf( sts[ch]->hIGFDec->virtualSpec, sts[ch]->hIGFDec->virtualSpec_e, sts[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); + //} } IF( st->hTonalMDCTConc != NULL ) { @@ -2566,10 +2460,10 @@ ivas_error ivas_jbm_dec_tc( fixedToFloat_arr( st->hTonalMDCTConc->secondLastPcmOut, st->hTonalMDCTConc->secondLastPcmOut_float, 0, st->hTonalMDCTConc->nSamples / 2 ); fixedToFloat_arr( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synthFB, st->Q_syn, st->hTcxDec->old_synth_lenFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); fixedToFloat_arr( st->hTcxDec->old_synth, st->hTcxDec->old_synth_float, st->Q_syn, 1280 ); - for ( int p = 0; p < st->L_frame; p++ ) - { - st->hTcxDec->old_excFB[p] = (float) ( st->hTcxDec->old_excFB_fx[p] ) / ( 1u << st->Q_exc ); - } + //for ( int p = 0; p < st->L_frame; p++ ) + //{ + // st->hTcxDec->old_excFB[p] = (float) ( st->hTcxDec->old_excFB_fx[p] ) / ( 1u << st->Q_exc ); + //} for ( int p = 0; p < st->L_frame / 2; p++ ) { st->hTcxDec->old_syn_Overl_float[p] = (float) st->hTcxDec->old_syn_Overl[p] * 2 * ( 1u << st->Q_syn ); @@ -2616,9 +2510,6 @@ ivas_error ivas_jbm_dec_tc( } /*------------------reset-code-start---------------------*/ - /*reset function flags*/ - Word8 reset_wb_tbe_synth = 0; - Word8 reset_swb_tbe = 0; /* reset WB BWE buffers */ @@ -2719,7 +2610,7 @@ ivas_error ivas_jbm_dec_tc( { IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->igf ) { - me2f_buf( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec_e, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); + //me2f_buf( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec_e, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); FOR( l = 0; l < IGF_START_MX; l++ ) { st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise[l] = (uint8_t) st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise_evs[l]; @@ -2739,7 +2630,6 @@ ivas_error ivas_jbm_dec_tc( if ( p_output[i] ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], Q11, L_FRAME48k ); - free( p_output_fx[i] ); } #endif // Fix to float #else @@ -2758,22 +2648,21 @@ ivas_error ivas_jbm_dec_tc( dbgwrite_txt( &p_output[sba_ch_idx], output_frame, "flt_ivas_agc_dec_process_output.txt", NULL ); #endif // DUMPS_ENABLED #else - FOR( Word16 i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) + FOR( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) { - output_fx[i] = malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ); - FOR( Word16 j = 0; j < output_frame; j++ ) + FOR( j = 0; j < output_frame; j++ ) { - output_fx[i][j] = (Word32) ( p_output[i + sba_ch_idx][j] * ONE_IN_Q14 ); + p_output_fx[i + sba_ch_idx][j] = (Word32) ( p_output[i + sba_ch_idx][j] * ONE_IN_Q14 ); } } - ivas_agc_dec_process_fx( st_ivas->hSpar->hAgcDec, ( output_fx ), ( output_fx ), st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); + ivas_agc_dec_process_fx( st_ivas->hSpar->hAgcDec, ( p_output_fx + sba_ch_idx ), ( p_output_fx + sba_ch_idx ), st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); - FOR( Word16 i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) + FOR( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) { - FOR( Word16 j = 0; j < output_frame; j++ ) + FOR( j = 0; j < output_frame; j++ ) { - p_output[i + sba_ch_idx][j] = (float) output_fx[i][j] / ONE_IN_Q11; + p_output[i + sba_ch_idx][j] = (float) p_output_fx[i + sba_ch_idx][j] / ONE_IN_Q11; } } @@ -2781,10 +2670,6 @@ ivas_error ivas_jbm_dec_tc( dbgwrite_txt( &p_output[sba_ch_idx][0], output_frame, "fix_ivas_agc_dec_process_output.txt", NULL ); #endif // DUMPS_ENABLED - FOR( Word16 i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) - { - free( output_fx[i] ); - } #endif // !IVAS_FLOAT_FIXED if ( st_ivas->hSpar->hPCA != NULL ) @@ -2805,8 +2690,8 @@ ivas_error ivas_jbm_dec_tc( frame_counter = frame_counter; float max_val = 0.0; int i_max_val_psd, i_max_val_op; - CPE_DEC_HANDLE hCPE = st_ivas->hCPE[0]; - SCE_DEC_HANDLE hSCE = st_ivas->hSCE[0]; + hCPE = st_ivas->hCPE[0]; + hSCE = st_ivas->hSCE[0]; for ( int ii = 0; ii < sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[0] ); ii++ ) { if ( max_val < fabs( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[ii] ) ) @@ -2844,7 +2729,6 @@ ivas_error ivas_jbm_dec_tc( } // st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact_fx = (Word16)floatToFixed(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact, 15); - st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_act_fact_fx = (Word16)floatToFixed(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_act_fact, 15); floatToFixed_arrL(&st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx[0], st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->q_smoothed_psd, sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx) / sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx[0])); //floatToFixed_arrL(&hCPE->prev_hb_synth[0][0], &hCPE->prev_hb_synth_fx[0][0], hCPE->hStereoDft->q_dft, sizeof(hCPE->prev_hb_synth_fx) / sizeof(hCPE->prev_hb_synth_fx[0][0])); for (int ii = 0; ii < sizeof(hCPE->hStereoDft->hb_nrg_subr_fx) / sizeof(hCPE->hStereoDft->hb_nrg_subr_fx[0]); ii++) @@ -2890,7 +2774,7 @@ ivas_error ivas_jbm_dec_tc( //floatToFixed_arr( &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx[0], Q15, sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx[0] ) ); for ( int ii = sba_ch_idx; ii < sba_ch_idx + 2; ii++ ) { - floatToFixed_arrL( &p_output[ii][0], &p_output_fix[ii][0], hCPE->hStereoDft->q_dft, ( 48000 / FRAMES_PER_SEC ) ); + floatToFixed_arrL( &p_output[ii][0], &p_output_fx[ii][0], hCPE->hStereoDft->q_dft, ( 48000 / FRAMES_PER_SEC ) ); } q = hCPE->hStereoDft->q_dft; floatToFixed_arrL(&hCPE->input_mem_BPF[0][0], &hCPE->input_mem_BPF_fx[0][0], q, STEREO_DFT32MS_OVL_16k); @@ -2942,11 +2826,10 @@ ivas_error ivas_jbm_dec_tc( } floatToFixed_arrL(&hCPE->prev_synth[0][0], &hCPE->prev_synth_fx[0][0], hCPE->q_prev_synth_fx, sizeof(hCPE->prev_synth) / sizeof(hCPE->prev_synth[0][0])); - ivas_sba_dirac_stereo_dec_fx( st_ivas, &p_output_fix[sba_ch_idx], output_frame, 0 ); + ivas_sba_dirac_stereo_dec_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame, 0 ); fixedToFloat_arrL(&hCPE->prev_synth_fx[0][0], &hCPE->prev_synth[0][0], hCPE->q_prev_synth_fx, sizeof(hCPE->prev_synth) / sizeof(hCPE->prev_synth[0][0])); // st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact = fixedToFloat( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact_fx, 15 ); - st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_act_fact = fixedToFloat( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_act_fact_fx, 15 ); fixedToFloat_arrL( &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[0], st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->q_smoothed_psd, sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx[0] ) ); for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_subr_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_subr_fx[0] ); ii++ ) { @@ -2965,7 +2848,7 @@ ivas_error ivas_jbm_dec_tc( //fixedToFloat_arr( &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state[0], Q15, sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx[0] ) ); for ( int ii = sba_ch_idx; ii < sba_ch_idx + 2; ii++ ) { - fixedToFloat_arrL( &p_output_fix[ii][0], &p_output[ii][0], hCPE->hStereoDft->q_dft, ( 48000 / FRAMES_PER_SEC ) ); + fixedToFloat_arrL( &p_output_fx[ii][0], &p_output[ii][0], hCPE->hStereoDft->q_dft, ( 48000 / FRAMES_PER_SEC ) ); } fixedToFloat_arrL(&hCPE->input_mem_BPF_fx[0][0], &hCPE->input_mem_BPF[0][0], q, STEREO_DFT32MS_OVL_16k); fixedToFloat_arrL(&hCPE->input_mem_fx[0][0], &hCPE->input_mem[0][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS )); @@ -3016,15 +2899,14 @@ ivas_error ivas_jbm_dec_tc( for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) { #ifdef IVAS_FLOAT_FIXED - Word32 p_output_fix[L_FRAME48k]; - for ( int i = 0; i < output_frame; i++ ) + for ( i = 0; i < output_frame; i++ ) { - p_output_fix[i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); + p_output_fx[n][i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); } - hp20_fix32( p_output_fix, output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); - for ( int i = 0; i < output_frame; i++ ) + hp20_fix32( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + for ( i = 0; i < output_frame; i++ ) { - p_output[n][i] = (float) p_output_fix[i] / ( 1 << 11 ); + p_output[n][i] = (float) p_output_fx[n][i] / ( 1 << 11 ); } #else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); @@ -3033,36 +2915,21 @@ ivas_error ivas_jbm_dec_tc( #ifdef IVAS_FLOAT_FIXED #if 1 - Word32 *p_output_fx[12]; Word16 Q_sba = 31; - FOR( Word16 lp = 0; lp < 12; lp++ ) - { - IF( p_output[lp] != NULL ) - { - p_output_fx[lp] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); - } - } - FOR( Word16 i = sba_ch_idx + 2; i <= sba_ch_idx + 3; i++ ) + FOR( i = sba_ch_idx + 2; i <= sba_ch_idx + 3; i++ ) { Q_sba = s_min( Q_sba, Q_factor_arrL( p_output[i], output_frame ) ); } - FOR( Word16 i = sba_ch_idx + 2; i <= sba_ch_idx + 3; i++ ) + FOR( i = sba_ch_idx + 2; i <= sba_ch_idx + 3; i++ ) { floatToFixed_arrL( p_output[i], p_output_fx[i], Q_sba, output_frame ); } #endif nchan_remapped = ivas_sba_remapTCs_fx( &p_output_fx[sba_ch_idx], st_ivas, output_frame ); - FOR( Word16 i = sba_ch_idx + 2; i <= sba_ch_idx + 3; i++ ) + FOR( i = sba_ch_idx + 2; i <= sba_ch_idx + 3; i++ ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], Q_sba, output_frame ); } - FOR( Word16 lp = 0; lp < 12; lp++ ) - { - IF( p_output[lp] != NULL ) - { - free( p_output_fx[lp] ); - } - } #else nchan_remapped = ivas_sba_remapTCs( &p_output[sba_ch_idx], st_ivas, output_frame ); #endif @@ -3073,26 +2940,21 @@ ivas_error ivas_jbm_dec_tc( #ifdef IVAS_FLOAT_FIXED #if 1 - Word16 ch, i; + Word16 ch; SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; Word16 Q_p_output = 14; Word16 num_bands_out, nchan_transport; num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; nchan_out = nchan_transport; - Word32 *output_fx[12]; - FOR( Word16 c = 0; c < nchan_transport; c++ ) - { - output_fx[c] = malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ); - } FOR( ch = 0; ch < nchan_transport; ch++ ) { FOR( i = 0; i < output_frame; i++ ) { - output_fx[ch][i] = floatToFixed( p_output[sba_ch_idx + ch][i], Q_p_output ); + p_output_fx[sba_ch_idx + ch][i] = floatToFixed( p_output[sba_ch_idx + ch][i], Q_p_output ); } } - Word16 j, b, i_ts, num_out_ch; + Word16 b, i_ts, num_out_ch; num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; Word16 Q_C_re_fx = 31, Q_P_re_fx = 31; hSpar->hMdDec->Q_mixer_mat = 31; @@ -3172,7 +3034,7 @@ ivas_error ivas_jbm_dec_tc( } } #endif - ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, output_fx, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames); + ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, p_output_fx, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames); #if 1 /*Fixed to float changes */ FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { @@ -3191,13 +3053,9 @@ ivas_error ivas_jbm_dec_tc( { FOR( j = 0; j < output_frame; j++ ) { - p_output[sba_ch_idx + c][j] = (float) output_fx[c][j]; + p_output[sba_ch_idx + c][j] = (float) p_output_fx[c][j]; } } - FOR( Word16 c = 0; c < nchan_transport; c++ ) - { - free( output_fx[c] ); - } #endif #else ivas_sba_mix_matrix_determiner( st_ivas->hSpar, &p_output[sba_ch_idx], st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); @@ -3210,21 +3068,21 @@ ivas_error ivas_jbm_dec_tc( if (size == 3) size += 1; - FOR(Word16 i = sba_ch_idx; i < size; i++) + FOR( i = sba_ch_idx; i < size; i++) { - FOR(Word16 j = 0; j < output_frame; j++) + FOR( j = 0; j < output_frame; j++) { - p_output_fix[i][j] = (Word32)(p_output[i][j] * ONE_IN_Q14); + p_output_fx[i][j] = (Word32)(p_output[i][j] * ONE_IN_Q14); } } - ivas_spar_dec_agc_pca_fx( st_ivas, &p_output_fix[sba_ch_idx], output_frame ); + ivas_spar_dec_agc_pca_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame ); - FOR(Word16 i = sba_ch_idx; i < size; i++) + FOR( i = sba_ch_idx; i < size; i++) { - FOR(Word16 j = 0; j < output_frame; j++) + FOR( j = 0; j < output_frame; j++) { - p_output[i][j] = (float)p_output_fix[i][j] / ONE_IN_Q11; + p_output[i][j] = (float)p_output_fx[i][j] / ONE_IN_Q11; } } #else @@ -3240,13 +3098,6 @@ ivas_error ivas_jbm_dec_tc( else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { #ifdef IVAS_FLOAT_FIXED - for ( int lp = 0; lp < 12; lp++ ) - { - if ( p_output[lp] != NULL ) - { - p_output_fx[lp] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); - } - } for ( int lp = 0; lp < 12; lp++ ) { if ( p_output[lp] != NULL ) @@ -3263,13 +3114,6 @@ ivas_error ivas_jbm_dec_tc( { p_output[0][lp] = (float) p_output_fx[0][lp] / ( 1u << 8 ); } - for ( int lp = 0; lp < 12; lp++ ) - { - if ( p_output[lp] != NULL ) - { - free( p_output_fx[lp] ); - } - } #else ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); #endif @@ -3289,17 +3133,14 @@ ivas_error ivas_jbm_dec_tc( { /* LFE channel decoder */ #ifdef IVAS_FLOAT_FIXED - Word32 *p_output_fx1; - p_output_fx1 = (Word32 *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ); - ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx1 ); + ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] ); for ( int p = 0; p < 960; p++ ) { - p_output[LFE_CHANNEL][p] = (float) p_output_fx1[p] / ONE_IN_Q9; + p_output[LFE_CHANNEL][p] = (float) p_output_fx[LFE_CHANNEL][p] / ONE_IN_Q9; } - free( p_output_fx1 ); #else ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output[LFE_CHANNEL] ); #endif // IVAS_FLOAT_FIXED @@ -3307,13 +3148,8 @@ ivas_error ivas_jbm_dec_tc( #ifdef IVAS_FLOAT_FIXED #if 1 // Float to fix - Decoder_State *st, **sts; - MCT_DEC_HANDLE hMCT; - CPE_DEC_HANDLE hCPE; - Word16 ch, nCPE, cpe_id; - Word16 q_output = 11; - Word16 k, l, i, j; + Word16 q_output = 11, l, k; nCPE = st_ivas->nCPE; move16(); @@ -3321,7 +3157,6 @@ ivas_error ivas_jbm_dec_tc( FOR( i = 0; i < 12; i++ ) if ( p_output[i] ) { - p_output_fx[i] = malloc( sizeof( Word32 ) * L_FRAME48k ); floatToFixed_arrL( p_output[i], p_output_fx[i], Q11, L_FRAME48k ); } FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) @@ -3395,10 +3230,10 @@ ivas_error ivas_jbm_dec_tc( IF( st->hTcxDec ) st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; IF( st->hTcxDec ) - 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 ) ); - } + //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 ) ); + //} IF( st->hFdCngDec && st->hFdCngDec->hFdCngCom ) floatToFixed_arr( st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, 15, 17 ); // st->stab_fac_fx = float_to_fix16(st->stab_fac, Q15); @@ -3530,10 +3365,10 @@ ivas_error ivas_jbm_dec_tc( sts[ch]->hIGFDec->infoTCXNoise[l] = (uint8_t) sts[ch]->hIGFDec->infoTCXNoise_evs[l]; } - IF( !sts[0]->bfi || ( sts[0]->bfi && sts[ch]->core != ACELP_CORE ) ) - { - me2f_buf( sts[ch]->hIGFDec->virtualSpec, sts[ch]->hIGFDec->virtualSpec_e, sts[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); - } + //IF( !sts[0]->bfi || ( sts[0]->bfi && sts[ch]->core != ACELP_CORE ) ) + //{ + // me2f_buf( sts[ch]->hIGFDec->virtualSpec, sts[ch]->hIGFDec->virtualSpec_e, sts[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); + //} } IF( st->hTonalMDCTConc != NULL ) { @@ -3584,10 +3419,10 @@ ivas_error ivas_jbm_dec_tc( fixedToFloat_arr( st->hTonalMDCTConc->secondLastPcmOut, st->hTonalMDCTConc->secondLastPcmOut_float, 0, st->hTonalMDCTConc->nSamples / 2 ); fixedToFloat_arr( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synthFB, st->Q_syn, st->hTcxDec->old_synth_lenFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); fixedToFloat_arr( st->hTcxDec->old_synth, st->hTcxDec->old_synth_float, st->Q_syn, 1280 ); - for ( int p = 0; p < st->L_frame; p++ ) - { - st->hTcxDec->old_excFB[p] = (float) ( st->hTcxDec->old_excFB_fx[p] ) / ( 1u << st->Q_exc ); - } + //for ( int p = 0; p < st->L_frame; p++ ) + //{ + // st->hTcxDec->old_excFB[p] = (float) ( st->hTcxDec->old_excFB_fx[p] ) / ( 1u << st->Q_exc ); + //} for ( int p = 0; p < st->L_frame / 2; p++ ) { st->hTcxDec->old_syn_Overl_float[p] = (float) st->hTcxDec->old_syn_Overl[p] * 2 * ( 1u << st->Q_syn ); @@ -3635,9 +3470,6 @@ ivas_error ivas_jbm_dec_tc( /*------------------reset-code-start---------------------*/ - /*reset function flags*/ - Word8 reset_wb_tbe_synth = 0; - Word8 reset_swb_tbe = 0; /* reset WB BWE buffers */ @@ -3738,7 +3570,7 @@ ivas_error ivas_jbm_dec_tc( { IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->igf ) { - me2f_buf( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec_e, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); + //me2f_buf( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec_e, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); FOR( l = 0; l < IGF_START_MX; l++ ) { st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise[l] = (uint8_t) st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise_evs[l]; @@ -3758,7 +3590,6 @@ ivas_error ivas_jbm_dec_tc( if ( p_output[i] ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], Q11, L_FRAME48k ); - free( p_output_fx[i] ); } #endif // Fix to float #else @@ -3774,15 +3605,14 @@ ivas_error ivas_jbm_dec_tc( if ( n != LFE_CHANNEL ) { #ifdef IVAS_FLOAT_FIXED - Word32 p_output_fix[L_FRAME48k]; - for ( int i = 0; i < output_frame; i++ ) + for ( i = 0; i < output_frame; i++ ) { - p_output_fix[i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); + p_output_fx[n][i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); } - hp20_fix32( p_output_fix, output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); - for ( int i = 0; i < output_frame; i++ ) + hp20_fix32( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + for ( i = 0; i < output_frame; i++ ) { - p_output[n][i] = (float) p_output_fix[i] / ( 1 << 11 ); + p_output[n][i] = (float) p_output_fx[n][i] / ( 1 << 11 ); } #else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); @@ -3796,15 +3626,7 @@ ivas_error ivas_jbm_dec_tc( { #ifdef IVAS_FLOAT_FIXED #if 1 - Word32 *p_output_fx[12]; - FOR( Word16 lp = 0; lp < 12; lp++ ) - { - IF( p_output[lp] != NULL ) - { - p_output_fx[lp] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); - } - } - Word16 Q_in_buffer_td = 31, i; + Word16 Q_in_buffer_td = 31; FOR( i = 0; i < st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; i++ ) { Q_in_buffer_td = s_min( Q_in_buffer_td, Q_factor_arrL( p_output[i], output_frame ) ); @@ -3820,13 +3642,6 @@ ivas_error ivas_jbm_dec_tc( { fixedToFloat_arrL( p_output_fx[i], p_output[i], Q_in_buffer_td - 3, output_frame ); } - FOR( Word16 lp = 0; lp < 12; lp++ ) - { - IF( p_output[lp] != NULL ) - { - free( p_output_fx[lp] ); - } - } #endif #else ivas_mc2sba( st_ivas->hTransSetup, p_output, p_output, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE ); @@ -3839,11 +3654,10 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->renderer_type == RENDERER_MC ) { #ifdef IVAS_FLOAT_FIXED - Word16 i, j, q = Q16; + Word16 q = Q16; q = q - find_guarded_bits_fx( st_ivas->nchan_transport ); FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { - p_output_fx[i] = malloc( L_FRAME48k * sizeof( Word32 ) ); floatToFixed_arrL( p_output[i], p_output_fx[i], q, output_frame ); } FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) @@ -3857,7 +3671,6 @@ ivas_error ivas_jbm_dec_tc( FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], q, output_frame ); - free( p_output_fx[i] ); } #else ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, output_frame, p_output, p_output ); @@ -3873,17 +3686,14 @@ ivas_error ivas_jbm_dec_tc( { /* LFE channel decoder */ #ifdef IVAS_FLOAT_FIXED - Word32 *p_output_fx1; - p_output_fx1 = (Word32 *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ); - ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx1 ); + ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] ); for ( int p = 0; p < 960; p++ ) { - p_output[LFE_CHANNEL][p] = (float) p_output_fx1[p] / ONE_IN_Q9; + p_output[LFE_CHANNEL][p] = (float) p_output_fx[LFE_CHANNEL][p] / ONE_IN_Q9; } - free( p_output_fx1 ); #else ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output[LFE_CHANNEL] ); #endif // IVAS_FLOAT_FIXED @@ -3893,13 +3703,9 @@ ivas_error ivas_jbm_dec_tc( #ifdef IVAS_FLOAT_FIXED #if 1 // Float to fix - Decoder_State *st, **sts; - MCT_DEC_HANDLE hMCT; - CPE_DEC_HANDLE hCPE; - Word16 ch, nCPE, cpe_id; Word16 q_output = 11; - Word16 k, l, i, j; + Word16 k, l; nCPE = st_ivas->nCPE; move16(); @@ -3907,7 +3713,6 @@ ivas_error ivas_jbm_dec_tc( FOR( i = 0; i < 12; i++ ) if ( p_output[i] ) { - p_output_fx[i] = malloc( sizeof( Word32 ) * L_FRAME48k ); floatToFixed_arrL( p_output[i], p_output_fx[i], Q11, L_FRAME48k ); } FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) @@ -3978,10 +3783,10 @@ ivas_error ivas_jbm_dec_tc( IF( st->hTcxDec ) st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; IF( st->hTcxDec ) - 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 ) ); - } + //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 ) ); + //} IF( st->hFdCngDec && st->hFdCngDec->hFdCngCom ) floatToFixed_arr( st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, 15, 17 ); // st->stab_fac_fx = float_to_fix16(st->stab_fac, Q15); @@ -4113,10 +3918,10 @@ ivas_error ivas_jbm_dec_tc( sts[ch]->hIGFDec->infoTCXNoise[l] = (uint8_t) sts[ch]->hIGFDec->infoTCXNoise_evs[l]; } - IF( !sts[0]->bfi || ( sts[0]->bfi && sts[ch]->core != ACELP_CORE ) ) - { - me2f_buf( sts[ch]->hIGFDec->virtualSpec, sts[ch]->hIGFDec->virtualSpec_e, sts[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); - } + //IF( !sts[0]->bfi || ( sts[0]->bfi && sts[ch]->core != ACELP_CORE ) ) + //{ + // me2f_buf( sts[ch]->hIGFDec->virtualSpec, sts[ch]->hIGFDec->virtualSpec_e, sts[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); + //} } IF( st->hTonalMDCTConc != NULL ) { @@ -4167,10 +3972,10 @@ ivas_error ivas_jbm_dec_tc( fixedToFloat_arr( st->hTonalMDCTConc->secondLastPcmOut, st->hTonalMDCTConc->secondLastPcmOut_float, 0, st->hTonalMDCTConc->nSamples / 2 ); fixedToFloat_arr( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synthFB, st->Q_syn, st->hTcxDec->old_synth_lenFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); fixedToFloat_arr( st->hTcxDec->old_synth, st->hTcxDec->old_synth_float, st->Q_syn, 1280 ); - for ( int p = 0; p < st->L_frame; p++ ) - { - st->hTcxDec->old_excFB[p] = (float) ( st->hTcxDec->old_excFB_fx[p] ) / ( 1u << st->Q_exc ); - } + //for ( int p = 0; p < st->L_frame; p++ ) + //{ + // st->hTcxDec->old_excFB[p] = (float) ( st->hTcxDec->old_excFB_fx[p] ) / ( 1u << st->Q_exc ); + //} for ( int p = 0; p < st->L_frame / 2; p++ ) { st->hTcxDec->old_syn_Overl_float[p] = (float) st->hTcxDec->old_syn_Overl[p] * 2 * ( 1u << st->Q_syn ); @@ -4218,9 +4023,6 @@ ivas_error ivas_jbm_dec_tc( /*------------------reset-code-start---------------------*/ - /*reset function flags*/ - Word8 reset_wb_tbe_synth = 0; - Word8 reset_swb_tbe = 0; /* reset WB BWE buffers */ @@ -4321,7 +4123,7 @@ ivas_error ivas_jbm_dec_tc( { IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->igf ) { - me2f_buf( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec_e, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); + //me2f_buf( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec_e, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); FOR( l = 0; l < IGF_START_MX; l++ ) { st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise[l] = (uint8_t) st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise_evs[l]; @@ -4341,7 +4143,6 @@ ivas_error ivas_jbm_dec_tc( if ( p_output[i] ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], Q11, L_FRAME48k ); - free( p_output_fx[i] ); } #endif // Fix to float #else @@ -4357,15 +4158,14 @@ ivas_error ivas_jbm_dec_tc( if ( n != LFE_CHANNEL ) { #ifdef IVAS_FLOAT_FIXED - Word32 p_output_fix[L_FRAME48k]; - for ( int i = 0; i < output_frame; i++ ) + for ( i = 0; i < output_frame; i++ ) { - p_output_fix[i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); + p_output_fx[n][i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); } - hp20_fix32( p_output_fix, output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); - for ( int i = 0; i < output_frame; i++ ) + hp20_fix32( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + for ( i = 0; i < output_frame; i++ ) { - p_output[n][i] = (float) p_output_fix[i] / ( 1 << 11 ); + p_output[n][i] = (float) p_output_fx[n][i] / ( 1 << 11 ); } #else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); @@ -4385,12 +4185,11 @@ ivas_error ivas_jbm_dec_tc( if ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) { #ifdef IVAS_FLOAT_FIXED - Word16 i, j, q = Q16, nchan_transport; + Word16 q = Q16, nchan_transport; nchan_transport = audioCfg2channels( IVAS_AUDIO_CONFIG_5_1_2 ); q = q - find_guarded_bits_fx( nchan_transport ); FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i ) { - p_output_fx[i] = malloc( L_FRAME48k * sizeof( Word32 ) ); floatToFixed_arrL( p_output[i], p_output_fx[i], q, output_frame ); } FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) @@ -4404,7 +4203,6 @@ ivas_error ivas_jbm_dec_tc( FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], q, output_frame ); - free( p_output_fx[i] ); } #else ivas_ls_setup_conversion( st_ivas, audioCfg2channels( IVAS_AUDIO_CONFIG_5_1_2 ), output_frame, p_output, p_output ); @@ -4420,23 +4218,18 @@ ivas_error ivas_jbm_dec_tc( #ifdef IVAS_FLOAT_FIXED IF( EQ_16( st_ivas->nCPE, 1 ) ) { - Word32 *output_fx[2]; Word16 q_output = 11; - output_fx[0] = malloc( sizeof( Word32 ) * L_FRAME48k ); - output_fx[1] = malloc( sizeof( Word32 ) * L_FRAME48k ); - IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, &output_fx[0], output_frame, nb_bits_metadata[0], &q_output ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0], &q_output ) ) != IVAS_ERR_OK ) { return error; } for ( int k = 0; k < output_frame; k++ ) { - p_output[0][k] = (float) output_fx[0][k] / ( 1 << q_output ); - p_output[1][k] = (float) output_fx[1][k] / ( 1 << q_output ); + p_output[0][k] = (float) p_output_fx[0][k] / ( 1 << q_output ); + p_output[1][k] = (float) p_output_fx[1][k] / ( 1 << q_output ); } - free( output_fx[0] ); - free( output_fx[1] ); } #else if ( st_ivas->nCPE == 1 ) @@ -4452,13 +4245,9 @@ ivas_error ivas_jbm_dec_tc( #ifdef IVAS_FLOAT_FIXED #if 1 // Float to fix - Decoder_State *st, **sts; - MCT_DEC_HANDLE hMCT; - CPE_DEC_HANDLE hCPE; - Word16 ch, nCPE, cpe_id; Word16 q_output = 11; - Word16 k, l, i, j; + Word16 k, l; nCPE = st_ivas->nCPE; move16(); @@ -4466,7 +4255,6 @@ ivas_error ivas_jbm_dec_tc( FOR( i = 0; i < 12; i++ ) if ( p_output[i] ) { - p_output_fx[i] = malloc( sizeof( Word32 ) * L_FRAME48k ); floatToFixed_arrL( p_output[i], p_output_fx[i], Q11, L_FRAME48k ); } FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) @@ -4537,10 +4325,10 @@ ivas_error ivas_jbm_dec_tc( IF( st->hTcxDec ) st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; IF( st->hTcxDec ) - 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 ) ); - } + //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 ) ); + //} IF( st->hFdCngDec && st->hFdCngDec->hFdCngCom ) floatToFixed_arr( st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, 15, 17 ); // st->stab_fac_fx = float_to_fix16(st->stab_fac, Q15); @@ -4670,10 +4458,10 @@ ivas_error ivas_jbm_dec_tc( { sts[ch]->hIGFDec->infoTCXNoise[l] = (uint8_t) sts[ch]->hIGFDec->infoTCXNoise_evs[l]; } - IF( !sts[0]->bfi || ( sts[0]->bfi && sts[ch]->core != ACELP_CORE ) ) - { - me2f_buf( sts[ch]->hIGFDec->virtualSpec, sts[ch]->hIGFDec->virtualSpec_e, sts[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); - } + //IF( !sts[0]->bfi || ( sts[0]->bfi && sts[ch]->core != ACELP_CORE ) ) + //{ + // me2f_buf( sts[ch]->hIGFDec->virtualSpec, sts[ch]->hIGFDec->virtualSpec_e, sts[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); + //} } IF( st->hTonalMDCTConc != NULL ) { @@ -4724,10 +4512,10 @@ ivas_error ivas_jbm_dec_tc( fixedToFloat_arr( st->hTonalMDCTConc->secondLastPcmOut, st->hTonalMDCTConc->secondLastPcmOut_float, 0, st->hTonalMDCTConc->nSamples / 2 ); fixedToFloat_arr( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synthFB, st->Q_syn, st->hTcxDec->old_synth_lenFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); fixedToFloat_arr( st->hTcxDec->old_synth, st->hTcxDec->old_synth_float, st->Q_syn, 1280 ); - for ( int p = 0; p < st->L_frame; p++ ) - { - st->hTcxDec->old_excFB[p] = (float) ( st->hTcxDec->old_excFB_fx[p] ) / ( 1u << st->Q_exc ); - } + //for ( int p = 0; p < st->L_frame; p++ ) + //{ + // st->hTcxDec->old_excFB[p] = (float) ( st->hTcxDec->old_excFB_fx[p] ) / ( 1u << st->Q_exc ); + //} for ( int p = 0; p < st->L_frame / 2; p++ ) { st->hTcxDec->old_syn_Overl_float[p] = (float) st->hTcxDec->old_syn_Overl[p] * 2 * ( 1u << st->Q_syn ); @@ -4775,9 +4563,6 @@ ivas_error ivas_jbm_dec_tc( /*------------------reset-code-start---------------------*/ - /*reset function flags*/ - Word8 reset_wb_tbe_synth = 0; - Word8 reset_swb_tbe = 0; /* reset WB BWE buffers */ @@ -4878,7 +4663,7 @@ ivas_error ivas_jbm_dec_tc( { IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->igf ) { - me2f_buf( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec_e, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); + //me2f_buf( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec_e, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); FOR( l = 0; l < IGF_START_MX; l++ ) { st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise[l] = (uint8_t) st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise_evs[l]; @@ -4898,7 +4683,6 @@ ivas_error ivas_jbm_dec_tc( if ( p_output[i] ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], Q11, L_FRAME48k ); - free( p_output_fx[i] ); } #endif // Fix to float #else @@ -4913,15 +4697,14 @@ ivas_error ivas_jbm_dec_tc( for ( n = 0; n < st_ivas->nchan_transport; n++ ) { #ifdef IVAS_FLOAT_FIXED - Word32 p_output_fix[L_FRAME48k]; - for ( int i = 0; i < output_frame; i++ ) + for ( i = 0; i < output_frame; i++ ) { - p_output_fix[i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); + p_output_fx[n][i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); } - hp20_fix32( p_output_fix, output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); - for ( int i = 0; i < output_frame; i++ ) + hp20_fix32( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + for ( i = 0; i < output_frame; i++ ) { - p_output[n][i] = (float) p_output_fix[i] / ( 1 << 11 ); + p_output[n][i] = (float) p_output_fx[n][i] / ( 1 << 11 ); } #else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); @@ -4932,11 +4715,10 @@ ivas_error ivas_jbm_dec_tc( if ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) { #ifdef IVAS_FLOAT_FIXED - Word16 i, j, q = Q16; + Word16 q = Q16; q = q - find_guarded_bits_fx( st_ivas->nchan_transport ); FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { - p_output_fx[i] = malloc( L_FRAME48k * sizeof( Word32 ) ); floatToFixed_arrL( p_output[i], p_output_fx[i], q, output_frame ); } FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) @@ -4950,7 +4732,6 @@ ivas_error ivas_jbm_dec_tc( FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], q, output_frame ); - free( p_output_fx[i] ); } #else ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, output_frame, p_output, p_output ); @@ -4969,16 +4750,16 @@ ivas_error ivas_jbm_dec_tc( // Float to fix conversion starts here. IF( st_ivas->hMasa->hMasaLfeSynth != NULL ) { - FOR( Word32 j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio_fx[j] = float_to_fix16( st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio[j], Q14 ); } } IF( st_ivas->hSpatParamRendCom != NULL ) { - FOR( Word16 i = 0; i < st_ivas->hSpatParamRendCom->dirac_md_buffer_length; i++ ) + FOR( i = 0; i < st_ivas->hSpatParamRendCom->dirac_md_buffer_length; i++ ) { - FOR( Word16 j = 0; j < st_ivas->hSpatParamRendCom->num_freq_bands; j++ ) + FOR( j = 0; j < st_ivas->hSpatParamRendCom->num_freq_bands; j++ ) { st_ivas->hSpatParamRendCom->diffuseness_vector_fx[i][j] = float_to_fix( st_ivas->hSpatParamRendCom->diffuseness_vector[i][j], 30 ); st_ivas->hSpatParamRendCom->energy_ratio1_fx[i][j] = float_to_fix( st_ivas->hSpatParamRendCom->energy_ratio1[i][j], 30 ); @@ -5002,9 +4783,9 @@ ivas_error ivas_jbm_dec_tc( // Fix to float conversion starts here. IF( st_ivas->hSpatParamRendCom != NULL ) { - FOR( Word16 i = 0; i < st_ivas->hSpatParamRendCom->dirac_md_buffer_length; i++ ) + FOR( i = 0; i < st_ivas->hSpatParamRendCom->dirac_md_buffer_length; i++ ) { - FOR( Word16 j = 0; j < st_ivas->hSpatParamRendCom->num_freq_bands; j++ ) + FOR( j = 0; j < st_ivas->hSpatParamRendCom->num_freq_bands; j++ ) { st_ivas->hSpatParamRendCom->energy_ratio1[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->energy_ratio1_fx[i][j], 30 ); st_ivas->hSpatParamRendCom->diffuseness_vector[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->diffuseness_vector_fx[i][j], 30 ); @@ -5020,7 +4801,7 @@ ivas_error ivas_jbm_dec_tc( } FOR( Word16 d = 0; d < max( st_ivas->hMasa->config.numberOfDirections, st_ivas->hQMetaData->no_directions ); d++ ) { - FOR( Word16 j = 0; j < max( st_ivas->hMasa->config.numCodingBands, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); j++ ) + FOR( j = 0; j < max( st_ivas->hMasa->config.numCodingBands, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); j++ ) { FOR( Word16 k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++ ) { @@ -5033,14 +4814,14 @@ ivas_error ivas_jbm_dec_tc( st_ivas->hMasa->data.dir_decode_quality = fix16_to_float( st_ivas->hMasa->data.dir_decode_quality_fx, Q14 ); IF( st_ivas->hMasa->hMasaLfeSynth != NULL ) { - for ( int j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + for ( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio[j] = fix16_to_float( st_ivas->hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio_fx[j], Q14 ); } } IF( st_ivas->hSpatParamRendCom != NULL ) { - FOR( Word16 i = 0; i < st_ivas->hSpatParamRendCom->numIsmDirections; i++ ) + FOR( i = 0; i < st_ivas->hSpatParamRendCom->numIsmDirections; i++ ) { FOR( Word16 block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) { @@ -5062,24 +4843,19 @@ ivas_error ivas_jbm_dec_tc( { /* Decode the transport audio signals */ #ifdef IVAS_FLOAT_FIXED - Word32 *output_fx[2]; Word16 q_output = 11; - output_fx[0] = malloc( sizeof( Word32 ) * L_FRAME48k ); - output_fx[1] = malloc( sizeof( Word32 ) * L_FRAME48k ); - IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, &output_fx[0], output_frame, nb_bits_metadata[0], &q_output ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0], &q_output ) ) != IVAS_ERR_OK ) { return error; } for ( int k = 0; k < output_frame; k++ ) { - p_output[0][k] = (float) output_fx[0][k] / ( 1 << q_output ); - p_output[1][k] = (float) output_fx[1][k] / ( 1 << q_output ); + p_output[0][k] = (float) p_output_fx[0][k] / ( 1 << q_output ); + p_output[1][k] = (float) p_output_fx[1][k] / ( 1 << q_output ); } - free( output_fx[0] ); - free( output_fx[1] ); #else if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { @@ -5092,21 +4868,20 @@ ivas_error ivas_jbm_dec_tc( /* Decode the separated channel to output[n] to be combined with the synthesized channels */ #ifdef IVAS_FLOAT_FIXED - output_fx[0] = malloc( sizeof( Word32 ) * L_FRAME48k ); - set32_fx( output_fx[0], 0, L_FRAME48k ); + set32_fx( p_output_fx[n], 0, L_FRAME48k ); //for ( int k = 0; k < 45; k++ ) //{ // st_ivas->hSCE[0]->prev_hb_synth_fx[k] = (Word32) ( st_ivas->hSCE[0]->prev_hb_synth[k] * ONE_IN_Q11 ); //} - IF( ( error = ivas_sce_dec_fx( st_ivas, 0, &output_fx[0], output_frame, 0 ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[n], output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; } for ( int k = 0; k < output_frame; k++ ) { - p_output[n][k] = (float) output_fx[0][k] / ONE_IN_Q11; + p_output[n][k] = (float) p_output_fx[n][k] / ONE_IN_Q11; } for ( int k = 0; k < 96; k++ ) { @@ -5114,7 +4889,6 @@ ivas_error ivas_jbm_dec_tc( //if ( k < 45 ) // st_ivas->hSCE[0]->prev_hb_synth[k] = (float) st_ivas->hSCE[0]->prev_hb_synth_fx[k] / ONE_IN_Q11; } - free( output_fx[0] ); #else if ( ( error = ivas_sce_dec( st_ivas, 0, &p_output[n], output_frame, 0 ) ) != IVAS_ERR_OK ) { @@ -5138,25 +4912,23 @@ ivas_error ivas_jbm_dec_tc( else { #ifdef IVAS_FLOAT_FIXED - Word32 *output_fx[2]; Word16 q_output = 11; IF( EQ_16( st_ivas->nSCE, 1 ) ) { - output_fx[0] = malloc( sizeof( Word32 ) * L_FRAME48k ); - set32_fx( output_fx[0], 0, L_FRAME48k ); + set32_fx( p_output_fx[0], 0, L_FRAME48k ); //for ( int k = 0; k < 45; k++ ) //{ // st_ivas->hSCE[0]->prev_hb_synth_fx[k] = (Word32) ( st_ivas->hSCE[0]->prev_hb_synth[k] * ( 1 << q_output ) ); //} - IF( ( error = ivas_sce_dec_fx( st_ivas, 0, &output_fx[0], output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } for ( int k = 0; k < output_frame; k++ ) { - p_output[0][k] = (float) output_fx[0][k] / ( 1 << q_output ); + p_output[0][k] = (float) p_output_fx[0][k] / ( 1 << q_output ); } for ( int k = 0; k < 96; k++ ) { @@ -5164,26 +4936,21 @@ ivas_error ivas_jbm_dec_tc( //if ( k < 45 ) // st_ivas->hSCE[0]->prev_hb_synth[k] = (float) st_ivas->hSCE[0]->prev_hb_synth_fx[k] / ( 1 << q_output ); } - free( output_fx[0] ); } ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) { - output_fx[0] = malloc( sizeof( Word32 ) * L_FRAME48k ); - output_fx[1] = malloc( sizeof( Word32 ) * L_FRAME48k ); - IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, &output_fx[0], output_frame, nb_bits_metadata[0], &q_output ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0], &q_output ) ) != IVAS_ERR_OK ) { return error; } for ( int k = 0; k < output_frame; k++ ) { - p_output[0][k] = (float) output_fx[0][k] / ( 1 << q_output ); - p_output[1][k] = (float) output_fx[1][k] / ( 1 << q_output ); + p_output[0][k] = (float) p_output_fx[0][k] / ( 1 << q_output ); + p_output[1][k] = (float) p_output_fx[1][k] / ( 1 << q_output ); } - free( output_fx[0] ); - free( output_fx[1] ); } #else if ( st_ivas->nSCE == 1 ) @@ -5216,8 +4983,8 @@ ivas_error ivas_jbm_dec_tc( frame_counter = frame_counter; float max_val = 0.0; int i_max_val_psd, i_max_val_op; - CPE_DEC_HANDLE hCPE = st_ivas->hCPE[0]; - SCE_DEC_HANDLE hSCE = st_ivas->hSCE[0]; + hCPE = st_ivas->hCPE[0]; + hSCE = st_ivas->hSCE[0]; for ( int ii = 0; ii < sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[0] ); ii++ ) { if ( max_val < fabs( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[ii] ) ) @@ -5255,7 +5022,6 @@ ivas_error ivas_jbm_dec_tc( } // st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact_fx = (Word16)floatToFixed(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact, 15); - st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_act_fact_fx = (Word16)floatToFixed(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_act_fact, 15); floatToFixed_arrL(&st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx[0], st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->q_smoothed_psd, sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx) / sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx[0])); //floatToFixed_arrL(&hCPE->prev_hb_synth[0][0], &hCPE->prev_hb_synth_fx[0][0], hCPE->hStereoDft->q_dft, sizeof(hCPE->prev_hb_synth_fx) / sizeof(hCPE->prev_hb_synth_fx[0][0])); for (int ii = 0; ii < sizeof(hCPE->hStereoDft->hb_nrg_subr_fx) / sizeof(hCPE->hStereoDft->hb_nrg_subr_fx[0]); ii++) @@ -5301,7 +5067,7 @@ ivas_error ivas_jbm_dec_tc( //floatToFixed_arr( &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx[0], Q15, sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx[0] ) ); for ( int ii = 0; ii < 2; ii++ ) { - floatToFixed_arrL( &p_output[ii][0], &p_output_fix[ii][0], hCPE->hStereoDft->q_dft, ( 48000 / FRAMES_PER_SEC ) ); + floatToFixed_arrL( &p_output[ii][0], &p_output_fx[ii][0], hCPE->hStereoDft->q_dft, ( 48000 / FRAMES_PER_SEC ) ); } q = hCPE->hStereoDft->q_dft; floatToFixed_arrL(&hCPE->input_mem_BPF[0][0], &hCPE->input_mem_BPF_fx[0][0], q, STEREO_DFT32MS_OVL_16k); @@ -5356,11 +5122,10 @@ ivas_error ivas_jbm_dec_tc( } floatToFixed_arrL(&hCPE->prev_synth[0][0], &hCPE->prev_synth_fx[0][0], hCPE->q_prev_synth_fx, sizeof(hCPE->prev_synth) / sizeof(hCPE->prev_synth[0][0])); - ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fix, output_frame, 1 ); + ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame, 1 ); fixedToFloat_arrL(&hCPE->prev_synth_fx[0][0], &hCPE->prev_synth[0][0], hCPE->q_prev_synth_fx, sizeof(hCPE->prev_synth) / sizeof(hCPE->prev_synth[0][0])); // st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact = fixedToFloat( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_rescale_fact_fx, 15 ); - st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_act_fact = fixedToFloat( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_act_fact_fx, 15 ); fixedToFloat_arrL( &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[0], st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->q_smoothed_psd, sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd_fx[0] ) ); for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_subr_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_subr_fx[0] ); ii++ ) { @@ -5379,7 +5144,7 @@ ivas_error ivas_jbm_dec_tc( //fixedToFloat_arr( &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state[0], Q15, sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_g_state_fx[0] ) ); for ( int ii = 0; ii < 2; ii++ ) { - fixedToFloat_arrL( &p_output_fix[ii][0], &p_output[ii][0], hCPE->hStereoDft->q_dft, ( 48000 / FRAMES_PER_SEC ) ); + fixedToFloat_arrL( &p_output_fx[ii][0], &p_output[ii][0], hCPE->hStereoDft->q_dft, ( 48000 / FRAMES_PER_SEC ) ); } fixedToFloat_arrL(&hCPE->input_mem_BPF_fx[0][0], &hCPE->input_mem_BPF[0][0], q, STEREO_DFT32MS_OVL_16k); fixedToFloat_arrL(&hCPE->input_mem_fx[0][0], &hCPE->input_mem[0][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS )); @@ -5433,15 +5198,14 @@ ivas_error ivas_jbm_dec_tc( for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) { #ifdef IVAS_FLOAT_FIXED - Word32 p_output_fix[L_FRAME48k]; - for ( int i = 0; i < output_frame; i++ ) + for ( i = 0; i < output_frame; i++ ) { - p_output_fix[i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); + p_output_fx[n][i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); } - hp20_fix32( p_output_fix, output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); - for ( int i = 0; i < output_frame; i++ ) + hp20_fix32( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + for ( i = 0; i < output_frame; i++ ) { - p_output[n][i] = (float) p_output_fix[i] / ( 1 << 11 ); + p_output[n][i] = (float) p_output_fx[n][i] / ( 1 << 11 ); } #else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); @@ -5451,14 +5215,6 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->renderer_type == RENDERER_MCMASA_MONO_STEREO ) { #ifdef IVAS_FLOAT_FIXED - for ( int lp = 0; lp < 12; lp++ ) - { - if ( p_output[lp] != NULL ) - { - - p_output_fx[lp] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); - } - } for ( int lp = 0; lp < 12; lp++ ) { if ( p_output[lp] != NULL ) @@ -5481,10 +5237,6 @@ ivas_error ivas_jbm_dec_tc( } } } - for ( int lp = 0; lp < 12; lp++ ) - { - free( p_output_fx[lp] ); - } #else ivas_mono_stereo_downmix_mcmasa( st_ivas, p_output, output_frame ); #endif @@ -5510,7 +5262,6 @@ ivas_error ivas_jbm_dec_tc( DECODER_TC_BUFFER_HANDLE hTcBuffer = st_ivas->hTcBuffer; Word16 n_ch_full_copy_temp = s_min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); Word16 n_ch_cldfb_tmp = hTcBuffer->nchan_transport_jbm - hTcBuffer->nchan_buffer_full; - Word32 *p_output_temp[12]; if ( st_ivas->hParamIsmDec != NULL ) { f2me_16( st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain, &st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_fx, &st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_e ); @@ -5518,8 +5269,7 @@ ivas_error ivas_jbm_dec_tc( for ( int lp = 0; lp < n_ch_cldfb_tmp; lp++ ) { - p_output_temp[lp] = (Word32 *) malloc( 960 * sizeof( Word32 ) ); - floatToFixed_arrL( p_output[lp], p_output_temp[lp], 11, 960 ); + floatToFixed_arrL( p_output[lp], p_output_fx[lp], 11, 960 ); } // cldfb_state @@ -5532,8 +5282,6 @@ ivas_error ivas_jbm_dec_tc( } } // cldfb - Word32 *real_buf; - Word32 *imag_buf; Word16 num_freq_bands = 0; if ( st_ivas->ivas_format == ISM_FORMAT ) @@ -5545,7 +5293,7 @@ ivas_error ivas_jbm_dec_tc( for ( int lp = 0; lp < n_ch_cldfb_tmp; lp++ ) { Word16 length = 15 * num_freq_bands * n_ch_cldfb_tmp + num_freq_bands * ( n_ch_cldfb_tmp - 1 ) + st_ivas->cldfbAnaDec[lp]->no_channels; - for ( Word16 i = 0; i < length; i++ ) + for ( i = 0; i < length; i++ ) { st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[i] = floatToFixed( st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[i], 6 ); @@ -5575,7 +5323,7 @@ ivas_error ivas_jbm_dec_tc( /*------------------------flt 2 fix----------------------*/ - ivas_jbm_dec_copy_tc_no_tsm_fx( st_ivas, p_output_temp, output_frame ); + ivas_jbm_dec_copy_tc_no_tsm_fx( st_ivas, p_output_fx, output_frame ); /*------------------------fix 2 flt----------------------*/ // cldfb_state @@ -5626,8 +5374,7 @@ ivas_error ivas_jbm_dec_tc( for ( int lp = 0; lp < n_ch_cldfb_tmp; lp++ ) { - fixedToFloat_arrL( p_output_temp[lp], p_output[lp], 11, 960 ); - free( p_output_temp[lp] ); + fixedToFloat_arrL( p_output_fx[lp], p_output[lp], 11, 960 ); } if ( st_ivas->hParamIsmDec != NULL ) @@ -5694,7 +5441,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( { float data_f[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k]; /* 'float' buffer for transport channels that will be directly converted with the CLDFB */ float *p_data_f[MAX_CLDFB_DIGEST_CHANNELS]; - int16_t n, n_render_timeslots; + int16_t n, n_render_timeslots, i; push_wmops( "ivas_jbm_dec_feed_tc_to_rendererer" ); for ( n = 0; n < MAX_CLDFB_DIGEST_CHANNELS; n++ ) @@ -5738,7 +5485,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( #if 1/*Float to fix */ PARAM_ISM_DEC_HANDLE hParamIsmDec; hParamIsmDec = st_ivas->hParamIsmDec; - FOR( Word16 i = 0; i < 11; i++ ) + FOR( i = 0; i < 11; i++ ) { FOR( Word16 j = 0; j < 1; j++ ) { @@ -5766,7 +5513,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( #endif // IVAS_FLOAT_FIXED ivas_param_ism_params_to_masa_param_mapping_fx( st_ivas ); #if 1 /*Fix to float*/ - FOR( Word16 i = 0; i < 11; i++ ) + FOR( i = 0; i < 11; i++ ) { FOR( Word16 j = 0; j < 1; j++ ) { @@ -5812,7 +5559,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( { #ifdef IVAS_FLOAT_FIXED #if 1 - Word16 num_in_ch, num_bands_out, nchan_transport, num_md_sub_frames, ch, i, j, b, i_ts, num_out_ch; + Word16 num_in_ch = 0, num_bands_out = 0, nchan_transport = 0, num_md_sub_frames = 0, j, b, i_ts, num_out_ch = 0; SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { @@ -5909,7 +5656,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( } } st_ivas->hTcBuffer->q_tc_fx = 14; - for (int i = 0; i < ivas_sba_get_nchan_metadata(st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate) + ch_sba_idx; i++) + for ( i = 0; i < ivas_sba_get_nchan_metadata(st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate) + ch_sba_idx; i++) { floatToFixed_arrL(st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], st_ivas->hTcBuffer->q_tc_fx, min(nSamplesForRendering, (int16_t)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC))); } @@ -5947,7 +5694,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( { Word32 max_cngNoiseLevel = 0; Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; - FOR(int i = 0; i < FFTCLDFBLEN; i++) + FOR( i = 0; i < FFTCLDFBLEN; i++) { max_cngNoiseLevel = L_max(L_abs((Word32)st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[i]), max_cngNoiseLevel); } @@ -5957,7 +5704,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( floatToFixed_arrL(st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN); - for (int i = 0; i < FFTLEN; i++) + for ( i = 0; i < FFTLEN; i++) { st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx[i] = float_to_fix(st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt[i], 15); } @@ -5992,7 +5739,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( ch_sba_idx = st_ivas->nchan_ism; move16(); } } - for (int i = 0; i < ivas_sba_get_nchan_metadata(st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate) + ch_sba_idx; i++) + for ( i = 0; i < ivas_sba_get_nchan_metadata(st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate) + ch_sba_idx; i++) { fixedToFloat_arrL(st_ivas->hTcBuffer->tc_fx[i], st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->q_tc_fx, min(nSamplesForRendering, (int16_t)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC))); } @@ -6066,43 +5813,705 @@ void ivas_jbm_dec_feed_tc_to_renderer( { n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); } +#ifdef IVAS_FLOAT_FIXED +#if 1 + Word16 num_in_ch, num_bands_out, nchan_transport, num_md_sub_frames, ch, i, j, b, i_ts, num_out_ch; + SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; + if (st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT) + { + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes(st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate); + num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; + num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; + Word16 Q_C_re_fx = 31, Q_P_re_fx = 31; + hSpar->hMdDec->Q_mixer_mat = 31; + num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; + FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) + { + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = 0; j < num_in_ch; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + hSpar->hMdDec->Q_mixer_mat = s_min(hSpar->hMdDec->Q_mixer_mat, Q_factor_L(hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS])); + } + } + } + } + FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) + { + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = 0; j < nchan_transport; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + Q_C_re_fx = s_min(Q_C_re_fx, Q_factor_L(hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS])); + } + } + } + } + FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) + { + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = nchan_transport; j < num_out_ch; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + Q_P_re_fx = s_min(Q_P_re_fx, Q_factor_L(hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS])); + } + } + } + } + hSpar->hMdDec->Q_mixer_mat = s_min(hSpar->hMdDec->Q_mixer_mat, s_min(Q_C_re_fx, Q_P_re_fx)); + FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) + { + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = 0; j < num_in_ch; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed(hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat); + } + } + } + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = 0; j < nchan_transport; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed(hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat); + } + } + } + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = nchan_transport; j < num_out_ch; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed(hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat); + } + } + } + } - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); - } - } - else - { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); - } - } - else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) - { - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) - { - n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); - } + IF(hSpar->hMdDec->td_decorr_flag && !(EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC) || EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM))) + { + Word16 ch_sba_idx = 0; + IF(EQ_16(st_ivas->ivas_format, SBA_ISM_FORMAT)) + { + IF(EQ_16(st_ivas->ism_mode, ISM_SBA_MODE_DISC)) + { + ch_sba_idx = st_ivas->nchan_ism; move16(); + } + } + st_ivas->hTcBuffer->q_tc_fx = 14; + for (int i = 0; i < ivas_sba_get_nchan_metadata(st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate) + ch_sba_idx; i++) + { + floatToFixed_arrL(st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], st_ivas->hTcBuffer->q_tc_fx, min(nSamplesForRendering, (int16_t)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC))); + } + } + } - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + if (st_ivas->hDiracDecBin != NULL && (st_ivas->hDiracDecBin->useTdDecorr)) + { + st_ivas->hTcBuffer->q_tc_fx = 14; + Word16 nSamplesLeftForTD, default_frame; + default_frame = (Word16)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC); + nSamplesLeftForTD = nSamplesForRendering; + Word16 size = 0; - if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) - { -#ifdef IVAS_FLOAT_FIXED - ivas_ism_dec_digest_tc_fx(st_ivas); -#else - ivas_ism_dec_digest_tc(st_ivas); -#endif - } - } - else if ( st_ivas->ivas_format == MC_FORMAT ) - { - if ( st_ivas->mc_mode == MC_MODE_MCT ) - { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - } - else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) - { + while (nSamplesLeftForTD) + { + Word16 nSamplesToDecorr = min(nSamplesLeftForTD, default_frame); + size += nSamplesToDecorr; + nSamplesLeftForTD -= nSamplesToDecorr; + } + size = s_max(size, default_frame); + for (int ch_idx = 0; ch_idx < BINAURAL_CHANNELS + 2; ch_idx++) + { + floatToFixed_arrL(st_ivas->hTcBuffer->tc[ch_idx], st_ivas->hTcBuffer->tc_fx[ch_idx], st_ivas->hTcBuffer->q_tc_fx, size); + } + } + nchan_transport = st_ivas->nchan_transport; + if (st_ivas->ivas_format == MASA_FORMAT && st_ivas->hDecoderConfig->ivas_total_brate < MASA_STEREO_MIN_BITRATE && (st_ivas->hDecoderConfig->ivas_total_brate > IVAS_SID_5k2 || (st_ivas->hDecoderConfig->ivas_total_brate <= IVAS_SID_5k2 && st_ivas->nCPE > 0 && st_ivas->hCPE[0]->nchan_out == 1))) + { + nchan_transport = 1; /* Only one channel transported */ + } + + if (((st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT) && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag) || + ((st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC) && (nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag))) + { + Word32 max_cngNoiseLevel = 0; + Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; + FOR(int i = 0; i < FFTCLDFBLEN; i++) + { + max_cngNoiseLevel = L_max(L_abs((Word32)st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[i]), max_cngNoiseLevel); + } + st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = norm_l(max_cngNoiseLevel); + + floatToFixed_arr(st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, Q13, M + 1); + + floatToFixed_arrL(st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN); + + for (int i = 0; i < FFTLEN; i++) + { + st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx[i] = float_to_fix(st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt[i], 15); + } + } +#endif + ivas_sba_dec_digest_tc_fx(st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available); +#if 1 + if (st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT) + { + FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) + { + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = 0; j < num_in_ch; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + st_ivas->hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = fixedToFloat(st_ivas->hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], st_ivas->hSpar->hMdDec->Q_mixer_mat); + } + } + } + } + + IF(hSpar->hMdDec->td_decorr_flag && !(EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC) || EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM))) + { + Word16 ch_sba_idx = 0; + IF(EQ_16(st_ivas->ivas_format, SBA_ISM_FORMAT)) + { + IF(EQ_16(st_ivas->ism_mode, ISM_SBA_MODE_DISC)) + { + ch_sba_idx = st_ivas->nchan_ism; move16(); + } + } + for (int i = 0; i < ivas_sba_get_nchan_metadata(st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate) + ch_sba_idx; i++) + { + fixedToFloat_arrL(st_ivas->hTcBuffer->tc_fx[i], st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->q_tc_fx, min(nSamplesForRendering, (int16_t)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC))); + } + } + } + + if (st_ivas->hDiracDecBin != NULL && (st_ivas->hDiracDecBin->useTdDecorr)) + { + st_ivas->hTcBuffer->q_tc_fx = 14; + int16_t nSamplesLeftForTD, default_frame; + default_frame = (int16_t)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC); + nSamplesLeftForTD = nSamplesForRendering; + Word16 size = 0; + + while (nSamplesLeftForTD) + { + int16_t nSamplesToDecorr = min(nSamplesLeftForTD, default_frame); + size += nSamplesToDecorr; + nSamplesLeftForTD -= nSamplesToDecorr; + } + size = s_max(size, default_frame); + for (int ch_idx = 0; ch_idx < BINAURAL_CHANNELS + 2; ch_idx++) + { + fixedToFloat_arrL(st_ivas->hTcBuffer->tc_fx[ch_idx], st_ivas->hTcBuffer->tc[ch_idx], st_ivas->hTcBuffer->q_tc_fx, size); + } + } + + if (((st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT) && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag) || + ((st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC) && (nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag))) + { + Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; + fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, 15, st->hFdCngDec->hFdCngCom->fftlen); + fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->fftBuffer, st->hFdCngDec->hFdCngCom->fftBuffer_flt, 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp, st->hFdCngDec->hFdCngCom->fftlen); + + fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->exc_cng_32fx, st->hFdCngDec->hFdCngCom->exc_cng_flt, 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp - 9, st->hFdCngDec->hFdCngCom->frameSize); + fixedToFloat_arrL(st_ivas->hTcBuffer->tc_fx[1], st_ivas->hTcBuffer->tc[1], 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp - 9, st->hFdCngDec->hFdCngCom->frameSize); + } +#endif +#else + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); +#endif + } + } + else + { + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); +#ifdef IVAS_FLOAT_FIXED +#if 1 + Word16 num_in_ch, num_bands_out, nchan_transport, num_md_sub_frames, ch, i, j, b, i_ts, num_out_ch; + SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; + if (st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT) + { + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes(st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate); + num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; + num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; + Word16 Q_C_re_fx = 31, Q_P_re_fx = 31; + hSpar->hMdDec->Q_mixer_mat = 31; + num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; + FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) + { + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = 0; j < num_in_ch; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + hSpar->hMdDec->Q_mixer_mat = s_min(hSpar->hMdDec->Q_mixer_mat, Q_factor_L(hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS])); + } + } + } + } + FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) + { + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = 0; j < nchan_transport; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + Q_C_re_fx = s_min(Q_C_re_fx, Q_factor_L(hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS])); + } + } + } + } + FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) + { + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = nchan_transport; j < num_out_ch; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + Q_P_re_fx = s_min(Q_P_re_fx, Q_factor_L(hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS])); + } + } + } + } + hSpar->hMdDec->Q_mixer_mat = s_min(hSpar->hMdDec->Q_mixer_mat, s_min(Q_C_re_fx, Q_P_re_fx)); + FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) + { + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = 0; j < num_in_ch; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed(hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat); + } + } + } + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = 0; j < nchan_transport; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed(hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat); + } + } + } + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = nchan_transport; j < num_out_ch; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed(hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat); + } + } + } + } + + + IF(hSpar->hMdDec->td_decorr_flag && !(EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC) || EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM))) + { + Word16 ch_sba_idx = 0; + IF(EQ_16(st_ivas->ivas_format, SBA_ISM_FORMAT)) + { + IF(EQ_16(st_ivas->ism_mode, ISM_SBA_MODE_DISC)) + { + ch_sba_idx = st_ivas->nchan_ism; move16(); + } + } + st_ivas->hTcBuffer->q_tc_fx = 14; + for (int i = 0; i < ivas_sba_get_nchan_metadata(st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate) + ch_sba_idx; i++) + { + floatToFixed_arrL(st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], st_ivas->hTcBuffer->q_tc_fx, min(nSamplesForRendering, (int16_t)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC))); + } + } + } + + if (st_ivas->hDiracDecBin != NULL && (st_ivas->hDiracDecBin->useTdDecorr)) + { + st_ivas->hTcBuffer->q_tc_fx = 14; + Word16 nSamplesLeftForTD, default_frame; + default_frame = (Word16)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC); + nSamplesLeftForTD = nSamplesForRendering; + Word16 size = 0; + + while (nSamplesLeftForTD) + { + Word16 nSamplesToDecorr = min(nSamplesLeftForTD, default_frame); + size += nSamplesToDecorr; + nSamplesLeftForTD -= nSamplesToDecorr; + } + size = s_max(size, default_frame); + for (int ch_idx = 0; ch_idx < BINAURAL_CHANNELS + 2; ch_idx++) + { + floatToFixed_arrL(st_ivas->hTcBuffer->tc[ch_idx], st_ivas->hTcBuffer->tc_fx[ch_idx], st_ivas->hTcBuffer->q_tc_fx, size); + } + } + nchan_transport = st_ivas->nchan_transport; + if (st_ivas->ivas_format == MASA_FORMAT && st_ivas->hDecoderConfig->ivas_total_brate < MASA_STEREO_MIN_BITRATE && (st_ivas->hDecoderConfig->ivas_total_brate > IVAS_SID_5k2 || (st_ivas->hDecoderConfig->ivas_total_brate <= IVAS_SID_5k2 && st_ivas->nCPE > 0 && st_ivas->hCPE[0]->nchan_out == 1))) + { + nchan_transport = 1; /* Only one channel transported */ + } + + if (((st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT) && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag) || + ((st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC) && (nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag))) + { + Word32 max_cngNoiseLevel = 0; + Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; + FOR(int i = 0; i < FFTCLDFBLEN; i++) + { + max_cngNoiseLevel = L_max(L_abs((Word32)st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[i]), max_cngNoiseLevel); + } + st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = norm_l(max_cngNoiseLevel); + + floatToFixed_arr(st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, Q13, M + 1); + + floatToFixed_arrL(st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN); + + for (int i = 0; i < FFTLEN; i++) + { + st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx[i] = float_to_fix(st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt[i], 15); + } + } +#endif + ivas_sba_dec_digest_tc_fx(st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available); +#if 1 + if (st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT) + { + FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) + { + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = 0; j < num_in_ch; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + st_ivas->hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = fixedToFloat(st_ivas->hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], st_ivas->hSpar->hMdDec->Q_mixer_mat); + } + } + } + } + + IF(hSpar->hMdDec->td_decorr_flag && !(EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC) || EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM))) + { + Word16 ch_sba_idx = 0; + IF(EQ_16(st_ivas->ivas_format, SBA_ISM_FORMAT)) + { + IF(EQ_16(st_ivas->ism_mode, ISM_SBA_MODE_DISC)) + { + ch_sba_idx = st_ivas->nchan_ism; move16(); + } + } + for (int i = 0; i < ivas_sba_get_nchan_metadata(st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate) + ch_sba_idx; i++) + { + fixedToFloat_arrL(st_ivas->hTcBuffer->tc_fx[i], st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->q_tc_fx, min(nSamplesForRendering, (int16_t)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC))); + } + } + } + + if (st_ivas->hDiracDecBin != NULL && (st_ivas->hDiracDecBin->useTdDecorr)) + { + st_ivas->hTcBuffer->q_tc_fx = 14; + int16_t nSamplesLeftForTD, default_frame; + default_frame = (int16_t)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC); + nSamplesLeftForTD = nSamplesForRendering; + Word16 size = 0; + + while (nSamplesLeftForTD) + { + int16_t nSamplesToDecorr = min(nSamplesLeftForTD, default_frame); + size += nSamplesToDecorr; + nSamplesLeftForTD -= nSamplesToDecorr; + } + size = s_max(size, default_frame); + for (int ch_idx = 0; ch_idx < BINAURAL_CHANNELS + 2; ch_idx++) + { + fixedToFloat_arrL(st_ivas->hTcBuffer->tc_fx[ch_idx], st_ivas->hTcBuffer->tc[ch_idx], st_ivas->hTcBuffer->q_tc_fx, size); + } + } + + if (((st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT) && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag) || + ((st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC) && (nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag))) + { + Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; + fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, 15, st->hFdCngDec->hFdCngCom->fftlen); + fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->fftBuffer, st->hFdCngDec->hFdCngCom->fftBuffer_flt, 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp, st->hFdCngDec->hFdCngCom->fftlen); + + fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->exc_cng_32fx, st->hFdCngDec->hFdCngCom->exc_cng_flt, 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp - 9, st->hFdCngDec->hFdCngCom->frameSize); + fixedToFloat_arrL(st_ivas->hTcBuffer->tc_fx[1], st_ivas->hTcBuffer->tc[1], 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp - 9, st->hFdCngDec->hFdCngCom->frameSize); + } +#endif +#else + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); +#endif + } + } + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); + } +#ifdef IVAS_FLOAT_FIXED +#if 1 + Word16 num_in_ch, num_bands_out, nchan_transport, num_md_sub_frames, ch, i, j, b, i_ts, num_out_ch; + SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; + if (st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT) + { + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes(st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate); + num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; + num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; + Word16 Q_C_re_fx = 31, Q_P_re_fx = 31; + hSpar->hMdDec->Q_mixer_mat = 31; + num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; + FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) + { + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = 0; j < num_in_ch; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + hSpar->hMdDec->Q_mixer_mat = s_min(hSpar->hMdDec->Q_mixer_mat, Q_factor_L(hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS])); + } + } + } + } + FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) + { + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = 0; j < nchan_transport; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + Q_C_re_fx = s_min(Q_C_re_fx, Q_factor_L(hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS])); + } + } + } + } + FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) + { + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = nchan_transport; j < num_out_ch; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + Q_P_re_fx = s_min(Q_P_re_fx, Q_factor_L(hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS])); + } + } + } + } + hSpar->hMdDec->Q_mixer_mat = s_min(hSpar->hMdDec->Q_mixer_mat, s_min(Q_C_re_fx, Q_P_re_fx)); + FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) + { + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = 0; j < num_in_ch; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed(hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat); + } + } + } + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = 0; j < nchan_transport; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed(hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat); + } + } + } + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = nchan_transport; j < num_out_ch; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed(hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat); + } + } + } + } + + + IF(hSpar->hMdDec->td_decorr_flag && !(EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC) || EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM))) + { + Word16 ch_sba_idx = 0; + IF(EQ_16(st_ivas->ivas_format, SBA_ISM_FORMAT)) + { + IF(EQ_16(st_ivas->ism_mode, ISM_SBA_MODE_DISC)) + { + ch_sba_idx = st_ivas->nchan_ism; move16(); + } + } + st_ivas->hTcBuffer->q_tc_fx = 14; + for (int i = 0; i < ivas_sba_get_nchan_metadata(st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate) + ch_sba_idx; i++) + { + floatToFixed_arrL(st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], st_ivas->hTcBuffer->q_tc_fx, min(nSamplesForRendering, (int16_t)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC))); + } + } + } + + if (st_ivas->hDiracDecBin != NULL && (st_ivas->hDiracDecBin->useTdDecorr)) + { + st_ivas->hTcBuffer->q_tc_fx = 14; + Word16 nSamplesLeftForTD, default_frame; + default_frame = (Word16)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC); + nSamplesLeftForTD = nSamplesForRendering; + Word16 size = 0; + + while (nSamplesLeftForTD) + { + Word16 nSamplesToDecorr = min(nSamplesLeftForTD, default_frame); + size += nSamplesToDecorr; + nSamplesLeftForTD -= nSamplesToDecorr; + } + size = s_max(size, default_frame); + for (int ch_idx = 0; ch_idx < BINAURAL_CHANNELS + 2; ch_idx++) + { + floatToFixed_arrL(st_ivas->hTcBuffer->tc[ch_idx], st_ivas->hTcBuffer->tc_fx[ch_idx], st_ivas->hTcBuffer->q_tc_fx, size); + } + } + nchan_transport = st_ivas->nchan_transport; + if (st_ivas->ivas_format == MASA_FORMAT && st_ivas->hDecoderConfig->ivas_total_brate < MASA_STEREO_MIN_BITRATE && (st_ivas->hDecoderConfig->ivas_total_brate > IVAS_SID_5k2 || (st_ivas->hDecoderConfig->ivas_total_brate <= IVAS_SID_5k2 && st_ivas->nCPE > 0 && st_ivas->hCPE[0]->nchan_out == 1))) + { + nchan_transport = 1; /* Only one channel transported */ + } + + if (((st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT) && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag) || + ((st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC) && (nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag))) + { + Word32 max_cngNoiseLevel = 0; + Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; + FOR(int i = 0; i < FFTCLDFBLEN; i++) + { + max_cngNoiseLevel = L_max(L_abs((Word32)st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[i]), max_cngNoiseLevel); + } + st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = norm_l(max_cngNoiseLevel); + + floatToFixed_arr(st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, Q13, M + 1); + + floatToFixed_arrL(st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN); + + for (int i = 0; i < FFTLEN; i++) + { + st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx[i] = float_to_fix(st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt[i], 15); + } + } +#endif + ivas_sba_dec_digest_tc_fx(st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available); +#if 1 + if (st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT) + { + FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) + { + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = 0; j < num_in_ch; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + st_ivas->hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = fixedToFloat(st_ivas->hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], st_ivas->hSpar->hMdDec->Q_mixer_mat); + } + } + } + } + + IF(hSpar->hMdDec->td_decorr_flag && !(EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC) || EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM))) + { + Word16 ch_sba_idx = 0; + IF(EQ_16(st_ivas->ivas_format, SBA_ISM_FORMAT)) + { + IF(EQ_16(st_ivas->ism_mode, ISM_SBA_MODE_DISC)) + { + ch_sba_idx = st_ivas->nchan_ism; move16(); + } + } + for (int i = 0; i < ivas_sba_get_nchan_metadata(st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate) + ch_sba_idx; i++) + { + fixedToFloat_arrL(st_ivas->hTcBuffer->tc_fx[i], st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->q_tc_fx, min(nSamplesForRendering, (int16_t)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC))); + } + } + } + + if (st_ivas->hDiracDecBin != NULL && (st_ivas->hDiracDecBin->useTdDecorr)) + { + st_ivas->hTcBuffer->q_tc_fx = 14; + int16_t nSamplesLeftForTD, default_frame; + default_frame = (int16_t)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC); + nSamplesLeftForTD = nSamplesForRendering; + Word16 size = 0; + + while (nSamplesLeftForTD) + { + int16_t nSamplesToDecorr = min(nSamplesLeftForTD, default_frame); + size += nSamplesToDecorr; + nSamplesLeftForTD -= nSamplesToDecorr; + } + size = s_max(size, default_frame); + for (int ch_idx = 0; ch_idx < BINAURAL_CHANNELS + 2; ch_idx++) + { + fixedToFloat_arrL(st_ivas->hTcBuffer->tc_fx[ch_idx], st_ivas->hTcBuffer->tc[ch_idx], st_ivas->hTcBuffer->q_tc_fx, size); + } + } + + if (((st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT) && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag) || + ((st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC) && (nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag))) + { + Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; + fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, 15, st->hFdCngDec->hFdCngCom->fftlen); + fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->fftBuffer, st->hFdCngDec->hFdCngCom->fftBuffer_flt, 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp, st->hFdCngDec->hFdCngCom->fftlen); + + fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->exc_cng_32fx, st->hFdCngDec->hFdCngCom->exc_cng_flt, 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp - 9, st->hFdCngDec->hFdCngCom->frameSize); + fixedToFloat_arrL(st_ivas->hTcBuffer->tc_fx[1], st_ivas->hTcBuffer->tc[1], 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp - 9, st->hFdCngDec->hFdCngCom->frameSize); + } +#endif +#else + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); +#endif + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { +#ifdef IVAS_FLOAT_FIXED + ivas_ism_dec_digest_tc_fx(st_ivas); +#else + ivas_ism_dec_digest_tc(st_ivas); +#endif + } + } + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + if ( st_ivas->mc_mode == MC_MODE_MCT ) + { + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + } + else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + { ivas_mc_paramupmix_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) @@ -6111,7 +6520,229 @@ void ivas_jbm_dec_feed_tc_to_renderer( } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { +#ifdef IVAS_FLOAT_FIXED +#if 1 + Word16 num_in_ch, num_bands_out, nchan_transport, num_md_sub_frames, ch, i, j, b, i_ts, num_out_ch; + SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; + if (st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT) + { + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes(st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate); + num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; + num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; + Word16 Q_C_re_fx = 31, Q_P_re_fx = 31; + hSpar->hMdDec->Q_mixer_mat = 31; + num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; + FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) + { + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = 0; j < num_in_ch; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + hSpar->hMdDec->Q_mixer_mat = s_min(hSpar->hMdDec->Q_mixer_mat, Q_factor_L(hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS])); + } + } + } + } + FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) + { + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = 0; j < nchan_transport; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + Q_C_re_fx = s_min(Q_C_re_fx, Q_factor_L(hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS])); + } + } + } + } + FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) + { + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = nchan_transport; j < num_out_ch; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + Q_P_re_fx = s_min(Q_P_re_fx, Q_factor_L(hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS])); + } + } + } + } + hSpar->hMdDec->Q_mixer_mat = s_min(hSpar->hMdDec->Q_mixer_mat, s_min(Q_C_re_fx, Q_P_re_fx)); + FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) + { + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = 0; j < num_in_ch; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed(hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat); + } + } + } + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = 0; j < nchan_transport; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed(hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat); + } + } + } + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = nchan_transport; j < num_out_ch; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed(hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat); + } + } + } + } + + + IF(hSpar->hMdDec->td_decorr_flag && !(EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC) || EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM))) + { + Word16 ch_sba_idx = 0; + IF(EQ_16(st_ivas->ivas_format, SBA_ISM_FORMAT)) + { + IF(EQ_16(st_ivas->ism_mode, ISM_SBA_MODE_DISC)) + { + ch_sba_idx = st_ivas->nchan_ism; move16(); + } + } + st_ivas->hTcBuffer->q_tc_fx = 14; + for (int i = 0; i < ivas_sba_get_nchan_metadata(st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate) + ch_sba_idx; i++) + { + floatToFixed_arrL(st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], st_ivas->hTcBuffer->q_tc_fx, min(nSamplesForRendering, (int16_t)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC))); + } + } + } + + if (st_ivas->hDiracDecBin != NULL && (st_ivas->hDiracDecBin->useTdDecorr)) + { + st_ivas->hTcBuffer->q_tc_fx = 14; + Word16 nSamplesLeftForTD, default_frame; + default_frame = (Word16)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC); + nSamplesLeftForTD = nSamplesForRendering; + Word16 size = 0; + + while (nSamplesLeftForTD) + { + Word16 nSamplesToDecorr = min(nSamplesLeftForTD, default_frame); + size += nSamplesToDecorr; + nSamplesLeftForTD -= nSamplesToDecorr; + } + size = s_max(size, default_frame); + for (int ch_idx = 0; ch_idx < BINAURAL_CHANNELS + 2; ch_idx++) + { + floatToFixed_arrL(st_ivas->hTcBuffer->tc[ch_idx], st_ivas->hTcBuffer->tc_fx[ch_idx], st_ivas->hTcBuffer->q_tc_fx, size); + } + } + nchan_transport = st_ivas->nchan_transport; + if (st_ivas->ivas_format == MASA_FORMAT && st_ivas->hDecoderConfig->ivas_total_brate < MASA_STEREO_MIN_BITRATE && (st_ivas->hDecoderConfig->ivas_total_brate > IVAS_SID_5k2 || (st_ivas->hDecoderConfig->ivas_total_brate <= IVAS_SID_5k2 && st_ivas->nCPE > 0 && st_ivas->hCPE[0]->nchan_out == 1))) + { + nchan_transport = 1; /* Only one channel transported */ + } + + if (((st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT) && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag) || + ((st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC) && (nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag))) + { + Word32 max_cngNoiseLevel = 0; + Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; + FOR(int i = 0; i < FFTCLDFBLEN; i++) + { + max_cngNoiseLevel = L_max(L_abs((Word32)st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[i]), max_cngNoiseLevel); + } + st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = norm_l(max_cngNoiseLevel); + + floatToFixed_arr(st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, Q13, M + 1); + + floatToFixed_arrL(st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN); + + for (int i = 0; i < FFTLEN; i++) + { + st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx[i] = float_to_fix(st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt[i], 15); + } + } +#endif + ivas_sba_dec_digest_tc_fx(st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available); +#if 1 + if (st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT) + { + FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) + { + FOR(i = 0; i < num_out_ch; i++) + { + FOR(j = 0; j < num_in_ch; j++) + { + FOR(b = 0; b < num_bands_out; b++) + { + st_ivas->hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = fixedToFloat(st_ivas->hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], st_ivas->hSpar->hMdDec->Q_mixer_mat); + } + } + } + } + + IF(hSpar->hMdDec->td_decorr_flag && !(EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC) || EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM))) + { + Word16 ch_sba_idx = 0; + IF(EQ_16(st_ivas->ivas_format, SBA_ISM_FORMAT)) + { + IF(EQ_16(st_ivas->ism_mode, ISM_SBA_MODE_DISC)) + { + ch_sba_idx = st_ivas->nchan_ism; move16(); + } + } + for (int i = 0; i < ivas_sba_get_nchan_metadata(st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate) + ch_sba_idx; i++) + { + fixedToFloat_arrL(st_ivas->hTcBuffer->tc_fx[i], st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->q_tc_fx, min(nSamplesForRendering, (int16_t)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC))); + } + } + } + + if (st_ivas->hDiracDecBin != NULL && (st_ivas->hDiracDecBin->useTdDecorr)) + { + st_ivas->hTcBuffer->q_tc_fx = 14; + int16_t nSamplesLeftForTD, default_frame; + default_frame = (int16_t)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC); + nSamplesLeftForTD = nSamplesForRendering; + Word16 size = 0; + + while (nSamplesLeftForTD) + { + int16_t nSamplesToDecorr = min(nSamplesLeftForTD, default_frame); + size += nSamplesToDecorr; + nSamplesLeftForTD -= nSamplesToDecorr; + } + size = s_max(size, default_frame); + for (int ch_idx = 0; ch_idx < BINAURAL_CHANNELS + 2; ch_idx++) + { + fixedToFloat_arrL(st_ivas->hTcBuffer->tc_fx[ch_idx], st_ivas->hTcBuffer->tc[ch_idx], st_ivas->hTcBuffer->q_tc_fx, size); + } + } + + if (((st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT) && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag) || + ((st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC) && (nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag))) + { + Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; + fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, 15, st->hFdCngDec->hFdCngCom->fftlen); + fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->fftBuffer, st->hFdCngDec->hFdCngCom->fftBuffer_flt, 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp, st->hFdCngDec->hFdCngCom->fftlen); + + fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->exc_cng_32fx, st->hFdCngDec->hFdCngCom->exc_cng_flt, 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp - 9, st->hFdCngDec->hFdCngCom->frameSize); + fixedToFloat_arrL(st_ivas->hTcBuffer->tc_fx[1], st_ivas->hTcBuffer->tc[1], 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp - 9, st->hFdCngDec->hFdCngCom->frameSize); + } +#endif +#else ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); +#endif } } @@ -6242,7 +6873,6 @@ ivas_error ivas_jbm_dec_render( nSamplesRendered_tmp = (UWord16) L_mult0( slots_to_render, slot_size ); FOR(Word16 ind = 0; ind < st_ivas->hTcBuffer->nchan_transport_jbm; ind++) { floatToFixed_arrL(st_ivas->hTcBuffer->tc[ind] + st_ivas->hTcBuffer->n_samples_rendered, st_ivas->hTcBuffer->tc_fx[ind] + st_ivas->hTcBuffer->n_samples_rendered, Q11, nSamplesRendered_tmp); - p_output_fx[ind] = malloc(sizeof(Word32) * 960); floatToFixed_arrL(p_output[ind], p_output_fx[ind], Q11, s_max(*nSamplesRendered, nSamplesAskedLocal)); } @@ -6250,7 +6880,6 @@ ivas_error ivas_jbm_dec_render( FOR(Word16 ind = 0; ind < st_ivas->hTcBuffer->nchan_transport_jbm; ind++) { fixedToFloat_arrL(p_output_fx[ind], p_output[ind], Q11, s_max(*nSamplesRendered, nSamplesAskedLocal)); - free(p_output_fx[ind]); } #else ivas_jbm_dec_tc_buffer_playout( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output ); @@ -6264,17 +6893,11 @@ ivas_error ivas_jbm_dec_render( *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); #ifdef IVAS_FLOAT_FIXED Word16 q = Q16; - Word32 *p_tc_fx[16]; q = q - find_guarded_bits_fx( st_ivas->nchan_transport ); FOR( i = 0; i < st_ivas->nchan_transport; ++i ) { - p_tc_fx[i] = malloc( L_FRAME48k * sizeof( Word32 ) ); floatToFixed_arrL( p_tc[i], p_tc_fx[i], q, *nSamplesRendered ); } - FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; ++i ) - { - p_output_fx[i] = malloc( L_FRAME48k * sizeof( Word32 ) ); - } FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) { FOR( j = 0; j < st_ivas->nchan_transport; j++ ) @@ -6286,11 +6909,6 @@ ivas_error ivas_jbm_dec_render( FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; ++i ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], q, *nSamplesRendered ); - free( p_output_fx[i] ); - } - FOR( i = 0; i < st_ivas->nchan_transport; ++i ) - { - free( p_tc_fx[i] ); } #else ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc, p_output ); @@ -6310,23 +6928,18 @@ ivas_error ivas_jbm_dec_render( { *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); #ifdef IVAS_FLOAT_FIXED - Word32 *output_fx[2]; - output_fx[0] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); - output_fx[1] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); for ( int lp = 0; lp < L_FRAME48k; lp++ ) { - output_fx[0][lp] = (Word32) ( p_output[0][lp] * ( 1u << 11 ) ); - output_fx[1][lp] = (Word32) ( p_output[1][lp] * ( 1u << 11 ) ); + p_output_fx[0][lp] = (Word32) ( p_output[0][lp] * ( 1u << 11 ) ); + p_output_fx[1][lp] = (Word32) ( p_output[1][lp] * ( 1u << 11 ) ); } Word16 non_diegetic_pan_gain_fx = (Word16) ( 32767 * st_ivas->hDecoderConfig->non_diegetic_pan_gain ); - ivas_apply_non_diegetic_panning_fx( output_fx, non_diegetic_pan_gain_fx, *nSamplesRendered ); + ivas_apply_non_diegetic_panning_fx( p_output_fx, non_diegetic_pan_gain_fx, *nSamplesRendered ); for ( int lp = 0; lp < L_FRAME48k; lp++ ) { - p_output[0][lp] = (float) output_fx[0][lp] / ( 1u << 11 ); - p_output[1][lp] = (float) output_fx[1][lp] / ( 1u << 11 ); + p_output[0][lp] = (float) p_output_fx[0][lp] / ( 1u << 11 ); + p_output[1][lp] = (float) p_output_fx[1][lp] / ( 1u << 11 ); } - free( output_fx[0] ); - free( output_fx[1] ); #else ivas_apply_non_diegetic_panning( p_output, st_ivas->hDecoderConfig->non_diegetic_pan_gain, *nSamplesRendered ); #endif @@ -6410,15 +7023,7 @@ ivas_error ivas_jbm_dec_render( /* Convert CICP19 -> Ambisonics */ #ifdef IVAS_FLOAT_FIXED #if 1 - Word32 *p_output_fx[20]; - FOR( Word16 lp = 0; lp < 20; lp++ ) - { - IF( p_output[lp] != NULL ) - { - p_output_fx[lp] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); - } - } - Word16 Q_in_buffer_td = 31, i; + Word16 Q_in_buffer_td = 31; FOR( i = 0; i < st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; i++ ) { Q_in_buffer_td = s_min( Q_in_buffer_td, Q_factor_arrL( p_output[i], *nSamplesRendered ) ); @@ -6434,13 +7039,6 @@ ivas_error ivas_jbm_dec_render( { fixedToFloat_arrL( p_output_fx[i], p_output[i], Q_in_buffer_td - 3, *nSamplesRendered ); } - FOR( Word16 lp = 0; lp < 20; lp++ ) - { - IF( p_output[lp] != NULL ) - { - free( p_output_fx[lp] ); - } - } #endif #else ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0.f ); @@ -6504,23 +7102,18 @@ ivas_error ivas_jbm_dec_render( else if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) { #ifdef IVAS_FLOAT_FIXED - Word32 *output_fx[2]; - output_fx[0] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); - output_fx[1] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); for ( int lp = 0; lp < L_FRAME48k; lp++ ) { - output_fx[0][lp] = (Word32) ( p_output[0][lp] * ( 1u << 11 ) ); - output_fx[1][lp] = (Word32) ( p_output[1][lp] * ( 1u << 11 ) ); + p_output_fx[0][lp] = (Word32) ( p_output[0][lp] * ( 1u << 11 ) ); + p_output_fx[1][lp] = (Word32) ( p_output[1][lp] * ( 1u << 11 ) ); } Word16 non_diegetic_pan_gain_fx = (Word16) ( 32767 * st_ivas->hDecoderConfig->non_diegetic_pan_gain ); - ivas_apply_non_diegetic_panning_fx( output_fx, non_diegetic_pan_gain_fx, *nSamplesRendered ); + ivas_apply_non_diegetic_panning_fx( p_output_fx, non_diegetic_pan_gain_fx, *nSamplesRendered ); for ( int lp = 0; lp < L_FRAME48k; lp++ ) { - p_output[0][lp] = (float) output_fx[0][lp] / ( 1u << 11 ); - p_output[1][lp] = (float) output_fx[1][lp] / ( 1u << 11 ); + p_output[0][lp] = (float) p_output_fx[0][lp] / ( 1u << 11 ); + p_output[1][lp] = (float) p_output_fx[1][lp] / ( 1u << 11 ); } - free( output_fx[0] ); - free( output_fx[1] ); #else ivas_apply_non_diegetic_panning( p_output, st_ivas->hDecoderConfig->non_diegetic_pan_gain, *nSamplesRendered ); #endif @@ -6537,14 +7130,6 @@ ivas_error ivas_jbm_dec_render( st_ivas->hIsmRendererData->prev_gains_fx[i][j] = L_shr( st_ivas->hIsmRendererData->prev_gains_fx[i][j], 1 ); // Q30 -> Q29 } } - Word32 *p_output_fx[20]; - FOR( Word16 lp = 0; lp < 20; lp++ ) - { - IF( p_output[lp] != NULL ) - { - p_output_fx[lp] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); - } - } Word16 Q_buffer_in = 31; FOR( i = 0; i < st_ivas->nchan_transport; i++ ) { @@ -6560,13 +7145,6 @@ ivas_error ivas_jbm_dec_render( { fixedToFloat_arrL( p_output_fx[j], p_output[j], Q_buffer_in + 29 - 31, *nSamplesRendered ); } - FOR( Word16 lp = 0; lp < 20; lp++ ) - { - IF( p_output[lp] != NULL ) - { - free( p_output_fx[lp] ); - } - } FOR(i = 0; i < 15; i++) { @@ -6585,10 +7163,9 @@ ivas_error ivas_jbm_dec_render( if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { #ifdef IVAS_FLOAT_FIXED - Word16 output_q_factor = Q11; - for (int i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++) + for ( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++) { - for (int j = 0; j < L_FRAME48k; j++) + for ( j = 0; j < L_FRAME48k; j++) { p_output_fx[i][j] = floatToFixed(p_output[i][j], Q11); } @@ -6603,9 +7180,9 @@ ivas_error ivas_jbm_dec_render( } // Fixed to float - for (int i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++) + for ( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++) { - for (int j = 0; j < L_FRAME48k; j++) + for ( j = 0; j < L_FRAME48k; j++) { p_output[i][j] = fixedToFloat(p_output_fx[i][j], Q11); } @@ -6706,14 +7283,14 @@ ivas_error ivas_jbm_dec_render( Word16 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 ); - for ( int i = 0; i < s_max( st_ivas->nchan_ism, 0 ) + nchan_internal; i++ ) + for ( i = 0; i < s_max( st_ivas->nchan_ism, 0 ) + nchan_internal; i++ ) { floatToFixed_arr32( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], Q11, st_ivas->hTcBuffer->n_samples_available ); } Word16 q1 = 30, q2 = 30; for ( int l = 0; l < numch_out; l++ ) { - for ( int j = 0; j < numch_in; j++ ) + for ( j = 0; j < numch_in; j++ ) { for ( int k = 0; k < num_md_sub_frames * IVAS_MAX_NUM_BANDS; k++ ) { @@ -6723,7 +7300,7 @@ ivas_error ivas_jbm_dec_render( } for ( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) { - for ( int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) + for ( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) { for ( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) { @@ -6736,14 +7313,14 @@ ivas_error ivas_jbm_dec_render( } 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++ ) + for ( 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++ ) + for ( 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 ); } @@ -6753,7 +7330,7 @@ ivas_error ivas_jbm_dec_render( { IF( st_ivas->cldfbSynDec[out_ch] ) { - FOR( Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++ ) + FOR( 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); } @@ -6771,14 +7348,14 @@ ivas_error ivas_jbm_dec_render( } 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++ ) + FOR( 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 ) ) ); /*Rounding off*/ } } FOR( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) { - FOR( int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) + FOR( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) { FOR( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) { @@ -6793,7 +7370,7 @@ ivas_error ivas_jbm_dec_render( 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++ ) + FOR( 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 ); } @@ -6803,7 +7380,7 @@ ivas_error ivas_jbm_dec_render( { IF( st_ivas->cldfbSynDec[out_ch] ) { - FOR( Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++ ) + FOR( 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 ) ) ); } @@ -6868,14 +7445,14 @@ ivas_error ivas_jbm_dec_render( Word16 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 ); - for ( int i = 0; i < s_max( st_ivas->nchan_ism, 0 ) + nchan_internal; i++ ) + for ( i = 0; i < s_max( st_ivas->nchan_ism, 0 ) + nchan_internal; i++ ) { floatToFixed_arr32( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], Q11, st_ivas->hTcBuffer->n_samples_available ); } Word16 q1 = 30, q2 = 30; for ( int l = 0; l < numch_out; l++ ) { - for ( int j = 0; j < numch_in; j++ ) + for ( j = 0; j < numch_in; j++ ) { for ( int k = 0; k < num_md_sub_frames * IVAS_MAX_NUM_BANDS; k++ ) { @@ -6885,7 +7462,7 @@ ivas_error ivas_jbm_dec_render( } for ( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) { - for ( int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) + for ( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) { for ( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) { @@ -6898,14 +7475,14 @@ ivas_error ivas_jbm_dec_render( } 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++ ) + for ( 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++ ) + for ( 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 ); } @@ -6915,7 +7492,7 @@ ivas_error ivas_jbm_dec_render( { IF( st_ivas->cldfbSynDec[out_ch] ) { - FOR( Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++ ) + FOR( 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 ); } @@ -6947,14 +7524,14 @@ ivas_error ivas_jbm_dec_render( } 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++ ) + FOR( 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 ) ) ); } } - FOR( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) + FOR(Word16 m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) { - FOR( int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) + FOR( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) { FOR( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) { @@ -6969,7 +7546,7 @@ ivas_error ivas_jbm_dec_render( 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++ ) + FOR( 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 ); } @@ -6979,7 +7556,7 @@ ivas_error ivas_jbm_dec_render( { IF( st_ivas->cldfbSynDec[out_ch] ) { - FOR( Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++ ) + FOR( 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 ) ) ); } @@ -6988,9 +7565,9 @@ ivas_error ivas_jbm_dec_render( #endif #if 1 /*TODO: remove fixed to float conversions */ - for (int i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++) + for ( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++) { - for (int j = 0; j < L_FRAME48k; j++) + for ( j = 0; j < L_FRAME48k; j++) { p_output[i][j] = fixedToFloat(p_output_fx[i][j], Q11); } @@ -7097,14 +7674,14 @@ ivas_error ivas_jbm_dec_render( Word16 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 ); - for ( int i = 0; i < s_max( st_ivas->nchan_ism, 0 ) + nchan_internal; i++ ) + for ( i = 0; i < s_max( st_ivas->nchan_ism, 0 ) + nchan_internal; i++ ) { floatToFixed_arr32( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], Q11, st_ivas->hTcBuffer->n_samples_available ); } Word16 q1 = 30, q2 = 30; for ( int l = 0; l < numch_out; l++ ) { - for ( int j = 0; j < numch_in; j++ ) + for ( j = 0; j < numch_in; j++ ) { for ( int k = 0; k < num_md_sub_frames * IVAS_MAX_NUM_BANDS; k++ ) { @@ -7114,7 +7691,7 @@ ivas_error ivas_jbm_dec_render( } for ( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) { - for ( int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) + for ( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) { for ( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) { @@ -7127,14 +7704,14 @@ ivas_error ivas_jbm_dec_render( } 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++ ) + for ( 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++ ) + for ( 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 ); } @@ -7144,7 +7721,7 @@ ivas_error ivas_jbm_dec_render( { IF( st_ivas->cldfbSynDec[out_ch] ) { - FOR( Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++ ) + FOR( 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 ); } @@ -7162,14 +7739,14 @@ ivas_error ivas_jbm_dec_render( } 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++ ) + FOR( 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 ) ) ); } } FOR( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) { - FOR( int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) + FOR( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) { FOR( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) { @@ -7184,7 +7761,7 @@ ivas_error ivas_jbm_dec_render( 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++ ) + FOR( 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 ); } @@ -7194,7 +7771,7 @@ ivas_error ivas_jbm_dec_render( { IF( st_ivas->cldfbSynDec[out_ch] ) { - FOR( Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++ ) + FOR( 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 ) ) ); } @@ -7233,14 +7810,14 @@ ivas_error ivas_jbm_dec_render( Word16 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 ); - for ( int i = 0; i < s_max( st_ivas->nchan_ism, 0 ) + nchan_internal; i++ ) + for ( i = 0; i < s_max( st_ivas->nchan_ism, 0 ) + nchan_internal; i++ ) { floatToFixed_arr32( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], Q11, st_ivas->hTcBuffer->n_samples_available ); } Word16 q1 = 30, q2 = 30; for ( int l = 0; l < numch_out; l++ ) { - for ( int j = 0; j < numch_in; j++ ) + for ( j = 0; j < numch_in; j++ ) { for ( int k = 0; k < num_md_sub_frames * IVAS_MAX_NUM_BANDS; k++ ) { @@ -7250,7 +7827,7 @@ ivas_error ivas_jbm_dec_render( } for ( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) { - for ( int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) + for ( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) { for ( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) { @@ -7263,14 +7840,14 @@ ivas_error ivas_jbm_dec_render( } 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++ ) + for ( 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++ ) + for ( 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 ); } @@ -7280,7 +7857,7 @@ ivas_error ivas_jbm_dec_render( { IF( st_ivas->cldfbSynDec[out_ch] ) { - FOR( Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++ ) + FOR( 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 ); } @@ -7298,14 +7875,14 @@ ivas_error ivas_jbm_dec_render( } 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++ ) + FOR( 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 ) ) ); /*Rounding off*/ } } FOR( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) { - FOR( int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) + FOR( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) { FOR( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) { @@ -7320,7 +7897,7 @@ ivas_error ivas_jbm_dec_render( 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++ ) + FOR( 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 ); } @@ -7330,7 +7907,7 @@ ivas_error ivas_jbm_dec_render( { IF( st_ivas->cldfbSynDec[out_ch] ) { - FOR( Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++ ) + FOR( 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 ) ) ); } @@ -7369,14 +7946,14 @@ ivas_error ivas_jbm_dec_render( Word16 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 ); - for ( int i = 0; i < s_max( st_ivas->nchan_ism, 0 ) + nchan_internal; i++ ) + for ( i = 0; i < s_max( st_ivas->nchan_ism, 0 ) + nchan_internal; i++ ) { floatToFixed_arr32( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], Q11, st_ivas->hTcBuffer->n_samples_available ); } Word16 q1 = 30, q2 = 30; for ( int l = 0; l < numch_out; l++ ) { - for ( int j = 0; j < numch_in; j++ ) + for ( j = 0; j < numch_in; j++ ) { for ( int k = 0; k < num_md_sub_frames * IVAS_MAX_NUM_BANDS; k++ ) { @@ -7384,9 +7961,9 @@ ivas_error ivas_jbm_dec_render( } } } - for ( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) + for (Word16 m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) { - for ( int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) + for ( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) { for ( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) { @@ -7399,14 +7976,14 @@ ivas_error ivas_jbm_dec_render( } 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++ ) + for ( 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++ ) + for ( 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 ); } @@ -7416,7 +7993,7 @@ ivas_error ivas_jbm_dec_render( { IF( st_ivas->cldfbSynDec[out_ch] ) { - FOR( Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++ ) + FOR( 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); } @@ -7434,14 +8011,14 @@ ivas_error ivas_jbm_dec_render( } 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++ ) + FOR( 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 ) ) ); /*Rounding off*/ } } - FOR( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) + FOR(Word16 m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) { - FOR( int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) + FOR( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) { FOR( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) { @@ -7455,7 +8032,7 @@ ivas_error ivas_jbm_dec_render( 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++ ) + FOR( 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 ); } @@ -7464,7 +8041,7 @@ ivas_error ivas_jbm_dec_render( { IF( st_ivas->cldfbSynDec[out_ch] ) { - FOR( Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++ ) + FOR( 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 ) ) ); } @@ -7566,17 +8143,11 @@ ivas_error ivas_jbm_dec_render( *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); #ifdef IVAS_FLOAT_FIXED Word16 q = Q16; - Word32 *p_tc_fx[16]; q = q - find_guarded_bits_fx( st_ivas->nchan_transport ); FOR( i = 0; i < st_ivas->nchan_transport; ++i ) { - p_tc_fx[i] = malloc( L_FRAME48k * sizeof( Word32 ) ); floatToFixed_arrL( p_tc[i], p_tc_fx[i], q, *nSamplesRendered ); } - FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; ++i ) - { - p_output_fx[i] = malloc( L_FRAME48k * sizeof( Word32 ) ); - } FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) { FOR( j = 0; j < st_ivas->nchan_transport; j++ ) @@ -7588,11 +8159,6 @@ ivas_error ivas_jbm_dec_render( FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; ++i ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], q, *nSamplesRendered ); - free( p_output_fx[i] ); - } - FOR( i = 0; i < st_ivas->nchan_transport; ++i ) - { - free( p_tc_fx[i] ); } #else ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc, p_output ); @@ -7606,10 +8172,9 @@ ivas_error ivas_jbm_dec_render( { #ifdef IVAS_FLOAT_FIXED #if 1 /* TODO: remove float to fix conversions: */ - Word16 output_q_factor = Q11; - for (int i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++) + for ( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++) { - for (int j = 0; j < L_FRAME48k; j++) + for ( j = 0; j < L_FRAME48k; j++) { p_output_fx[i][j] = floatToFixed(p_output[i][j], output_q_factor); } @@ -7625,9 +8190,9 @@ ivas_error ivas_jbm_dec_render( } #if 1 /* TODO: remove Fixed to float */ - for (int i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++) + for ( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++) { - for (int j = 0; j < L_FRAME48k; j++) + for ( j = 0; j < L_FRAME48k; j++) { p_output[i][j] = fixedToFloat(p_output_fx[i][j], Q11); } @@ -7646,9 +8211,7 @@ ivas_error ivas_jbm_dec_render( FOR(i = 0; i < st_ivas->nchan_transport; ++i) { //p_tc and pout point to same location - p_tc_fx[i] = malloc(L_FRAME48k * sizeof(Word32)); floatToFixed_arrL(p_tc[i], p_tc_fx[i], q, *nSamplesRendered); - p_output_fx[i] = malloc(L_FRAME48k * sizeof(Word32)); floatToFixed_arrL(p_output[i], p_output_fx[i], q, *nSamplesRendered); } @@ -7658,9 +8221,7 @@ ivas_error ivas_jbm_dec_render( { //p_tc and pout point to same location fixedToFloat_arrL(p_tc_fx[i], p_tc[i], q, *nSamplesRendered); - free(p_tc_fx[i]); fixedToFloat_arrL(p_output_fx[i], p_output[i], q, *nSamplesRendered); - free(p_output_fx[i]); } #else ivas_binaural_add_LFE(st_ivas, *nSamplesRendered, p_tc, p_output); @@ -7682,7 +8243,6 @@ ivas_error ivas_jbm_dec_render( q = q - find_guarded_bits_fx(*nSamplesRendered); FOR(i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, MC_PARAMUPMIX_MAX_INPUT_CHANS); ++i) { - p_output_fx[i] = malloc(L_FRAME48k * sizeof(Word32)); floatToFixed_arrL(p_output[i], p_output_fx[i], q, *nSamplesRendered); } @@ -7691,7 +8251,6 @@ ivas_error ivas_jbm_dec_render( FOR(i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, MC_PARAMUPMIX_MAX_INPUT_CHANS); ++i) { fixedToFloat_arrL(p_output_fx[i], p_output[i], q, *nSamplesRendered); - free(p_output_fx[i]); } #else ivas_binaural_add_LFE(st_ivas, *nSamplesRendered, p_output, p_output); @@ -7705,7 +8264,6 @@ ivas_error ivas_jbm_dec_render( q = q - find_guarded_bits_fx( MC_PARAMUPMIX_MAX_INPUT_CHANS ); FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, MC_PARAMUPMIX_MAX_INPUT_CHANS ); ++i ) { - p_output_fx[i] = malloc( L_FRAME48k * sizeof( Word32 ) ); floatToFixed_arrL( p_output[i], p_output_fx[i], q, *nSamplesRendered ); } FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) @@ -7719,7 +8277,6 @@ ivas_error ivas_jbm_dec_render( FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, MC_PARAMUPMIX_MAX_INPUT_CHANS ); ++i ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], q, *nSamplesRendered ); - free( p_output_fx[i] ); } #else ivas_ls_setup_conversion( st_ivas, MC_PARAMUPMIX_MAX_INPUT_CHANS, *nSamplesRendered, p_output, p_output ); @@ -7741,7 +8298,6 @@ ivas_error ivas_jbm_dec_render( q = q - find_guarded_bits_fx(*nSamplesRendered); FOR(i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, MC_PARAMUPMIX_MAX_INPUT_CHANS); ++i) { - p_output_fx[i] = malloc(L_FRAME48k * sizeof(Word32)); floatToFixed_arrL(p_output[i], p_output_fx[i], q, *nSamplesRendered); } @@ -7750,7 +8306,6 @@ ivas_error ivas_jbm_dec_render( FOR(i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, MC_PARAMUPMIX_MAX_INPUT_CHANS); ++i) { fixedToFloat_arrL(p_output_fx[i], p_output[i], q, *nSamplesRendered); - free(p_output_fx[i]); } #else ivas_binaural_add_LFE(st_ivas, *nSamplesRendered, p_output, p_output); @@ -7874,15 +8429,13 @@ ivas_error ivas_jbm_dec_render( } #ifdef IVAS_FLOAT_FIXED Word16 q_p_output = Q11; - FOR(Word16 i = 0; i < nchan_out; i++) { - p_output_fx[i] = malloc(sizeof(Word32) * (*nSamplesRendered)); + FOR( i = 0; i < nchan_out; i++) { floatToFixed_arrL(p_output[i], p_output_fx[i], q_p_output, *nSamplesRendered); } ivas_syn_output_fx( p_output_fx, q_p_output, *nSamplesRendered, nchan_out, data ); - FOR(Word16 i = 0; i < nchan_out; i++) { - free(p_output_fx[i]); + FOR( i = 0; i < nchan_out; i++) { } #else @@ -8061,7 +8614,6 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( { Word32 *tc_local_fx[MAX_TRANSPORT_CHANNELS]; - Word16 q = Q11; move16(); FOR ( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ ) { diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index faec090b7..f6728e20a 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -2586,11 +2586,13 @@ static ivas_error ivas_mc_dec_reconfig( #ifdef IVAS_FLOAT_FIXED init_igf_dec( st->hIGFDec ); #if 1/*TODO: To be removed later(floating point initialization)*/ +#if (defined EVS_FLOAT) || !(defined 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]; - set_f( st->hIGFDec->igfData.pSpecFlatBuf, 0, IGF_START_MX ); - st->hIGFDec->igfData.pSpecFlat_float = &st->hIGFDec->igfData.pSpecFlatBuf[0]; #endif #else init_igf_dec_flt( st->hIGFDec ); diff --git a/lib_dec/ivas_mct_dec_mct_fx.c b/lib_dec/ivas_mct_dec_mct_fx.c index 1c88b2c09..4a3577cd1 100644 --- a/lib_dec/ivas_mct_dec_mct_fx.c +++ b/lib_dec/ivas_mct_dec_mct_fx.c @@ -372,11 +372,11 @@ void mctStereoIGF_dec_fx( move32(); } - IF( st->igf ) - { - // TODO: remove this float to fixed conversion later. - me2f_buf( st->hIGFDec->virtualSpec, st->hIGFDec->virtualSpec_e, st->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); - } + //IF( st->igf ) + //{ + // // TODO: remove this float to fixed conversion later. + // me2f_buf( st->hIGFDec->virtualSpec, st->hIGFDec->virtualSpec_e, st->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); + //} } } // TODO: Converting 16bit noise info to u8bit. can remove this later. @@ -437,7 +437,7 @@ void mctStereoIGF_dec_fx( IF( st->igf ) { // TODO: Fixed to float. Remove this later. - me2f_buf( st->hIGFDec->virtualSpec, st->hIGFDec->virtualSpec_e, st->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); + //me2f_buf( st->hIGFDec->virtualSpec, st->hIGFDec->virtualSpec_e, st->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); // TODO: 16bit to u8bit. Remove this later. FOR( Word16 l = 0; l < IGF_START_MX; l++ ) { diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 2560aab83..9af44380f 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -513,10 +513,6 @@ void ivas_mdct_dec_side_bits_frame_channel_fx( { /* Initialization or re-configuration of Stereo TCX */ stereo_tcx_init_dec_fx( sts[ch], 1, hCPE->last_element_mode ); - -#if 1 // TODO: To be removed later - stereo_tcx_init_dec( sts[ch], 1, hCPE->last_element_mode ); -#endif } sts[ch]->enablePlcWaveadjust = 0; } diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index f22dd6458..f6a805aaf 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -277,16 +277,17 @@ ivas_error ivas_sce_dec_fx( } #endif + set32_fx(output[0], 0, L_FRAME48k); #endif // !IVAS_FLOAT_FIXED_TO_BE_REMOVED - IF( ( error = ivas_core_dec( st_ivas, hSCE, NULL, NULL, 1, output_flt, outputHB_flt, NULL, st_ivas->sba_dirac_stereo_flag ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_core_dec( st_ivas, hSCE, NULL, NULL, 1, output, outputHB_flt, NULL, st_ivas->sba_dirac_stereo_flag ) ) != IVAS_ERR_OK ) { return error; } #ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED FOR( int k = 0; k < L_FRAME48k; k++ ) { - output[0][k] = (Word32) ( output_flt[0][k] * ONE_IN_Q11 ); + //output[0][k] = (Word32) ( output_flt[0][k] * ONE_IN_Q11 ); outputHB[0][k] = (Word32) ( outputHB_flt[0][k] * ONE_IN_Q11 ); } free( output_flt[0] ); diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index baf805c90..55874bb33 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -2136,7 +2136,7 @@ void stereo_cna_update_params_fx( hFdCngDec = sts[0]->hFdCngDec; //delete below - hFdCngDec->cna_act_fact_fx = (Word16)(hFdCngDec->cna_act_fact * (1 << 15)); + //hFdCngDec->cna_act_fact_fx = (Word16)(hFdCngDec->cna_act_fact * (1 << 15)); // hFdCngDec->cna_LR_LT_fx = (Word16)(hFdCngDec->cna_LR_LT * (1 << 15)); // hFdCngDec->cna_ILD_LT_fx = (Word16)(hFdCngDec->cna_ILD_LT * (1 << 15)); ///// @@ -2299,7 +2299,7 @@ void stereo_cna_update_params_fx( /* quickly decrease in TD stereo mode */ hFdCngDec->cna_act_fact_fx = extract_h( Mpy_32_16_1( 1503238553, hFdCngDec->cna_act_fact_fx ) ); } - else if ( sts[0]->VAD > hFdCngDec->cna_act_fact ) + else if ( (sts[0]->VAD*MAX_WORD16) > hFdCngDec->cna_act_fact_fx )//VAD is one bit { /* quickly increase during active frames in DFT stereo mode */ hFdCngDec->cna_act_fact_fx = extract_h( Mpy_32_16_1( 1503238553, hFdCngDec->cna_act_fact_fx ) + ( 644245094 * sts[0]->VAD ) ); @@ -2312,16 +2312,6 @@ void stereo_cna_update_params_fx( } } - //delete below - //hCPE->lt_es_em = (float)hCPE->lt_es_em_fx / (1 << 24); - hFdCngDec->cna_act_fact = (float) hFdCngDec->cna_act_fact_fx / ( 1 << 15 ); - // hFdCngDec->cna_LR_LT = (float )hFdCngDec->cna_LR_LT_fx / ( 1 << 15 ); - // hFdCngDec->cna_ILD_LT= (float )hFdCngDec->cna_ILD_LT_fx / ( 1 << 15 ); - for (int idx = 0; idx < STEREO_DFT_BAND_MAX; idx++) - { - //hFdCngDec->cna_g_state[idx] = (float)hFdCngDec->cna_g_state_fx[idx]/ (1 << 15); - //hFdCngDec->cna_cm[idx] = (float)hFdCngDec->cna_cm_fx[idx]/ (1 << 15); - } return; } diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index 632e6ee34..1f92f548a 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -1016,6 +1016,7 @@ static void run_min_stats_fx( noisy_speech_detection( st->hFdCngDec, st->VAD && st->m_frame_type == ACTIVE_FRAME, power_spec_16, sub(15, power_spec_e)); st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx = L_add(Mpy_32_32(Q31_0_99, st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx), Mpy_32_32(st->hFdCngDec->hFdCngCom->flag_noisy_speech, Q31_0_01)); + st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = extract_h( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx ); st->lp_noise = st->hFdCngDec->lp_noise; } diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 781800cfd..88457bb8d 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -145,7 +145,7 @@ static ivas_error allocate_CoreCoder_TCX_fx( } reset_tcx_overl_buf_fx( st->hTcxDec ); - + st->hTcxDec->CngLevelBackgroundTrace_bfi = 0; //initializing to avoid garbage overflow; set16_fx( st->hTcxDec->syn_OverlFB, 0, L_FRAME48k / 2 ); set16_fx( st->hTcxDec->old_synth, 0, OLD_SYNTH_INTERNAL_DEC ); set16_fx( st->hTcxDec->synth_history_fx, 0, L_PROT48k + L_FRAME48k ); diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 4d0ab1bea..6212dab02 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -156,7 +156,7 @@ void stereo_tcx_init_dec_fx( return; } #endif - +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) void stereo_tcx_init_dec( Decoder_State *st, /* i/o: decoder state structure */ const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ @@ -237,7 +237,7 @@ void stereo_tcx_init_dec( return; } - +#endif #ifdef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* @@ -652,7 +652,7 @@ void stereo_tcx_core_dec_fx( E_LPC_f_lsp_a_conversion( &lsp_fx[( k + 1 ) * M], Aq_fx, M ); { - IGFDecRestoreTCX10SubFrameData_flt( st->hIGFDec, k ); /*float call to be removed*/ + //IGFDecRestoreTCX10SubFrameData_flt( st->hIGFDec, k ); /*float call to be removed*/ IGFDecRestoreTCX10SubFrameData_fx( st->hIGFDec, k ); } @@ -852,9 +852,8 @@ void stereo_tcx_core_dec_fx( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx = L_add( Mpy_32_32( Q31_0_99, st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx ), st->hFdCngDec->hFdCngCom->flag_noisy_speech * Q31_0_01 ); + st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = extract_h( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx ); st->lp_noise = st->hFdCngDec->lp_noise; - // To be removed - st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt = 0.99f * st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt + 0.01f * (float) st->hFdCngDec->hFdCngCom->flag_noisy_speech; IF( NE_16( st->element_mode, IVAS_CPE_TD ) ) { @@ -1611,6 +1610,7 @@ static void dec_prm_tcx( return; } #endif // IVAS_FLOAT_FIXED +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) /*-----------------------------------------------------------------* * Function stereo_tcx_dec_mode_switch_reconf() * @@ -1651,6 +1651,7 @@ static void stereo_tcx_dec_mode_switch_reconf( return; } +#endif #ifdef IVAS_FLOAT_FIXED static void stereo_tcx_dec_mode_switch_reconf_ivas_fx( Decoder_State *st, /* i/o: decoder state structure */ diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 1b3a8c897..ceec307b9 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -82,7 +82,7 @@ typedef struct { HANDLE_FD_CNG_COM hFdCngCom; - Word16 olapBufferAna[320]; + Word16 olapBufferAna[FFTLEN]; Word16 olapBufferSynth2[FFTLEN]; #if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) float msPeriodog_float[NPART_SHAPING]; /* Periodogram */ @@ -210,7 +210,9 @@ typedef struct int16_t cna_nbands; /* stereo CNA - number of frequency bands used by the CNA in DFT stereo mode */ int16_t cna_band_limits[STEREO_DFT_BAND_MAX + 1]; /* stereo CNA - band limits used by the CNA in DFT stereo mode */ +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) float cna_act_fact; /* stereo CNA - long-term signal activity factor (0-1) */ +#endif #if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) float cna_rescale_fact; /* stereo CNA - CN energy re-scaling factor to maintain decoded energy */ #endif @@ -481,12 +483,15 @@ typedef struct igfdec_private_data_struct IGF_INFO igfInfo; /* envelope reconstruction: */ +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) float igf_sN_float[IGF_MAX_SFB]; /* only with short blocks as static needed */ +#endif Word32 igf_sN[IGF_MAX_SFB]; /* Q31 | only with short blocks as static needed */ Word16 igf_sN_e[IGF_MAX_SFB]; /* | exponent for igf_sN */ - +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) float igf_pN_float[IGF_MAX_SFB]; /* only with short blocks as static needed */ +#endif Word32 igf_pN[IGF_MAX_SFB]; /* Q31 | only with short blocks as static needed */ Word16 igf_pN_e[IGF_MAX_SFB]; @@ -498,8 +503,10 @@ typedef struct igfdec_private_data_struct int16_t igf_flatteningTrigger_subframe[IGF_MAX_SUBFRAMES]; /* spectral whitening: */ +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) float *pSpecFlat_float; float pSpecFlatBuf[IGF_START_MX]; +#endif Word32 *pSpecFlat; Word32 pSpecFlatBuf_fx[IGF_START_MX]; /* Q31 | MDCT spectrum before LPC shaping */ Word16 pSpecFlat_exp; @@ -510,8 +517,9 @@ typedef struct igfdec_private_data_struct int16_t prevWhiteningLevel[IGF_MAX_TILES]; /* needed for concealment */ int16_t currWhiteningLevel_subframe[IGF_MAX_SUBFRAMES][IGF_MAX_TILES]; int16_t prevWhiteningLevel_subframe[IGF_MAX_SUBFRAMES][IGF_MAX_TILES]; /* needed for concealment */ - +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) float totalNoiseNrg_float; +#endif Word32 totalNoiseNrg; Word16 totalNoiseNrg_exp; @@ -519,8 +527,9 @@ typedef struct igfdec_private_data_struct Word16 headroom_TCX_noise_white; Word16 headroom_TCX_noise; - +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) float totalNoiseNrg_off_float; +#endif Word32 totalNoiseNrg_off; Word16 totalNoiseNrg_off_exp; int16_t n_noise_bands_off; @@ -547,9 +556,10 @@ typedef struct igfdec_instance_struct Word16 infoTCXNoise_evs[IGF_START_MX]; int16_t *flag_sparse; int16_t flag_sparseBuf[N_MAX_TCX - IGF_START_MN]; - +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) float *virtualSpec_float; // needed in MCT path float virtualSpecBuf[N_MAX_TCX - IGF_START_MN]; +#endif Word32 *virtualSpec_fx; Word32 virtualSpec[N_MAX_TCX - IGF_START_MN]; /* Q31 | buffer for temp flattening */ Word16 virtualSpec_e; /* | exponent of virtualSpec */ @@ -615,8 +625,7 @@ typedef struct tcx_ltp_dec_structure int16_t tcxltp_pitch_int_post_prev; int16_t tcxltp_pitch_fr_post_prev; -//#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) -#if 1 +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) float tcxltp_gain_post_prev_float; #endif // #if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) Word16 tcxltp_gain_post_prev; @@ -654,8 +663,9 @@ typedef struct tcx_dec_structure int16_t pit_max_TCX; int16_t L_frameTCX; - +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) float old_excFB[L_FRAME48k]; /* old excitation FB */ +#endif Word16 old_excFB_fx[L_FRAME48k]; /* old excitation FB */ int16_t old_synth_len; @@ -1344,7 +1354,9 @@ typedef struct hq_dec_structure //int16_t prev_R; /* the table of bit allocation of last frame */ Word16 prev_R; /* the table of bit allocation of last frame */ +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) float prev_coeff_out[L_HQ_WB_BWE]; /* the highest coefficients of last frame */ +#endif int16_t prev_SWB_peak_pos[SPT_SHORTEN_SBNUM]; Word32 prev_coeff_out_fx[L_HQ_WB_BWE]; /* Q12 */ /* the coefficients of last frame */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index f8e79837c..8e633488e 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -1088,8 +1088,8 @@ static void ivas_dirac_dec_binaural_internal( st_ivas->cldfbAnaDec[cha]->cldfb_state_fx[ind] = (Word32)(st_ivas->cldfbAnaDec[cha]->cldfb_state[ind] * (1 << q_input)); } } - IF(st_ivas->hSCE[0] && st_ivas->hSCE[0]->hCoreCoder[0] && st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt >= (1 << 0)) assert(0); - IF(st_ivas->hSCE[0] && st_ivas->hSCE[0]->hCoreCoder[0]) st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->likelihood_noisy_speech = (Word16)(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt * (32767)); + //IF(st_ivas->hSCE[0] && st_ivas->hSCE[0]->hCoreCoder[0] && st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt >= (1 << 0)) assert(0); + //IF(st_ivas->hSCE[0] && st_ivas->hSCE[0]->hCoreCoder[0]) st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->likelihood_noisy_speech = (Word16)(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt * (32767)); st_ivas->cldfbAnaDec[1]->q_scale = 15; IF(abs_s((Word16)st_ivas->cldfbAnaDec[1]->scale_flt) != 0) st_ivas->cldfbAnaDec[1]->q_scale = norm_s((Word16)st_ivas->cldfbAnaDec[1]->scale_flt); -- GitLab