diff --git a/lib_com/float_to_fix_ops.c b/lib_com/float_to_fix_ops.c index 4a1d8af75457bd16a4137811ae961dfb282cc9fa..137226b7e9fe3d261aaf9d0c3f4a1682a9e51311 100644 --- a/lib_com/float_to_fix_ops.c +++ b/lib_com/float_to_fix_ops.c @@ -306,18 +306,18 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( st->hTcxDec->Q_syn_Overl_TDAC = Q_factor_arr( st->hTcxDec->syn_Overl_TDAC_float, L_FRAME32k / 2 ) - 1; st->hTcxDec->Q_syn_Overl = Q_factor_arr( st->hTcxDec->syn_Overl_float, L_FRAME32k / 2 ) - 1; st->hTcxDec->Q_syn_Overl_TDACFB = Q_factor_arr( st->hTcxDec->syn_Overl_TDACFB_float, L_FRAME32k / 2 ); - st->hTcxDec->Q_syn_OverlFB = Q_factor_arr( st->hTcxDec->syn_OverlFB_float, L_FRAME_MAX / 2 ); + //st->hTcxDec->Q_syn_OverlFB = Q_factor_arr( st->hTcxDec->syn_OverlFB_float, L_FRAME_MAX / 2 ); Q_old_synth = Q_syn; - Q_synth_history = Q_factor_arr( st->hTcxDec->synth_history, L_PROT48k + L_FRAME_MAX ); + //Q_synth_history = Q_factor_arr( st->hTcxDec->synth_history, L_PROT48k + L_FRAME_MAX ); floatToFixed_arr( st->hTcxDec->old_syn_Overl_float, st->hTcxDec->old_syn_Overl, st->hTcxDec->Q_old_syn_Overl, L_FRAME32k / 2 ); floatToFixed_arr( st->hTcxDec->syn_Overl_TDAC_float, st->hTcxDec->syn_Overl_TDAC, st->hTcxDec->Q_syn_Overl_TDAC, L_FRAME32k / 2 ); floatToFixed_arr( st->hTcxDec->syn_Overl_float, st->hTcxDec->syn_Overl, st->hTcxDec->Q_syn_Overl, L_FRAME32k / 2 ); floatToFixed_arr( st->hTcxDec->syn_Overl_TDACFB_float, st->hTcxDec->syn_Overl_TDACFB, st->hTcxDec->Q_syn_Overl_TDACFB, L_FRAME_MAX / 2 ); - floatToFixed_arr( st->hTcxDec->syn_OverlFB_float, st->hTcxDec->syn_OverlFB, st->hTcxDec->Q_syn_OverlFB, L_FRAME_MAX / 2 ); - floatToFixed_arr( st->hTcxDec->old_synth_float, st->hTcxDec->old_synth, Q_old_synth, OLD_SYNTH_INTERNAL_DEC ); - floatToFixed_arr( st->hTcxDec->synth_history, st->hTcxDec->synth_history_fx, Q_synth_history, L_PROT48k + L_FRAME_MAX ); + //floatToFixed_arr( st->hTcxDec->syn_OverlFB_float, st->hTcxDec->syn_OverlFB, st->hTcxDec->Q_syn_OverlFB, L_FRAME_MAX / 2 ); + //floatToFixed_arr( st->hTcxDec->old_synth_float, st->hTcxDec->old_synth, Q_old_synth, OLD_SYNTH_INTERNAL_DEC ); + //floatToFixed_arr( st->hTcxDec->synth_history, st->hTcxDec->synth_history_fx, Q_synth_history, L_PROT48k + L_FRAME_MAX ); st->hTcxDec->L_frameTCX = extract_l( Mult_32_16( st->output_Fs, 0x0290 ) ); - st->hTcxDec->tcxltp_last_gain_unmodified = (Word16) floatToFixed( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 ); + //st->hTcxDec->tcxltp_last_gain_unmodified = (Word16) floatToFixed( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 ); st->output_frame_fx = st->hTcxDec->L_frameTCX; st->hTcxDec->CngLevelBackgroundTrace_bfi_fx = floatToFixed( st->hTcxDec->CngLevelBackgroundTrace_bfi, 15 ); //st->hTcxDec->conceal_eof_gain = (Word16) floatToFixed( st->hTcxDec->conceal_eof_gain_float, 14 ); @@ -353,10 +353,10 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( IF( st->hTcxLtpDec ) { - Q_tcxltp_mem_in = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_in_float, TCXLTP_MAX_DELAY ); - Q_tcxltp_mem_out = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_out_float, L_FRAME48k ); - floatToFixed_arr( st->hTcxLtpDec->tcxltp_mem_in_float, st->hTcxLtpDec->tcxltp_mem_in, Q_tcxltp_mem_in, TCXLTP_MAX_DELAY ); - floatToFixed_arr( st->hTcxLtpDec->tcxltp_mem_out_float, st->hTcxLtpDec->tcxltp_mem_out, Q_tcxltp_mem_out, L_FRAME48k ); + //Q_tcxltp_mem_in = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_in_float, TCXLTP_MAX_DELAY ); + //Q_tcxltp_mem_out = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_out_float, L_FRAME48k ); + //floatToFixed_arr( st->hTcxLtpDec->tcxltp_mem_in_float, st->hTcxLtpDec->tcxltp_mem_in, Q_tcxltp_mem_in, TCXLTP_MAX_DELAY ); + //floatToFixed_arr( st->hTcxLtpDec->tcxltp_mem_out_float, st->hTcxLtpDec->tcxltp_mem_out, Q_tcxltp_mem_out, L_FRAME48k ); } @@ -406,10 +406,10 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( fixedToFloat_arr( st->hTcxDec->syn_Overl_TDAC, st->hTcxDec->syn_Overl_TDAC_float, st->hTcxDec->Q_syn_Overl_TDAC, 320 ); fixedToFloat_arr( st->hTcxDec->syn_Overl, st->hTcxDec->syn_Overl_float, st->hTcxDec->Q_syn_Overl, 320 ); fixedToFloat_arr( st->hTcxDec->syn_Overl_TDACFB, st->hTcxDec->syn_Overl_TDACFB_float, st->hTcxDec->Q_syn_Overl_TDACFB, 480 ); - fixedToFloat_arr( st->hTcxDec->syn_OverlFB, st->hTcxDec->syn_OverlFB_float, st->hTcxDec->Q_syn_OverlFB, 480 ); - fixedToFloat_arr( st->hTcxDec->old_synth, st->hTcxDec->old_synth_float, Q_old_synth, OLD_SYNTH_INTERNAL_DEC ); - fixedToFloat_arr( st->hTcxDec->synth_history_fx, st->hTcxDec->synth_history, Q_synth_history, L_PROT48k + L_FRAME_MAX ); - st->hTcxDec->q_synth_history_fx = Q_synth_history; + //fixedToFloat_arr( st->hTcxDec->syn_OverlFB, st->hTcxDec->syn_OverlFB_float, st->hTcxDec->Q_syn_OverlFB, 480 ); + //fixedToFloat_arr( st->hTcxDec->old_synth, st->hTcxDec->old_synth_float, Q_old_synth, OLD_SYNTH_INTERNAL_DEC ); + //fixedToFloat_arr( st->hTcxDec->synth_history_fx, st->hTcxDec->synth_history, Q_synth_history, L_PROT48k + L_FRAME_MAX ); + //st->hTcxDec->q_synth_history_fx = Q_synth_history; //st->hTcxDec->conceal_eof_gain_float = fixedToFloat( st->hTcxDec->conceal_eof_gain, 14 ); st->hTcxDec->CngLevelBackgroundTrace_bfi = fixedToFloat( st->hTcxDec->CngLevelBackgroundTrace_bfi_fx, 15 ); } @@ -443,16 +443,16 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( Q_lsf_cng = Q_factor( 6400 ); IF( st->hTcxLtpDec != NULL ) { - Q_tcxltp_mem_in = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_in_float, TCXLTP_MAX_DELAY ); - Q_tcxltp_mem_out = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_out_float, L_FRAME48k ); - fixedToFloat_arr( st->hTcxLtpDec->tcxltp_mem_in, st->hTcxLtpDec->tcxltp_mem_in_float, Q_tcxltp_mem_in, TCXLTP_MAX_DELAY ); - fixedToFloat_arr( st->hTcxLtpDec->tcxltp_mem_out, st->hTcxLtpDec->tcxltp_mem_out_float, Q_tcxltp_mem_out, L_FRAME48k ); + //Q_tcxltp_mem_in = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_in_float, TCXLTP_MAX_DELAY ); + //Q_tcxltp_mem_out = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_out_float, L_FRAME48k ); + //fixedToFloat_arr( st->hTcxLtpDec->tcxltp_mem_in, st->hTcxLtpDec->tcxltp_mem_in_float, Q_tcxltp_mem_in, TCXLTP_MAX_DELAY ); + //fixedToFloat_arr( st->hTcxLtpDec->tcxltp_mem_out, st->hTcxLtpDec->tcxltp_mem_out_float, Q_tcxltp_mem_out, L_FRAME48k ); } IF( st->hTonalMDCTConc ) { FOR( i = 0; i < FDNS_NPTS; i++ ) { - st->hTonalMDCTConc->scaleFactorsBackground_flt[i] = fixedToFloat( st->hTonalMDCTConc->scaleFactorsBackground[i], 15 ); + //st->hTonalMDCTConc->scaleFactorsBackground_flt[i] = fixedToFloat( st->hTonalMDCTConc->scaleFactorsBackground[i], 15 ); } } } @@ -527,18 +527,18 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( st->hTcxDec->Q_syn_Overl_TDAC = 0; st->hTcxDec->Q_syn_Overl = 0; st->hTcxDec->Q_syn_Overl_TDACFB = 0; - st->hTcxDec->Q_syn_OverlFB = 0; + //st->hTcxDec->Q_syn_OverlFB = 0; Q_old_synth = 0; Q_synth_history = 0; floatToFixed_arr( st->hTcxDec->old_syn_Overl_float, st->hTcxDec->old_syn_Overl, st->hTcxDec->Q_old_syn_Overl, L_FRAME32k / 2 ); floatToFixed_arr( st->hTcxDec->syn_Overl_TDAC_float, st->hTcxDec->syn_Overl_TDAC, st->hTcxDec->Q_syn_Overl_TDAC, L_FRAME32k / 2 ); floatToFixed_arr( st->hTcxDec->syn_Overl_float, st->hTcxDec->syn_Overl, st->hTcxDec->Q_syn_Overl, L_FRAME32k / 2 ); floatToFixed_arr( st->hTcxDec->syn_Overl_TDACFB_float, st->hTcxDec->syn_Overl_TDACFB, st->hTcxDec->Q_syn_Overl_TDACFB, L_FRAME_MAX / 2 ); - floatToFixed_arr( st->hTcxDec->syn_OverlFB_float, st->hTcxDec->syn_OverlFB, st->hTcxDec->Q_syn_OverlFB, L_FRAME_MAX / 2 ); - floatToFixed_arr( st->hTcxDec->old_synth_float, st->hTcxDec->old_synth, Q_old_synth, OLD_SYNTH_INTERNAL_DEC ); - floatToFixed_arr( st->hTcxDec->synth_history, st->hTcxDec->synth_history_fx, Q_synth_history, L_PROT48k + L_FRAME_MAX ); + //floatToFixed_arr( st->hTcxDec->syn_OverlFB_float, st->hTcxDec->syn_OverlFB, st->hTcxDec->Q_syn_OverlFB, L_FRAME_MAX / 2 ); + //floatToFixed_arr( st->hTcxDec->old_synth_float, st->hTcxDec->old_synth, Q_old_synth, OLD_SYNTH_INTERNAL_DEC ); + //floatToFixed_arr( st->hTcxDec->synth_history, st->hTcxDec->synth_history_fx, Q_synth_history, L_PROT48k + L_FRAME_MAX ); st->hTcxDec->L_frameTCX = extract_l( Mult_32_16( st->output_Fs, 0x0290 ) ); - st->hTcxDec->tcxltp_last_gain_unmodified = (Word16) floatToFixed( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 ); + //st->hTcxDec->tcxltp_last_gain_unmodified = (Word16) floatToFixed( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 ); st->output_frame_fx = st->hTcxDec->L_frameTCX; st->hTcxDec->CngLevelBackgroundTrace_bfi_fx = floatToFixed( st->hTcxDec->CngLevelBackgroundTrace_bfi, 15 ); //st->hTcxDec->conceal_eof_gain = (Word16) floatToFixed( st->hTcxDec->conceal_eof_gain_float, 14 ); @@ -573,10 +573,10 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( } IF( st->hTcxLtpDec ) { - Q_tcxltp_mem_in = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_in_float, TCXLTP_MAX_DELAY ); - Q_tcxltp_mem_out = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_out_float, L_FRAME48k ); - floatToFixed_arr( st->hTcxLtpDec->tcxltp_mem_in_float, st->hTcxLtpDec->tcxltp_mem_in, Q_tcxltp_mem_in, TCXLTP_MAX_DELAY ); - floatToFixed_arr( st->hTcxLtpDec->tcxltp_mem_out_float, st->hTcxLtpDec->tcxltp_mem_out, Q_tcxltp_mem_out, L_FRAME48k ); + //Q_tcxltp_mem_in = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_in_float, TCXLTP_MAX_DELAY ); + //Q_tcxltp_mem_out = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_out_float, L_FRAME48k ); + //floatToFixed_arr( st->hTcxLtpDec->tcxltp_mem_in_float, st->hTcxLtpDec->tcxltp_mem_in, Q_tcxltp_mem_in, TCXLTP_MAX_DELAY ); + //floatToFixed_arr( st->hTcxLtpDec->tcxltp_mem_out_float, st->hTcxLtpDec->tcxltp_mem_out, Q_tcxltp_mem_out, L_FRAME48k ); } @@ -626,10 +626,10 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( fixedToFloat_arr( st->hTcxDec->syn_Overl_TDAC, st->hTcxDec->syn_Overl_TDAC_float, st->hTcxDec->Q_syn_Overl_TDAC, 320 ); fixedToFloat_arr( st->hTcxDec->syn_Overl, st->hTcxDec->syn_Overl_float, st->hTcxDec->Q_syn_Overl, 320 ); fixedToFloat_arr( st->hTcxDec->syn_Overl_TDACFB, st->hTcxDec->syn_Overl_TDACFB_float, st->hTcxDec->Q_syn_Overl_TDACFB, 480 ); - fixedToFloat_arr( st->hTcxDec->syn_OverlFB, st->hTcxDec->syn_OverlFB_float, st->hTcxDec->Q_syn_OverlFB, 480 ); - fixedToFloat_arr( st->hTcxDec->old_synth, st->hTcxDec->old_synth_float, Q_old_synth, OLD_SYNTH_INTERNAL_DEC ); - fixedToFloat_arr( st->hTcxDec->synth_history_fx, st->hTcxDec->synth_history, Q_synth_history, L_PROT48k + L_FRAME_MAX ); - st->hTcxDec->q_synth_history_fx = Q_synth_history; + //fixedToFloat_arr( st->hTcxDec->syn_OverlFB, st->hTcxDec->syn_OverlFB_float, st->hTcxDec->Q_syn_OverlFB, 480 ); + //fixedToFloat_arr( st->hTcxDec->old_synth, st->hTcxDec->old_synth_float, Q_old_synth, OLD_SYNTH_INTERNAL_DEC ); + //fixedToFloat_arr( st->hTcxDec->synth_history_fx, st->hTcxDec->synth_history, Q_synth_history, L_PROT48k + L_FRAME_MAX ); + //st->hTcxDec->q_synth_history_fx = Q_synth_history; //st->hTcxDec->conceal_eof_gain_float = fixedToFloat( st->hTcxDec->conceal_eof_gain, 14 ); st->hTcxDec->CngLevelBackgroundTrace_bfi = fixedToFloat( st->hTcxDec->CngLevelBackgroundTrace_bfi_fx, 15 ); st->hTcxDec->conCngLevelBackgroundTrace = (Word16) st->hTcxDec->CngLevelBackgroundTrace_bfi_fx; @@ -668,16 +668,16 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( IF( st->hTcxLtpDec != NULL ) { - Q_tcxltp_mem_in = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_in_float, TCXLTP_MAX_DELAY ); - Q_tcxltp_mem_out = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_out_float, L_FRAME48k ); - fixedToFloat_arr( st->hTcxLtpDec->tcxltp_mem_in, st->hTcxLtpDec->tcxltp_mem_in_float, Q_tcxltp_mem_in, TCXLTP_MAX_DELAY ); - fixedToFloat_arr( st->hTcxLtpDec->tcxltp_mem_out, st->hTcxLtpDec->tcxltp_mem_out_float, Q_tcxltp_mem_out, L_FRAME48k ); + //Q_tcxltp_mem_in = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_in_float, TCXLTP_MAX_DELAY ); + //Q_tcxltp_mem_out = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_out_float, L_FRAME48k ); + //fixedToFloat_arr( st->hTcxLtpDec->tcxltp_mem_in, st->hTcxLtpDec->tcxltp_mem_in_float, Q_tcxltp_mem_in, TCXLTP_MAX_DELAY ); + //fixedToFloat_arr( st->hTcxLtpDec->tcxltp_mem_out, st->hTcxLtpDec->tcxltp_mem_out_float, Q_tcxltp_mem_out, L_FRAME48k ); } IF( st->hTonalMDCTConc ) { FOR( i = 0; i < FDNS_NPTS; i++ ) { - st->hTonalMDCTConc->scaleFactorsBackground_flt[i] = fixedToFloat( st->hTonalMDCTConc->scaleFactorsBackground[i], 15 ); + //st->hTonalMDCTConc->scaleFactorsBackground_flt[i] = fixedToFloat( st->hTonalMDCTConc->scaleFactorsBackground[i], 15 ); } } } @@ -688,14 +688,14 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( /*==========*/ for ( int p = 0; p < hTcxDec->old_synth_len; p++ ) { - hTcxDec->old_synth[p] = (Word16) ( hTcxDec->old_synth_float[p] ); + //hTcxDec->old_synth[p] = (Word16) ( hTcxDec->old_synth_float[p] ); } for ( int p = 0; p < hTcxDec->old_synth_lenFB; p++ ) { hTcxDec->old_synthFB_fx[p] = (Word16) ( hTcxDec->old_synthFB[p] ); } - st->hTcxDec->tcxltp_last_gain_unmodified = (Word16) floatToFixed( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 ); + //st->hTcxDec->tcxltp_last_gain_unmodified = (Word16) floatToFixed( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 ); if ( st->hTonalMDCTConc != NULL ) { floatToFixed_arr( st->hTonalMDCTConc->secondLastPcmOut_float, st->hTonalMDCTConc->secondLastPcmOut, 0, st->hTonalMDCTConc->nSamples ); @@ -718,7 +718,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; if ( hTcxLtpDec->tcxltp ) { - hTcxDec->tcxltp_last_gain_unmodified = (Word16) floatToFixed( hTcxDec->tcxltp_last_gain_unmodified_float, Q15 ); + //hTcxDec->tcxltp_last_gain_unmodified = (Word16) floatToFixed( hTcxDec->tcxltp_last_gain_unmodified_float, Q15 ); } floatToFixed_arr( st->hHQ_core->old_out + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), 0, NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); @@ -736,10 +736,10 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( //{ // st->hFdCngDec->hFdCngCom->periodog[p] = (Word32) ( st->hFdCngDec->hFdCngCom->periodog_flt[p] * ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->periodog_exp ) ) ); //} - for ( int p = 0; p < st->hFdCngDec->hFdCngCom->fftlen; p++ ) - { - st->hFdCngDec->hFdCngCom->fftBuffer[p] = (Word32) ( st->hFdCngDec->hFdCngCom->fftBuffer_flt[p] * ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp ) ) ); - } + //for ( int p = 0; p < st->hFdCngDec->hFdCngCom->fftlen; p++ ) + //{ + // st->hFdCngDec->hFdCngCom->fftBuffer[p] = (Word32) ( st->hFdCngDec->hFdCngCom->fftBuffer_flt[p] * ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp ) ) ); + //} st->hFdCngDec->msNoiseEst_exp = 31 - Q4; for ( int p = 0; p < st->hFdCngDec->npart_shaping; p++ ) { @@ -766,15 +766,6 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( //} } - IF(bfi && st->tonal_mdct_plc_active && NE_16(st->element_mode, IVAS_CPE_MDCT)) - { - FOR(Word16 ii = 0; ii < FDNS_NPTS; ii++) - { - f2me_16(st->hTonalMDCTConc->secondLastBlockData.scaleFactors_float[ii], &st->hTonalMDCTConc->secondLastBlockData.scaleFactors[ii], &st->hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[ii]); - st->hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e = s_max(st->hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e, st->hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[ii]); - } - } - // u8bit to 16bit FOR(int l = 0; l < IGF_START_MX; l++) { @@ -787,7 +778,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( floatToFixed_arr(st->hTcxDec->syn_Overl_TDAC_float, st->hTcxDec->syn_Overl_TDAC, st->Q_syn, 320); floatToFixed_arr(st->hTcxDec->syn_Overl_float, st->hTcxDec->syn_Overl, st->Q_syn+1, 320); floatToFixed_arr(st->hTcxDec->syn_Overl_TDACFB_float, st->hTcxDec->syn_Overl_TDACFB, st->Q_syn, 480); - floatToFixed_arr(st->hTcxDec->syn_OverlFB_float, st->hTcxDec->syn_OverlFB, st->Q_syn, 480); + //floatToFixed_arr(st->hTcxDec->syn_OverlFB_float, st->hTcxDec->syn_OverlFB, st->Q_syn, 480); } } @@ -797,14 +788,14 @@ void fixed_to_float_stereo_tcx_core_dec( { TCX_DEC_HANDLE hTcxDec = st->hTcxDec; //Word16 q_Aq; - st->hTcxDec->tcxltp_last_gain_unmodified_float = (Word16) fixedToFloat( st->hTcxDec->tcxltp_last_gain_unmodified, Q15 ); + //st->hTcxDec->tcxltp_last_gain_unmodified_float = (Word16) fixedToFloat( st->hTcxDec->tcxltp_last_gain_unmodified, Q15 ); if ( EQ_16( st->core, ACELP_CORE ) ) { for ( int p = 0; p < st->L_frame / 2; p++ ) { - st->hTcxDec->syn_OverlFB_float[p] = (float) st->hTcxDec->syn_OverlFB[p] / (float) pow( 2, st->Q_syn ); + //st->hTcxDec->syn_OverlFB_float[p] = (float) st->hTcxDec->syn_OverlFB[p] / (float) pow( 2, st->Q_syn ); st->hTcxDec->syn_Overl_float[p] = (float) st->hTcxDec->syn_Overl[p] / (float) pow( 2, st->Q_syn ); st->hTcxDec->old_syn_Overl_float[p] = (float) st->hTcxDec->old_syn_Overl[p] * 2 * ( 1u << st->Q_syn ); st->hTcxDec->syn_Overl_TDACFB_float[p] = (float) st->hTcxDec->syn_Overl_TDACFB[p] * 2 * (float) pow( 2, st->Q_syn ); @@ -827,15 +818,15 @@ void fixed_to_float_stereo_tcx_core_dec( // st->mid_lsf_int = st->mid_lsf_int; //} - hTcxDec->tcxltp_last_gain_unmodified_float = fixedToFloat( hTcxDec->tcxltp_last_gain_unmodified, Q15 ); + //hTcxDec->tcxltp_last_gain_unmodified_float = fixedToFloat( hTcxDec->tcxltp_last_gain_unmodified, Q15 ); //st->hTcxDec->conceal_eof_gain_float = fixedToFloat( st->hTcxDec->conceal_eof_gain, Q14 ); st->hTcxDec->CngLevelBackgroundTrace_bfi = fixedToFloat( st->hTcxDec->conCngLevelBackgroundTrace, 15 - st->hTcxDec->conCngLevelBackgroundTrace_e ); - fixedToFloat_arr( hTcxDec->old_synth, hTcxDec->old_synth_float, 0, hTcxDec->old_synth_len ); - fixedToFloat_arr( hTcxDec->synth_history_fx, hTcxDec->synth_history, 0, NS2SA_fx2( st->output_Fs, PH_ECU_MEM_NS ) ); - st->hTcxDec->q_synth_history_fx = 0; + //fixedToFloat_arr( hTcxDec->old_synth, hTcxDec->old_synth_float, 0, hTcxDec->old_synth_len ); + //fixedToFloat_arr( hTcxDec->synth_history_fx, hTcxDec->synth_history, 0, NS2SA_fx2( st->output_Fs, PH_ECU_MEM_NS ) ); + //st->hTcxDec->q_synth_history_fx = 0; fixedToFloat_arr( hTcxDec->old_synthFB_fx, hTcxDec->old_synthFB, 0, NS2SA_fx2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) + hTcxDec->old_synth_lenFB ); @@ -864,17 +855,17 @@ void fixed_to_float_stereo_tcx_core_dec( { st->hTcxDec->CngLevelBackgroundTrace_bfi = fix_to_float( st->hTcxDec->CngLevelBackgroundTrace_bfi_fx, ( 31 - st->hTcxDec->CngLevelBackgroundTrace_bfi_exp ) ); //st->cngTDLevel_float = fixedToFloat( st->cngTDLevel, ( 15 - st->cngTDLevel_e ) ); - for ( int p = 0; p < st->hFdCngDec->hFdCngCom->fftlen; p++ ) - { - st->hFdCngDec->hFdCngCom->fftBuffer_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->fftBuffer[p] / ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp ) ) ); - } + //for ( int p = 0; p < st->hFdCngDec->hFdCngCom->fftlen; p++ ) + //{ + // st->hFdCngDec->hFdCngCom->fftBuffer_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->fftBuffer[p] / ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp ) ) ); + //} for ( int p = 0; p < ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); p++ ) { st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->cngNoiseLevel[p] / ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) ) ); } for ( int p = 0; p < ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); p++ ) { - st->hFdCngDec->bandNoiseShape_float[p] = ( (float) st->hFdCngDec->bandNoiseShape[p] / ( 1u << ( 31 - st->hFdCngDec->bandNoiseShape_exp ) ) ); + //st->hFdCngDec->bandNoiseShape_float[p] = ( (float) st->hFdCngDec->bandNoiseShape[p] / ( 1u << ( 31 - st->hFdCngDec->bandNoiseShape_exp ) ) ); } @@ -887,8 +878,9 @@ void fixed_to_float_stereo_tcx_core_dec( { for ( int p = 0; p < L_FRAME16k - st->hFdCngDec->hFdCngCom->startBand; p++ ) { - st->hFdCngDec->smoothed_psd[st->hFdCngDec->hFdCngCom->startBand + p] = ( (float) st->hFdCngDec->smoothed_psd_fx[st->hFdCngDec->hFdCngCom->startBand + p] / ( 1u << ( 31 - st->hFdCngDec->msNoiseEst_exp ) ) ); + //st->hFdCngDec->smoothed_psd[st->hFdCngDec->hFdCngCom->startBand + p] = ( (float) st->hFdCngDec->smoothed_psd_fx[st->hFdCngDec->hFdCngCom->startBand + p] / ( 1u << ( 31 - st->hFdCngDec->msNoiseEst_exp ) ) ); } + st->hFdCngDec->q_smoothed_psd = sub( 31 , st->hFdCngDec->msNoiseEst_exp ); } int A_cng_q = 14; @@ -922,7 +914,7 @@ void fixed_to_float_stereo_tcx_core_dec( } FOR( Word16 ind = 0; ind < L_FRAME_MAX / 2; ind++ ) { - st->hTcxDec->syn_OverlFB_float[ind] = (float) st->hTcxDec->syn_OverlFB[ind] / ( (float) pow( 2, st->Q_syn ) ); + //st->hTcxDec->syn_OverlFB_float[ind] = (float) st->hTcxDec->syn_OverlFB[ind] / ( (float) pow( 2, st->Q_syn ) ); } } } diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 098eda07c014ea1cf0d42466dab14ee71540c83c..be05cc7c3742b399093838e6636d011d04bdd893 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1586,7 +1586,7 @@ typedef enum #define GAIN_LFE 1.88364911f /* Gain applied to LFE during renderering */ #define GAIN_LFE_WORD32 2022552831 /* Gain applied to LFE during renderering */ #ifdef IVAS_FLOAT_FIXED -#define GAIN_LFE_FX 30862 /* Gain applied to LFE during renderering */ +#define GAIN_LFE_FX 30862 /*Q.14 Gain applied to LFE during renderering */ #endif // IVAS_FLOAT_FIXED #define LOW_BIT_RATE_BINAURAL_EQ_BINS 17 /* Number of bins in an EQ applied at low bit rates in binauralization */ #define LOW_BIT_RATE_BINAURAL_EQ_OFFSET 14 /* Offset of bins where the low-bit-rate EQ starts*/ diff --git a/lib_com/ivas_filters.c b/lib_com/ivas_filters.c index 2d320fcacbc81ea9742b2fe81ff62da0912c3976..07c6783116a7c93a38f511aa5493a50639831907 100644 --- a/lib_com/ivas_filters.c +++ b/lib_com/ivas_filters.c @@ -43,11 +43,10 @@ /*------------------------------------------------------------------------------------------* * Local functions declaration *------------------------------------------------------------------------------------------*/ - -static void ivas_iir_2_filter( ivas_filters_process_state_t *filter_state, float *pIn_Out, const int16_t length, const int16_t stage ); - +static void ivas_iir_2_filter(ivas_filters_process_state_t *filter_state, float *pIn_Out, const int16_t length, const int16_t stage); +#ifdef IVAS_FLOAT_FIXED static void ivas_iir_2_filter_fx(ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q_fcator); - +#endif /*-----------------------------------------------------------------------------------------* * Function ivas_filters_init() * @@ -116,18 +115,11 @@ void ivas_filters_init_fx( { filter_state->num_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[i]; filter_state->den_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[add(i, IVAS_BIQUAD_FILT_LEN)]; - - filter_state->num[IVAS_FILTER_STAGE_0][i] = WORD322FL_SCALE(filter_state->num_fx[IVAS_FILTER_STAGE_0][i], 1); - filter_state->den[IVAS_FILTER_STAGE_0][i] = WORD322FL_SCALE(filter_state->den_fx[IVAS_FILTER_STAGE_0][i], 1); } filter_state->state_fx[0][0] = 0; filter_state->state_fx[0][1] = 0; filter_state->state_fx[0][2] = 0; - - filter_state->state[0][0] = WORD322FL_SCALE(filter_state->state_fx[0][0], 1); - filter_state->state[0][1] = WORD322FL_SCALE(filter_state->state_fx[0][1], 1); - filter_state->state[0][2] = WORD322FL_SCALE(filter_state->state_fx[0][2], 1); } ELSE { @@ -140,11 +132,6 @@ void ivas_filters_init_fx( filter_state->den_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[add(i, IVAS_BIQUAD_FILT_LEN)]; filter_state->num_fx[IVAS_FILTER_STAGE_1][i] = filt_coeff_fx[add(i, i_mult(IVAS_BIQUAD_FILT_LEN,2))]; filter_state->den_fx[IVAS_FILTER_STAGE_1][i] = filt_coeff_fx[add(i, i_mult(IVAS_BIQUAD_FILT_LEN, 3))]; - - filter_state->num[IVAS_FILTER_STAGE_0][i] = WORD322FL_SCALE(filter_state->num_fx[IVAS_FILTER_STAGE_0][i], 1); - filter_state->den[IVAS_FILTER_STAGE_0][i] = WORD322FL_SCALE(filter_state->den_fx[IVAS_FILTER_STAGE_0][i], 1); - filter_state->num[IVAS_FILTER_STAGE_1][i] = WORD322FL_SCALE(filter_state->num_fx[IVAS_FILTER_STAGE_1][i], 1); - filter_state->den[IVAS_FILTER_STAGE_1][i] = WORD322FL_SCALE(filter_state->den_fx[IVAS_FILTER_STAGE_1][i], 1); } filter_state->state_fx[0][0] = 0; @@ -153,13 +140,6 @@ void ivas_filters_init_fx( filter_state->state_fx[1][0] = 0; filter_state->state_fx[1][1] = 0; filter_state->state_fx[1][2] = 0; - - filter_state->state[0][0] = WORD322FL_SCALE(filter_state->state_fx[0][0], 1); - filter_state->state[0][1] = WORD322FL_SCALE(filter_state->state_fx[0][1], 1); - filter_state->state[0][2] = WORD322FL_SCALE(filter_state->state_fx[0][2], 1); - filter_state->state[1][0] = WORD322FL_SCALE(filter_state->state_fx[1][0], 1); - filter_state->state[1][1] = WORD322FL_SCALE(filter_state->state_fx[1][1], 1); - filter_state->state[1][2] = WORD322FL_SCALE(filter_state->state_fx[1][2], 1); } return; @@ -173,7 +153,6 @@ void ivas_filters_init_fx( * * Process call for selecting the type filter *-----------------------------------------------------------------------------------------*/ - void ivas_filter_process( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ float *pIn_Out, /* i/o: signal subject to filtering */ @@ -199,7 +178,6 @@ void ivas_filter_process( return; } - #ifdef IVAS_FLOAT_FIXED void ivas_filter_process_fx( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ @@ -235,7 +213,6 @@ void ivas_filter_process_fx( * * Process call for filtering a signal *-----------------------------------------------------------------------------------------*/ - static void ivas_iir_2_filter( ivas_filters_process_state_t *filter_state, float *pIn_Out, @@ -353,7 +330,7 @@ static void ivas_iir_2_filter_fx( filter_state->state_fx[stage][j - 1] = W_extract_l(L_tmp_2); - filter_state->state[stage][j - 1] = WORD322FL_SCALE(filter_state->state_fx[stage][j - 1], sub(31, q_factor)); + //filter_state->state[stage][j - 1] = WORD322FL_SCALE(filter_state->state_fx[stage][j - 1], sub(31, q_factor)); } } diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 26fdae54ba8f55a26abb2f2cd338f7cf4954d937..16a1cd00550ccfeb44467174543090fc3db89950 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -511,7 +511,7 @@ ivas_error ivas_core_dec( MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ const int16_t n_channels, /* i : number of channels to be decoded */ Word32 *output_fx[], /* o : output synthesis signal */ - float outputHB[][L_FRAME48k], /* o : output HB synthesis signal */ + Word32 outputHB[][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 */ ); @@ -1753,9 +1753,6 @@ void stereo_dft_dec_core_switching( void init_basic_allpass( basic_allpass_t *ap, /* i/o: basic allpass structure */ const float *gains, /* i : allpass filter gains */ -#ifdef IVAS_FLOAT_FIXED - const Word32 *gains_fx, -#endif const int16_t *delays /* i : allpass filter delays */ ); @@ -6737,7 +6734,7 @@ void ivas_lfe_enc_fx( ); #endif // IVAS_FLOAT_FIXED - +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_create_lfe_dec( LFE_DEC_HANDLE *hLFE_out, /* o : IVAS LFE decoder structure */ const int32_t output_Fs, /* i : output sampling rate */ @@ -6755,7 +6752,7 @@ void ivas_lfe_dec( const int16_t bfi, /* i : BFI flag */ float output_lfe_ch[] /* o : output LFE synthesis */ ); - +#endif void ivas_lfe_tdplc( LFE_DEC_HANDLE hLFE, /* i/o: LFE decoder handle */ const float *prevsynth, /* i : previous frame synthesis */ @@ -6798,7 +6795,6 @@ void ivas_filters_init_fx( ); #endif - void ivas_filter_process( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ float *pIn_Out, /* i : signal subject to filtering */ diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 3779a30888b6118196d20e21c571b77209f8fe89..0e51fe22479cb5302df9dc54e8e02cf9a2088257 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -370,7 +370,7 @@ void decoder_tcx_noisefilling_fx( Word16 *x_e, Word16 *gainlpc2, Word16 *gainlpc2_e, - int16_t *temp_concealment_method, + Word16 *temp_concealment_method, const Word16 gain_tcx, const Word16 gain_tcx_e, const Word16 *prm_sqQ, @@ -515,10 +515,15 @@ void stereo_dft_dec_analyze_fx( Word16 *q, Word16 *q_out_DFT ); +void init_basic_allpass_fx( + basic_allpass_t *ap, + const Word32 *gains_fx, + const Word16 *delays ); + void filter_with_allpass_fx( const Word32 *sig, /* i : allpass input signal */ Word32 *out, /* o : filtered output */ - const int16_t len, /* i : length of input */ + const Word16 len, /* i : length of input */ basic_allpass_t *ap, /* i/o: basic allpass structure */ Word16 q_shift ); @@ -526,7 +531,7 @@ void filter_with_allpass_fx( Word32 stereo_dft_dmx_swb_nrg_fx( const Word32 *dmx_k0, /* i : first subframe spectrum */ const Word32 *dmx_k1, /* i : second subframe spectrum */ - const int16_t frame_length, /* i : frame lanegth */ + const Word16 frame_length, /* i : frame lanegth */ const Word16 q0, const Word16 q1 ); @@ -1300,8 +1305,8 @@ void add_HB_to_mono_dmx_fx( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ Word32 output[L_FRAME48k], /* i/o: output synthesis */ Word32 outputHB[L_FRAME48k], /* i : HB synthesis */ - const int16_t last_core, /* i : last core, primary channel */ - const int16_t output_frame /* i : frame length */ + const Word16 last_core, /* i : last core, primary channel */ + const Word16 output_frame /* i : frame length */ ); void stereo_dft_dmx_out_reset_fx( @@ -1383,25 +1388,25 @@ void ivas_mdct_core_tns_ns_fx( void decoder_tcx_imdct_fx( Decoder_State *st, /* i/o: coder memory state */ - const int16_t L_frame_glob, /* i : frame length */ - const int16_t L_frameTCX_glob, - const int16_t L_spec, - const int16_t tcx_offset, - const int16_t tcx_offsetFB, - const int16_t L_frame, - const int16_t L_frameTCX, - const int16_t left_rect, + const Word16 L_frame_glob, /* i : frame length */ + const Word16 L_frameTCX_glob, + const Word16 L_spec, + const Word16 tcx_offset, + const Word16 tcx_offsetFB, + const Word16 L_frame, + const Word16 L_frameTCX, + const Word16 left_rect, Word32 x_fx[N_MAX], Word16 q_x, Word16 xn_buf_fx[], Word16 q_win, - const uint16_t kernelType, /* i : TCX transform kernel type */ - const int16_t fUseTns, /* i : flag that is set if TNS data is present */ + const UWord16 kernelType, /* i : TCX transform kernel type */ + const Word16 fUseTns, /* i : flag that is set if TNS data is present */ Word16 synth_fx[], /* i/o: synth[-M..L_frame] */ Word16 synthFB_fx[], - const int16_t bfi, /* i : Bad frame indicator */ - const int16_t frame_cnt, /* i : frame counter in the super frame */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ + const Word16 bfi, /* i : Bad frame indicator */ + const Word16 frame_cnt, /* i : frame counter in the super frame */ + const Word16 sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ ); void ivas_sba_dirac_stereo_dec_fx( diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 753f3cd1052c43482c6df48eb2476e3696da62c4..fe2454d6c3aa4c275ffc7a963c4653ea3721f92b 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -709,15 +709,15 @@ typedef struct ivas_filters_process_state_t { int16_t order; int16_t filt_len; - float num[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; - float den[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; - float state[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; #ifdef IVAS_FLOAT_FIXED Word32 num_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word32 den_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word32 state_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word32 state_fx_q_factor[IVAS_FILTER_MAX_STAGES]; #endif + float num[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; + float den[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; + float state[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; } ivas_filters_process_state_t; diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index d8c97fabfab68050def18f3b38714ea8f3791f9d..b45e9fd7e4309e2602da1053004d6f2ccc31624b 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -211,7 +211,7 @@ ivas_error acelp_core_dec_ivas_fx( for ( int p = 0; p < ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); p++ ) { - st->hFdCngDec->bandNoiseShape[p] = (Word32) ( st->hFdCngDec->bandNoiseShape_float[p] * ( 1u << ( 31 - st->hFdCngDec->bandNoiseShape_exp ) ) ); + //st->hFdCngDec->bandNoiseShape[p] = (Word32) ( st->hFdCngDec->bandNoiseShape_float[p] * ( 1u << ( 31 - st->hFdCngDec->bandNoiseShape_exp ) ) ); } ApplyFdCng_fx( NULL, 0, NULL, 0, NULL, NULL, NULL, st, 0, 0 ); @@ -732,7 +732,7 @@ ivas_error acelp_core_dec_ivas_fx( /* local float2fix (to be removed) */ for ( int p = 0; p < ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); p++ ) { - st->hFdCngDec->bandNoiseShape[p] = (Word32) ( st->hFdCngDec->bandNoiseShape_float[p] * ( 1u << ( 31 - st->hFdCngDec->bandNoiseShape_exp ) ) ); + //st->hFdCngDec->bandNoiseShape[p] = (Word32) ( st->hFdCngDec->bandNoiseShape_float[p] * ( 1u << ( 31 - st->hFdCngDec->bandNoiseShape_exp ) ) ); } Word16 new_sidNoiseEstExp = 31 - Q4; Scale_sig32(st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, st->hFdCngDec->hFdCngCom->sidNoiseEstExp - new_sidNoiseEstExp); @@ -1754,7 +1754,6 @@ ivas_error acelp_core_dec_ivas_fx( #ifndef IVAS_FLOAT_FIXED generate_stereo_masking_noise(syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out); #else - //generate_stereo_masking_noise_fx(syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out); generate_stereo_masking_noise_16fx(psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out); #endif hStereoCng->flag_cna_fade = 0; @@ -1771,7 +1770,6 @@ ivas_error acelp_core_dec_ivas_fx( #ifndef IVAS_FLOAT_FIXED generate_stereo_masking_noise(syn, st, hStereoTD, flag_sec_CNA, 0, hStereoCng, nchan_out); #else - //generate_stereo_masking_noise_fx(syn, st, hStereoTD, flag_sec_CNA, 0, hStereoCng, nchan_out); generate_stereo_masking_noise_16fx(psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 0, hStereoCng, nchan_out); #endif } @@ -1797,7 +1795,6 @@ ivas_error acelp_core_dec_ivas_fx( #ifndef IVAS_FLOAT_FIXED generate_stereo_masking_noise(syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out); #else - //generate_stereo_masking_noise_fx(syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out); generate_stereo_masking_noise_16fx(psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out); #endif hStereoCng->flag_cna_fade = 1; @@ -2631,7 +2628,7 @@ void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HANDLE hSte //FdCng if ( st->hFdCngDec ) { - floatToFixed_arrL( st->hFdCngDec->hFdCngCom->sidNoiseEstLp_flt, st->hFdCngDec->hFdCngCom->sidNoiseEstLp, Q31 - st->hFdCngDec->hFdCngCom->sidNoiseEstExp, NPART ); + //floatToFixed_arrL( st->hFdCngDec->hFdCngCom->sidNoiseEstLp_flt, st->hFdCngDec->hFdCngCom->sidNoiseEstLp, Q31 - st->hFdCngDec->hFdCngCom->sidNoiseEstExp, NPART ); st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = Q31 - 4; floatToFixed_arrL(st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, Q31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN); floatToFixed_arr(st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, Q12, M + 1); @@ -2640,7 +2637,7 @@ void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HANDLE hSte floatToFixed_arr(st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->fftlenShift, FFTLEN); //st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = float_to_fix16(st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt, Q15); - floatToFixed_arrL( st->hFdCngDec->bandNoiseShape_float, st->hFdCngDec->bandNoiseShape, Q31 - st->hFdCngDec->bandNoiseShape_exp, FFTLEN2); + //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) { @@ -2649,13 +2646,13 @@ void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HANDLE hSte if (st->element_mode != IVAS_CPE_TD && !st->cng_ism_flag) { st->hFdCngDec->hFdCngCom->fftBuffer_exp = st->hFdCngDec->msNoiseEst_exp = Q31 - Q4; //st->hFdCngDec->hFdCngCom->periodog_exp = st->hFdCngDec->msPsd_exp_fft = st->hFdCngDec->msPeriodog_exp = st->hFdCngDec->msPeriodog_ST_exp = 31 - Q4; Q4 - floatToFixed_arrL(st->hFdCngDec->hFdCngCom->fftBuffer_flt, st->hFdCngDec->hFdCngCom->fftBuffer, Q31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp, st->hFdCngDec->hFdCngCom->fftlen); + //floatToFixed_arrL(st->hFdCngDec->hFdCngCom->fftBuffer_flt, st->hFdCngDec->hFdCngCom->fftBuffer, Q31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp, st->hFdCngDec->hFdCngCom->fftlen); floatToFixed_arrL(st->hFdCngDec->msNoiseEst_float, st->hFdCngDec->msNoiseEst, Q31 - st->hFdCngDec->msNoiseEst_exp, st->hFdCngDec->npart_shaping); - - if (st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT) - { - floatToFixed_arrL(st->hFdCngDec->smoothed_psd, st->hFdCngDec->smoothed_psd_fx, Q31 - st->hFdCngDec->msNoiseEst_exp, L_FRAME16k - st->hFdCngDec->hFdCngCom->startBand); - } + + //if (st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT) + //{ + //floatToFixed_arrL(st->hFdCngDec->smoothed_psd, st->hFdCngDec->smoothed_psd_fx, Q31 - /*st->hFdCngDec->msNoiseEst_exp*/ Q27, L_FRAME16k - st->hFdCngDec->hFdCngCom->startBand); + //} } } } @@ -2697,13 +2694,13 @@ void acelp_decoder_state_fix2float(Decoder_State *st, STEREO_CNG_DEC_HANDLE hSte //FdCng if ( st->hFdCngDec ) { - fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->sidNoiseEstLp, st->hFdCngDec->hFdCngCom->sidNoiseEstLp_flt, Q31 - st->hFdCngDec->hFdCngCom->sidNoiseEstExp, NPART); + //fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->sidNoiseEstLp, st->hFdCngDec->hFdCngCom->sidNoiseEstLp_flt, Q31 - st->hFdCngDec->hFdCngCom->sidNoiseEstExp, NPART); fixedToFloat_arrL( st->hFdCngDec->hFdCngCom->cngNoiseLevel, st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, Q31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN ); fixedToFloat_arr( st->hFdCngDec->hFdCngCom->A_cng, st->hFdCngDec->hFdCngCom->A_cng_flt, Q12, M + 1 ); fixedToFloat_arr(st->hFdCngDec->hFdCngCom->exc_cng, st->hFdCngDec->hFdCngCom->exc_cng_flt, st->Q_exc_cng, L_FRAME16k); fixedToFloat_arr(st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, st->hFdCngDec->hFdCngCom->fftlenShift, FFTLEN); //st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt = fixedToFloat(st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, Q15); - fixedToFloat_arrL(st->hFdCngDec->bandNoiseShape, st->hFdCngDec->bandNoiseShape_float, Q31 - st->hFdCngDec->bandNoiseShape_exp, FFTLEN2); + //fixedToFloat_arrL(st->hFdCngDec->bandNoiseShape, st->hFdCngDec->bandNoiseShape_float, Q31 - st->hFdCngDec->bandNoiseShape_exp, FFTLEN2); //fixedToFloat_arrL(st->hFdCngDec->partNoiseShape, st->hFdCngDec->partNoiseShape_float, Q31 - st->hFdCngDec->partNoiseShape_exp, NPART); /*CNA: ApplyFdCng*/ if ((st->hFdCngDec != NULL || st->idchan == 1) && st->element_mode != IVAS_CPE_MDCT) @@ -2723,15 +2720,15 @@ void acelp_decoder_state_fix2float(Decoder_State *st, STEREO_CNG_DEC_HANDLE hSte ) { //fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->periodog, st->hFdCngDec->hFdCngCom->periodog_flt, Q31 - st->hFdCngDec->hFdCngCom->periodog_exp, PERIODOGLEN); - fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->fftBuffer, st->hFdCngDec->hFdCngCom->fftBuffer_flt, Q31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp, st->hFdCngDec->hFdCngCom->fftlen); + //fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->fftBuffer, st->hFdCngDec->hFdCngCom->fftBuffer_flt, Q31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp, st->hFdCngDec->hFdCngCom->fftlen); fixedToFloat_arrL(st->hFdCngDec->msNoiseEst, st->hFdCngDec->msNoiseEst_float, Q31 - st->hFdCngDec->msNoiseEst_exp, st->hFdCngDec->npart_shaping); // fixedToFloat_arrL(st->hFdCngDec->msPeriodog, st->hFdCngDec->msPeriodog_float, Q31 - st->hFdCngDec->msPeriodog_exp, st->hFdCngDec->npart_shaping); //fixedToFloat_arrL(st->hFdCngDec->msPeriodog_ST_fx, st->hFdCngDec->msPeriodog_ST, Q31 - st->hFdCngDec->msPeriodog_ST_exp, st->hFdCngDec->npart_shaping); - if (st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT) - { - fixedToFloat_arrL(st->hFdCngDec->smoothed_psd_fx, st->hFdCngDec->smoothed_psd, Q31 - st->hFdCngDec->msNoiseEst_exp, L_FRAME16k - st->hFdCngDec->hFdCngCom->startBand); - } + //if (st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT) + //{ + //fixedToFloat_arrL(st->hFdCngDec->smoothed_psd_fx, st->hFdCngDec->smoothed_psd, Q31 - st->hFdCngDec->msNoiseEst_exp, L_FRAME16k - st->hFdCngDec->hFdCngCom->startBand); + //} if (!((st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT) && (st->hFdCngDec->hFdCngCom->active_frame_counter > 0))) { st->hTcxDec->CngLevelBackgroundTrace_bfi = fixedToFloat(st->hTcxDec->CngLevelBackgroundTrace_bfi_fx, (31 - st->hTcxDec->CngLevelBackgroundTrace_bfi_exp)); @@ -2762,4 +2759,4 @@ static void rescale_fdCngDec(HANDLE_FD_CNG_DEC hFdCngDec, Word16 Exp_diff) { hFdCngDec->hFdCngCom->cngNoiseLevelExp += Exp_diff;*/ } -#endif \ No newline at end of file +#endif diff --git a/lib_dec/arith_coder_dec.c b/lib_dec/arith_coder_dec.c index 5c16c17cc96df985c994b94f80c7f381137c9cfb..90ed66764d2c81124e67ba7cd29b270c46b89ac5 100644 --- a/lib_dec/arith_coder_dec.c +++ b/lib_dec/arith_coder_dec.c @@ -44,6 +44,7 @@ #include "basop_proto_func.h" #include "wmc_auto.h" #include "prot_fx1.h" +#include "prot_fx2.h" /*-------------------------------------------------------* * tcx_arith_decode_flt() @@ -385,7 +386,7 @@ void tcx_arith_decode_envelope_fx( } envelope = (Word16 *) env; - tcx_arith_scale_envelope_flt( L_spec, L_spec_core, env, target_bits, low_complexity, envelope, &envelope_e ); + tcx_arith_scale_envelope( L_spec, L_spec_core, env, target_bits, low_complexity, envelope, &envelope_e ); *arith_bits = tcx_arith_decode_fx( L_spec, envelope, envelope_e, target_bits, prm, q_spectrum, q_spectrum_e ); move16(); diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index 8efdf9c406bae318f334348e2a36a892f95e3a79..704f7cee1266831bad8822ff902c3801f88aa06a 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -1840,12 +1840,6 @@ void open_decoder_LPD_ivas_fx( st->hTonalMDCTConc->lastBlockData.tonalConcealmentActive = 0; st->hTonalMDCTConc->lastBlockData.nSamples = 0; TonalMDCTConceal_Init_ivas_fx( st->hTonalMDCTConc, st->hTcxDec->L_frameTCX, st->L_frame, FDNS_NPTS, st->hTcxCfg ); - // To be removed later: Float pointer initiaizations----------------- - st->hTonalMDCTConc->lastBlockData.spectralData_float = st->hTonalMDCTConc->spectralDataBuffers_float[0]; - st->hTonalMDCTConc->secondLastBlockData.spectralData_float = st->hTonalMDCTConc->spectralDataBuffers_float[1]; - st->hTonalMDCTConc->secondLastPowerSpectrum_float = st->hTonalMDCTConc->secondLastBlockData.spectralData_float; - st->hTonalMDCTConc->lastBlockData.scaleFactors_float = st->hTonalMDCTConc->scaleFactorsBuffers_float[0]; - st->hTonalMDCTConc->secondLastBlockData.scaleFactors_float = st->hTonalMDCTConc->scaleFactorsBuffers_float[1]; #if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) //st->hTonalMDCTConc->pTCI = (TonalComponentsInfo *) st->hTonalMDCTConc->timeDataBuffer_float; st->hTonalMDCTConc->pTCI = &st->hTonalMDCTConc->pTCI1; diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 1e729c7d907f67d4402001ea5b5a89e484dce468..81d9add2ec81f878573a3d0d61965d1250c53a2e 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -4352,7 +4352,6 @@ void decoder_tcx_noisefilling_fx( } nf_seed = extract_l( tmp32 ); } - pInfoTCXNoise = NULL; #ifndef FIX_ISSUE_723_INFO_TCX_NOISE Word16 tmp_infoTCXNoiseBuf[IGF_START_MX]; @@ -4524,7 +4523,6 @@ void decoder_tcx_noisefilling_fx( { move16(); st->hTonalMDCTConc->lastBlockData.spectralData[i] = st->hTonalMDCTConc->lastBlockData.spectralData[i + 1]; - st->hTonalMDCTConc->lastBlockData.spectralData_float[i] = st->hTonalMDCTConc->lastBlockData.spectralData_float[i + 1]; } } ELSE IF( LT_16( tmp1, ONE_IN_Q12 ) ) /*0.5 in Q13 = 1 in Q12*/ @@ -4533,7 +4531,6 @@ void decoder_tcx_noisefilling_fx( { move16(); st->hTonalMDCTConc->lastBlockData.spectralData[i + 1] = st->hTonalMDCTConc->lastBlockData.spectralData[i]; - st->hTonalMDCTConc->lastBlockData.spectralData_float[i + 1] = st->hTonalMDCTConc->lastBlockData.spectralData_float[i]; } } } diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index d0fc708eb3b8fc62ccc4b6a40a224ea38587149e..d2c8860ad6afaefc374bae559b777dfef6e3f830 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -165,8 +165,8 @@ void initFdCngDec_flt( #endif hFdCngDec->nFFTpart_shaping = 0; - set_f( hFdCngDec->hFdCngCom->sidNoiseEstLp_flt, 0.0f, NPART ); #if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) + set_f( hFdCngDec->hFdCngCom->sidNoiseEstLp_flt, 0.0f, NPART ); set_f( hFdCngDec->smoothed_psd, 0.0f, L_FRAME16k ); set_f( hFdCngDec->msPeriodog_ST, 0.0f, NPART_SHAPING ); #endif @@ -2287,7 +2287,7 @@ void generate_masking_noise_mdct_flt( return; } -#endif + /*------------------------------------------------------------------- * generate_stereo_masking_noise() * @@ -2411,183 +2411,8 @@ void generate_stereo_masking_noise( return; } - +#endif #ifdef IVAS_FLOAT_FIXED -/*------------------------------------------------------------------- - * generate_stereo_masking_noise_fx() - * - * Generate additional comfort noise (kind of noise filling) - *-------------------------------------------------------------------*/ - -void generate_stereo_masking_noise_fx( - float *syn, /* i/o: time-domain signal */ - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */ - const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ - const int16_t fadeOut, /* i : only fade out of previous state */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ - const int16_t nchan_out /* i : number of output channels */ -) -{ - HANDLE_FD_CNG_COM hFdCngCom; - Word32 gamma_fx, scale_fx /*, SP_ratio_fx needs to be integrated*/; - Word32 Np_fx[L_FRAME16k]; - Word32 Ns_fx[L_FRAME16k]; - Word32 N1_fx[L_FRAME16k]; - Word32 N2_fx[L_FRAME16k]; - Word16 N1_fx_exp, N2_fx_exp; - int16_t i; - - IF( st->idchan == 0 ) - { - hFdCngCom = st->hFdCngDec->hFdCngCom; - // mvr2r(hStereoCng->olapBufferSynth22, Ns, hFdCngCom->frameSize / 2); - // mvr2r(hFdCngCom->olapBufferSynth2_flt, Np, hFdCngCom->frameSize / 2); - for ( i = 0; i < hFdCngCom->frameSize / 2; i++ ) - { - Ns_fx[i] = float_to_fix( hStereoCng->olapBufferSynth22[i], Q6 ); - Np_fx[i] = float_to_fix( hFdCngCom->olapBufferSynth2_flt[i], Q6 ); - } - set_l( &Np_fx[hFdCngCom->frameSize / 2], 0, hFdCngCom->frameSize / 2 ); - set_l( &Ns_fx[hFdCngCom->frameSize / 2], 0, hFdCngCom->frameSize / 2 ); - - IF( !fadeOut ) - { - // generate_masking_noise_flt(N1, hFdCngCom, hFdCngCom->frameSize, 0, 1, 0, st->element_mode, hStereoCng, nchan_out); - generate_masking_noise_ivas_fx( N1_fx, &N1_fx_exp, hFdCngCom, hFdCngCom->frameSize, 0, 1, 0, st->element_mode, hStereoCng, nchan_out ); // N1_fx Q6 - /* Generate masking noise for secondary channel */ - IF( flag_sec_CNA ) - { - // generate_masking_noise_flt(N2, hFdCngCom, hFdCngCom->frameSize, 0, 1, 1, st->element_mode, hStereoCng, nchan_out); - generate_masking_noise_ivas_fx( N2_fx, &N2_fx_exp, hFdCngCom, hFdCngCom->frameSize, 0, 1, 1, st->element_mode, hStereoCng, nchan_out ); // N2_fx Q6 - // gamma = hStereoCng->c_PS_LT * hStereoCng->c_PS_LT; - gamma_fx = float_to_fix( hStereoCng->c_PS_LT * hStereoCng->c_PS_LT, Q30 ); - // scale = 1.0f; - scale_fx = ONE_IN_Q30; - // if (gamma < 0.9f) - IF( gamma_fx < 966367642 ) - { - // gamma = gamma / (1 - gamma); - // gamma = (float)sqrt(gamma + 1) - (float)sqrt(gamma); - // scale = 1.0f / (float)sqrt(1 + gamma * gamma); - Word16 exp_gamma = 0; - Word16 divisor1 = Inv16( (Word16) L_shr( L_sub( ONE_IN_Q30, gamma_fx ), Q15 ), &exp_gamma ); // Q15-exp_gamma - gamma_fx = L_shl( Mpy_32_16_1( gamma_fx, divisor1 ), exp_gamma ); // Q30 - Word16 exp_gamma1 = Q1, exp_gamma2 = Q1, exp_gamma3 = Q1; - gamma_fx = Sqrt32( L_add( gamma_fx, ONE_IN_Q30 ), &exp_gamma1 ); - // gamma_fx = L_shl( gamma_fx, exp_gamma1 ); - Word32 temp = Sqrt32( gamma_fx, &exp_gamma2 ); // Q31-exp_gamma1 - gamma_fx = L_sub( gamma_fx, L_shl( temp, exp_gamma2 - exp_gamma1 ) ); // Q31-exp_gamma1 - gamma_fx = L_shl( gamma_fx, exp_gamma1 - Q1 ); // Q30 - Word32 divisor2 = Sqrt32( L_add( ONE_IN_Q30, L_shl( Mpy_32_32( gamma_fx, gamma_fx ), Q1 ) ), &exp_gamma3 ); // Q31 - exp_gamma3 - scale_fx = L_shl( divide3232( ONE_IN_Q30, divisor2 ), Q15 + exp_gamma3 ); // Q30 - } - ELSE - { - gamma_fx = 0; - } - - FOR( i = 0; i < 2 * hFdCngCom->frameSize / 4; i++ ) - { - // Np[i] += scale * (N1[i] + gamma * N2[i]); - // Ns[i] += scale * sign(hStereoCng->c_PS_LT) * (N1[i] - gamma * N2[i]); - Np_fx[i] = L_add( Np_fx[i], - Mpy_32_32( scale_fx, L_shl( L_add( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ) ); // Q6 - Word32 add2 = Mpy_32_32( scale_fx, L_shl( L_sub( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6 - if ( hStereoCng->c_PS_LT < 0.0f ) - { - add2 = L_negate( add2 ); - } - Ns_fx[i] = L_add( Ns_fx[i], add2 ); - } - FOR( ; i < hFdCngCom->frameSize; i++ ) - { - // Np[i] = scale * (N1[i] + gamma * N2[i]); - // Ns[i] = scale * sign(hStereoCng->c_PS_LT) * (N1[i] - gamma * N2[i]); - Np_fx[i] = Mpy_32_32( scale_fx, L_shl( L_add( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6 - Ns_fx[i] = Mpy_32_32( scale_fx, L_shl( L_sub( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6 - IF( hStereoCng->c_PS_LT < 0.0f ) - { - Ns_fx[i] = L_negate( Ns_fx[i] ); - } - } - /* Below code to be converted */ - float gamma = fix_to_float( gamma_fx, Q30 ); - float scale = fix_to_float( scale_fx, Q30 ); - scale *= (float) ( hFdCngCom->fftlen / 2 ); - // scale_fx = L_shr(scale_fx, Q1) * hFdCngCom->fftlen; - for ( i = 0; i < hFdCngCom->frameSize / 2; i++ ) - { - hFdCngCom->olapBufferSynth2_flt[i] = scale * ( hFdCngCom->olapBufferSynth2_flt[i + 5 * hFdCngCom->frameSize / 4] + gamma * hStereoCng->olapBufferSynth22[i + 5 * hFdCngCom->frameSize / 4] ); - hStereoCng->olapBufferSynth22[i] = sign( hStereoCng->c_PS_LT ) * scale * ( hFdCngCom->olapBufferSynth2_flt[i + 5 * hFdCngCom->frameSize / 4] - gamma * hStereoCng->olapBufferSynth22[i + 5 * hFdCngCom->frameSize / 4] ); - } - } - else - { - FOR( i = 0; i < hFdCngCom->frameSize / 2; i++ ) - { - // Np[i] += N1[i]; - Np_fx[i] = L_add( Np_fx[i], N1_fx[i] ); // Q6 - } - // mvr2r(&N1[hFdCngCom->frameSize / 2], &Np[hFdCngCom->frameSize / 2], hFdCngCom->frameSize / 2); - mvl2l( &N1_fx[hFdCngCom->frameSize / 2], &Np_fx[hFdCngCom->frameSize / 2], hFdCngCom->frameSize / 2 ); - float scale = (float) ( hFdCngCom->fftlen / 2 ); - for ( i = 0; i < hFdCngCom->frameSize; i++ ) - { - hFdCngCom->olapBufferSynth2_flt[i] = scale * hFdCngCom->olapBufferSynth2_flt[i + 5 * hFdCngCom->frameSize / 4]; - } - } - } - else - { - set_f( hFdCngCom->olapBufferSynth2_flt, 0.0f, hFdCngCom->frameSize / 2 ); - set_f( hStereoCng->olapBufferSynth22, 0.0f, hFdCngCom->frameSize / 2 ); - } - if ( flag_sec_CNA ) - { - // mvr2r(Ns, hStereoCng->maskingNoiseS, hFdCngCom->frameSize); - for ( i = 0; i < hFdCngCom->frameSize; i++ ) - { - hStereoCng->maskingNoiseS[i] = fix_to_float( Ns_fx[i], Q6 ); - } - hStereoCng->enableSecCNA = 1; - } - else - { - set_f( hStereoCng->olapBufferSynth22, 0.0f, hFdCngCom->frameSize ); - } - - /* add masking noise */ - // v_add(Np, syn, syn, hFdCngCom->frameSize); - for ( i = 0; i < hFdCngCom->frameSize; i++ ) - { - syn[i] = syn[i] + fix_to_float( Np_fx[i], Q6 ); - } - } - else if ( hStereoCng->enableSecCNA ) - { - float SP_ratio = hStereoTD->SP_ratio_LT; /* Use long-term SP ratio based on L/R synthesis */ - /* scale and add masking noise */ - for ( i = 0; i < *hStereoCng->frameSize / 4; i++ ) - { - float scale = ( ( hStereoTD->prevSP_ratio * ( *hStereoCng->frameSize / 4 - (float) i ) + SP_ratio * (float) i ) / ( *hStereoCng->frameSize / 4 ) ); - syn[i] += scale * hStereoCng->maskingNoiseS[i]; - } - for ( ; i < *hStereoCng->frameSize / 2; i++ ) - { - syn[i] += SP_ratio * hStereoCng->maskingNoiseS[i]; - } - for ( ; i < *hStereoCng->frameSize; i++ ) - { - syn[i] += SP_ratio * hStereoCng->maskingNoiseS[i]; - } - hStereoTD->prevSP_ratio = SP_ratio; - } - - return; -} - - /*------------------------------------------------------------------- * generate_stereo_masking_noise_16fx() * @@ -2780,7 +2605,7 @@ void generate_stereo_masking_noise_16fx( return; } #endif - +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) /*------------------------------------------------------------------- * generate_masking_noise_hf_cldfb() * @@ -2879,37 +2704,7 @@ void generate_masking_noise_lb_dirac( fftBuffer[1] = 0.f; /* Perform STFT synthesis */ -#ifdef IVAS_FLOAT_FIXED - Word32 fftBuffer_fx[FFTLEN], timeDomainBuffer_fx[L_FRAME16k]; - Word16 exp = Q14; - for (i = 0; i < hFdCngCom->fftlen; i++) - { - fftBuffer_fx[i] = float_to_fix(fftBuffer[i], exp); - } - for (i = 0; i < hFdCngCom->fftlen; i++) - { - hFdCngCom->olapBufferSynth2_fx[i] = float_to_fix(hFdCngCom->olapBufferSynth2_flt[i], exp); - } - - SynthesisSTFT_dirac_fx(fftBuffer_fx, timeDomainBuffer_fx + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom); - - for (i = 0; i < hFdCngCom->fftlen; i++) - { - hFdCngCom->olapBufferSynth2_flt[i] = fix_to_float(hFdCngCom->olapBufferSynth2_fx[i], exp); - } - exp = exp - 9; - for (i = 0; i < hFdCngCom->frameSize; i++) - { - tdBuffer[i] = fix_to_float(timeDomainBuffer_fx[i], exp); - } - - for (i = 0; i < hFdCngCom->frameSize; i++) - { - hFdCngCom->exc_cng_flt[i] = fix_to_float(hFdCngCom->exc_cng_32fx[i], exp); - } -#else SynthesisSTFT_dirac_flt( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_flt, hFdCngCom->olapWinSyn_flt, n_samples_out_loop, hFdCngCom ); -#endif } @@ -2921,37 +2716,7 @@ void generate_masking_noise_lb_dirac( set_f( fftBuffer, 0.f, hFdCngCom->fftlen ); /* Perform STFT synthesis */ -#ifdef IVAS_FLOAT_FIXED - Word32 fftBuffer_fx[FFTLEN], timeDomainBuffer_fx[L_FRAME16k]; - Word16 exp = Q14; - for (i = 0; i < hFdCngCom->fftlen; i++) - { - fftBuffer_fx[i] = float_to_fix(fftBuffer[i], exp); - } - for (i = 0; i < hFdCngCom->fftlen; i++) - { - hFdCngCom->olapBufferSynth2_fx[i] = float_to_fix(hFdCngCom->olapBufferSynth2_flt[i], exp); - } - - SynthesisSTFT_dirac_fx(fftBuffer_fx, timeDomainBuffer_fx + n_samples_start, hFdCngCom->olapBufferSynth2_fx, (Word16 *)hFdCngCom->olapWinSyn, n_samples_out_loop, hFdCngCom); - - for (i = 0; i < hFdCngCom->fftlen; i++) - { - hFdCngCom->olapBufferSynth2_flt[i] = fix_to_float(hFdCngCom->olapBufferSynth2_fx[i], exp); - } - exp = exp - 9; - for (i = 0; i < hFdCngCom->frameSize; i++) - { - tdBuffer[i] = fix_to_float(timeDomainBuffer_fx[i], exp); - } - - for (i = 0; i < hFdCngCom->frameSize; i++) - { - hFdCngCom->exc_cng_flt[i] = fix_to_float(hFdCngCom->exc_cng_32fx[i], exp); - } -#else SynthesisSTFT_dirac_flt( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_flt, hFdCngCom->olapWinSyn_flt, n_samples_out_loop, hFdCngCom ); -#endif } n_samples_out -= hFdCngCom->frameSize; @@ -2963,7 +2728,7 @@ void generate_masking_noise_lb_dirac( return; } - +#endif #ifdef IVAS_FLOAT_FIXED void generate_masking_noise_lb_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 5743b96d9f22ac92a89f30d9dc11d8880f37a991..c71f52d6e0bc1f61367df44ee9e56672a4c4b3a0 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -150,7 +150,7 @@ void ivas_initFdCngDec_fx( hFdCngDec->hFdCngCom->periodog_exp = 0; move16(); set32_fx( hFdCngDec->smoothed_psd_fx, 0, L_FRAME16k ); - + hFdCngDec->q_smoothed_psd = Q4; set32_fx( hFdCngDec->hFdCngCom->sidNoiseEstLp, 0, NPART ); hFdCngDec->ms_last_inactive_bwidth = NB; @@ -263,6 +263,7 @@ void initFdCngDec( hFdCngDec->hFdCngCom->fftBuffer_exp = 0; hFdCngDec->hFdCngCom->periodog_exp = 0; set32_fx(hFdCngDec->smoothed_psd_fx, 0, L_FRAME16k); + hFdCngDec->q_smoothed_psd = Q4; #ifdef IVAS_CODE_CNG set_f(hFdCngDec->hFdCngCom->sidNoiseEstLp, 0.0f, NPART); @@ -2787,6 +2788,7 @@ void perform_noise_estimation_dec_fx( scalebands_fx( msNoiseEst, part, nFFTpart, hFdCngDec->midband_shaping, nFFTpart, sub( stopFFTbin, startBand ), hFdCngDec->bandNoiseShape, 1 ); hFdCngDec->bandNoiseShape_exp = hFdCngDec->msNoiseEst_exp; Copy32( hFdCngDec->bandNoiseShape, &hFdCngDec->smoothed_psd_fx[startBand], sub( stopFFTbin, startBand ) ); + hFdCngDec->q_smoothed_psd = sub(Q31, hFdCngDec->bandNoiseShape_exp); set32_fx( &hFdCngDec->smoothed_psd_fx[stopFFTbin], 0, sub( L_FRAME16k, stopFFTbin ) ); } ELSE diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 7ad048e8df20b90c343a3adaeb3b0a9374aaf879..5ce6305013aad325bc5029c42a0b42bc37f497a1 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -1429,7 +1429,7 @@ ivas_error init_decoder_ivas_fx( if ( st_fx->ivas_format != ISM_FORMAT ) { st_fx->old_bwe_delay = -1; - set_f(st_fx->hb_prev_synth_buffer, 0, NS2SA(48000, DELAY_BWE_TOTAL_NS)); + //set_f(st_fx->hb_prev_synth_buffer, 0, NS2SA(48000, DELAY_BWE_TOTAL_NS)); } #endif st_fx->old_bwe_delay = -1; /*Q0*/ move16(); diff --git a/lib_dec/ivas_agc_dec.c b/lib_dec/ivas_agc_dec.c index 1da6f64cefbfba764a7e908c11f63ad1f2b4e94c..83a2147632fb5d79ff12e48b1103bc960402bad2 100644 --- a/lib_dec/ivas_agc_dec.c +++ b/lib_dec/ivas_agc_dec.c @@ -32,6 +32,7 @@ #include #include "options.h" +#ifndef IVAS_FLOAT_FIXED #include "prot.h" #include "ivas_prot.h" #include @@ -39,7 +40,6 @@ #include "wmc_auto.h" - /*-----------------------------------------------------------------------------------------* * Function ivas_agc_dec_init() * @@ -275,3 +275,4 @@ void ivas_agc_read_bits( return; } +#endif diff --git a/lib_dec/ivas_agc_dec_fx.c b/lib_dec/ivas_agc_dec_fx.c index c328a9d6de1952171aa741b38fd4fb633e242404..eea0759b001dbbff9b21f8fea564d32aeedd6300 100644 --- a/lib_dec/ivas_agc_dec_fx.c +++ b/lib_dec/ivas_agc_dec_fx.c @@ -60,7 +60,9 @@ static void ivas_agc_dec_init_fx( ivas_agc_chan_data_t *ptr = hAgcDec->gain_data; hAgcDec->agc_com.in_delay = delay; + move16(); hAgcDec->agc_com.num_coeff = IVAS_SPAR_MAX_DMX_CHS; + move16(); ivas_agc_calcGainParams_fx( &hAgcDec->agc_com.absEmin, &hAgcDec->agc_com.betaE, &hAgcDec->agc_com.maxAttExp, hAgcDec->agc_com.num_coeff ); ivas_agc_initWindowFunc_fx( hAgcDec->agc_com.winFunc_fx, output_frame - hAgcDec->agc_com.in_delay ); @@ -69,12 +71,16 @@ static void ivas_agc_dec_init_fx( { /* gain_state */ ptrG->lastGain_fx = MAX_16; + move16(); ptrG->gainExpVal = 0; + move16(); ptrG++; /* gain_data */ ptr->absGainExp = hAgcDec->agc_com.absEmin; + move16(); ptr->absGainExpCurr = hAgcDec->agc_com.absEmin; + move16(); ptr++; } @@ -101,8 +107,9 @@ ivas_error ivas_spar_agc_dec_open_fx( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for AGC decoder" ); } - output_frame = (Word16) Mpy_32_16_1( output_Fs, INV_FRAME_PER_SEC_Q15 ); + output_frame = extract_l( Mpy_32_16_1( output_Fs, INV_FRAME_PER_SEC_Q15 ) ); delay = NS2SA_fx2( output_Fs, ( IVAS_ENC_DELAY_NS + IVAS_DEC_DELAY_NS ) ); + move16(); IF( ( hAgc->agc_com.winFunc_fx = (Word16 *) malloc( sizeof( Word16 ) * ( output_frame - delay ) ) ) == NULL ) { @@ -139,6 +146,7 @@ void ivas_spar_agc_dec_close_fx( { ivas_agc_dec_state_t *hAgc; + test(); IF( hAgcDec == NULL || *hAgcDec == NULL ) { return; @@ -182,16 +190,18 @@ void ivas_agc_dec_process_fx( Word16 gainLast, gain; ivas_agc_dec_state_t *pState = hAgcDec; - offset = sub(output_frame, pState->agc_com.in_delay); + offset = sub( output_frame, pState->agc_com.in_delay ); FOR( i = 0; i < n_channels; i++ ) { pState->gain_state[i].gainExpVal = sub( pState->gain_data[i].absGainExp, pState->gain_data[i].absGainExpCurr ); + test(); IF( GT_16( pState->gain_state[i].gainExpVal, ( pState->agc_com.maxAttExp + 1 ) ) || LT_16( pState->gain_state[i].gainExpVal, -1 ) ) { /* Such conditions indicate packet loss, better reset and do nothing*/ - pState->gain_data[i].absGainExp = pState->agc_com.absEmin; move16(); + pState->gain_data[i].absGainExp = pState->agc_com.absEmin; + move16(); pState->gain_state[i].gainExpVal = 0; move16(); } @@ -231,15 +241,17 @@ void ivas_agc_dec_process_fx( { // gain = powf( pState->agc_com.winFunc[idx - pState->agc_com.in_delay], (float) ( -1 * pState->gain_state[i].gainExpVal ) ) * gainLast; - tmp = negate( pState->gain_state[i].gainExpVal ); move16(); + tmp = negate( pState->gain_state[i].gainExpVal ); + move16(); IF( LT_16( tmp, 0 ) ) { - tmp_2 = MAX_16; move16(); + tmp_2 = MAX_16; + move16(); FOR( j = 0; j < negate( tmp ); j++ ) { tmp_2 = mult( pState->agc_com.winFunc_fx[idx - pState->agc_com.in_delay], tmp_2 ); } - IF ( LT_16( tmp_2, 0 ) ) + IF( LT_16( tmp_2, 0 ) ) { tmp_2 = div_l( ONE_IN_Q30, negate( tmp_2 ) ); // Q14 tmp_2 = negate( tmp_2 ); @@ -251,7 +263,8 @@ void ivas_agc_dec_process_fx( } ELSE { - tmp_2 = MAX_16; move16(); + tmp_2 = MAX_16; + move16(); FOR( j = 0; j < ( tmp ); j++ ) { tmp_2 = mult( pState->agc_com.winFunc_fx[idx - pState->agc_com.in_delay], tmp_2 ); @@ -269,10 +282,12 @@ void ivas_agc_dec_process_fx( } // pState->gain_state[i].lastGain *= powf( pState->agc_com.winFunc[offset - 1], (float) pState->gain_state[i].gainExpVal ); - tmp = pState->gain_state[i].gainExpVal; move16(); + tmp = pState->gain_state[i].gainExpVal; + move16(); IF( LT_16( tmp, 0 ) ) { - tmp_2 = MAX_16; move16(); + tmp_2 = MAX_16; + move16(); FOR( idx = 0; idx < negate( tmp ); idx++ ) { tmp_2 = mult( pState->agc_com.winFunc_fx[offset - 1], tmp_2 ); @@ -281,7 +296,8 @@ void ivas_agc_dec_process_fx( } ELSE { - tmp_2 = MAX_16; move16(); + tmp_2 = MAX_16; + move16(); FOR( idx = 0; idx < ( tmp ); idx++ ) { tmp_2 = mult( pState->agc_com.winFunc_fx[offset - 1], tmp_2 ); @@ -298,7 +314,8 @@ void ivas_agc_dec_process_fx( pcm_out[i][idx] = Mpy_32_16_1( pcm_in[i][idx], gain ); // Q_pcm_out = Q_pcm_in - 3 } } - pState->gain_data[i].absGainExp = pState->gain_data[i].absGainExpCurr; move16(); + pState->gain_data[i].absGainExp = pState->gain_data[i].absGainExpCurr; + move16(); } return; diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 525b529c48d35c42fcaafcb03970880c02db3589..675dff48ed2c72697099ee02acb4df38de923fdf 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -95,7 +95,7 @@ ivas_error ivas_core_dec( 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 hb_synth_32_fx[][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 */ ) @@ -153,12 +153,14 @@ ivas_error ivas_core_dec( int32_t element_brate, output_Fs; int32_t last_element_brate; int16_t use_cldfb_for_dft; - float *p_output_mem; + //float *p_output_mem; + Word32 *p_output_mem_fx; int16_t flag_sec_CNA; int16_t read_sid_info; int16_t last_element_mode; int16_t nchan_out; - float *save_hb_synth; + //float *save_hb_synth; + Word32 *save_hb_synth_32_fx; ivas_error error; Word32 L_tmp; Word16 Q_synth; @@ -167,15 +169,20 @@ ivas_error ivas_core_dec( //Word32 output_32_fx[CPE_CHANNELS][L_FRAME48k]; //output_32p_fx[0] = output_32_fx[0]; //output_32p_fx[1] = output_32_fx[1]; + //float hb_synth[CPE_CHANNELS][L_FRAME48k]; + Word16 hb_synth_16_fx[CPE_CHANNELS][L_FRAME48k]; + //Word32 hb_synth_32_fx[CPE_CHANNELS][L_FRAME48k]; + 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 ); + //set16_fx(hb_synth_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 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 synth_16fx[CPE_CHANNELS][L_FRAME48k]; Word32 pitch_buf_32fx[CPE_CHANNELS][NB_SUBFR16k]; @@ -245,7 +252,8 @@ ivas_error ivas_core_dec( last_element_brate = hSCE->last_element_brate; /* note: this parameter is unused */ last_element_mode = IVAS_SCE; hStereoTD = NULL; - p_output_mem = NULL; + //p_output_mem = NULL; + p_output_mem_fx = NULL; nchan_out = 1; IF( st_ivas != NULL && st_ivas->ivas_format == ISM_FORMAT ) { @@ -263,7 +271,11 @@ ivas_error ivas_core_dec( last_element_mode = hCPE->last_element_mode; hStereoICBWE = hCPE->hStereoICBWE; hStereoTD = hCPE->hStereoTD; - p_output_mem = hCPE->output_mem[1]; + //p_output_mem = hCPE->output_mem[1]; + p_output_mem_fx = hCPE->output_mem_fx[1]; + + if(hCPE->output_mem[1] != NULL)floatToFixed_arrL(hCPE->output_mem[1], hCPE->output_mem_fx[1],Q11, NS2SA_fx2(sts[0]->output_Fs, STEREO_DFT32MS_OVL_NS)); + nchan_out = hCPE->nchan_out; IF( hCPE->hStereoTD != NULL ) @@ -343,8 +355,8 @@ ivas_error ivas_core_dec( } set16_fx( voice_factors_fx[n], 0, NB_SUBFR16k ); - set16_fx( hb_synth_fx[n], 0, L_FRAME48k ); - + set32_fx( hb_synth_32_fx[n], 0, L_FRAME48k ); + set16_fx(hb_synth_16_fx[n], 0, L_FRAME48k); /*------------------------------------------------------------------* * Decision matrix (selection of technologies) *-----------------------------------------------------------------*/ @@ -398,11 +410,14 @@ ivas_error ivas_core_dec( IF( sba_dirac_stereo_flag && hSCE && sts[0]->total_brate <= SID_2k40 && sts[0]->cng_type == FD_CNG ) { - save_hb_synth = hSCE->save_hb_synth; + //save_hb_synth = hSCE->save_hb_synth; + floatToFixed_arrL( hSCE->save_hb_synth, hSCE->save_hb_synth_fx, Q11, output_frame ); + save_hb_synth_32_fx = hSCE->save_hb_synth_fx; } ELSE { - save_hb_synth = NULL; + //save_hb_synth = NULL; + save_hb_synth_32_fx = NULL; } /*------------------------------------------------------------------* @@ -446,7 +461,7 @@ ivas_error ivas_core_dec( fixedToFloat_arr( sts[k]->hHQ_core->old_out_LB_fx, sts[k]->hHQ_core->old_outLB, 0, L_FRAME32k ); } //fixedToFloat_arr( voice_factors_fx[k], voice_factors[k], 15, NB_SUBFR16k ); - fixedToFloat_arr( hb_synth_fx[k], hb_synth[k], 0, L_FRAME48k ); // 0 is assumed as original values are set to 0 + //fixedToFloat_arrL( hb_synth_32_fx[k], hb_synth[k], 0, L_FRAME48k ); // 0 is assumed as original values are set to 0 } IF( sts[0]->element_mode == IVAS_CPE_MDCT && sts[0]->total_brate == SID_2k40 ) { @@ -506,18 +521,18 @@ 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, + 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_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 ) ); + //Q_hb_prev_synth_buffer = Q_factor_arr( st->hb_prev_synth_buffer, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); //Q_prev_synth_buffer = Q_factor_arr( st->prev_synth_buffer, 96 ); - floatToFixed_arr( st->hb_prev_synth_buffer, st->hb_prev_synth_buffer_fx, Q_hb_prev_synth_buffer, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); + //floatToFixed_arr( st->hb_prev_synth_buffer, st->hb_prev_synth_buffer_fx, Q_hb_prev_synth_buffer, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); - IF( st->hHQ_core ) - { - Q_fer_samples = Q_factor_arr( st->hHQ_core->fer_samples, 960 ); - } + //IF( st->hHQ_core ) + //{ + // Q_fer_samples = Q_factor_arr( st->hHQ_core->fer_samples, 960 ); + //} IF( st->hTcxDec ) { //Q_FBTCXdelayBuf = Q_factor_arr( st->hTcxDec->FBTCXdelayBuf_float, 111 ); @@ -526,11 +541,11 @@ ivas_error ivas_core_dec( Q_syn_Overl = Q_factor_arr( st->hTcxDec->syn_Overl_float, 320 ); Q_old_syn_Overl = Q_factor_arr( st->hTcxDec->old_syn_Overl_float, L_FRAME32k / 2 ) - 1; } - Q_syn_Overl = s_min( Q_fer_samples, Q_syn_Overl ) - 1; - IF( st->hHQ_core ) - { + Q_syn_Overl = s_min( 0, Q_syn_Overl ) - 1; + //IF( st->hHQ_core ) + //{ - } + //} IF( st->hTcxDec ) { //floatToFixed_arr16( st->hTcxDec->FBTCXdelayBuf_float, st->hTcxDec->FBTCXdelayBuf, Q_prev_synth_buffer, 111 ); @@ -574,7 +589,7 @@ ivas_error ivas_core_dec( return error; } #if 1 /*Fixed to float function changes*/ - fixedToFloat_arr( st->hb_prev_synth_buffer_fx, st->hb_prev_synth_buffer, Q_hb_prev_synth_buffer, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); + //fixedToFloat_arr( st->hb_prev_synth_buffer_fx, st->hb_prev_synth_buffer, Q_hb_prev_synth_buffer, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); //fixedToFloat_arr( st->prev_synth_buffer_fx, st->prev_synth_buffer, Q_prev_synth_buffer, 96 ); //st->q_prev_synth_buffer_fx = Q_prev_synth_buffer; //fixedToFloat_arr( st->prev_synth_buffer_fx, st->prev_synth_buffer, 0, 96 ); @@ -618,12 +633,12 @@ ivas_error ivas_core_dec( /* ACELP core decoder */ 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; + Word16 save_hb_synth_fx_arr[L_FRAME48k], *save_hb_synth_16_fx; + IF (save_hb_synth_32_fx) { + save_hb_synth_16_fx = save_hb_synth_fx_arr; } - else { - save_hb_synth_fx = NULL; + ELSE { + save_hb_synth_16_fx = NULL; } //Word32 bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]; @@ -632,7 +647,7 @@ 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_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 ) + IF ( ( error = acelp_core_dec_ivas_fx( st, output_16_fx[n], synth_fxl, save_hb_synth_16_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; } @@ -643,8 +658,10 @@ ivas_error ivas_core_dec( acelp_decoder_state_fix2float(st, hCPE == NULL ? NULL : hCPE->hStereoCng); //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); + if ( save_hb_synth_32_fx ) + { + Copy_Scale_sig_16_32( save_hb_synth_16_fx, save_hb_synth_32_fx, output_frame, Q11 ); + fixedToFloat_arrL( hSCE->save_hb_synth_fx, hSCE->save_hb_synth, negate( Q11 ), output_frame ); } //fixedToFloat_arrL(bwe_exc_extended_fx, bwe_exc_extended[n], 2*st->Q_exc, L_FRAME32k + NL_BUFF_OFFSET); //fixedToFloat_arr(voice_factors_fx[n], voice_factors[n], Q15, NB_SUBFR16k); @@ -749,10 +766,10 @@ ivas_error ivas_core_dec( * MDCT stereo: joint TCX Core Decoding *---------------------------------------------------------------------*/ - IF ( sts[0]->element_mode == IVAS_CPE_MDCT ) + IF ( EQ_16(sts[0]->element_mode, IVAS_CPE_MDCT )) { /* active-frame decoding */ - IF ( sts[0]->core_brate > SID_2k40 ) + IF ( GT_32(sts[0]->core_brate, SID_2k40 )) { IF ( hMCT ) { @@ -762,7 +779,6 @@ ivas_error ivas_core_dec( } ELSE { -#ifdef IVAS_FLOAT_FIXED #if 1 Word16 e_sig = 17; //Word32 *output_fx[CPE_CHANNELS]; @@ -784,28 +800,28 @@ ivas_error ivas_core_dec( { FOR( i = 0; i < s_min( st->hTonalMDCTConc->nScaleFactors, 64 ); i++ ) { - st->hTonalMDCTConc->scaleFactorsBackground_fx[i] = floatToFixed( st->hTonalMDCTConc->scaleFactorsBackground_flt[i], 15 ); + //st->hTonalMDCTConc->scaleFactorsBackground_fx[i] = floatToFixed( st->hTonalMDCTConc->scaleFactorsBackground_flt[i], 15 ); } - if ( sts[0]->bfi && st->tonal_mdct_plc_active && st->hTonalMDCTConc->pTCI ) - { - FOR( i = 0; i < s_min( st->hTonalMDCTConc->pTCI->numIndexes, 30 ); i++ ) - { - float pd = st->hTonalMDCTConc->pTCI->phaseDiff_float[i]; - if ( pd >= PI2 ) - pd = fmodf( pd, PI2 ) - PI2; - st->hTonalMDCTConc->pTCI->phaseDiff[i] = (Word16) floatToFixed( pd, Q12 ); - } - FOR( i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++ ) - { - float pd = st->hTonalMDCTConc->pTCI->phase_currentFramePredicted_float[i]; - pd = fmodf( pd, PI2 ); - st->hTonalMDCTConc->pTCI->phase_currentFramePredicted[i] = (Word16) ( pd * ( 1u << Q13 ) ); - } - } + //if ( sts[0]->bfi && st->tonal_mdct_plc_active && st->hTonalMDCTConc->pTCI ) + //{ + // FOR( i = 0; i < s_min( st->hTonalMDCTConc->pTCI->numIndexes, 30 ); i++ ) + // { + // float pd = st->hTonalMDCTConc->pTCI->phaseDiff_float[i]; + // if ( pd >= PI2 ) + // pd = fmodf( pd, PI2 ) - PI2; + // st->hTonalMDCTConc->pTCI->phaseDiff[i] = (Word16) floatToFixed( pd, Q12 ); + // } + // FOR( i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++ ) + // { + // float pd = st->hTonalMDCTConc->pTCI->phase_currentFramePredicted_float[i]; + // pd = fmodf( pd, PI2 ); + // st->hTonalMDCTConc->pTCI->phase_currentFramePredicted[i] = (Word16) ( pd * ( 1u << Q13 ) ); + // } + //} } - IF( st->hTcxDec ) - st->hTcxDec->tcxltp_last_gain_unmodified = (Word16) floatToFixed( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 ); + //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] ) ) //{ @@ -813,10 +829,10 @@ ivas_error ivas_core_dec( //} 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++ ) - { - sts[ch]->hFdCngDec->hFdCngCom->fftBuffer[p] = (Word32) ( sts[ch]->hFdCngDec->hFdCngCom->fftBuffer_flt[p] * ( 1u << ( 31 - sts[ch]->hFdCngDec->hFdCngCom->fftBuffer_exp ) ) ); - } + //for ( int p = 0; p < s_min( sts[ch]->hFdCngDec->hFdCngCom->fftlen, 640 ); p++ ) + //{ + // sts[ch]->hFdCngDec->hFdCngCom->fftBuffer[p] = (Word32) ( sts[ch]->hFdCngDec->hFdCngCom->fftBuffer_flt[p] * ( 1u << ( 31 - sts[ch]->hFdCngDec->hFdCngCom->fftBuffer_exp ) ) ); + //} sts[ch]->hFdCngDec->msNoiseEst_exp = 31 - Q4; for ( int p = 0; p < NPART_SHAPING; p++ ) { @@ -835,8 +851,8 @@ ivas_error ivas_core_dec( IF( st->hTcxDec ) floatToFixed_arr( st->hTcxDec->syn_Overl_float, st->hTcxDec->syn_Overl, st->Q_syn, L_FRAME32k / 2 ); - IF( st->hTcxDec ) - floatToFixed_arr( st->hTcxDec->syn_OverlFB_float, st->hTcxDec->syn_OverlFB, st->Q_syn, L_FRAME_MAX / 2 ); + //IF( st->hTcxDec ) + //floatToFixed_arr( st->hTcxDec->syn_OverlFB_float, st->hTcxDec->syn_OverlFB, st->Q_syn, L_FRAME_MAX / 2 ); st->prev_Q_syn = st->Q_syn; @@ -857,10 +873,10 @@ ivas_error ivas_core_dec( floatToFixed_arr( st->p_bpf_noise_buf_float, st->p_bpf_noise_buf, 0, L_FRAME_16k ); } - IF( st->hTcxDec ) - floatToFixed_arr( st->hTcxDec->old_synth_float, st->hTcxDec->old_synth, st->Q_syn, 1280 ); - IF( st->hTcxDec ) - floatToFixed_arr( st->hTcxDec->synth_history, st->hTcxDec->synth_history_fx, st->Q_syn, s_min( 2496, NS2SA( st->output_Fs, PH_ECU_MEM_NS ) ) ); + //IF( st->hTcxDec ) + //floatToFixed_arr( st->hTcxDec->old_synth_float, st->hTcxDec->old_synth, st->Q_syn, 1280 ); + //IF( st->hTcxDec ) + //floatToFixed_arr( st->hTcxDec->synth_history, st->hTcxDec->synth_history_fx, st->Q_syn, s_min( 2496, NS2SA( st->output_Fs, PH_ECU_MEM_NS ) ) ); IF( st->hHQ_core ) floatToFixed_arr( st->hHQ_core->old_out, st->hHQ_core->old_out_fx, st->Q_syn, 960 ); @@ -900,21 +916,10 @@ ivas_error ivas_core_dec( st_ivas->hLsSetUpConversion->dmxMtx_fx[chInIdx][chOutIdx] = float_to_fix( st_ivas->hLsSetUpConversion->dmxMtx[chInIdx][chOutIdx], 30 ); /*Q30*/ } } - - IF( sts[0]->bfi && ( hCPE->hStereoMdct->mdct_stereo_mode[0] > SMDCT_DUAL_MONO || hCPE->hStereoMdct->mdct_stereo_mode[1] > SMDCT_DUAL_MONO ) ) - { - floatToFixed_arr( sts[0]->hTonalMDCTConc->lastBlockData.spectralData_float, sts[0]->hTonalMDCTConc->lastBlockData.spectralData, ( 15 - sts[0]->hTonalMDCTConc->lastBlockData.spectralData_exp ), L_FRAME_MAX ); - 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_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 ) ) - { - fixedToFloat_arr( sts[0]->hTonalMDCTConc->lastBlockData.spectralData, sts[0]->hTonalMDCTConc->lastBlockData.spectralData_float, ( 15 - sts[0]->hTonalMDCTConc->lastBlockData.spectralData_exp ), sts[0]->L_frameTCX_past ); - fixedToFloat_arr( sts[1]->hTonalMDCTConc->lastBlockData.spectralData, sts[1]->hTonalMDCTConc->lastBlockData.spectralData_float, ( 15 - sts[1]->hTonalMDCTConc->lastBlockData.spectralData_exp ), sts[0]->L_frameTCX_past ); - } +#if 1 // Fix to float conversion IF( st_ivas->hLsSetUpConversion ) me2f_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); IF( st_ivas->hLsSetUpConversion ) @@ -925,36 +930,36 @@ ivas_error ivas_core_dec( 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 ) ); 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_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 ); - st->hTcxDec->tcxltp_last_gain_unmodified_float = fix16_to_float( st->hTcxDec->tcxltp_last_gain_unmodified, Q15 ); + //st->hTcxDec->tcxltp_last_gain_unmodified_float = fix16_to_float( st->hTcxDec->tcxltp_last_gain_unmodified, Q15 ); //st->hTcxDec->conceal_eof_gain_float = fix16_to_float( st->hTcxDec->conceal_eof_gain, Q14 ); - if ( sts[ch]->last_core != -1 && sts[ch]->nbLostCmpt == 1 ) - { - if ( !( sts[ch]->rf_flag && sts[ch]->use_partial_copy && ( sts[ch]->rf_frame_type == RF_TCXTD1 || sts[ch]->rf_frame_type == RF_TCXTD2 ) ) ) - { - IF( sts[ch]->hTonalMDCTConc != NULL && sts[ch]->last_core == TCX_20_CORE && sts[ch]->second_last_core == TCX_20_CORE && ( ( sts[ch]->old_fpitch <= L_shl( sts[ch]->L_frame, 15 ) ) || ( sts[ch]->hTcxDec->tcxltp_last_gain_unmodified <= 13107 /*0.4f*/ ) ) - /* it is fine to call the detection even if no ltp information - is available, meaning that st->old_fpitch == - st->tcxltp_second_last_pitch == st->L_frame */ - && ( sts[ch]->old_fpitch == sts[ch]->hTcxDec->tcxltp_second_last_pitch ) && !sts[ch]->last_tns_active && !sts[ch]->second_last_tns_active ) - { - - if ( sts[ch]->hTonalMDCTConc->pTCI->numIndexes < MAX_NUMBER_OF_IDX ) - { - FOR( i = 0; i < s_min( 30, sts[ch]->hTonalMDCTConc->pTCI->numIndexes ); i++ ) - { - sts[ch]->hTonalMDCTConc->pTCI->phaseDiff_float[i] = fixedToFloat( sts[ch]->hTonalMDCTConc->pTCI->phaseDiff[i], Q12 ); - } - FOR( i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++ ) - { - sts[ch]->hTonalMDCTConc->pTCI->phase_currentFramePredicted_float[i] = fixedToFloat( sts[ch]->hTonalMDCTConc->pTCI->phase_currentFramePredicted[i], Q13 ); - } - } - } - } - } + //if ( sts[ch]->last_core != -1 && sts[ch]->nbLostCmpt == 1 ) + //{ + // if ( !( sts[ch]->rf_flag && sts[ch]->use_partial_copy && ( sts[ch]->rf_frame_type == RF_TCXTD1 || sts[ch]->rf_frame_type == RF_TCXTD2 ) ) ) + // { + // IF( sts[ch]->hTonalMDCTConc != NULL && sts[ch]->last_core == TCX_20_CORE && sts[ch]->second_last_core == TCX_20_CORE && ( ( sts[ch]->old_fpitch <= L_shl( sts[ch]->L_frame, 15 ) ) || ( sts[ch]->hTcxDec->tcxltp_last_gain_unmodified <= 13107 /*0.4f*/ ) ) + // /* it is fine to call the detection even if no ltp information + // is available, meaning that st->old_fpitch == + // st->tcxltp_second_last_pitch == st->L_frame */ + // && ( sts[ch]->old_fpitch == sts[ch]->hTcxDec->tcxltp_second_last_pitch ) && !sts[ch]->last_tns_active && !sts[ch]->second_last_tns_active ) + // { + + // if ( sts[ch]->hTonalMDCTConc->pTCI->numIndexes < MAX_NUMBER_OF_IDX ) + // { + // FOR( i = 0; i < s_min( 30, sts[ch]->hTonalMDCTConc->pTCI->numIndexes ); i++ ) + // { + // sts[ch]->hTonalMDCTConc->pTCI->phaseDiff_float[i] = fixedToFloat( sts[ch]->hTonalMDCTConc->pTCI->phaseDiff[i], Q12 ); + // } + // FOR( i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++ ) + // { + // sts[ch]->hTonalMDCTConc->pTCI->phase_currentFramePredicted_float[i] = fixedToFloat( sts[ch]->hTonalMDCTConc->pTCI->phase_currentFramePredicted[i], Q13 ); + // } + // } + // } + // } + //} //if ( !sts[0]->bfi && ( will_estimate_noise_on_channel[0] || will_estimate_noise_on_channel[1] ) ) //{ @@ -965,10 +970,10 @@ ivas_error ivas_core_dec( { if ( !sts[ch]->bfi ) { - for ( int p = 0; p < s_min( 640, sts[ch]->hFdCngDec->hFdCngCom->fftlen ); p++ ) - { - sts[ch]->hFdCngDec->hFdCngCom->fftBuffer_flt[p] = ( (float) sts[ch]->hFdCngDec->hFdCngCom->fftBuffer[p] / ( 1u << ( 31 - sts[ch]->hFdCngDec->hFdCngCom->fftBuffer_exp ) ) ); - } + //for ( int p = 0; p < s_min( 640, sts[ch]->hFdCngDec->hFdCngCom->fftlen ); p++ ) + //{ + // sts[ch]->hFdCngDec->hFdCngCom->fftBuffer_flt[p] = ( (float) sts[ch]->hFdCngDec->hFdCngCom->fftBuffer[p] / ( 1u << ( 31 - sts[ch]->hFdCngDec->hFdCngCom->fftBuffer_exp ) ) ); + //} for ( int p = 0; p < s_min( 62, sts[ch]->hFdCngDec->npart_shaping ); p++ ) { sts[ch]->hFdCngDec->msNoiseEst_float[p] = ( (float) sts[ch]->hFdCngDec->msNoiseEst[p] / ( 1u << ( 31 - sts[ch]->hFdCngDec->msNoiseEst_exp ) ) ); @@ -977,7 +982,7 @@ ivas_error ivas_core_dec( for ( int p = 0; p < s_min( 320, sts[ch]->hFdCngDec->hFdCngCom->stopFFTbin - sts[ch]->hFdCngDec->hFdCngCom->startBand ); p++ ) { - sts[ch]->hFdCngDec->bandNoiseShape_float[p] = ( (float) sts[ch]->hFdCngDec->bandNoiseShape[p] / ( 1u << ( 31 - sts[ch]->hFdCngDec->bandNoiseShape_exp ) ) ); + //sts[ch]->hFdCngDec->bandNoiseShape_float[p] = ( (float) sts[ch]->hFdCngDec->bandNoiseShape[p] / ( 1u << ( 31 - sts[ch]->hFdCngDec->bandNoiseShape_exp ) ) ); } for ( int p = 0; p < s_min( 340, sts[ch]->hFdCngDec->hFdCngCom->stopFFTbin - sts[ch]->hFdCngDec->hFdCngCom->startBand ); p++ ) @@ -995,7 +1000,7 @@ ivas_error ivas_core_dec( } for ( int p = 0; p < FDNS_NPTS; p++ ) { - sts[ch]->hTonalMDCTConc->scaleFactorsBackground_flt[p] = (float) sts[ch]->hTonalMDCTConc->scaleFactorsBackground_fx[p] / ONE_IN_Q16; + //sts[ch]->hTonalMDCTConc->scaleFactorsBackground_flt[p] = (float) sts[ch]->hTonalMDCTConc->scaleFactorsBackground_fx[p] / ONE_IN_Q16; } } if ( sts[ch]->element_mode != IVAS_CPE_MDCT || sts[ch]->core == ACELP_CORE ) @@ -1030,8 +1035,8 @@ ivas_error ivas_core_dec( } - fixedToFloat_arr( st->hTcxDec->old_synth, st->hTcxDec->old_synth_float, st->Q_syn, 1280 ); - fixedToFloat_arr( st->hTcxDec->synth_history_fx, st->hTcxDec->synth_history, st->Q_syn, s_min( 2496, NS2SA( st->output_Fs, PH_ECU_MEM_NS ) ) ); + //fixedToFloat_arr( st->hTcxDec->old_synth, st->hTcxDec->old_synth_float, st->Q_syn, 1280 ); + //fixedToFloat_arr( st->hTcxDec->synth_history_fx, st->hTcxDec->synth_history, st->Q_syn, s_min( 2496, NS2SA( st->output_Fs, PH_ECU_MEM_NS ) ) ); fixedToFloat_arr( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synthFB, st->Q_syn, s_min( 2496, st->hTcxDec->old_synth_lenFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ) ); for ( int p = 0; p < 960; p++ ) @@ -1052,9 +1057,6 @@ ivas_error ivas_core_dec( fixedToFloat_arr( synth_fx_16[1], synth[1], 15 - e_sig, 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 ); #endif } } @@ -1105,10 +1107,10 @@ ivas_error ivas_core_dec( if ( hCPE->last_element_brate <= IVAS_SID_5k2 ) { - f2me_buf_16( sts[0]->hTcxLtpDec->tcxltp_mem_in_float, sts[0]->hTcxLtpDec->tcxltp_mem_in, &sts[0]->hTcxLtpDec->exp_tcxltp_mem_in, TCXLTP_MAX_DELAY ); - f2me_buf_16( sts[1]->hTcxLtpDec->tcxltp_mem_in_float, sts[1]->hTcxLtpDec->tcxltp_mem_in, &sts[1]->hTcxLtpDec->exp_tcxltp_mem_in, TCXLTP_MAX_DELAY ); - f2me_buf_16( sts[0]->hTcxLtpDec->tcxltp_mem_out_float, sts[0]->hTcxLtpDec->tcxltp_mem_out, &sts[0]->hTcxLtpDec->exp_tcxltp_mem_out, L_FRAME48k ); - f2me_buf_16( sts[1]->hTcxLtpDec->tcxltp_mem_out_float, sts[1]->hTcxLtpDec->tcxltp_mem_out, &sts[1]->hTcxLtpDec->exp_tcxltp_mem_out, L_FRAME48k ); + //f2me_buf_16( sts[0]->hTcxLtpDec->tcxltp_mem_in_float, sts[0]->hTcxLtpDec->tcxltp_mem_in, &sts[0]->hTcxLtpDec->exp_tcxltp_mem_in, TCXLTP_MAX_DELAY ); + //f2me_buf_16( sts[1]->hTcxLtpDec->tcxltp_mem_in_float, sts[1]->hTcxLtpDec->tcxltp_mem_in, &sts[1]->hTcxLtpDec->exp_tcxltp_mem_in, TCXLTP_MAX_DELAY ); + //f2me_buf_16( sts[0]->hTcxLtpDec->tcxltp_mem_out_float, sts[0]->hTcxLtpDec->tcxltp_mem_out, &sts[0]->hTcxLtpDec->exp_tcxltp_mem_out, L_FRAME48k ); + //f2me_buf_16( sts[1]->hTcxLtpDec->tcxltp_mem_out_float, sts[1]->hTcxLtpDec->tcxltp_mem_out, &sts[1]->hTcxLtpDec->exp_tcxltp_mem_out, L_FRAME48k ); 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 ); @@ -1117,8 +1119,8 @@ ivas_error ivas_core_dec( if ( hCPE->last_element_brate <= IVAS_SID_5k2 ) { - me2f_buf_16( sts[0]->hTcxLtpDec->tcxltp_mem_in, sts[0]->hTcxLtpDec->exp_tcxltp_mem_in, sts[0]->hTcxLtpDec->tcxltp_mem_in_float, TCXLTP_MAX_DELAY ); - me2f_buf_16( sts[0]->hTcxLtpDec->tcxltp_mem_out, sts[0]->hTcxLtpDec->exp_tcxltp_mem_out, sts[0]->hTcxLtpDec->tcxltp_mem_out_float, L_FRAME48k ); + //me2f_buf_16( sts[0]->hTcxLtpDec->tcxltp_mem_in, sts[0]->hTcxLtpDec->exp_tcxltp_mem_in, sts[0]->hTcxLtpDec->tcxltp_mem_in_float, TCXLTP_MAX_DELAY ); + //me2f_buf_16( sts[0]->hTcxLtpDec->tcxltp_mem_out, sts[0]->hTcxLtpDec->exp_tcxltp_mem_out, sts[0]->hTcxLtpDec->tcxltp_mem_out_float, L_FRAME48k ); me2f_buf_16( sts[0]->hHQ_core->old_out_fx, sts[0]->hHQ_core->exp_old_out, sts[0]->hHQ_core->old_out, L_FRAME48k ); 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 ); } @@ -1142,15 +1144,14 @@ ivas_error ivas_core_dec( updateBuffersForDmxMdctStereo( hCPE, output_frame, output, synth ); #endif } - - if ( sts[0]->bfi == 0 && sts[0]->prev_bfi == 1 ) + test(); + IF ( EQ_16(sts[0]->bfi, 0) && EQ_16(sts[0]->prev_bfi, 1 )) { /* On first good frame after frameloss undo the whitening of the bg noise shape */ - for ( n = 0; n < n_channels; ++n ) + FOR ( n = 0; n < n_channels; ++n ) { - if ( sts[n]->last_core_bfi != ACELP_CORE ) + IF ( NE_16(sts[n]->last_core_bfi, ACELP_CORE) ) { -#ifdef IVAS_FLOAT_FIXED sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 27; for ( int p = 0; p < sts[n]->hFdCngDec->hFdCngCom->stopFFTbin - sts[n]->hFdCngDec->hFdCngCom->startBand; p++ ) { @@ -1158,7 +1159,7 @@ ivas_error ivas_core_dec( } for ( int p = 0; p < FDNS_NPTS; p++ ) { - sts[n]->hTonalMDCTConc->scaleFactorsBackground_fx[p] = (Word32) ( sts[n]->hTonalMDCTConc->scaleFactorsBackground_flt[p] * ONE_IN_Q16 ); + //sts[n]->hTonalMDCTConc->scaleFactorsBackground_fx[p] = (Word32) ( sts[n]->hTonalMDCTConc->scaleFactorsBackground_flt[p] * ONE_IN_Q16 ); } TonalMdctConceal_whiten_noise_shape_ivas_fx( sts[n], L_FRAME16k, ON_FIRST_GOOD_FRAME ); @@ -1169,11 +1170,8 @@ ivas_error ivas_core_dec( } for ( int p = 0; p < FDNS_NPTS; p++ ) { - sts[n]->hTonalMDCTConc->scaleFactorsBackground_flt[p] = (float) sts[n]->hTonalMDCTConc->scaleFactorsBackground_fx[p] / ONE_IN_Q16; + //sts[n]->hTonalMDCTConc->scaleFactorsBackground_flt[p] = (float) sts[n]->hTonalMDCTConc->scaleFactorsBackground_fx[p] / ONE_IN_Q16; } -#else - TonalMdctConceal_whiten_noise_shape_ivas( sts[n], L_FRAME16k, ON_FIRST_GOOD_FRAME ); -#endif // IVAS_FLOAT_FIXED } } } @@ -1185,7 +1183,6 @@ ivas_error ivas_core_dec( if ( sts[0]->element_mode == IVAS_CPE_TD && hCPE->hStereoCng != NULL ) { -#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]; Word16 Q_c_PS_LT = 31, Q_output = 31; @@ -1221,15 +1218,6 @@ ivas_error ivas_core_dec( 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 - dbgwrite_txt( &( hCPE->hStereoCng->c_PS_LT ), 1, "Fixed_code_c_PS_LT.txt", NULL ); -#endif -#else - stereo_cng_compute_PScorr( output, &hCPE->hStereoCng->c_PS_LT, sts[0]->L_frame, sts[1]->L_frame ); -#ifdef DUMPS_ENABLED - dbgwrite_txt( &( hCPE->hStereoCng->c_PS_LT ), 1, "Float_code_c_PS_LT.txt", NULL ); -#endif -#endif } /*---------------------------------------------------------------------* @@ -1245,14 +1233,14 @@ ivas_error ivas_core_dec( *---------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED - Word32 hb_synth_fxg[CPE_CHANNELS][L_FRAME48k]; + //Word32 hb_synth_fxg[CPE_CHANNELS][L_FRAME48k]; if (st->last_core == ACELP_CORE && (st->core == TCX_20_CORE || st->core == TCX_10_CORE || st->core == HQ_CORE) && st->hBWE_TD != NULL) { FOR(int ch_ind = 0; ch_ind < n_channels; ch_ind++) { FOR(int ind = 0; ind < L_FRAME48k; ind++) { - hb_synth_fxg[ch_ind][ind] = (Word32)(hb_synth[ch_ind][ind] * (1 << 11)); + //hb_synth_32_fx[ch_ind][ind] = (Word32)(hb_synth[ch_ind][ind] * (1 << 11)); } } @@ -1289,19 +1277,28 @@ ivas_error ivas_core_dec( /*------------------fix-to-fix-end-----------------------*/ Word16 *synth_fx16; - Word16 *output_mem_fx; + //Word16 *output_mem_fx; + + Word16 output_mem_16_fx[L_FRAME48k]; + Word16 *p_output_mem_16; synth_fx16 = (Word16 *)malloc(L_FRAME48k * sizeof(Word16)); //Word32 output_fx32[L_FRAME48k]; - output_mem_fx = (Word16 *)malloc(NS2SA(st->output_Fs, 3125000) * sizeof(Word16)); + //output_mem_fx = (Word16 *)malloc(NS2SA(st->output_Fs, 3125000) * sizeof(Word16)); + - IF(p_output_mem != NULL) + IF(p_output_mem_fx != NULL) { - floatToFixed_arr(p_output_mem, output_mem_fx, 0, NS2SA(st->output_Fs, 3125000)); + //floatToFixed_arrL(p_output_mem, p_output_mem_fx, Q11, NS2SA_fx2(output_Fs, STEREO_DFT32MS_OVL_NS)); + p_output_mem_16 = output_mem_16_fx; + Copy_Scale_sig_32_16(p_output_mem_fx, p_output_mem_16, NS2SA_fx2(output_Fs, STEREO_DFT32MS_OVL_NS), negate(Q11)); + + //floatToFixed_arr(p_output_mem, output_mem_fx, 0, NS2SA(st->output_Fs, 3125000)); } ELSE { - set16_fx(output_mem_fx, 0, NS2SA(st->output_Fs, 3125000)); + p_output_mem_16 = NULL; + set16_fx(output_mem_16_fx, 0, NS2SA(st->output_Fs, 3125000)); } floatToFixed_arr(synth[n], synth_fx16, Q_synth, L_FRAME48k); @@ -1358,11 +1355,11 @@ ivas_error ivas_core_dec( test(); test(); test(); test(); IF ( (EQ_16(st->bwidth, SWB) || EQ_16(st->bwidth, FB) ) && (EQ_16(st->last_extl, SWB_TBE) || EQ_16(st->last_extl, FB_TBE) ) ) { - GenTransition_fixed( st->hBWE_TD, hb_synth_fxg[n], output_Fs, st->element_mode, st->L_frame, st->rf_flag, st->total_brate ); + GenTransition_fixed( st->hBWE_TD, hb_synth_32_fx[n], output_Fs, st->element_mode, st->L_frame, st->rf_flag, st->total_brate ); } ELSE IF (EQ_16(st->bwidth, WB) && EQ_16(st->last_extl, WB_TBE) ) { - GenTransition_WB_fixed( st->hBWE_TD, hb_synth_fxg[n], output_Fs ); + GenTransition_WB_fixed( st->hBWE_TD, hb_synth_32_fx[n], output_Fs ); move16(); } @@ -1396,7 +1393,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_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 ) + IF ( ( error = core_switching_post_dec_ivas_fx( st, synth_fx16, output_32_fx[n], p_output_mem_16, ( st_ivas != NULL ) ? st_ivas->ivas_format : UNDEFINED_FORMAT, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, ( hCPE != NULL ) ? hCPE->last_element_mode : IVAS_SCE, &Q_synth ) ) != IVAS_ERR_OK ) { return error; } @@ -1429,7 +1426,7 @@ ivas_error ivas_core_dec( // Delete from here FOR(int ch_ind = 0; ch_ind < n_channels; ch_ind++) { - fixedToFloat_arrL(hb_synth_fxg[ch_ind], hb_synth[ch_ind], 11, L_FRAME48k); + //fixedToFloat_arrL(hb_synth_32_fx[ch_ind], hb_synth[ch_ind], 11, L_FRAME48k); } } if (sba_dirac_stereo_flag && st->element_mode != IVAS_CPE_MDCT && !(st->core_brate == SID_2k40 && st->cng_type == FD_CNG)) @@ -1478,7 +1475,7 @@ ivas_error ivas_core_dec( } free(synth_fx16); - free(output_mem_fx); + //free(output_mem_fx); if (sba_dirac_stereo_flag && hSCE && st->core_brate == SID_2k40 && st->cng_type == FD_CNG) { @@ -1493,14 +1490,14 @@ ivas_error ivas_core_dec( #ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED - Word16 hb_synth_fx_16[CPE_CHANNELS][L_FRAME48k]; + //Word16 hb_synth_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; Word32 synth_fx32[L_FRAME48k]; - Word32 hb_synth_fx32[L_FRAME48k]; + //Word32 hb_synth_fx32[L_FRAME48k]; Word16 Q_syn_hb; Q_input = 0; @@ -1517,8 +1514,9 @@ ivas_error ivas_core_dec( //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 ); + Copy_Scale_sig_32_16(output_32_fx[n], output_16_fx[n], L_FRAME48k, negate(Q11)); + Copy_Scale_sig_32_16(hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, negate(Q11)); + //floatToFixed_arr( hb_synth[n], hb_synth_16_fx[n], Q_hb_synth_fx, 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 ); @@ -1537,7 +1535,7 @@ ivas_error ivas_core_dec( { /* WB TBE decoder */ - ivas_wb_tbe_dec_fx( st, st->coder_type, bwe_exc_extended_fx[n], st->Q_exc, voice_factors_fx[n], hb_synth_fx_16[n], &Q_hb_synth_fx ); + ivas_wb_tbe_dec_fx( st, st->coder_type, bwe_exc_extended_fx[n], st->Q_exc, voice_factors_fx[n], hb_synth_16_fx[n], &Q_hb_synth_fx ); } ELSE IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( n, 1 ) && !tdm_LRTD_flag && NE_16( st->extl, -1 ) && EQ_16( st->bws_cnt, 0 ) && EQ_32( st->extl_brate, 0 ) ) { @@ -1546,11 +1544,11 @@ 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_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 ); + Q_hb_synth_fx = ivas_wb_bwe_dec_fx( st, output_16_fx[n], synth_fx_16[n], hb_synth_16_fx[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( hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, Q11 - Q_hb_synth_fx ); 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 ); @@ -1583,7 +1581,7 @@ ivas_error ivas_core_dec( /* SWB TBE decoder */ Q_white_exc = 0; move16(); - ivas_swb_tbe_dec_fx( st, hStereoICBWE, bwe_exc_extended_fx[n], st->Q_exc, voice_factors_fx[n], old_syn_12k8_16k_fx[n], tmp_buffer_fx /*fb_exc*/, hb_synth_fx32, pitch_buf_fx[n], &Q_white_exc ); + ivas_swb_tbe_dec_fx( st, hStereoICBWE, bwe_exc_extended_fx[n], st->Q_exc, voice_factors_fx[n], old_syn_12k8_16k_fx[n], tmp_buffer_fx /*fb_exc*/, hb_synth_32_fx[n], pitch_buf_fx[n], &Q_white_exc ); Copy_Scale_sig_32_16( st->hBWE_TD->old_tbe_synth_fx_32, st->hBWE_TD->old_tbe_synth_fx, L_SHB_TRANSITION_LENGTH, st->prev_Qx - Q11 ); // Check @@ -1596,16 +1594,16 @@ ivas_error ivas_core_dec( /* FB TBE decoder */ IF( EQ_16( st->extl, FB_TBE ) ) { - fb_tbe_dec_ivas_fx( st, tmp_buffer_fx /*fb_exc*/, Q_white_exc, hb_synth_fx32, 0, tmp_buffer_fx /*fb_synth_ref*/, Q_white_exc, output_frame ); + fb_tbe_dec_ivas_fx( st, tmp_buffer_fx /*fb_exc*/, Q_white_exc, hb_synth_32_fx[n], 0, tmp_buffer_fx /*fb_synth_ref*/, Q_white_exc, output_frame ); } } 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_32_fx[n], 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_32_fx[n], use_cldfb_for_dft, output_frame ); // Output - Scale_sig32( hb_synth_fx32, output_frame, Q11 - Q_syn_hb ); + Scale_sig32( hb_synth_32_fx[n], output_frame, Q11 - Q_syn_hb ); Copy_Scale_sig_32_16( st->hBWE_FD->L_old_wtda_swb_fx32, st->hBWE_FD->L_old_wtda_swb_fx, output_frame, hBWE_FD->old_wtda_swb_fx_exp - Q11 ); // Check } @@ -1631,7 +1629,7 @@ ivas_error ivas_core_dec( move16(); FOR( i = 0; i < j; i++ ) { - hb_synth_fx32[i] = Mpy_32_16_1( hb_synth_fx32[i], tmp16_2 ); /* Q11 */ + hb_synth_32_fx[n][i] = Mpy_32_16_1( hb_synth_32_fx[n][i], tmp16_2 ); /* Q11 */ move32(); #ifdef BASOP_NOGLOB tmp16_2 = add_o( tmp16_2, tmp16, &Overflow ); /* Q15 */ @@ -1648,18 +1646,18 @@ ivas_error ivas_core_dec( IF ( ( output_frame >= L_FRAME32k && st->hTdCngDec != NULL ) || ( st->element_mode == IVAS_CPE_DFT && st->bwidth >= SWB && st->hTdCngDec != NULL ) ) { /* SHB CNG decoder */ - Word16 synth_fxl[960], hb_synth_fxl[960]; /* Q-2 */ + Word16 synth_fxl[960]/*, hb_synth_fxl[960]*/; /* Q-2 */ Word16 q = 2; //st->prev_Q_bwe_syn2 = 0; - Copy_Scale_sig_32_16(hb_synth_fx32, hb_synth_fxl, L_FRAME48k, -(Q11 + q)); + Copy_Scale_sig_32_16(hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -(Q11 + q)); Copy_Scale_sig_32_16(synth_fx32, synth_fxl, L_FRAME48k, -(Q11 + q)); Scale_sig(st->hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, (Q8 - st->prev_Q_bwe_syn)); Scale_sig32(st->hBWE_TD->genSHBsynth_Hilbert_Mem_fx, HILBERT_MEM_SIZE, (st->prev_Q_bwe_syn2 - Q11)); Copy_Scale_sig_32_16(st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, 2 * ALLPASSSECTIONS_STEEP, (st->prev_Q_bwe_syn2 - Q11)); - swb_CNG_dec_ivas_fx( st, synth_fxl, hb_synth_fxl, sid_bw[n], -q ); + swb_CNG_dec_ivas_fx( st, synth_fxl, hb_synth_16_fx[n], sid_bw[n], -q ); - Copy_Scale_sig_16_32(hb_synth_fxl, hb_synth_fx32, L_FRAME48k, (Q11 + q)); + Copy_Scale_sig_16_32(hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, (Q11 + q)); Copy_Scale_sig_16_32(synth_fxl, synth_fx32, L_FRAME48k, (Q11 + q)); Scale_sig(st->hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, -(Q8 - st->prev_Q_bwe_syn)); Scale_sig32(st->hBWE_TD->genSHBsynth_Hilbert_Mem_fx, HILBERT_MEM_SIZE, -(st->prev_Q_bwe_syn2 - Q11)); @@ -1668,7 +1666,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(hb_synth_32_fx[n], hb_synth[n], Q11, L_FRAME48k); //fixedToFloat_arrL(output_32_fx[n], output[n], Q11, L_FRAME48k); fixedToFloat_arrL(synth_fx32, synth[n], Q11, L_FRAME48k); @@ -1684,11 +1682,11 @@ ivas_error ivas_core_dec( test(); IF ( EQ_16(n, 0) && GE_16(st->element_mode, IVAS_CPE_DFT )) { - Word32 *hb_synth_0 = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); - Word32 *hb_synth_1 = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); + //Word32 *hb_synth_0 = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); + //Word32 *hb_synth_1 = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); Word16 q = 11; - floatToFixed_arrL( hb_synth[0], hb_synth_0, q, L_FRAME48k ); - floatToFixed_arrL( hb_synth[1], hb_synth_1, q, L_FRAME48k ); + //floatToFixed_arrL( hb_synth[0], hb_synth_32_fx[0], q, L_FRAME48k ); + //floatToFixed_arrL( hb_synth[1], hb_synth_32_fx[1], q, L_FRAME48k ); if ( hCPE->hStereoDft != NULL ) @@ -1697,12 +1695,14 @@ ivas_error ivas_core_dec( hCPE->hStereoDft->td_gain_fx[0] = 1; } Scale_sig( tmp_buffer_fx, L_FRAME48k, Q11 - Q_white_exc ); - stereo_icBWE_dec_fx( hCPE, hb_synth_0, hb_synth_1, tmp_buffer_fx /*fb_synth_ref*/, voice_factors_fx[0], output_frame, &q ); + stereo_icBWE_dec_fx( hCPE, hb_synth_32_fx[0], hb_synth_32_fx[1], tmp_buffer_fx /*fb_synth_ref*/, voice_factors_fx[0], output_frame, &q ); - fixedToFloat_arrL( hb_synth_0, hb_synth[0], q, L_FRAME48k ); - fixedToFloat_arrL( hb_synth_1, hb_synth[1], q, L_FRAME48k ); + //fixedToFloat_arrL( hb_synth_32_fx[0], hb_synth[0], q, L_FRAME48k ); + //fixedToFloat_arrL( hb_synth_32_fx[1], hb_synth[1], q, L_FRAME48k ); + Scale_sig32(hb_synth_32_fx[0], L_FRAME48k, sub(Q11 , q)); + Scale_sig32(hb_synth_32_fx[1], L_FRAME48k, sub(Q11 , q)); if ( hCPE->hStereoDft != NULL ) { @@ -1719,8 +1719,8 @@ ivas_error ivas_core_dec( } - free( hb_synth_0 ); - free( hb_synth_1 ); + //free( hb_synth_0 ); + //free( hb_synth_1 ); } IF( EQ_16( st->element_mode, EVS_MONO ) ) @@ -1780,18 +1780,18 @@ ivas_error ivas_core_dec( move16(); FOR ( i = 0; i < tmps; i++ ) { - hb_synth_fx[n][i] = mult_r(hb_synth_fx[n][i], sin_table256_fx[tmp16]); + hb_synth_32_fx[n][i] = Mpy_32_16_1(hb_synth_32_fx[n][i], sin_table256_fx[tmp16]); move16(); tmp16 = add(tmp16, incr); } set16_fx( st->hb_prev_synth_buffer_fx, 0, tmps ); #if 1 //To be removed - for (i = 0; i < tmps; i++) + /*for (i = 0; i < tmps; i++) { hb_synth[n][i] *= sin_table256[i * incr]; - } - set_f(st->hb_prev_synth_buffer, 0.0f, tmps); + }*/ + //set_f(st->hb_prev_synth_buffer, 0.0f, tmps); #endif } ELSE IF ( LT_16(tmps, st->old_bwe_delay )) @@ -1808,7 +1808,7 @@ ivas_error ivas_core_dec( tmp16 = add(tmp16, incr); } Copy(tmp_buffer_fx, st->hb_prev_synth_buffer_fx, tmps); -#if 1 //To be removed +#if 0 //To be removed for (i = 0; i < tmps; i++) { tmp_buffer[i] = st->hb_prev_synth_buffer[i] * sin_table256[255 - i * incr] + @@ -1845,7 +1845,7 @@ ivas_error ivas_core_dec( Copy( tmp_buffer_fx, st->hb_prev_synth_buffer_fx, tmps ); -#if 1 //To be removed +#if 0 //To be removed for (i = 0; i < st->old_bwe_delay; i++) { tmp_buffer[i] = st->hb_prev_synth_buffer[i] * sin_table256[255 - i * incr]; @@ -1869,19 +1869,21 @@ ivas_error ivas_core_dec( IF ( ( NE_16(st->element_mode, IVAS_CPE_TD) && !use_cldfb_for_dft ) || ( EQ_16(hCPE->element_mode, IVAS_CPE_TD) && tdm_LRTD_flag ) ) { /* Delay hb_synth */ - Word32 hb_synth_fxl[960], hb_prev_synth_buffer_fx_32[111]; - floatToFixed_arrL(hb_synth[n], hb_synth_fxl, Q11, 960); - floatToFixed_arrL(st->hb_prev_synth_buffer, hb_prev_synth_buffer_fx_32, Q11, 111); + Word32 /*hb_synth_fxl[960],*/ hb_prev_synth_buffer_fx_32[111]; + //floatToFixed_arrL(hb_synth[n], hb_synth_fxl, Q11, 960); + //floatToFixed_arrL(st->hb_prev_synth_buffer, hb_prev_synth_buffer_fx_32, Q11, 111); - delay_signal_fx( hb_synth_fxl, output_frame, hb_prev_synth_buffer_fx_32, tmps ); + Copy_Scale_sig_16_32(st->hb_prev_synth_buffer_fx, hb_prev_synth_buffer_fx_32, 111, 11); + delay_signal_fx( hb_synth_32_fx[n], output_frame, hb_prev_synth_buffer_fx_32, tmps ); + Copy_Scale_sig_32_16(hb_prev_synth_buffer_fx_32, st->hb_prev_synth_buffer_fx, 111, -11); - fixedToFloat_arrL(hb_synth_fxl, hb_synth[n], Q11, 960); - fixedToFloat_arrL(hb_prev_synth_buffer_fx_32, st->hb_prev_synth_buffer, Q11, 111); + //fixedToFloat_arrL(hb_synth_fxl, hb_synth[n], Q11, 960); + //fixedToFloat_arrL(hb_prev_synth_buffer_fx_32, st->hb_prev_synth_buffer, Q11, 111); } ELSE { - Copy( hb_synth_fx[n] + output_frame - tmps, st->hb_prev_synth_buffer_fx, tmps ); //ToDo: Scale Signl with appropriate Q. -#if 1 // TO BE REMOVED + Copy_Scale_sig_32_16(hb_synth_32_fx[n] + output_frame - tmps, st->hb_prev_synth_buffer_fx, tmps,negate(Q11)); //ToDo: Scale Signl with appropriate Q. +#if 0 // TO BE REMOVED mvr2r(hb_synth[n] + output_frame - tmps, st->hb_prev_synth_buffer, tmps); #endif } @@ -1890,7 +1892,11 @@ ivas_error ivas_core_dec( #if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) if ( st->hBWE_TD != NULL ) { - mvr2r( hb_synth[n], st->hBWE_TD->old_hb_synth, output_frame ); + //mvr2r( hb_synth[n], st->hBWE_TD->old_hb_synth, output_frame ); + } + IF( st->hBWE_TD != NULL ) + { + Copy_Scale_sig_32_16( hb_synth_32_fx[n], st->hBWE_TD->old_hb_synth_fx, output_frame, negate( Q11 ) ); } #endif @@ -1899,10 +1905,10 @@ ivas_error ivas_core_dec( IF ( GE_16(output_frame, L_FRAME32k) && GT_16(st->extl, SWB_CNG) && EQ_16(st->core, ACELP_CORE) && st->hTdCngDec != NULL ) { #ifdef IVAS_FLOAT_FIXED - Word32 hb_synth_fxl[960]; + //Word32 hb_synth_fxl[960]; //Word32 L_tmp; Word16 exp, fra; - floatToFixed_arrL(hb_synth[n], hb_synth_fxl, Q11, 960); + //floatToFixed_arrL(hb_synth[n], hb_synth_32_fx[n], Q11, 960); #endif SWITCH(output_frame) { @@ -1923,7 +1929,7 @@ ivas_error ivas_core_dec( L_tmp = L_deposit_l(2); /*0.001 in Q11*/ Word16 gb = find_guarded_bits_fx(output_frame); - L_tmp = L_add(L_tmp, sum2_f_32_fx(hb_synth_fxl, output_frame, sub(11, gb))); + L_tmp = L_add(L_tmp, sum2_f_32_fx(hb_synth_32_fx[n], output_frame, sub(11, gb))); L_tmp = Mpy_32_16_1(L_tmp , tmp16); exp = norm_l(L_tmp); fra = Log2_norm_lc(L_shl(L_tmp, exp)); @@ -1958,7 +1964,7 @@ ivas_error ivas_core_dec( { //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)); + //hb_synth_32_fx[ch_ind][ind] = (Word32)(hb_synth[ch_ind][ind] * (1 << 11)); } } //Word16 q_DFT[2] = { 3, 3 }; @@ -2043,11 +2049,11 @@ ivas_error ivas_core_dec( { FOR(Word32 p = 0; p < L_FRAME48k; p++) { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] = (Word32)(hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] * (1u << OUTPUT_Q)); + //hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] = (Word32)(hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] * (1u << OUTPUT_Q)); } FOR(Word32 p = 0; p < TCXLTP_MAX_DELAY; p++) { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] = (Word32)(hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] * (1u << OUTPUT_Q)); + //hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] = (Word32)(hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] * (1u << OUTPUT_Q)); } } @@ -2056,11 +2062,11 @@ ivas_error ivas_core_dec( { FOR(Word32 p = 0; p < L_FRAME48k; p++) { - hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_out_32[p] = (Word32)(hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_out_float[p] * (1u << OUTPUT_Q)); + //hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_out_32[p] = (Word32)(hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_out_float[p] * (1u << OUTPUT_Q)); } FOR(Word32 p = 0; p < TCXLTP_MAX_DELAY; p++) { - hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_in_32[p] = (Word32)(hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_in_float[p] * (1u << OUTPUT_Q)); + //hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_in_32[p] = (Word32)(hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_in_float[p] * (1u << OUTPUT_Q)); } } IF(hCPE->hCoreCoder[ch_ind]->hTcxDec != NULL) @@ -2098,11 +2104,11 @@ ivas_error ivas_core_dec( { FOR(Word32 p = 0; p < L_FRAME48k; p++) { - hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_out_32[p] = (Word32)(hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_out_float[p] * (1u << OUTPUT_Q)); + //hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_out_32[p] = (Word32)(hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_out_float[p] * (1u << OUTPUT_Q)); } FOR(Word32 p = 0; p < TCXLTP_MAX_DELAY; p++) { - hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_in_32[p] = (Word32)(hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_in_float[p] * (1u << OUTPUT_Q)); + //hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_in_32[p] = (Word32)(hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_in_float[p] * (1u << OUTPUT_Q)); } } } @@ -2125,7 +2131,7 @@ ivas_error ivas_core_dec( { IF ( hCPE != NULL ) { - stereo_td2dft_update_fx( hCPE, n, output_32_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_32_fx[n], output_frame ); } } } @@ -2138,7 +2144,7 @@ ivas_error ivas_core_dec( } 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 ); + stereo_dft_dec_core_switching_fx( hCPE, output_32_fx[0], synth_fxg[0], hb_synth_32_fx[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] ); @@ -2151,7 +2157,7 @@ ivas_error ivas_core_dec( IF( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF ) ) { /* mono output for non-residual coding modes uses CLDFB instead of DFT - requires DFT buffer update in case of bitrate switching */ - stereo_td2dft_update_fx( hCPE, n, output_32_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_32_fx[n], output_frame ); } } @@ -2192,9 +2198,9 @@ ivas_error ivas_core_dec( Scale_sig(st->delay_buf_out_fx, NS2SA(st->output_Fs, DELAY_CLDFB_NS), exp_max - 0); Scale_sig(st->hHQ_core->old_out_fx + NS2SA(st->output_Fs, N_ZERO_MDCT_NS), NS2SA(st->output_Fs, PH_ECU_LOOKAHEAD_NS) - NS2SA(st->output_Fs, N_ZERO_MDCT_NS), exp_max - 0); Scale_sig(st->prev_synth_buffer_fx, NS2SA(48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS), exp_max - st->q_prev_synth_buffer_fx); - Scale_sig(st->hTcxDec->synth_history_fx + output_frame, 2 * output_frame - NS2SA(st->output_Fs, DELAY_CLDFB_NS) + NS2SA(st->output_Fs, PH_ECU_MEM_NS) - output_frame, exp_max - st->hTcxDec->q_synth_history_fx); + Scale_sig(st->hTcxDec->synth_history_fx + output_frame, 2 * output_frame - NS2SA(st->output_Fs, DELAY_CLDFB_NS) + NS2SA(st->output_Fs, PH_ECU_MEM_NS) - output_frame, exp_max - st->Q_syn); - st->hTcxDec->q_synth_history_fx = exp_max - st->q_prev_synth_buffer_fx; + //st->hTcxDec->q_synth_history_fx = exp_max - st->q_prev_synth_buffer_fx; st->q_prev_synth_buffer_fx = exp_max - st->q_prev_synth_buffer_fx; } /* Save synthesis for HQ FEC */ @@ -2214,7 +2220,7 @@ ivas_error ivas_core_dec( { //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 ); + //hb_synth[ch_ind][i] = (float) hb_synth_32_fx[ch_ind][i] / (float) ( 1 << 11 ); } } //IF( DFT != NULL ) @@ -2256,11 +2262,11 @@ ivas_error ivas_core_dec( { FOR(Word32 p = 0; p < L_FRAME48k; p++) { - hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_out_float[p] = (float)hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_out_32[p] / (1u << OUTPUT_Q); + //hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_out_float[p] = (float)hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_out_32[p] / (1u << OUTPUT_Q); } FOR(Word32 p = 0; p < TCXLTP_MAX_DELAY; p++) { - hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_in_float[p] = (float)hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_in_32[p] / (1u << OUTPUT_Q); + //hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_in_float[p] = (float)hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_in_32[p] / (1u << OUTPUT_Q); } } IF(hCPE->hCoreCoder[ch_ind]->hTcxDec != NULL) @@ -2312,11 +2318,11 @@ ivas_error ivas_core_dec( { FOR(Word32 p = 0; p < L_FRAME48k; p++) { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] = (float)hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] / (1u << OUTPUT_Q); + //hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] = (float)hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] / (1u << OUTPUT_Q); } FOR(Word32 p = 0; p < TCXLTP_MAX_DELAY; p++) { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] = (float)hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] / (1u << OUTPUT_Q); + //hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] = (float)hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] / (1u << OUTPUT_Q); } } } @@ -2349,11 +2355,11 @@ ivas_error ivas_core_dec( { FOR(Word32 p = 0; p < L_FRAME48k; p++) { - hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_out_float[p] = (float)hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_out_32[p] / (1u << OUTPUT_Q); + //hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_out_float[p] = (float)hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_out_32[p] / (1u << OUTPUT_Q); } FOR(Word32 p = 0; p < TCXLTP_MAX_DELAY; p++) { - hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_in_float[p] = (float)hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_in_32[p] / (1u << OUTPUT_Q); + //hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_in_float[p] = (float)hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_in_32[p] / (1u << OUTPUT_Q); } } } @@ -2363,7 +2369,7 @@ ivas_error ivas_core_dec( { for (i = 0; i < 2 * output_frame + NS2SA(st->output_Fs, PH_ECU_LOOKAHEAD_NS); i++) { - fix2f_16(&st->hTcxDec->synth_history_fx[i], &st->hTcxDec->synth_history[i], st->hTcxDec->q_synth_history_fx); + //fix2f_16(&st->hTcxDec->synth_history_fx[i], &st->hTcxDec->synth_history[i], st->hTcxDec->q_synth_history_fx); } } #endif diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index 807281206f0292343aad50e575d45888f345a85a..249c8d4922a80d75fc9c6070c77bfe9b10be89c3 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -78,7 +78,6 @@ ivas_error ivas_cpe_dec_fx( Word16 last_bwidth; Word16 tdm_ratio_idx; #ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED - float *output_flt[CPE_CHANNELS]; float outputHB[CPE_CHANNELS][L_FRAME48k]; /* 'float' buffer for output HB synthesis, both channels */ float res_buf[STEREO_DFT_N_8k]; Word32 outputHB_fx[CPE_CHANNELS][L_FRAME48k]; /* buffer for output HB synthesis, both channels */ @@ -96,16 +95,6 @@ ivas_error ivas_cpe_dec_fx( error = IVAS_ERR_OK; -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED - output_flt[0] = malloc( sizeof( float ) * L_FRAME48k ); - output_flt[1] = malloc( sizeof( float ) * L_FRAME48k ); - FOR( int k = 0; k < L_FRAME48k; k++ ) - { - output_flt[0][k] = (float) output[0][k] / ( 1 << *q_output ); - output_flt[1][k] = (float) output[1][k] / ( 1 << *q_output ); - } -#endif // IVAS_FLOAT_FIXED_TO_BE_REMOVED - push_wmops( "ivas_cpe_dec" ); ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; @@ -196,20 +185,20 @@ ivas_error ivas_cpe_dec_fx( q_tcxltp_mem_in_float = 11; IF(hCPE->hStereoDft && hCPE->hStereoDft->hTcxLtpDec) FOR(Word16 ind = 0; ind < s_min(12, (Word16)( TCXLTP_MAX_DELAY * st_ivas->hDecoderConfig->output_Fs ) / 48000) ; ind++) { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[ind] = (Word32)(hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[ind] * (1<hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[ind] = (Word32)(hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[ind] * (1<hStereoDft && hCPE->hStereoDft->hTcxLtpDec) FOR(Word16 ind = 0; ind < s_min(12, (Word16)( L_FRAME48k * st_ivas->hDecoderConfig->output_Fs ) / 48000) ; ind++) { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[ind] = (Word32)(hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[ind] * (1<hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[ind] = (Word32)(hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[ind] * (1<hCoreCoder[ind2] && hCPE->hCoreCoder[ind2]->hTcxLtpDec) FOR(Word16 ind = 0; ind < s_min(12, (Word16)(TCXLTP_MAX_DELAY * st_ivas->hDecoderConfig->output_Fs) / 48000); ind++) { - hCPE->hCoreCoder[ind2]->hTcxLtpDec->tcxltp_mem_in_32[ind] = (Word32)(hCPE->hCoreCoder[ind2]->hTcxLtpDec->tcxltp_mem_in_float[ind] * (1 << q_tcxltp_mem_in_float)); + //hCPE->hCoreCoder[ind2]->hTcxLtpDec->tcxltp_mem_in_32[ind] = (Word32)(hCPE->hCoreCoder[ind2]->hTcxLtpDec->tcxltp_mem_in_float[ind] * (1 << q_tcxltp_mem_in_float)); } IF(hCPE->hCoreCoder[ind2] && hCPE->hCoreCoder[ind2]->hTcxLtpDec) FOR(Word16 ind = 0; ind < s_min(12, (Word16)(L_FRAME48k * st_ivas->hDecoderConfig->output_Fs) / 48000); ind++) { - hCPE->hCoreCoder[ind2]->hTcxLtpDec->tcxltp_mem_out_32[ind] = (Word32)(hCPE->hCoreCoder[ind2]->hTcxLtpDec->tcxltp_mem_out_float[ind] * (1 << q_tcxltp_mem_in_float)); + //hCPE->hCoreCoder[ind2]->hTcxLtpDec->tcxltp_mem_out_32[ind] = (Word32)(hCPE->hCoreCoder[ind2]->hTcxLtpDec->tcxltp_mem_out_float[ind] * (1 << q_tcxltp_mem_in_float)); } IF(hCPE->hCoreCoder[ind2] && hCPE->hCoreCoder[ind2]->cldfbSyn) hCPE->hCoreCoder[ind2]->cldfbSyn->scale = (Word16)(hCPE->hCoreCoder[ind2]->cldfbSyn->scale_flt * (1u << norm_s((Word16)hCPE->hCoreCoder[0]->cldfbSyn->scale_flt))); @@ -260,20 +249,20 @@ ivas_error ivas_cpe_dec_fx( } IF(hCPE->hStereoDft && hCPE->hStereoDft->hTcxLtpDec) FOR(Word16 ind = 0; ind < s_min(12, (Word16)( TCXLTP_MAX_DELAY * st_ivas->hDecoderConfig->output_Fs ) / 48000) ; ind++) { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[ind] = (float)hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[ind] / (float)(1<hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[ind] = (float)hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[ind] / (float)(1<hStereoDft && hCPE->hStereoDft->hTcxLtpDec) FOR(Word16 ind = 0; ind < s_min(12, (Word16)( L_FRAME48k * st_ivas->hDecoderConfig->output_Fs ) / 48000) ; ind++) { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[ind] = (float)hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[ind] / (float)(1<hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[ind] = (float)hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[ind] / (float)(1<hCoreCoder[ind2] && hCPE->hCoreCoder[ind2]->hTcxLtpDec) FOR(Word16 ind = 0; ind < s_min(12, (Word16)( TCXLTP_MAX_DELAY * st_ivas->hDecoderConfig->output_Fs ) / 48000) ; ind++) { - hCPE->hCoreCoder[ind2]->hTcxLtpDec->tcxltp_mem_in_float[ind] = (float)hCPE->hCoreCoder[ind2]->hTcxLtpDec->tcxltp_mem_in_32[ind] / (float)(1<hCoreCoder[ind2]->hTcxLtpDec->tcxltp_mem_in_float[ind] = (float)hCPE->hCoreCoder[ind2]->hTcxLtpDec->tcxltp_mem_in_32[ind] / (float)(1<hCoreCoder[ind2] && hCPE->hCoreCoder[ind2]->hTcxLtpDec) FOR(Word16 ind = 0; ind < s_min(12, (Word16)( L_FRAME48k * st_ivas->hDecoderConfig->output_Fs ) / 48000) ; ind++) { - hCPE->hCoreCoder[ind2]->hTcxLtpDec->tcxltp_mem_out_float[ind] = (float)hCPE->hCoreCoder[ind2]->hTcxLtpDec->tcxltp_mem_out_32[ind] / (float)(1<hCoreCoder[ind2]->hTcxLtpDec->tcxltp_mem_out_float[ind] = (float)hCPE->hCoreCoder[ind2]->hTcxLtpDec->tcxltp_mem_out_32[ind] / (float)(1<hMCT, n_channels, output, 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_fx, 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); + fixedToFloat_arrL(outputHB_fx[0], outputHB[0], Q11, L_FRAME48k); + fixedToFloat_arrL(outputHB_fx[1], outputHB[1], Q11, L_FRAME48k); } IF( st_ivas->hMCT ) @@ -700,8 +689,6 @@ ivas_error ivas_cpe_dec_fx( *----------------------------------------------------------------*/ for (int j = 0; j < output_frame; j++) { - output[0][j] = (Word32)(output_flt[0][j] * (1 << *q_output)); - output[1][j] = (Word32)(output_flt[1][j] * (1 << *q_output)); outputHB_fx[0][j] = (Word32)(outputHB[0][j] * (1 << *q_output)); outputHB_fx[1][j] = (Word32)(outputHB[1][j] * (1 << *q_output)); } @@ -750,43 +737,96 @@ ivas_error ivas_cpe_dec_fx( set32_fx( DFT_fx[1], 0, STEREO_DFT_BUF_MAX ); /* core decoder */ - 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 ) + floatToFixed_arrL(outputHB[0], outputHB_fx[0], Q11, L_FRAME48k); + floatToFixed_arrL(outputHB[1], outputHB_fx[1], Q11, L_FRAME48k); + IF( ( error = ivas_core_dec( NULL, NULL, hCPE, st_ivas->hMCT, n_channels, output, outputHB_fx, 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(outputHB_fx[0], outputHB[0], Q11, L_FRAME48k); + fixedToFloat_arrL(outputHB_fx[1], outputHB[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); + // Scaling of DFT's + //Word16 q_dft_tmp = s_min(getScaleFactor32(DFT_fx[0], STEREO_DFT_BUF_MAX), getScaleFactor32(DFT_fx[1], STEREO_DFT_BUF_MAX)); + Word16 shift; + Word32 tmp1, tmp2; + maximum_abs_32_fx(DFT_fx[0], STEREO_DFT_BUF_MAX, &tmp1); + maximum_abs_32_fx(DFT_fx[1], STEREO_DFT_BUF_MAX, &tmp2); + + shift = s_min((tmp1 == 0) ? 31 : norm_l(tmp1), (tmp2 == 0) ? 31 : norm_l(tmp2)); + + if (shift != 31) { + shift = hCPE->hStereoDft->q_dft + shift - Q11; /* Q11 for guard bits */ + + IF(shift > hCPE->hStereoDft->q_dft) + { + Scale_sig32(DFT_fx[0], STEREO_DFT_BUF_MAX, shift - hCPE->hStereoDft->q_dft); + Scale_sig32(DFT_fx[1], STEREO_DFT_BUF_MAX, shift - hCPE->hStereoDft->q_dft); + hCPE->hStereoDft->q_dft = shift; + } + } + else + { + hCPE->hStereoDft->q_dft = Q8; + } + /* DFT Stereo residual decoding */ IF( GT_16( hCPE->hStereoDft->res_cod_band_max, 0 ) && !st_ivas->bfi ) { #ifndef IVAS_FLOAT_FIXED stereo_dft_dec_res( hCPE, res_buf, output_flt[1] ); + + stereo_dft_dec_analyze( hCPE, output[1], DFT, 1, L_FRAME8k, output_frame, DFT_STEREO_DEC_ANA_LB, 0, 0 ); #else - { - Word32 output_fix[L_FRAME8k]; - hCPE->hStereoDft->q_res_cod_mem_fx = 0; // keeping same as shift needed inside. - floatToFixed_arrL(hCPE->hStereoDft->res_cod_mem, hCPE->hStereoDft->res_cod_mem_fx, Q16, sizeof(hCPE->hStereoDft->res_cod_mem_fx) / sizeof(hCPE->hStereoDft->res_cod_mem_fx[0])); + //Word32 output_fix[L_FRAME8k]; + hCPE->hStereoDft->q_res_cod_mem_fx = 0; // keeping same as shift needed inside. + floatToFixed_arrL(hCPE->hStereoDft->res_cod_mem, hCPE->hStereoDft->res_cod_mem_fx, Q16, sizeof(hCPE->hStereoDft->res_cod_mem_fx) / sizeof(hCPE->hStereoDft->res_cod_mem_fx[0])); - Copy_Scale_sig_32_16(hCPE->hCoreCoder[0]->old_pitch_buf_fx, hCPE->hCoreCoder[0]->old_pitch_buf_16_fx, 2 * NB_SUBFR16k + 2, -10); + Copy_Scale_sig_32_16(hCPE->hCoreCoder[0]->old_pitch_buf_fx, hCPE->hCoreCoder[0]->old_pitch_buf_16_fx, 2 * NB_SUBFR16k + 2, -10); - stereo_dft_dec_res_fx(hCPE, res_buf_fx, Q8, output_fix); + stereo_dft_dec_res_fx(hCPE, res_buf_fx, Q8, output[1]); - Copy_Scale_sig_16_32(hCPE->hCoreCoder[0]->old_pitch_buf_16_fx, hCPE->hCoreCoder[0]->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, 10); + Copy_Scale_sig_16_32(hCPE->hCoreCoder[0]->old_pitch_buf_16_fx, hCPE->hCoreCoder[0]->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, 10); - fixedToFloat_arrL(hCPE->hStereoDft->res_cod_mem_fx, hCPE->hStereoDft->res_cod_mem, Q16, sizeof(hCPE->hStereoDft->res_cod_mem_fx) / sizeof(hCPE->hStereoDft->res_cod_mem_fx[0])); - fixedToFloat_arrL(&output_fix[0], output_flt[1], Q15, L_FRAME8k); - } + fixedToFloat_arrL(hCPE->hStereoDft->res_cod_mem_fx, hCPE->hStereoDft->res_cod_mem, Q16, sizeof(hCPE->hStereoDft->res_cod_mem_fx) / sizeof(hCPE->hStereoDft->res_cod_mem_fx[0])); + + Scale_sig32(output[1], L_FRAME8k, Q11 - Q15); // Q15 -> Q11 #endif + /////////////////////////////////////////////////////// + Word16 q = Q11; + Word32 output_Fs = hCPE->hCoreCoder[0]->output_Fs; + floatToFixed_arrL(hCPE->input_mem_BPF[0], hCPE->input_mem_BPF_fx[0], q, STEREO_DFT32MS_OVL_16k); + FOR(int i = 0; i < CPE_CHANNELS; ++i) + { + floatToFixed_arrL(hCPE->input_mem[i], hCPE->input_mem_fx[i], q, NS2SA(output_Fs, STEREO_DFT32MS_OVL_NS)); + floatToFixed_arrL(hCPE->input_mem_LB[i], hCPE->input_mem_LB_fx[i], q, STEREO_DFT32MS_OVL_16k); + } + /////////////////////////////////////////////////////// + Word16 q_out_DFT[2]; + q_out_DFT[0] = q_out_DFT[1] = hCPE->hStereoDft->q_dft; + // output in Q11, q not modified + // q_out_DFT only of 1 modified + + stereo_dft_dec_analyze_fx( hCPE, output[1], DFT_fx, 1, L_FRAME8k, output_frame, DFT_STEREO_DEC_ANA_LB, 0, 0, &q, q_out_DFT); // q not modified - stereo_dft_dec_analyze( hCPE, output_flt[1], DFT, 1, L_FRAME8k, output_frame, DFT_STEREO_DEC_ANA_LB, 0, 0 ); + /////////////////////////////////////////////////////// + fixedToFloat_arrL(hCPE->input_mem_BPF_fx[0], hCPE->input_mem_BPF[0], q, STEREO_DFT32MS_OVL_16k); + FOR(int i = 0; i < CPE_CHANNELS; ++i) + { + fixedToFloat_arrL(hCPE->input_mem_fx[i], hCPE->input_mem[i], q, NS2SA(output_Fs, STEREO_DFT32MS_OVL_NS)); + fixedToFloat_arrL(hCPE->input_mem_LB_fx[i], hCPE->input_mem_LB[i], q, STEREO_DFT32MS_OVL_16k); + } + /////////////////////////////////////////////////////// + + Scale_sig32(DFT_fx[1], STEREO_DFT_BUF_MAX, hCPE->hStereoDft->q_dft - q_out_DFT[1]); } + 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 CNG */ #ifndef IVAS_FLOAT_FIXED stereo_dtf_cng( hCPE, ivas_total_brate, DFT, output_frame ); @@ -795,6 +835,7 @@ ivas_error ivas_cpe_dec_fx( Word16 q_dft, q_smoothed_psd; float max_val = 0.0; int i_max_val =0, i_max_val_psd = 0; +#if 0 for (int ii = 0; ii < sizeof(DFT) / sizeof(DFT[0]); ii++) { for (int jj = 0; jj < sizeof(DFT[0]) / sizeof(DFT[0][0]); jj++) @@ -805,29 +846,35 @@ ivas_error ivas_cpe_dec_fx( } } } - max_val = 0.0; - for (int ii = 0; ii < sizeof(sts[0]->hFdCngDec->smoothed_psd) / sizeof(sts[0]->hFdCngDec->smoothed_psd[0]); ii++) - { - if (max_val < fabs(sts[0]->hFdCngDec->smoothed_psd[ii])) - { - max_val = (float)fabs(sts[0]->hFdCngDec->smoothed_psd[ii]); - } - } - i_max_val_psd = (int)max_val; - sts[0]->hFdCngDec->q_smoothed_psd = norm_l(i_max_val_psd) - Q4; + //max_val = 0.0; + //for (int ii = 0; ii < sizeof(sts[0]->hFdCngDec->smoothed_psd) / sizeof(sts[0]->hFdCngDec->smoothed_psd[0]); ii++) + //{ + // if (max_val < fabs(sts[0]->hFdCngDec->smoothed_psd[ii])) + // { + // max_val = (float)fabs(sts[0]->hFdCngDec->smoothed_psd[ii]); + // } + //} + //i_max_val_psd = (int)max_val; + //sts[0]->hFdCngDec->q_smoothed_psd = norm_l(i_max_val_psd) - Q4; i_max_val = (int)max_val; - q_dft = s_min(Q8, norm_l(i_max_val)); + if (i_max_val !=0) + q_dft = s_min(Q8, norm_l(i_max_val)); + else + q_dft = Q8; +#endif + + q_dft = hCPE->hStereoDft->q_dft; //hCPE->hStereoDft->q_dft = norm_l(i_max_val); //IF (hCPE->hStereoDft->q_dft > Q8) //{ // hCPE->hStereoDft->q_dft = Q8; //} - floatToFixed_arrL(sts[0]->hFdCngDec->bandNoiseShape_float, sts[0]->hFdCngDec->bandNoiseShape, Q31 - sts[0]->hFdCngDec->bandNoiseShape_exp, FFTLEN2); + //floatToFixed_arrL(sts[0]->hFdCngDec->bandNoiseShape_float, sts[0]->hFdCngDec->bandNoiseShape, Q31 - sts[0]->hFdCngDec->bandNoiseShape_exp, FFTLEN2); floatToFixed_arrL(&DFT[0][0], &DFT_fx[0][0], q_dft, sizeof(DFT) / sizeof(DFT[0][0])); //floatToFixed_arr(&hCPE->hCoreCoder[0]->hTdCngDec->shb_lpcCNG[0], &hCPE->hCoreCoder[0]->hTdCngDec->shb_lpcCNG_fx[0], Q15, sizeof(hCPE->hCoreCoder[0]->hTdCngDec->shb_lpcCNG_fx) / sizeof(hCPE->hCoreCoder[0]->hTdCngDec->shb_lpcCNG_fx[0])); floatToFixed_arr(&hCPE->hStereoCng->cm[0], &hCPE->hStereoCng->cm_fx[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); floatToFixed_arr(&hCPE->hStereoCng->coh[0], &hCPE->hStereoCng->coh_fx[0], Q15, sizeof(hCPE->hStereoCng->coh_fx) / sizeof(hCPE->hStereoCng->coh_fx[0]) ); - 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(&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])); hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->q_cngNoiseLevel = s_max(0, Q31 - hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp); floatToFixed_arrL(&hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[0], &hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel[0], @@ -840,11 +887,11 @@ ivas_error ivas_cpe_dec_fx( &hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[0], hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->q_cngNoiseLevel, FFTCLDFBLEN); - 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(&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_arr(&hCPE->hStereoCng->coh_fx[0], &hCPE->hStereoCng->coh[0], Q15, sizeof(hCPE->hStereoCng->coh_fx) / sizeof(hCPE->hStereoCng->coh_fx[0]) ); fixedToFloat_arr( &hCPE->hStereoCng->cm_fx[0], &hCPE->hStereoCng->cm[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); //fixedToFloat_arr(&hCPE->hCoreCoder[0]->hTdCngDec->shb_lpcCNG_fx[0], &hCPE->hCoreCoder[0]->hTdCngDec->shb_lpcCNG[0], Q15, sizeof(hCPE->hCoreCoder[0]->hTdCngDec->shb_lpcCNG) / sizeof(hCPE->hCoreCoder[0]->hTdCngDec->shb_lpcCNG[0])); - fixedToFloat_arrL(sts[0]->hFdCngDec->bandNoiseShape, sts[0]->hFdCngDec->bandNoiseShape_float, Q31 - sts[0]->hFdCngDec->bandNoiseShape_exp, FFTLEN2); + //fixedToFloat_arrL(sts[0]->hFdCngDec->bandNoiseShape, sts[0]->hFdCngDec->bandNoiseShape_float, Q31 - sts[0]->hFdCngDec->bandNoiseShape_exp, FFTLEN2); fixedToFloat_arrL(&DFT_fx[0][0], &DFT[0][0], q_dft, sizeof(DFT) / sizeof(DFT[0][0])); } #endif @@ -856,16 +903,16 @@ ivas_error ivas_cpe_dec_fx( float l_hb_nrg = 0.0, l_hb_nrg_subr = 0.0; float max_val = 0.0; int i_max_val = 0, i_max_val_psd; - { - for (int ii = 0; ii < sizeof(sts[0]->hFdCngDec->smoothed_psd) / sizeof(sts[0]->hFdCngDec->smoothed_psd[0]); ii++) - { - if (max_val < fabs(sts[0]->hFdCngDec->smoothed_psd[ii])) - { - max_val = (float)fabs(sts[0]->hFdCngDec->smoothed_psd[ii]); - } - } - i_max_val_psd = (int)max_val; - sts[0]->hFdCngDec->q_smoothed_psd = norm_l(i_max_val_psd) - Q4; +#if 0 + //for (int ii = 0; ii < sizeof(sts[0]->hFdCngDec->smoothed_psd) / sizeof(sts[0]->hFdCngDec->smoothed_psd[0]); ii++) + //{ + // if (max_val < fabs(sts[0]->hFdCngDec->smoothed_psd[ii])) + // { + // max_val = (float)fabs(sts[0]->hFdCngDec->smoothed_psd[ii]); + // } + //} + //i_max_val_psd = (int)max_val; + //sts[0]->hFdCngDec->q_smoothed_psd = norm_l(i_max_val_psd) - Q4; max_val = 0.0; for (int ii = 0; ii < sizeof(DFT) / sizeof(DFT[0]); ii++) { @@ -892,84 +939,82 @@ ivas_error ivas_cpe_dec_fx( { hCPE->hStereoDft->q_dft = 0; } - IF(EQ_16(hCPE->hStereoDft->first_frame, 1)) +#endif + IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) { - hCPE->hStereoDft->q_smoothed_nrg = hCPE->hStereoDft->q_dft; - FOR(int ii = 0; ii < sizeof(hCPE->hStereoDft->q_DFT_past_DMX_fx) / sizeof(hCPE->hStereoDft->q_DFT_past_DMX_fx[0]); ii++) - { - hCPE->hStereoDft->q_DFT_past_DMX_fx[ii] = hCPE->hStereoDft->q_dft; - } - hCPE->hStereoDft->first_frame = 0; + hCPE->hStereoDft->q_smoothed_nrg = hCPE->hStereoDft->q_dft; + FOR( int ii = 0; ii < sizeof( hCPE->hStereoDft->q_DFT_past_DMX_fx ) / sizeof( hCPE->hStereoDft->q_DFT_past_DMX_fx[0] ); ii++ ) + { + hCPE->hStereoDft->q_DFT_past_DMX_fx[ii] = hCPE->hStereoDft->q_dft; + } + hCPE->hStereoDft->first_frame = 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])); - for (int ii = 0; ii < sizeof(hCPE->hStereoDft->hb_nrg_subr_fx) / sizeof(hCPE->hStereoDft->hb_nrg_subr_fx[0]); ii++) + 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] ) ); + for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_subr_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_subr_fx[0] ); ii++ ) { - if (l_hb_nrg_subr < hCPE->hStereoDft->hb_nrg_subr[ii]) - { - l_hb_nrg_subr = hCPE->hStereoDft->hb_nrg_subr[ii]; - } + if ( l_hb_nrg_subr < hCPE->hStereoDft->hb_nrg_subr[ii] ) + { + l_hb_nrg_subr = hCPE->hStereoDft->hb_nrg_subr[ii]; + } } hCPE->hStereoDft->q_hb_nrg_subr = 0; - if (l_hb_nrg_subr > (float)MAX_32) + if ( l_hb_nrg_subr > (float) MAX_32 ) { - int quotient = (int)ceil(l_hb_nrg_subr / (float)MAX_32); - hCPE->hStereoDft->q_hb_nrg_subr = Q31 - norm_l(quotient); + int quotient = (int) ceil( l_hb_nrg_subr / (float) MAX_32 ); + hCPE->hStereoDft->q_hb_nrg_subr = Q31 - norm_l( quotient ); } - for (int ii = 0; ii < sizeof(hCPE->hStereoDft->hb_nrg_subr_fx) / sizeof(hCPE->hStereoDft->hb_nrg_subr_fx[0]); ii++) + for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_subr_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_subr_fx[0] ); ii++ ) { - hCPE->hStereoDft->hb_nrg_subr_fx[ii] = (Word32)(hCPE->hStereoDft->hb_nrg_subr[ii] / ((float)(1 << hCPE->hStereoDft->q_hb_nrg_subr))); + hCPE->hStereoDft->hb_nrg_subr_fx[ii] = (Word32) ( hCPE->hStereoDft->hb_nrg_subr[ii] / ( (float) ( 1 << hCPE->hStereoDft->q_hb_nrg_subr ) ) ); } - for (int ii = 0; ii < sizeof(hCPE->hStereoDft->hb_nrg_fx) / sizeof(hCPE->hStereoDft->hb_nrg_fx[0]); ii++) + for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_fx[0] ); ii++ ) { - if (l_hb_nrg < hCPE->hStereoDft->hb_nrg[ii]) - { - l_hb_nrg = hCPE->hStereoDft->hb_nrg[ii]; - } + if ( l_hb_nrg < hCPE->hStereoDft->hb_nrg[ii] ) + { + l_hb_nrg = hCPE->hStereoDft->hb_nrg[ii]; + } } hCPE->hStereoDft->q_hb_nrg = 0; - if (l_hb_nrg > (float)MAX_32) + if ( l_hb_nrg > (float) MAX_32 ) { - int quotient = (int)ceil(l_hb_nrg / (float)MAX_32); - hCPE->hStereoDft->q_hb_nrg = Q31 - norm_l(quotient); + int quotient = (int) ceil( l_hb_nrg / (float) MAX_32 ); + hCPE->hStereoDft->q_hb_nrg = Q31 - norm_l( quotient ); } - for (int ii = 0; ii < sizeof(hCPE->hStereoDft->hb_nrg_fx) / sizeof(hCPE->hStereoDft->hb_nrg_fx[0]); ii++) + for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_fx[0] ); ii++ ) { - hCPE->hStereoDft->hb_nrg_fx[ii] = (Word32)(hCPE->hStereoDft->hb_nrg[ii] / ((float)(1 << hCPE->hStereoDft->q_hb_nrg))); + hCPE->hStereoDft->hb_nrg_fx[ii] = (Word32) ( hCPE->hStereoDft->hb_nrg[ii] / ( (float) ( 1 << hCPE->hStereoDft->q_hb_nrg ) ) ); } - floatToFixed_arr(&hCPE->hStereoCng->cm[0], &hCPE->hStereoCng->cm_fx[0], Q15, sizeof(hCPE->hStereoCng->cm_fx) / sizeof(hCPE->hStereoCng->cm_fx[0])); - } + floatToFixed_arr( &hCPE->hStereoCng->cm[0], &hCPE->hStereoCng->cm_fx[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); #endif stereo_dft_unify_dmx_fx( hCPE->hStereoDft, sts[0], DFT_fx, hCPE->input_mem_fx[1], hCPE->hStereoCng->prev_sid_nodata ); #if 1 + if ( hCPE->hStereoDft->res_cod_band_max > 0 ) { - if (hCPE->hStereoDft->res_cod_band_max > 0) - { - if (!sts[0]->bfi) + if ( !sts[0]->bfi ) { - fixedToFloat_arrL(&hCPE->hStereoDft->res_mem_fx[0], &hCPE->hStereoDft->res_mem[0], hCPE->hStereoDft->q_res_mem, 2 * hCPE->hStereoDft->band_limits[hCPE->hStereoDft->res_cod_band_max]); + fixedToFloat_arrL( &hCPE->hStereoDft->res_mem_fx[0], &hCPE->hStereoDft->res_mem[0], hCPE->hStereoDft->q_res_mem, 2 * hCPE->hStereoDft->band_limits[hCPE->hStereoDft->res_cod_band_max] ); } else { - fixedToFloat_arrL(&hCPE->hStereoDft->res_cod_mem_fx[0], &hCPE->hStereoDft->res_cod_mem[0], hCPE->hStereoDft->q_res_cod_mem_fx, sizeof(hCPE->hStereoDft->res_cod_mem_fx) / sizeof(hCPE->hStereoDft->res_cod_mem_fx[0])); + fixedToFloat_arrL( &hCPE->hStereoDft->res_cod_mem_fx[0], &hCPE->hStereoDft->res_cod_mem[0], hCPE->hStereoDft->q_res_cod_mem_fx, sizeof( hCPE->hStereoDft->res_cod_mem_fx ) / sizeof( hCPE->hStereoDft->res_cod_mem_fx[0] ) ); } - } - fixedToFloat_arrL(&DFT_fx[0][0], &DFT[0][0], hCPE->hStereoDft->q_dft, (sizeof(DFT) / (2 * 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++) - { - hCPE->hStereoDft->hb_nrg_subr[0] = ((float)hCPE->hStereoDft->hb_nrg_subr_fx[0] * ((float)(1 << hCPE->hStereoDft->q_hb_nrg_subr))); - } - for (int ii = 0; ii < sizeof(hCPE->hStereoDft->hb_nrg_fx) / sizeof(hCPE->hStereoDft->hb_nrg_fx[0]); ii++) - { - hCPE->hStereoDft->hb_nrg[ii] = ((float)hCPE->hStereoDft->hb_nrg_fx[ii] * ((float)(1 << hCPE->hStereoDft->q_hb_nrg))); - } - fixedToFloat_arr(&hCPE->hStereoCng->cm_fx[0], &hCPE->hStereoCng->cm[0], Q15, sizeof(hCPE->hStereoCng->cm_fx) / sizeof(hCPE->hStereoCng->cm_fx[0])); - fixedToFloat_arrL(&hCPE->hStereoDft->td_gain_fx[0], &hCPE->hStereoDft->td_gain[0], Q15, sizeof(hCPE->hStereoDft->td_gain_fx) / sizeof(hCPE->hStereoDft->td_gain_fx[0])); } + fixedToFloat_arrL( &DFT_fx[0][0], &DFT[0][0], hCPE->hStereoDft->q_dft, ( sizeof( DFT ) / ( 2 * 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++ ) + { + hCPE->hStereoDft->hb_nrg_subr[0] = ( (float) hCPE->hStereoDft->hb_nrg_subr_fx[0] * ( (float) ( 1 << hCPE->hStereoDft->q_hb_nrg_subr ) ) ); + } + for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_fx[0] ); ii++ ) + { + hCPE->hStereoDft->hb_nrg[ii] = ( (float) hCPE->hStereoDft->hb_nrg_fx[ii] * ( (float) ( 1 << hCPE->hStereoDft->q_hb_nrg ) ) ); + } + fixedToFloat_arr( &hCPE->hStereoCng->cm_fx[0], &hCPE->hStereoCng->cm[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); + fixedToFloat_arrL( &hCPE->hStereoDft->td_gain_fx[0], &hCPE->hStereoDft->td_gain[0], Q15, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); #endif } ELSE @@ -978,15 +1023,16 @@ ivas_error ivas_cpe_dec_fx( float max_val = 0.0; int i_max_val = 0, i_max_val_psd; { - for (int ii = 0; ii < sizeof(sts[0]->hFdCngDec->smoothed_psd) / sizeof(sts[0]->hFdCngDec->smoothed_psd[0]); ii++) - { - if (max_val < fabs(sts[0]->hFdCngDec->smoothed_psd[ii])) - { - max_val = (float)fabs(sts[0]->hFdCngDec->smoothed_psd[ii]); - } - } - i_max_val_psd = (int)max_val; - sts[0]->hFdCngDec->q_smoothed_psd = norm_l(i_max_val_psd) - Q4; +#if 0 + //for (int ii = 0; ii < sizeof(sts[0]->hFdCngDec->smoothed_psd) / sizeof(sts[0]->hFdCngDec->smoothed_psd[0]); ii++) + //{ + // if (max_val < fabs(sts[0]->hFdCngDec->smoothed_psd[ii])) + // { + // max_val = (float)fabs(sts[0]->hFdCngDec->smoothed_psd[ii]); + // } + //} + //i_max_val_psd = (int)max_val; + //sts[0]->hFdCngDec->q_smoothed_psd = norm_l(i_max_val_psd) - Q4; max_val = 0.0; for (int ii = 0; ii < sizeof(DFT) / sizeof(DFT[0]); ii++) { @@ -1008,11 +1054,12 @@ ivas_error ivas_cpe_dec_fx( { hCPE->hStereoDft->q_dft = 0; } - hCPE->hStereoDft->q_dft = s_min(hCPE->hStereoDft->q_dft, sts[0]->hFdCngDec->q_smoothed_psd); + //hCPE->hStereoDft->q_dft = s_min(hCPE->hStereoDft->q_dft, sts[0]->hFdCngDec->q_smoothed_psd); IF (hCPE->hStereoDft->q_dft < 0) { hCPE->hStereoDft->q_dft = 0; } +#endif IF (EQ_16(hCPE->hStereoDft->first_frame, 1)) { hCPE->hStereoDft->q_smoothed_nrg = hCPE->hStereoDft->q_dft; @@ -1024,7 +1071,7 @@ ivas_error ivas_cpe_dec_fx( } // sts[0]->hFdCngDec->cna_rescale_fact_fx = (Word16)floatToFixed(sts[0]->hFdCngDec->cna_rescale_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(&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])); for (int ii = 0; ii < sizeof(hCPE->hStereoDft->hb_nrg_subr_fx) / sizeof(hCPE->hStereoDft->hb_nrg_subr_fx[0]); ii++) @@ -1071,7 +1118,7 @@ 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); - 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(&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++) { @@ -1089,6 +1136,11 @@ ivas_error ivas_cpe_dec_fx( } } + FOR( n = 0; n < hCPE->nchan_out; n++ ) + { + Scale_sig32( output[n], L_FRAME48k, hCPE->hStereoDft->q_dft - Q11 ); + } + /* synthesis iFFT */ FOR( n = 0; n < hCPE->nchan_out; n++ ) { @@ -1106,27 +1158,16 @@ ivas_error ivas_cpe_dec_fx( #endif } -#if 0 //delete below - for (int j = 0; j < output_frame; j++) + FOR( n = 0; n < hCPE->nchan_out; n++ ) { - output[0][j] = (Word32)(output_flt[0][j] * (1 << *q_output)); - output[1][j] = (Word32)(output_flt[1][j] * (1 << *q_output)); - outputHB_fx[0][j] = (Word32)(outputHB[0][j] * (1 << *q_output)); - outputHB_fx[1][j] = (Word32)(outputHB[1][j] * (1 << *q_output)); + Scale_sig32( output[n], L_FRAME48k, Q11 - hCPE->hStereoDft->q_dft); } -#else - //delete below for (int j = 0; j < output_frame; j++) { - output_flt[0][j] = ((float)output[0][j] / (1 << hCPE->hStereoDft->q_dft)); - output_flt[1][j] = ((float)output[1][j] / (1 << hCPE->hStereoDft->q_dft)); - output[0][j] = L_shl(output[0][j], sub(*q_output, hCPE->hStereoDft->q_dft)); - output[1][j] = L_shl(output[1][j], sub(*q_output, hCPE->hStereoDft->q_dft)); outputHB_fx[0][j] = (Word32)(outputHB[0][j] * (1 << *q_output)); outputHB_fx[1][j] = (Word32)(outputHB[1][j] * (1 << *q_output)); } -#endif } ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) ) { @@ -1187,11 +1228,11 @@ ivas_error ivas_cpe_dec_fx( { FOR( Word32 p = 0; p < L_FRAME48k; p++ ) { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] = (Word32) ( hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] * ( 1u << output_q ) ); + //hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] = (Word32) ( hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] * ( 1u << output_q ) ); } FOR( Word32 p = 0; p < TCXLTP_MAX_DELAY; p++ ) { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] = (Word32) ( hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] * ( 1u << output_q ) ); + //hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] = (Word32) ( hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] * ( 1u << output_q ) ); } } } @@ -1201,11 +1242,11 @@ ivas_error ivas_cpe_dec_fx( { FOR( Word32 p = 0; p < L_FRAME48k; p++ ) { - hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_32[p] = (Word32) ( hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_float[p] * ( 1u << output_q ) ); + //hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_32[p] = (Word32) ( hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_float[p] * ( 1u << output_q ) ); } FOR( Word32 p = 0; p < TCXLTP_MAX_DELAY; p++ ) { - hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_32[p] = (Word32) ( hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_float[p] * ( 1u << output_q ) ); + //hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_32[p] = (Word32) ( hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_float[p] * ( 1u << output_q ) ); } } @@ -1261,11 +1302,11 @@ ivas_error ivas_cpe_dec_fx( { FOR( Word32 p = 0; p < L_FRAME48k; p++ ) { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] = (float) hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] / ( 1u << output_q ); + //hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] = (float) hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] / ( 1u << output_q ); } FOR( Word32 p = 0; p < TCXLTP_MAX_DELAY; p++ ) { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] = (float) hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] / ( 1u << output_q ); + //hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] = (float) hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] / ( 1u << output_q ); } } } @@ -1284,11 +1325,11 @@ ivas_error ivas_cpe_dec_fx( { FOR( Word32 p = 0; p < L_FRAME48k; p++ ) { - hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_float[p] = (float) hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_32[p] / ( 1u << output_q ); + //hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_float[p] = (float) hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_32[p] / ( 1u << output_q ); } FOR( Word32 p = 0; p < TCXLTP_MAX_DELAY; p++ ) { - hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_float[p] = (float) hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_32[p] / ( 1u << output_q ); + //hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_float[p] = (float) hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_32[p] / ( 1u << output_q ); } } //FOR( Word32 k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); k++ ) @@ -1372,11 +1413,6 @@ ivas_error ivas_cpe_dec_fx( st_ivas->BER_detect = s_or( st_ivas->BER_detect, sts[0]->BER_detect ); st_ivas->BER_detect = s_or( st_ivas->BER_detect, sts[1]->BER_detect ); -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED - free( output_flt[0] ); - free( output_flt[1] ); -#endif // IVAS_FLOAT_FIXED_TO_BE_REMOVED - pop_wmops(); return error; } diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index fff08a3a15e9e2719bb45403647de51ac0092fb1..8a64bf7144939c91fe12fc8be3c1e05dcc082edf 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -185,7 +185,7 @@ static ivas_error ivas_dirac_rend_config_fx( /*Todo: remove float code*/ float *proto_frame_f_old; #ifdef IVAS_FLOAT_FIXED - Word16 *proto_frame_f_old_fx; + Word32 *proto_frame_f_old_fx; #endif Word16 proto_signal_decorr_on_old; uint16_t i, j, k; @@ -641,6 +641,7 @@ static ivas_error ivas_dirac_rend_config_fx( } } set32_fx( hDirACRend->hoa_encoder_fx, 0, nchan_out_woLFE * hDirACRend->num_outputs_diff ); + hDirACRend->hoa_encoder_len = nchan_out_woLFE * hDirACRend->num_outputs_diff; compute_hoa_encoder_mtx_fx( ls_azimuth_fx, ls_elevation_fx, hDirACRend->hoa_encoder_fx, hDirACRend->num_outputs_diff, hDirACRend->hOutSetup.ambisonics_order ); FOR( i = 0; i < nchan_out_woLFE * hDirACRend->num_outputs_diff; i++ ) @@ -812,20 +813,24 @@ static ivas_error ivas_dirac_rend_config_fx( IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - /*TODO : remove float code*/ +#if 1 /*TODO : remove float code*/ + IF( EQ_16( flag_config, DIRAC_RECONFIGURE ) && hDirACRend->proto_frame_f ) + { + free( hDirACRend->proto_frame_f ); + } + hDirACRend->proto_frame_f = NULL; +#endif IF( EQ_16( flag_config, DIRAC_RECONFIGURE ) && hDirACRend->proto_frame_f_fx ) { free( hDirACRend->proto_frame_f_fx ); - free( hDirACRend->proto_frame_f ); } hDirACRend->proto_frame_f_fx = NULL; - hDirACRend->proto_frame_f = NULL; } ELSE { IF( EQ_16( flag_config, DIRAC_OPEN ) || ( EQ_16( flag_config, DIRAC_RECONFIGURE ) && hDirACRend->proto_frame_f_fx == NULL ) ) { - IF( ( hDirACRend->proto_frame_f_fx = (Word16 *) malloc( sizeof( Word16 ) * 2 * hDirACRend->num_protos_diff * hSpatParamRendCom->num_freq_bands ) ) == NULL ) + IF( ( hDirACRend->proto_frame_f_fx = (Word32 *) malloc( sizeof( Word32 ) * 2 * hDirACRend->num_protos_diff * hSpatParamRendCom->num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); } @@ -834,11 +839,12 @@ static ivas_error ivas_dirac_rend_config_fx( { proto_frame_f_old_fx = hDirACRend->proto_frame_f_fx; free( proto_frame_f_old_fx ); - IF( ( hDirACRend->proto_frame_f_fx = (Word16 *) malloc( sizeof( Word16 ) * 2 * hDirACRend->num_protos_diff * hSpatParamRendCom->num_freq_bands ) ) == NULL ) + IF( ( hDirACRend->proto_frame_f_fx = (Word32 *) malloc( sizeof( Word32 ) * 2 * hDirACRend->num_protos_diff * hSpatParamRendCom->num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); } } + hDirACRend->proto_frame_f_len = 2 * hDirACRend->num_protos_diff * hSpatParamRendCom->num_freq_bands; #ifdef TRUE /*Todo : to remove float code*/ if ( flag_config == DIRAC_OPEN || ( flag_config == DIRAC_RECONFIGURE && hDirACRend->proto_frame_f == NULL ) ) @@ -3617,13 +3623,13 @@ void ivas_dirac_dec_render_sf( Word32 Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; set_zero_fx(surCohRatio_fx, CLDFB_NO_CHANNELS_MAX); Word16 q_cldfb, q_temp_cldfb;; - Word32 proto_frame_f_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX]; + //Word32 proto_frame_f_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX]; Word32 proto_direct_buffer_f_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX]; Word32 proto_power_smooth_fx[2 * CLDFB_NO_CHANNELS_MAX * MAX_OUTPUT_CHANNELS]; Word32 reference_power_fix[5 * CLDFB_NO_CHANNELS_MAX]; Word32 onset_filter_subframe_fix[2 * MAX_OUTPUT_CHANNELS]; Word32 proto_diffuse_buffer_f_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX]; - set_zero_fx( &proto_frame_f_fx[0], 2 * MAX_OUTPUT_CHANNELS * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ); + //set_zero_fx( &proto_frame_f_fx[0], 2 * MAX_OUTPUT_CHANNELS * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ); set_zero_fx( &proto_direct_buffer_f_fx[0], 2 * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX * MAX_OUTPUT_CHANNELS ); set_zero_fx( &proto_power_smooth_fx[0], 2 * CLDFB_NO_CHANNELS_MAX * MAX_OUTPUT_CHANNELS ); set_zero_fx( &reference_power_fix[0], 5 * CLDFB_NO_CHANNELS_MAX ); @@ -4117,7 +4123,7 @@ void ivas_dirac_dec_render_sf( } ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) { - protoSignalComputation2_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, proto_frame_f_fx, + protoSignalComputation2_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hDirACRend->proto_frame_f_fx, &hDirACRend->proto_frame_f_q, proto_direct_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, @@ -4137,7 +4143,7 @@ void ivas_dirac_dec_render_sf( case 6: case 4: protoSignalComputation4_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, - proto_frame_f_fx, + hDirACRend->proto_frame_f_fx, &hDirACRend->proto_frame_f_q, proto_direct_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, @@ -4152,7 +4158,7 @@ void ivas_dirac_dec_render_sf( hDirACRend->sba_map_tc, q_cldfb ); BREAK; case 2: - protoSignalComputation2_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, proto_frame_f_fx, + protoSignalComputation2_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hDirACRend->proto_frame_f_fx, &hDirACRend->proto_frame_f_q, proto_direct_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, @@ -4168,7 +4174,7 @@ void ivas_dirac_dec_render_sf( BREAK; case 1: protoSignalComputation1_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, - proto_frame_f_fx, + hDirACRend->proto_frame_f_fx, &hDirACRend->proto_frame_f_q, proto_direct_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, @@ -4275,7 +4281,7 @@ void ivas_dirac_dec_render_sf( { fixedToFloat_arrL32( proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); fixedToFloat_arrL32( &proto_direct_buffer_f_fx[i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 2 )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 2 ), hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( 4, hSpatParamRendCom->num_freq_bands ) ); - fixedToFloat_arrL32( proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); + fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); fixedToFloat_arrL32( reference_power_fix, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); IF( hDirACRend->masa_stereo_type_detect ) { @@ -4293,7 +4299,7 @@ void ivas_dirac_dec_render_sf( offset = i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); fixedToFloat_arrL32( proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); fixedToFloat_arrL32( &proto_direct_buffer_f_fx[offset], &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f[offset], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ) ); - fixedToFloat_arrL32( proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ) ); + fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ) ); fixedToFloat_arrL32( reference_power_fix, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); BREAK; case 2: @@ -4311,13 +4317,13 @@ void ivas_dirac_dec_render_sf( hDirACRend->masa_stereo_type_detect->subtract_power_y = fixedToFloat_32( hDirACRend->masa_stereo_type_detect->subtract_power_y_fx, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ); } } - fixedToFloat_arrL32( proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); + fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); fixedToFloat_arrL32( reference_power_fix, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); BREAK; case 1: fixedToFloat_arrL32( proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hSpatParamRendCom->num_freq_bands ); fixedToFloat_arrL32( &proto_direct_buffer_f_fx[i_mult( slot_idx, i_mult( 2, hSpatParamRendCom->num_freq_bands ) )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( slot_idx, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ), hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); - fixedToFloat_arrL32( proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_diff ) ) ); + fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_diff ) ) ); fixedToFloat_arrL32( reference_power_fix, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); BREAK; } @@ -4905,8 +4911,11 @@ void ivas_dirac_dec_render_sf( hDirACRend->proto_frame_dec_f = DirAC_mem.frame_dec_f; p_onset_filter = onset_filter; #ifdef IVAS_FLOAT_FIXED - floatToFixed_arrL( onset_filter, onset_filter_fx, Q30, hSpatParamRendCom->num_freq_bands ); + hDirACRend->proto_frame_dec_f_fx = DirAC_mem.frame_dec_f_fx; + hDirACRend->proto_frame_dec_f_q = DirAC_mem.frame_dec_f_q; + hDirACRend->proto_frame_dec_f_len = DirAC_mem.frame_dec_f_len; p_onset_filter_fx = onset_filter_fx; + floatToFixed_arrL(onset_filter, onset_filter_fx, Q30, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff); #endif } } @@ -4927,6 +4936,9 @@ void ivas_dirac_dec_render_sf( hDirACRend->proto_frame_dec_f = hDirACRend->proto_frame_f; p_onset_filter = NULL; #ifdef IVAS_FLOAT_FIXED + hDirACRend->proto_frame_dec_f_fx = hDirACRend->proto_frame_f_fx; + hDirACRend->proto_frame_dec_f_len = hDirACRend->proto_frame_f_len; + hDirACRend->proto_frame_dec_f_q = hDirACRend->proto_frame_f_q; p_onset_filter_fx = NULL; #endif } @@ -4939,7 +4951,37 @@ void ivas_dirac_dec_render_sf( if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_LS || hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_SHD ) { /*Compute diffuse prototypes*/ +#ifdef IVAS_FLOAT_FIXED + /* Float to fixed */ + if (hDirACRend->h_output_synthesis_psd_params.max_band_decorr != 0) + { + f2me_buf(hDirACRend->proto_frame_dec_f, hDirACRend->proto_frame_dec_f_fx, &hDirACRend->proto_frame_dec_f_q, hDirACRend->proto_frame_dec_f_len); + hDirACRend->proto_frame_dec_f_q = 31 - hDirACRend->proto_frame_dec_f_q; + DIRAC_OUTPUT_SYNTHESIS_STATE *state = &(hDirACRend->h_output_synthesis_psd_state); + f2me_buf(state->proto_power_diff_smooth, state->proto_power_diff_smooth_fx, &state->proto_power_diff_smooth_q, state->proto_power_diff_smooth_len); + state->proto_power_diff_smooth_q = 31 - state->proto_power_diff_smooth_q; + Word16 diffuse_start = slot_idx * 2 * hDirACRend->h_output_synthesis_psd_params.max_band_decorr * hDirACRend->hOutSetup.nchan_out_woLFE; + state->proto_diffuse_buffer_f_q = 31; + f2me_buf(state->proto_diffuse_buffer_f, state->proto_diffuse_buffer_f_fx, &state->proto_diffuse_buffer_f_q, diffuse_start); + state->proto_diffuse_buffer_f_q = 31 - state->proto_diffuse_buffer_f_q; + } + ivas_dirac_dec_compute_diffuse_proto_fx( hDirACRend, hSpatParamRendCom->num_freq_bands, slot_idx ); + /* Fixed to float */ + if (hDirACRend->h_output_synthesis_psd_params.max_band_decorr != 0) + { + DIRAC_OUTPUT_SYNTHESIS_STATE *state = &(hDirACRend->h_output_synthesis_psd_state); + me2f_buf(state->proto_power_diff_smooth_fx, + 31 - state->proto_power_diff_smooth_q, + state->proto_power_diff_smooth, + state->proto_power_diff_smooth_len); + me2f_buf(state->proto_diffuse_buffer_f_fx, + 31 - state->proto_diffuse_buffer_f_q, + state->proto_diffuse_buffer_f, + state->proto_diffuse_buffer_f_len); + } +#else ivas_dirac_dec_compute_diffuse_proto( hDirACRend, hSpatParamRendCom->num_freq_bands, slot_idx ); +#endif } /*Compute PSDs*/ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 3ec9035a7939e1f377186c0f336a1f97fd0a2eae..9c031b69e40d5b255d97ab309f3c52d156151909 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -70,6 +70,43 @@ ivas_error ivas_dec_setup( Word16 *data /* o : output synthesis signal */ ) { +#if 1 /*TODO:To be removed later*/ + RENDER_CONFIG_DATA *hRendCfg = st_ivas->hRenderConfig; + HRTFS_CREND_HANDLE hSetOfHRTF = st_ivas->hSetOfHRTF; + IF( hSetOfHRTF ) + { + hSetOfHRTF->hHRTF_brir_combined->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_brir_combined->latency_s, 31 ); + hSetOfHRTF->hHRTF_hrir_foa->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_hrir_foa->latency_s, 31 ); + hSetOfHRTF->hHRTF_hrir_combined->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_hrir_combined->latency_s, 31 ); + hSetOfHRTF->hHRTF_hrir_hoa3->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_hrir_hoa3->latency_s, 31 ); + hSetOfHRTF->hHRTF_hrir_hoa2->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_hrir_hoa2->latency_s, 31 ); + } + IF( hRendCfg ) + { + hRendCfg->roomAcoustics.acousticPreDelay_fx = floatToFixed( hRendCfg->roomAcoustics.acousticPreDelay, 27 ); + FOR( int i = 0; i < 60; i++ ) + { + hRendCfg->roomAcoustics.pFc_input_fx[i] = (Word32) ( hRendCfg->roomAcoustics.pFc_input[i] * ONE_IN_Q16 ); + hRendCfg->roomAcoustics.pAcoustic_rt60_fx[i] = (Word32) ( ( hRendCfg->roomAcoustics.pAcoustic_rt60[i] ) * ONE_IN_Q26 ); + hRendCfg->roomAcoustics.pAcoustic_dsr_fx[i] = (Word32) ( hRendCfg->roomAcoustics.pAcoustic_dsr[i] * ONE_IN_Q30 ); + } + + hRendCfg->roomAcoustics.inputPreDelay_fx = (Word32) ( hRendCfg->roomAcoustics.inputPreDelay * ONE_IN_Q27 ); + hRendCfg->roomAcoustics.dimensions.x_fx = (Word32) ( hRendCfg->roomAcoustics.dimensions.x * 4194304 ); // Q10.22, min value:1, max :999.0 + hRendCfg->roomAcoustics.dimensions.y_fx = (Word32) ( hRendCfg->roomAcoustics.dimensions.y * 4194304 ); // Q10.22 + hRendCfg->roomAcoustics.dimensions.z_fx = (Word32) ( hRendCfg->roomAcoustics.dimensions.z * 4194304 ); // Q10.22 + + + FOR( int ii = 0; ii < 6; ii++ ) + { + hRendCfg->roomAcoustics.AbsCoeff_fx[ii] = (Word32) ( hRendCfg->roomAcoustics.AbsCoeff[ii] * 1073741824 ); // Q2.30 min :0 max 1 + } + + hRendCfg->roomAcoustics.ListenerOrigin.x_fx = (Word32) ( hRendCfg->roomAcoustics.ListenerOrigin.x * 4194304 ); //( 2147483648 >> 2 ); + hRendCfg->roomAcoustics.ListenerOrigin.y_fx = (Word32) ( hRendCfg->roomAcoustics.ListenerOrigin.y * ( 4194304 ) ); + hRendCfg->roomAcoustics.ListenerOrigin.z_fx = (Word32) ( hRendCfg->roomAcoustics.ListenerOrigin.z * ( 4194304 ) ); + } +#endif Word16 k, idx, num_bits_read; Word16 nchan_ism, element_mode_flag; Decoder_State *st; @@ -703,6 +740,14 @@ ivas_error ivas_dec_setup( st->total_brate = ACELP_8k00; /* only temporary initialization - this is needed for get_next_indice() in the frame following NO_DATA frame */ } +#if 1 /*Cleanup changes: fixed to float*/ + IF( st_ivas->hCrendWrapper != NULL ) + { + st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe = fixedToFloat( st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe_fx, 14 ); + st_ivas->hCrendWrapper->hHrtfCrend->latency_s = fixedToFloat( st_ivas->hCrendWrapper->hHrtfCrend->latency_s_fx, 31 ); + fixedToFloat_arr( st_ivas->hCrendWrapper->hHrtfCrend->inv_diffuse_weight_fx, st_ivas->hCrendWrapper->hHrtfCrend->inv_diffuse_weight, 15, 16 ); + } +#endif return error; } @@ -1077,10 +1122,18 @@ ivas_error ivas_init_decoder_front( return error; } +#ifdef IVAS_FLOAT_FIXED + IF((error = ivas_render_config_init_from_rom_fx(&st_ivas->hRenderConfig)) != IVAS_ERR_OK) + { + return error; + } +#endif + /*FLOAT CODE*/ IF ( ( error = ivas_render_config_init_from_rom( &st_ivas->hRenderConfig ) ) != IVAS_ERR_OK ) { return error; } + /*---------*/ } return error; @@ -2007,7 +2060,7 @@ ivas_error ivas_init_decoder( IF ( st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - IF ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -2066,6 +2119,14 @@ ivas_error ivas_init_decoder( return error; } +#if 1 /*Cleanup changes: fixed to float*/ + IF( st_ivas->hCrendWrapper->hHrtfCrend != NULL ) + { + st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe = fixedToFloat( st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe_fx, 14 ); + st_ivas->hCrendWrapper->hHrtfCrend->latency_s = fixedToFloat( st_ivas->hCrendWrapper->hHrtfCrend->latency_s_fx, 31 ); + fixedToFloat_arr( st_ivas->hCrendWrapper->hHrtfCrend->inv_diffuse_weight_fx, st_ivas->hCrendWrapper->hHrtfCrend->inv_diffuse_weight, 15, 16 ); + } +#endif st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; IF ( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) @@ -2204,10 +2265,11 @@ ivas_error ivas_init_decoder( } set_zero( st_ivas->hLFE->prevsynth_buf, LFE_PLC_BUFLEN ); +#ifndef IVAS_FLOAT_FIXED set_zero( st_ivas->hLFE->prior_out_buffer, L_FRAME48k ); -#ifdef IVAS_FLOAT_FIXED - set32_fx(st_ivas->hLFE->prevsynth_buf_fx,0, LFE_PLC_BUFLEN); - set32_fx(st_ivas->hLFE->prior_out_buffer_fx,0, L_FRAME48k); +#else + set32_fx( st_ivas->hLFE->prevsynth_buf_fx, 0, LFE_PLC_BUFLEN ); + set32_fx( st_ivas->hLFE->prior_out_buffer_fx, 0, L_FRAME48k ); #endif // IVAS_FLOAT_FIXED } diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index d6560e17b4860c81d7bf16047391fa58453eafff..1c9b6c021e8e8462cab9877140428b8ab4c9d377 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -198,7 +198,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( } IF ( st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - IF ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL,st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -781,7 +781,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( #endif // IVAS_FLOAT_FIXED if ( st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL,st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -850,7 +850,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( } fixedToFloat_arrL(st_ivas->hHrtfParambin->parametricReverberationTimes_fx, st_ivas->hHrtfParambin->parametricReverberationTimes, 31, CLDFB_NO_CHANNELS_MAX ); fixedToFloat_arrL(st_ivas->hHrtfParambin->parametricReverberationEneCorrections_fx, st_ivas->hHrtfParambin->parametricReverberationEneCorrections, 31, CLDFB_NO_CHANNELS_MAX ); - fixedToFloat_arrL(st_ivas->hHrtfParambin->parametricEarlyPartEneCorrection_fx, st_ivas->hHrtfParambin->parametricEarlyPartEneCorrection, 31, CLDFB_NO_CHANNELS_MAX ); + fixedToFloat_arrL(st_ivas->hHrtfParambin->parametricEarlyPartEneCorrection_fx, st_ivas->hHrtfParambin->parametricEarlyPartEneCorrection, 28, CLDFB_NO_CHANNELS_MAX ); #endif #else if ( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index e8ed168402448e798d8959584e1e3d34bcb6dcb4..e87f2d96e7b79eae6b523d26882d1f53da1e052c 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -282,6 +282,87 @@ static void ivas_ism_get_proto_matrix( } #endif +#ifdef IVAS_FLOAT_FIXED +static void ivas_param_ism_collect_slot_fx( + PARAM_ISM_DEC_HANDLE hParamIsmDec, /* i/o: decoder ParamISM handle */ + Word32 *Cldfb_RealBuffer_in_fx, + Word16 exp_real, + Word32 *Cldfb_ImagBuffer_in_fx, + Word16 exp_imag, + const Word16 ch, + Word32 ref_power_fx[], + Word16 *exp_ref_power, + Word32 cx_diag_fx[][PARAM_ISM_MAX_DMX], + Word16 *exp_cx_diag ) +{ + Word16 band_idx, bin_idx; + Word16 brange[2]; + Word32 tmp_fx; + Word16 exp_tmp; + + /* loop over parameter bands to collect transport channel energies */ + + Word16 exp_ref_power_buf[CLDFB_NO_CHANNELS_MAX]; + Word16 exp_cx_diag_buf[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; + FOR( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) + { + brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx]; + move16(); + brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; + move16(); + FOR( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ ) + { + tmp_fx = 0; + exp_tmp = 0; + Word32 var1 = Mpy_32_32( Cldfb_RealBuffer_in_fx[bin_idx], Cldfb_RealBuffer_in_fx[bin_idx] ); // 2 * exp_real + Word32 var2 = Mpy_32_32( Cldfb_ImagBuffer_in_fx[bin_idx], Cldfb_ImagBuffer_in_fx[bin_idx] ); // 2 * exp_imag + tmp_fx = BASOP_Util_Add_Mant32Exp( tmp_fx, exp_tmp, var1, add( exp_real, exp_real ), &exp_tmp ); + tmp_fx = BASOP_Util_Add_Mant32Exp( tmp_fx, exp_tmp, var2, add( exp_imag, exp_imag ), &exp_tmp ); + + Word16 exp_cx_diag_new = 0, exp_ref_power_new = 0; + cx_diag_fx[bin_idx][ch] = BASOP_Util_Add_Mant32Exp( cx_diag_fx[bin_idx][ch], *exp_cx_diag, tmp_fx, exp_tmp, &exp_cx_diag_new ); + move32(); + ref_power_fx[bin_idx] = BASOP_Util_Add_Mant32Exp( ref_power_fx[bin_idx], *exp_ref_power, tmp_fx, exp_tmp, &exp_ref_power_new ); + move32(); + exp_cx_diag_buf[bin_idx][ch] = exp_cx_diag_new; + move16(); + exp_ref_power_buf[bin_idx] = exp_ref_power_new; + move16(); + } + } + + /*make common exponent*/ + Word16 max_exp_cx_diag = 0, max_exp_ref_power = 0; + Word16 a, b; + FOR( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) + { + a = hParamIsmDec->hParamIsm->band_grouping[band_idx]; + b = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; + FOR( bin_idx = a; bin_idx < b; bin_idx++ ) + { + max_exp_cx_diag = s_max( max_exp_cx_diag, exp_cx_diag_buf[bin_idx][ch] ); + max_exp_ref_power = s_max( max_exp_ref_power, exp_ref_power_buf[bin_idx] ); + } + } + + + FOR( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) + { + a = hParamIsmDec->hParamIsm->band_grouping[band_idx]; + b = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; + FOR( bin_idx = a; bin_idx < b; bin_idx++ ) + { + cx_diag_fx[bin_idx][ch] = L_shr( cx_diag_fx[bin_idx][ch], sub( max_exp_cx_diag, exp_cx_diag_buf[bin_idx][ch] ) ); + ref_power_fx[bin_idx] = L_shr( ref_power_fx[bin_idx], sub( max_exp_ref_power, exp_ref_power_buf[bin_idx] ) ); + } + } + + *exp_cx_diag = max_exp_cx_diag; + *exp_ref_power = max_exp_ref_power; + + return; +} +#endif static void ivas_param_ism_collect_slot( PARAM_ISM_DEC_HANDLE hParamIsmDec, /* i/o: decoder ParamISM handle */ @@ -291,7 +372,6 @@ static void ivas_param_ism_collect_slot( float ref_power[], float cx_diag[][PARAM_ISM_MAX_DMX] ) { - int16_t band_idx, bin_idx; int16_t brange[2]; float tmp; @@ -314,7 +394,6 @@ static void ivas_param_ism_collect_slot( return; } - static void ivas_param_ism_compute_mixing_matrix( const int16_t nchan_ism, /* i : number of ISM channels */ PARAM_ISM_DEC_HANDLE hParamIsmDec, /* i/o: decoder ParamISM handle */ @@ -1883,8 +1962,38 @@ void ivas_param_ism_dec_digest_tc( mvr2r( RealBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); mvr2r( ImagBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); } +#ifdef IVAS_FLOAT_FIXED + Word16 exp_real_tmp = 0, exp_imag_tmp = 0; + f2me_buf( &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &exp_real_tmp, hSpatParamRendCom->num_freq_bands ); + f2me_buf( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &exp_imag_tmp, hSpatParamRendCom->num_freq_bands ); + Word32 ref_power_fx[CLDFB_NO_CHANNELS_MAX]; + Word32 cx_diag_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; + Word16 exp_ref_power = 0, exp_cx_diag = 0; + f2me_buf( ref_power, ref_power_fx, &exp_ref_power, CLDFB_NO_CHANNELS_MAX ); + f2me_buf( (float *) cx_diag, (Word32 *) cx_diag_fx, &exp_cx_diag, CLDFB_NO_CHANNELS_MAX * PARAM_ISM_MAX_DMX ); + + ivas_param_ism_collect_slot_fx( hParamIsmDec, + &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], + exp_real_tmp, + &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], + exp_imag_tmp, + ch, + ref_power_fx, &exp_ref_power, cx_diag_fx, &exp_cx_diag ); + + FOR( int band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) + { + Word16 a = hParamIsmDec->hParamIsm->band_grouping[band_idx]; + Word16 b = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; + FOR( bin_idx = a; bin_idx < b; bin_idx++ ) + { - ivas_param_ism_collect_slot( hParamIsmDec, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], ch, ref_power, cx_diag ); + cx_diag[bin_idx][ch] = me2f( cx_diag_fx[bin_idx][ch], exp_cx_diag ); + ref_power[bin_idx] = me2f( ref_power_fx[bin_idx], exp_ref_power ); + } + } +#else + ivas_param_ism_collect_slot(hParamIsmDec, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], ch, ref_power, cx_diag); +#endif } } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index d761e1c72a801cc73fa0ae79d8a538613bfcef96..4b48b9a7fbbf48acf4da1ef174bfbc490fd5ecdd 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -61,7 +61,7 @@ static void ivas_jbm_dec_copy_tc( Decoder_Struct *st_ivas, const int16_t nSample static void ivas_jbm_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint16_t nSamplesAsked, uint16_t *nSamplesRendered, float *output[] ); #ifdef IVAS_FLOAT_FIXED -static void ivas_jbm_dec_tc_buffer_playout_fx( Decoder_Struct *st_ivas, const UWord16 nSamplesAsked, UWord16 *nSamplesRendered, Word32 *output_fx[]); +static void ivas_jbm_dec_tc_buffer_playout_fx( Decoder_Struct *st_ivas, const UWord16 nSamplesAsked, UWord16 *nSamplesRendered, Word32 *output_fx[] ); #endif static void ivas_jbm_dec_copy_masa_meta_to_buffer( Decoder_Struct *st_ivas ); @@ -78,7 +78,7 @@ static Word16 ceil_fx16( Word16 inp, Word16 Q ); static Word16 ceil_fx16( Word16 inp, Word16 Q ) { Word16 ret = shr( inp, Q ); - IF( (inp & ( ( 1 << Q ) - 1 )) > 0 ) + IF( ( inp & ( ( 1 << Q ) - 1 ) ) > 0 ) { ret = ret + 1; } @@ -97,20 +97,21 @@ ivas_error ivas_jbm_dec_tc( float *data /* o : transport channel signals */ ) { - 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 */ + Word16 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_fx[MAX_TRANSPORT_CHANNELS]; /* '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]; - int32_t output_Fs, ivas_total_brate; + Word16 nchan_remapped; + Word16 nb_bits_metadata[MAX_SCE + 1]; + Word32 output_Fs, ivas_total_brate; AUDIO_CONFIG output_config; ivas_error error; - int16_t num_md_sub_frames; - int32_t ism_total_brate; - + Word16 num_md_sub_frames; + Word32 ism_total_brate; + Word16 s; + MCT_DEC_HANDLE hMCT; CPE_DEC_HANDLE hCPE; SCE_DEC_HANDLE hSCE; @@ -125,31 +126,32 @@ ivas_error ivas_jbm_dec_tc( output_config = st_ivas->hDecoderConfig->output_config; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); + output_frame = (Word16) ( output_Fs / FRAMES_PER_SEC ); - for ( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) + FOR( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) { p_output[n] = st_ivas->p_output_f[n]; - if ( p_output[n] != NULL ) +#if 1 // TODO: To be removed later + IF( p_output[n] != NULL ) { set_zero( p_output[n], L_FRAME48k ); } -#ifdef IVAS_FLOAT_FIXED +#endif p_output_fx[n] = st_ivas->p_output_fx[n]; - if ( p_output_fx[n] != NULL ) + IF( p_output_fx[n] != NULL ) { - set_l( p_output_fx[n], 0, L_FRAME48k ); + set32_fx( p_output_fx[n], 0, L_FRAME48k ); } -#endif } - if ( !st_ivas->hDecoderConfig->Opt_tsm ) + IF( EQ_16( st_ivas->hDecoderConfig->Opt_tsm, 0 ) ) { - for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) + FOR( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) { - st_ivas->hTcBuffer->tc[n] = st_ivas->p_output_f[n]; -#ifdef IVAS_FLOAT_FIXED st_ivas->hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n]; +#if 1 // TODO: To be removed later + st_ivas->hTcBuffer->tc[n] = st_ivas->p_output_f[n]; + floatToFixed_arrL( st_ivas->hTcBuffer->tc[n], st_ivas->hTcBuffer->tc_fx[n], Q11, L_FRAME48k ); #endif } } @@ -158,22 +160,22 @@ ivas_error ivas_jbm_dec_tc( * Decoding + pre-rendering *----------------------------------------------------------------*/ - if ( st_ivas->bfi && st_ivas->ini_frame == 0 ) + IF( NE_16( st_ivas->bfi, 0 ) && EQ_16( st_ivas->ini_frame, 0 ) ) { +#if 1 // TODO: To be removed later /* zero output when first frame(s) is lost */ - for ( n = 0; n < nchan_out; n++ ) + FOR( n = 0; n < nchan_out; n++ ) { set_f( p_output[n], 0.0f, output_frame ); } -#ifdef IVAS_FLOAT_FIXED +#endif /* zero output when first frame(s) is lost */ - for ( n = 0; n < nchan_out; n++ ) + FOR( n = 0; n < nchan_out; n++ ) { - set_l( p_output_fx[n], 0, output_frame ); + set32_fx( p_output_fx[n], 0, output_frame ); } -#endif } - else if ( st_ivas->ivas_format == STEREO_FORMAT ) + ELSE IF( st_ivas->ivas_format == STEREO_FORMAT ) { st_ivas->hCPE[0]->element_brate = ivas_total_brate; #ifdef IVAS_FLOAT_FIXED @@ -186,10 +188,10 @@ ivas_error ivas_jbm_dec_tc( return error; } - for ( int k = 0; k < L_FRAME48k; k++ ) + IF( NE_16( q_output, Q11 ) ) { - 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 ); + Scale_sig32( p_output_fx[0], L_FRAME48k, sub( Q11, q_output ) ); + Scale_sig32( p_output_fx[1], L_FRAME48k, sub( Q11, q_output ) ); } #else if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, 0 ) ) != IVAS_ERR_OK ) @@ -199,31 +201,23 @@ ivas_error ivas_jbm_dec_tc( #endif // IVAS_FLOAT_FIXED /* HP filtering */ - for ( n = 0; n < min( nchan_out, st_ivas->nchan_transport ); n++ ) + FOR( n = 0; n < min( nchan_out, st_ivas->nchan_transport ); n++ ) { #ifdef IVAS_FLOAT_FIXED - for ( i = 0; i < output_frame; i++ ) - { - p_output_fx[n][i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); - } 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_fx[n][i] / ( 1 << 11 ); - } #else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); #endif // IVAS_FLOAT_FIXED } - if ( st_ivas->renderer_type == RENDERER_MC && st_ivas->hDecoderConfig->nchan_out == 1 ) + IF( st_ivas->renderer_type == RENDERER_MC && EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) ) { #ifdef IVAS_FLOAT_FIXED - Word16 q = Q16; - q = q - find_guarded_bits_fx( st_ivas->nchan_transport ); + s = sub( Q16, Q11 ); + s = sub( s, find_guarded_bits_fx( st_ivas->nchan_transport ) ); FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { - floatToFixed_arrL( p_output[i], p_output_fx[i], q, output_frame ); + Scale_sig32( p_output_fx[i], output_frame, s ); } FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) { @@ -235,17 +229,17 @@ ivas_error ivas_jbm_dec_tc( ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); 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 ); + Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); } #else ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, output_frame, p_output, p_output ); #endif } } - else if ( st_ivas->ivas_format == ISM_FORMAT ) + ELSE IF( st_ivas->ivas_format == ISM_FORMAT ) { /* Metadata decoding and configuration */ - if ( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) + IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) { #ifdef IVAS_FLOAT_FIXED #if 1 /*Cleanup changes: float to fixed*/ @@ -258,13 +252,6 @@ ivas_error ivas_jbm_dec_tc( st_ivas->hIsmMetaData[ind]->last_true_azimuth_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->last_true_azimuth * ( 1 << 22 ) ); st_ivas->hIsmMetaData[ind]->last_true_elevation_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->last_true_elevation * ( 1 << 22 ) ); } - //FOR( Word16 ind = 0; ind < st_ivas->nchan_transport; ind++ ) - //st_ivas->hSCE[ind]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx = (Word16) ( st_ivas->hSCE[ind]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_flt * 32767 ); - FOR( Word16 ch = 0; ch < st_ivas->nchan_ism; ch++ ) - { - st_ivas->hIsmMetaData[ch]->last_azimuth_fx = floatToFixed( st_ivas->hIsmMetaData[ch]->last_azimuth, 22 ); - st_ivas->hIsmMetaData[ch]->last_elevation_fx = floatToFixed( st_ivas->hIsmMetaData[ch]->last_elevation, 22 ); - } #endif ivas_ism_dtx_dec_fx( st_ivas, nb_bits_metadata ); #if 1 /*Cleanup changes: fixed to float*/ @@ -277,13 +264,6 @@ ivas_error ivas_jbm_dec_tc( st_ivas->hIsmMetaData[ind]->last_true_azimuth = (float) ( st_ivas->hIsmMetaData[ind]->last_true_azimuth_fx ) / (float) ( 1 << 22 ); st_ivas->hIsmMetaData[ind]->last_true_elevation = (float) ( st_ivas->hIsmMetaData[ind]->last_true_elevation_fx ) / (float) ( 1 << 22 ); } - //FOR( Word16 ind = 0; ind < st_ivas->nchan_transport; ind++ ) - //st_ivas->hSCE[ind]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_flt = (float) ( st_ivas->hSCE[ind]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx ) / 32767.f; - FOR( Word16 ch = 0; ch < st_ivas->nchan_ism; ch++ ) - { - st_ivas->hIsmMetaData[ch]->last_azimuth = fixedToFloat( st_ivas->hIsmMetaData[ch]->last_azimuth_fx, 22 ); - st_ivas->hIsmMetaData[ch]->last_elevation = fixedToFloat( st_ivas->hIsmMetaData[ch]->last_elevation_fx, 22 ); - } #endif #else ivas_ism_dtx_dec( st_ivas, nb_bits_metadata ); @@ -291,25 +271,11 @@ ivas_error ivas_jbm_dec_tc( #ifdef IVAS_FLOAT_FIXED 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, &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) p_output_fx[st_ivas->hISMDTX.sce_id_dtx][k] / ONE_IN_Q11; - } - for ( int k = 0; k < 96; k++ ) - { - //st_ivas->hSCE[st_ivas->hISMDTX.sce_id_dtx]->hCoreCoder[0]->prev_synth_buffer[k] = (float) st_ivas->hSCE[st_ivas->hISMDTX.sce_id_dtx]->hCoreCoder[0]->prev_synth_buffer32_fx[k] / ONE_IN_Q11; - //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; - } #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 ) @@ -350,7 +316,7 @@ ivas_error ivas_jbm_dec_tc( ivas_ism_dtx_limit_noise_energy_for_near_silence( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport ); #endif // IVAS_FLOAT_FIXED } - else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + ELSE IF( st_ivas->ism_mode == ISM_MODE_PARAM ) { #ifdef IVAS_FLOAT_FIXED @@ -389,7 +355,7 @@ ivas_error ivas_jbm_dec_tc( } #endif } - else /* ISM_MODE_DISC */ + ELSE /* ISM_MODE_DISC */ { #ifdef IVAS_FLOAT_FIXED FOR( Word16 ind = 0; ind < st_ivas->nchan_ism; ind++ ) @@ -428,33 +394,18 @@ ivas_error ivas_jbm_dec_tc( #endif } - for ( n = 0; n < st_ivas->nchan_transport; n++ ) + FOR( n = 0; n < st_ivas->nchan_transport; n++ ) { /* for DTX frames, dominant object has already been decoded before */ - if ( !( ( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) && n == st_ivas->hISMDTX.sce_id_dtx ) ) + IF( !( ( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) && n == st_ivas->hISMDTX.sce_id_dtx ) ) { #ifdef IVAS_FLOAT_FIXED 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, &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) p_output_fx[n][k] / ONE_IN_Q11; - } - for ( int k = 0; k < 96; k++ ) - { - //st_ivas->hSCE[n]->hCoreCoder[0]->prev_synth_buffer[k] = (float) st_ivas->hSCE[n]->hCoreCoder[0]->prev_synth_buffer32_fx[k] / ONE_IN_Q11; - //if ( k < 45 ) - // st_ivas->hSCE[n]->prev_hb_synth[k] = (float) st_ivas->hSCE[n]->prev_hb_synth_fx[k] / ONE_IN_Q11; - } #else if ( ( error = ivas_sce_dec( st_ivas, n, &p_output[n], output_frame, nb_bits_metadata[n] ) ) != IVAS_ERR_OK ) { @@ -465,86 +416,44 @@ ivas_error ivas_jbm_dec_tc( /* HP filtering */ #ifdef IVAS_FLOAT_FIXED - for ( i = 0; i < output_frame; i++ ) - { - p_output_fx[n][i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); - } 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_fx[n][i] / ( 1 << 11 ); - } #else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); #endif // IVAS_FLOAT_FIXED } - if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) + IF( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { #ifdef IVAS_FLOAT_FIXED - for ( int lp = 0; lp < 12; lp++ ) - { - if ( p_output[lp] != NULL ) - { - } - } - for ( int lp = 0; lp < 12; lp++ ) - { - if ( p_output[lp] != NULL ) - { - for ( int lp2 = 0; lp2 < output_frame; lp2++ ) - { - p_output_fx[lp][lp2] = (Word32) ( p_output[lp][lp2] * ( 1u << 11 ) ); - } - } - } 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) p_output_fx[0][lp] / ( 1u << 8 ); - } + Scale_sig32( p_output_fx[0], L_FRAME48k, 3 ); #else ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); #endif } - else if ( st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) + ELSE IF( st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) { /* loudness correction */ #ifdef IVAS_FLOAT_FIXED - for ( int lp = 0; lp < st_ivas->nchan_transport; lp++ ) - { - if ( p_output[lp] != NULL ) - { - } - } - Word16 Q_p_output = 31; - 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 ( 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 ( 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 ); + Scale_sig32( p_output_fx[i], output_frame, 1 ); } #else ivas_dirac_dec_binaural_sba_gain( p_output, st_ivas->nchan_transport, output_frame ); #endif // IVAS_FLOAT_FIXED } } - else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) + ELSE IF( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { - set_s( nb_bits_metadata, 0, MAX_SCE ); + set16_fx( nb_bits_metadata, 0, MAX_SCE ); /* read parameters from the bitstream */ - if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->hQMetaData != NULL ) + IF( st_ivas->ivas_format == MASA_FORMAT && st_ivas->hQMetaData != NULL ) { st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; @@ -642,12 +551,12 @@ ivas_error ivas_jbm_dec_tc( } #endif - if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + IF( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); } } - else if ( st_ivas->ivas_format == SBA_FORMAT ) + ELSE IF( st_ivas->ivas_format == SBA_FORMAT ) { #ifdef IVAS_FLOAT_FIXED IF( ( error = ivas_spar_dec_fx( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK ) @@ -662,34 +571,25 @@ ivas_error ivas_jbm_dec_tc( #endif } - if ( st_ivas->nchan_transport == CPE_CHANNELS && st_ivas->nCPE >= 1 ) + IF( EQ_16( st_ivas->nchan_transport, CPE_CHANNELS ) && GE_16( st_ivas->nCPE, 1 ) ) { st_ivas->hCPE[0]->brate_surplus = 0; + move32(); st_ivas->hCPE[0]->element_brate = ivas_total_brate; + move32(); } /* core-decoding of transport channels */ #ifdef IVAS_FLOAT_FIXED - Word16 q_output = 11; - + Word16 q_output = Q11; IF( EQ_16( st_ivas->nSCE, 1 ) ) { 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, &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) p_output_fx[0][k] / ( 1 << q_output ); - } } ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) { @@ -701,10 +601,10 @@ ivas_error ivas_jbm_dec_tc( return error; } - for ( int k = 0; k < L_FRAME48k; k++ ) + IF( NE_16( q_output, Q11 ) ) { - 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 ); + Scale_sig32( p_output_fx[0], L_FRAME48k, sub( Q11, q_output ) ); + Scale_sig32( p_output_fx[1], L_FRAME48k, sub( Q11, q_output ) ); } } #else @@ -723,22 +623,17 @@ ivas_error ivas_jbm_dec_tc( } } #endif // IVAS_FLOAT_FIXED - else if ( st_ivas->nCPE > 1 ) + ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) { #ifdef IVAS_FLOAT_FIXED #if 1 // Float to fix - + Word16 ch, nCPE, cpe_id; Word16 k, l; - + nCPE = st_ivas->nCPE; move16(); hMCT = st_ivas->hMCT; - FOR( i = 0; i < 12; i++ ) - if ( p_output[i] ) - { - floatToFixed_arrL( p_output[i], p_output_fx[i], Q11, L_FRAME48k ); - } FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { hCPE = st_ivas->hCPE[cpe_id]; @@ -748,39 +643,6 @@ ivas_error ivas_jbm_dec_tc( FOR( n = 0; n < CPE_CHANNELS; n++ ) { st = hCPE->hCoreCoder[n]; - IF( st->hTonalMDCTConc ) - { - - FOR( i = 0; i < st->hTonalMDCTConc->nScaleFactors; i++ ) - { - st->hTonalMDCTConc->scaleFactorsBackground_fx[i] = float_to_fix( st->hTonalMDCTConc->scaleFactorsBackground_flt[i], 15 ); - } - //st->hTonalMDCTConc->scf_fadeout = float_to_fix16( st->hTonalMDCTConc->scf_fadeout_flt, 15 ); - if ( hCPE->hCoreCoder[n]->bfi && st->tonal_mdct_plc_active ) - { - FOR( i = 0; i < FDNS_NPTS; i++ ) - { - f2me_16( st->hTonalMDCTConc->secondLastBlockData.scaleFactors_float[i], &st->hTonalMDCTConc->secondLastBlockData.scaleFactors[i], &st->hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i] ); - } - FOR( i = 0; i < 30; i++ ) - { - float pd = st->hTonalMDCTConc->pTCI->phaseDiff_float[i]; - if ( pd >= PI2 ) - pd = fmodf( pd, PI2 ) - PI2; - st->hTonalMDCTConc->pTCI->phaseDiff[i] = (Word16) floatToFixed( pd, Q12 ); - } - FOR( i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++ ) - { - float pd = st->hTonalMDCTConc->pTCI->phase_currentFramePredicted_float[i]; - pd = fmodf( pd, PI2 ); - st->hTonalMDCTConc->pTCI->phase_currentFramePredicted[i] = (Word16) ( pd * ( 1u << Q13 ) ); - } - } - //f2me( st->hTonalMDCTConc->last_block_nrg_flt, &st->hTonalMDCTConc->last_block_nrg, &st->hTonalMDCTConc->last_block_nrg_exp ); - } - // st->old_fpitch = float_to_fix(st->old_fpitch_float, 16); - st->hTcxDec->tcxltp_last_gain_unmodified = float_to_fix16( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 ); - IF( sts[n]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { // u8bit to 16bit @@ -805,21 +667,8 @@ ivas_error ivas_jbm_dec_tc( st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; IF( st->hTcxDec ) st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; - IF( st->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 ) ); - //} 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); - - IF( hCPE->hCoreCoder[n]->hTcxLtpDec ) - { - floatToFixed_arrL( hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_float, hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_32, q_output, L_FRAME48k ); - floatToFixed_arrL( hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_float, hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_32, q_output, TCXLTP_MAX_DELAY ); - //floatToFixed_arrL( hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float, hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32, Q11, 111 ); - } /*cldfb struct*/ @@ -849,8 +698,6 @@ ivas_error ivas_jbm_dec_tc( /*-------------------cldfb-end---------------------------*/ - - //floatToFixed_arr( sts[n]->prev_synth_buffer, hCPE->hCoreCoder[n]->prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); } IF( hCPE->output_mem[0] != NULL ) @@ -865,21 +712,6 @@ ivas_error ivas_jbm_dec_tc( FOR( n = 0; n < CPE_CHANNELS; n++ ) { - IF( hCPE->hStereoDft != NULL ) - { - IF( hCPE->hStereoDft->hTcxLtpDec != NULL ) - { - FOR( Word32 p = 0; p < L_FRAME48k; p++ ) - { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] = (Word32) ( hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] * ( 1u << q_output ) ); - } - FOR( Word32 p = 0; p < TCXLTP_MAX_DELAY; p++ ) - { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] = (Word32) ( hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] * ( 1u << q_output ) ); - } - } - } - IF( hCPE->input_mem_LB[n] != NULL ) { FOR( Word32 ind = 0; ind < STEREO_DFT32MS_OVL_16k; ind++ ) @@ -887,11 +719,6 @@ ivas_error ivas_jbm_dec_tc( hCPE->input_mem_LB_fx[n][ind] = (Word32) ( hCPE->input_mem_LB[n][ind] * ( 1 << q_output ) ); } } - - //FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); k++ ) - //{ - // hCPE->prev_hb_synth_fx[n][k] = (Word32) ( hCPE->prev_hb_synth[n][k] * ( 1 << q_output ) ); - //} FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) { hCPE->prev_synth_fx[n][k] = (Word32) ( hCPE->prev_synth[n][k] * ( 1 << q_output ) ); @@ -930,8 +757,6 @@ ivas_error ivas_jbm_dec_tc( FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = hCPE->hCoreCoder[ch]; - st->hTcxDec->tcxltp_last_gain_unmodified_float = fixedToFloat(st->hTcxLtpDec->tcxltp_gain, 15); - //st->hTcxDec->tcxltp_last_gain_unmodified_float = st->hTcxLtpDec->tcxltp_gain_float; IF( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { // 16bit to u8bit @@ -939,45 +764,6 @@ 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( st->hTonalMDCTConc != NULL ) - { - //st->hTonalMDCTConc->scf_fadeout_flt = fixedToFloat( st->hTonalMDCTConc->scf_fadeout, 15 ); - //st->hTonalMDCTConc->last_block_nrg_flt = me2f( st->hTonalMDCTConc->last_block_nrg, st->hTonalMDCTConc->last_block_nrg_exp ); - if ( hCPE->hCoreCoder[ch]->bfi && st->tonal_mdct_plc_active ) - { - //st->hTonalMDCTConc->nFramesLost_float = fix16_to_float( st->hTonalMDCTConc->nFramesLost, Q1 ); - } - } - - if ( sts[ch]->last_core != -1 && sts[ch]->nbLostCmpt == 1 ) - { - if ( !( sts[ch]->rf_flag && sts[ch]->use_partial_copy && ( sts[ch]->rf_frame_type == RF_TCXTD1 || sts[ch]->rf_frame_type == RF_TCXTD2 ) ) ) - { - IF( sts[ch]->hTonalMDCTConc != NULL && sts[ch]->last_core == TCX_20_CORE && sts[ch]->second_last_core == TCX_20_CORE && ( ( sts[ch]->old_fpitch <= L_shl( sts[ch]->L_frame, 15 ) ) || ( sts[ch]->hTcxDec->tcxltp_last_gain_unmodified <= 13107 /*0.4f*/ ) ) - /* it is fine to call the detection even if no ltp information - is available, meaning that st->old_fpitch == - st->tcxltp_second_last_pitch == st->L_frame */ - && ( sts[ch]->old_fpitch == sts[ch]->hTcxDec->tcxltp_second_last_pitch ) && !sts[ch]->last_tns_active && !sts[ch]->second_last_tns_active ) - { - - if ( sts[ch]->hTonalMDCTConc->pTCI->numIndexes < MAX_NUMBER_OF_IDX ) - { - FOR( i = 0; i < sts[ch]->hTonalMDCTConc->pTCI->numIndexes; i++ ) - { - sts[ch]->hTonalMDCTConc->pTCI->phaseDiff_float[i] = fixedToFloat( sts[ch]->hTonalMDCTConc->pTCI->phaseDiff[i], Q12 ); - } - FOR( i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++ ) - { - sts[ch]->hTonalMDCTConc->pTCI->phase_currentFramePredicted_float[i] = fixedToFloat( sts[ch]->hTonalMDCTConc->pTCI->phase_currentFramePredicted[i], Q13 ); - } - } - } - } } } @@ -992,16 +778,7 @@ ivas_error ivas_jbm_dec_tc( IF( sts[0]->bfi == 0 && !st->hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive ) fixedToFloat_arr( st->hTonalMDCTConc->secondLastPcmOut, st->hTonalMDCTConc->secondLastPcmOut_float, 0, st->hTonalMDCTConc->nSamples / 2 ); fixedToFloat_arr( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synthFB, st->Q_syn, st->hTcxDec->old_synth_lenFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); - 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 ); - //} - // 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; - // st->cummulative_damping_float = (float)st->cummulative_damping / MAX_16; - // st->old_enr_LP_float = (float)st->old_enr_LP / ONE_IN_Q3; + for ( int p = 0; p < st->L_frame / 2; p++ ) { st->hTcxDec->old_syn_Overl_float[p] = (float) st->hTcxDec->old_syn_Overl[p] * 2 * ( 1u << st->Q_syn ); @@ -1017,11 +794,7 @@ ivas_error ivas_jbm_dec_tc( { fixedToFloat_arr( st->p_bpf_noise_buf, st->p_bpf_noise_buf_float, 0, L_FRAME_16k ); } - - fixedToFloat_arr( st->hTcxDec->syn_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 ); - st->hTcxDec->tcxltp_last_gain_unmodified_float = fix16_to_float( st->hTcxDec->tcxltp_last_gain_unmodified, Q15 ); - //st->hTcxDec->conceal_eof_gain_float = fix16_to_float( st->hTcxDec->conceal_eof_gain, Q14 ); /*-------------------cldfb-start-------------------------*/ @@ -1066,47 +839,8 @@ ivas_error ivas_jbm_dec_tc( /*------------------reset-code-end-----------------------*/ - for ( int p = 0; p < L_FRAME48k; p++ ) - { - - IF( hCPE->hCoreCoder[n]->hTcxLtpDec ) - { - hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_float[p] = (float) hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_32[p] / ( 1u << q_output ); - if ( p < TCXLTP_MAX_DELAY ) - { - hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_float[p] = (float) hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_32[p] / ( 1u << q_output ); - } - } - } - if ( hCPE->hCoreCoder[n]->hTcxDec ) - { - for ( k = 0; k < 111; k++ ) - { - //hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] = (float) hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] / ( 1u << q_output ); - } - } - IF( hCPE->hCoreCoder[n]->hTcxLtpDec ) - - if ( ( hCPE->hCoreCoder[n]->codec_mode == MODE1 && hCPE->hCoreCoder[n]->hTcxDec != NULL ) && ( ( hCPE->hCoreCoder[n]->core == ACELP_CORE && !( hCPE->hCoreCoder[n]->bfi == 1 && hCPE->hCoreCoder[n]->con_tcx == 1 ) ) || hCPE->hCoreCoder[n]->core == HQ_CORE ) ) - { - fixedToFloat_arr( hCPE->hCoreCoder[n]->hTcxDec->synth_history_fx, hCPE->hCoreCoder[n]->hTcxDec->synth_history, 0, output_frame ); - } } - IF( hCPE->hStereoDft != NULL ) - { - IF( hCPE->hStereoDft->hTcxLtpDec != NULL ) - { - FOR( Word32 p = 0; p < L_FRAME48k; p++ ) - { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] = (float) hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] / ( 1u << q_output ); - } - FOR( Word32 p = 0; p < TCXLTP_MAX_DELAY; p++ ) - { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] = (float) hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] / ( 1u << q_output ); - } - } - } FOR( n = 0; n < CPE_CHANNELS; n++ ) { IF( hCPE->output_mem[n] != NULL ) @@ -1116,13 +850,6 @@ ivas_error ivas_jbm_dec_tc( hCPE->output_mem[n][k] = (float) hCPE->output_mem_fx[n][k] / ( 1u << 11 ); } } - //IF( hCPE->hCoreCoder[n] != NULL ) - //{ - // FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); k++ ) - // { - // hCPE->hCoreCoder[n]->prev_synth_buffer[k] = (float) hCPE->hCoreCoder[n]->prev_synth_buffer32_fx[k] / ( 1 << q_output ); - // } - //} IF( hCPE->input_mem[n] != NULL ) { FOR( Word32 ind = 0; ind < STEREO_DFT32MS_OVL_16k; ind++ ) @@ -1130,10 +857,6 @@ ivas_error ivas_jbm_dec_tc( hCPE->input_mem_LB[n][ind] = ( (float) hCPE->input_mem_LB_fx[n][ind] / ( 1 << q_output ) ); } } - //FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); k++ ) - //{ - // hCPE->prev_hb_synth[n][k] = (float) hCPE->prev_hb_synth_fx[n][k] / ( 1 << q_output ); - //} FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) { hCPE->prev_synth[n][k] = (float) hCPE->prev_synth_fx[n][k] / ( 1 << q_output ); @@ -1152,7 +875,6 @@ 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 ) ); 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]; @@ -1168,11 +890,6 @@ ivas_error ivas_jbm_dec_tc( IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx ) me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - FOR( i = 0; i < 12; i++ ) - if ( p_output[i] ) - { - fixedToFloat_arrL( p_output_fx[i], p_output[i], Q11, L_FRAME48k ); - } #endif // Fix to float #else if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) @@ -1188,18 +905,15 @@ ivas_error ivas_jbm_dec_tc( { nchan_remapped = nchan_out; - IF ( EQ_16(st_ivas->ivas_format, SBA_FORMAT )) + IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) ) { #ifdef IVAS_FLOAT_FIXED - 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); + 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( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) { - FOR( j = 0; j < output_frame; j++ ) - { - p_output_fx[i][j] = (Word32) ( p_output[i][j] * ONE_IN_Q14 ); - } + Scale_sig32( p_output_fx[i], output_frame, sub( Q14, Q11 ) ); } SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; Word16 num_bands_out, nchan_transport; @@ -1212,119 +926,112 @@ ivas_error ivas_jbm_dec_tc( hSpar->hMdDec->Q_mixer_mat = 31; Word16 num_in_ch; 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_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( i = 0; i < num_out_ch; i++ ) { - 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( 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_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( i = 0; i < num_out_ch; i++ ) { - 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( 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_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( i = 0; i < num_out_ch; i++ ) { - 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])); - } + 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++) + 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( i = 0; i < num_out_ch; i++ ) { - 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( 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( i = 0; i < num_out_ch; i++ ) { - 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( 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( i = 0; i < num_out_ch; i++ ) { - 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); - } + 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 ); + } + } } - } } #endif 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) + 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, p_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); + 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( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++) - { - FOR( j = 0; j < output_frame; j++) - { - p_output[i][j] = (float)p_output_fx[i][j] / ONE_IN_Q11; - } - } - FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) + 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( i = 0; i < num_out_ch; i++ ) { - 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); - } + 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 ); + } + } } - } } #endif #else - ivas_agc_dec_process(st_ivas->hSpar->hAgcDec, p_output, p_output, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame); + ivas_agc_dec_process( st_ivas->hSpar->hAgcDec, p_output, p_output, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); if ( st_ivas->hSpar->hPCA != NULL ) { ivas_pca_dec( 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 ); } - ivas_spar_dec_gen_umx_mat(st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes(st_ivas->sba_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate)); + ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); #endif } @@ -1334,52 +1041,28 @@ ivas_error ivas_jbm_dec_tc( { Word16 q; float l_hb_nrg = 0.0, l_hb_nrg_subr = 0.0; - //static int frame_counter = 0; - //if ( frame_counter >= 200 ) - // frame_counter = frame_counter; float max_val = 0.0; - int i_max_val_psd, i_max_val_op; + int i_max_val_op; 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] ) ) - { - max_val = (float) fabs( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[ii] ); - } - } - i_max_val_psd = (int) max_val; - for ( int ii = 0; ii < 2; ii++ ) - { - for ( int jj = 0; jj < ( 48000 / FRAMES_PER_SEC ); jj++ ) - { - if ( max_val < fabs( p_output[ii][jj] ) ) - { - max_val = (float) fabs( p_output[ii][jj] ); - } - } - } - i_max_val_op = (int)max_val; - hCPE->hStereoDft->q_dft = norm_l(i_max_val_op) - Q11; - IF(hCPE->hStereoDft->q_dft < 0) + i_max_val_op = (int) max_val; + s = 0; + FOR( i = 0; i < 2; i++ ) { - hCPE->hStereoDft->q_dft = 0; + s = s_min( s, L_norm_arr( p_output_fx[i], L_FRAME48k ) - 11 ) /* Guard bits */; } - ELSE IF (hCPE->hStereoDft->q_dft > Q11) + FOR( i = 0; i < 2; i++ ) { - hCPE->hStereoDft->q_dft = Q11; + Scale_sig32( p_output_fx[i], L_FRAME48k, s ); } - st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->q_smoothed_psd = norm_l(i_max_val_psd) - Q9; - IF (EQ_16(hCPE->hStereoDft->first_frame, 1)) + hCPE->hStereoDft->q_dft = Q11 + s; + // st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->q_smoothed_psd = Q11 - Q9; + IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) { - //hCPE->q_prev_synth_fx = hCPE->hStereoDft->q_dft; - hCPE->hStereoDft->q_smoothed_nrg = Q6;//hCPE->hStereoDft->q_dft; + hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; 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); - 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++) + for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_subr_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_subr_fx[0] ); ii++ ) { if ( l_hb_nrg_subr < hCPE->hStereoDft->hb_nrg_subr[ii] ) { @@ -1411,134 +1094,118 @@ ivas_error ivas_jbm_dec_tc( } for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_fx[0] ); ii++ ) { - hCPE->hStereoDft->hb_nrg_fx[ii] = (Word32)(hCPE->hStereoDft->hb_nrg[ii] * ((float)(1 << hCPE->hStereoDft->q_hb_nrg))); + hCPE->hStereoDft->hb_nrg_fx[ii] = (Word32) ( hCPE->hStereoDft->hb_nrg[ii] * ( (float) ( 1 << hCPE->hStereoDft->q_hb_nrg ) ) ); } - - //floatToFixed_arr( &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx[0], Q15, sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx[0] ) ); IF( hCPE->hStereoCng != NULL ) { floatToFixed_arr( &hCPE->hStereoCng->cm[0], &hCPE->hStereoCng->cm_fx[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); } - //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_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); - floatToFixed_arrL(&hCPE->input_mem[0][0], &hCPE->input_mem_fx[0][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS )); - floatToFixed_arrL(&hCPE->input_mem_LB[0][0], &hCPE->input_mem_LB_fx[0][0], q, STEREO_DFT32MS_OVL_16k); - floatToFixed_arrL(&hCPE->input_mem[1][0], &hCPE->input_mem_fx[1][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS )); - floatToFixed_arrL(&hCPE->input_mem_LB[1][0], &hCPE->input_mem_LB_fx[1][0], q, STEREO_DFT32MS_OVL_16k); - if (hSCE != NULL) - { - //floatToFixed_arrL(&hSCE->prev_hb_synth[0], &hSCE->prev_hb_synth_fx[0], hCPE->hStereoDft->q_dft, sizeof(hSCE->prev_hb_synth_fx) / sizeof(hSCE->prev_hb_synth_fx[0])); - //hSCE->q_prev_hb_synth_fx = hCPE->hStereoDft->q_dft; - floatToFixed_arrL(&hSCE->save_hb_synth[0], &hSCE->save_hb_synth_fx[0], q, (Word16)(hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC)); + floatToFixed_arrL( &hCPE->input_mem_BPF[0][0], &hCPE->input_mem_BPF_fx[0][0], q, STEREO_DFT32MS_OVL_16k ); + floatToFixed_arrL( &hCPE->input_mem[0][0], &hCPE->input_mem_fx[0][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ) ); + floatToFixed_arrL( &hCPE->input_mem_LB[0][0], &hCPE->input_mem_LB_fx[0][0], q, STEREO_DFT32MS_OVL_16k ); + floatToFixed_arrL( &hCPE->input_mem[1][0], &hCPE->input_mem_fx[1][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ) ); + floatToFixed_arrL( &hCPE->input_mem_LB[1][0], &hCPE->input_mem_LB_fx[1][0], q, STEREO_DFT32MS_OVL_16k ); + if ( hSCE != NULL ) + { + floatToFixed_arrL( &hSCE->save_hb_synth[0], &hSCE->save_hb_synth_fx[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); hSCE->q_save_hb_synth_fx = q; - floatToFixed_arrL(&hSCE->save_synth[0], &hSCE->save_synth_fx[0], q, (Word16)(hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC)); + floatToFixed_arrL( &hSCE->save_synth[0], &hSCE->save_synth_fx[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); hSCE->q_save_synth_fx = q; } IF( hCPE->hCoreCoder[0] != NULL ) { - floatToFixed_arrL(&hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], q, L_FRAME32k); + floatToFixed_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], q, L_FRAME32k ); hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; - floatToFixed_arrL(&hCPE->hCoreCoder[0]->hHQ_core->old_out[0], &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], q, L_FRAME48k); - IF( (hCPE->hCoreCoder[0] != NULL) && (hCPE->hCoreCoder[0]->p_bpf_noise_buf_32 != NULL) ) - floatToFixed_arrL(&hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], q, L_FRAME16k); + floatToFixed_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], q, L_FRAME48k ); + IF( ( hCPE->hCoreCoder[0] != NULL ) && ( hCPE->hCoreCoder[0]->p_bpf_noise_buf_32 != NULL ) ) + floatToFixed_arrL( &hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], q, L_FRAME16k ); } IF( hCPE->hStereoDft != NULL ) { - floatToFixed_arrL(&hCPE->hStereoDft->td_gain[0], &hCPE->hStereoDft->td_gain_fx[0], Q31, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); - floatToFixed_arrL(&hCPE->hStereoDft->ap_delay_mem[0], &hCPE->hStereoDft->ap_delay_mem_fx[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS )); - floatToFixed_arrL(&hCPE->hStereoDft->buff_LBTCX_mem[0], &hCPE->hStereoDft->buff_LBTCX_mem_fx[0], q, NS2SA( 16000, STEREO_DFT32MS_OVL_NS )); + floatToFixed_arrL( &hCPE->hStereoDft->td_gain[0], &hCPE->hStereoDft->td_gain_fx[0], Q31, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); + floatToFixed_arrL( &hCPE->hStereoDft->ap_delay_mem[0], &hCPE->hStereoDft->ap_delay_mem_fx[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); + floatToFixed_arrL( &hCPE->hStereoDft->buff_LBTCX_mem[0], &hCPE->hStereoDft->buff_LBTCX_mem_fx[0], q, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ) ); hCPE->hStereoDft->q_smooth_buf_fx = Q7; - floatToFixed_arrL(&hCPE->hStereoDft->smooth_buf[0][0], &hCPE->hStereoDft->smooth_buf_fx[0][0], hCPE->hStereoDft->q_smooth_buf_fx, sizeof(hCPE->hStereoDft->smooth_buf_fx) / sizeof(hCPE->hStereoDft->smooth_buf_fx[0][0])); - floatToFixed_arrL(&st_ivas->hSpar->hMdDec->mixer_mat_prev[0][0][0][0], &st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0], Q31, sizeof(st_ivas->hSpar->hMdDec->mixer_mat_prev_fx) / sizeof(st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0])); + floatToFixed_arrL( &hCPE->hStereoDft->smooth_buf[0][0], &hCPE->hStereoDft->smooth_buf_fx[0][0], hCPE->hStereoDft->q_smooth_buf_fx, sizeof( hCPE->hStereoDft->smooth_buf_fx ) / sizeof( hCPE->hStereoDft->smooth_buf_fx[0][0] ) ); + floatToFixed_arrL( &st_ivas->hSpar->hMdDec->mixer_mat_prev[0][0][0][0], &st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0], Q31, sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx ) / sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0] ) ); } - for (int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++) + for ( int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++ ) { - for (int jj = 0; jj < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; jj++) + for ( int jj = 0; jj < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; jj++ ) { - floatToFixed_arrL(&st_ivas->hSpar->hMdDec->mixer_mat[ii][jj][0], - &st_ivas->hSpar->hMdDec->mixer_mat_fx[ii][jj][0], - Q31, - st_ivas->hSpar->hMdDec->mix_mat_dim_2); + floatToFixed_arrL( &st_ivas->hSpar->hMdDec->mixer_mat[ii][jj][0], + &st_ivas->hSpar->hMdDec->mixer_mat_fx[ii][jj][0], + Q31, + st_ivas->hSpar->hMdDec->mix_mat_dim_2 ); } } - //hCPE->lt_es_em_fx = floatToFixed(hCPE->lt_es_em, Q15); - for (int ii = 0; ii < CPE_CHANNELS; ii++) + for ( int ii = 0; ii < CPE_CHANNELS; ii++ ) { hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; - floatToFixed_arrL(&hCPE->output_mem[ii][0], &hCPE->output_mem_fx[ii][0], hCPE->hStereoDft->q_dft, NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS )); + floatToFixed_arrL( &hCPE->output_mem[ii][0], &hCPE->output_mem_fx[ii][0], hCPE->hStereoDft->q_dft, NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ) ); } - 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])); + 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_fx, output_frame, st_ivas->ivas_format == MC_FORMAT ); + FOR( i = 0; i < 2; i++ ) + { + Scale_sig32( p_output_fx[i], L_FRAME48k, negate( s ) ); + } - 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 ); - 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] ) ); + 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] ) ); for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_subr_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_subr_fx[0] ); ii++ ) { - hCPE->hStereoDft->hb_nrg_subr[ii] = ((float)hCPE->hStereoDft->hb_nrg_subr_fx[ii] / ((float)(1 << hCPE->hStereoDft->q_hb_nrg_subr))); + hCPE->hStereoDft->hb_nrg_subr[ii] = ( (float) hCPE->hStereoDft->hb_nrg_subr_fx[ii] / ( (float) ( 1 << hCPE->hStereoDft->q_hb_nrg_subr ) ) ); } for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_fx[0] ); ii++ ) { hCPE->hStereoDft->hb_nrg[ii] = ( (float) hCPE->hStereoDft->hb_nrg_fx[ii] * ( (float) ( 1 << hCPE->hStereoDft->q_hb_nrg ) ) ); } - //fixedToFloat_arr(&st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm[0], Q15, sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx) / sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx[0])); - //fixedToFloat_arrL(&hCPE->prev_hb_synth_fx[0][0], &hCPE->prev_hb_synth[0][0], hCPE->hStereoDft->q_dft, sizeof(hCPE->prev_hb_synth_fx) / sizeof(hCPE->prev_hb_synth_fx[0][0])); - IF (hCPE->hStereoCng != NULL) + IF( hCPE->hStereoCng != NULL ) { fixedToFloat_arr( &hCPE->hStereoCng->cm_fx[0], &hCPE->hStereoCng->cm[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); } - //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_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 )); - fixedToFloat_arrL(&hCPE->input_mem_LB_fx[0][0], &hCPE->input_mem_LB[0][0], q, STEREO_DFT32MS_OVL_16k); - fixedToFloat_arrL(&hCPE->input_mem_fx[1][0], &hCPE->input_mem[1][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS )); - fixedToFloat_arrL(&hCPE->input_mem_LB_fx[1][0], &hCPE->input_mem_LB[1][0], q, STEREO_DFT32MS_OVL_16k); - if (hSCE != NULL) + + 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 ) ); + fixedToFloat_arrL( &hCPE->input_mem_LB_fx[0][0], &hCPE->input_mem_LB[0][0], q, STEREO_DFT32MS_OVL_16k ); + fixedToFloat_arrL( &hCPE->input_mem_fx[1][0], &hCPE->input_mem[1][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ) ); + fixedToFloat_arrL( &hCPE->input_mem_LB_fx[1][0], &hCPE->input_mem_LB[1][0], q, STEREO_DFT32MS_OVL_16k ); + if ( hSCE != NULL ) { - //fixedToFloat_arrL(&hSCE->prev_hb_synth_fx[0], &hSCE->prev_hb_synth[0], hCPE->hStereoDft->q_dft, sizeof(hSCE->prev_hb_synth_fx) / sizeof(hSCE->prev_hb_synth_fx[0])); - fixedToFloat_arrL(&hSCE->save_synth_fx[0], &hSCE->save_synth[0], q, (Word16)(hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC)); - fixedToFloat_arrL(&hSCE->save_hb_synth_fx[0], &hSCE->save_hb_synth[0], q, (Word16)(hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC)); + fixedToFloat_arrL( &hSCE->save_synth_fx[0], &hSCE->save_synth[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); + fixedToFloat_arrL( &hSCE->save_hb_synth_fx[0], &hSCE->save_hb_synth[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); } IF( hCPE->hCoreCoder[0] != NULL ) { - fixedToFloat_arrL(&hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], q, L_FRAME32k); - fixedToFloat_arrL(&hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], q, L_FRAME48k); + fixedToFloat_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], q, L_FRAME32k ); + fixedToFloat_arrL( &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], q, L_FRAME48k ); IF( hCPE->hCoreCoder[0]->p_bpf_noise_buf_32 != NULL ) - fixedToFloat_arrL(&hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], q, L_FRAME16k); + fixedToFloat_arrL( &hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], q, L_FRAME16k ); } IF( hCPE->hStereoDft != NULL ) { - fixedToFloat_arrL(&hCPE->hStereoDft->td_gain_fx[0], &hCPE->hStereoDft->td_gain[0], Q31, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); - fixedToFloat_arrL(&hCPE->hStereoDft->ap_delay_mem_fx[0], &hCPE->hStereoDft->ap_delay_mem[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS )); - fixedToFloat_arrL(&hCPE->hStereoDft->buff_LBTCX_mem_fx[0], &hCPE->hStereoDft->buff_LBTCX_mem[0], q, NS2SA( 16000, STEREO_DFT32MS_OVL_NS )); - fixedToFloat_arrL(&st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0], &st_ivas->hSpar->hMdDec->mixer_mat_prev[0][0][0][0], Q31, sizeof(st_ivas->hSpar->hMdDec->mixer_mat_prev_fx) / sizeof(st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0])); - fixedToFloat_arrL(&hCPE->hStereoDft->smooth_buf_fx[0][0], &hCPE->hStereoDft->smooth_buf[0][0], hCPE->hStereoDft->q_smooth_buf_fx, sizeof(hCPE->hStereoDft->smooth_buf_fx) / sizeof(hCPE->hStereoDft->smooth_buf_fx[0][0])); + fixedToFloat_arrL( &hCPE->hStereoDft->td_gain_fx[0], &hCPE->hStereoDft->td_gain[0], Q31, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); + fixedToFloat_arrL( &hCPE->hStereoDft->ap_delay_mem_fx[0], &hCPE->hStereoDft->ap_delay_mem[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); + fixedToFloat_arrL( &hCPE->hStereoDft->buff_LBTCX_mem_fx[0], &hCPE->hStereoDft->buff_LBTCX_mem[0], q, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ) ); + fixedToFloat_arrL( &st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0], &st_ivas->hSpar->hMdDec->mixer_mat_prev[0][0][0][0], Q31, sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx ) / sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0] ) ); + fixedToFloat_arrL( &hCPE->hStereoDft->smooth_buf_fx[0][0], &hCPE->hStereoDft->smooth_buf[0][0], hCPE->hStereoDft->q_smooth_buf_fx, sizeof( hCPE->hStereoDft->smooth_buf_fx ) / sizeof( hCPE->hStereoDft->smooth_buf_fx[0][0] ) ); } - for (int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++) + for ( int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++ ) { - for (int jj = 0; jj < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; jj++) + for ( int jj = 0; jj < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; jj++ ) { - fixedToFloat_arrL(&st_ivas->hSpar->hMdDec->mixer_mat_fx[ii][jj][0], - &st_ivas->hSpar->hMdDec->mixer_mat[ii][jj][0], - Q31, - st_ivas->hSpar->hMdDec->mix_mat_dim_2); + fixedToFloat_arrL( &st_ivas->hSpar->hMdDec->mixer_mat_fx[ii][jj][0], + &st_ivas->hSpar->hMdDec->mixer_mat[ii][jj][0], + Q31, + st_ivas->hSpar->hMdDec->mix_mat_dim_2 ); } } - for (int ii = 0; ii < CPE_CHANNELS; ii++) + for ( int ii = 0; ii < CPE_CHANNELS; ii++ ) { - fixedToFloat_arrL(&hCPE->output_mem_fx[ii][0], &hCPE->output_mem[ii][0], hCPE->hStereoDft->q_dft, NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS )); + fixedToFloat_arrL( &hCPE->output_mem_fx[ii][0], &hCPE->output_mem[ii][0], hCPE->hStereoDft->q_dft, NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ) ); } - //hCPE->lt_es_em = fixedToFloat(hCPE->lt_es_em_fx, Q15); } #endif } @@ -1551,15 +1218,7 @@ ivas_error ivas_jbm_dec_tc( for ( n = 0; n < nchan_remapped; n++ ) { #ifdef IVAS_FLOAT_FIXED - for ( i = 0; i < output_frame; i++ ) - { - p_output_fx[n][i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); - } 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_fx[n][i] / ( 1 << 11 ); - } #else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); #endif // IVAS_FLOAT_FIXED @@ -1568,22 +1227,7 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->ivas_format == SBA_FORMAT ) { #ifdef IVAS_FLOAT_FIXED -#if 1 - Word16 Q_sba = 31; - FOR( i = 2; i <= 3; i++ ) - { - Q_sba = s_min( Q_sba, Q_factor_arrL( p_output[i], output_frame ) ); - } - 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( i = 2; i <= 3; i++ ) - { - fixedToFloat_arrL( p_output_fx[i], p_output[i], Q_sba, output_frame ); - } #else nchan_remapped = ivas_sba_remapTCs( p_output, st_ivas, output_frame ); #endif // IVAS_FLOAT_FIXED @@ -1600,12 +1244,9 @@ ivas_error ivas_jbm_dec_tc( num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; nchan_out = nchan_transport; - FOR(ch = 0; ch < nchan_transport; ch++) + FOR( ch = 0; ch < nchan_transport; ch++ ) { - FOR(i = 0; i < output_frame; i++) - { - p_output_fx[ch][i] = floatToFixed(p_output[ch][i], Q_p_output); - } + Scale_sig32( p_output_fx[ch], output_frame, sub( Q_p_output, Q11 ) ); } Word16 b, i_ts, num_out_ch; num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; @@ -1613,101 +1254,98 @@ ivas_error ivas_jbm_dec_tc( hSpar->hMdDec->Q_mixer_mat = 31; Word16 num_in_ch; 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_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( i = 0; i < num_out_ch; i++ ) { - 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( 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_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( i = 0; i < num_out_ch; i++ ) { - 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( 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_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( i = 0; i < num_out_ch; i++ ) { - 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])); - } + 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++) + 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( i = 0; i < num_out_ch; i++ ) { - 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( 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( i = 0; i < num_out_ch; i++ ) { - 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( 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( i = 0; i < num_out_ch; i++ ) { - 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); - } + 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 ); + } + } } - } } #endif - ivas_sba_mix_matrix_determiner_fx(st_ivas->hSpar, p_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++) + 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( i = 0; i < num_out_ch; i++ ) { - FOR(b = 0; b < num_bands_out; b++) - { - hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = fixedToFloat(hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat); - } + FOR( j = 0; j < num_in_ch; j++ ) + { + FOR( b = 0; b < num_bands_out; b++ ) + { + hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = fixedToFloat( hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); + } + } } - } } - FOR(Word16 c = 0; c < nchan_transport; c++) + FOR( Word16 c = 0; c < nchan_transport; c++ ) { - FOR(j = 0; j < output_frame; j++) - { - p_output[c][j] = (float)p_output_fx[c][j]; - } + Scale_sig32( p_output_fx[c], output_frame, 11 ); } #endif #else @@ -1715,32 +1353,20 @@ ivas_error ivas_jbm_dec_tc( #endif } else if ( st_ivas->renderer_type != RENDERER_DISABLE ) - { + { #ifdef IVAS_FLOAT_FIXED Word16 size = st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; - if (st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport == 3) - size += 1; + if ( st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport == 3 ) + size += 1; - FOR( i = 0; i < size; i++) + FOR( i = 0; i < size; i++ ) { - FOR( j = 0; j < output_frame; j++) - { - p_output_fx[i][j] = (Word32)(p_output[i][j] * ONE_IN_Q14); - } + Scale_sig32( p_output_fx[i], output_frame, sub( Q14, Q11 ) ); } ivas_spar_dec_agc_pca_fx( st_ivas, p_output_fx, output_frame ); - - FOR( i = 0; i < size; i++) - { - FOR( j = 0; j < output_frame; j++) - { - p_output[i][j] = (float)p_output_fx[i][j] / ONE_IN_Q11; - } - //dbgwrite_txt_flt(p_output[i], output_frame, "p_output.txt"); - } #else - ivas_spar_dec_agc_pca(st_ivas, p_output, output_frame); + ivas_spar_dec_agc_pca( st_ivas, p_output, output_frame ); #endif } } @@ -1749,20 +1375,10 @@ ivas_error ivas_jbm_dec_tc( { #ifdef IVAS_FLOAT_FIXED Word16 q_shift = 0; - FOR( i = 0; i < 2; i++ ) - { - FOR( j = 0; j < output_frame; j++ ) - { - p_output_fx[i][j] = float_to_fix( p_output[i][j], Q11 ); - } - } ivas_masa_prerender_fx( st_ivas, p_output_fx, &q_shift, output_frame, nchan_remapped ); FOR( i = 0; i < 2; i++ ) { - FOR( j = 0; j < output_frame; j++ ) - { - p_output[i][j] = fix_to_float( p_output_fx[i][j], Q11 + q_shift ); - } + Scale_sig32( p_output_fx[i], output_frame, negate( q_shift ) ); } #else ivas_masa_prerender( st_ivas, p_output, output_frame, nchan_remapped ); @@ -1772,48 +1388,39 @@ ivas_error ivas_jbm_dec_tc( { /* loudness correction */ #ifdef IVAS_FLOAT_FIXED + ivas_dirac_dec_binaural_sba_gain_fx( p_output_fx, nchan_remapped, output_frame ); - Word16 Q_p_output = 31; - for ( 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 ( 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, nchan_remapped, output_frame); - - Q_p_output = Q_p_output - 1; - for ( i = 0; i < st_ivas->nchan_transport; i++) - { - fixedToFloat_arrL(p_output_fx[i], p_output[i], Q_p_output, output_frame); + Scale_sig32( p_output_fx[i], output_frame, 1 ); } #else ivas_dirac_dec_binaural_sba_gain( p_output, nchan_remapped, output_frame ); #endif - } } - else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + ELSE IF( st_ivas->ivas_format == MASA_ISM_FORMAT ) { - int16_t nchan_ism, nchan_transport_ism; - int16_t dirac_bs_md_write_idx; + Word16 nchan_ism, nchan_transport_ism; + Word16 dirac_bs_md_write_idx; - set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); + set16_fx( nb_bits_metadata, 0, MAX_SCE + 1 ); /* Set the number of objects for the parametric rendering */ dirac_bs_md_write_idx = 0; - if ( st_ivas->hSpatParamRendCom != NULL ) + move16(); + IF( st_ivas->hSpatParamRendCom != NULL ) { st_ivas->hSpatParamRendCom->numIsmDirections = 0; - if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) + move16(); + IF( st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) { st_ivas->hSpatParamRendCom->numIsmDirections = st_ivas->nchan_ism; + move16(); } dirac_bs_md_write_idx = st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx; /* Store the write-index for this frame */ + move16(); } @@ -1869,10 +1476,6 @@ ivas_error ivas_jbm_dec_tc( FOR( n = 0; n < tmp_nchan_ism; n++ ) { 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 ); - //} } ///////////////////////////////////// Float to fix conversion ends here. /////////////////////////////////// @@ -2013,20 +1616,11 @@ ivas_error ivas_jbm_dec_tc( st_ivas->hIsmMetaData[ind]->yaw = (float) ( st_ivas->hIsmMetaData[ind]->yaw_fx ) / (float) ( 1 << 22 ); st_ivas->hIsmMetaData[ind]->pitch = (float) ( st_ivas->hIsmMetaData[ind]->pitch_fx ) / (float) ( 1 << 22 ); } - FOR( n = 0; n < nchan_transport_ism; n++ ) - { - FOR( int k = 0; k < 96; k++ ) - { - //st_ivas->hSCE[n]->hCoreCoder[0]->prev_synth_buffer[k] = (float) st_ivas->hSCE[n]->hCoreCoder[0]->prev_synth_buffer32_fx[k] / ONE_IN_Q11; - //IF( k < 45 ) - // st_ivas->hSCE[n]->prev_hb_synth[k] = (float) st_ivas->hSCE[n]->prev_hb_synth_fx[k] / ONE_IN_Q11; - } - } - FOR( n = 0; n < s_max( getNumChanSynthesis( st_ivas ), nchan_transport_ism + st_ivas->nchan_transport ); n++ ) + IF( NE_16( output_q, Q11 ) ) { - FOR( i = 0; i < output_frame; i++ ) + FOR( n = 0; n < s_max( getNumChanSynthesis( st_ivas ), nchan_transport_ism + st_ivas->nchan_transport ); n++ ) { - p_output[n][i] = (float) p_output_fx[n][i] / ( 1 << output_q ); + Scale_sig32( p_output_fx[n], output_frame, sub( Q11, output_q ) ); } } /////////////////////////////////// Fixed to float conversion ends here. /////////////////////////////////// @@ -2136,26 +1730,11 @@ ivas_error ivas_jbm_dec_tc( IF( EQ_16( st_ivas->nSCE, 1 ) ) { 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, &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) p_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 ); - } } ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) { @@ -2165,10 +1744,10 @@ ivas_error ivas_jbm_dec_tc( return error; } - for ( int k = 0; k < output_frame; k++ ) + IF( NE_16( q_output, Q11 ) ) { - 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 ); + Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); + Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); } } #else @@ -2187,21 +1766,16 @@ ivas_error ivas_jbm_dec_tc( } } #endif // IVAS_FLOAT_FIXED - else if ( st_ivas->nCPE > 1 ) + ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) { #ifdef IVAS_FLOAT_FIXED #if 1 // Float to fix Word16 ch, nCPE, cpe_id; Word16 k, l; - + nCPE = st_ivas->nCPE; move16(); hMCT = st_ivas->hMCT; - FOR( i = 0; i < 12; i++ ) - if ( p_output[i] ) - { - floatToFixed_arrL( p_output[i], p_output_fx[i], Q11, L_FRAME48k ); - } FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { hCPE = st_ivas->hCPE[cpe_id]; @@ -2211,44 +1785,9 @@ ivas_error ivas_jbm_dec_tc( FOR( n = 0; n < CPE_CHANNELS; n++ ) { st = hCPE->hCoreCoder[n]; - IF( st->hTonalMDCTConc ) - { - - FOR( i = 0; i < st->hTonalMDCTConc->nScaleFactors; i++ ) - { - st->hTonalMDCTConc->scaleFactorsBackground_fx[i] = float_to_fix( st->hTonalMDCTConc->scaleFactorsBackground_flt[i], 15 ); - } - //st->hTonalMDCTConc->scf_fadeout = float_to_fix16( st->hTonalMDCTConc->scf_fadeout_flt, 15 ); - if ( hCPE->hCoreCoder[n]->bfi && st->tonal_mdct_plc_active ) - { - FOR( i = 0; i < FDNS_NPTS; i++ ) - { - f2me_16( st->hTonalMDCTConc->secondLastBlockData.scaleFactors_float[i], &st->hTonalMDCTConc->secondLastBlockData.scaleFactors[i], &st->hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i] ); - } - FOR( i = 0; i < 30; i++ ) - { - float pd = st->hTonalMDCTConc->pTCI->phaseDiff_float[i]; - if ( pd >= PI2 ) - pd = fmodf( pd, PI2 ) - PI2; - st->hTonalMDCTConc->pTCI->phaseDiff[i] = (Word16) floatToFixed( pd, Q12 ); - } - FOR( i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++ ) - { - float pd = st->hTonalMDCTConc->pTCI->phase_currentFramePredicted_float[i]; - pd = fmodf( pd, PI2 ); - st->hTonalMDCTConc->pTCI->phase_currentFramePredicted[i] = (Word16) ( pd * ( 1u << Q13 ) ); - } - // st->hTonalMDCTConc->nFramesLost = float_to_fix16( st->hTonalMDCTConc->nFramesLost, Q1 ); - } - //f2me( st->hTonalMDCTConc->last_block_nrg_flt, &st->hTonalMDCTConc->last_block_nrg, &st->hTonalMDCTConc->last_block_nrg_exp ); - } - // st->old_fpitch = float_to_fix(st->old_fpitch_float, 16); - st->hTcxDec->tcxltp_last_gain_unmodified = float_to_fix16( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 ); IF( sts[n]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { - // sts[n]->Mode2_lp_gainp = floatToFixed( sts[n]->lp_gainp, Q16 ); - // u8bit to 16bit FOR( l = 0; l < IGF_START_MX; l++ ) { sts[n]->hIGFDec->infoTCXNoise_evs[l] = (Word16) sts[n]->hIGFDec->infoTCXNoise[l]; @@ -2270,21 +1809,8 @@ ivas_error ivas_jbm_dec_tc( st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; IF( st->hTcxDec ) st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; - IF( st->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 ) ); - //} 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); - - IF( hCPE->hCoreCoder[n]->hTcxLtpDec ) - { - floatToFixed_arrL( hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_float, hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_32, q_output, L_FRAME48k ); - floatToFixed_arrL( hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_float, hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_32, q_output, TCXLTP_MAX_DELAY ); - //floatToFixed_arrL( hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float, hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32, Q11, 111 ); - } /*cldfb struct*/ @@ -2315,8 +1841,6 @@ ivas_error ivas_jbm_dec_tc( /*-------------------cldfb-end---------------------------*/ - - //floatToFixed_arr( sts[n]->prev_synth_buffer, hCPE->hCoreCoder[n]->prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); } IF( hCPE->output_mem[0] != NULL ) @@ -2331,21 +1855,6 @@ ivas_error ivas_jbm_dec_tc( FOR( n = 0; n < CPE_CHANNELS; n++ ) { - IF( hCPE->hStereoDft != NULL ) - { - IF( hCPE->hStereoDft->hTcxLtpDec != NULL ) - { - FOR( Word32 p = 0; p < L_FRAME48k; p++ ) - { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] = (Word32) ( hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] * ( 1u << q_output ) ); - } - FOR( Word32 p = 0; p < TCXLTP_MAX_DELAY; p++ ) - { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] = (Word32) ( hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] * ( 1u << q_output ) ); - } - } - } - IF( hCPE->input_mem_LB[n] != NULL ) { FOR( Word32 ind = 0; ind < STEREO_DFT32MS_OVL_16k; ind++ ) @@ -2353,11 +1862,6 @@ ivas_error ivas_jbm_dec_tc( hCPE->input_mem_LB_fx[n][ind] = (Word32) ( hCPE->input_mem_LB[n][ind] * ( 1 << q_output ) ); } } - - //FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); k++ ) - //{ - // hCPE->prev_hb_synth_fx[n][k] = (Word32) ( hCPE->prev_hb_synth[n][k] * ( 1 << q_output ) ); - //} FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) { hCPE->prev_synth_fx[n][k] = (Word32) ( hCPE->prev_synth[n][k] * ( 1 << q_output ) ); @@ -2396,8 +1900,6 @@ ivas_error ivas_jbm_dec_tc( FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = hCPE->hCoreCoder[ch]; - st->hTcxDec->tcxltp_last_gain_unmodified_float = fixedToFloat(st->hTcxLtpDec->tcxltp_gain, 15); - //st->hTcxDec->tcxltp_last_gain_unmodified_float = st->hTcxLtpDec->tcxltp_gain_float; IF( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { // 16bit to u8bit @@ -2405,47 +1907,8 @@ 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( st->hTonalMDCTConc != NULL ) - { - //st->hTonalMDCTConc->scf_fadeout_flt = fixedToFloat( st->hTonalMDCTConc->scf_fadeout, 15 ); - //st->hTonalMDCTConc->last_block_nrg_flt = me2f( st->hTonalMDCTConc->last_block_nrg, st->hTonalMDCTConc->last_block_nrg_exp ); - if ( hCPE->hCoreCoder[ch]->bfi && st->tonal_mdct_plc_active ) - { - //st->hTonalMDCTConc->nFramesLost_float = fix16_to_float( st->hTonalMDCTConc->nFramesLost, Q1 ); - } } - if ( sts[ch]->last_core != -1 && sts[ch]->nbLostCmpt == 1 ) - { - if ( !( sts[ch]->rf_flag && sts[ch]->use_partial_copy && ( sts[ch]->rf_frame_type == RF_TCXTD1 || sts[ch]->rf_frame_type == RF_TCXTD2 ) ) ) - { - IF( sts[ch]->hTonalMDCTConc != NULL && sts[ch]->last_core == TCX_20_CORE && sts[ch]->second_last_core == TCX_20_CORE && ( ( sts[ch]->old_fpitch <= L_shl( sts[ch]->L_frame, 15 ) ) || ( sts[ch]->hTcxDec->tcxltp_last_gain_unmodified <= 13107 /*0.4f*/ ) ) - /* it is fine to call the detection even if no ltp information - is available, meaning that st->old_fpitch == - st->tcxltp_second_last_pitch == st->L_frame */ - && ( sts[ch]->old_fpitch == sts[ch]->hTcxDec->tcxltp_second_last_pitch ) && !sts[ch]->last_tns_active && !sts[ch]->second_last_tns_active ) - { - - if ( sts[ch]->hTonalMDCTConc->pTCI->numIndexes < MAX_NUMBER_OF_IDX ) - { - FOR( i = 0; i < sts[ch]->hTonalMDCTConc->pTCI->numIndexes; i++ ) - { - sts[ch]->hTonalMDCTConc->pTCI->phaseDiff_float[i] = fixedToFloat( sts[ch]->hTonalMDCTConc->pTCI->phaseDiff[i], Q12 ); - } - FOR( i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++ ) - { - sts[ch]->hTonalMDCTConc->pTCI->phase_currentFramePredicted_float[i] = fixedToFloat( sts[ch]->hTonalMDCTConc->pTCI->phase_currentFramePredicted[i], Q13 ); - } - } - } - } - } } FOR( n = 0; n < 2; n++ ) @@ -2459,11 +1922,6 @@ ivas_error ivas_jbm_dec_tc( IF( sts[0]->bfi == 0 && !st->hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive ) fixedToFloat_arr( st->hTonalMDCTConc->secondLastPcmOut, st->hTonalMDCTConc->secondLastPcmOut_float, 0, st->hTonalMDCTConc->nSamples / 2 ); fixedToFloat_arr( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synthFB, st->Q_syn, st->hTcxDec->old_synth_lenFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); - 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 / 2; p++ ) { st->hTcxDec->old_syn_Overl_float[p] = (float) st->hTcxDec->old_syn_Overl[p] * 2 * ( 1u << st->Q_syn ); @@ -2480,10 +1938,7 @@ ivas_error ivas_jbm_dec_tc( fixedToFloat_arr( st->p_bpf_noise_buf, st->p_bpf_noise_buf_float, 0, L_FRAME_16k ); } - fixedToFloat_arr( st->hTcxDec->syn_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 ); - st->hTcxDec->tcxltp_last_gain_unmodified_float = fix16_to_float( st->hTcxDec->tcxltp_last_gain_unmodified, Q15 ); - //st->hTcxDec->conceal_eof_gain_float = fix16_to_float( st->hTcxDec->conceal_eof_gain, Q14 ); /*-------------------cldfb-start-------------------------*/ @@ -2523,48 +1978,8 @@ ivas_error ivas_jbm_dec_tc( sts[n]->hBWE_FD->prev_L_swb_norm = sts[n]->hBWE_FD->prev_L_swb_norm; sts[n]->hBWE_FD->prev_flag = sts[n]->hBWE_FD->prev_flag; } - - for ( int p = 0; p < L_FRAME48k; p++ ) - { - - IF( hCPE->hCoreCoder[n]->hTcxLtpDec ) - { - hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_float[p] = (float) hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_32[p] / ( 1u << q_output ); - if ( p < TCXLTP_MAX_DELAY ) - { - hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_float[p] = (float) hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_32[p] / ( 1u << q_output ); - } - } - } - if ( hCPE->hCoreCoder[n]->hTcxDec ) - { - for ( k = 0; k < 111; k++ ) - { - //hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] = (float) hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] / ( 1u << q_output ); - } - } - IF( hCPE->hCoreCoder[n]->hTcxLtpDec ) - - if ( ( hCPE->hCoreCoder[n]->codec_mode == MODE1 && hCPE->hCoreCoder[n]->hTcxDec != NULL ) && ( ( hCPE->hCoreCoder[n]->core == ACELP_CORE && !( hCPE->hCoreCoder[n]->bfi == 1 && hCPE->hCoreCoder[n]->con_tcx == 1 ) ) || hCPE->hCoreCoder[n]->core == HQ_CORE ) ) - { - fixedToFloat_arr( hCPE->hCoreCoder[n]->hTcxDec->synth_history_fx, hCPE->hCoreCoder[n]->hTcxDec->synth_history, 0, output_frame ); - } } - IF( hCPE->hStereoDft != NULL ) - { - IF( hCPE->hStereoDft->hTcxLtpDec != NULL ) - { - FOR( Word32 p = 0; p < L_FRAME48k; p++ ) - { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] = (float) hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] / ( 1u << q_output ); - } - FOR( Word32 p = 0; p < TCXLTP_MAX_DELAY; p++ ) - { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] = (float) hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] / ( 1u << q_output ); - } - } - } FOR( n = 0; n < CPE_CHANNELS; n++ ) { IF( hCPE->output_mem[n] != NULL ) @@ -2574,13 +1989,6 @@ ivas_error ivas_jbm_dec_tc( hCPE->output_mem[n][k] = (float) hCPE->output_mem_fx[n][k] / ( 1u << 11 ); } } - IF( hCPE->hCoreCoder[n] != NULL ) - { - FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); k++ ) - { - //hCPE->hCoreCoder[n]->prev_synth_buffer[k] = (float) hCPE->hCoreCoder[n]->prev_synth_buffer32_fx[k] / ( 1 << q_output ); - } - } IF( hCPE->input_mem[n] != NULL ) { FOR( Word32 ind = 0; ind < STEREO_DFT32MS_OVL_16k; ind++ ) @@ -2588,10 +1996,6 @@ ivas_error ivas_jbm_dec_tc( hCPE->input_mem_LB[n][ind] = ( (float) hCPE->input_mem_LB_fx[n][ind] / ( 1 << q_output ) ); } } - //FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); k++ ) - //{ - // hCPE->prev_hb_synth[n][k] = (float) hCPE->prev_hb_synth_fx[n][k] / ( 1 << q_output ); - //} FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) { hCPE->prev_synth[n][k] = (float) hCPE->prev_synth_fx[n][k] / ( 1 << q_output ); @@ -2610,7 +2014,6 @@ 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 ) ); 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]; @@ -2626,11 +2029,6 @@ ivas_error ivas_jbm_dec_tc( IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx ) me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - FOR( i = 0; i < 12; i++ ) - if ( p_output[i] ) - { - fixedToFloat_arrL( p_output_fx[i], p_output[i], Q11, L_FRAME48k ); - } #endif // Fix to float #else if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) @@ -2644,32 +2042,14 @@ ivas_error ivas_jbm_dec_tc( { #ifndef IVAS_FLOAT_FIXED ivas_agc_dec_process( st_ivas->hSpar->hAgcDec, &p_output[sba_ch_idx], &p_output[sba_ch_idx], st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); -#ifdef DUMPS_ENABLED - dbgwrite_txt( &p_output[sba_ch_idx], output_frame, "flt_ivas_agc_dec_process_output.txt", NULL ); -#endif // DUMPS_ENABLED #else FOR( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) { - FOR( j = 0; j < output_frame; j++ ) - { - p_output_fx[i + sba_ch_idx][j] = (Word32) ( p_output[i + sba_ch_idx][j] * ONE_IN_Q14 ); - } + Scale_sig32( p_output_fx[i + sba_ch_idx], output_frame, sub( Q14, Q11 ) ); } 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( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) - { - FOR( j = 0; j < output_frame; j++ ) - { - p_output[i + sba_ch_idx][j] = (float) p_output_fx[i + sba_ch_idx][j] / ONE_IN_Q11; - } - } - -#ifdef DUMPS_ENABLED - dbgwrite_txt( &p_output[sba_ch_idx][0], output_frame, "fix_ivas_agc_dec_process_output.txt", NULL ); -#endif // DUMPS_ENABLED - #endif // !IVAS_FLOAT_FIXED if ( st_ivas->hSpar->hPCA != NULL ) @@ -2685,53 +2065,25 @@ ivas_error ivas_jbm_dec_tc( { Word16 q; float l_hb_nrg = 0.0, l_hb_nrg_subr = 0.0; - static int frame_counter = 0; - if ( frame_counter >= 200 ) - frame_counter = frame_counter; - float max_val = 0.0; - int i_max_val_psd, i_max_val_op; 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] ) ) - { - max_val = (float) fabs( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[ii] ); - } - } - i_max_val_psd = (int) max_val; - for ( int ii = sba_ch_idx; ii < sba_ch_idx + 2; ii++ ) - { - for ( int jj = 0; jj < ( 48000 / FRAMES_PER_SEC ); jj++ ) - { - if ( max_val < fabs( p_output[ii][jj] ) ) - { - max_val = (float) fabs( p_output[ii][jj] ); - } - } - } - i_max_val_op = (int)max_val; - hCPE->hStereoDft->q_dft = norm_l(i_max_val_op) - Q11; - IF(hCPE->hStereoDft->q_dft < 0) + s = 0; + FOR( i = 0; i < 2; i++ ) { - hCPE->hStereoDft->q_dft = 0; + s = s_min( s, L_norm_arr( p_output_fx[sba_ch_idx + i], L_FRAME48k ) - 11 /* Guard bits */ ); } - ELSE IF (hCPE->hStereoDft->q_dft > Q11) + FOR( i = 0; i < 2; i++ ) { - hCPE->hStereoDft->q_dft = Q11; + Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, s ); } - st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->q_smoothed_psd = norm_l(i_max_val_psd) - Q9; - IF (EQ_16(hCPE->hStereoDft->first_frame, 1)) + hCPE->hStereoDft->q_dft = Q11 + s; + // st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->q_smoothed_psd = Q11 - Q9; + IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) { - //hCPE->q_prev_synth_fx = hCPE->hStereoDft->q_dft; - hCPE->hStereoDft->q_smoothed_nrg = Q6;//hCPE->hStereoDft->q_dft; + hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; 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); - 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++) + for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_subr_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_subr_fx[0] ); ii++ ) { if ( l_hb_nrg_subr < hCPE->hStereoDft->hb_nrg_subr[ii] ) { @@ -2763,178 +2115,137 @@ ivas_error ivas_jbm_dec_tc( } for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_fx[0] ); ii++ ) { - hCPE->hStereoDft->hb_nrg_fx[ii] = (Word32)(hCPE->hStereoDft->hb_nrg[ii] * ((float)(1 << hCPE->hStereoDft->q_hb_nrg))); + hCPE->hStereoDft->hb_nrg_fx[ii] = (Word32) ( hCPE->hStereoDft->hb_nrg[ii] * ( (float) ( 1 << hCPE->hStereoDft->q_hb_nrg ) ) ); } - //floatToFixed_arr( &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx[0], Q15, sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx[0] ) ); IF( hCPE->hStereoCng != NULL ) { floatToFixed_arr( &hCPE->hStereoCng->cm[0], &hCPE->hStereoCng->cm_fx[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); } - //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_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); - floatToFixed_arrL(&hCPE->input_mem[0][0], &hCPE->input_mem_fx[0][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS )); - floatToFixed_arrL(&hCPE->input_mem_LB[0][0], &hCPE->input_mem_LB_fx[0][0], q, STEREO_DFT32MS_OVL_16k); - floatToFixed_arrL(&hCPE->input_mem[1][0], &hCPE->input_mem_fx[1][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS )); - floatToFixed_arrL(&hCPE->input_mem_LB[1][0], &hCPE->input_mem_LB_fx[1][0], q, STEREO_DFT32MS_OVL_16k); - if (hSCE != NULL) - { - //floatToFixed_arrL(&hSCE->prev_hb_synth[0], &hSCE->prev_hb_synth_fx[0], hCPE->hStereoDft->q_dft, sizeof(hSCE->prev_hb_synth_fx) / sizeof(hSCE->prev_hb_synth_fx[0])); - //hSCE->q_prev_hb_synth_fx = hCPE->hStereoDft->q_dft; - floatToFixed_arrL(&hSCE->save_hb_synth[0], &hSCE->save_hb_synth_fx[0], q, (Word16)(hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC)); + floatToFixed_arrL( &hCPE->input_mem_BPF[0][0], &hCPE->input_mem_BPF_fx[0][0], q, STEREO_DFT32MS_OVL_16k ); + floatToFixed_arrL( &hCPE->input_mem[0][0], &hCPE->input_mem_fx[0][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ) ); + floatToFixed_arrL( &hCPE->input_mem_LB[0][0], &hCPE->input_mem_LB_fx[0][0], q, STEREO_DFT32MS_OVL_16k ); + floatToFixed_arrL( &hCPE->input_mem[1][0], &hCPE->input_mem_fx[1][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ) ); + floatToFixed_arrL( &hCPE->input_mem_LB[1][0], &hCPE->input_mem_LB_fx[1][0], q, STEREO_DFT32MS_OVL_16k ); + if ( hSCE != NULL ) + { + floatToFixed_arrL( &hSCE->save_hb_synth[0], &hSCE->save_hb_synth_fx[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); hSCE->q_save_hb_synth_fx = q; - floatToFixed_arrL(&hSCE->save_synth[0], &hSCE->save_synth_fx[0], q, (Word16)(hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC)); + floatToFixed_arrL( &hSCE->save_synth[0], &hSCE->save_synth_fx[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); hSCE->q_save_synth_fx = q; } IF( hCPE->hCoreCoder[0] != NULL ) { - floatToFixed_arrL(&hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], q, L_FRAME32k); + floatToFixed_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], q, L_FRAME32k ); hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; - floatToFixed_arrL(&hCPE->hCoreCoder[0]->hHQ_core->old_out[0], &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], q, L_FRAME48k); - IF( (hCPE->hCoreCoder[0] != NULL) && (hCPE->hCoreCoder[0]->p_bpf_noise_buf_32 != NULL) ) - floatToFixed_arrL(&hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], q, L_FRAME16k); + floatToFixed_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], q, L_FRAME48k ); + IF( ( hCPE->hCoreCoder[0] != NULL ) && ( hCPE->hCoreCoder[0]->p_bpf_noise_buf_32 != NULL ) ) + floatToFixed_arrL( &hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], q, L_FRAME16k ); } IF( hCPE->hStereoDft != NULL ) { - floatToFixed_arrL(&hCPE->hStereoDft->td_gain[0], &hCPE->hStereoDft->td_gain_fx[0], Q31, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); - floatToFixed_arrL(&hCPE->hStereoDft->ap_delay_mem[0], &hCPE->hStereoDft->ap_delay_mem_fx[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS )); - floatToFixed_arrL(&hCPE->hStereoDft->buff_LBTCX_mem[0], &hCPE->hStereoDft->buff_LBTCX_mem_fx[0], q, NS2SA( 16000, STEREO_DFT32MS_OVL_NS )); + floatToFixed_arrL( &hCPE->hStereoDft->td_gain[0], &hCPE->hStereoDft->td_gain_fx[0], Q31, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); + floatToFixed_arrL( &hCPE->hStereoDft->ap_delay_mem[0], &hCPE->hStereoDft->ap_delay_mem_fx[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); + floatToFixed_arrL( &hCPE->hStereoDft->buff_LBTCX_mem[0], &hCPE->hStereoDft->buff_LBTCX_mem_fx[0], q, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ) ); hCPE->hStereoDft->q_smooth_buf_fx = Q7; - floatToFixed_arrL(&hCPE->hStereoDft->smooth_buf[0][0], &hCPE->hStereoDft->smooth_buf_fx[0][0], hCPE->hStereoDft->q_smooth_buf_fx, sizeof(hCPE->hStereoDft->smooth_buf_fx) / sizeof(hCPE->hStereoDft->smooth_buf_fx[0][0])); - floatToFixed_arrL(&st_ivas->hSpar->hMdDec->mixer_mat_prev[0][0][0][0], &st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0], Q31, sizeof(st_ivas->hSpar->hMdDec->mixer_mat_prev_fx) / sizeof(st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0])); + floatToFixed_arrL( &hCPE->hStereoDft->smooth_buf[0][0], &hCPE->hStereoDft->smooth_buf_fx[0][0], hCPE->hStereoDft->q_smooth_buf_fx, sizeof( hCPE->hStereoDft->smooth_buf_fx ) / sizeof( hCPE->hStereoDft->smooth_buf_fx[0][0] ) ); + floatToFixed_arrL( &st_ivas->hSpar->hMdDec->mixer_mat_prev[0][0][0][0], &st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0], Q31, sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx ) / sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0] ) ); } - for (int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++) + for ( int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++ ) { - for (int jj = 0; jj < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; jj++) + for ( int jj = 0; jj < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; jj++ ) { - floatToFixed_arrL(&st_ivas->hSpar->hMdDec->mixer_mat[ii][jj][0], - &st_ivas->hSpar->hMdDec->mixer_mat_fx[ii][jj][0], - Q31, - st_ivas->hSpar->hMdDec->mix_mat_dim_2); + floatToFixed_arrL( &st_ivas->hSpar->hMdDec->mixer_mat[ii][jj][0], + &st_ivas->hSpar->hMdDec->mixer_mat_fx[ii][jj][0], + Q31, + st_ivas->hSpar->hMdDec->mix_mat_dim_2 ); } } - //hCPE->lt_es_em_fx = floatToFixed(hCPE->lt_es_em, Q15); - for (int ii = 0; ii < CPE_CHANNELS; ii++) + for ( int ii = 0; ii < CPE_CHANNELS; ii++ ) { hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; - floatToFixed_arrL(&hCPE->output_mem[ii][0], &hCPE->output_mem_fx[ii][0], hCPE->hStereoDft->q_dft, NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS )); + floatToFixed_arrL( &hCPE->output_mem[ii][0], &hCPE->output_mem_fx[ii][0], hCPE->hStereoDft->q_dft, NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ) ); } - 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])); - + 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_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 ); - 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( i = 0; i < 2; i++ ) + { + Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, negate( s ) ); + } + 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] ) ); for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_subr_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_subr_fx[0] ); ii++ ) { - hCPE->hStereoDft->hb_nrg_subr[ii] = ((float)hCPE->hStereoDft->hb_nrg_subr_fx[ii] / ((float)(1 << hCPE->hStereoDft->q_hb_nrg_subr))); + hCPE->hStereoDft->hb_nrg_subr[ii] = ( (float) hCPE->hStereoDft->hb_nrg_subr_fx[ii] / ( (float) ( 1 << hCPE->hStereoDft->q_hb_nrg_subr ) ) ); } for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_fx[0] ); ii++ ) { hCPE->hStereoDft->hb_nrg[ii] = ( (float) hCPE->hStereoDft->hb_nrg_fx[ii] * ( (float) ( 1 << hCPE->hStereoDft->q_hb_nrg ) ) ); } - //fixedToFloat_arr(&st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm[0], Q15, sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx) / sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx[0])); - //fixedToFloat_arrL(&hCPE->prev_hb_synth_fx[0][0], &hCPE->prev_hb_synth[0][0], hCPE->hStereoDft->q_dft, sizeof(hCPE->prev_hb_synth_fx) / sizeof(hCPE->prev_hb_synth_fx[0][0])); - IF (hCPE->hStereoCng != NULL) + IF( hCPE->hStereoCng != NULL ) { fixedToFloat_arr( &hCPE->hStereoCng->cm_fx[0], &hCPE->hStereoCng->cm[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); } - //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_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 )); - fixedToFloat_arrL(&hCPE->input_mem_LB_fx[0][0], &hCPE->input_mem_LB[0][0], q, STEREO_DFT32MS_OVL_16k); - fixedToFloat_arrL(&hCPE->input_mem_fx[1][0], &hCPE->input_mem[1][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS )); - fixedToFloat_arrL(&hCPE->input_mem_LB_fx[1][0], &hCPE->input_mem_LB[1][0], q, STEREO_DFT32MS_OVL_16k); - if (hSCE != NULL) + 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 ) ); + fixedToFloat_arrL( &hCPE->input_mem_LB_fx[0][0], &hCPE->input_mem_LB[0][0], q, STEREO_DFT32MS_OVL_16k ); + fixedToFloat_arrL( &hCPE->input_mem_fx[1][0], &hCPE->input_mem[1][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ) ); + fixedToFloat_arrL( &hCPE->input_mem_LB_fx[1][0], &hCPE->input_mem_LB[1][0], q, STEREO_DFT32MS_OVL_16k ); + if ( hSCE != NULL ) { - //fixedToFloat_arrL(&hSCE->prev_hb_synth_fx[0], &hSCE->prev_hb_synth[0], hCPE->hStereoDft->q_dft, sizeof(hSCE->prev_hb_synth_fx) / sizeof(hSCE->prev_hb_synth_fx[0])); - fixedToFloat_arrL(&hSCE->save_synth_fx[0], &hSCE->save_synth[0], q, (Word16)(hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC)); - fixedToFloat_arrL(&hSCE->save_hb_synth_fx[0], &hSCE->save_hb_synth[0], q, (Word16)(hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC)); + fixedToFloat_arrL( &hSCE->save_synth_fx[0], &hSCE->save_synth[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); + fixedToFloat_arrL( &hSCE->save_hb_synth_fx[0], &hSCE->save_hb_synth[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); } IF( hCPE->hCoreCoder[0] != NULL ) { - fixedToFloat_arrL(&hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], q, L_FRAME32k); - fixedToFloat_arrL(&hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], q, L_FRAME48k); + fixedToFloat_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], q, L_FRAME32k ); + fixedToFloat_arrL( &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], q, L_FRAME48k ); IF( hCPE->hCoreCoder[0]->p_bpf_noise_buf_32 != NULL ) - fixedToFloat_arrL(&hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], q, L_FRAME16k); + fixedToFloat_arrL( &hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], q, L_FRAME16k ); } IF( hCPE->hStereoDft != NULL ) { fixedToFloat_arrL( &hCPE->hStereoDft->td_gain_fx[0], &hCPE->hStereoDft->td_gain[0], Q31, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); - fixedToFloat_arrL(&hCPE->hStereoDft->ap_delay_mem_fx[0], &hCPE->hStereoDft->ap_delay_mem[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS )); - fixedToFloat_arrL(&hCPE->hStereoDft->buff_LBTCX_mem_fx[0], &hCPE->hStereoDft->buff_LBTCX_mem[0], q, NS2SA( 16000, STEREO_DFT32MS_OVL_NS )); - fixedToFloat_arrL(&st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0], &st_ivas->hSpar->hMdDec->mixer_mat_prev[0][0][0][0], Q31, sizeof(st_ivas->hSpar->hMdDec->mixer_mat_prev_fx) / sizeof(st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0])); - fixedToFloat_arrL(&hCPE->hStereoDft->smooth_buf_fx[0][0], &hCPE->hStereoDft->smooth_buf[0][0], hCPE->hStereoDft->q_smooth_buf_fx, sizeof(hCPE->hStereoDft->smooth_buf_fx) / sizeof(hCPE->hStereoDft->smooth_buf_fx[0][0])); + fixedToFloat_arrL( &hCPE->hStereoDft->ap_delay_mem_fx[0], &hCPE->hStereoDft->ap_delay_mem[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); + fixedToFloat_arrL( &hCPE->hStereoDft->buff_LBTCX_mem_fx[0], &hCPE->hStereoDft->buff_LBTCX_mem[0], q, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ) ); + fixedToFloat_arrL( &st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0], &st_ivas->hSpar->hMdDec->mixer_mat_prev[0][0][0][0], Q31, sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx ) / sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0] ) ); + fixedToFloat_arrL( &hCPE->hStereoDft->smooth_buf_fx[0][0], &hCPE->hStereoDft->smooth_buf[0][0], hCPE->hStereoDft->q_smooth_buf_fx, sizeof( hCPE->hStereoDft->smooth_buf_fx ) / sizeof( hCPE->hStereoDft->smooth_buf_fx[0][0] ) ); } - for (int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++) + for ( int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++ ) { - for (int jj = 0; jj < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; jj++) + for ( int jj = 0; jj < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; jj++ ) { - fixedToFloat_arrL(&st_ivas->hSpar->hMdDec->mixer_mat_fx[ii][jj][0], - &st_ivas->hSpar->hMdDec->mixer_mat[ii][jj][0], - Q31, - st_ivas->hSpar->hMdDec->mix_mat_dim_2); + fixedToFloat_arrL( &st_ivas->hSpar->hMdDec->mixer_mat_fx[ii][jj][0], + &st_ivas->hSpar->hMdDec->mixer_mat[ii][jj][0], + Q31, + st_ivas->hSpar->hMdDec->mix_mat_dim_2 ); } } - for (int ii = 0; ii < CPE_CHANNELS; ii++) + for ( int ii = 0; ii < CPE_CHANNELS; ii++ ) { - fixedToFloat_arrL(&hCPE->output_mem_fx[ii][0], &hCPE->output_mem[ii][0], hCPE->hStereoDft->q_dft, NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS )); + fixedToFloat_arrL( &hCPE->output_mem_fx[ii][0], &hCPE->output_mem[ii][0], hCPE->hStereoDft->q_dft, NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ) ); } - //hCPE->lt_es_em = fixedToFloat(hCPE->lt_es_em_fx, Q15); } #endif } /* HP filtering */ - for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) + FOR( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) { #ifdef IVAS_FLOAT_FIXED - for ( i = 0; i < output_frame; i++ ) - { - p_output_fx[n][i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); - } 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_fx[n][i] / ( 1 << 11 ); - } #else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); #endif // IVAS_FLOAT_FIXED } #ifdef IVAS_FLOAT_FIXED -#if 1 - Word16 Q_sba = 31; - 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( 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( i = sba_ch_idx + 2; i <= sba_ch_idx + 3; i++ ) - { - fixedToFloat_arrL( p_output_fx[i], p_output[i], Q_sba, output_frame ); - } #else nchan_remapped = ivas_sba_remapTCs( &p_output[sba_ch_idx], st_ivas, output_frame ); #endif - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + IF( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); @@ -2949,10 +2260,7 @@ ivas_error ivas_jbm_dec_tc( nchan_out = nchan_transport; FOR( ch = 0; ch < nchan_transport; ch++ ) { - FOR( i = 0; i < output_frame; i++ ) - { - p_output_fx[sba_ch_idx + ch][i] = floatToFixed( p_output[sba_ch_idx + ch][i], Q_p_output ); - } + Scale_sig32( p_output_fx[sba_ch_idx + ch], output_frame, sub( Q_p_output, Q11 ) ); } Word16 b, i_ts, num_out_ch; num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; @@ -2968,7 +2276,7 @@ ivas_error ivas_jbm_dec_tc( { 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] ) ); + 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] ) ); } } } @@ -2999,7 +2307,7 @@ ivas_error ivas_jbm_dec_tc( } } } - hSpar->hMdDec->Q_mixer_mat = s_min(hSpar->hMdDec->Q_mixer_mat, s_min( Q_C_re_fx, Q_P_re_fx ) ); + 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++ ) @@ -3034,7 +2342,7 @@ ivas_error ivas_jbm_dec_tc( } } #endif - ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, p_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[sba_ch_idx], 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++ ) { @@ -3051,81 +2359,63 @@ ivas_error ivas_jbm_dec_tc( } FOR( Word16 c = 0; c < nchan_transport; c++ ) { - FOR( j = 0; j < output_frame; j++ ) - { - p_output[sba_ch_idx + c][j] = (float) p_output_fx[c][j]; - } + Scale_sig32( p_output_fx[sba_ch_idx + c], output_frame, Q11 ); } #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 ); #endif // IVAS_FLOAT_FIXED } - else if ( st_ivas->renderer_type != RENDERER_DISABLE && !st_ivas->sba_dirac_stereo_flag ) + ELSE IF( st_ivas->renderer_type != RENDERER_DISABLE && NE_16( st_ivas->sba_dirac_stereo_flag, 0 ) ) { #ifdef IVAS_FLOAT_FIXED Word16 size = st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport + sba_ch_idx; - if (size == 3) - size += 1; + if ( size == 3 ) + size += 1; - FOR( i = sba_ch_idx; i < size; i++) + FOR( i = sba_ch_idx; i < size; i++ ) { - FOR( j = 0; j < output_frame; j++) - { - p_output_fx[i][j] = (Word32)(p_output[i][j] * ONE_IN_Q14); - } + Scale_sig32( p_output_fx[i], output_frame, sub( Q14, Q11 ) ); } ivas_spar_dec_agc_pca_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame ); - - FOR( i = sba_ch_idx; i < size; i++) - { - FOR( j = 0; j < output_frame; j++) - { - p_output[i][j] = (float)p_output_fx[i][j] / ONE_IN_Q11; - } - } #else - ivas_spar_dec_agc_pca(st_ivas, &p_output[sba_ch_idx], output_frame); + ivas_spar_dec_agc_pca( st_ivas, &p_output[sba_ch_idx], output_frame ); #endif } if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { /* loudness correction */ +#ifdef IVAS_FLOAT_FIXED + ivas_dirac_dec_binaural_sba_gain_fx( &p_output_fx[sba_ch_idx], nchan_remapped, output_frame ); /*returns Q-1*/ + + FOR( i = 0; i < nchan_remapped; i++ ) + { + Scale_sig32( p_output_fx[i], output_frame, 1 ); + } +#else ivas_dirac_dec_binaural_sba_gain( &p_output[sba_ch_idx], nchan_remapped, output_frame ); +#endif // IVAS_FLOAT_FIXED } - else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + 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 ) - { - for ( int lp2 = 0; lp2 < output_frame; lp2++ ) - { - p_output_fx[lp][lp2] = (Word32) ( p_output[lp][lp2] * ( 1u << 11 ) ); - } - } - } 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) p_output_fx[0][lp] / ( 1u << 8 ); - } + Scale_sig32( p_output_fx[0], L_FRAME48k, sub( Q11, Q8 ) ); #else ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); #endif /* add W */ - for ( n = 0; n < nchan_out; n++ ) + FOR( n = 0; n < nchan_out; n++ ) { - v_add( p_output[n], p_output[n + max( nchan_out, nchan_ism )], p_output[n], output_frame ); + v_add_32( p_output_fx[n], p_output_fx[n + max( nchan_out, nchan_ism )], p_output_fx[n], output_frame ); } } } - else if ( st_ivas->ivas_format == MC_FORMAT ) + ELSE IF( st_ivas->ivas_format == MC_FORMAT ) { st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; @@ -3133,32 +2423,22 @@ ivas_error ivas_jbm_dec_tc( { /* LFE channel decoder */ #ifdef IVAS_FLOAT_FIXED - - 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_fx[LFE_CHANNEL][p] / ONE_IN_Q9; - } + Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, sub( Q11, Q9 ) ); #else ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output[LFE_CHANNEL] ); #endif // IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED #if 1 // Float to fix - + Word16 ch, nCPE, cpe_id; Word16 q_output = 11, l, k; - + nCPE = st_ivas->nCPE; move16(); hMCT = st_ivas->hMCT; - FOR( i = 0; i < 12; i++ ) - if ( p_output[i] ) - { - floatToFixed_arrL( p_output[i], p_output_fx[i], Q11, L_FRAME48k ); - } FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { hCPE = st_ivas->hCPE[cpe_id]; @@ -3168,43 +2448,9 @@ ivas_error ivas_jbm_dec_tc( FOR( n = 0; n < CPE_CHANNELS; n++ ) { st = hCPE->hCoreCoder[n]; - IF( st->hTonalMDCTConc ) - { - - FOR( i = 0; i < st->hTonalMDCTConc->nScaleFactors; i++ ) - { - st->hTonalMDCTConc->scaleFactorsBackground_fx[i] = float_to_fix( st->hTonalMDCTConc->scaleFactorsBackground_flt[i], 15 ); - } - //st->hTonalMDCTConc->scf_fadeout = float_to_fix16( st->hTonalMDCTConc->scf_fadeout_flt, 15 ); - if ( hCPE->hCoreCoder[n]->bfi && st->tonal_mdct_plc_active ) - { - FOR( i = 0; i < FDNS_NPTS; i++ ) - { - f2me_16( st->hTonalMDCTConc->secondLastBlockData.scaleFactors_float[i], &st->hTonalMDCTConc->secondLastBlockData.scaleFactors[i], &st->hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i] ); - } - FOR( i = 0; i < 30; i++ ) - { - float pd = st->hTonalMDCTConc->pTCI->phaseDiff_float[i]; - if ( pd >= PI2 ) - pd = fmodf( pd, PI2 ) - PI2; - st->hTonalMDCTConc->pTCI->phaseDiff[i] = (Word16) floatToFixed( pd, Q12 ); - } - FOR( i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++ ) - { - float pd = st->hTonalMDCTConc->pTCI->phase_currentFramePredicted_float[i]; - pd = fmodf( pd, PI2 ); - st->hTonalMDCTConc->pTCI->phase_currentFramePredicted[i] = (Word16) ( pd * ( 1u << Q13 ) ); - } - // st->hTonalMDCTConc->nFramesLost = float_to_fix16( st->hTonalMDCTConc->nFramesLost, Q1 ); - } - //f2me( st->hTonalMDCTConc->last_block_nrg_flt, &st->hTonalMDCTConc->last_block_nrg, &st->hTonalMDCTConc->last_block_nrg_exp ); - } - // st->old_fpitch = float_to_fix(st->old_fpitch_float, 16); - st->hTcxDec->tcxltp_last_gain_unmodified = float_to_fix16( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 ); IF( sts[n]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { - // sts[n]->Mode2_lp_gainp = floatToFixed( sts[n]->lp_gainp, Q16 ); // u8bit to 16bit FOR( l = 0; l < IGF_START_MX; l++ ) { @@ -3219,8 +2465,6 @@ ivas_error ivas_jbm_dec_tc( { st->hTcxDec->conLastFrameLevel_e = 0; } - IF( st->hTcxDec ) - //st->hTcxDec->conLastFrameLevel = (Word16) floatToFixed( st->hTcxDec->LastFrameLevel_bfi, 15 - st->hTcxDec->conLastFrameLevel_e ); if ( st->hTcxDec && st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) { set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); @@ -3229,23 +2473,8 @@ ivas_error ivas_jbm_dec_tc( st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; IF( st->hTcxDec ) st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; - IF( st->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 ) ); - //} 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); - - IF( hCPE->hCoreCoder[n]->hTcxLtpDec ) - { - floatToFixed_arrL( hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_float, hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_32, q_output, L_FRAME48k ); - floatToFixed_arrL( hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_float, hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_32, q_output, TCXLTP_MAX_DELAY ); - //floatToFixed_arrL( hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float, hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32, Q11, 111 ); - } - - /*cldfb struct*/ /*------------------fix-to-fix-start---------------------*/ @@ -3274,8 +2503,6 @@ ivas_error ivas_jbm_dec_tc( /*-------------------cldfb-end---------------------------*/ - - //floatToFixed_arr( sts[n]->prev_synth_buffer, hCPE->hCoreCoder[n]->prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); } IF( hCPE->output_mem[0] != NULL ) @@ -3289,22 +2516,6 @@ ivas_error ivas_jbm_dec_tc( FOR( n = 0; n < CPE_CHANNELS; n++ ) { - - IF( hCPE->hStereoDft != NULL ) - { - IF( hCPE->hStereoDft->hTcxLtpDec != NULL ) - { - FOR( Word32 p = 0; p < L_FRAME48k; p++ ) - { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] = (Word32) ( hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] * ( 1u << q_output ) ); - } - FOR( Word32 p = 0; p < TCXLTP_MAX_DELAY; p++ ) - { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] = (Word32) ( hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] * ( 1u << q_output ) ); - } - } - } - IF( hCPE->input_mem_LB[n] != NULL ) { FOR( Word32 ind = 0; ind < STEREO_DFT32MS_OVL_16k; ind++ ) @@ -3312,11 +2523,6 @@ ivas_error ivas_jbm_dec_tc( hCPE->input_mem_LB_fx[n][ind] = (Word32) ( hCPE->input_mem_LB[n][ind] * ( 1 << q_output ) ); } } - - //FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); k++ ) - //{ - // hCPE->prev_hb_synth_fx[n][k] = (Word32) ( hCPE->prev_hb_synth[n][k] * ( 1 << q_output ) ); - //} FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) { hCPE->prev_synth_fx[n][k] = (Word32) ( hCPE->prev_synth[n][k] * ( 1 << q_output ) ); @@ -3355,8 +2561,6 @@ ivas_error ivas_jbm_dec_tc( FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = hCPE->hCoreCoder[ch]; - st->hTcxDec->tcxltp_last_gain_unmodified_float = fixedToFloat(st->hTcxLtpDec->tcxltp_gain, 15); - //st->hTcxDec->tcxltp_last_gain_unmodified_float = st->hTcxLtpDec->tcxltp_gain_float; IF( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { // 16bit to u8bit @@ -3364,46 +2568,6 @@ 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( st->hTonalMDCTConc != NULL ) - { - //st->hTonalMDCTConc->scf_fadeout_flt = fixedToFloat( st->hTonalMDCTConc->scf_fadeout, 15 ); - //st->hTonalMDCTConc->last_block_nrg_flt = me2f( st->hTonalMDCTConc->last_block_nrg, st->hTonalMDCTConc->last_block_nrg_exp ); - if ( hCPE->hCoreCoder[ch]->bfi && st->tonal_mdct_plc_active ) - { - //st->hTonalMDCTConc->nFramesLost_float = fix16_to_float( st->hTonalMDCTConc->nFramesLost, Q1 ); - } - } - - if ( sts[ch]->last_core != -1 && sts[ch]->nbLostCmpt == 1 ) - { - if ( !( sts[ch]->rf_flag && sts[ch]->use_partial_copy && ( sts[ch]->rf_frame_type == RF_TCXTD1 || sts[ch]->rf_frame_type == RF_TCXTD2 ) ) ) - { - IF( sts[ch]->hTonalMDCTConc != NULL && sts[ch]->last_core == TCX_20_CORE && sts[ch]->second_last_core == TCX_20_CORE && ( ( sts[ch]->old_fpitch <= L_shl( sts[ch]->L_frame, 15 ) ) || ( sts[ch]->hTcxDec->tcxltp_last_gain_unmodified <= 13107 /*0.4f*/ ) ) - /* it is fine to call the detection even if no ltp information - is available, meaning that st->old_fpitch == - st->tcxltp_second_last_pitch == st->L_frame */ - && ( sts[ch]->old_fpitch == sts[ch]->hTcxDec->tcxltp_second_last_pitch ) && !sts[ch]->last_tns_active && !sts[ch]->second_last_tns_active ) - { - - if ( sts[ch]->hTonalMDCTConc->pTCI->numIndexes < MAX_NUMBER_OF_IDX ) - { - FOR( i = 0; i < sts[ch]->hTonalMDCTConc->pTCI->numIndexes; i++ ) - { - sts[ch]->hTonalMDCTConc->pTCI->phaseDiff_float[i] = fixedToFloat( sts[ch]->hTonalMDCTConc->pTCI->phaseDiff[i], Q12 ); - } - FOR( i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++ ) - { - sts[ch]->hTonalMDCTConc->pTCI->phase_currentFramePredicted_float[i] = fixedToFloat( sts[ch]->hTonalMDCTConc->pTCI->phase_currentFramePredicted[i], Q13 ); - } - } - } - } } } @@ -3418,11 +2582,6 @@ ivas_error ivas_jbm_dec_tc( IF( sts[0]->bfi == 0 && !st->hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive ) fixedToFloat_arr( st->hTonalMDCTConc->secondLastPcmOut, st->hTonalMDCTConc->secondLastPcmOut_float, 0, st->hTonalMDCTConc->nSamples / 2 ); fixedToFloat_arr( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synthFB, st->Q_syn, st->hTcxDec->old_synth_lenFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); - 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 / 2; p++ ) { st->hTcxDec->old_syn_Overl_float[p] = (float) st->hTcxDec->old_syn_Overl[p] * 2 * ( 1u << st->Q_syn ); @@ -3439,11 +2598,7 @@ ivas_error ivas_jbm_dec_tc( fixedToFloat_arr( st->p_bpf_noise_buf, st->p_bpf_noise_buf_float, 0, L_FRAME_16k ); } - fixedToFloat_arr( st->hTcxDec->syn_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 ); - st->hTcxDec->tcxltp_last_gain_unmodified_float = fix16_to_float( st->hTcxDec->tcxltp_last_gain_unmodified, Q15 ); - //st->hTcxDec->conceal_eof_gain_float = fix16_to_float( st->hTcxDec->conceal_eof_gain, Q14 ); - /*-------------------cldfb-start-------------------------*/ /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ @@ -3483,64 +2638,16 @@ ivas_error ivas_jbm_dec_tc( sts[n]->hBWE_FD->prev_L_swb_norm = sts[n]->hBWE_FD->prev_L_swb_norm; sts[n]->hBWE_FD->prev_flag = sts[n]->hBWE_FD->prev_flag; } - - for ( int p = 0; p < L_FRAME48k; p++ ) + } + FOR( n = 0; n < CPE_CHANNELS; n++ ) + { + IF( hCPE->output_mem[n] != NULL ) { - - IF( hCPE->hCoreCoder[n]->hTcxLtpDec ) - { - hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_float[p] = (float) hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_32[p] / ( 1u << q_output ); - if ( p < TCXLTP_MAX_DELAY ) - { - hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_float[p] = (float) hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_32[p] / ( 1u << q_output ); - } - } - } - if ( hCPE->hCoreCoder[n]->hTcxDec ) - { - for ( k = 0; k < 111; k++ ) - { - //hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] = (float) hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] / ( 1u << q_output ); - } - } - IF( hCPE->hCoreCoder[n]->hTcxLtpDec ) - - if ( ( hCPE->hCoreCoder[n]->codec_mode == MODE1 && hCPE->hCoreCoder[n]->hTcxDec != NULL ) && ( ( hCPE->hCoreCoder[n]->core == ACELP_CORE && !( hCPE->hCoreCoder[n]->bfi == 1 && hCPE->hCoreCoder[n]->con_tcx == 1 ) ) || hCPE->hCoreCoder[n]->core == HQ_CORE ) ) - { - fixedToFloat_arr( hCPE->hCoreCoder[n]->hTcxDec->synth_history_fx, hCPE->hCoreCoder[n]->hTcxDec->synth_history, 0, output_frame ); - } - } - - IF( hCPE->hStereoDft != NULL ) - { - IF( hCPE->hStereoDft->hTcxLtpDec != NULL ) - { - FOR( Word32 p = 0; p < L_FRAME48k; p++ ) - { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] = (float) hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] / ( 1u << q_output ); - } - FOR( Word32 p = 0; p < TCXLTP_MAX_DELAY; p++ ) - { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] = (float) hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] / ( 1u << q_output ); - } - } - } - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - IF( hCPE->output_mem[n] != NULL ) - { - FOR( k = 0; k < NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ); k++ ) + FOR( k = 0; k < NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ); k++ ) { hCPE->output_mem[n][k] = (float) hCPE->output_mem_fx[n][k] / ( 1u << 11 ); } } - IF( hCPE->hCoreCoder[n] != NULL ) - { - FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); k++ ) - { - //hCPE->hCoreCoder[n]->prev_synth_buffer[k] = (float) hCPE->hCoreCoder[n]->prev_synth_buffer32_fx[k] / ( 1 << q_output ); - } - } IF( hCPE->input_mem[n] != NULL ) { FOR( Word32 ind = 0; ind < STEREO_DFT32MS_OVL_16k; ind++ ) @@ -3548,10 +2655,6 @@ ivas_error ivas_jbm_dec_tc( hCPE->input_mem_LB[n][ind] = ( (float) hCPE->input_mem_LB_fx[n][ind] / ( 1 << q_output ) ); } } - //FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); k++ ) - //{ - // hCPE->prev_hb_synth[n][k] = (float) hCPE->prev_hb_synth_fx[n][k] / ( 1 << q_output ); - //} FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) { hCPE->prev_synth[n][k] = (float) hCPE->prev_synth_fx[n][k] / ( 1 << q_output ); @@ -3570,7 +2673,6 @@ 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 ) ); 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]; @@ -3586,11 +2688,6 @@ ivas_error ivas_jbm_dec_tc( IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx ) me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - FOR( i = 0; i < 12; i++ ) - if ( p_output[i] ) - { - fixedToFloat_arrL( p_output_fx[i], p_output[i], Q11, L_FRAME48k ); - } #endif // Fix to float #else if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, 0 ) ) != IVAS_ERR_OK ) @@ -3605,15 +2702,7 @@ ivas_error ivas_jbm_dec_tc( if ( n != LFE_CHANNEL ) { #ifdef IVAS_FLOAT_FIXED - for ( i = 0; i < output_frame; i++ ) - { - p_output_fx[n][i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); - } 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_fx[n][i] / ( 1 << 11 ); - } #else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); #endif // IVAS_FLOAT_FIXED @@ -3625,24 +2714,7 @@ ivas_error ivas_jbm_dec_tc( if ( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) >= ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ) ) { #ifdef IVAS_FLOAT_FIXED -#if 1 - 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 ) ); - } - FOR( i = 0; i < st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; i++ ) - { - floatToFixed_arrL( p_output[i], p_output_fx[i], Q_in_buffer_td, output_frame ); - } -#endif // IVAS_FLOAT_FIXED ivas_mc2sba_fx( st_ivas->hTransSetup, p_output_fx, p_output_fx, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE_FX ); -#if 1 - FOR( i = 0; i < ( st_ivas->hIntSetup.ambisonics_order + 1 ) * ( st_ivas->hIntSetup.ambisonics_order + 1 ); i++ ) - { - fixedToFloat_arrL( p_output_fx[i], p_output[i], Q_in_buffer_td - 3, output_frame ); - } -#endif #else ivas_mc2sba( st_ivas->hTransSetup, p_output, p_output, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE ); #endif // IVAS_FLOAT_FIXED @@ -3654,11 +2726,11 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->renderer_type == RENDERER_MC ) { #ifdef IVAS_FLOAT_FIXED - Word16 q = Q16; - q = q - find_guarded_bits_fx( st_ivas->nchan_transport ); + s = sub( Q16, Q11 ); + s = sub( s, find_guarded_bits_fx( st_ivas->nchan_transport ) ); FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { - floatToFixed_arrL( p_output[i], p_output_fx[i], q, output_frame ); + Scale_sig32( p_output_fx[i], output_frame, s ); } FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) { @@ -3670,7 +2742,7 @@ ivas_error ivas_jbm_dec_tc( ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); 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 ); + Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); } #else ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, output_frame, p_output, p_output ); @@ -3678,11 +2750,15 @@ ivas_error ivas_jbm_dec_tc( } else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { +#ifdef IVAS_FLOAT_FIXED + ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, output_frame, st_ivas->hOutSetup.ambisonics_order, 0 ); +#else ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, output_frame, st_ivas->hOutSetup.ambisonics_order, 0.f ); +#endif } } } - else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + ELSE IF( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { /* LFE channel decoder */ #ifdef IVAS_FLOAT_FIXED @@ -3690,10 +2766,7 @@ ivas_error ivas_jbm_dec_tc( 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_fx[LFE_CHANNEL][p] / ONE_IN_Q9; - } + Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, sub( Q11, Q9 ) ); #else ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output[LFE_CHANNEL] ); #endif // IVAS_FLOAT_FIXED @@ -3702,19 +2775,14 @@ ivas_error ivas_jbm_dec_tc( #ifdef IVAS_FLOAT_FIXED #if 1 // Float to fix - + Word16 ch, nCPE, cpe_id; Word16 q_output = 11; Word16 k, l; - + nCPE = st_ivas->nCPE; move16(); hMCT = st_ivas->hMCT; - FOR( i = 0; i < 12; i++ ) - if ( p_output[i] ) - { - floatToFixed_arrL( p_output[i], p_output_fx[i], Q11, L_FRAME48k ); - } FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { hCPE = st_ivas->hCPE[cpe_id]; @@ -3724,39 +2792,6 @@ ivas_error ivas_jbm_dec_tc( FOR( n = 0; n < CPE_CHANNELS; n++ ) { st = hCPE->hCoreCoder[n]; - IF( st->hTonalMDCTConc ) - { - - FOR( i = 0; i < st->hTonalMDCTConc->nScaleFactors; i++ ) - { - st->hTonalMDCTConc->scaleFactorsBackground_fx[i] = float_to_fix( st->hTonalMDCTConc->scaleFactorsBackground_flt[i], 15 ); - } - //st->hTonalMDCTConc->scf_fadeout = float_to_fix16( st->hTonalMDCTConc->scf_fadeout_flt, 15 ); - if ( hCPE->hCoreCoder[n]->bfi && st->tonal_mdct_plc_active ) - { - FOR( i = 0; i < FDNS_NPTS; i++ ) - { - f2me_16( st->hTonalMDCTConc->secondLastBlockData.scaleFactors_float[i], &st->hTonalMDCTConc->secondLastBlockData.scaleFactors[i], &st->hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i] ); - } - FOR( i = 0; i < 30; i++ ) - { - float pd = st->hTonalMDCTConc->pTCI->phaseDiff_float[i]; - if ( pd >= PI2 ) - pd = fmodf( pd, PI2 ) - PI2; - st->hTonalMDCTConc->pTCI->phaseDiff[i] = (Word16) floatToFixed( pd, Q12 ); - } - FOR( i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++ ) - { - float pd = st->hTonalMDCTConc->pTCI->phase_currentFramePredicted_float[i]; - pd = fmodf( pd, PI2 ); - st->hTonalMDCTConc->pTCI->phase_currentFramePredicted[i] = (Word16) ( pd * ( 1u << Q13 ) ); - } - // st->hTonalMDCTConc->nFramesLost = float_to_fix16( st->hTonalMDCTConc->nFramesLost, Q1 ); - } - //f2me( st->hTonalMDCTConc->last_block_nrg_flt, &st->hTonalMDCTConc->last_block_nrg, &st->hTonalMDCTConc->last_block_nrg_exp ); - } - // st->old_fpitch = float_to_fix(st->old_fpitch_float, 16); - st->hTcxDec->tcxltp_last_gain_unmodified = float_to_fix16( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 ); IF( sts[n]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { @@ -3782,22 +2817,8 @@ ivas_error ivas_jbm_dec_tc( st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; IF( st->hTcxDec ) st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; - IF( st->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 ) ); - //} 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); - - IF( hCPE->hCoreCoder[n]->hTcxLtpDec ) - { - floatToFixed_arrL( hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_float, hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_32, q_output, L_FRAME48k ); - floatToFixed_arrL( hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_float, hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_32, q_output, TCXLTP_MAX_DELAY ); - //floatToFixed_arrL( hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float, hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32, Q11, 111 ); - } - /*cldfb struct*/ @@ -3827,8 +2848,6 @@ ivas_error ivas_jbm_dec_tc( /*-------------------cldfb-end---------------------------*/ - - //floatToFixed_arr( sts[n]->prev_synth_buffer, hCPE->hCoreCoder[n]->prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); } IF( hCPE->output_mem[0] != NULL ) @@ -3842,22 +2861,6 @@ ivas_error ivas_jbm_dec_tc( FOR( n = 0; n < CPE_CHANNELS; n++ ) { - - IF( hCPE->hStereoDft != NULL ) - { - IF( hCPE->hStereoDft->hTcxLtpDec != NULL ) - { - FOR( Word32 p = 0; p < L_FRAME48k; p++ ) - { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] = (Word32) ( hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] * ( 1u << q_output ) ); - } - FOR( Word32 p = 0; p < TCXLTP_MAX_DELAY; p++ ) - { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] = (Word32) ( hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] * ( 1u << q_output ) ); - } - } - } - IF( hCPE->input_mem_LB[n] != NULL ) { FOR( Word32 ind = 0; ind < STEREO_DFT32MS_OVL_16k; ind++ ) @@ -3865,11 +2868,6 @@ ivas_error ivas_jbm_dec_tc( hCPE->input_mem_LB_fx[n][ind] = (Word32) ( hCPE->input_mem_LB[n][ind] * ( 1 << q_output ) ); } } - - //FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); k++ ) - //{ - // hCPE->prev_hb_synth_fx[n][k] = (Word32) ( hCPE->prev_hb_synth[n][k] * ( 1 << q_output ) ); - //} FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) { hCPE->prev_synth_fx[n][k] = (Word32) ( hCPE->prev_synth[n][k] * ( 1 << q_output ) ); @@ -3908,8 +2906,6 @@ ivas_error ivas_jbm_dec_tc( FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = hCPE->hCoreCoder[ch]; - st->hTcxDec->tcxltp_last_gain_unmodified_float = fixedToFloat(st->hTcxLtpDec->tcxltp_gain, 15); - //st->hTcxDec->tcxltp_last_gain_unmodified_float = st->hTcxLtpDec->tcxltp_gain_float; IF( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { // 16bit to u8bit @@ -3917,46 +2913,6 @@ 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( st->hTonalMDCTConc != NULL ) - { - //st->hTonalMDCTConc->scf_fadeout_flt = fixedToFloat( st->hTonalMDCTConc->scf_fadeout, 15 ); - //st->hTonalMDCTConc->last_block_nrg_flt = me2f( st->hTonalMDCTConc->last_block_nrg, st->hTonalMDCTConc->last_block_nrg_exp ); - if ( hCPE->hCoreCoder[ch]->bfi && st->tonal_mdct_plc_active ) - { - //st->hTonalMDCTConc->nFramesLost_float = fix16_to_float( st->hTonalMDCTConc->nFramesLost, Q1 ); - } - } - - if ( sts[ch]->last_core != -1 && sts[ch]->nbLostCmpt == 1 ) - { - if ( !( sts[ch]->rf_flag && sts[ch]->use_partial_copy && ( sts[ch]->rf_frame_type == RF_TCXTD1 || sts[ch]->rf_frame_type == RF_TCXTD2 ) ) ) - { - IF( sts[ch]->hTonalMDCTConc != NULL && sts[ch]->last_core == TCX_20_CORE && sts[ch]->second_last_core == TCX_20_CORE && ( ( sts[ch]->old_fpitch <= L_shl( sts[ch]->L_frame, 15 ) ) || ( sts[ch]->hTcxDec->tcxltp_last_gain_unmodified <= 13107 /*0.4f*/ ) ) - /* it is fine to call the detection even if no ltp information - is available, meaning that st->old_fpitch == - st->tcxltp_second_last_pitch == st->L_frame */ - && ( sts[ch]->old_fpitch == sts[ch]->hTcxDec->tcxltp_second_last_pitch ) && !sts[ch]->last_tns_active && !sts[ch]->second_last_tns_active ) - { - - if ( sts[ch]->hTonalMDCTConc->pTCI->numIndexes < MAX_NUMBER_OF_IDX ) - { - FOR( i = 0; i < sts[ch]->hTonalMDCTConc->pTCI->numIndexes; i++ ) - { - sts[ch]->hTonalMDCTConc->pTCI->phaseDiff_float[i] = fixedToFloat( sts[ch]->hTonalMDCTConc->pTCI->phaseDiff[i], Q12 ); - } - FOR( i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++ ) - { - sts[ch]->hTonalMDCTConc->pTCI->phase_currentFramePredicted_float[i] = fixedToFloat( sts[ch]->hTonalMDCTConc->pTCI->phase_currentFramePredicted[i], Q13 ); - } - } - } - } } } @@ -3971,11 +2927,6 @@ ivas_error ivas_jbm_dec_tc( IF( sts[0]->bfi == 0 && !st->hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive ) fixedToFloat_arr( st->hTonalMDCTConc->secondLastPcmOut, st->hTonalMDCTConc->secondLastPcmOut_float, 0, st->hTonalMDCTConc->nSamples / 2 ); fixedToFloat_arr( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synthFB, st->Q_syn, st->hTcxDec->old_synth_lenFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); - 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 / 2; p++ ) { st->hTcxDec->old_syn_Overl_float[p] = (float) st->hTcxDec->old_syn_Overl[p] * 2 * ( 1u << st->Q_syn ); @@ -3991,11 +2942,7 @@ ivas_error ivas_jbm_dec_tc( { fixedToFloat_arr( st->p_bpf_noise_buf, st->p_bpf_noise_buf_float, 0, L_FRAME_16k ); } - - fixedToFloat_arr( st->hTcxDec->syn_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 ); - st->hTcxDec->tcxltp_last_gain_unmodified_float = fix16_to_float( st->hTcxDec->tcxltp_last_gain_unmodified, Q15 ); - //st->hTcxDec->conceal_eof_gain_float = fix16_to_float( st->hTcxDec->conceal_eof_gain, Q14 ); /*-------------------cldfb-start-------------------------*/ @@ -4036,47 +2983,6 @@ ivas_error ivas_jbm_dec_tc( sts[n]->hBWE_FD->prev_L_swb_norm = sts[n]->hBWE_FD->prev_L_swb_norm; sts[n]->hBWE_FD->prev_flag = sts[n]->hBWE_FD->prev_flag; } - - for ( int p = 0; p < L_FRAME48k; p++ ) - { - - IF( hCPE->hCoreCoder[n]->hTcxLtpDec ) - { - hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_float[p] = (float) hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_32[p] / ( 1u << q_output ); - if ( p < TCXLTP_MAX_DELAY ) - { - hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_float[p] = (float) hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_32[p] / ( 1u << q_output ); - } - } - } - if ( hCPE->hCoreCoder[n]->hTcxDec ) - { - for ( k = 0; k < 111; k++ ) - { - //hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] = (float) hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] / ( 1u << q_output ); - } - } - IF( hCPE->hCoreCoder[n]->hTcxLtpDec ) - - if ( ( hCPE->hCoreCoder[n]->codec_mode == MODE1 && hCPE->hCoreCoder[n]->hTcxDec != NULL ) && ( ( hCPE->hCoreCoder[n]->core == ACELP_CORE && !( hCPE->hCoreCoder[n]->bfi == 1 && hCPE->hCoreCoder[n]->con_tcx == 1 ) ) || hCPE->hCoreCoder[n]->core == HQ_CORE ) ) - { - fixedToFloat_arr( hCPE->hCoreCoder[n]->hTcxDec->synth_history_fx, hCPE->hCoreCoder[n]->hTcxDec->synth_history, 0, output_frame ); - } - } - - IF( hCPE->hStereoDft != NULL ) - { - IF( hCPE->hStereoDft->hTcxLtpDec != NULL ) - { - FOR( Word32 p = 0; p < L_FRAME48k; p++ ) - { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] = (float) hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] / ( 1u << q_output ); - } - FOR( Word32 p = 0; p < TCXLTP_MAX_DELAY; p++ ) - { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] = (float) hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] / ( 1u << q_output ); - } - } } FOR( n = 0; n < CPE_CHANNELS; n++ ) { @@ -4087,13 +2993,6 @@ ivas_error ivas_jbm_dec_tc( hCPE->output_mem[n][k] = (float) hCPE->output_mem_fx[n][k] / ( 1u << 11 ); } } - IF( hCPE->hCoreCoder[n] != NULL ) - { - FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); k++ ) - { - //hCPE->hCoreCoder[n]->prev_synth_buffer[k] = (float) hCPE->hCoreCoder[n]->prev_synth_buffer32_fx[k] / ( 1 << q_output ); - } - } IF( hCPE->input_mem[n] != NULL ) { FOR( Word32 ind = 0; ind < STEREO_DFT32MS_OVL_16k; ind++ ) @@ -4101,10 +3000,6 @@ ivas_error ivas_jbm_dec_tc( hCPE->input_mem_LB[n][ind] = ( (float) hCPE->input_mem_LB_fx[n][ind] / ( 1 << q_output ) ); } } - //FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); k++ ) - //{ - // hCPE->prev_hb_synth[n][k] = (float) hCPE->prev_hb_synth_fx[n][k] / ( 1 << q_output ); - //} FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) { hCPE->prev_synth[n][k] = (float) hCPE->prev_synth_fx[n][k] / ( 1 << q_output ); @@ -4123,7 +3018,6 @@ 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 ) ); 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]; @@ -4139,11 +3033,6 @@ ivas_error ivas_jbm_dec_tc( IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx ) me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - FOR( i = 0; i < 12; i++ ) - if ( p_output[i] ) - { - fixedToFloat_arrL( p_output_fx[i], p_output[i], Q11, L_FRAME48k ); - } #endif // Fix to float #else if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) @@ -4158,15 +3047,7 @@ ivas_error ivas_jbm_dec_tc( if ( n != LFE_CHANNEL ) { #ifdef IVAS_FLOAT_FIXED - for ( i = 0; i < output_frame; i++ ) - { - p_output_fx[n][i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); - } 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_fx[n][i] / ( 1 << 11 ); - } #else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); #endif // IVAS_FLOAT_FIXED @@ -4177,20 +3058,21 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->renderer_type == RENDERER_MC && ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) ) { /* Compensate loudness for not doing full upmix */ - for ( n = 4; n < 8; n++ ) + FOR( n = 4; n < 8; n++ ) { - v_multc( p_output[n], 2.0f, p_output[n], output_frame ); + Scale_sig32( p_output_fx[n], output_frame, 1 ); } if ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) { #ifdef IVAS_FLOAT_FIXED - Word16 q = Q16, nchan_transport; + s = sub( Q16, Q11 ); + Word16 nchan_transport; nchan_transport = audioCfg2channels( IVAS_AUDIO_CONFIG_5_1_2 ); - q = q - find_guarded_bits_fx( nchan_transport ); + s = s - find_guarded_bits_fx( nchan_transport ); FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i ) { - floatToFixed_arrL( p_output[i], p_output_fx[i], q, output_frame ); + Scale_sig32( p_output_fx[i], output_frame, s ); } FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) { @@ -4202,7 +3084,7 @@ ivas_error ivas_jbm_dec_tc( ivas_ls_setup_conversion_fx( st_ivas, nchan_transport, output_frame, p_output_fx, p_output_fx ); 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 ); + Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); } #else ivas_ls_setup_conversion( st_ivas, audioCfg2channels( IVAS_AUDIO_CONFIG_5_1_2 ), output_frame, p_output, p_output ); @@ -4224,12 +3106,11 @@ ivas_error ivas_jbm_dec_tc( { return error; } - for ( int k = 0; k < output_frame; k++ ) + IF( NE_16( q_output, Q11 ) ) { - 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 ); + Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); + Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); } - } #else if ( st_ivas->nCPE == 1 ) @@ -4242,7 +3123,7 @@ ivas_error ivas_jbm_dec_tc( #endif // IVAS_FLOAT_FIXED else if ( st_ivas->nCPE > 1 ) { - #ifdef IVAS_FLOAT_FIXED +#ifdef IVAS_FLOAT_FIXED #if 1 // Float to fix Word16 ch, nCPE, cpe_id; @@ -4252,11 +3133,6 @@ ivas_error ivas_jbm_dec_tc( nCPE = st_ivas->nCPE; move16(); hMCT = st_ivas->hMCT; - FOR( i = 0; i < 12; i++ ) - if ( p_output[i] ) - { - floatToFixed_arrL( p_output[i], p_output_fx[i], Q11, L_FRAME48k ); - } FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { hCPE = st_ivas->hCPE[cpe_id]; @@ -4266,40 +3142,6 @@ ivas_error ivas_jbm_dec_tc( FOR( n = 0; n < CPE_CHANNELS; n++ ) { st = hCPE->hCoreCoder[n]; - IF( st->hTonalMDCTConc ) - { - - FOR( i = 0; i < st->hTonalMDCTConc->nScaleFactors; i++ ) - { - st->hTonalMDCTConc->scaleFactorsBackground_fx[i] = float_to_fix( st->hTonalMDCTConc->scaleFactorsBackground_flt[i], 15 ); - } - //st->hTonalMDCTConc->scf_fadeout = float_to_fix16( st->hTonalMDCTConc->scf_fadeout_flt, 15 ); - if ( hCPE->hCoreCoder[n]->bfi && st->tonal_mdct_plc_active ) - { - FOR( i = 0; i < FDNS_NPTS; i++ ) - { - f2me_16( st->hTonalMDCTConc->secondLastBlockData.scaleFactors_float[i], &st->hTonalMDCTConc->secondLastBlockData.scaleFactors[i], &st->hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i] ); - } - FOR( i = 0; i < 30; i++ ) - { - float pd = st->hTonalMDCTConc->pTCI->phaseDiff_float[i]; - if ( pd >= PI2 ) - pd = fmodf( pd, PI2 ) - PI2; - st->hTonalMDCTConc->pTCI->phaseDiff[i] = (Word16) floatToFixed( pd, Q12 ); - } - FOR( i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++ ) - { - float pd = st->hTonalMDCTConc->pTCI->phase_currentFramePredicted_float[i]; - pd = fmodf( pd, PI2 ); - st->hTonalMDCTConc->pTCI->phase_currentFramePredicted[i] = (Word16) ( pd * ( 1u << Q13 ) ); - } - // st->hTonalMDCTConc->nFramesLost = float_to_fix16( st->hTonalMDCTConc->nFramesLost, Q1 ); - } - //f2me( st->hTonalMDCTConc->last_block_nrg_flt, &st->hTonalMDCTConc->last_block_nrg, &st->hTonalMDCTConc->last_block_nrg_exp ); - } - // st->old_fpitch = float_to_fix(st->old_fpitch_float, 16); - st->hTcxDec->tcxltp_last_gain_unmodified = float_to_fix16( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 ); - IF( sts[n]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { // u8bit to 16bit @@ -4324,22 +3166,8 @@ ivas_error ivas_jbm_dec_tc( st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; IF( st->hTcxDec ) st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; - IF( st->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 ) ); - //} 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); - - IF( hCPE->hCoreCoder[n]->hTcxLtpDec ) - { - floatToFixed_arrL( hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_float, hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_32, q_output, L_FRAME48k ); - floatToFixed_arrL( hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_float, hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_32, q_output, TCXLTP_MAX_DELAY ); - //floatToFixed_arrL( hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float, hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32, Q11, 111 ); - } - /*cldfb struct*/ @@ -4369,8 +3197,6 @@ ivas_error ivas_jbm_dec_tc( /*-------------------cldfb-end---------------------------*/ - - //floatToFixed_arr( sts[n]->prev_synth_buffer, hCPE->hCoreCoder[n]->prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); } IF( hCPE->output_mem[0] != NULL ) @@ -4384,22 +3210,6 @@ ivas_error ivas_jbm_dec_tc( FOR( n = 0; n < CPE_CHANNELS; n++ ) { - - IF( hCPE->hStereoDft != NULL ) - { - IF( hCPE->hStereoDft->hTcxLtpDec != NULL ) - { - FOR( Word32 p = 0; p < L_FRAME48k; p++ ) - { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] = (Word32) ( hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] * ( 1u << q_output ) ); - } - FOR( Word32 p = 0; p < TCXLTP_MAX_DELAY; p++ ) - { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] = (Word32) ( hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] * ( 1u << q_output ) ); - } - } - } - IF( hCPE->input_mem_LB[n] != NULL ) { FOR( Word32 ind = 0; ind < STEREO_DFT32MS_OVL_16k; ind++ ) @@ -4407,11 +3217,6 @@ ivas_error ivas_jbm_dec_tc( hCPE->input_mem_LB_fx[n][ind] = (Word32) ( hCPE->input_mem_LB[n][ind] * ( 1 << q_output ) ); } } - - //FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); k++ ) - //{ - // hCPE->prev_hb_synth_fx[n][k] = (Word32) ( hCPE->prev_hb_synth[n][k] * ( 1 << q_output ) ); - //} FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) { hCPE->prev_synth_fx[n][k] = (Word32) ( hCPE->prev_synth[n][k] * ( 1 << q_output ) ); @@ -4450,7 +3255,6 @@ ivas_error ivas_jbm_dec_tc( FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = hCPE->hCoreCoder[ch]; - st->hTcxDec->tcxltp_last_gain_unmodified_float = fixedToFloat(st->hTcxLtpDec->tcxltp_gain, 15); IF( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { // 16bit to u8bit @@ -4458,45 +3262,6 @@ 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( st->hTonalMDCTConc != NULL ) - { - //st->hTonalMDCTConc->scf_fadeout_flt = fixedToFloat( st->hTonalMDCTConc->scf_fadeout, 15 ); - //st->hTonalMDCTConc->last_block_nrg_flt = me2f( st->hTonalMDCTConc->last_block_nrg, st->hTonalMDCTConc->last_block_nrg_exp ); - if ( hCPE->hCoreCoder[ch]->bfi && st->tonal_mdct_plc_active ) - { - //st->hTonalMDCTConc->nFramesLost_float = fix16_to_float( st->hTonalMDCTConc->nFramesLost, Q1 ); - } - } - - if ( sts[ch]->last_core != -1 && sts[ch]->nbLostCmpt == 1 ) - { - if ( !( sts[ch]->rf_flag && sts[ch]->use_partial_copy && ( sts[ch]->rf_frame_type == RF_TCXTD1 || sts[ch]->rf_frame_type == RF_TCXTD2 ) ) ) - { - IF( sts[ch]->hTonalMDCTConc != NULL && sts[ch]->last_core == TCX_20_CORE && sts[ch]->second_last_core == TCX_20_CORE && ( ( sts[ch]->old_fpitch <= L_shl( sts[ch]->L_frame, 15 ) ) || ( sts[ch]->hTcxDec->tcxltp_last_gain_unmodified <= 13107 /*0.4f*/ ) ) - /* it is fine to call the detection even if no ltp information - is available, meaning that st->old_fpitch == - st->tcxltp_second_last_pitch == st->L_frame */ - && ( sts[ch]->old_fpitch == sts[ch]->hTcxDec->tcxltp_second_last_pitch ) && !sts[ch]->last_tns_active && !sts[ch]->second_last_tns_active ) - { - - if ( sts[ch]->hTonalMDCTConc->pTCI->numIndexes < MAX_NUMBER_OF_IDX ) - { - FOR( i = 0; i < sts[ch]->hTonalMDCTConc->pTCI->numIndexes; i++ ) - { - sts[ch]->hTonalMDCTConc->pTCI->phaseDiff_float[i] = fixedToFloat( sts[ch]->hTonalMDCTConc->pTCI->phaseDiff[i], Q12 ); - } - FOR( i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++ ) - { - sts[ch]->hTonalMDCTConc->pTCI->phase_currentFramePredicted_float[i] = fixedToFloat( sts[ch]->hTonalMDCTConc->pTCI->phase_currentFramePredicted[i], Q13 ); - } - } - } - } } } @@ -4511,11 +3276,6 @@ ivas_error ivas_jbm_dec_tc( IF( sts[0]->bfi == 0 && !st->hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive ) fixedToFloat_arr( st->hTonalMDCTConc->secondLastPcmOut, st->hTonalMDCTConc->secondLastPcmOut_float, 0, st->hTonalMDCTConc->nSamples / 2 ); fixedToFloat_arr( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synthFB, st->Q_syn, st->hTcxDec->old_synth_lenFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); - 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 / 2; p++ ) { st->hTcxDec->old_syn_Overl_float[p] = (float) st->hTcxDec->old_syn_Overl[p] * 2 * ( 1u << st->Q_syn ); @@ -4531,11 +3291,7 @@ ivas_error ivas_jbm_dec_tc( { fixedToFloat_arr( st->p_bpf_noise_buf, st->p_bpf_noise_buf_float, 0, L_FRAME_16k ); } - - fixedToFloat_arr( st->hTcxDec->syn_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 ); - st->hTcxDec->tcxltp_last_gain_unmodified_float = fix16_to_float( st->hTcxDec->tcxltp_last_gain_unmodified, Q15 ); - //st->hTcxDec->conceal_eof_gain_float = fix16_to_float( st->hTcxDec->conceal_eof_gain, Q14 ); /*-------------------cldfb-start-------------------------*/ @@ -4576,48 +3332,8 @@ ivas_error ivas_jbm_dec_tc( sts[n]->hBWE_FD->prev_L_swb_norm = sts[n]->hBWE_FD->prev_L_swb_norm; sts[n]->hBWE_FD->prev_flag = sts[n]->hBWE_FD->prev_flag; } - - for ( int p = 0; p < L_FRAME48k; p++ ) - { - - IF( hCPE->hCoreCoder[n]->hTcxLtpDec ) - { - hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_float[p] = (float) hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_32[p] / ( 1u << q_output ); - if ( p < TCXLTP_MAX_DELAY ) - { - hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_float[p] = (float) hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_32[p] / ( 1u << q_output ); - } - } - } - if ( hCPE->hCoreCoder[n]->hTcxDec ) - { - for ( k = 0; k < 111; k++ ) - { - //hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] = (float) hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] / ( 1u << q_output ); - } - } - IF( hCPE->hCoreCoder[n]->hTcxLtpDec ) - - if ( ( hCPE->hCoreCoder[n]->codec_mode == MODE1 && hCPE->hCoreCoder[n]->hTcxDec != NULL ) && ( ( hCPE->hCoreCoder[n]->core == ACELP_CORE && !( hCPE->hCoreCoder[n]->bfi == 1 && hCPE->hCoreCoder[n]->con_tcx == 1 ) ) || hCPE->hCoreCoder[n]->core == HQ_CORE ) ) - { - fixedToFloat_arr( hCPE->hCoreCoder[n]->hTcxDec->synth_history_fx, hCPE->hCoreCoder[n]->hTcxDec->synth_history, 0, output_frame ); - } } - IF( hCPE->hStereoDft != NULL ) - { - IF( hCPE->hStereoDft->hTcxLtpDec != NULL ) - { - FOR( Word32 p = 0; p < L_FRAME48k; p++ ) - { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] = (float) hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] / ( 1u << q_output ); - } - FOR( Word32 p = 0; p < TCXLTP_MAX_DELAY; p++ ) - { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] = (float) hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] / ( 1u << q_output ); - } - } - } FOR( n = 0; n < CPE_CHANNELS; n++ ) { IF( hCPE->output_mem[n] != NULL ) @@ -4627,13 +3343,6 @@ ivas_error ivas_jbm_dec_tc( hCPE->output_mem[n][k] = (float) hCPE->output_mem_fx[n][k] / ( 1u << 11 ); } } - IF( hCPE->hCoreCoder[n] != NULL ) - { - FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); k++ ) - { - //hCPE->hCoreCoder[n]->prev_synth_buffer[k] = (float) hCPE->hCoreCoder[n]->prev_synth_buffer32_fx[k] / ( 1 << q_output ); - } - } IF( hCPE->input_mem[n] != NULL ) { FOR( Word32 ind = 0; ind < STEREO_DFT32MS_OVL_16k; ind++ ) @@ -4641,10 +3350,6 @@ ivas_error ivas_jbm_dec_tc( hCPE->input_mem_LB[n][ind] = ( (float) hCPE->input_mem_LB_fx[n][ind] / ( 1 << q_output ) ); } } - //FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); k++ ) - //{ - // hCPE->prev_hb_synth[n][k] = (float) hCPE->prev_hb_synth_fx[n][k] / ( 1 << q_output ); - //} FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) { hCPE->prev_synth[n][k] = (float) hCPE->prev_synth_fx[n][k] / ( 1 << q_output ); @@ -4663,7 +3368,6 @@ 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 ) ); 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]; @@ -4679,11 +3383,6 @@ ivas_error ivas_jbm_dec_tc( IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx ) me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - FOR( i = 0; i < 12; i++ ) - if ( p_output[i] ) - { - fixedToFloat_arrL( p_output_fx[i], p_output[i], Q11, L_FRAME48k ); - } #endif // Fix to float #else if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) @@ -4697,15 +3396,7 @@ ivas_error ivas_jbm_dec_tc( for ( n = 0; n < st_ivas->nchan_transport; n++ ) { #ifdef IVAS_FLOAT_FIXED - for ( i = 0; i < output_frame; i++ ) - { - p_output_fx[n][i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); - } 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_fx[n][i] / ( 1 << 11 ); - } #else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); #endif // IVAS_FLOAT_FIXED @@ -4715,11 +3406,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 q = Q16; - q = q - find_guarded_bits_fx( st_ivas->nchan_transport ); + s = sub( Q16, Q11 ); + s = sub( s, find_guarded_bits_fx( st_ivas->nchan_transport ) ); FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { - floatToFixed_arrL( p_output[i], p_output_fx[i], q, output_frame ); + Scale_sig32( p_output_fx[i], output_frame, s ); } FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) { @@ -4731,16 +3422,16 @@ ivas_error ivas_jbm_dec_tc( ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); 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 ); + Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); } #else ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, output_frame, p_output, p_output ); #endif } } - else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) + ELSE IF( st_ivas->mc_mode == MC_MODE_MCMASA ) { - if ( st_ivas->hOutSetup.separateChannelEnabled ) + IF( st_ivas->hOutSetup.separateChannelEnabled ) { st = st_ivas->hCPE[0]->hCoreCoder[0]; /* Metadata is always with CPE in the case of separated channel */ } @@ -4849,11 +3540,10 @@ ivas_error ivas_jbm_dec_tc( { return error; } - - for ( int k = 0; k < output_frame; k++ ) + IF( NE_16( q_output, Q11 ) ) { - 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 ); + Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); + Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); } #else @@ -4869,33 +3559,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 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, &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) p_output_fx[n][k] / ONE_IN_Q11; - } - 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] / ONE_IN_Q11; - //if ( k < 45 ) - // st_ivas->hSCE[0]->prev_hb_synth[k] = (float) st_ivas->hSCE[0]->prev_hb_synth_fx[k] / ONE_IN_Q11; - } #else if ( ( error = ivas_sce_dec( st_ivas, 0, &p_output[n], output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; } #endif // IVAS_FLOAT_FIXED - +#if 1 + fixedToFloat_arrL( p_output_fx[n], p_output[n], Q11, output_frame ); + fixedToFloat_arrL( p_output_fx[LFE_CHANNEL], p_output[LFE_CHANNEL], Q11, output_frame ); /* Delay the separated channel to sync with CLDFB delay of the DirAC synthesis, and synthesize the LFE signal. */ if ( output_config == IVAS_AUDIO_CONFIG_5_1 || output_config == IVAS_AUDIO_CONFIG_7_1 || output_config == IVAS_AUDIO_CONFIG_5_1_4 || output_config == IVAS_AUDIO_CONFIG_7_1_4 || @@ -4908,6 +3585,9 @@ ivas_error ivas_jbm_dec_tc( /* Delay the separated channel to sync with the DirAC rendering */ delay_signal_float( p_output[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size ); } + floatToFixed_arrL( p_output[n], p_output_fx[n], Q11, output_frame ); + floatToFixed_arrL( p_output[LFE_CHANNEL], p_output_fx[LFE_CHANNEL], Q11, output_frame ); +#endif } else { @@ -4916,26 +3596,11 @@ ivas_error ivas_jbm_dec_tc( IF( EQ_16( st_ivas->nSCE, 1 ) ) { 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, &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) p_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 ); - } } ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) { @@ -4944,13 +3609,11 @@ ivas_error ivas_jbm_dec_tc( { return error; } - - for ( int k = 0; k < output_frame; k++ ) + IF( NE_16( q_output, Q11 ) ) { - 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 ); + Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); + Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); } - } #else if ( st_ivas->nSCE == 1 ) @@ -4970,61 +3633,37 @@ ivas_error ivas_jbm_dec_tc( #endif // IVAS_FLOAT_FIXED } - if ( st_ivas->sba_dirac_stereo_flag ) /* use the flag to trigger the DFT upmix */ + IF( NE_16( st_ivas->sba_dirac_stereo_flag, 0 ) ) /* use the flag to trigger the DFT upmix */ { #ifndef IVAS_FLOAT_FIXED ivas_sba_dirac_stereo_dec( st_ivas, p_output, output_frame, 1 ); #else - { Word16 q; float l_hb_nrg = 0.0, l_hb_nrg_subr = 0.0; - static int frame_counter = 0; - if ( frame_counter >= 200 ) - frame_counter = frame_counter; float max_val = 0.0; - int i_max_val_psd, i_max_val_op; + int i_max_val_op; 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++ ) + i_max_val_op = (int) max_val; + s = 0; + FOR( i = 0; i < 2; i++ ) { - if ( max_val < fabs( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[ii] ) ) - { - max_val = (float) fabs( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->smoothed_psd[ii] ); - } + s = s_min( s, L_norm_arr( p_output_fx[i], L_FRAME48k ) - 11 /* Guard bits */ ); } - i_max_val_psd = (int) max_val; - for ( int ii = 0; ii < 2; ii++ ) + FOR( i = 0; i < 2; i++ ) { - for ( int jj = 0; jj < ( 48000 / FRAMES_PER_SEC ); jj++ ) - { - if ( max_val < fabs( p_output[ii][jj] ) ) - { - max_val = (float) fabs( p_output[ii][jj] ); - } - } + Scale_sig32( p_output_fx[i], L_FRAME48k, s ); } - i_max_val_op = (int)max_val; - hCPE->hStereoDft->q_dft = norm_l(i_max_val_op) - Q11; - IF(hCPE->hStereoDft->q_dft < 0) + hCPE->hStereoDft->q_dft = Q11 + s; + // st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->q_smoothed_psd = Q11 - Q9; + IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) { - hCPE->hStereoDft->q_dft = 0; - } - ELSE IF (hCPE->hStereoDft->q_dft > Q11) - { - hCPE->hStereoDft->q_dft = Q11; - } - st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->q_smoothed_psd = norm_l(i_max_val_psd) - Q9; - IF (EQ_16(hCPE->hStereoDft->first_frame, 1)) - { - //hCPE->q_prev_synth_fx = hCPE->hStereoDft->q_dft; - hCPE->hStereoDft->q_smoothed_nrg = Q6;//hCPE->hStereoDft->q_dft; + hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; 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); - 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++) + //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] ) ); + for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_subr_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_subr_fx[0] ); ii++ ) { if ( l_hb_nrg_subr < hCPE->hStereoDft->hb_nrg_subr[ii] ) { @@ -5056,141 +3695,138 @@ ivas_error ivas_jbm_dec_tc( } for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_fx[0] ); ii++ ) { - hCPE->hStereoDft->hb_nrg_fx[ii] = (Word32)(hCPE->hStereoDft->hb_nrg[ii] * ((float)(1 << hCPE->hStereoDft->q_hb_nrg))); + hCPE->hStereoDft->hb_nrg_fx[ii] = (Word32) ( hCPE->hStereoDft->hb_nrg[ii] * ( (float) ( 1 << hCPE->hStereoDft->q_hb_nrg ) ) ); } - //floatToFixed_arr( &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx[0], Q15, sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx ) / sizeof( st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx[0] ) ); IF( hCPE->hStereoCng != NULL ) { floatToFixed_arr( &hCPE->hStereoCng->cm[0], &hCPE->hStereoCng->cm_fx[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); } - //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_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); - floatToFixed_arrL(&hCPE->input_mem[0][0], &hCPE->input_mem_fx[0][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS )); - floatToFixed_arrL(&hCPE->input_mem_LB[0][0], &hCPE->input_mem_LB_fx[0][0], q, STEREO_DFT32MS_OVL_16k); - floatToFixed_arrL(&hCPE->input_mem[1][0], &hCPE->input_mem_fx[1][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS )); - floatToFixed_arrL(&hCPE->input_mem_LB[1][0], &hCPE->input_mem_LB_fx[1][0], q, STEREO_DFT32MS_OVL_16k); - if (hSCE != NULL) - { - //floatToFixed_arrL(&hSCE->prev_hb_synth[0], &hSCE->prev_hb_synth_fx[0], hCPE->hStereoDft->q_dft, sizeof(hSCE->prev_hb_synth_fx) / sizeof(hSCE->prev_hb_synth_fx[0])); - //hSCE->q_prev_hb_synth_fx = hCPE->hStereoDft->q_dft; - floatToFixed_arrL(&hSCE->save_hb_synth[0], &hSCE->save_hb_synth_fx[0], q, (Word16)(hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC)); + floatToFixed_arrL( &hCPE->input_mem_BPF[0][0], &hCPE->input_mem_BPF_fx[0][0], q, STEREO_DFT32MS_OVL_16k ); + floatToFixed_arrL( &hCPE->input_mem[0][0], &hCPE->input_mem_fx[0][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ) ); + floatToFixed_arrL( &hCPE->input_mem_LB[0][0], &hCPE->input_mem_LB_fx[0][0], q, STEREO_DFT32MS_OVL_16k ); + floatToFixed_arrL( &hCPE->input_mem[1][0], &hCPE->input_mem_fx[1][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ) ); + floatToFixed_arrL( &hCPE->input_mem_LB[1][0], &hCPE->input_mem_LB_fx[1][0], q, STEREO_DFT32MS_OVL_16k ); + if ( hSCE != NULL ) + { + floatToFixed_arrL( &hSCE->save_hb_synth[0], &hSCE->save_hb_synth_fx[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); hSCE->q_save_hb_synth_fx = q; - floatToFixed_arrL(&hSCE->save_synth[0], &hSCE->save_synth_fx[0], q, (Word16)(hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC)); + floatToFixed_arrL( &hSCE->save_synth[0], &hSCE->save_synth_fx[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); hSCE->q_save_synth_fx = q; } IF( hCPE->hCoreCoder[0] != NULL ) { - floatToFixed_arrL(&hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], q, L_FRAME32k); + floatToFixed_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], q, L_FRAME32k ); hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; - floatToFixed_arrL(&hCPE->hCoreCoder[0]->hHQ_core->old_out[0], &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], q, L_FRAME48k); - IF( (hCPE->hCoreCoder[0] != NULL) && (hCPE->hCoreCoder[0]->p_bpf_noise_buf_32 != NULL) ) - floatToFixed_arrL(&hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], q, L_FRAME16k); + floatToFixed_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], q, L_FRAME48k ); + IF( ( hCPE->hCoreCoder[0] != NULL ) && ( hCPE->hCoreCoder[0]->p_bpf_noise_buf_32 != NULL ) ) + floatToFixed_arrL( &hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], q, L_FRAME16k ); } IF( hCPE->hStereoDft != NULL ) { - floatToFixed_arrL(&hCPE->hStereoDft->td_gain[0], &hCPE->hStereoDft->td_gain_fx[0], Q31, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); - floatToFixed_arrL(&hCPE->hStereoDft->ap_delay_mem[0], &hCPE->hStereoDft->ap_delay_mem_fx[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS )); - floatToFixed_arrL(&hCPE->hStereoDft->buff_LBTCX_mem[0], &hCPE->hStereoDft->buff_LBTCX_mem_fx[0], q, NS2SA( 16000, STEREO_DFT32MS_OVL_NS )); + floatToFixed_arrL( &hCPE->hStereoDft->td_gain[0], &hCPE->hStereoDft->td_gain_fx[0], Q31, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); + floatToFixed_arrL( &hCPE->hStereoDft->ap_delay_mem[0], &hCPE->hStereoDft->ap_delay_mem_fx[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); + floatToFixed_arrL( &hCPE->hStereoDft->buff_LBTCX_mem[0], &hCPE->hStereoDft->buff_LBTCX_mem_fx[0], q, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ) ); hCPE->hStereoDft->q_smooth_buf_fx = Q7; - floatToFixed_arrL(&hCPE->hStereoDft->smooth_buf[0][0], &hCPE->hStereoDft->smooth_buf_fx[0][0], hCPE->hStereoDft->q_smooth_buf_fx, sizeof(hCPE->hStereoDft->smooth_buf_fx) / sizeof(hCPE->hStereoDft->smooth_buf_fx[0][0])); + floatToFixed_arrL( &hCPE->hStereoDft->smooth_buf[0][0], &hCPE->hStereoDft->smooth_buf_fx[0][0], hCPE->hStereoDft->q_smooth_buf_fx, sizeof( hCPE->hStereoDft->smooth_buf_fx ) / sizeof( hCPE->hStereoDft->smooth_buf_fx[0][0] ) ); } - IF (st_ivas->hSpar != NULL) + IF( st_ivas->hSpar != NULL ) { - floatToFixed_arrL(&st_ivas->hSpar->hMdDec->mixer_mat_prev[0][0][0][0], &st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0], Q31, sizeof(st_ivas->hSpar->hMdDec->mixer_mat_prev_fx) / sizeof(st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0])); - for (int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++) - { - for (int jj = 0; jj < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; jj++) - { - floatToFixed_arrL(&st_ivas->hSpar->hMdDec->mixer_mat[ii][jj][0], + floatToFixed_arrL( &st_ivas->hSpar->hMdDec->mixer_mat_prev[0][0][0][0], &st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0], Q31, sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx ) / sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0] ) ); + for ( int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++ ) + { + for ( int jj = 0; jj < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; jj++ ) + { + floatToFixed_arrL( &st_ivas->hSpar->hMdDec->mixer_mat[ii][jj][0], &st_ivas->hSpar->hMdDec->mixer_mat_fx[ii][jj][0], Q31, - st_ivas->hSpar->hMdDec->mix_mat_dim_2); - } - } + st_ivas->hSpar->hMdDec->mix_mat_dim_2 ); + } + } } - //hCPE->lt_es_em_fx = floatToFixed(hCPE->lt_es_em, Q15); - for (int ii = 0; ii < CPE_CHANNELS; ii++) + for ( int ii = 0; ii < CPE_CHANNELS; ii++ ) { hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; - floatToFixed_arrL(&hCPE->output_mem[ii][0], &hCPE->output_mem_fx[ii][0], hCPE->hStereoDft->q_dft, NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS )); + floatToFixed_arrL( &hCPE->output_mem[ii][0], &hCPE->output_mem_fx[ii][0], hCPE->hStereoDft->q_dft, NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ) ); } - 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])); - + 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_fx, output_frame, 1 ); + FOR( i = 0; i < 2; i++ ) + { + Scale_sig32( p_output_fx[i], L_FRAME48k, negate( s ) ); + } - 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 ); - 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] ) ); + 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] ) ); for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_subr_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_subr_fx[0] ); ii++ ) { - hCPE->hStereoDft->hb_nrg_subr[ii] = ((float)hCPE->hStereoDft->hb_nrg_subr_fx[ii] / ((float)(1 << hCPE->hStereoDft->q_hb_nrg_subr))); + hCPE->hStereoDft->hb_nrg_subr[ii] = ( (float) hCPE->hStereoDft->hb_nrg_subr_fx[ii] / ( (float) ( 1 << hCPE->hStereoDft->q_hb_nrg_subr ) ) ); } for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_fx[0] ); ii++ ) { hCPE->hStereoDft->hb_nrg[ii] = ( (float) hCPE->hStereoDft->hb_nrg_fx[ii] * ( (float) ( 1 << hCPE->hStereoDft->q_hb_nrg ) ) ); } - //fixedToFloat_arr(&st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx[0], &st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm[0], Q15, sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx) / sizeof(st_ivas->hCPE[0]->hCoreCoder[0]->hFdCngDec->cna_cm_fx[0])); - //fixedToFloat_arrL(&hCPE->prev_hb_synth_fx[0][0], &hCPE->prev_hb_synth[0][0], hCPE->hStereoDft->q_dft, sizeof(hCPE->prev_hb_synth_fx) / sizeof(hCPE->prev_hb_synth_fx[0][0])); - IF (hCPE->hStereoCng != NULL) + IF( hCPE->hStereoCng != NULL ) { fixedToFloat_arr( &hCPE->hStereoCng->cm_fx[0], &hCPE->hStereoCng->cm[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); } - //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_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 )); - fixedToFloat_arrL(&hCPE->input_mem_LB_fx[0][0], &hCPE->input_mem_LB[0][0], q, STEREO_DFT32MS_OVL_16k); - fixedToFloat_arrL(&hCPE->input_mem_fx[1][0], &hCPE->input_mem[1][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS )); - fixedToFloat_arrL(&hCPE->input_mem_LB_fx[1][0], &hCPE->input_mem_LB[1][0], q, STEREO_DFT32MS_OVL_16k); - if (hSCE != NULL) + 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 ) ); + fixedToFloat_arrL( &hCPE->input_mem_LB_fx[0][0], &hCPE->input_mem_LB[0][0], q, STEREO_DFT32MS_OVL_16k ); + fixedToFloat_arrL( &hCPE->input_mem_fx[1][0], &hCPE->input_mem[1][0], q, NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ) ); + fixedToFloat_arrL( &hCPE->input_mem_LB_fx[1][0], &hCPE->input_mem_LB[1][0], q, STEREO_DFT32MS_OVL_16k ); + if ( hSCE != NULL ) { - //fixedToFloat_arrL(&hSCE->prev_hb_synth_fx[0], &hSCE->prev_hb_synth[0], hCPE->hStereoDft->q_dft, sizeof(hSCE->prev_hb_synth_fx) / sizeof(hSCE->prev_hb_synth_fx[0])); - fixedToFloat_arrL(&hSCE->save_synth_fx[0], &hSCE->save_synth[0], q, (Word16)(hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC)); - fixedToFloat_arrL(&hSCE->save_hb_synth_fx[0], &hSCE->save_hb_synth[0], q, (Word16)(hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC)); + fixedToFloat_arrL( &hSCE->save_synth_fx[0], &hSCE->save_synth[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); + fixedToFloat_arrL( &hSCE->save_hb_synth_fx[0], &hSCE->save_hb_synth[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); } IF( hCPE->hCoreCoder[0] != NULL ) { - fixedToFloat_arrL(&hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], q, L_FRAME32k); - fixedToFloat_arrL(&hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], q, L_FRAME48k); + fixedToFloat_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], q, L_FRAME32k ); + fixedToFloat_arrL( &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], q, L_FRAME48k ); IF( hCPE->hCoreCoder[0]->p_bpf_noise_buf_32 != NULL ) - fixedToFloat_arrL(&hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], q, L_FRAME16k); + fixedToFloat_arrL( &hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], q, L_FRAME16k ); } IF( hCPE->hStereoDft != NULL ) { fixedToFloat_arrL( &hCPE->hStereoDft->td_gain_fx[0], &hCPE->hStereoDft->td_gain[0], Q31, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); - fixedToFloat_arrL(&hCPE->hStereoDft->ap_delay_mem_fx[0], &hCPE->hStereoDft->ap_delay_mem[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS )); - fixedToFloat_arrL(&hCPE->hStereoDft->buff_LBTCX_mem_fx[0], &hCPE->hStereoDft->buff_LBTCX_mem[0], q, NS2SA( 16000, STEREO_DFT32MS_OVL_NS )); - fixedToFloat_arrL(&hCPE->hStereoDft->smooth_buf_fx[0][0], &hCPE->hStereoDft->smooth_buf[0][0], hCPE->hStereoDft->q_smooth_buf_fx, sizeof(hCPE->hStereoDft->smooth_buf_fx) / sizeof(hCPE->hStereoDft->smooth_buf_fx[0][0])); + fixedToFloat_arrL( &hCPE->hStereoDft->ap_delay_mem_fx[0], &hCPE->hStereoDft->ap_delay_mem[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); + fixedToFloat_arrL( &hCPE->hStereoDft->buff_LBTCX_mem_fx[0], &hCPE->hStereoDft->buff_LBTCX_mem[0], q, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ) ); + fixedToFloat_arrL( &hCPE->hStereoDft->smooth_buf_fx[0][0], &hCPE->hStereoDft->smooth_buf[0][0], hCPE->hStereoDft->q_smooth_buf_fx, sizeof( hCPE->hStereoDft->smooth_buf_fx ) / sizeof( hCPE->hStereoDft->smooth_buf_fx[0][0] ) ); } - IF (st_ivas->hSpar != NULL) + IF( st_ivas->hSpar != NULL ) { - fixedToFloat_arrL(&st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0], &st_ivas->hSpar->hMdDec->mixer_mat_prev[0][0][0][0], Q31, sizeof(st_ivas->hSpar->hMdDec->mixer_mat_prev_fx) / sizeof(st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0])); - for (int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++) + fixedToFloat_arrL( &st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0], &st_ivas->hSpar->hMdDec->mixer_mat_prev[0][0][0][0], Q31, sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx ) / sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0] ) ); + for ( int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++ ) { - for (int jj = 0; jj < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; jj++) + fixedToFloat_arrL( &hCPE->hStereoDft->td_gain_fx[0], &hCPE->hStereoDft->td_gain[0], Q31, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); + fixedToFloat_arrL( &hCPE->hStereoDft->ap_delay_mem_fx[0], &hCPE->hStereoDft->ap_delay_mem[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); + fixedToFloat_arrL( &hCPE->hStereoDft->buff_LBTCX_mem_fx[0], &hCPE->hStereoDft->buff_LBTCX_mem[0], q, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ) ); + fixedToFloat_arrL( &hCPE->hStereoDft->smooth_buf_fx[0][0], &hCPE->hStereoDft->smooth_buf[0][0], hCPE->hStereoDft->q_smooth_buf_fx, sizeof( hCPE->hStereoDft->smooth_buf_fx ) / sizeof( hCPE->hStereoDft->smooth_buf_fx[0][0] ) ); + } + IF( st_ivas->hSpar != NULL ) + { + fixedToFloat_arrL( &st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0], &st_ivas->hSpar->hMdDec->mixer_mat_prev[0][0][0][0], Q31, sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx ) / sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0] ) ); + for ( int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++ ) { - fixedToFloat_arrL(&st_ivas->hSpar->hMdDec->mixer_mat_fx[ii][jj][0], - &st_ivas->hSpar->hMdDec->mixer_mat[ii][jj][0], - Q31, - st_ivas->hSpar->hMdDec->mix_mat_dim_2); + for ( int jj = 0; jj < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; jj++ ) + { + fixedToFloat_arrL( &st_ivas->hSpar->hMdDec->mixer_mat_fx[ii][jj][0], + &st_ivas->hSpar->hMdDec->mixer_mat[ii][jj][0], + Q31, + st_ivas->hSpar->hMdDec->mix_mat_dim_2 ); + } } } + for ( int ii = 0; ii < CPE_CHANNELS; ii++ ) + { + fixedToFloat_arrL( &hCPE->output_mem_fx[ii][0], &hCPE->output_mem[ii][0], hCPE->hStereoDft->q_dft, NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ) ); + } } - for (int ii = 0; ii < CPE_CHANNELS; ii++) - { - fixedToFloat_arrL(&hCPE->output_mem_fx[ii][0], &hCPE->output_mem[ii][0], hCPE->hStereoDft->q_dft, NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS )); - } - //hCPE->lt_es_em = fixedToFloat(hCPE->lt_es_em_fx, Q15); - } #endif } @@ -5198,15 +3834,7 @@ ivas_error ivas_jbm_dec_tc( for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) { #ifdef IVAS_FLOAT_FIXED - for ( i = 0; i < output_frame; i++ ) - { - p_output_fx[n][i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); - } 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_fx[n][i] / ( 1 << 11 ); - } #else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); #endif // IVAS_FLOAT_FIXED @@ -5215,28 +3843,7 @@ 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 ) - { - for ( int lp2 = 0; lp2 < output_frame; lp2++ ) - { - p_output_fx[lp][lp2] = (Word32) ( p_output[lp][lp2] * ( 1u << 11 ) ); - } - } - } ivas_mono_stereo_downmix_mcmasa_fx( st_ivas, p_output_fx, output_frame ); - - for ( int lp = 0; lp < 12; lp++ ) - { - if ( p_output[lp] != NULL ) - { - for ( int lp2 = 0; lp2 < output_frame; lp2++ ) - { - p_output[lp][lp2] = (float) p_output_fx[lp][lp2] / ( 1u << 11 ); - } - } - } #else ivas_mono_stereo_downmix_mcmasa( st_ivas, p_output, output_frame ); #endif @@ -5244,6 +3851,12 @@ ivas_error ivas_jbm_dec_tc( } } + FOR( Word16 ch = 0; ch < 12; ch++ ) + IF( p_output[ch] ) + { + fixedToFloat_arrL( p_output_fx[ch], p_output[ch], Q11, L_FRAME48k ); + } + /*----------------------------------------------------------------* * Write IVAS transport channels *----------------------------------------------------------------*/ @@ -5266,11 +3879,6 @@ ivas_error ivas_jbm_dec_tc( { 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 ); } - - for ( int lp = 0; lp < n_ch_cldfb_tmp; lp++ ) - { - floatToFixed_arrL( p_output[lp], p_output_fx[lp], 11, 960 ); - } // cldfb_state for ( int ch = 0; ch < n_ch_cldfb_tmp; ch++ ) @@ -5322,11 +3930,19 @@ ivas_error ivas_jbm_dec_tc( } /*------------------------flt 2 fix----------------------*/ - + for ( int lp = 0; lp < n_ch_cldfb_tmp; lp++ ) + { + floatToFixed_arrL( p_output[lp], p_output_fx[lp], 11, 960 ); + } ivas_jbm_dec_copy_tc_no_tsm_fx( st_ivas, p_output_fx, output_frame ); /*------------------------fix 2 flt----------------------*/ // cldfb_state + for ( int lp = 0; lp < n_ch_cldfb_tmp; lp++ ) + { + fixedToFloat_arrL( p_output_fx[lp], p_output[lp], 11, 960 ); + } + for ( int ch = 0; ch < n_ch_cldfb_tmp; ch++ ) { Word16 cldfb_size = st_ivas->cldfbAnaDec[ch]->cldfb_size; @@ -5372,11 +3988,6 @@ ivas_error ivas_jbm_dec_tc( } } - for ( int lp = 0; lp < n_ch_cldfb_tmp; lp++ ) - { - fixedToFloat_arrL( p_output_fx[lp], p_output[lp], 11, 960 ); - } - if ( st_ivas->hParamIsmDec != NULL ) { st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain = me2f_16( st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_fx, st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_e ); @@ -5482,7 +4093,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( { #ifdef IVAS_FLOAT_FIXED ivas_dirac_dec_set_md_map_fx( st_ivas, n_render_timeslots ); -#if 1/*Float to fix */ +#if 1 /*Float to fix */ PARAM_ISM_DEC_HANDLE hParamIsmDec; hParamIsmDec = st_ivas->hParamIsmDec; FOR( i = 0; i < 11; i++ ) @@ -5495,7 +4106,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( } } } - //st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx = float_to_fix16( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_flt, 15 ); + // st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx = float_to_fix16( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_flt, 15 ); SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; hSpatParamRendCom = st_ivas->hSpatParamRendCom; Word16 nBins = hSpatParamRendCom->num_freq_bands; @@ -5549,9 +4160,9 @@ void ivas_jbm_dec_feed_tc_to_renderer( { #ifdef IVAS_FLOAT_FIXED - ivas_ism_dec_digest_tc_fx(st_ivas); + ivas_ism_dec_digest_tc_fx( st_ivas ); #else - ivas_ism_dec_digest_tc(st_ivas); + ivas_ism_dec_digest_tc( st_ivas ); #endif } } @@ -5563,154 +4174,155 @@ void ivas_jbm_dec_feed_tc_to_renderer( 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++) + 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(j = 0; j < num_in_ch; j++) - { - FOR(b = 0; b < num_bands_out; b++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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( 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( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { - FOR(j = 0; j < nchan_transport; j++) - { - FOR(b = 0; b < num_bands_out; b++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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( 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( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { - FOR(j = nchan_transport; j < num_out_ch; j++) - { - FOR(b = 0; b < num_bands_out; b++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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])); + 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++) + 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(j = 0; j < num_in_ch; j++) - { - FOR(b = 0; b < num_bands_out; b++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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( 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++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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( 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++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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); + 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 ( i = 0; i < ivas_sba_get_nchan_metadata(st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate) + ch_sba_idx; i++) + 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 ) ) ) { - 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))); + 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 ( 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)) + 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); + 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; + 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++) + 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); + 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))) + 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 */ + 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))) + 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( 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); + Word32 max_cngNoiseLevel = 0; + Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; + FOR( 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_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); + floatToFixed_arrL( st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN ); - for ( i = 0; i < FFTLEN; i++) - { - st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx[i] = float_to_fix(st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt[i], 15); - } + for ( 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); + 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) @@ -5772,7 +4384,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( { 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->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); @@ -5790,7 +4402,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( #ifdef IVAS_FLOAT_FIXED ivas_ism_dec_digest_tc_fx( st_ivas ); #else - ivas_ism_dec_digest_tc(st_ivas); + ivas_ism_dec_digest_tc( st_ivas ); #endif /* delay the objects here for all renderers where it is needed */ @@ -5815,222 +4427,223 @@ 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) + 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++) + 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(j = 0; j < num_in_ch; j++) - { - FOR(b = 0; b < num_bands_out; b++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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( 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( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { - FOR(j = 0; j < nchan_transport; j++) - { - FOR(b = 0; b < num_bands_out; b++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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( 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( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { - FOR(j = nchan_transport; j < num_out_ch; j++) - { - FOR(b = 0; b < num_bands_out; b++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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])); + 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++) + 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(j = 0; j < num_in_ch; j++) - { - FOR(b = 0; b < num_bands_out; b++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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( 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++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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( 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++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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); + 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++) + 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 ) ) ) { - 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))); + 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 ( 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)) + 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; + 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); - } + 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))) + 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 */ + 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))) + 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); + Word32 max_cngNoiseLevel = 0; + Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; + FOR( 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_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); + 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); - } + for ( 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); + 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) + 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( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { - FOR(j = 0; j < num_in_ch; j++) - { - FOR(b = 0; b < num_bands_out; b++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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); + 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++) + 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 ) ) ) { - 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))); + 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 ( 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)) + 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; + 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); - } + 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))) + 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); + + 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 @@ -6043,222 +4656,223 @@ void ivas_jbm_dec_feed_tc_to_renderer( 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; + 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) + 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++) + 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(j = 0; j < num_in_ch; j++) - { - FOR(b = 0; b < num_bands_out; b++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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( 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( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { - FOR(j = 0; j < nchan_transport; j++) - { - FOR(b = 0; b < num_bands_out; b++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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( 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( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { - FOR(j = nchan_transport; j < num_out_ch; j++) - { - FOR(b = 0; b < num_bands_out; b++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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])); + 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++) + 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(j = 0; j < num_in_ch; j++) - { - FOR(b = 0; b < num_bands_out; b++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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( 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++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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( 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++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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); + 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++) + 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 ) ) ) { - 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))); + 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 ( 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)) + 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; + 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); - } + 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))) + 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 */ + 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))) + 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); + Word32 max_cngNoiseLevel = 0; + Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; + FOR( 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_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); + 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); - } + for ( 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); + 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) + 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( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { - FOR(j = 0; j < num_in_ch; j++) - { - FOR(b = 0; b < num_bands_out; b++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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); + 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++) + 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 ) ) ) { - 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))); + 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 ( 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)) + 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; + 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); - } + 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))) + 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); + + 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 @@ -6274,222 +4888,223 @@ 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) - { - 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++) + 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(j = 0; j < num_in_ch; j++) - { - FOR(b = 0; b < num_bands_out; b++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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( 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( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { - FOR(j = 0; j < nchan_transport; j++) - { - FOR(b = 0; b < num_bands_out; b++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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( 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( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { - FOR(j = nchan_transport; j < num_out_ch; j++) - { - FOR(b = 0; b < num_bands_out; b++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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])); + 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++) + 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(j = 0; j < num_in_ch; j++) - { - FOR(b = 0; b < num_bands_out; b++) + 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++ ) { - 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( 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 ); + } + } } - } } - FOR(i = 0; i < num_out_ch; i++) + + + 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 ) ) ) { - FOR(j = 0; j < nchan_transport; j++) - { - FOR(b = 0; b < num_bands_out; b++) + Word16 ch_sba_idx = 0; + IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { - 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); + IF( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) + { + ch_sba_idx = st_ivas->nchan_ism; + move16(); + } } - } - } - 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++) + st_ivas->hTcBuffer->q_tc_fx = 14; + for ( i = 0; i < ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) + ch_sba_idx; i++ ) { - 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); + 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; - 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)) + while ( nSamplesLeftForTD ) { - IF(EQ_16(st_ivas->ism_mode, ISM_SBA_MODE_DISC)) - { - ch_sba_idx = st_ivas->nchan_ism; move16(); - } + Word16 nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); + size += nSamplesToDecorr; + nSamplesLeftForTD -= nSamplesToDecorr; } - 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++) + size = s_max( size, default_frame ); + for ( int ch_idx = 0; ch_idx < BINAURAL_CHANNELS + 2; ch_idx++ ) { - 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))); + floatToFixed_arrL( st_ivas->hTcBuffer->tc[ch_idx], st_ivas->hTcBuffer->tc_fx[ch_idx], st_ivas->hTcBuffer->q_tc_fx, size ); } - } - } - - 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))) + 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 */ + 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))) + 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); + Word32 max_cngNoiseLevel = 0; + Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; + FOR( 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_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); + 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); - } + for ( 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); + 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) + 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( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { - FOR(j = 0; j < num_in_ch; j++) - { - FOR(b = 0; b < num_bands_out; b++) + FOR( i = 0; i < num_out_ch; i++ ) { - 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); + 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( hSpar->hMdDec->td_decorr_flag && !( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) { - 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))); + 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 ( 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)) + 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; + 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); - } + 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))) + 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); + + 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 @@ -6498,9 +5113,9 @@ void ivas_jbm_dec_feed_tc_to_renderer( if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { #ifdef IVAS_FLOAT_FIXED - ivas_ism_dec_digest_tc_fx(st_ivas); + ivas_ism_dec_digest_tc_fx( st_ivas ); #else - ivas_ism_dec_digest_tc(st_ivas); + ivas_ism_dec_digest_tc( st_ivas ); #endif } } @@ -6522,223 +5137,224 @@ 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; - 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++) + 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 ) { - FOR(i = 0; i < num_out_ch; i++) - { - FOR(j = nchan_transport; j < num_out_ch; j++) + 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(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])); - } + 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] ) ); + } + } + } } - } - } - 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( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { - 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++ ) + { + 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 = 0; i < num_out_ch; i++) - { - FOR(j = 0; j < nchan_transport; j++) + FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { - 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++ ) + { + 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] ) ); + } + } + } } - } - FOR(i = 0; i < num_out_ch; i++) - { - FOR(j = nchan_transport; j < num_out_ch; j++) + 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(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); - } + 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)) + 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 ) ) ) { - ch_sba_idx = st_ivas->nchan_ism; move16(); + 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 ( 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 ) ) ); + } } - } - 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) + if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->hDiracDecBin->useTdDecorr ) ) { - Word16 nSamplesToDecorr = min(nSamplesLeftForTD, default_frame); - size += nSamplesToDecorr; - nSamplesLeftForTD -= nSamplesToDecorr; + 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 ); + } } - size = s_max(size, default_frame); - for (int ch_idx = 0; ch_idx < BINAURAL_CHANNELS + 2; ch_idx++) + 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 ) ) ) { - floatToFixed_arrL(st_ivas->hTcBuffer->tc[ch_idx], st_ivas->hTcBuffer->tc_fx[ch_idx], st_ivas->hTcBuffer->q_tc_fx, size); + nchan_transport = 1; /* Only one channel transported */ } - } - 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++) + 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 ) ) ) { - max_cngNoiseLevel = L_max(L_abs((Word32)st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[i]), max_cngNoiseLevel); - } - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = norm_l(max_cngNoiseLevel); + Word32 max_cngNoiseLevel = 0; + Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; + FOR( 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_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); + 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); + for ( 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); + 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++) + if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { - FOR(i = 0; i < num_out_ch; i++) - { - FOR(j = 0; j < num_in_ch; j++) + FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { - 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); - } + 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)) + 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 ) ) ) { - ch_sba_idx = st_ivas->nchan_ism; move16(); + 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 ( 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 ) ) ); + } } - } - 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++) + if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->hDiracDecBin->useTdDecorr ) ) { - fixedToFloat_arrL(st_ivas->hTcBuffer->tc_fx[ch_idx], st_ivas->hTcBuffer->tc[ch_idx], st_ivas->hTcBuffer->q_tc_fx, size); + 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); - } + + 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 ); @@ -6871,15 +5487,17 @@ ivas_error ivas_jbm_dec_render( slots_to_render = s_min( sub( st_ivas->hTcBuffer->num_slots, st_ivas->hTcBuffer->slots_rendered ), tmp ); slots_rendered = add( st_ivas->hTcBuffer->slots_rendered, slots_to_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); - floatToFixed_arrL(p_output[ind], p_output_fx[ind], Q11, s_max(*nSamplesRendered, nSamplesAskedLocal)); + 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 ); + floatToFixed_arrL( p_output[ind], p_output_fx[ind], Q11, s_max( *nSamplesRendered, nSamplesAskedLocal ) ); } ivas_jbm_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx ); - 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)); + 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 ) ); } #else ivas_jbm_dec_tc_buffer_playout( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output ); @@ -6999,7 +5617,7 @@ ivas_error ivas_jbm_dec_render( } /*-------------------------------------flt 2 fix----------------------------------------------------------*/ - ivas_param_ism_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext,p_output_fx_tmp ); + ivas_param_ism_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx_tmp ); /*-----------------------------------------fix 2 flt--------------------------------------------*/ for ( ch = 0; ch < st_ivas->nchan_ism; ch++ ) @@ -7126,8 +5744,8 @@ ivas_error ivas_jbm_dec_render( { FOR( j = 0; j < 16; j++ ) { - st_ivas->hIsmRendererData->gains_fx[i][j] = L_shr( st_ivas->hIsmRendererData->gains_fx[i][j], 1 ); // Q30 -> Q29 - st_ivas->hIsmRendererData->prev_gains_fx[i][j] = L_shr( st_ivas->hIsmRendererData->prev_gains_fx[i][j], 1 ); // Q30 -> Q29 + st_ivas->hIsmRendererData->gains_fx[i][j] = L_shr( st_ivas->hIsmRendererData->gains_fx[i][j], 1 ); // Q30 -> Q29 + st_ivas->hIsmRendererData->prev_gains_fx[i][j] = L_shr( st_ivas->hIsmRendererData->prev_gains_fx[i][j], 1 ); // Q30 -> Q29 } } Word16 Q_buffer_in = 31; @@ -7146,12 +5764,12 @@ ivas_error ivas_jbm_dec_render( fixedToFloat_arrL( p_output_fx[j], p_output[j], Q_buffer_in + 29 - 31, *nSamplesRendered ); } - FOR(i = 0; i < 15; i++) + FOR( i = 0; i < 15; i++ ) { - FOR(j = 0; j < 16; j++) + FOR( j = 0; j < 16; j++ ) { - st_ivas->hIsmRendererData->gains_fx[i][j] = L_shl(st_ivas->hIsmRendererData->gains_fx[i][j], 1); // Q29 -> Q30 - st_ivas->hIsmRendererData->prev_gains_fx[i][j] = L_shl(st_ivas->hIsmRendererData->prev_gains_fx[i][j], 1); // Q29 -> Q30 + st_ivas->hIsmRendererData->gains_fx[i][j] = L_shl( st_ivas->hIsmRendererData->gains_fx[i][j], 1 ); // Q29 -> Q30 + st_ivas->hIsmRendererData->prev_gains_fx[i][j] = L_shl( st_ivas->hIsmRendererData->prev_gains_fx[i][j], 1 ); // Q29 -> Q30 } } #else @@ -7163,28 +5781,28 @@ ivas_error ivas_jbm_dec_render( if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { #ifdef IVAS_FLOAT_FIXED - for ( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++) + for ( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) { - for ( j = 0; j < L_FRAME48k; j++) + for ( j = 0; j < L_FRAME48k; j++ ) { - p_output_fx[i][j] = floatToFixed(p_output[i][j], Q11); + p_output_fx[i][j] = floatToFixed( p_output[i][j], Q11 ); } } - for (int ch = 0; ch < st_ivas->hTcBuffer->nchan_transport_internal; ch++) + for ( int ch = 0; ch < st_ivas->hTcBuffer->nchan_transport_internal; ch++ ) { - floatToFixed_arrL(st_ivas->hTcBuffer->tc[ch], st_ivas->hTcBuffer->tc_fx[ch], Q11, L_FRAME48k); + floatToFixed_arrL( st_ivas->hTcBuffer->tc[ch], st_ivas->hTcBuffer->tc_fx[ch], Q11, L_FRAME48k ); } - IF ( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, output_q_factor, *nSamplesRendered ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, output_q_factor, *nSamplesRendered ) ) != IVAS_ERR_OK ) { return error; } // Fixed to float - for ( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++) + for ( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) { - for ( j = 0; j < L_FRAME48k; j++) + for ( j = 0; j < L_FRAME48k; j++ ) { - p_output[i][j] = fixedToFloat(p_output_fx[i][j], Q11); + p_output[i][j] = fixedToFloat( p_output_fx[i][j], Q11 ); } } #else @@ -7332,12 +5950,12 @@ ivas_error ivas_jbm_dec_render( { 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); + st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx[i] = float_to_fix( st_ivas->cldfbSynDec[out_ch]->cldfb_state[i], Q11 ); } } } #endif // - if ( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx,960) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx, 960 ) ) != IVAS_ERR_OK ) { return error; } @@ -7494,7 +6112,7 @@ ivas_error ivas_jbm_dec_render( { 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 ); + st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx[i] = float_to_fix( st_ivas->cldfbSynDec[out_ch]->cldfb_state[i], Q11 ); } } } @@ -7502,17 +6120,17 @@ ivas_error ivas_jbm_dec_render( #if 1 /* NOTE: remove float to fix conversion */ Word16 n_tc; - if (st_ivas->ivas_format == MASA_ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT) + if ( st_ivas->ivas_format == MASA_ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) n_tc = st_ivas->nchan_ism; else n_tc = st_ivas->hTcBuffer->nchan_transport_internal; - for (int ch = 0; ch < n_tc; ch++) + for ( int ch = 0; ch < n_tc; ch++ ) { - floatToFixed_arrL(st_ivas->hTcBuffer->tc[ch], st_ivas->hTcBuffer->tc_fx[ch], Q11, L_FRAME48k); + floatToFixed_arrL( st_ivas->hTcBuffer->tc[ch], st_ivas->hTcBuffer->tc_fx[ch], Q11, L_FRAME48k ); } #endif - IF ( ( error = ivas_osba_dirac_td_binaural_jbm_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx, output_q_factor, 960 ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_osba_dirac_td_binaural_jbm_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx, output_q_factor, 960 ) ) != IVAS_ERR_OK ) { return error; } @@ -7529,7 +6147,7 @@ ivas_error ivas_jbm_dec_render( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] ) / ( 1LL << ( Q11 ) ) ); } } - FOR(Word16 m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) + FOR( Word16 m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) { FOR( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) { @@ -7565,11 +6183,11 @@ ivas_error ivas_jbm_dec_render( #endif #if 1 /*TODO: remove fixed to float conversions */ - for ( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++) + for ( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) { - for ( j = 0; j < L_FRAME48k; j++) + for ( j = 0; j < L_FRAME48k; j++ ) { - p_output[i][j] = fixedToFloat(p_output_fx[i][j], Q11); + p_output[i][j] = fixedToFloat( p_output_fx[i][j], Q11 ); } } #endif @@ -7723,12 +6341,12 @@ ivas_error ivas_jbm_dec_render( { 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 ); + st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx[i] = float_to_fix( st_ivas->cldfbSynDec[out_ch]->cldfb_state[i], Q11 ); } } } #endif // - if ( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, &p_output_fx[st_ivas->nchan_ism], 960) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, &p_output_fx[st_ivas->nchan_ism], 960 ) ) != IVAS_ERR_OK ) { return error; } @@ -7741,7 +6359,7 @@ ivas_error ivas_jbm_dec_render( { 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 ) ) ); + 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++ ) @@ -7859,12 +6477,12 @@ ivas_error ivas_jbm_dec_render( { 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 ); + st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx[i] = float_to_fix( st_ivas->cldfbSynDec[out_ch]->cldfb_state[i], Q11 ); } } } #endif // - if ( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx,960) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx, 960 ) ) != IVAS_ERR_OK ) { return error; } @@ -7961,7 +6579,7 @@ ivas_error ivas_jbm_dec_render( } } } - for (Word16 m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) + for ( Word16 m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) { for ( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) { @@ -7995,12 +6613,12 @@ ivas_error ivas_jbm_dec_render( { 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); + st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx[i] = float_to_fix( st_ivas->cldfbSynDec[out_ch]->cldfb_state[i], Q11 ); } } } #endif // - if ( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx , 960) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx, 960 ) ) != IVAS_ERR_OK ) { return error; } @@ -8016,7 +6634,7 @@ ivas_error ivas_jbm_dec_render( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] ) / ( 1LL << ( Q11 ) ) ); /*Rounding off*/ } } - FOR(Word16 m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) + FOR( Word16 m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) { FOR( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) { @@ -8029,7 +6647,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 ) ) ) ) + 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( i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) @@ -8101,12 +6719,12 @@ ivas_error ivas_jbm_dec_render( } exp -= gd_bits; *st_ivas->hCrendWrapper->p_io_qfactor = exp; - for (i = 0; i < nchan_in; i++) + for ( i = 0; i < nchan_in; i++ ) { - for (j = 0; j < *nSamplesRendered; j++) - { - p_output_fx[i][j] = (Word32)float_to_fixed(p_output[i][j], *st_ivas->hCrendWrapper->p_io_qfactor); - } + for ( j = 0; j < *nSamplesRendered; j++ ) + { + p_output_fx[i][j] = (Word32) float_to_fixed( p_output[i][j], *st_ivas->hCrendWrapper->p_io_qfactor ); + } } if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : p_tc_fx, p_output_fx, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) @@ -8115,14 +6733,14 @@ ivas_error ivas_jbm_dec_render( { return error; } - ivas_binaural_add_LFE_fix(st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx); + ivas_binaural_add_LFE_fix( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); - for (i = 0; i < nchan_in; i++) + for ( i = 0; i < nchan_in; i++ ) { - for (j = 0; j < *nSamplesRendered; j++) - { - p_output[i][j] = fixed_to_float(p_output_fx[i][j], *st_ivas->hCrendWrapper->p_io_qfactor); - } + for ( j = 0; j < *nSamplesRendered; j++ ) + { + p_output[i][j] = fixed_to_float( p_output_fx[i][j], *st_ivas->hCrendWrapper->p_io_qfactor ); + } } #else @@ -8134,9 +6752,8 @@ ivas_error ivas_jbm_dec_render( return error; } - ivas_binaural_add_LFE(st_ivas, *nSamplesRendered, p_tc, p_output); + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); #endif - } else if ( st_ivas->renderer_type == RENDERER_MC ) { @@ -8172,29 +6789,29 @@ ivas_error ivas_jbm_dec_render( { #ifdef IVAS_FLOAT_FIXED #if 1 /* TODO: remove float to fix conversions: */ - for ( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++) + for ( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) { - for ( 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); + p_output_fx[i][j] = floatToFixed( p_output[i][j], output_q_factor ); } } - for (int ch = 0; ch < st_ivas->hTcBuffer->nchan_transport_internal; ch++) + for ( int ch = 0; ch < st_ivas->hTcBuffer->nchan_transport_internal; ch++ ) { - floatToFixed_arrL(st_ivas->hTcBuffer->tc[ch], st_ivas->hTcBuffer->tc_fx[ch], Q11, L_FRAME48k); + floatToFixed_arrL( st_ivas->hTcBuffer->tc[ch], st_ivas->hTcBuffer->tc_fx[ch], Q11, L_FRAME48k ); } #endif - IF ( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, output_q_factor, *nSamplesRendered ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, output_q_factor, *nSamplesRendered ) ) != IVAS_ERR_OK ) { return error; } #if 1 /* TODO: remove Fixed to float */ - for ( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++) + for ( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) { - for ( j = 0; j < L_FRAME48k; j++) + for ( j = 0; j < L_FRAME48k; j++ ) { - p_output[i][j] = fixedToFloat(p_output_fx[i][j], Q11); + p_output[i][j] = fixedToFloat( p_output_fx[i][j], Q11 ); } } #endif @@ -8207,26 +6824,25 @@ ivas_error ivas_jbm_dec_render( #ifdef IVAS_FLOAT_FIXED Word16 q = Q16; - q = q - find_guarded_bits_fx(*nSamplesRendered); - FOR(i = 0; i < st_ivas->nchan_transport; ++i) + q = q - find_guarded_bits_fx( *nSamplesRendered ); + FOR( i = 0; i < st_ivas->nchan_transport; ++i ) { - //p_tc and pout point to same location - floatToFixed_arrL(p_tc[i], p_tc_fx[i], q, *nSamplesRendered); - floatToFixed_arrL(p_output[i], p_output_fx[i], q, *nSamplesRendered); + // p_tc and pout point to same location + floatToFixed_arrL( p_tc[i], p_tc_fx[i], q, *nSamplesRendered ); + floatToFixed_arrL( p_output[i], p_output_fx[i], q, *nSamplesRendered ); } - ivas_binaural_add_LFE_fix(st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx); + ivas_binaural_add_LFE_fix( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); - FOR(i = 0; i < st_ivas->nchan_transport; ++i) + FOR( i = 0; i < st_ivas->nchan_transport; ++i ) { - //p_tc and pout point to same location - fixedToFloat_arrL(p_tc_fx[i], p_tc[i], q, *nSamplesRendered); - fixedToFloat_arrL(p_output_fx[i], p_output[i], q, *nSamplesRendered); + // p_tc and pout point to same location + fixedToFloat_arrL( p_tc_fx[i], p_tc[i], q, *nSamplesRendered ); + fixedToFloat_arrL( p_output_fx[i], p_output[i], q, *nSamplesRendered ); } #else - ivas_binaural_add_LFE(st_ivas, *nSamplesRendered, p_tc, p_output); + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); #endif - } } else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) @@ -8240,20 +6856,20 @@ ivas_error ivas_jbm_dec_render( { #ifdef IVAS_FLOAT_FIXED Word16 q = Q16; - q = q - find_guarded_bits_fx(*nSamplesRendered); - FOR(i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, MC_PARAMUPMIX_MAX_INPUT_CHANS); ++i) + q = q - find_guarded_bits_fx( *nSamplesRendered ); + FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, MC_PARAMUPMIX_MAX_INPUT_CHANS ); ++i ) { - floatToFixed_arrL(p_output[i], p_output_fx[i], q, *nSamplesRendered); + floatToFixed_arrL( p_output[i], p_output_fx[i], q, *nSamplesRendered ); } - ivas_binaural_add_LFE_fix( st_ivas, *nSamplesRendered, p_output_fx, p_output_fx); + ivas_binaural_add_LFE_fix( st_ivas, *nSamplesRendered, p_output_fx, p_output_fx ); - FOR(i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, MC_PARAMUPMIX_MAX_INPUT_CHANS); ++i) + 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); + fixedToFloat_arrL( p_output_fx[i], p_output[i], q, *nSamplesRendered ); } #else - ivas_binaural_add_LFE(st_ivas, *nSamplesRendered, p_output, p_output); + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output ); #endif } } @@ -8295,20 +6911,20 @@ ivas_error ivas_jbm_dec_render( #ifdef IVAS_FLOAT_FIXED Word16 q = Q16; - q = q - find_guarded_bits_fx(*nSamplesRendered); - FOR(i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, MC_PARAMUPMIX_MAX_INPUT_CHANS); ++i) + q = q - find_guarded_bits_fx( *nSamplesRendered ); + FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, MC_PARAMUPMIX_MAX_INPUT_CHANS ); ++i ) { - floatToFixed_arrL(p_output[i], p_output_fx[i], q, *nSamplesRendered); + floatToFixed_arrL( p_output[i], p_output_fx[i], q, *nSamplesRendered ); } - ivas_binaural_add_LFE_fix(st_ivas, *nSamplesRendered, p_output_fx, p_output_fx); + ivas_binaural_add_LFE_fix( st_ivas, *nSamplesRendered, p_output_fx, p_output_fx ); - FOR(i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, MC_PARAMUPMIX_MAX_INPUT_CHANS); ++i) + 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); + fixedToFloat_arrL( p_output_fx[i], p_output[i], q, *nSamplesRendered ); } #else - ivas_binaural_add_LFE(st_ivas, *nSamplesRendered, p_output, p_output); + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output ); #endif } } @@ -8401,9 +7017,9 @@ ivas_error ivas_jbm_dec_render( p_output_fx[ch_idx] = tmp_buffer_fx[ch_idx]; } - for ( ch_idx = 0; ch_idx < nchan_out; ch_idx++ ) + for ( ch_idx = 0; ch_idx < nchan_out; ch_idx++ ) { - exp = s_min( exp , Q_factor_arrL( p_output[ch_idx], *nSamplesRendered ) ); + exp = s_min( exp, Q_factor_arrL( p_output[ch_idx], *nSamplesRendered ) ); } exp -= 2; for ( ch_idx = 0; ch_idx < nchan_out; ch_idx++ ) @@ -8423,19 +7039,21 @@ ivas_error ivas_jbm_dec_render( } #else ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out, *nSamplesRendered, st_ivas->BER_detect ); - #endif +#endif #endif } } #ifdef IVAS_FLOAT_FIXED Word16 q_p_output = Q11; - FOR( i = 0; i < nchan_out; i++) { - floatToFixed_arrL(p_output[i], p_output_fx[i], q_p_output, *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( i = 0; i < nchan_out; i++) { + FOR( i = 0; i < nchan_out; i++ ) + { } #else @@ -8459,14 +7077,14 @@ ivas_error ivas_jbm_dec_render( #ifdef IVAS_FLOAT_FIXED ivas_error ivas_jbm_dec_flush_renderer_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const Word16 tc_granularity_new, /* i : new renderer granularity */ + const Word16 tc_granularity_new, /* i : new renderer granularity */ const RENDERER_TYPE renderer_type_old, /* i : old renderer type */ const AUDIO_CONFIG intern_config_old, /* i : old internal config */ const IVAS_OUTPUT_SETUP_HANDLE hIntSetupOld, /* i : old internal output setup */ const MC_MODE mc_mode_old, /* i : old MC mode */ const ISM_MODE ism_mode_old, /* i : old ISM mode */ - UWord16 *nSamplesRendered, /* o : number of samples flushed */ - Word16 *data /* o : output synthesis signal */ + UWord16 *nSamplesRendered, /* o : number of samples flushed */ + Word16 *data /* o : output synthesis signal */ ) { ivas_error error; @@ -8478,7 +7096,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( Word32 *p_output_fx[MAX_CICP_CHANNELS]; Word16 nchan_in, nchan_out; const Word16 output_q_factor = Q11; - IF ( !st_ivas->hDecoderConfig->Opt_tsm ) + IF( !st_ivas->hDecoderConfig->Opt_tsm ) { return IVAS_ERR_OK; } @@ -8488,23 +7106,23 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( hTcBuffer = st_ivas->hTcBuffer; /* get number of possible slots in new granularity */ - n_samples_still_available = sub(hTcBuffer->n_samples_buffered , hTcBuffer->n_samples_rendered); + n_samples_still_available = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_rendered ); n_slots_still_available = n_samples_still_available / tc_granularity_new; - *nSamplesRendered = imult1616(n_slots_still_available , tc_granularity_new); + *nSamplesRendered = imult1616( n_slots_still_available, tc_granularity_new ); n_samples_to_render = *nSamplesRendered; move16(); - n_samples_still_available = sub(n_samples_still_available,n_samples_to_render); + n_samples_still_available = sub( n_samples_still_available, n_samples_to_render ); assert( n_samples_still_available < tc_granularity_new ); /* update combined orientation access index */ ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); - IF ( n_slots_still_available ) + IF( n_slots_still_available ) { Word16 ch_idx; /* render what is still there with zero padding */ - FOR ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) + FOR( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) { /* move it at the beginning of the TC buffer with zero padding */ Copy32( hTcBuffer->tc_fx[ch_idx] + hTcBuffer->n_samples_rendered, hTcBuffer->tc_fx[ch_idx], n_samples_to_render ); @@ -8517,7 +7135,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( hTcBuffer->subframes_rendered = 0; hTcBuffer->slots_rendered = 0; hTcBuffer->subframe_nbslots[0] = 1; - hTcBuffer->n_samples_buffered = add(hTcBuffer->n_samples_granularity , n_samples_still_available); + hTcBuffer->n_samples_buffered = add( hTcBuffer->n_samples_granularity, n_samples_still_available ); hTcBuffer->n_samples_available = 0; hTcBuffer->n_samples_flushed = n_samples_to_render; #ifdef CR_FIX_JBM_FLUSH_OFFSET @@ -8525,26 +7143,33 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( #else hTcBuffer->n_samples_rendered = hTcBuffer->n_samples_granularity; #endif - move16();move16();move16();move16();move16();move16();move16();move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); - FOR ( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ ) + FOR( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ ) { p_output_fx[ch_idx] = output_fx[ch_idx]; } - IF ( EQ_16(st_ivas->ivas_format , ISM_FORMAT) ) + IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) { - IF ( EQ_16(ism_mode_old , ISM_MODE_DISC) ) + IF( EQ_16( ism_mode_old, ISM_MODE_DISC ) ) { /* Binaural rendering */ - IF ( EQ_16(renderer_type_old , RENDERER_BINAURAL_OBJECTS_TD) ) + IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_OBJECTS_TD ) ) { - IF ( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, output_q_factor, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, output_q_factor, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) { return error; } } - ELSE IF ( EQ_16(renderer_type_old , RENDERER_BINAURAL_MIXER_CONV_ROOM) ) + ELSE IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { /*TODO :To be tested : no stream entering---------------------------------------*/ /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ @@ -8555,8 +7180,8 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; *st_ivas->hCrendWrapper->p_io_qfactor = 11; move16(); - IF ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, - NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, + NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -8567,36 +7192,35 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong ISM_MODE in VoIP renderer flushing!" ); } } - ELSE IF ( EQ_16(st_ivas->ivas_format , MC_FORMAT) ) + ELSE IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) ) { - IF ( EQ_16(mc_mode_old , MC_MODE_MCT) ) + IF( EQ_16( mc_mode_old, MC_MODE_MCT ) ) { - IF ( EQ_16(renderer_type_old , RENDERER_BINAURAL_MIXER_CONV) || EQ_16(renderer_type_old , RENDERER_BINAURAL_MIXER_CONV_ROOM) ) + IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV ) || EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { /*TODO :To be tested : no stream entering*/ st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; - IF ( ( error = getAudioConfigNumChannels( intern_config_old, &nchan_in ) ) != IVAS_ERR_OK ) + IF( ( error = getAudioConfigNumChannels( intern_config_old, &nchan_in ) ) != IVAS_ERR_OK ) { return error; } - IF ( ( error = getAudioConfigNumChannels( st_ivas->hOutSetup.output_config, &nchan_out ) ) != IVAS_ERR_OK ) + IF( ( error = getAudioConfigNumChannels( st_ivas->hOutSetup.output_config, &nchan_out ) ) != IVAS_ERR_OK ) { return error; } *st_ivas->hCrendWrapper->p_io_qfactor = 11; move16(); - IF ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } ivas_binaural_add_LFE_fix( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc_fx, p_output_fx ); - } - ELSE IF ( EQ_16(st_ivas->renderer_type , RENDERER_BINAURAL_OBJECTS_TD) ) + ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) { - IF ( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, output_q_factor, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, output_q_factor, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) { return error; } @@ -8608,38 +7232,38 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong MC_MODE in VoIP renderer flushing!" ); } } - ELSE IF ( EQ_16(st_ivas->ivas_format , MASA_ISM_FORMAT) || EQ_16(st_ivas->ivas_format , MASA_FORMAT) ) + ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_FORMAT ) ) { - IF ( EQ_16(ism_mode_old , ISM_MASA_MODE_DISC) ) + IF( EQ_16( ism_mode_old, ISM_MASA_MODE_DISC ) ) { Word32 *tc_local_fx[MAX_TRANSPORT_CHANNELS]; move16(); - FOR ( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ ) + FOR( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ ) { tc_local_fx[ch_idx] = &st_ivas->hTcBuffer->tc_fx[ch_idx + 2][hTcBuffer->n_samples_rendered]; - Copy32( st_ivas->hMasaIsmData->delayBuffer_fx[ch_idx], tc_local_fx[ch_idx], st_ivas->hMasaIsmData->delayBuffer_size );/*Q11*/ + Copy32( st_ivas->hMasaIsmData->delayBuffer_fx[ch_idx], tc_local_fx[ch_idx], st_ivas->hMasaIsmData->delayBuffer_size ); /*Q11*/ } - IF ( GT_16(st_ivas->nchan_ism , 0) ) + IF( GT_16( st_ivas->nchan_ism, 0 ) ) { - IF ( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, output_q_factor, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, output_q_factor, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) { return error; } } ELSE { - FOR ( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) + FOR( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) { set_zero_fx( p_output_fx[ch_idx], (Word16) ( *nSamplesRendered ) ); } - st_ivas->hTcBuffer->slots_rendered = add(st_ivas->hTcBuffer->slots_rendered,1); - st_ivas->hTcBuffer->subframes_rendered = add(st_ivas->hTcBuffer->subframes_rendered,1); + st_ivas->hTcBuffer->slots_rendered = add( st_ivas->hTcBuffer->slots_rendered, 1 ); + st_ivas->hTcBuffer->subframes_rendered = add( st_ivas->hTcBuffer->subframes_rendered, 1 ); } } } - ELSE IF ( EQ_16(st_ivas->ivas_format , SBA_ISM_FORMAT) ) + ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { Word32 *tc_local_fx[MAX_TRANSPORT_CHANNELS]; Word16 last_spar_md_idx; @@ -8651,7 +7275,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( move16(); move16(); /* copy from ISM delay buffer to the correct place in tcs */ - FOR ( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ ) + FOR( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ ) { tc_local_fx[ch_idx] = &st_ivas->hTcBuffer->tc_fx[ch_idx + 2][hTcBuffer->n_samples_rendered]; Copy32( st_ivas->hSbaIsmData->delayBuffer_fx[ch_idx], tc_local_fx[ch_idx], st_ivas->hSbaIsmData->delayBuffer_size ); @@ -8668,14 +7292,23 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( st_ivas->hSpatParamRendCom->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME; st_ivas->hSpatParamRendCom->slots_rendered = 0; st_ivas->hSpatParamRendCom->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME; - move16();move16();move16();move16();move16();move16();move16();move16();move16();move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); /* also adapt md maps, just use the last index */ set16_fx( st_ivas->hSpar->render_to_md_map, last_spar_md_idx, n_slots_still_available ); set16_fx( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available ); /* render the last subframe */ - IF ( ( error = ivas_osba_dirac_td_binaural_jbm_fx( st_ivas, (UWord16) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output_fx, output_q_factor, L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES) ) != IVAS_ERR_OK ) + IF( ( error = ivas_osba_dirac_td_binaural_jbm_fx( st_ivas, (UWord16) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output_fx, output_q_factor, L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) { return error; } @@ -8696,11 +7329,11 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( move16(); /* Only write out the valid data*/ { - IF ( NE_16(st_ivas->ivas_format , MONO_FORMAT) ) + IF( NE_16( st_ivas->ivas_format, MONO_FORMAT ) ) { #ifndef DISABLE_LIMITER - Word16 ch_idx,exp=11; - FOR ( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ ) + Word16 ch_idx, exp = 11; + FOR( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ ) { p_output_fx[ch_idx] = output_fx[ch_idx]; } @@ -8709,7 +7342,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( } } - ivas_syn_output_fx( p_output_fx,Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out,data); + ivas_syn_output_fx( p_output_fx, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, data ); return IVAS_ERR_OK; } #else @@ -8943,7 +7576,7 @@ ivas_error ivas_jbm_dec_flush_renderer( for ( j = 0; j < hTcBuffer->n_samples_granularity; j++ ) { - hTcBuffer->tc_fx[i][j] = (Word32) float_to_fixed( hTcBuffer->tc[i][j], *st_ivas->hCrendWrapper->p_io_qfactor ); + hTcBuffer->tc_fx[i][j] = (Word32) float_to_fixed( hTcBuffer->tc[i][j], *st_ivas->hCrendWrapper->p_io_qfactor ); } } if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, @@ -8952,15 +7585,15 @@ ivas_error ivas_jbm_dec_flush_renderer( return error; } - ivas_binaural_add_LFE_fix(st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc_fx, p_output_fx); + ivas_binaural_add_LFE_fix( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc_fx, p_output_fx ); - for (i = 0; i < nchan_in; i++) + for ( i = 0; i < nchan_in; i++ ) { - for (j = 0; j < *nSamplesRendered; j++) - { - // p_output[i][j] = fixed_to_float(p_output_fx[i][j], *st_ivas->hCrendWrapper->p_io_qfactor); - st_ivas->hTcBuffer->tc[i][j] = fixed_to_float(st_ivas->hTcBuffer->tc_fx[i][j], *st_ivas->hCrendWrapper->p_io_qfactor); - } + for ( j = 0; j < *nSamplesRendered; j++ ) + { + // p_output[i][j] = fixed_to_float(p_output_fx[i][j], *st_ivas->hCrendWrapper->p_io_qfactor); + st_ivas->hTcBuffer->tc[i][j] = fixed_to_float( st_ivas->hTcBuffer->tc_fx[i][j], *st_ivas->hCrendWrapper->p_io_qfactor ); + } } #else if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, @@ -8968,10 +7601,8 @@ ivas_error ivas_jbm_dec_flush_renderer( { return error; } - ivas_binaural_add_LFE(st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc, p_output); + ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc, p_output ); #endif - - } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { @@ -8982,26 +7613,26 @@ ivas_error ivas_jbm_dec_flush_renderer( #ifdef IVAS_FLOAT_FIXED Word16 q = Q16; - q = q - find_guarded_bits_fx(*nSamplesRendered); - FOR(i = 0; i < st_ivas->nchan_transport; ++i) + q = q - find_guarded_bits_fx( *nSamplesRendered ); + FOR( i = 0; i < st_ivas->nchan_transport; ++i ) { - //p_tc and pout point to same location - floatToFixed_arrL(st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->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); + // p_tc and pout point to same location + floatToFixed_arrL( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->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 ); } - ivas_binaural_add_LFE_fix(st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc_fx, p_output_fx); + ivas_binaural_add_LFE_fix( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc_fx, p_output_fx ); - FOR(i = 0; i < st_ivas->nchan_transport; ++i) + FOR( i = 0; i < st_ivas->nchan_transport; ++i ) { - //p_tc and pout point to same location only need to do for 2 channels can be cleaned up later - fixedToFloat_arrL(st_ivas->hTcBuffer->tc_fx[i], st_ivas->hTcBuffer->tc[i], q, *nSamplesRendered); - fixedToFloat_arrL(p_output_fx[i], p_output[i], q, *nSamplesRendered); - free(p_output_fx[i]); + // p_tc and pout point to same location only need to do for 2 channels can be cleaned up later + fixedToFloat_arrL( st_ivas->hTcBuffer->tc_fx[i], st_ivas->hTcBuffer->tc[i], q, *nSamplesRendered ); + fixedToFloat_arrL( p_output_fx[i], p_output[i], q, *nSamplesRendered ); + free( p_output_fx[i] ); } #else - ivas_binaural_add_LFE(st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc, p_output); + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc, p_output ); #endif } } @@ -9114,7 +7745,7 @@ ivas_error ivas_jbm_dec_flush_renderer( { for ( j = 0; j < *nSamplesRendered; j++ ) { - p_output_fx[ch_idx][j] = (Word32) ( p_output[ch_idx][j] *(1<< exp) ) ; + p_output_fx[ch_idx][j] = (Word32) ( p_output[ch_idx][j] * ( 1 << exp ) ); } } ivas_limiter_dec_fx( st_ivas->hLimiter, p_output_fx, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, exp ); @@ -10697,21 +9328,21 @@ static void ivas_jbm_dec_tc_buffer_playout_fx( slot_size = st_ivas->hTcBuffer->n_samples_granularity; /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ - tmp = BASOP_Util_Divide1616_Scale(nSamplesAsked, slot_size, &e); - tmp = shr(tmp, sub(15, e)); - slots_to_render = s_min( sub( st_ivas->hTcBuffer->num_slots, st_ivas->hTcBuffer->slots_rendered), tmp ); - st_ivas->hTcBuffer->slots_rendered = add(st_ivas->hTcBuffer->slots_rendered, slots_to_render); - *nSamplesRendered = (UWord16) L_mult0(slots_to_render, slot_size); + tmp = BASOP_Util_Divide1616_Scale( nSamplesAsked, slot_size, &e ); + tmp = shr( tmp, sub( 15, e ) ); + slots_to_render = s_min( sub( st_ivas->hTcBuffer->num_slots, st_ivas->hTcBuffer->slots_rendered ), tmp ); + st_ivas->hTcBuffer->slots_rendered = add( st_ivas->hTcBuffer->slots_rendered, slots_to_render ); + *nSamplesRendered = (UWord16) L_mult0( slots_to_render, slot_size ); first_sf = st_ivas->hTcBuffer->subframes_rendered; last_sf = first_sf; - WHILE ( GT_16(slots_to_render, 0) ) + WHILE( GT_16( slots_to_render, 0 ) ) { - slots_to_render = sub(slots_to_render, st_ivas->hTcBuffer->subframe_nbslots[last_sf]); - last_sf = add(last_sf, 1); + slots_to_render = sub( slots_to_render, st_ivas->hTcBuffer->subframe_nbslots[last_sf] ); + last_sf = add( last_sf, 1 ); } - FOR ( ch_idx = 0; ch_idx < st_ivas->hTcBuffer->nchan_transport_jbm; ch_idx++ ) + FOR( ch_idx = 0; ch_idx < st_ivas->hTcBuffer->nchan_transport_jbm; ch_idx++ ) { mvl2l( st_ivas->hTcBuffer->tc_fx[ch_idx] + st_ivas->hTcBuffer->n_samples_rendered, output_fx[ch_idx], *nSamplesRendered ); } @@ -11371,7 +10002,7 @@ static void ivas_jbm_dec_copy_masa_meta_to_buffer( static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ #ifdef IVAS_FLOAT_FIXED - const Word16 nCldfbTs /* i : number of CLDFB time slots */ + const Word16 nCldfbTs /* i : number of CLDFB time slots */ ) { Word16 sf_to_slot_map[MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME]; diff --git a/lib_dec/ivas_lfe_dec.c b/lib_dec/ivas_lfe_dec.c index a38dee76fd9c284a84967c3eeaa2fed636a661c9..b6b88e0e4f45f9e67872f321bbbe4deacda3f498 100644 --- a/lib_dec/ivas_lfe_dec.c +++ b/lib_dec/ivas_lfe_dec.c @@ -32,6 +32,7 @@ #include #include "options.h" +#ifndef IVAS_FLOAT_FIXED #include "prot.h" #include "ivas_prot.h" #include "ivas_rom_com.h" @@ -470,3 +471,4 @@ void ivas_lfe_dec_close( return; } +#endif diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index bd4a7399711c2ba9e57c2f459d9d551f415fd1cb..4efe4a477c006a53f320429a325f9d80f1882418 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -71,34 +71,43 @@ static void ivas_lfe_dec_delay_adjust_fx( diff = sub( hLFE->lfe_prior_buf_len, hLFE->pWindow_state->fade_len ); loop_counter = LT_16( diff, 0 ) ? 0 : diff; + move16(); fade_len = hLFE->pWindow_state->fade_len; + move16(); dct_len = hLFE->pWindow_state->dct_len; + move16(); zero_pad_len = hLFE->pWindow_state->zero_pad_len; + move16(); FOR( i = 0; i < loop_counter; i++ ) { tmp_buffer[i] = hLFE->prior_out_buffer_fx[i]; + move32(); } FOR( i = 0; i < fade_len; i++ ) { tmp_buffer[i + loop_counter] = L_add( hLFE->prior_out_buffer_fx[i + loop_counter], pInbuf[i] ); + move32(); } loop_counter = add( loop_counter, fade_len ); FOR( i = 0; i < add( fade_len, shl( zero_pad_len, 1 ) ); i++ ) { tmp_buffer[i + loop_counter] = pInbuf[i + fade_len]; + move32(); } FOR( i = 0; i < hLFE->lfe_prior_buf_len; i++ ) { hLFE->prior_out_buffer_fx[i] = tmp_buffer[i + dct_len]; + move32(); } FOR( i = 0; i < dct_len; i++ ) { output_lfe_ch[i] = tmp_buffer[i]; + move32(); } return; @@ -121,22 +130,27 @@ static void ivas_lfe_dec_windowing_fx( const Word32 *pWindow_coeffs; fade_len = hLFE->pWindow_state->fade_len; + move16(); zero_pad_len = hLFE->pWindow_state->zero_pad_len; + move16(); pWindow_coeffs = hLFE->pWindow_state->pWindow_coeffs_fx; FOR( i = 0; i < fade_len; i++ ) { pInbuf[i] = Mpy_32_32( pInbuf[add( zero_pad_len, i )], pWindow_coeffs[i] ); + move32(); } FOR( i = 0; i < shl( zero_pad_len, 1 ); i++ ) { pInbuf[add( fade_len, i )] = pInbuf[add( add( zero_pad_len, fade_len ), i )]; + move32(); } FOR( i = 0; i < fade_len; i++ ) { pInbuf[add( add( shl( zero_pad_len, 1 ), fade_len ), i )] = Mpy_32_32( pInbuf[add( add( i_mult( zero_pad_len, 3 ), fade_len ), i )], pWindow_coeffs[sub( sub( fade_len, i ), 1 )] ); + move32(); } return; @@ -168,17 +182,22 @@ static Word16 ivas_lfe_dec_dequant_fx( Word16 values[IVAS_LFE_MAX_NUM_DCT_COEFFS]; Word16 num_dct_coeffs, num_groups; - all_zeros_dct = get_next_indice( st0, 1 ); + all_zeros_dct = get_next_indice_fx( st0, 1 ); lfe_bits = st0->next_bit_pos; + move16(); shift_bits = IVAS_LFE_SHIFT_BITS; + move16(); min_shift_bits = 0; + move16(); shift = 0; + move16(); IF( EQ_16( all_zeros_dct, 1 ) ) { FOR( i = 0; i < IVAS_LFE_MAX_NUM_DCT_COEFFS; i++ ) { pOut_buf[i] = 0; + move32(); } } ELSE @@ -188,28 +207,34 @@ static Word16 ivas_lfe_dec_dequant_fx( Word16 iii, extra_bits_read; extra_bits_read = 0; - quant_strategy = get_next_indice( st0, 1 ); + move16(); + quant_strategy = get_next_indice_fx( st0, 1 ); *num_dct_pass_bins = ivas_lfe_num_dct_pass_bins_tbl[quant_strategy]; + move16(); num_dct_coeffs = shl( *num_dct_pass_bins, 1 ); num_groups = shr( num_dct_coeffs, 2 ); min_shift_bits = ivas_lfe_min_shift_tbl[quant_strategy]; - shift = add( get_next_indice( st0, shift_bits ), shl( min_shift_bits, 2 ) ); + move16(); + shift = add( get_next_indice_fx( st0, shift_bits ), shl( min_shift_bits, 2 ) ); FOR( i = 0; i < num_dct_coeffs; i++ ) { - sign_bits[i] = get_next_indice( st0, 1 ); + sign_bits[i] = get_next_indice_fx( st0, 1 ); + move16(); } - coding_strategy = get_next_indice( st0, 1 ); + coding_strategy = get_next_indice_fx( st0, 1 ); IF( coding_strategy ) { FOR( iii = 0; iii < num_groups; iii++ ) { base2_bit_size = hLFE->lfe_dec_indices_coeffs_tbl[quant_strategy][iii]; + move16(); FOR( i = 0; i < 4; i++ ) { - abs_values[iii * 4 + i] = get_next_indice( st0, base2_bit_size ); + abs_values[iii * 4 + i] = get_next_indice_fx( st0, base2_bit_size ); + move16(); } } } @@ -218,11 +243,13 @@ static Word16 ivas_lfe_dec_dequant_fx( FOR( iii = 0; iii < num_groups; iii++ ) { extra_bits_read = 0; + move16(); ivas_ari_start_decoding_14bits_ext_1_lfe( st0, &as, &extra_bits_read ); FOR( i = 0; i < 4; i++ ) { abs_values[iii * 4 + i] = ivas_ari_decode_14bits_bit_ext_1_lfe( st0, &as, hLFE->cum_freq_models[quant_strategy][iii], &extra_bits_read ); + move16(); } ivas_ari_done_decoding_14bits_ext_1_lfe( st0, extra_bits_read ); } @@ -231,21 +258,28 @@ static Word16 ivas_lfe_dec_dequant_fx( FOR( i = 0; i < num_dct_coeffs; i++ ) { values[i] = shl( abs_values[i], 9 ); // Q9 + move16(); IF( GT_16( sign_bits[i], 0 ) ) { values[i] = shl( sub( negate( abs_values[i] ), 1 ), 9 ); // Q9 + move16(); } } two_pow_shift_by_4 = tbl_two_pow_shift_by_4[shift]; + move32(); FOR( i = 0; i < num_groups; i++ ) { - pOut_buf[2 * i] = Mpy_32_16_1( two_pow_shift_by_4, values[4 * i] ); // Q30 + Q9 >> 15 = Q24 + pOut_buf[2 * i] = Mpy_32_16_1( two_pow_shift_by_4, values[4 * i] ); // Q30 + Q9 >> 15 = Q24 + move32(); pOut_buf[2 * i + 1] = Mpy_32_16_1( two_pow_shift_by_4, values[4 * i + 1] ); // Q30 + Q9 >> 15 = Q24 + move32(); - pOut_buf[2 * i + *num_dct_pass_bins] = Mpy_32_16_1( two_pow_shift_by_4, values[4 * i + 2] ); // Q30 + Q9 >> 15 = Q24 + pOut_buf[2 * i + *num_dct_pass_bins] = Mpy_32_16_1( two_pow_shift_by_4, values[4 * i + 2] ); // Q30 + Q9 >> 15 = Q24 + move32(); pOut_buf[2 * i + *num_dct_pass_bins + 1] = Mpy_32_16_1( two_pow_shift_by_4, values[4 * i + 3] ); // Q30 + Q9 >> 15 = Q24 + move32(); } } @@ -276,7 +310,9 @@ void ivas_lfe_dec_fx( Word32 lfe_dct[IVAS_LFE_MAX_NUM_DCT_COEFFS]; dct_len = hLFE->pWindow_state->dct_len; + move16(); num_dct_pass_bins = IVAS_LFE_MAX_NUM_DCT_PASS_BINS; + move16(); IF( EQ_16( bfi, 0 ) ) { @@ -285,6 +321,7 @@ void ivas_lfe_dec_fx( set32_fx( t_audio, 0, dct_len ); Copy32( lfe_dct, t_audio, num_dct_pass_bins ); // Q24 q_out = Q24; + move16(); ivas_imdct_fx( t_audio, out, dct_len, &q_out ); // Q9 ivas_lfe_dec_windowing_fx( hLFE, out ); // Q9 ivas_lfe_dec_delay_adjust_fx( hLFE, out, output_lfe_ch ); // Q9 @@ -292,6 +329,7 @@ void ivas_lfe_dec_fx( set32_fx( t_audio, 0, dct_len ); Copy32( &lfe_dct[num_dct_pass_bins], t_audio, num_dct_pass_bins ); // Q24 q_out = Q24; + move16(); ivas_imdct_fx( t_audio, out, dct_len, &q_out ); // Q9 ivas_lfe_dec_windowing_fx( hLFE, out ); // Q9 ivas_lfe_dec_delay_adjust_fx( hLFE, out, output_lfe_ch + dct_len ); // Q9 @@ -299,13 +337,16 @@ void ivas_lfe_dec_fx( Copy32( hLFE->prevsynth_buf_fx + L_FRAME_1k6, hLFE->prevsynth_buf_fx, LFE_PLC_BUFLEN - L_FRAME_1k6 ); j = 0; + move16(); FOR( i = 0; i < L_FRAME_1k6; i++ ) { hLFE->prevsynth_buf_fx[i + LFE_PLC_BUFLEN - L_FRAME_1k6] = output_lfe_ch[j]; + move32(); j = add( j, shr( output_frame, 5 ) ); } hLFE->bfi_count = 0; + move16(); } ELSE { @@ -344,9 +385,11 @@ void ivas_lfe_dec_fx( Copy32( hLFE->prevsynth_buf_fx + L_FRAME_1k6, hLFE->prevsynth_buf_fx, LFE_PLC_BUFLEN - L_FRAME_1k6 ); j = 0; + move16(); FOR( i = 0; i < L_FRAME_1k6; i++ ) { hLFE->prevsynth_buf_fx[i + LFE_PLC_BUFLEN - L_FRAME_1k6] = output_lfe_ch[j]; + move32(); j = add( j, shr( output_frame, 5 ) ); } } @@ -389,9 +432,11 @@ ivas_error ivas_create_lfe_dec_fx( Word32 output_fs_fx; low_pass_delay_dec_out = 0; + move16(); block_offset_s = 0; + move16(); - output_frame = extract_l(Mpy_32_16_1( output_Fs, INV_FRAME_PER_SEC_Q15 )); + output_frame = extract_l( Mpy_32_16_1( output_Fs, INV_FRAME_PER_SEC_Q15 ) ); /*-----------------------------------------------------------------* * Allocate LFE handle @@ -424,20 +469,27 @@ ivas_error ivas_create_lfe_dec_fx( hLFE->cum_freq_models[1][3] = &ivas_str_lfe_freq_models.entropy_coder_model_coarse_sg4; /* delay calculation */ - hLFE->lfe_block_delay_s_fx = ( IVAS_LFE_FADE_S_Q15 ) + ivas_lfe_lpf_delay_Q15[IVAS_FILTER_ORDER_4 - 3]; + hLFE->lfe_block_delay_s_fx = add( IVAS_LFE_FADE_S_Q15, ivas_lfe_lpf_delay_Q15[IVAS_FILTER_ORDER_4 - 3] ); block_offset_s = BLOCK_OFFSET_S_Q15; + move16(); filt_order = 0; + move16(); low_pass_delay_dec_out = 0; + move16(); hLFE->filter_state.order = filt_order; - hLFE->lfe_block_delay_s_fx = hLFE->lfe_block_delay_s_fx + low_pass_delay_dec_out; + move16(); + hLFE->lfe_block_delay_s_fx = add( hLFE->lfe_block_delay_s_fx, low_pass_delay_dec_out ); hLFE->lfe_prior_buf_len = NS2SA_fx2( output_Fs, IVAS_LFE_FADE_NS ); + move16(); hLFE->bfi_count = 0; + move16(); output_fs_fx = NE_32( output_Fs, 48000 ) ? ( NE_32( output_Fs, 32000 ) ? FS_16K_IN_NS_Q31 : FS_32K_IN_NS_Q31 ) : FS_48K_IN_NS_Q31; + move32(); - lfe_addl_delay_s = block_offset_s - hLFE->lfe_block_delay_s_fx; + lfe_addl_delay_s = sub( block_offset_s, hLFE->lfe_block_delay_s_fx ); lfe_addl_delay_s = s_max( 0, lfe_addl_delay_s ); add_delay_sa = (Word16) W_round64_L( W_mult0_32_32( L_shl( binauralization_delay_ns, 1 ), output_fs_fx ) ); hLFE->lfe_addl_delay = add( (Word16) L_shr( ( (Word32) lfe_addl_delay_s * (Word32) output_Fs ), 15 ), add_delay_sa ); @@ -462,6 +514,7 @@ ivas_error ivas_create_lfe_dec_fx( FOR( j = 0; j < IVAS_MAX_NUM_DCT_COEF_GROUPS; j++ ) { hLFE->lfe_dec_indices_coeffs_tbl[i][j] = ivas_lfe_log2_num_ele_in_coder_models_fx[i][j]; + move16(); } } @@ -481,6 +534,7 @@ void ivas_lfe_dec_close_fx( LFE_DEC_HANDLE *hLFE /* i/o: LFE decoder handle */ ) { + test(); IF( hLFE == NULL || *hLFE == NULL ) { return; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index f6728e20a40b4526f518bb4edd8d02112d5150ed..215774f4a94430503230a1105c1c4abcb38e3d81 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1060,7 +1060,7 @@ ivas_error ivas_mct_dec_fx( } IF(hCPE->hCoreCoder[n]->hTcxDec) { - Scale_sig(hCPE->hCoreCoder[n]->hTcxDec->synth_history_fx, NS2SA(hCPE->hCoreCoder[n]->output_Fs, PH_ECU_MEM_NS), negate(hCPE->hCoreCoder[n]->Q_syn)); + //Scale_sig(hCPE->hCoreCoder[n]->hTcxDec->synth_history_fx, NS2SA(hCPE->hCoreCoder[n]->output_Fs, PH_ECU_MEM_NS), negate(hCPE->hCoreCoder[n]->Q_syn)); } IF(hCPE->hCoreCoder[n]->hHQ_core) { @@ -2682,8 +2682,8 @@ static ivas_error ivas_mc_dec_reconfig( { IF( st->ini_frame == 0 ) { - fixedToFloat_arr( st->hTcxLtpDec->tcxltp_mem_in, st->hTcxLtpDec->tcxltp_mem_in_float, 0, TCXLTP_MAX_DELAY ); - fixedToFloat_arr( st->hTcxLtpDec->tcxltp_mem_out, st->hTcxLtpDec->tcxltp_mem_out_float, 0, L_FRAME48k ); + //fixedToFloat_arr( st->hTcxLtpDec->tcxltp_mem_in, st->hTcxLtpDec->tcxltp_mem_in_float, 0, TCXLTP_MAX_DELAY ); + //fixedToFloat_arr( st->hTcxLtpDec->tcxltp_mem_out, st->hTcxLtpDec->tcxltp_mem_out_float, 0, L_FRAME48k ); } } #else @@ -2736,9 +2736,10 @@ static ivas_error ivas_mc_dec_reconfig( return error; } +#ifndef IVAS_FLOAT_FIXED set_zero( st_ivas->hLFE->prevsynth_buf, LFE_PLC_BUFLEN ); set_zero( st_ivas->hLFE->prior_out_buffer, L_FRAME48k ); -#ifdef IVAS_FLOAT_FIXED +#else set32_fx(st_ivas->hLFE->prevsynth_buf_fx, 0, LFE_PLC_BUFLEN); set32_fx(st_ivas->hLFE->prior_out_buffer_fx, 0, L_FRAME48k); #endif // IVAS_FLOAT_FIXED @@ -2934,10 +2935,55 @@ static ivas_error ivas_mc_dec_reconfig( } else if ( st_ivas->hCrendWrapper == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { +#if 1 /*Cleanup changes: float to fixed*/ + RENDER_CONFIG_DATA *hRendCfg = st_ivas->hRenderConfig; + HRTFS_CREND_HANDLE hSetOfHRTF = st_ivas->hSetOfHRTF; + IF( hSetOfHRTF ) + { + hSetOfHRTF->hHRTF_brir_combined->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_brir_combined->latency_s, 31 ); + hSetOfHRTF->hHRTF_hrir_foa->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_hrir_foa->latency_s, 31 ); + hSetOfHRTF->hHRTF_hrir_combined->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_hrir_combined->latency_s, 31 ); + hSetOfHRTF->hHRTF_hrir_hoa3->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_hrir_hoa3->latency_s, 31 ); + hSetOfHRTF->hHRTF_hrir_hoa2->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_hrir_hoa2->latency_s, 31 ); + } + IF( hRendCfg ) + { + hRendCfg->roomAcoustics.acousticPreDelay_fx = floatToFixed( hRendCfg->roomAcoustics.acousticPreDelay, 27 ); + FOR( int i = 0; i < 60; i++ ) + { + hRendCfg->roomAcoustics.pFc_input_fx[i] = (Word32) ( hRendCfg->roomAcoustics.pFc_input[i] * ONE_IN_Q16 ); + hRendCfg->roomAcoustics.pAcoustic_rt60_fx[i] = (Word32) ( ( hRendCfg->roomAcoustics.pAcoustic_rt60[i] ) * ONE_IN_Q26 ); + hRendCfg->roomAcoustics.pAcoustic_dsr_fx[i] = (Word32) ( hRendCfg->roomAcoustics.pAcoustic_dsr[i] * ONE_IN_Q30 ); + } + + hRendCfg->roomAcoustics.inputPreDelay_fx = (Word32) ( hRendCfg->roomAcoustics.inputPreDelay * ONE_IN_Q27 ); + hRendCfg->roomAcoustics.dimensions.x_fx = (Word32) ( hRendCfg->roomAcoustics.dimensions.x * 4194304 ); // Q10.22, min value:1, max :999.0 + hRendCfg->roomAcoustics.dimensions.y_fx = (Word32) ( hRendCfg->roomAcoustics.dimensions.y * 4194304 ); // Q10.22 + hRendCfg->roomAcoustics.dimensions.z_fx = (Word32) ( hRendCfg->roomAcoustics.dimensions.z * 4194304 ); // Q10.22 + + + FOR( int ii = 0; ii < 6; ii++ ) + { + hRendCfg->roomAcoustics.AbsCoeff_fx[ii] = (Word32) ( hRendCfg->roomAcoustics.AbsCoeff[ii] * 1073741824 ); // Q2.30 min :0 max 1 + } + + hRendCfg->roomAcoustics.ListenerOrigin.x_fx = (Word32) ( hRendCfg->roomAcoustics.ListenerOrigin.x * 4194304 ); //( 2147483648 >> 2 ); + hRendCfg->roomAcoustics.ListenerOrigin.y_fx = (Word32) ( hRendCfg->roomAcoustics.ListenerOrigin.y * ( 4194304 ) ); + hRendCfg->roomAcoustics.ListenerOrigin.z_fx = (Word32) ( hRendCfg->roomAcoustics.ListenerOrigin.z * ( 4194304 ) ); + } +#endif // 1 if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } +#if 1 /*Cleanup changes: fixed to float*/ + IF( st_ivas->hCrendWrapper->hHrtfCrend != NULL ) + { + st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe = fixedToFloat( st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe_fx, 14 ); + st_ivas->hCrendWrapper->hHrtfCrend->latency_s = fixedToFloat( st_ivas->hCrendWrapper->hHrtfCrend->latency_s_fx, 31 ); + fixedToFloat_arr( st_ivas->hCrendWrapper->hHrtfCrend->inv_diffuse_weight_fx, st_ivas->hCrendWrapper->hHrtfCrend->inv_diffuse_weight, 15, 16 ); + } +#endif st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; } } diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 9af44380fc77f90e7ae830d7432b6f277fea00c6..01e94f1bb3dcc64fed84b64b8d8a5a77524683da 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -1197,36 +1197,6 @@ void ivas_mdct_core_invQ_fx( * TCX20/10/5 *--------------------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED - // PLC - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - IF( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) - { - IF( bfi && sts[ch]->tonal_mdct_plc_active && NE_16( sts[ch]->element_mode, IVAS_CPE_MDCT ) ) - { - FOR( Word16 i = 0; i < sts[ch]->hTonalMDCTConc->pTCI->numIndexes; i++ ) - { - float pd = sts[ch]->hTonalMDCTConc->pTCI->phaseDiff_float[i]; - IF( pd >= PI2 ) - pd = fmodf( pd, PI2 ) - PI2; - sts[ch]->hTonalMDCTConc->pTCI->phaseDiff[i] = float_to_fix16( pd, Q12 ); - } - FOR( Word16 i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++ ) - { - float pd = sts[ch]->hTonalMDCTConc->pTCI->phase_currentFramePredicted_float[i]; - pd = fmodf( pd, PI2 ); - sts[ch]->hTonalMDCTConc->pTCI->phase_currentFramePredicted[i] = (Word16) ( pd * ( 1u << Q13 ) ); - } - FOR( Word16 i = 0; i < FDNS_NPTS; i++ ) - { - f2me_16( sts[ch]->hTonalMDCTConc->secondLastBlockData.scaleFactors_float[i], &sts[ch]->hTonalMDCTConc->secondLastBlockData.scaleFactors[i], &sts[ch]->hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i] ); - sts[ch]->hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e = s_max( sts[ch]->hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e, sts[ch]->hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i] ); - } - } - } - } -#endif FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = sts[ch]; @@ -1879,7 +1849,7 @@ void ivas_mdct_core_reconstruct_fx( synth_fx = synth_buf_fx + st->hTcxDec->old_synth_len; synthFB_fx = synth_bufFB_fx + st->hTcxDec->old_synth_lenFB; - Copy_Scale_sig( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len, sub(q_syn, st->Q_syn) ); + Copy_Scale_sig( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len, 0 ); Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub(q_syn, st->Q_syn) ); set16_fx( synth_fx, 0, L_FRAME_PLUS + M ); set16_fx( synthFB_fx, 0, L_FRAME_PLUS + M ); @@ -1995,8 +1965,8 @@ void ivas_mdct_core_reconstruct_fx( } /* Update */ - mvs2s( synth_buf_fx + st->L_frame, st->hTcxDec->old_synth, st->hTcxDec->old_synth_len ); - mvs2s( st->hTcxDec->old_synthFB_fx + st->hTcxDec->L_frameTCX - NS2SA( st->output_Fs, PH_ECU_MEM_NS ), st->hTcxDec->synth_history_fx, NS2SA( st->output_Fs, PH_ECU_MEM_NS ) ); + Copy( synth_buf_fx + st->L_frame, st->hTcxDec->old_synth, st->hTcxDec->old_synth_len ); + Copy( st->hTcxDec->old_synthFB_fx + st->hTcxDec->L_frameTCX - NS2SA( st->output_Fs, PH_ECU_MEM_NS ), st->hTcxDec->synth_history_fx, NS2SA( st->output_Fs, PH_ECU_MEM_NS ) ); mvs2s( synth_bufFB_fx + st->hTcxDec->L_frameTCX, st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synth_lenFB ); Scale_sig(st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub(st->Q_syn, q_syn)); IF ( st->hHQ_core != NULL ) @@ -2282,42 +2252,7 @@ void ivas_mdct_core_tns_ns( if ( bfi && st->tonal_mdct_plc_active ) { -#ifdef IVAS_FLOAT_FIXED - // Float to fixed - Word32 x_fx[N_MAX]; - Word16 x_e; - f2me_buf(x[ch][0], x_fx, &x_e, st->hTonalMDCTConc->pTCI->upperIndex[st->hTonalMDCTConc->pTCI->numIndexes - 1]); - FOR(Word16 i = 0; i < st->hTonalMDCTConc->pTCI->numIndexes; i++) - { - float pd = st->hTonalMDCTConc->pTCI->phaseDiff_float[i]; - if (pd >= PI2) - pd = fmodf(pd, PI2) - PI2; - st->hTonalMDCTConc->pTCI->phaseDiff[i] = float_to_fix16(pd, Q12); - } - FOR(Word16 i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++) - { - float pd = st->hTonalMDCTConc->pTCI->phase_currentFramePredicted_float[i]; - pd = fmodf(pd, PI2); - st->hTonalMDCTConc->pTCI->phase_currentFramePredicted[i] = (Word16)(pd * (1u << Q13)); - } - FOR(Word16 i = 0; i < FDNS_NPTS; i++) - { - f2me_16(st->hTonalMDCTConc->secondLastBlockData.scaleFactors_float[i], &st->hTonalMDCTConc->secondLastBlockData.scaleFactors[i], &st->hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i]); - st->hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e = s_max(st->hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e, st->hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i]); - } - TonalMDCTConceal_Apply_ivas_fx( st->hTonalMDCTConc, x_fx, &x_e, st->hTcxCfg->psychParamsCurrent ); - // Fix to float - FOR(Word16 i = 0; i < st->hTonalMDCTConc->pTCI->numIndexes; i++) - { - FOR(Word16 l = st->hTonalMDCTConc->pTCI->lowerIndex[i]; l <= st->hTonalMDCTConc->pTCI->upperIndex[i]; l++) - { - x[ch][0][l] = me2f(x_fx[l], x_e); - } - } - //st->hTonalMDCTConc->nFramesLost_float = fix16_to_float(st->hTonalMDCTConc->nFramesLost, Q1); -#else TonalMDCTConceal_Apply_ivas( st->hTonalMDCTConc, x[ch][0], st->hTcxCfg->psychParamsCurrent ); -#endif } if ( ( bfi || MCT_flag ) && st->hTonalMDCTConc != NULL ) @@ -2348,7 +2283,6 @@ void ivas_mdct_core_tns_ns_fx( Word16 L_frame_global[CPE_CHANNELS], L_frameTCX_glob[CPE_CHANNELS]; /* TCX */ -#ifdef IVAS_FLOAT_FIXED Word32 xn_buf_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; Word16 tcx_offset[CPE_CHANNELS]; Word16 tcx_offsetFB[CPE_CHANNELS]; @@ -2356,7 +2290,6 @@ void ivas_mdct_core_tns_ns_fx( Word16 L_spec[CPE_CHANNELS]; Word32 sns_int_scf_fx[FDNS_NPTS]; Word16 exp; -#endif // IVAS_FLOAT_FIXED /* Initializations */ sts = hCPE->hCoreCoder; @@ -2402,16 +2335,10 @@ void ivas_mdct_core_tns_ns_fx( q_x = sub(31 , x_e[ch][k]); IF ( EQ_16(bfi, 0) ) { - -#ifdef IVAS_FLOAT_FIXED sns_interpolate_scalefactors_fx( sns_int_scf_fx, &Aq_fx[ch][k * M], DEC ); -#else - sns_interpolate_scalefactors( &sns_int_scf[0], &Aq[ch][k * M], DEC ); -#endif // IVAS_FLOAT_FIXED IF ( NE_16(MCT_flag, 0) && st->hTonalMDCTConc != NULL && EQ_16( add( k, 1 ), nSubframes[ch] ) ) { -#ifdef IVAS_FLOAT_FIXED Word16 scf_fx[FDNS_NPTS], scf_e[FDNS_NPTS]; Word16 q_shift; FOR(Word16 ind = 0; ind < st->hTonalMDCTConc->nScaleFactors; ind++) { @@ -2420,18 +2347,13 @@ void ivas_mdct_core_tns_ns_fx( scf_e[ind] = sub(15 , q_shift); } TonalMDCTConceal_SaveFreqSignal_ivas_fx( st->hTonalMDCTConc, x_fx[ch][k], x_e[ch][k], L_frameTCX[ch], L_frame[ch], &scf_fx[0], scf_e, 0, get_igf_startline( st, L_frame[ch], L_frameTCX[ch] ) ); -#else - TonalMDCTConceal_SaveFreqSignal_ivas( st->hTonalMDCTConc, x[ch][k], L_frameTCX[ch], L_frame[ch], &sns_int_scf[0], get_igf_startline_flt( st, L_frame[ch], L_frameTCX[ch] ) ); -#endif } } ELSE { - // st->hTonalMDCTConc->scf_fadeout; IF ( st->hTonalMDCTConc != NULL ) { IF ( EQ_16(MCT_flag, 0) && LT_16(st->hTcxDec->cummulative_damping_tcx, 32440) ) - //if ( !MCT_flag && st->hTcxDec->cummulative_damping_tcx_float != 1.f ) { Word16 *scf_last_m, *scf_last_e; Word32 *scf_bg; @@ -2461,7 +2383,6 @@ void ivas_mdct_core_tns_ns_fx( } } } -#ifdef IVAS_FLOAT_FIXED Word16 norm_x; q_x = sub(q_x,5); Scale_sig32( &x_fx[ch][k][0], L_spec[ch], -5 ); @@ -2470,10 +2391,7 @@ void ivas_mdct_core_tns_ns_fx( Scale_sig32( &x_fx[ch][k][0], L_spec[ch], norm_x ); q_x = add(q_x,norm_x); x_e[ch][k] = sub(31 , q_x); -#else - decoder_tcx_tns( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], &x[ch][k][0], fUseTns[ch][k], &tnsData[ch][k], bfi, k, 1 ); -#endif -#ifdef IVAS_FLOAT_FIXED + Word16 q_sns_int_scf; Word16 q_2; q_sns_int_scf = add(16 - 1 , getScaleFactor32( sns_int_scf_fx, FDNS_NPTS )); @@ -2495,20 +2413,14 @@ void ivas_mdct_core_tns_ns_fx( q_x = add(q_x , 1); } x_e[ch][k] = sub(31 , q_x); -#else - sns_shape_spectrum( x[ch][k], st->hTcxCfg->psychParamsCurrent, &sns_int_scf[0], st->hTcxCfg->psychParamsCurrent->nBins ); -#endif // IVAS_FLOAT_FIXEDs -#ifdef IVAS_FLOAT_FIXED + v_multc_fixed( x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sns_int_scf_fx[FDNS_NPTS - 1], x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, L_spec[ch] - st->hTcxCfg->psychParamsCurrent->nBins ); q_2 = sub(add(q_x , q_sns_int_scf) , 31); Scale_sig32( &x_fx[ch][k][0], st->hTcxCfg->psychParamsCurrent->nBins, q_2 - q_x ); q_x = q_2; x_e[ch][k] = sub(31 , q_x); -#else - v_multc( x[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sns_int_scf[FDNS_NPTS - 1], x[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, L_spec[ch] - st->hTcxCfg->psychParamsCurrent->nBins ); -#endif // IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED + q_x = sub(q_x,5); Scale_sig32( &x_fx[ch][k][0], L_spec[ch], -5 ); decoder_tcx_tns_fx( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], &x_fx[ch][k][0], fUseTns[ch][k], &tnsData[ch][k], bfi, k, 0 ); @@ -2516,14 +2428,10 @@ void ivas_mdct_core_tns_ns_fx( Scale_sig32( &x_fx[ch][k][0], L_spec[ch], norm_x ); q_x = add(q_x,norm_x); x_e[ch][k] = sub(31 , q_x); -#else - decoder_tcx_tns( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], &x[ch][k][0], fUseTns[ch][k], &tnsData[ch][k], bfi, k, 0 ); -#endif // IVAS_FLOAT_FIXED } IF ( NE_16(bfi, 0) && NE_16(st->tonal_mdct_plc_active, 0) ) { -#ifdef IVAS_FLOAT_FIXED Word16 q_x, q_x_old; FOR( Word16 i = 0; i < FDNS_NPTS; i++ ) { @@ -2559,9 +2467,6 @@ void ivas_mdct_core_tns_ns_fx( } } } -#else - TonalMDCTConceal_Apply_ivas( st->hTonalMDCTConc, x[ch][0], st->hTcxCfg->psychParamsCurrent ); -#endif } IF ( ( bfi || MCT_flag ) && st->hTonalMDCTConc != NULL ) diff --git a/lib_dec/ivas_post_proc.c b/lib_dec/ivas_post_proc.c index 0226e232b6e5f8d7a9e8a614eb1890bc1ce7b5e7..4b2d93c35edbf21ad59953c0148a8036b9aff1cf 100644 --- a/lib_dec/ivas_post_proc.c +++ b/lib_dec/ivas_post_proc.c @@ -695,7 +695,9 @@ void stereo_dft_dec_core_switching_fx( return; } #endif -#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) + + +#ifndef IVAS_FLOAT_FIXED void stereo_dft_dec_core_switching( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ float output[], /* i/o: synthesis @internal Fs */ diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index a284b74c45e187707f4af691dc5d2a49c710800a..2ad7994b549aa6e2deecc932e2873acd5367212e 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -895,7 +895,7 @@ ivas_error ivas_sba_dec_reconfigure( return error; } - +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) /*-------------------------------------------------------------------* * ivas_sba_dec_digest_tc() * @@ -1189,7 +1189,7 @@ void ivas_sba_dec_digest_tc( return; } - +#endif #ifdef IVAS_FLOAT_FIXED void ivas_sba_dec_digest_tc_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index 1ddff43a4469822ad1d03b1937458e309d42d2bd..af1f06f2be15098f34c56887f4f01b72b527e0ba 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -849,9 +849,6 @@ void ivas_sba_dirac_stereo_dec( ivas_sba_dirac_stereo_config( hStereoDft->hConfig ); hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, st_ivas->hDecoderConfig->output_Fs, hStereoDft->NFFT, ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !mcmasa ) ); stereo_dft_dec_update( hStereoDft, output_frame, 1 /*st_ivas->sba_dirac_stereo_flag*/ ); -#ifdef IVAS_FLOAT_FIXED - stereo_dft_dec_update_fx( hCPE->hStereoDft, output_frame, 0 ); -#endif if ( st_ivas->nchan_transport > 1 ) { stereo_dft_dec_analyze( hCPE, output[0], DFT, 0, output_frame, output_frame, DFT_STEREO_DEC_ANA_FB, 0, 0 ); @@ -865,122 +862,7 @@ void ivas_sba_dirac_stereo_dec( /* do DFT Stereo core switching (including DFT analysis) here as CPE element was not available in SCE decoder */ mvr2r( hSCE->save_synth, tmp_synth, hSCE->hCoreCoder[0]->L_frame ); -#ifdef IVAS_FLOAT_FIXED - Word16 q = 11, q_DFT[2] = { 3, 3 }; - Word32 DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX]; - Word32 synth_fx[L_FRAME48k]; - Word32 hb_synth_fx[L_FRAME48k]; - Word32 output_fx[960]; - FOR( int i = 0; i < 960; i++ ) - { - output_fx[i] = (Word32)(output[0][i] * ( 1 << q )); - } - IF( hCPE->hCoreCoder[0] != NULL ) - FOR( int i = 0; i < L_FRAME32k; i++ ) - { - hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[i] = (Word32)(hCPE->hCoreCoder[0]->hHQ_core->old_outLB[i] * ( 1 << q )); - } - IF( (hCPE->hCoreCoder[0] != NULL) && (hCPE->hCoreCoder[0]->p_bpf_noise_buf_32 != NULL) ) - FOR( int i = 0; i < L_FRAME16k; i++ ) - { - hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[i] = (Word32)(hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[i] * ( 1 << q )); - } - IF( DFT != NULL ) - FOR( int i = 0; i < CPE_CHANNELS; i++ ) - { - FOR( int j = 0; j < STEREO_DFT_BUF_MAX; j++ ) - { - DFT_fx[i][j] = (Word32)(DFT[i][j] * ( 1 << q_DFT[i] )); - } - } - - FOR( int i = 0; i < STEREO_DFT32MS_OVL_16k; i++ ) - hCPE->input_mem_BPF_fx[0][i] = (Word32)(hCPE->input_mem_BPF[0][i] * ( 1 << q )); - FOR( int i = 0; i < NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ); i++ ) - hCPE->input_mem_fx[0][i] = (Word32)(hCPE->input_mem[0][i] * ( 1 << q )); - FOR( int i = 0; i < STEREO_DFT32MS_OVL_16k; i++ ) - hCPE->input_mem_LB_fx[0][i] = (Word32)(hCPE->input_mem_LB[0][i] * ( 1 << q )); - FOR( int i = 0; i < NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ); i++ ) - hCPE->input_mem_fx[1][i] = (Word32)(hCPE->input_mem[1][i] * ( 1 << q )); - FOR( int i = 0; i < STEREO_DFT32MS_OVL_16k; i++ ) - hCPE->input_mem_LB_fx[1][i] = (Word32)(hCPE->input_mem_LB[1][i] * ( 1 << q )); - IF( hCPE->hStereoDft != NULL ) - FOR( int i = 0; i < NS2SA( 16000, DELAY_BWE_TOTAL_NS ); i++ ) - { - hCPE->hStereoDft->ap_delay_mem_fx[i] = (Word32)(hCPE->hStereoDft->ap_delay_mem[i] * ( 1 << q )); - } - FOR( int i = 0; i < hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC; i++ ) - { - synth_fx[i] = (Word32)(hSCE->save_synth[i] * ( 1 << q )); - hb_synth_fx[i] = (Word32)(hSCE->save_hb_synth[i] * ( 1 << q )); - } - IF( hCPE->hCoreCoder[0] != NULL ) - FOR( int i = 0; i < L_FRAME48k; i++ ) - { - hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[i] = (Word32)(hCPE->hCoreCoder[0]->hHQ_core->old_out[i] * ( 1 << q )); - } - IF( hCPE->hStereoDft != NULL ) - FOR( int i = 0; i < NS2SA( 16000, STEREO_DFT32MS_OVL_NS ); i++ ) - { - hCPE->hStereoDft->buff_LBTCX_mem_fx[i] = (Word32)(hCPE->hStereoDft->buff_LBTCX_mem[i] * ( 1 << q )); - } - stereo_dft_dec_core_switching_fx( hCPE, output_fx /*hSCE->save_output*/, synth_fx, hb_synth_fx, DFT_fx, output_frame, 0, dtx_flag, &q, q_DFT ); - IF( DFT != NULL ) - FOR( int i = 0; i < CPE_CHANNELS; i++ ) - { - FOR( Word16 j = 0; j < STEREO_DFT_BUF_MAX; j++ ) - { - DFT[i][j] = (float) DFT_fx[i][j] / (float) ( 1 << q_DFT[i] ); - } - } - FOR( int i = 0; i < STEREO_DFT32MS_OVL_16k; i++ ) - hCPE->input_mem_BPF[0][i] = (float) hCPE->input_mem_BPF_fx[0][i] / (float) ( 1 << q ); - FOR( int i = 0; i < NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ); i++ ) - hCPE->input_mem[0][i] = (float) hCPE->input_mem_fx[0][i] / (float) ( 1 << q ); - FOR( int i = 0; i < STEREO_DFT32MS_OVL_16k; i++ ) - hCPE->input_mem_LB[0][i] = (float) hCPE->input_mem_LB_fx[0][i] / (float) ( 1 << q ); - FOR( int i = 0; i < NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ); i++ ) - hCPE->input_mem[1][i] = (float) hCPE->input_mem_fx[1][i] / (float) ( 1 << q ); - FOR( int i = 0; i < STEREO_DFT32MS_OVL_16k; i++ ) - hCPE->input_mem_LB[1][i] = (float) hCPE->input_mem_LB_fx[1][i] / (float) ( 1 << q ); - IF( hCPE->hStereoDft != NULL ) - FOR( int i = 0; i < NS2SA( 16000, DELAY_BWE_TOTAL_NS ); i++ ) - { - hCPE->hStereoDft->ap_delay_mem[i] = (float) hCPE->hStereoDft->ap_delay_mem_fx[i] / (float) ( 1 << q ); - } - IF( (hCPE->hCoreCoder[0] != NULL) && (hCPE->hCoreCoder[0]->p_bpf_noise_buf_32 != NULL) ) - FOR( int i = 0; i < L_FRAME16k; i++ ) - { - hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[i] = (float) hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[i] / (float) ( 1 << q ); - } - FOR( int i = 0; i < 960; i++ ) - { - output[0][i] = (float) output_fx[i] / (float) ( 1 << q ); - } - FOR( int i = 0; i < hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC; i++ ) - { - hSCE->save_synth[i] = (float) synth_fx[i] / (float) ( 1 << q ); - hSCE->save_hb_synth[i] = (float) hb_synth_fx[i] / (float) ( 1 << q ); - } - IF( hCPE->hCoreCoder[0] != NULL ) - FOR( int i = 0; i < L_FRAME48k; i++ ) - { - hCPE->hCoreCoder[0]->hHQ_core->old_out[i] = (float) hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[i] / (float) ( 1 << q ); - } - IF( hCPE->hStereoDft != NULL ) - FOR( int i = 0; i < NS2SA( 16000, STEREO_DFT32MS_OVL_NS ); i++ ) - { - hCPE->hStereoDft->buff_LBTCX_mem[i] = (float) hCPE->hStereoDft->buff_LBTCX_mem_fx[i] / (float) ( 1 << q ); - } - IF( hCPE->hCoreCoder[0] != NULL ) - FOR( int i = 0; i < L_FRAME32k; i++ ) - { - hCPE->hCoreCoder[0]->hHQ_core->old_outLB[i] = (float) hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[i] / (float) ( 1 << q ); - } - -#else stereo_dft_dec_core_switching( hCPE, output[0] /*hSCE->save_output*/, hSCE->save_synth, hSCE->save_hb_synth, DFT, output_frame, 0, dtx_flag ); -#endif /* do updates here after skipping this in SCE decoder (needs to be done after core switching) */ updt_dec_common( hSCE->hCoreCoder[0], NORMAL_HQ_CORE, -1, hSCE->save_synth ); @@ -1006,11 +888,8 @@ void ivas_sba_dirac_stereo_dec( { stereo_dft_dec_synthesize( hCPE, DFT, 1, output[1], output_frame ); } -#ifdef IVAS_FLOAT_FIXED - synchro_synthesis_fixed( st_ivas->hDecoderConfig->ivas_total_brate, hCPE, output, output_frame, 1 /*st_ivas->sba_dirac_stereo_flag*/ ); -#else + synchro_synthesis( st_ivas->hDecoderConfig->ivas_total_brate, hCPE, output, output_frame, 1 /*st_ivas->sba_dirac_stereo_flag*/ ); -#endif //Todo use below once input is fixed not done due to complication in pointer //synchro_synthesis_fixed_clean( st_ivas->hDecoderConfig->ivas_total_brate, hCPE, output, output_frame, 1 /*st_ivas->sba_dirac_stereo_flag*/ ); diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index f6a805aaf338a71d973895aeffa88ecb49d01bd3..7a932b2c2b377c909d0c0f65b80df3d92ebe42a3 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -280,7 +280,7 @@ ivas_error ivas_sce_dec_fx( 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, 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, NULL, st_ivas->sba_dirac_stereo_flag ) ) != IVAS_ERR_OK ) { return error; } @@ -288,7 +288,7 @@ ivas_error ivas_sce_dec_fx( FOR( int k = 0; k < L_FRAME48k; k++ ) { //output[0][k] = (Word32) ( output_flt[0][k] * ONE_IN_Q11 ); - outputHB[0][k] = (Word32) ( outputHB_flt[0][k] * ONE_IN_Q11 ); + //outputHB[0][k] = (Word32) ( outputHB_flt[0][k] * ONE_IN_Q11 ); } free( output_flt[0] ); #endif // !IVAS_FLOAT_FIXED_TO_BE_REMOVED @@ -296,10 +296,11 @@ ivas_error ivas_sce_dec_fx( IF( st_ivas->sba_dirac_stereo_flag && ( GT_32( st->core_brate, SID_2k40 ) || EQ_16( st->cng_type, LP_CNG ) ) ) { /* skip addition of ACELP BWE for now, will be done after upmix */ -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED +#ifndef IVAS_FLOAT_FIXED_TO_BE_REMOVED mvr2r( outputHB_flt[0], hSCE->save_hb_synth, output_frame ); #else Copy32( outputHB[0], hSCE->save_hb_synth_fx, output_frame ); + fixedToFloat_arrL(hSCE->save_hb_synth_fx, hSCE->save_hb_synth,Q11,output_frame); #endif // IVAS_FLOAT_FIXED_TO_BE_REMOVED } ELSE IF( !st_ivas->sba_dirac_stereo_flag ) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index a312c195baaec9340fe2f76e421ec797d77cce53..fd45271bf4e7f0b9c4a8e1a19a99d2e5ccd29cb6 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -63,18 +63,21 @@ typedef struct /* basic allpass structure */ typedef struct { +#ifndef IVAS_FLOAT_FIXED float gains[3]; - int16_t delays[3]; +#endif + Word16 delays[3]; +#ifndef IVAS_FLOAT_FIXED float buffer[3][STEREO_DFT_ALLPASS_BUFFERLEN]; - int16_t pos; +#endif + Word16 pos; #ifdef IVAS_FLOAT_FIXED - Word32 gains_fx[3]; - Word32 buffer_fx[3][STEREO_DFT_ALLPASS_BUFFERLEN]; + Word32 gains_fx[3]; /* Q31 */ + Word32 buffer_fx[3][STEREO_DFT_ALLPASS_BUFFERLEN]; /* Q(q_buffer_fx) */ Word16 q_buffer_fx; #endif - } basic_allpass_t; @@ -331,8 +334,8 @@ typedef struct stereo_dft_dec_data_struct /* PLC on residual signal */ float res_mem[STEREO_DFT_RES_BW_MAX]; int16_t time_offs; - float past_dmx_nrg; #ifndef IVAS_FLOAT_FIXED + float past_dmx_nrg; float sg_mean; #endif int16_t sg_mem_corrupt; @@ -346,7 +349,7 @@ typedef struct stereo_dft_dec_data_struct /* PLC on residual signal */ Word32 sg_mean_fx; /* Q31 */ Word32 res_mem_fx[STEREO_DFT_RES_BW_MAX]; - Word32 past_dmx_nrg_fx; + Word32 past_dmx_nrg_fx; /* Q(2 * q_dft) */ Word32 smooth_buf_fx[SBA_DIRAC_STEREO_NUM_BANDS][SBA_DIRAC_NRG_SMOOTH_LONG + 1]; Word16 smooth_fac_fx[NB_DIV][SBA_DIRAC_STEREO_NUM_BANDS]; /* Q15 */ Word16 q_smooth_buf_fx; @@ -374,17 +377,20 @@ typedef struct stereo_dft_dec_data_struct /* DFT Stereo mono output structure */ typedef struct stereo_dft_dmx_out_data_structure { - float targetGain; /* TCA gain norm applied on target (or right) channel in current frame */ +#ifndef IVAS_FLOAT_FIXED + float targetGain; /* TCA gain norm applied on target (or right) channel in current frame */ float prevTargetGain; /* TCA gain norm applied on target (or right) channel in previous frame */ -#ifdef IVAS_FLOAT_FIXED - Word32 targetGain_fx; - Word32 prevTargetGain_fx; +#else + Word32 targetGain_fx; /* Q29 */ + Word32 prevTargetGain_fx; /* Q29 */ #endif + +#ifndef IVAS_FLOAT_FIXED float memOutHB[NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS )]; float memTransitionHB[NS2SA( 48000, STEREO_DFT32MS_OVL_NS )]; -#ifdef IVAS_FLOAT_FIXED - Word32 memOutHB_fx[NS2SA(48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS)]; - Word32 memTransitionHB_fx[NS2SA(48000, STEREO_DFT32MS_OVL_NS)]; +#else + Word32 memOutHB_fx[NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS )]; /* Q11 */ + Word32 memTransitionHB_fx[NS2SA( 48000, STEREO_DFT32MS_OVL_NS )]; /* Q11 */ #endif } STEREO_DFT_DMX_DATA, *STEREO_DFT_DMX_DATA_HANDLE; @@ -406,8 +412,11 @@ typedef struct stereo_dec_cng int16_t first_SID_after_TD; /* first SID after TD-stereo indicator */ int16_t prev_sid_nodata; /* previous frame SID/FRAME_NO_DATA indicator */ int16_t last_tdm_idx; /* last tdm index */ +#ifndef IVAS_FLOAT_FIXED float c_LR_LT; /* left right cross correlation */ - Word32 c_LR_LT_fx; /* left right cross correlation */ +#else + Word32 c_LR_LT_fx; /* left right cross correlation */ /* Q31 */ +#endif int16_t active_frame_counter; /* counter for active frames */ int16_t xfade_frame_counter; /* xfade counter */ int16_t xfade_length; /* number of frames to perform xfade */ @@ -944,11 +953,12 @@ typedef struct ivas_spar_md_dec_state_t /* AGC structure */ typedef struct ivas_agc_dec_chan_state_t { +#ifndef IVAS_FLOAT_FIXED float lastGain; -#ifdef IVAS_FLOAT_FIXED - Word16 lastGain_fx; +#else + Word16 lastGain_fx; /* Q15 */ #endif // IVAS_FLOAT_FIXED - int16_t gainExpVal; + Word16 gainExpVal; } ivas_agc_dec_chan_state_t; @@ -1153,22 +1163,29 @@ typedef struct ivas_lfe_dec_data_structure { ivas_filters_process_state_t filter_state; LFE_WINDOW_HANDLE pWindow_state; - const uint16_t *cum_freq_models[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS]; - int16_t lfe_dec_indices_coeffs_tbl[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS]; + const UWord16 *cum_freq_models[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS]; + Word16 lfe_dec_indices_coeffs_tbl[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS]; +#ifndef IVAS_FLOAT_FIXED float lfe_block_delay_s; - int16_t lfe_prior_buf_len; +#else + Word16 lfe_block_delay_s_fx; /* Q15 */ +#endif + Word16 lfe_prior_buf_len; +#ifndef IVAS_FLOAT_FIXED float prior_out_buffer[L_FRAME48k]; +#else + Word32 prior_out_buffer_fx[L_FRAME48k]; /* Q9 */ +#endif float prevsynth_buf[LFE_PLC_BUFLEN]; +#ifndef IVAS_FLOAT_FIXED float *lfe_delay_buf; -#ifdef IVAS_FLOAT_FIXED - Word16 lfe_block_delay_s_fx; - Word32 prior_out_buffer_fx[L_FRAME48k]; - Word32 prevsynth_buf_fx[LFE_PLC_BUFLEN]; - Word32 *lfe_delay_buf_fx; +#else + Word32 prevsynth_buf_fx[LFE_PLC_BUFLEN]; /* Q9 */ + Word32 *lfe_delay_buf_fx; /* Q9 */ #endif // IVAS_FLOAT_FIXED - int16_t lfe_addl_delay; - int16_t bfi_count; + Word16 lfe_addl_delay; + Word16 bfi_count; } LFE_DEC_DATA, *LFE_DEC_HANDLE; diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index 55874bb333814546b33dffd693b82135ec1d3365..a3a385a737b79c32c0aaa72e34399d0ee0a84976 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -1340,11 +1340,14 @@ static void stereo_dft_generate_comfort_noise_fx( IF( EQ_16( chan, 0 ) && LE_32( st->core_brate, SID_2k40 ) ) { + Word32 max_smoothed_psd = 0; move32(); + (void)maximum_32_fx(&st->hFdCngDec->smoothed_psd_fx[hFdCngCom->startBand], sub(hFdCngCom->stopFFTbin, hFdCngCom->startBand), &max_smoothed_psd); /* update smoothed periodogram used by stereo CNA in SID and NO_DATA frames from cngNoiseLevel_flt */ FOR( i = hFdCngCom->startBand; i < hFdCngCom->stopFFTbin; i++ ) { Word16 l_shift_val = sub(st->hFdCngDec->q_smoothed_psd, hFdCngCom->q_cngNoiseLevel); move16(); + l_shift_val = max_smoothed_psd == 0 ? 0 :l_shift_val; ftmp = hFdCngCom->cngNoiseLevel[i - hFdCngCom->startBand]; move32(); IF( !st->hFdCngDec->first_cna_noise_updated ) @@ -1357,7 +1360,7 @@ static void stereo_dft_generate_comfort_noise_fx( { alpha = (Word16) ( 0x799A ); move16(); - IF( GT_32( st->hFdCngDec->smoothed_psd_fx[i], 0 ) && GT_32( Mpy_32_16_1( ftmp, (Word16) 0x3333 ), st->hFdCngDec->smoothed_psd_fx[i] ) ) + IF( GT_32( st->hFdCngDec->smoothed_psd_fx[i], 0 ) && GT_32( Mpy_32_16_1( ftmp, (Word16) 0x3333 ), L_shr(st->hFdCngDec->smoothed_psd_fx[i], l_shift_val) ) ) { /* prevent abrupt upward update steps */ ftmp = L_add(L_shl(st->hFdCngDec->smoothed_psd_fx[i], 2), L_shr(st->hFdCngDec->smoothed_psd_fx[i], 1)); @@ -1674,12 +1677,15 @@ void stereo_cng_compute_PScorr( return; } + + /*-------------------------------------------------------------------* * Function stereo_cng_compute_LRcorr() * * CNA for TD stereo, compute LR correlation *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static void stereo_cng_compute_LRcorr( CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ float *output[CPE_CHANNELS], /* i : Output signal */ @@ -1723,7 +1729,7 @@ static void stereo_cng_compute_LRcorr( return; } - +#else static void stereo_cng_compute_LRcorr_fx( CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ Word32 *output_fx[CPE_CHANNELS], /* i : Output signal */ @@ -1817,7 +1823,6 @@ static void stereo_cng_compute_LRcorr_fx( c_q = 15 - div_q + ( enrR_q - enrL_q ); // to be delete - hCPE->hStereoCng->c_LR_LT = (float) hCPE->hStereoCng->c_LR_LT_fx / ( ONE_IN_Q31 ); hCPE->hStereoTD->c_LR_LT = (float) hCPE->hStereoTD->c_LR_LT_fx / ( ONE_IN_Q31 ); hCPE->hStereoTD->c_LR_LT_fx = L_add( Mpy_32_32( STEREO_TD_PS_CORR_FILT_FX, hCPE->hStereoTD->c_LR_LT_fx ), @@ -1892,7 +1897,7 @@ static void stereo_cng_compute_LRcorr_fx( return; } - +#endif /*-------------------------------------------------------------------* @@ -1995,13 +2000,14 @@ static void FindEmEs_fx( return; } -#ifndef IVAS_FLOAT_FIXED + /*-------------------------------------------------------------------* * Function stereo_cna_update_params() * * compute LR correlation and update long-term parameters for stereo CNA *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void stereo_cna_update_params( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ float *output[CPE_CHANNELS], /* i : Output signal */ diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index 9f3b0ba788288340c9535c18ca1a457e965a6334..c11f9d2648f6959b1e882b76f19a894649dc7a1c 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -751,9 +751,9 @@ void stereo_dft_dec_reset( #ifdef IVAS_FLOAT_FIXED set_val_Word16( hStereoDft->g_state_fx, 0, STEREO_DFT_BAND_MAX ); - init_basic_allpass( &hStereoDft->ap1, dft_ap_gains[0], dft_ap_gains_fx[0], dft_ap_delays[0] ); - init_basic_allpass( &hStereoDft->ap2, dft_ap_gains[1], dft_ap_gains_fx[1], dft_ap_delays[1] ); - init_basic_allpass( &hStereoDft->ap3, dft_ap_gains[2], dft_ap_gains_fx[2], dft_ap_delays[2] ); + init_basic_allpass_fx( &hStereoDft->ap1, dft_ap_gains_fx[0], dft_ap_delays[0] ); + init_basic_allpass_fx( &hStereoDft->ap2, dft_ap_gains_fx[1], dft_ap_delays[1] ); + init_basic_allpass_fx( &hStereoDft->ap3, dft_ap_gains_fx[2], dft_ap_delays[2] ); #else set_zero( hStereoDft->g_state, STEREO_DFT_BAND_MAX ); init_basic_allpass( &hStereoDft->ap1, dft_ap_gains[0], dft_ap_delays[0] ); @@ -786,10 +786,11 @@ void stereo_dft_dec_reset( /* PLC parameters */ set_zero( hStereoDft->res_mem, STEREO_DFT_RES_BW_MAX ); hStereoDft->time_offs = 0; - hStereoDft->past_dmx_nrg = 0; #ifdef IVAS_FLOAT_FIXED + hStereoDft->past_dmx_nrg_fx = 0; hStereoDft->sg_mean_fx = 0; #else + hStereoDft->past_dmx_nrg = 0; hStereoDft->sg_mean = 0.0f; #endif hStereoDft->sg_mem_corrupt = 0; diff --git a/lib_dec/ivas_stereo_dft_dec_dmx.c b/lib_dec/ivas_stereo_dft_dec_dmx.c index ae5a608014bdc8bab278dcb8cc6c43a1572b265f..49743166dc0ab40e26cf796dd1afacf1d2e2177c 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx.c @@ -55,6 +55,7 @@ * Reset DFT stereo mono output memories *------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void stereo_dft_dmx_out_reset( STEREO_DFT_DMX_DATA_HANDLE hStereoDftDmx /* i/o: DFT stereo DMX decoder */ ) @@ -67,43 +68,46 @@ void stereo_dft_dmx_out_reset( return; } - -#ifdef IVAS_FLOAT_FIXED +#else void stereo_dft_dmx_out_reset_fx( - STEREO_DFT_DMX_DATA_HANDLE hStereoDftDmx /* i/o: DFT stereo DMX decoder */ + STEREO_DFT_DMX_DATA_HANDLE hStereoDftDmx /* i/o: DFT stereo DMX decoder */ ) { -#if 1 /*TODO: Remove float dft_dmx_reset*/ +#if 0 /*TODO: Remove float dft_dmx_reset*/ hStereoDftDmx->targetGain = 1.0f; hStereoDftDmx->prevTargetGain = 1.0f; #endif - hStereoDftDmx->targetGain_fx = ONE_IN_Q29; - hStereoDftDmx->prevTargetGain_fx = ONE_IN_Q29; + hStereoDftDmx->targetGain_fx = ONE_IN_Q29; + move32(); + hStereoDftDmx->prevTargetGain_fx = ONE_IN_Q29; + move32(); -#if 1 /*TODO: Remove float dft_dmx_reset*/ +#if 0 /*TODO: Remove float dft_dmx_reset*/ set_zero(hStereoDftDmx->memOutHB, NS2SA(48000, STEREO_DFT32MS_OVL_NS)); set_zero(hStereoDftDmx->memTransitionHB, NS2SA(48000, STEREO_DFT32MS_OVL_NS)); #endif - set32_fx(hStereoDftDmx->memOutHB_fx, 0, NS2SA(48000, STEREO_DFT32MS_OVL_NS)); - set32_fx(hStereoDftDmx->memTransitionHB_fx, 0, NS2SA(48000, STEREO_DFT32MS_OVL_NS)); + set32_fx( hStereoDftDmx->memOutHB_fx, 0, NS2SA( 48000, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hStereoDftDmx->memTransitionHB_fx, 0, NS2SA( 48000, STEREO_DFT32MS_OVL_NS ) ); - return; + return; } #endif + /*------------------------------------------------------------------------- * stereo_dft_unify_dmx() * * create a uniform dmx in case of residual coding by converting from passive * to active dmx in residual coding region *-------------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED void stereo_dft_unify_dmx_fx( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder stereo handle */ - Decoder_State *st0, /* i/o: decoder state structure */ + STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder stereo handle */ + Decoder_State *st0, /* i/o: decoder state structure */ Word32 DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i/o: DFT buffers */ Word32 *input_mem, /* i/o: mem of buffer DFT analysis */ - const Word16 prev_sid_nodata /* i : Previous SID/No data indicator */ + const Word16 prev_sid_nodata /* i : Previous SID/No data indicator */ ) { Word16 i, k, b, N_div; @@ -111,9 +115,9 @@ void stereo_dft_unify_dmx_fx( Word32 DFT_R[STEREO_DFT32MS_N_MAX]; Word32 *pDFT_DMX; Word32 *pDFT_RES; - Word32 g, tmp; + Word32 tmp; Word32 *pSideGain; - Word16 k_offset; + Word16 k_offset, g; /* Variables for stereo residual PLC */ Word32 DFT_PRED_RES[STEREO_DFT32MS_N_32k]; @@ -127,56 +131,66 @@ void stereo_dft_unify_dmx_fx( Word16 num_plocs; Word32 plocsi[STEREO_DFT_RES_N_PEAKS_MAX]; - output_frame = (Word16)(st0->output_Fs / FRAMES_PER_SEC); - samp_ratio = BASOP_Util_Divide3232_Scale(st0->sr_core, st0->output_Fs, &q_samp_ratio); - samp_ratio = shr(samp_ratio, sub(Q15 - Q12, q_samp_ratio)); + output_frame = (Word16) ( st0->output_Fs / FRAMES_PER_SEC ); + samp_ratio = BASOP_Util_Divide3232_Scale( st0->sr_core, st0->output_Fs, &q_samp_ratio ); + samp_ratio = shr( samp_ratio, sub( Q15 - Q12, q_samp_ratio ) ); - prev_bfi = st0->prev_old_bfi; move32(); + prev_bfi = st0->prev_old_bfi; + move32(); /* Initialization */ - k_offset = 1; move16(); - N_div = STEREO_DFT_NBDIV; move16(); + k_offset = 1; + move16(); + N_div = STEREO_DFT_NBDIV; + move16(); - dmx_nrg = 0; move32(); + dmx_nrg = 0; + move32(); /* make sure number of bands corresponds to output bwidth in case it is lower than parameter bwidth */ - IF ( LT_16(output_frame, inner_frame_tbl[st0->bwidth] )) + IF( LT_16( output_frame, inner_frame_tbl[st0->bwidth] ) ) { hStereoDft->nbands = stereo_dft_band_config_fx( hStereoDft->band_limits, hStereoDft->band_res[k_offset], hStereoDft->NFFT, DEC ); } - IF ( prev_bfi ) + IF( prev_bfi ) { - //dmx_nrg = stereo_dft_dmx_swb_nrg_fx( DFT[0], DFT[0] + STEREO_DFT32MS_N_MAX, s_min( hStereoDft->NFFT, STEREO_DFT32MS_N_32k ), hStereoDft->q_dft, hStereoDft->q_dft ); - dmx_nrg = stereo_dft_dmx_swb_nrg_fx( DFT[0], DFT[0] + STEREO_DFT32MS_N_MAX, s_min( hStereoDft->NFFT, STEREO_DFT32MS_N_32k ), 0, 0); + dmx_nrg = stereo_dft_dmx_swb_nrg_fx( DFT[0], DFT[0] + STEREO_DFT32MS_N_MAX, s_min( hStereoDft->NFFT, STEREO_DFT32MS_N_32k ), 0, 0 ); } /* Analyze nature of current frame */ - test(); test(); test(); test(); test(); test(); test(); test(); - hStereoDft->trans = (Word16)((EQ_16(st0->clas_dec, ONSET) || EQ_16(st0->clas_dec, SIN_ONSET) || EQ_16(st0->clas_dec, UNVOICED_CLAS) || EQ_16(st0->clas_dec, UNVOICED_TRANSITION)) || LE_16(st0->stab_fac_fx, (Word16)0x2000)) || - ((EQ_16(st0->core, TCX_20_CORE) && (EQ_16(st0->hTcxCfg->tcx_last_overlap_mode, MIN_OVERLAP) || EQ_16(st0->hTcxCfg->tcx_last_overlap_mode, HALF_OVERLAP))) || EQ_16(st0->core, TCX_10_CORE)); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + hStereoDft->trans = (Word16) ( ( EQ_16( st0->clas_dec, ONSET ) || EQ_16( st0->clas_dec, SIN_ONSET ) || EQ_16( st0->clas_dec, UNVOICED_CLAS ) || EQ_16( st0->clas_dec, UNVOICED_TRANSITION ) ) || LE_16( st0->stab_fac_fx, (Word16) 0x2000 ) ) || + ( ( EQ_16( st0->core, TCX_20_CORE ) && ( EQ_16( st0->hTcxCfg->tcx_last_overlap_mode, MIN_OVERLAP ) || EQ_16( st0->hTcxCfg->tcx_last_overlap_mode, HALF_OVERLAP ) ) ) || EQ_16( st0->core, TCX_10_CORE ) ); /* Smoothing for the current frame */ stereo_dft_dec_smooth_parameters_fx( hStereoDft, prev_sid_nodata, st0->hFdCngDec->hFdCngCom->active_frame_counter, st0->element_brate ); - FOR ( k = 0; k < N_div; k++ ) + FOR( k = 0; k < N_div; k++ ) { - pDFT_DMX = DFT[0] + i_mult(k, STEREO_DFT32MS_N_MAX); - pDFT_RES = DFT[1] + i_mult(k, STEREO_DFT32MS_N_MAX); + pDFT_DMX = DFT[0] + i_mult( k, STEREO_DFT32MS_N_MAX ); + pDFT_RES = DFT[1] + i_mult( k, STEREO_DFT32MS_N_MAX ); assert( hStereoDft->hConfig->dmx_active ); /*Apply Stereo*/ g = MAX_16; move16(); /* since delay is just 3.125ms, the parameters received are used for the second window */ - pSideGain = hStereoDft->side_gain_fx + i_mult(add(k, k_offset), STEREO_DFT_BAND_MAX); + pSideGain = hStereoDft->side_gain_fx + i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ); /* Stereo residual PLC */ - IF ( GT_16(hStereoDft->res_cod_band_max, 0 )) + IF( GT_16( hStereoDft->res_cod_band_max, 0 ) ) { - IF ( !st0->bfi ) + IF( !st0->bfi ) { - IF ( EQ_16(k, 1 )) + IF( EQ_16( k, 1 ) ) { - Copy32( pDFT_RES, hStereoDft->res_mem_fx, shl(hStereoDft->band_limits[hStereoDft->res_cod_band_max], 1) ); + Copy32( pDFT_RES, hStereoDft->res_mem_fx, shl( hStereoDft->band_limits[hStereoDft->res_cod_band_max], 1 ) ); hStereoDft->q_res_mem = hStereoDft->q_dft; hStereoDft->time_offs = 0; move16(); @@ -186,8 +200,8 @@ void stereo_dft_unify_dmx_fx( { hStereoDft->nbands = hStereoDft->res_cod_band_max; /* Limit nbands since residual PLC only needs the low frequency range of the stereo filling */ move16(); - pPredGain = hStereoDft->res_pred_gain_fx + i_mult(add(k, k_offset), STEREO_DFT_BAND_MAX); - hStereoDft->past_DMX_pos = ( sub(add(hStereoDft->past_DMX_pos, STEREO_DFT_PAST_MAX), 1 )) % STEREO_DFT_PAST_MAX; + pPredGain = hStereoDft->res_pred_gain_fx + i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ); + hStereoDft->past_DMX_pos = ( sub( add( hStereoDft->past_DMX_pos, STEREO_DFT_PAST_MAX ), 1 ) ) % STEREO_DFT_PAST_MAX; stereo_dft_generate_res_pred_fx( hStereoDft, samp_ratio, pDFT_DMX, DFT_PRED_RES, pPredGain, k, DFT[1] + k * STEREO_DFT32MS_N_MAX, &stop, st0->bfi ); stereo_dft_res_ecu_fx( hStereoDft, pDFT_RES, DFT_PRED_RES, k, output_frame, prev_bfi, dmx_nrg, &num_plocs, plocs, plocsi, input_mem ); hStereoDft->q_res_cod_mem_fx = hStereoDft->q_dft; @@ -200,29 +214,29 @@ void stereo_dft_unify_dmx_fx( DFT_R[0] = pDFT_DMX[0]; /* upmix residual part */ - FOR ( b = 0; b < hStereoDft->res_cod_band_max; b++ ) + FOR( b = 0; b < hStereoDft->res_cod_band_max; b++ ) { - g = extract_h(pSideGain[b]); + g = extract_h( pSideGain[b] ); move16(); - FOR ( i = hStereoDft->band_limits[b]; i < hStereoDft->band_limits[b + 1]; i++ ) + FOR( i = hStereoDft->band_limits[b]; i < hStereoDft->band_limits[b + 1]; i++ ) { - tmp = Madd_32_16(pDFT_RES[2 * i], pDFT_DMX[2 * i], g); + tmp = Madd_32_16( pDFT_RES[2 * i], pDFT_DMX[2 * i], g ); - DFT_L[2 * i] = L_add(pDFT_DMX[2 * i], tmp); - DFT_R[2 * i] = L_sub(pDFT_DMX[2 * i], tmp); + DFT_L[2 * i] = L_add( pDFT_DMX[2 * i], tmp ); + DFT_R[2 * i] = L_sub( pDFT_DMX[2 * i], tmp ); - tmp = Madd_32_16(pDFT_RES[2 * i + 1], pDFT_DMX[2 * i + 1], g); + tmp = Madd_32_16( pDFT_RES[2 * i + 1], pDFT_DMX[2 * i + 1], g ); - DFT_L[2 * i + 1] = L_add(pDFT_DMX[2 * i + 1], tmp); - DFT_R[2 * i + 1] = L_sub(pDFT_DMX[2 * i + 1], tmp); + DFT_L[2 * i + 1] = L_add( pDFT_DMX[2 * i + 1], tmp ); + DFT_R[2 * i + 1] = L_sub( pDFT_DMX[2 * i + 1], tmp ); } } /* downmix residual part with active downmix */ - FOR ( b = 0; b < hStereoDft->res_cod_band_max; b++ ) + FOR( b = 0; b < hStereoDft->res_cod_band_max; b++ ) { - Word16 j, max_e; + Word16 j; Word32 sum_nrg_Mid, sum_abs, dot_prod_abs; Word16 wR, wL; Word16 norm_sum_nrg_L, norm_sum_nrg_R, norm_dot_prod_real, norm_dot_prod_imag, guard_bit, min_norm, q_sum_nrg_L, q_sum_nrg_R, q_dot_prod_real; @@ -231,60 +245,63 @@ void stereo_dft_unify_dmx_fx( Word64 sum_nrg_L = 0, sum_nrg_R = 0; Word64 dot_prod_real = 0, dot_prod_img = 0; - FOR ( j = hStereoDft->band_limits[b]; j < hStereoDft->band_limits[b + 1]; j++ ) + FOR( j = hStereoDft->band_limits[b]; j < hStereoDft->band_limits[b + 1]; j++ ) { - sum_nrg_L = W_add(sum_nrg_L, W_add(W_mult_32_32(DFT_L[2 * j], DFT_L[2 * j]), W_mult_32_32(DFT_L[2 * j + 1], DFT_L[2 * j + 1]))); - sum_nrg_R = W_add(sum_nrg_R, W_add(W_mult_32_32(DFT_R[2 * j], DFT_R[2 * j]), W_mult_32_32(DFT_R[2 * j + 1], DFT_R[2 * j + 1]))); - - dot_prod_real = W_add(dot_prod_real, W_add(W_mult_32_32(DFT_L[2 * j], DFT_R[2 * j]), W_mult_32_32(DFT_L[2 * j + 1], DFT_R[2 * j + 1]))); - dot_prod_img = W_add(dot_prod_img, W_sub(W_mult_32_32(DFT_L[2 * j + 1], DFT_R[2 * j]), W_mult_32_32(DFT_L[2 * j], DFT_R[2 * j + 1]))); + sum_nrg_L = W_add( sum_nrg_L, W_add( W_mult_32_32( DFT_L[2 * j], DFT_L[2 * j] ), W_mult_32_32( DFT_L[2 * j + 1], DFT_L[2 * j + 1] ) ) ); + sum_nrg_R = W_add( sum_nrg_R, W_add( W_mult_32_32( DFT_R[2 * j], DFT_R[2 * j] ), W_mult_32_32( DFT_R[2 * j + 1], DFT_R[2 * j + 1] ) ) ); + + dot_prod_real = W_add( dot_prod_real, W_add( W_mult_32_32( DFT_L[2 * j], DFT_R[2 * j] ), W_mult_32_32( DFT_L[2 * j + 1], DFT_R[2 * j + 1] ) ) ); + dot_prod_img = W_add( dot_prod_img, W_sub( W_mult_32_32( DFT_L[2 * j + 1], DFT_R[2 * j] ), W_mult_32_32( DFT_L[2 * j], DFT_R[2 * j + 1] ) ) ); } - norm_sum_nrg_L = W_norm(sum_nrg_L); - norm_sum_nrg_R = W_norm(sum_nrg_R); - norm_dot_prod_real = W_norm(dot_prod_real); - norm_dot_prod_imag = W_norm(dot_prod_img); - - guard_bit = find_guarded_bits_fx(4); - min_norm = s_min(s_min(s_min(norm_sum_nrg_L, norm_sum_nrg_R), norm_dot_prod_real), norm_dot_prod_imag) - guard_bit; - sum_nrg_L_32 = W_extract_h(W_shl(sum_nrg_L, min_norm)); - sum_nrg_R_32 = W_extract_h(W_shl(sum_nrg_R, min_norm)); - dot_prod_real_32 = W_extract_h(W_shl(dot_prod_real, min_norm)); - dot_prod_img_32 = W_extract_h(W_shl(dot_prod_img, min_norm)); - - q_sum_nrg_L = sub(add(shl(hStereoDft->q_dft, 1), min_norm), 31); - q_sum_nrg_R = sub(add(shl(hStereoDft->q_dft, 1), min_norm), 31); - q_dot_prod_real = sub(add(shl(hStereoDft->q_dft, 1), min_norm), 31); - - exp_sum_nrg_l = sub(31, q_sum_nrg_L); - exp_sum_nrg_R = sub(31, q_sum_nrg_R); - exp_dot_prod_abs = sub(31, sub(shl(q_dot_prod_real, 1), 31)); - exp_sum_nrg_Mid = sub(31, q_sum_nrg_L); - - sum_nrg_Mid = L_max(0, L_add(L_add(sum_nrg_L_32, sum_nrg_R_32), L_shl(dot_prod_real_32, 1))); - - Word32 tmp_nrg_L = Sqrt32(sum_nrg_L_32, &exp_sum_nrg_l); - Word32 tmp_nrg_R = Sqrt32(sum_nrg_R_32, &exp_sum_nrg_R); + norm_sum_nrg_L = W_norm( sum_nrg_L ); + norm_sum_nrg_R = W_norm( sum_nrg_R ); + norm_dot_prod_real = W_norm( dot_prod_real ); + norm_dot_prod_imag = W_norm( dot_prod_img ); + + guard_bit = find_guarded_bits_fx( 4 ); + min_norm = s_min( s_min( s_min( norm_sum_nrg_L, norm_sum_nrg_R ), norm_dot_prod_real ), norm_dot_prod_imag ) - guard_bit; + sum_nrg_L_32 = W_extract_h( W_shl( sum_nrg_L, min_norm ) ); + sum_nrg_R_32 = W_extract_h( W_shl( sum_nrg_R, min_norm ) ); + dot_prod_real_32 = W_extract_h( W_shl( dot_prod_real, min_norm ) ); + dot_prod_img_32 = W_extract_h( W_shl( dot_prod_img, min_norm ) ); + + q_sum_nrg_L = sub( add( shl( hStereoDft->q_dft, 1 ), min_norm ), 31 ); + q_sum_nrg_R = sub( add( shl( hStereoDft->q_dft, 1 ), min_norm ), 31 ); + q_dot_prod_real = sub( add( shl( hStereoDft->q_dft, 1 ), min_norm ), 31 ); + + exp_sum_nrg_l = sub( 31, q_sum_nrg_L ); + exp_sum_nrg_R = sub( 31, q_sum_nrg_R ); + exp_dot_prod_abs = sub( 31, sub( shl( q_dot_prod_real, 1 ), 31 ) ); + exp_sum_nrg_Mid = sub( 31, q_sum_nrg_L ); + + sum_nrg_Mid = L_max( 0, L_add( L_add( sum_nrg_L_32, sum_nrg_R_32 ), L_shl( dot_prod_real_32, 1 ) ) ); + + Word32 tmp_nrg_L = Sqrt32( sum_nrg_L_32, &exp_sum_nrg_l ); + Word32 tmp_nrg_R = Sqrt32( sum_nrg_R_32, &exp_sum_nrg_R ); Word16 exp_sum_abs = exp_sum_nrg_l; - IF(GT_16(exp_sum_nrg_R, exp_sum_nrg_l)) + IF( GT_16( exp_sum_nrg_R, exp_sum_nrg_l ) ) { - exp_sum_abs = exp_sum_nrg_R; move16(); + exp_sum_abs = exp_sum_nrg_R; + move16(); } - exp_sum_abs = add(exp_sum_abs, 1); - sum_abs = L_add(L_shr(tmp_nrg_L, exp_sum_abs - exp_sum_nrg_l), L_shr(tmp_nrg_R, exp_sum_abs - exp_sum_nrg_R)); - dot_prod_abs = Sqrt32(L_add(Mpy_32_32(dot_prod_real_32, dot_prod_real_32), Mpy_32_32(dot_prod_img_32, dot_prod_img_32)), &exp_dot_prod_abs); - Word32 num = L_add(L_shr(L_add(sum_nrg_L_32, sum_nrg_R_32), 1), L_shr(dot_prod_abs, (31 - exp_dot_prod_abs) - q_sum_nrg_L)); - Word16 E_num = sub(31, q_sum_nrg_L); - Word32 num_sqrt = Sqrt32(num, &E_num); - Word16 exp_wR = exp_sum_abs; move16(); - - IF( LT_16(exp_sum_abs, E_num )) + exp_sum_abs = add( exp_sum_abs, 1 ); + sum_abs = L_add( L_shr( tmp_nrg_L, exp_sum_abs - exp_sum_nrg_l ), L_shr( tmp_nrg_R, exp_sum_abs - exp_sum_nrg_R ) ); + dot_prod_abs = Sqrt32( L_add( Mpy_32_32( dot_prod_real_32, dot_prod_real_32 ), Mpy_32_32( dot_prod_img_32, dot_prod_img_32 ) ), &exp_dot_prod_abs ); + Word32 num = L_add( L_shr( L_add( sum_nrg_L_32, sum_nrg_R_32 ), 1 ), L_shr( dot_prod_abs, ( 31 - exp_dot_prod_abs ) - q_sum_nrg_L ) ); + Word16 E_num = sub( 31, q_sum_nrg_L ); + Word32 num_sqrt = Sqrt32( num, &E_num ); + Word16 exp_wR = exp_sum_abs; + move16(); + + IF( LT_16( exp_sum_abs, E_num ) ) { - exp_wR = E_num; move16(); + exp_wR = E_num; + move16(); } Word16 wR_temp; - IF( EQ_32(num_sqrt, 0) && EQ_32(sum_abs, 0) ) + IF( EQ_32( num_sqrt, 0 ) && EQ_32( sum_abs, 0 ) ) { wR_temp = 6364; // 0.776887059 in Q13 move16(); @@ -302,60 +319,64 @@ void stereo_dft_unify_dmx_fx( Word32 sum_nrg_Mid_sqrt = Sqrt32( sum_nrg_Mid, &exp_sum_nrg_Mid ); Word16 exp_wL = exp_sum_abs; - IF( LT_16(exp_sum_abs, exp_sum_nrg_Mid )) + IF( LT_16( exp_sum_abs, exp_sum_nrg_Mid ) ) { - exp_wL = exp_sum_nrg_Mid; move16(); + exp_wL = exp_sum_nrg_Mid; + move16(); } Word16 wL_temp; - IF( EQ_32(sum_nrg_Mid_sqrt, 0) && EQ_32(sum_abs, 0) ) + IF( EQ_32( sum_nrg_Mid_sqrt, 0 ) && EQ_32( sum_abs, 0 ) ) { - wL_temp = 6364; move16(); + wL_temp = 6364; + move16(); } ELSE IF( sum_nrg_Mid_sqrt == 0 && sum_abs != 0 ) { - wL_temp = 5793; move16(); + wL_temp = 5793; + move16(); } ELSE { wL_temp = shr( divide3232( L_shr( sum_nrg_Mid_sqrt, exp_wL - exp_sum_nrg_Mid ), L_shr( sum_abs, exp_wL - exp_sum_abs ) ), 1 ); } - wR = wR_temp; move16(); - wL = add(wR, mult( 23170 /*sqrt(2.0f in Q14)*/, sub( 16384 /* 1.0f in Q14 */, wL_temp ) ) ); + wR = wR_temp; /* Q13 */ + move16(); + wL = add( wR, mult( 23170 /*sqrt(2.0f in Q14)*/, sub( 16384 /* 1.0f in Q14 */, wL_temp ) ) ); /* Q13 */ - FOR ( i = hStereoDft->band_limits[b]; i < hStereoDft->band_limits[b + 1]; i++ ) + FOR( i = hStereoDft->band_limits[b]; i < hStereoDft->band_limits[b + 1]; i++ ) { /*DMX Mapping*/ - pDFT_DMX[2 * i] = Mpy_32_32( L_add(Mpy_32_16_1(DFT_L[2 * i], wL), Mpy_32_16_1(DFT_R[2 * i], wR)), INV_SQRT_2_Q31); - pDFT_DMX[2 * i + 1] = Mpy_32_32( L_add(Mpy_32_16_1(DFT_L[2 * i + 1], wL), Mpy_32_16_1(DFT_R[2 * i + 1], wR)), INV_SQRT_2_Q31); + pDFT_DMX[2 * i] = L_shl( Mpy_32_32( L_add( Mpy_32_16_1( DFT_L[2 * i], wL ), Mpy_32_16_1( DFT_R[2 * i], wR ) ), INV_SQRT_2_Q31 ), Q2 ); /* Q(hStereoDft->q_dft) */ + pDFT_DMX[2 * i + 1] = L_shl( Mpy_32_32( L_add( Mpy_32_16_1( DFT_L[2 * i + 1], wL ), Mpy_32_16_1( DFT_R[2 * i + 1], wR ) ), INV_SQRT_2_Q31 ), Q2 ); /* Q(hStereoDft->q_dft) */ } } - Scale_sig32(pDFT_DMX, (hStereoDft->band_limits[0]), -2); - Scale_sig32(pDFT_DMX + hStereoDft->band_limits[hStereoDft->res_cod_band_max + 1], hStereoDft->NFFT - hStereoDft->band_limits[hStereoDft->res_cod_band_max + 1], -2); + // Scale_sig32(pDFT_DMX, (hStereoDft->band_limits[0]), -2); + // Scale_sig32(pDFT_DMX + hStereoDft->band_limits[hStereoDft->res_cod_band_max + 1], hStereoDft->NFFT - hStereoDft->band_limits[hStereoDft->res_cod_band_max + 1], -2); - Copy32( pDFT_DMX, DFT[0] + i_mult(k, STEREO_DFT32MS_N_MAX), hStereoDft->NFFT ); + Copy32( pDFT_DMX, DFT[0] + i_mult( k, STEREO_DFT32MS_N_MAX ), hStereoDft->NFFT ); /* Update DFT_past_DMX, needed for stereo filling used by stereo residual PLC */ hStereoDft->past_DMX_pos = ( hStereoDft->past_DMX_pos + 1 ) % STEREO_DFT_PAST_MAX; Copy32( pDFT_DMX, hStereoDft->DFT_past_DMX_fx[hStereoDft->past_DMX_pos], s_min( hStereoDft->NFFT, STEREO_DFT32MS_N_32k ) ); - //Scale_sig32(hStereoDft->DFT_past_DMX_fx[hStereoDft->past_DMX_pos], s_min(hStereoDft->NFFT, STEREO_DFT32MS_N_32k), -2); - hStereoDft->q_DFT_past_DMX_fx[hStereoDft->past_DMX_pos] = sub(add(hStereoDft->q_dft, 13), 15); - IF ( st0->bfi && !prev_bfi ) + // Scale_sig32(hStereoDft->DFT_past_DMX_fx[hStereoDft->past_DMX_pos], s_min(hStereoDft->NFFT, STEREO_DFT32MS_N_32k), -2); + // hStereoDft->q_DFT_past_DMX_fx[hStereoDft->past_DMX_pos] = sub(add(hStereoDft->q_dft, 13), 15); + IF( st0->bfi && !prev_bfi ) { Word16 idx_k0, idx_k1; Word16 q_shift0; Word16 q_shift1; - idx_k0 = ( add(hStereoDft->past_DMX_pos, 1) ) % STEREO_DFT_PAST_MAX; - idx_k1 = ( add(idx_k0, 1) ) % STEREO_DFT_PAST_MAX; - q_shift0 = sub(hStereoDft->q_dft, hStereoDft->q_DFT_past_DMX_fx[idx_k0]); - q_shift1 = sub(hStereoDft->q_dft, hStereoDft->q_DFT_past_DMX_fx[idx_k1]); + idx_k0 = ( add( hStereoDft->past_DMX_pos, 1 ) ) % STEREO_DFT_PAST_MAX; + idx_k1 = ( add( idx_k0, 1 ) ) % STEREO_DFT_PAST_MAX; + q_shift0 = sub( hStereoDft->q_dft, hStereoDft->q_DFT_past_DMX_fx[idx_k0] ); + q_shift1 = sub( hStereoDft->q_dft, hStereoDft->q_DFT_past_DMX_fx[idx_k1] ); /*dmx energy memory*/ - hStereoDft->past_dmx_nrg = stereo_dft_dmx_swb_nrg_fx( hStereoDft->DFT_past_DMX_fx[idx_k0], hStereoDft->DFT_past_DMX_fx[idx_k1], min( hStereoDft->NFFT, STEREO_DFT32MS_N_32k ), q_shift0, q_shift1); + hStereoDft->past_dmx_nrg_fx = stereo_dft_dmx_swb_nrg_fx( hStereoDft->DFT_past_DMX_fx[idx_k0], hStereoDft->DFT_past_DMX_fx[idx_k1], s_min( hStereoDft->NFFT, STEREO_DFT32MS_N_32k ), q_shift0, q_shift1 ); } } - hStereoDft->q_dft = sub(add(hStereoDft->q_dft, 13), 15); + // hStereoDft->q_dft = sub(add(hStereoDft->q_dft, 13), 15); return; } @@ -524,6 +545,7 @@ void stereo_dft_unify_dmx( } #endif + /*-------------------------------------------------------------------* * add_HB_to_mono_dmx() * @@ -646,11 +668,15 @@ void add_HB_to_mono_dmx_fx( Word32 *memOutHB_fx, *memTransitionHB_fx; output_Fs = hCPE->hCoreCoder[0]->output_Fs; +#if 0 Word16 q_memOutHB = Q_factor_arr(hCPE->hStereoDftDmx->memOutHB, NS2SA(48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS)); floatToFixed_arrL(hCPE->hStereoDftDmx->memOutHB, hCPE->hStereoDftDmx->memOutHB_fx, q_memOutHB, NS2SA(48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS)); +#endif memOutHB_fx = hCPE->hStereoDftDmx->memOutHB_fx; +#if 0 Word16 q_memTransitionHB = Q_factor_arr(hCPE->hStereoDftDmx->memTransitionHB, NS2SA(48000, STEREO_DFT32MS_OVL_NS)); floatToFixed_arrL(hCPE->hStereoDftDmx->memTransitionHB, hCPE->hStereoDftDmx->memTransitionHB_fx, q_memTransitionHB, NS2SA(48000, STEREO_DFT32MS_OVL_NS)); +#endif memTransitionHB_fx = hCPE->hStereoDftDmx->memTransitionHB_fx; memOffset = NS2SA(output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS); diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 72c52a0d70126b91ef75cb6b5edd69fa9b5b64eb..8858b52ef500f1d20ea12df7c7354ddb4350e3d7 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -173,9 +173,9 @@ void stereo_dft_dec_reset_fx( set_val_Word16( &hStereoDft->g_state_fx[0], 0, STEREO_DFT_BAND_MAX ); - init_basic_allpass( &hStereoDft->ap1, dft_ap_gains[0], dft_ap_gains_fx[0], dft_ap_delays[0] ); - init_basic_allpass( &hStereoDft->ap2, dft_ap_gains[1], dft_ap_gains_fx[1], dft_ap_delays[1] ); - init_basic_allpass( &hStereoDft->ap3, dft_ap_gains[2], dft_ap_gains_fx[2], dft_ap_delays[2] ); + init_basic_allpass_fx( &hStereoDft->ap1, dft_ap_gains_fx[0], dft_ap_delays[0] ); + init_basic_allpass_fx( &hStereoDft->ap2, dft_ap_gains_fx[1], dft_ap_delays[1] ); + init_basic_allpass_fx( &hStereoDft->ap3, dft_ap_gains_fx[2], dft_ap_delays[2] ); set_val_Word32( hStereoDft->ap_delay_mem_fx, 0, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); set_val_Word32( hStereoDft->ap_fade_mem_fx, 0, STEREO_DFT_ALLPASS_FADELEN_16k ); diff --git a/lib_dec/ivas_stereo_esf_dec.c b/lib_dec/ivas_stereo_esf_dec.c index 5fda7188efa9ab2dcd2c326afd59adb5c2178561..efec50708f4e657ca6ec909a4da9e8ff02dacc49 100644 --- a/lib_dec/ivas_stereo_esf_dec.c +++ b/lib_dec/ivas_stereo_esf_dec.c @@ -44,12 +44,10 @@ * *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void init_basic_allpass( basic_allpass_t *ap, const float *gains, -#ifdef IVAS_FLOAT_FIXED - const Word32 *gains_fx, -#endif const int16_t *delays ) { int16_t i, j; @@ -58,26 +56,47 @@ void init_basic_allpass( { ap->gains[i] = gains[i]; ap->delays[i] = delays[i]; -#ifdef IVAS_FLOAT_FIXED - ap->gains_fx[i] = gains_fx[i]; -#endif for ( j = 0; j < STEREO_DFT_ALLPASS_BUFFERLEN; j++ ) { ap->buffer[i][j] = 0.f; -#ifdef IVAS_FLOAT_FIXED + } + } + + ap->pos = 0; + + return; +} +#else +void init_basic_allpass_fx( + basic_allpass_t *ap, + const Word32 *gains_fx, + const Word16 *delays ) +{ + Word16 i, j; + + FOR( i = 0; i < 3; i++ ) + { + ap->delays[i] = delays[i]; + move16(); + ap->gains_fx[i] = gains_fx[i]; + move32(); + + FOR( j = 0; j < STEREO_DFT_ALLPASS_BUFFERLEN; j++ ) + { ap->buffer_fx[i][j] = 0; -#endif + move32(); } -#ifdef IVAS_FLOAT_FIXED ap->q_buffer_fx = 0; -#endif + move16(); } ap->pos = 0; + move16(); return; } +#endif /*-------------------------------------------------------------------* @@ -86,6 +105,7 @@ void init_basic_allpass( * *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void filter_with_allpass( const float *sig, float *out, @@ -136,14 +156,13 @@ void filter_with_allpass( return; } - -#ifdef IVAS_FLOAT_FIXED +#else void filter_with_allpass_fx( const Word32 *sig, Word32 *out, const Word16 len, basic_allpass_t *ap, - Word16 q_shift) + Word16 q_shift ) { Word16 k; Word16 pos, mask; @@ -152,43 +171,72 @@ void filter_with_allpass_fx( Word32 g1_fx, g2_fx, g3_fx, *D1_fx, *D2_fx, *D3_fx; P1_fx = P2_fx = P3_fx = P4_fx = P5_fx = 0; - mask = STEREO_DFT_ALLPASS_BUFFERLEN - 1; + move32(); + move32(); + move32(); + move32(); + move32(); + mask = sub( STEREO_DFT_ALLPASS_BUFFERLEN, 1 ); + move32(); pos = ap->pos; + move16(); g1_fx = ap->gains_fx[0]; + move32(); g2_fx = ap->gains_fx[1]; + move32(); g3_fx = ap->gains_fx[2]; + move32(); d1 = ap->delays[0]; + move16(); d2 = ap->delays[1]; + move16(); d3 = ap->delays[2]; + move16(); D1_fx = ap->buffer_fx[0]; + move32(); D2_fx = ap->buffer_fx[1]; + move32(); D3_fx = ap->buffer_fx[2]; + move32(); - IF (NE_16(q_shift, ap->q_buffer_fx)) + IF( NE_16( q_shift, ap->q_buffer_fx ) ) { - FOR (k = 0; k < sizeof(ap->buffer_fx[0]) / sizeof(ap->buffer_fx[0][0]); k++) + FOR( k = 0; k < sizeof( ap->buffer_fx[0] ) / sizeof( ap->buffer_fx[0][0] ); k++ ) { - D1_fx[k] = L_shr(D1_fx[k], sub(ap->q_buffer_fx, q_shift)); - D2_fx[k] = L_shr(D2_fx[k], sub(ap->q_buffer_fx, q_shift)); - D3_fx[k] = L_shr(D3_fx[k], sub(ap->q_buffer_fx, q_shift)); + D1_fx[k] = L_shr( D1_fx[k], sub( ap->q_buffer_fx, q_shift ) ); + move32(); + D2_fx[k] = L_shr( D2_fx[k], sub( ap->q_buffer_fx, q_shift ) ); + move32(); + D3_fx[k] = L_shr( D3_fx[k], sub( ap->q_buffer_fx, q_shift ) ); + move32(); } ap->q_buffer_fx = q_shift; + move16(); } - Word32 D1_upd = pos + d1, D2_upd = pos + d2, D3_upd = pos + d3; + Word32 D1_upd = add( pos, d1 ), D2_upd = add( pos, d2 ), D3_upd = add( pos, d3 ); FOR( k = 0; k <= mask; k++ ) { - IF( pos == D1_upd ) - D1_upd = -1; - IF( pos == D2_upd ) - D2_upd = -1; - IF( pos == D3_upd ) - D3_upd = -1; + IF( EQ_32( pos, D1_upd ) ) + { + D1_upd = -1; + move32(); + } + IF( EQ_32( pos, D2_upd ) ) + { + D2_upd = -1; + move32(); + } + IF( EQ_32( pos, D3_upd ) ) + { + D3_upd = -1; + move32(); + } P1_fx = L_sub_sat( sig[k], Mpy_32_32( g3_fx, D3_fx[pos] ) ); P2_fx = L_sub_sat( P1_fx, Mpy_32_32( g1_fx, D1_fx[pos] ) ); @@ -196,12 +244,16 @@ void filter_with_allpass_fx( P4_fx = L_add_sat( D2_fx[pos], Mpy_32_32( g2_fx, P3_fx ) ); P5_fx = L_add_sat( D3_fx[pos], Mpy_32_32( g3_fx, P1_fx ) ); out[k] = P5_fx; /* could overwrite sig */ + move32(); D1_fx[( pos + d1 ) & mask] = P2_fx; + move32(); D2_fx[( pos + d2 ) & mask] = P3_fx; + move32(); D3_fx[( pos + d3 ) & mask] = P4_fx; + move32(); - pos = ( pos + 1 ) & mask; + pos = s_and( add( pos, 1 ), mask ); } FOR( k = mask + 1; k < len; k++ ) @@ -213,15 +265,20 @@ void filter_with_allpass_fx( P4_fx = L_add( D2_fx[pos], Mpy_32_32( g2_fx, P3_fx ) ); P5_fx = L_add( D3_fx[pos], Mpy_32_32( g3_fx, P1_fx ) ); out[k] = P5_fx; /* could overwrite sig */ + move32(); D1_fx[( pos + d1 ) & mask] = P2_fx; + move32(); D2_fx[( pos + d2 ) & mask] = P3_fx; + move32(); D3_fx[( pos + d3 ) & mask] = P4_fx; + move32(); - pos = ( pos + 1 ) & mask; + pos = s_and( add( pos, 1 ), mask ); } ap->pos = pos; + move16(); return; } diff --git a/lib_dec/ivas_stereo_ica_dec.c b/lib_dec/ivas_stereo_ica_dec.c index 9c1f34218c728359d777049b10ab8869bda3351a..3c0cf6fa8ff9bc9446fabaac2f4fac9e82019e00 100644 --- a/lib_dec/ivas_stereo_ica_dec.c +++ b/lib_dec/ivas_stereo_ica_dec.c @@ -85,15 +85,19 @@ void stereo_tca_dec_fx( { IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { +#if 0 // to be deleted next MR hCPE->hStereoDftDmx->targetGain = 1.0f; +#endif hCPE->hStereoDftDmx->targetGain_fx = ONE_IN_Q29; move32(); } /* save the target gain for next frame */ +#if 0 // to be deleted next MR hCPE->hStereoDftDmx->prevTargetGain = hCPE->hStereoDftDmx->targetGain; +#endif hCPE->hStereoDftDmx->prevTargetGain_fx = hCPE->hStereoDftDmx->targetGain_fx; move32(); } diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index dc352d85892d33fc69e555bd175d269d093036f9..db3b2733f1d0121288b7abac3b9f67f557908433 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -1121,7 +1121,16 @@ static void update_exp( Word16 *a_exp, Word16 *b_exp, Word16 *buff_a, Word16 *bu } return; } - +static Word16 norm_arr(Word16 *arr, int size) +{ + Word16 q = 15; + for (int i = 0; i < size; i++) + if (arr[i] != 0) + { + q = min(q, norm_s(arr[i])); + } + return q; +} void updateBuffersForDmxMdctStereo_fx( CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ const Word16 output_frame, /* i : output frame length */ @@ -1201,12 +1210,30 @@ void updateBuffersForDmxMdctStereo_fx( Word16 sum_tcx_ltp = 0, sum_delay_buf = 0, sum_tcx_ltp_out = 0, sum_old_out = 0; + Copy_Scale_sig_32_16(&sts[0]->hTcxLtpDec->tcxltp_mem_in_32, &sts[0]->hTcxLtpDec->tcxltp_mem_in, TCXLTP_MAX_DELAY, -11); + Copy_Scale_sig_32_16(&sts[1]->hTcxLtpDec->tcxltp_mem_in_32, &sts[1]->hTcxLtpDec->tcxltp_mem_in, TCXLTP_MAX_DELAY, -11); + + Copy_Scale_sig_32_16(&sts[0]->hTcxLtpDec->tcxltp_mem_out_32, &sts[0]->hTcxLtpDec->tcxltp_mem_out, L_FRAME48k, -11); + Copy_Scale_sig_32_16(&sts[1]->hTcxLtpDec->tcxltp_mem_out_32, &sts[1]->hTcxLtpDec->tcxltp_mem_out, L_FRAME48k, -11); + + sts[0]->hTcxLtpDec->exp_tcxltp_mem_in = 15 - norm_arr(sts[0]->hTcxLtpDec->tcxltp_mem_in, TCXLTP_MAX_DELAY); + sts[1]->hTcxLtpDec->exp_tcxltp_mem_in = 15 - norm_arr(sts[1]->hTcxLtpDec->tcxltp_mem_in, TCXLTP_MAX_DELAY); + + sts[0]->hTcxLtpDec->exp_tcxltp_mem_out = 15 - norm_arr(sts[0]->hTcxLtpDec->tcxltp_mem_out, L_FRAME48k); + sts[1]->hTcxLtpDec->exp_tcxltp_mem_out = 15 - norm_arr(sts[1]->hTcxLtpDec->tcxltp_mem_out, L_FRAME48k); + + + + Scale_sig(&sts[0]->hTcxLtpDec->tcxltp_mem_in, TCXLTP_MAX_DELAY, sub(15, sts[0]->hTcxLtpDec->exp_tcxltp_mem_in)); + Scale_sig(&sts[1]->hTcxLtpDec->tcxltp_mem_in, TCXLTP_MAX_DELAY, sub(15, sts[1]->hTcxLtpDec->exp_tcxltp_mem_in)); + + Scale_sig(&sts[0]->hTcxLtpDec->tcxltp_mem_out, TCXLTP_MAX_DELAY, sub(15, sts[0]->hTcxLtpDec->exp_tcxltp_mem_out)); + Scale_sig(&sts[1]->hTcxLtpDec->tcxltp_mem_out, TCXLTP_MAX_DELAY, sub(15, sts[1]->hTcxLtpDec->exp_tcxltp_mem_out)); + + update_exp( &sts[0]->hTcxLtpDec->exp_tcxltp_mem_in, &sts[1]->hTcxLtpDec->exp_tcxltp_mem_in, sts[0]->hTcxLtpDec->tcxltp_mem_in, sts[1]->hTcxLtpDec->tcxltp_mem_in, TCXLTP_MAX_DELAY ); - //update_exp( &sts[1]->exp_delay_buf_out, &sts[1]->exp_delay_buf_out, - // sts[0]->delay_buf_out_fx, sts[1]->delay_buf_out_fx, HQ_DELTA_MAX * HQ_DELAY_COMP ); - update_exp( &sts[0]->hHQ_core->exp_old_out, &sts[1]->hHQ_core->exp_old_out, sts[0]->hHQ_core->old_out_fx, sts[1]->hHQ_core->old_out_fx, L_FRAME48k ); @@ -1252,6 +1279,9 @@ void updateBuffersForDmxMdctStereo_fx( sts[0]->hTcxLtpDec->exp_tcxltp_mem_in = add( sts[0]->hTcxLtpDec->exp_tcxltp_mem_in, 1 ); sts[0]->hHQ_core->exp_old_out = add( sts[0]->hHQ_core->exp_old_out, 1 ); sts[0]->hTcxLtpDec->exp_tcxltp_mem_out = add( sts[0]->hTcxLtpDec->exp_tcxltp_mem_out, 1 ); + + Copy_Scale_sig_16_32(&sts[0]->hTcxLtpDec->tcxltp_mem_in, &sts[0]->hTcxLtpDec->tcxltp_mem_in_32, TCXLTP_MAX_DELAY, sub(11, sub(15, sts[0]->hTcxLtpDec->exp_tcxltp_mem_in))); + Copy_Scale_sig_16_32(&sts[0]->hTcxLtpDec->tcxltp_mem_out, &sts[0]->hTcxLtpDec->tcxltp_mem_out_32, TCXLTP_MAX_DELAY, sub(11, sub(15, sts[0]->hTcxLtpDec->exp_tcxltp_mem_out))); } return; diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 88457bb8d230c804cc0aef17d5a5c78f8c5544e4..06a22a1d17139f35cd0df1671f012a7dc5e81201 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -3003,11 +3003,11 @@ void synchro_synthesis_fx( { FOR( Word32 p = 0; p < L_FRAME48k; p++ ) { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] = (float) hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] / ( 1u << output_q ); + //hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] = (float) hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] / ( 1u << output_q ); } FOR( Word32 p = 0; p < TCXLTP_MAX_DELAY; p++ ) { - hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] = (float) hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] / ( 1u << output_q ); + // hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] = (float) hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] / ( 1u << output_q ); } } } @@ -3026,11 +3026,11 @@ void synchro_synthesis_fx( { FOR( Word32 p = 0; p < L_FRAME48k; p++ ) { - hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_float[p] = (float) hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_32[p] / ( 1u << output_q ); + //hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_float[p] = (float) hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_out_32[p] / ( 1u << output_q ); } FOR( Word32 p = 0; p < TCXLTP_MAX_DELAY; p++ ) { - hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_float[p] = (float) hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_32[p] / ( 1u << output_q ); + //hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_float[p] = (float) hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_32[p] / ( 1u << output_q ); } } //FOR( Word32 k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); k++ ) diff --git a/lib_dec/ivas_stereo_td_dec.c b/lib_dec/ivas_stereo_td_dec.c index 7af9d7b22d39c467551a5c4306890dc76329d681..2bdbb72b20188f3b305c8bbf628789b8fe4116d3 100644 --- a/lib_dec/ivas_stereo_td_dec.c +++ b/lib_dec/ivas_stereo_td_dec.c @@ -268,9 +268,6 @@ void tdm_configure_dec( tmpS = get_indice_st( sts[0], element_brate_adapt, bstr_last_pos - TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + STEREO_BITS_TCA_CHAN + STEREO_BITS_TCA_CORRSTATS, STEREO_BITS_TCA_GD ); } hCPE->hStereoDftDmx->targetGain_fx = power_table[tmpS]; -#ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED - //hCPE->hStereoDftDmx->targetGain = fixedToFloat(hCPE->hStereoDftDmx->targetGain_fx, 29 ); -#endif } ELSE { diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 6212dab02a7e6ee7e7ac6d71d88fd37041a3b723..70b2bd2944b18cbb129e7294307d2f510bf334da 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -354,7 +354,7 @@ void stereo_tcx_core_dec_fx( /* Initialize pointers */ synth_fx = synth_buf_fx + hTcxDec->old_synth_len; synthFB_fx = synth_bufFB_fx + hTcxDec->old_synth_lenFB; - Copy( hTcxDec->old_synth, synth_buf_fx, hTcxDec->old_synth_len ); + Copy_Scale_sig( hTcxDec->old_synth, synth_buf_fx, hTcxDec->old_synth_len, -st->Q_syn); Copy( hTcxDec->old_synthFB_fx, synth_bufFB_fx, hTcxDec->old_synth_lenFB ); set16_fx( synth_fx, 0, L_FRAME_PLUS + M ); set16_fx( synthFB_fx, 0, L_FRAME_PLUS + M ); @@ -381,37 +381,6 @@ void stereo_tcx_core_dec_fx( st->core = GetPLCModeDecision_ivas_fx( st ); } -#if 1 // TO BE REMOVED - IF( bfi && ( NE_16( st->last_core, -1 ) && EQ_16( st->nbLostCmpt, 1 ) ) ) - { - IF( !( st->rf_flag && st->use_partial_copy && ( EQ_16( st->rf_frame_type, RF_TCXTD1 ) || EQ_16( st->rf_frame_type, RF_TCXTD2 ) ) ) ) - { - IF( st->hTonalMDCTConc != NULL && st->last_core == TCX_20_CORE && st->second_last_core == TCX_20_CORE && ( ( st->old_fpitch <= L_shl(st->L_frame, 15) ) || ( st->hTcxDec->tcxltp_last_gain_unmodified <= 13107 /*0.4f*/ ) ) - /* it is fine to call the detection even if no ltp information - is available, meaning that st->old_fpitch == - st->tcxltp_second_last_pitch == st->L_frame */ - && ( st->old_fpitch == st->hTcxDec->tcxltp_second_last_pitch ) && !st->last_tns_active && !st->second_last_tns_active ) - { - //st->hTonalMDCTConc->pTCI->numIndexes = st->hTonalMDCTConc->pTCI->numIndexes; - FOR( i = 0; i < st->hTonalMDCTConc->pTCI->numIndexes; ++i ) - { - st->hTonalMDCTConc->pTCI->indexOfTonalPeak[i] = st->hTonalMDCTConc->pTCI->indexOfTonalPeak[i]; - st->hTonalMDCTConc->pTCI->lowerIndex[i] = st->hTonalMDCTConc->pTCI->lowerIndex[i]; - st->hTonalMDCTConc->pTCI->upperIndex[i] = st->hTonalMDCTConc->pTCI->upperIndex[i]; - } - FOR( i = 0; i < st->hTonalMDCTConc->pTCI->numIndexes; i++ ) - { - st->hTonalMDCTConc->pTCI->phaseDiff_float[i] = fixedToFloat( st->hTonalMDCTConc->pTCI->phaseDiff[i], Q12 ); - } - FOR( i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++ ) - { - st->hTonalMDCTConc->pTCI->phase_currentFramePredicted_float[i] = fixedToFloat( st->hTonalMDCTConc->pTCI->phase_currentFramePredicted[i], Q13 ); - } - } - } - } -#endif // 1 - /*--------------------------------------------------------------------------------* * LPC PARAMETERS *--------------------------------------------------------------------------------*/ @@ -751,7 +720,7 @@ void stereo_tcx_core_dec_fx( } /* Update past buffers */ - Copy( synth_buf_fx + st->L_frame, hTcxDec->old_synth, hTcxDec->old_synth_len ); + Copy_Scale_sig( synth_buf_fx + st->L_frame, hTcxDec->old_synth, hTcxDec->old_synth_len, 0); Copy( hTcxDec->old_synthFB_fx + hTcxDec->L_frameTCX - NS2SA_fx2( st->output_Fs, PH_ECU_MEM_NS ), hTcxDec->synth_history_fx, NS2SA_fx2( st->output_Fs, PH_ECU_MEM_NS ) ); Copy( synth_bufFB_fx + hTcxDec->L_frameTCX, hTcxDec->old_synthFB_fx, hTcxDec->old_synth_lenFB ); Copy( st->hHQ_core->old_out_fx + NS2SA_fx2( st->output_Fs, N_ZERO_MDCT_NS ), hTcxDec->old_synthFB_fx + hTcxDec->old_synth_lenFB, NS2SA_fx2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); @@ -881,7 +850,7 @@ void stereo_tcx_core_dec_fx( } expand_range( st->hFdCngDec->msPsd, psd_part_fx, &psd_part_e, st->hFdCngDec->nFFTpart_shaping ); scalebands_fx( psd_part_fx, st->hFdCngDec->part_shaping, st->hFdCngDec->nFFTpart_shaping, st->hFdCngDec->midband_shaping, st->hFdCngDec->nFFTpart_shaping, st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand, psd_fx, 1 ); - // generate_stereo_masking_noise_fx( signal_out, st, hStereoTD, flag_sec_CNA, 0, hStereoCng, nchan_out ); + generate_stereo_masking_noise_16fx( signal_out_fx, 0, st, hStereoTD, flag_sec_CNA, 0, hStereoCng, nchan_out ); } ELSE IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) @@ -1813,7 +1782,7 @@ static void dec_prm_tcx_ivas_fx( #if 1 /*Fixed to float changes*/ //st->hTcxLtpDec->tcxltp_gain_float = fixedToFloat( st->hTcxLtpDec->tcxltp_gain, 15 ); - st->hTcxDec->tcxltp_last_gain_unmodified_float = fixedToFloat( st->hTcxDec->tcxltp_last_gain_unmodified, 15 ); + //st->hTcxDec->tcxltp_last_gain_unmodified_float = fixedToFloat( st->hTcxDec->tcxltp_last_gain_unmodified, 15 ); #endif // Ends here return; } diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index b9df10d50115058acfa36d3bab444f73339348a7..d4864d2500cd6e0da5e14a8cec9801d1d6da0d9f 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1810,11 +1810,19 @@ ivas_error IVAS_DEC_GetDefaultRenderConfig( RENDER_CONFIG_DATA RCin; RENDER_CONFIG_HANDLE hRCin = &RCin; ivas_error error; +#ifdef IVAS_FLOAT_FIXED + IF((error = ivas_render_config_init_from_rom_fx(&hRCin)) != IVAS_ERR_OK) + { + return error; + } +#endif + /*FLOAT CODE*/ IF( ( error = ivas_render_config_init_from_rom( &hRCin ) ) != IVAS_ERR_OK ) { return error; } + /*--------- */ return copyRendererConfigStruct( hRCin, hRCout ); } diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index ceec307b99261a08a913fa0298b0ba15ac499f1a..5e8f7c3b23d5f2b79d8c71be5721d9d3b5fae4a0 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -172,8 +172,10 @@ typedef struct float psize_inv_shaping_float[NPART_SHAPING]; /* Inverse of partition sizes */ Word16 psize_inv_shaping[NPART_SHAPING]; /* Inverse of partition sizes */ - + +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) float bandNoiseShape_float[FFTLEN2]; /* CNG spectral shape computed at the decoder */ +#endif Word32 bandNoiseShape[FFTLEN2]; /* CNG spectral shape computed at the decoder */ @@ -185,8 +187,8 @@ typedef struct Word16 partNoiseShape_exp; /* exponent of partNoiseShape */ - float smoothed_psd[L_FRAME16k]; /* stereo CNA - periodogram smoothed with IIR filter */ #if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) + float smoothed_psd[L_FRAME16k]; /* stereo CNA - periodogram smoothed with IIR filter */ float msPeriodog_ST[NPART_SHAPING]; /* stereo CNA - short-term periodogram */ #endif Word32 msPeriodog_ST_fx[NPART_SHAPING]; /* stereo CNA - short-term periodogram */ @@ -356,24 +358,25 @@ typedef struct Word16 phaseDiff[MAX_NUMBER_OF_IDX]; // Q12 /* This one can be stored with 16 bits in range 0..2*PI */ Word16 phase_currentFramePredicted[MAX_NUMBER_OF_IDX*GROUP_LENGTH]; // Q13 /* This one can be stored with 16 bits in range [-pi;pi] 2Q13, but the code has to be adapted to use moduo(2*PI) after adding */ - +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) Float32 phaseDiff_float[MAX_NUMBER_OF_IDX]; /* This one can be stored with 16 bits in range 0..2*PI */ Float32 phase_currentFramePredicted_float[MAX_NUMBER_OF_IDX * GROUP_LENGTH]; /* This one can be stored with 16 bits in range 0..2*PI, but the code has to be adapted to use moduo(2*PI) after adding */ +#endif } TonalComponentsInfo; -typedef struct -{ - Word16 numIndexes; - Word16 indexOfTonalPeak[MAX_NUMBER_OF_IDX]; - Word16 lowerIndex[MAX_NUMBER_OF_IDX]; - Word16 upperIndex[MAX_NUMBER_OF_IDX]; - - Word16 phaseDiff[MAX_NUMBER_OF_IDX]; // Q12 /* This one can be stored with 16 bits in range 0..2*PI */ - - Word16 phase_currentFramePredicted[MAX_NUMBER_OF_IDX*GROUP_LENGTH]; // Q13 /* This one can be stored with 16 bits in range [-pi;pi] 2Q13, but the code has to be adapted to use moduo(2*PI) after adding */ - -} TonalComponentsInfo_fix; +//typedef struct +//{ +// Word16 numIndexes; +// Word16 indexOfTonalPeak[MAX_NUMBER_OF_IDX]; +// Word16 lowerIndex[MAX_NUMBER_OF_IDX]; +// Word16 upperIndex[MAX_NUMBER_OF_IDX]; +// +// Word16 phaseDiff[MAX_NUMBER_OF_IDX]; // Q12 /* This one can be stored with 16 bits in range 0..2*PI */ +// +// Word16 phase_currentFramePredicted[MAX_NUMBER_OF_IDX*GROUP_LENGTH]; // Q13 /* This one can be stored with 16 bits in range [-pi;pi] 2Q13, but the code has to be adapted to use moduo(2*PI) after adding */ +// +//} TonalComponentsInfo_fix; typedef struct tonalmdctconceal { @@ -416,7 +419,7 @@ typedef struct tonalmdctconceal Word16 secondLastPowerSpectrum_exp; float scaleFactorsBackground_flt[FDNS_NPTS]; - Word16 scaleFactorsBackground[FDNS_NPTS]; + //Word16 scaleFactorsBackground[FDNS_NPTS]; Word32 scaleFactorsBackground_fx[FDNS_NPTS]; #if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) float scf_fadeout_flt; @@ -2624,7 +2627,6 @@ typedef struct Decoder_State int16_t old_bwe_delay; //Word16 old_bwe_delay; /*Q0*/ - float hb_prev_synth_buffer[NS2SA( 48000, DELAY_BWE_TOTAL_NS )]; Word16 hb_prev_synth_buffer_fx[NS2SA(48000, DELAY_BWE_TOTAL_NS)]; /* WB/SWB bandwidth switching */ @@ -2633,6 +2635,7 @@ typedef struct Decoder_State Word16 tilt_swb_fx; #if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) + float hb_prev_synth_buffer[NS2SA( 48000, DELAY_BWE_TOTAL_NS )]; float tilt_wb; float tilt_swb; float prev_ener_shb; diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index 0acc63ef7bf5fc4c11f77e3b53dfe8c00cc08c02..9314ae06cf1894d53c231c2da58ee654933655e8 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -70,11 +70,13 @@ ivas_error TonalMDCTConceal_Init_ivas( assert( ( hTonalMDCTConc->nScaleFactors == nScaleFactors ) || ( hTonalMDCTConc->nSamples != nSamples ) ); /* If nSamples doesn't change then also nScaleFactors must stay the same */ hTonalMDCTConc->tcx_cfg = hTcxCfg; +#if (defined EVS_FLOAT) || (!defined IVAS_FLOAT_FIXED ) hTonalMDCTConc->lastBlockData.spectralData_float = hTonalMDCTConc->spectralDataBuffers_float[0]; hTonalMDCTConc->secondLastBlockData.spectralData_float = hTonalMDCTConc->spectralDataBuffers_float[1]; hTonalMDCTConc->secondLastPowerSpectrum_float = hTonalMDCTConc->secondLastBlockData.spectralData_float; hTonalMDCTConc->lastBlockData.scaleFactors_float = hTonalMDCTConc->scaleFactorsBuffers_float[0]; hTonalMDCTConc->secondLastBlockData.scaleFactors_float = hTonalMDCTConc->scaleFactorsBuffers_float[1]; +#endif hTonalMDCTConc->lastBlockData.blockIsValid = 0; hTonalMDCTConc->secondLastBlockData.blockIsValid = 0; hTonalMDCTConc->nSamples = 0; @@ -98,6 +100,7 @@ ivas_error TonalMDCTConceal_Init_ivas( hTonalMDCTConc->nScaleFactors = nScaleFactors; set_zero( hTonalMDCTConc->scaleFactorsBackground_flt, FDNS_NPTS ); + set32_fx( hTonalMDCTConc->scaleFactorsBackground_fx, 0, FDNS_NPTS ); #if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) hTonalMDCTConc->scf_fadeout_flt = 1.0f; #endif @@ -223,7 +226,7 @@ void TonalMDCTConceal_UpdateState_ivas( return; } -#endif + static void FindPhases( const TonalMDCTConcealPtr hTonalMDCTConc, @@ -316,7 +319,7 @@ static void CalcPowerSpec( return; } -#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) + static void CalcPowerSpecAndDetectTonalComponents( const TonalMDCTConcealPtr hTonalMDCTConc, float secondLastMDST[], @@ -504,49 +507,7 @@ void TonalMDCTConceal_Detect_ivas( } else { -#ifdef IVAS_FLOAT_FIXED - Word32 powerSpectrum_fx[L_FRAME_MAX], scaleFactors_fx[FDNS_NPTS]; - Word16 q_ps = 31, q_sf = 31; - FOR( Word16 k = 0; k < hTonalMDCTConc->nSamplesCore; k++ ) - { - if ( abs( (Word32) powerSpectrum[k] ) != 0 ) - q_ps = s_min( q_ps, norm_l( (Word32) powerSpectrum[k] ) ); - } - FOR( Word16 k = 0; k < FDNS_NPTS; k++ ) - { - if ( abs( (Word32) hTonalMDCTConc->secondLastBlockData.scaleFactors_float[k] ) != 0 ) - q_sf = s_min( q_sf, norm_l( (Word32) hTonalMDCTConc->secondLastBlockData.scaleFactors_float[k] ) ); - } - q_ps -= 1; - q_sf -= 1; - FOR( Word16 c = 0; c < hTonalMDCTConc->nSamplesCore; c++ ) - { - powerSpectrum_fx[c] = (Word32) ( powerSpectrum[c] * ( 1 << q_ps ) ); - } - FOR( Word16 c = 0; c < FDNS_NPTS; c++ ) - { - scaleFactors_fx[c] = (Word32) ( hTonalMDCTConc->secondLastBlockData.scaleFactors_float[c] * ( 1 << q_sf ) ); - } - - sns_shape_spectrum_fx( powerSpectrum_fx, &q_ps, psychParamsCurrent, scaleFactors_fx, q_sf, hTonalMDCTConc->nSamplesCore ); - - IF ( q_ps + 1 < 31 ) - { - FOR( Word16 c = 0; c < hTonalMDCTConc->nSamplesCore; c++ ) - { - powerSpectrum[c] = ( (float) powerSpectrum_fx[c] / ( 1 << ( q_ps + 1 ) ) ); - } - } - ELSE IF ( q_ps + 1 == 31 ) - { - FOR( Word16 c = 0; c < hTonalMDCTConc->nSamplesCore; c++ ) - { - powerSpectrum[c] = ( (float) powerSpectrum_fx[c] / ONE_IN_Q31 ); - } - } -#else sns_shape_spectrum( powerSpectrum, psychParamsCurrent, hTonalMDCTConc->secondLastBlockData.scaleFactors_float, hTonalMDCTConc->nSamplesCore ); -#endif // IVAS_FLOAT_FIXED nBands = psychParamsCurrent->nBands; } diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index 7769fb8b59883492f99862a0c596ac0955c83904..ee4c1d48c060ef110b971d67a2239883cbf1650a 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -202,7 +202,7 @@ ivas_error TonalMDCTConceal_Init_ivas_fx( //#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT // PMTE() // To be uncommented when field of fixed type is added for scaleFactorsBackground - set16_fx( hTonalMDCTConc->scaleFactorsBackground, 0, FDNS_NPTS ); + set32_fx( hTonalMDCTConc->scaleFactorsBackground_fx, 0, FDNS_NPTS ); hTonalMDCTConc->scf_fadeout = 16384 /*1.000000 Q14*/; PsychoacousticParameters_Init( INT_FS_16k, L_FRAME16k, 64, 1, 1, &hTonalMDCTConc->psychParamsTCX20 ); PsychoacousticParameters_Init( INT_FS_16k, L_FRAME16k / 2, 64, 0, 1, &hTonalMDCTConc->psychParamsTCX10 ); @@ -408,17 +408,6 @@ void TonalMDCTConceal_SaveFreqSignal_ivas_fx( IF( LE_16( nNewSamples, L_FRAME_MAX ) ) { /* Shift the buffers */ - -#if 1 // TODO: Remove Float pointer movement - float *temp_flt; - temp_flt = hTonalMDCTConc->secondLastBlockData.spectralData_float; /* Save the pointer */ - hTonalMDCTConc->secondLastBlockData.spectralData_float = hTonalMDCTConc->lastBlockData.spectralData_float; - hTonalMDCTConc->lastBlockData.spectralData_float = temp_flt; - temp_flt = hTonalMDCTConc->secondLastBlockData.scaleFactors_float; - hTonalMDCTConc->secondLastBlockData.scaleFactors_float = hTonalMDCTConc->lastBlockData.scaleFactors_float; - hTonalMDCTConc->lastBlockData.scaleFactors_float = temp_flt; -#endif - temp = hTonalMDCTConc->secondLastBlockData.spectralData; /* Save the pointer */ move16(); hTonalMDCTConc->secondLastBlockData.spectralData = hTonalMDCTConc->lastBlockData.spectralData; @@ -464,14 +453,6 @@ void TonalMDCTConceal_SaveFreqSignal_ivas_fx( ELSE { /* Order the buffers so that even transition frame can fit in if written into the first buffer */ - -#if 1 /* TODO: remove float code */ - hTonalMDCTConc->lastBlockData.spectralData_float = hTonalMDCTConc->spectralDataBuffers_float[0]; - hTonalMDCTConc->secondLastBlockData.spectralData_float = hTonalMDCTConc->spectralDataBuffers_float[1]; - hTonalMDCTConc->lastBlockData.scaleFactors_float = hTonalMDCTConc->scaleFactorsBuffers_float[0]; - hTonalMDCTConc->secondLastBlockData.scaleFactors_float = hTonalMDCTConc->scaleFactorsBuffers_float[1]; -#endif - hTonalMDCTConc->lastBlockData.spectralData = hTonalMDCTConc->spectralDataBuffers[0]; move16(); hTonalMDCTConc->secondLastBlockData.spectralData = hTonalMDCTConc->spectralDataBuffers[1]; @@ -513,12 +494,6 @@ void TonalMDCTConceal_SaveFreqSignal_ivas_fx( } hTonalMDCTConc->last_block_nrg_exp = 31 - ( ( 15 - mdctSpectrum_exp ) * 2 - 16 ); -#if 1 /* TODO: remove float code */ - FOR( i = 0; i < nNewSamples; i++ ) - { - hTonalMDCTConc->lastBlockData.spectralData_float[i] = me2f( mdctSpectrum[i], mdctSpectrum_exp ); - } -#endif /* Store new data */ s = getScaleFactor32( mdctSpectrum, nNewSamples ); @@ -543,13 +518,6 @@ void TonalMDCTConceal_SaveFreqSignal_ivas_fx( hTonalMDCTConc->lastBlockData.gain_tcx_exp = gain_tcx_exp; Copy( scaleFactors, hTonalMDCTConc->lastBlockData.scaleFactors, hTonalMDCTConc->nScaleFactors ); - -#if 1 /* TODO: remove float code. */ - for ( i = 0; i < hTonalMDCTConc->nScaleFactors; i++ ) - { - hTonalMDCTConc->lastBlockData.scaleFactors_float[i] = me2f_16( scaleFactors[i], hTonalMDCTConc->lastBlockData.scaleFactors_exp[i] ); - } -#endif } return; @@ -2801,8 +2769,6 @@ void TonalMDCTConceal_Apply_ivas_fx( const PsychoacousticParameters *psychParamsCurrent ) { - /* TODO: change pTCI to pTCI in this function. */ - Word16 i, l; Word16 *phaseDiff, *pCurrentPhase; Word32 phaseToAdd; @@ -2812,10 +2778,8 @@ void TonalMDCTConceal_Apply_ivas_fx( Word16 nSamples; Word16 nBands; - /* TODO: remove this later. */ - Word16 *tmp_secondLastPowerSpectrum = (Word16 *)malloc(hTonalMDCTConc->nNonZeroSamples * sizeof(Word16)); - Word16 tmp_secondLastPowerSpectrum_exp; - f2me_buf_16(hTonalMDCTConc->secondLastPowerSpectrum_float, tmp_secondLastPowerSpectrum, &tmp_secondLastPowerSpectrum_exp, hTonalMDCTConc->nNonZeroSamples); + Word16 *tmp_secondLastPowerSpectrum = hTonalMDCTConc->secondLastPowerSpectrum; + Word16 tmp_secondLastPowerSpectrum_exp = hTonalMDCTConc->secondLastPowerSpectrum_exp; Word16 max_nSamples = s_max(hTonalMDCTConc->nNonZeroSamples, hTonalMDCTConc->nSamplesCore); @@ -2835,7 +2799,7 @@ void TonalMDCTConceal_Apply_ivas_fx( nSamples = hTonalMDCTConc->nNonZeroSamples; move16(); assert( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1] < nSamples ); - //mvr2r( hTonalMDCTConc->secondLastPowerSpectrum_float, powerSpectrum_flt, nSamples ); /* Convert from 16 bits to 32 bits */ + FOR (i = 0; i < nSamples; i++) { powerSpectrum[i] = L_deposit_h(tmp_secondLastPowerSpectrum[i]); @@ -2961,9 +2925,6 @@ void TonalMDCTConceal_Apply_ivas_fx( } } - /* TODO: remove this later. */ - free(tmp_secondLastPowerSpectrum); - hTonalMDCTConc->nFramesLost = add(hTonalMDCTConc->nFramesLost, 2); /*Q1*/ move16(); diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index fb421900391ce77ecc172f5823b9919559daba3c..ef7b6f36afc65425a0ef374a49a3ff3dc35af34c 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -2696,169 +2696,160 @@ ivas_error ivas_rend_openCrend( const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, HRTFS_CREND_HANDLE hSetOfHRTF, - const int32_t output_Fs ) + const Word32 output_Fs ) { - int16_t i, subframe_length; - int16_t max_total_ir_len; + Word16 i, subframe_length; + Word16 max_total_ir_len; HRTFS_HANDLE hHrtf; CREND_HANDLE hCrend; ivas_error error; error = IVAS_ERR_OK; - if ( ( error = ivas_rend_initCrendWrapper( pCrend ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_rend_initCrendWrapper( pCrend ) ) != IVAS_ERR_OK ) { return error; } - subframe_length = (int16_t) ( output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES; + subframe_length = extract_l(Mult_32_16( output_Fs , 164));/*( output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES(i/o:164=(32768/FRAMES_PER_SEC)/MAX_PARAM_SPATIAL_SUBFRAMES*/ - if ( ( *pCrend )->hHrtfCrend == NULL ) + IF ( ( *pCrend )->hHrtfCrend == NULL ) { -#ifdef IVAS_FLOAT_FIXED -#if 1 /*Cleanup changes: float to fixed*/ - IF( hSetOfHRTF ) - { - hSetOfHRTF->hHRTF_brir_combined->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_brir_combined->latency_s, 31 ); - hSetOfHRTF->hHRTF_hrir_foa->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_hrir_foa->latency_s, 31 ); - hSetOfHRTF->hHRTF_hrir_combined->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_hrir_combined->latency_s, 31 ); - hSetOfHRTF->hHRTF_hrir_hoa3->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_hrir_hoa3->latency_s, 31 ); - hSetOfHRTF->hHRTF_hrir_hoa2->latency_s_fx = floatToFixed( hSetOfHRTF->hHRTF_hrir_hoa2->latency_s, 31 ); - floatToFixed_arr( hSetOfHRTF->hHRTF_brir_combined->inv_diffuse_weight, hSetOfHRTF->hHRTF_brir_combined->inv_diffuse_weight_fx, 15, 16 ); - floatToFixed_arr( hSetOfHRTF->hHRTF_hrir_combined->inv_diffuse_weight, hSetOfHRTF->hHRTF_hrir_combined->inv_diffuse_weight_fx, 15, 16 ); - floatToFixed_arr( hSetOfHRTF->hHRTF_hrir_hoa3->inv_diffuse_weight, hSetOfHRTF->hHRTF_hrir_hoa3->inv_diffuse_weight_fx, 15, 16 ); - floatToFixed_arr( hSetOfHRTF->hHRTF_hrir_hoa2->inv_diffuse_weight, hSetOfHRTF->hHRTF_hrir_hoa2->inv_diffuse_weight_fx, 15, 16 ); - floatToFixed_arr( hSetOfHRTF->hHRTF_hrir_foa->inv_diffuse_weight, hSetOfHRTF->hHRTF_hrir_foa->inv_diffuse_weight_fx, 15, 16 ); - } IF ( ( error = ivas_rend_initCrend_fx( *pCrend, inConfig, outConfig, hSetOfHRTF, output_Fs ) ) != IVAS_ERR_OK ) { return error; } -#if 1/*Cleanup changes: float to fixed*/ - ( *pCrend )->hHrtfCrend->gain_lfe = fixedToFloat( ( *pCrend )->hHrtfCrend->gain_lfe_fx, 14 ); - ( *pCrend )->hHrtfCrend->latency_s = fixedToFloat( ( *pCrend )->hHrtfCrend->latency_s_fx, 31 ); - fixedToFloat_arr( ( *pCrend )->hHrtfCrend->inv_diffuse_weight_fx, ( *pCrend )->hHrtfCrend->inv_diffuse_weight, 15, 16 ); -#endif -#endif // 1 -#else - if ( ( error = ivas_rend_initCrend( *pCrend, inConfig, outConfig, hSetOfHRTF, output_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif } { hCrend = ( *pCrend )->hCrend; hHrtf = ( *pCrend )->hHrtfCrend; - if ( hHrtf != NULL ) + IF ( hHrtf != NULL ) { - max_total_ir_len = hHrtf->max_num_iterations * subframe_length; + max_total_ir_len = imult1616(hHrtf->max_num_iterations , subframe_length); - for ( i = 0; i < hHrtf->max_num_ir; i++ ) + FOR ( i = 0; i < hHrtf->max_num_ir; i++ ) { - if ( ( hCrend->freq_buffer_re[i] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) +#if 1/*TODO: Floating point memory allocation:To be removed later*/ + IF ( ( hCrend->freq_buffer_re[i] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } set_zero( hCrend->freq_buffer_re[i], max_total_ir_len ); - if ( ( hCrend->freq_buffer_re_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + IF ( ( hCrend->freq_buffer_im[i] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } - set_val_Word32( hCrend->freq_buffer_re_fx[i], 0, max_total_ir_len ); + set_zero( hCrend->freq_buffer_im[i], max_total_ir_len ); +#endif - if ( ( hCrend->freq_buffer_im[i] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) + IF ( ( hCrend->freq_buffer_re_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } - set_zero( hCrend->freq_buffer_im[i], max_total_ir_len ); - if ( ( hCrend->freq_buffer_im_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + set_zero_fx( hCrend->freq_buffer_re_fx[i], max_total_ir_len ); + IF ( ( hCrend->freq_buffer_im_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } - set_val_Word32( hCrend->freq_buffer_im_fx[i], 0, max_total_ir_len ); + set_zero_fx( hCrend->freq_buffer_im_fx[i], max_total_ir_len ); } - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + FOR ( i = 0; i < BINAURAL_CHANNELS; i++ ) { - if ( ( hCrend->prev_out_buffer[i] = (float *) malloc( sizeof( float ) * subframe_length ) ) == NULL ) +#if 1/*TODO: Floating point memory allocation:To be removed later*/ + IF ( ( hCrend->prev_out_buffer[i] = (float *) malloc( sizeof( float ) * subframe_length ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } - if ( ( hCrend->prev_out_buffer_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * subframe_length ) ) == NULL ) + set_zero( hCrend->prev_out_buffer[i], subframe_length ); +#endif + IF ( ( hCrend->prev_out_buffer_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * subframe_length ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } - set_zero( hCrend->prev_out_buffer[i], subframe_length ); - set_val_Word32( hCrend->prev_out_buffer_fx[i], 0, subframe_length ); + set_zero_fx( hCrend->prev_out_buffer_fx[i], subframe_length ); } - max_total_ir_len = hHrtf->num_iterations_diffuse[0] * subframe_length; + max_total_ir_len = imult1616((Word16)hHrtf->num_iterations_diffuse[0] , subframe_length); - if ( max_total_ir_len > 0 ) + IF ( GT_16(max_total_ir_len , 0) ) { +#if 1/*TODO: Floating point memory allocation:To be removed later*/ if ( ( hCrend->freq_buffer_re_diffuse = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } set_zero( hCrend->freq_buffer_re_diffuse, max_total_ir_len ); - if ( ( hCrend->freq_buffer_re_diffuse_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + if ( ( hCrend->freq_buffer_im_diffuse = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } - set_val_Word32( hCrend->freq_buffer_re_diffuse_fx, 0, max_total_ir_len ); - if ( ( hCrend->freq_buffer_im_diffuse = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) + set_zero( hCrend->freq_buffer_im_diffuse, max_total_ir_len ); +#endif // + IF ( ( hCrend->freq_buffer_re_diffuse_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } - set_zero( hCrend->freq_buffer_im_diffuse, max_total_ir_len ); - if ( ( hCrend->freq_buffer_im_diffuse_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + set_zero_fx( hCrend->freq_buffer_re_diffuse_fx,max_total_ir_len ); + IF ( ( hCrend->freq_buffer_im_diffuse_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } - set_val_Word32( hCrend->freq_buffer_im_diffuse_fx, 0, max_total_ir_len ); + set_zero_fx( hCrend->freq_buffer_im_diffuse_fx,max_total_ir_len ); } - else + ELSE { +#if 1/*TODO: Floating point memory allocation:To be removed later*/ hCrend->freq_buffer_re_diffuse = NULL; - hCrend->freq_buffer_re_diffuse_fx = NULL; hCrend->freq_buffer_im_diffuse = NULL; +#endif // + hCrend->freq_buffer_re_diffuse_fx = NULL; hCrend->freq_buffer_im_diffuse_fx = NULL; } - max_total_ir_len = (int16_t) ( hHrtf->latency_s * output_Fs + 0.5f ) + subframe_length; - if ( max_total_ir_len > 0 ) + max_total_ir_len = add(extract_l(L_shr(L_add(L_shl(Mult_32_32(hHrtf->latency_s_fx , output_Fs),1) , 1) ,1)) , subframe_length);/*(int16_t) ( hHrtf->latency_s * output_Fs + 0.5f ) + subframe_length;*/ + IF ( GT_16(max_total_ir_len , 0) ) { - if ( ( hCrend->lfe_delay_line = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) +#if 1/*TODO: Floating point memory allocation:To be removed later*/ + IF ( ( hCrend->lfe_delay_line = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } set_zero( hCrend->lfe_delay_line, max_total_ir_len ); +#endif + IF ( ( hCrend->lfe_delay_line_fx = (Word32 *) malloc( sizeof(Word32) * max_total_ir_len ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + set_zero_fx( hCrend->lfe_delay_line_fx, max_total_ir_len ); } - else + ELSE { +#if 1/*TODO: Floating point memory allocation:To be removed later*/ hCrend->lfe_delay_line = NULL; +#endif + hCrend->lfe_delay_line_fx = NULL; } - if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + IF ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - if ( ( error = ivas_reverb_open( &( hCrend->hReverb ), inConfig, ( *pCrend )->hHrtfCrend, NULL, hRendCfg, output_Fs ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_reverb_open( &( hCrend->hReverb ), inConfig, ( *pCrend )->hHrtfCrend,NULL, hRendCfg, output_Fs ) ) != IVAS_ERR_OK ) { return error; } - if ( hRendCfg->roomAcoustics.use_er == 1 ) + IF ( EQ_16(hRendCfg->roomAcoustics.use_er , 1) ) { /* Allocate memory for reflections */ hCrend->reflections = (er_struct_t *) malloc( sizeof( er_struct_t ) ); - if ( !hCrend->reflections ) + IF ( !hCrend->reflections ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Early Reflections" ); } - if ( ( error = ivas_er_init_handle( hCrend->reflections ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_er_init_handle( hCrend->reflections ) ) != IVAS_ERR_OK ) { return error; } @@ -2867,55 +2858,35 @@ ivas_error ivas_rend_openCrend( hCrend->reflections->lowComplexity = hRendCfg->roomAcoustics.lowComplexity; /* Set sample rate and frame size */ -#ifndef IVAS_FLOAT_FIXED - hCrend->reflections->output_Fs = (float) output_Fs; -#else - hCrend->reflections->output_Fs_fx = (Word32) output_Fs; -#endif - hCrend->reflections->max_frame_size = (int16_t) ( output_Fs / FRAMES_PER_SEC ); -#ifdef IVAS_FLOAT_FIXED - hRendCfg->roomAcoustics.dimensions.x_fx = (Word32)(hRendCfg->roomAcoustics.dimensions.x * 4194304); // Q10.22, min value:1, max :999.0 - hRendCfg->roomAcoustics.dimensions.y_fx = (Word32)(hRendCfg->roomAcoustics.dimensions.y * 4194304); // Q10.22 - hRendCfg->roomAcoustics.dimensions.z_fx = (Word32)(hRendCfg->roomAcoustics.dimensions.z * 4194304); // Q10.22 - - - for ( int ii = 0; ii < 6; ii++ ) - { - hRendCfg->roomAcoustics.AbsCoeff_fx[ii] = (Word32)(hRendCfg->roomAcoustics.AbsCoeff[ii] * 1073741824); // Q2.30 min :0 max 1 - } - - hRendCfg->roomAcoustics.ListenerOrigin.x_fx = (Word32)(hRendCfg->roomAcoustics.ListenerOrigin.x * 4194304); //( 2147483648 >> 2 ); - hRendCfg->roomAcoustics.ListenerOrigin.y_fx = (Word32)(hRendCfg->roomAcoustics.ListenerOrigin.y * ( 4194304 )); - hRendCfg->roomAcoustics.ListenerOrigin.z_fx = (Word32)(hRendCfg->roomAcoustics.ListenerOrigin.z * ( 4194304 )); + hCrend->reflections->output_Fs_fx = (Word32) output_Fs; -#endif + hCrend->reflections->max_frame_size = extract_l(Mult_32_16( output_Fs , INV_FRAME_PER_SEC_Q15)); /* Init Shoebox */ ivas_shoebox_config_init( &hCrend->reflections->shoebox_lib.cal, hRendCfg ); /* Init and compute Reflections */ - if ( ( error = ivas_er_init( hCrend->reflections, inConfig ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_er_init( hCrend->reflections, inConfig ) ) != IVAS_ERR_OK ) { return error; } } - else + ELSE { hCrend->reflections = NULL; } } - else + ELSE { hCrend->hReverb = NULL; } - ( *pCrend )->binaural_latency_ns = (int32_t) ( ( *pCrend )->hHrtfCrend->latency_s * 1000000000.f ); + ( *pCrend )->binaural_latency_ns = Mult_32_32( ( *pCrend )->hHrtfCrend->latency_s_fx , (Word32)1000000000 ); } ( *pCrend )->hCrend = hCrend; } - return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 8e633488e9d742bbe4c0a63efc94e69328a85234..d4757ad4db2f7d527db973837fdf30653e8296d6 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -114,7 +114,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices( DIRAC_DEC_BIN static void ivas_dirac_dec_binaural_process_output( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], float *output_f[], float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t max_band_decorr, const int16_t numInChannels, const int16_t processReverb, const int16_t subframe ); #ifdef IVAS_FLOAT_FIXED -static void ivas_dirac_dec_binaural_process_output_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], Word32 *output_fx[], Word16 *q_out,Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const Word16 max_band_decorr, const Word16 numInChannels, const Word16 processReverb, const Word16 subframe ); +static void ivas_dirac_dec_binaural_process_output_fx(DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], Word32 *output_fx[], Word16 *q_out, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const Word16 q_inp, const Word16 max_band_decorr, const Word16 numInChannels, const Word16 processReverb, const Word16 subframe, const Word16 q_mat); #endif static void adaptTransportSignalsHeadtracked( COMBINED_ORIENTATION_HANDLE hHeadTrackData, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t nBins, const int16_t nSlots, float Rmat[3][3] ); @@ -1451,6 +1451,8 @@ static void ivas_dirac_dec_binaural_internal( Word32 *output_fx[MAX_OUTPUT_CHANNELS]; Word32 output_fx_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; Word16 q_out; + Word16 q_mat = 15; + Word16 q_inp = Q6; FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { output_fx[ch] = output_fx_buff[ch]; @@ -1459,36 +1461,61 @@ static void ivas_dirac_dec_binaural_internal( { FOR( slot = 0; slot < BINAURAL_CHANNELS; slot++ ) { - floatToFixed_arr16( hDiracDecBin->processMtxDecRe[ch][slot], hDiracDecBin->processMtxDecRe_fx[ch][slot], Q11, nBins ); - floatToFixed_arr16( hDiracDecBin->processMtxDecIm[ch][slot], hDiracDecBin->processMtxDecIm_fx[ch][slot], Q11, nBins ); - floatToFixed_arr16( hDiracDecBin->processMtxDecRePrev[ch][slot], hDiracDecBin->processMtxDecRePrev_fx[ch][slot], Q11, nBins ); - floatToFixed_arr16( hDiracDecBin->processMtxDecImPrev[ch][slot], hDiracDecBin->processMtxDecImPrev_fx[ch][slot], Q11, nBins ); + q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxDecRe[ch][slot], nBins ) ); + q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxDecIm[ch][slot], nBins ) ); + q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxDecRePrev[ch][slot], nBins ) ); + q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxDecImPrev[ch][slot], nBins ) ); } } FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { FOR( slot = 0; slot < 4; slot++ ) { - floatToFixed_arr16( hDiracDecBin->processMtxRe[ch][slot], hDiracDecBin->processMtxRe_fx[ch][slot], Q11, nBins ); - floatToFixed_arr16( hDiracDecBin->processMtxIm[ch][slot], hDiracDecBin->processMtxIm_fx[ch][slot], Q11, nBins ); - floatToFixed_arr16( hDiracDecBin->processMtxRePrev[ch][slot], hDiracDecBin->processMtxRePrev_fx[ch][slot], Q11, nBins ); - floatToFixed_arr16( hDiracDecBin->processMtxImPrev[ch][slot], hDiracDecBin->processMtxImPrev_fx[ch][slot], Q11, nBins ); + q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxRe[ch][slot], nBins ) ); + q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxIm[ch][slot], nBins ) ); + q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxRePrev[ch][slot], nBins ) ); + q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxImPrev[ch][slot], nBins ) ); + } + } + q_mat = sub(q_mat, 1) ; //guardbits// + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + output_fx[ch] = output_fx_buff[ch]; + } + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + FOR( slot = 0; slot < BINAURAL_CHANNELS; slot++ ) + { + floatToFixed_arr16( hDiracDecBin->processMtxDecRe[ch][slot], hDiracDecBin->processMtxDecRe_fx[ch][slot], q_mat, nBins ); + floatToFixed_arr16( hDiracDecBin->processMtxDecIm[ch][slot], hDiracDecBin->processMtxDecIm_fx[ch][slot], q_mat, nBins ); + floatToFixed_arr16( hDiracDecBin->processMtxDecRePrev[ch][slot], hDiracDecBin->processMtxDecRePrev_fx[ch][slot], q_mat, nBins ); + floatToFixed_arr16( hDiracDecBin->processMtxDecImPrev[ch][slot], hDiracDecBin->processMtxDecImPrev_fx[ch][slot], q_mat, nBins ); + } + } + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + FOR( slot = 0; slot < 4; slot++ ) + { + floatToFixed_arr16( hDiracDecBin->processMtxRe[ch][slot], hDiracDecBin->processMtxRe_fx[ch][slot], q_mat, nBins ); + floatToFixed_arr16( hDiracDecBin->processMtxIm[ch][slot], hDiracDecBin->processMtxIm_fx[ch][slot], q_mat, nBins ); + floatToFixed_arr16( hDiracDecBin->processMtxRePrev[ch][slot], hDiracDecBin->processMtxRePrev_fx[ch][slot], q_mat, nBins ); + floatToFixed_arr16( hDiracDecBin->processMtxImPrev[ch][slot], hDiracDecBin->processMtxImPrev_fx[ch][slot], q_mat, nBins ); } floatToFixed_arrL( st_ivas->cldfbSynDec[ch]->cldfb_state, st_ivas->cldfbSynDec[ch]->cldfb_state_fx, Q11, st_ivas->cldfbSynDec[ch]->p_filter_length ); st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; } FOR( Word16 cha = 0; cha < 6; cha++ ) FOR( slot = 0; slot < 4; slot++ ) - FOR( Word16 ind = 0; ind < 60; ind++ ) + FOR( Word16 ind = 0; ind < 60; ind++ ) { - Cldfb_RealBuffer_in_fx[cha][slot][ind] = float_to_fix( Cldfb_RealBuffer_in[cha][slot][ind], Q6 ); - Cldfb_ImagBuffer_in_fx[cha][slot][ind] = float_to_fix( Cldfb_ImagBuffer_in[cha][slot][ind], Q6 ); + Cldfb_RealBuffer_in_fx[cha][slot][ind] = float_to_fix( Cldfb_RealBuffer_in[cha][slot][ind], q_inp); + Cldfb_ImagBuffer_in_fx[cha][slot][ind] = float_to_fix( Cldfb_ImagBuffer_in[cha][slot][ind], q_inp); } - ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, max_band_decorr, numInChannels, config_data.processReverb, subframe ); + ivas_dirac_dec_binaural_process_output_fx(hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat); FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - fixedToFloat_arrL32( output_fx[ch], output_f[ch], q_out, imult1616(nBins , hSpatParamRendCom->subframe_nbslots[subframe]) ); + fixedToFloat_arrL32( output_fx[ch], output_f[ch], q_out, imult1616( nBins, hSpatParamRendCom->subframe_nbslots[subframe] ) ); fixedToFloat_arrL32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_state, st_ivas->cldfbSynDec[ch]->Q_cldfb_state, st_ivas->cldfbSynDec[ch]->p_filter_length ); } #else @@ -2329,10 +2356,12 @@ static void ivas_dirac_dec_binaural_process_output_fx( Word16 *q_out, Word32 inRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 inIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + const Word16 q_input, const Word16 max_band_decorr, const Word16 numInChannels, const Word16 processReverb, - const Word16 subframe ) + const Word16 subframe, + const Word16 q_mat) { Word16 slot, bin, chA, chB; Word16 nBins; @@ -2377,12 +2406,14 @@ static void ivas_dirac_dec_binaural_process_output_fx( q_inp_mix = s_min( q_inp[i][j], q_inp_mix ); } } + + q_inp_mix = sub( q_inp_mix, 3 ); // gaurded bits// - Word16 cldfb_state_shift = sub(add(q_inp_mix, Q1), cldfbSynDec[0]->Q_cldfb_state); - IF(GT_16(cldfb_state_shift, shift)) + Word16 cldfb_state_shift = sub( add( add( q_inp_mix, q_mat ), sub( q_input, 16 ) ), cldfbSynDec[0]->Q_cldfb_state ); + IF( GT_16( cldfb_state_shift, shift ) ) { - q_inp_mix = q_inp_mix + shift - cldfb_state_shift; - cldfb_state_shift = shift; + q_inp_mix = q_inp_mix + shift - cldfb_state_shift; + cldfb_state_shift = shift; } FOR( Word16 i = 0; i < 6; i++ ) @@ -2394,20 +2425,20 @@ static void ivas_dirac_dec_binaural_process_output_fx( scale_sig32(inIm_fx[i][j], nBins, q_inp_mix); IF( processReverb && ( i < 2 ) ) { - scale_sig32(reverbRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub(q_inp_mix, 4)); - scale_sig32(reverbIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub(q_inp_mix, 4)); + scale_sig32( reverbRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( add( q_inp_mix, q_mat ), 15 ) ); + scale_sig32( reverbIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( add( q_inp_mix, q_mat ), 15 ) ); } } } // scaling cldfb states to q_result-1// - scale_sig32(cldfbSynDec[0]->cldfb_state_fx, cldfbSynDec[0]->p_filter_length, cldfb_state_shift); - scale_sig32(cldfbSynDec[1]->cldfb_state_fx, cldfbSynDec[1]->p_filter_length, cldfb_state_shift); + scale_sig32( cldfbSynDec[0]->cldfb_state_fx, cldfbSynDec[0]->p_filter_length, cldfb_state_shift ); + scale_sig32( cldfbSynDec[1]->cldfb_state_fx, cldfbSynDec[1]->p_filter_length, cldfb_state_shift ); - q_inp_mix = add(q_inp_mix, Q6); + q_inp_mix = add( q_inp_mix, q_input ); interpVal_fx = 0; - Word16 q_result = sub( q_inp_mix, 4 ); // setting it prior// + Word16 q_result = sub( add( q_inp_mix, q_mat ), 15 ); // setting it prior// cldfbSynDec[0]->Q_cldfb_state = sub( q_result, 1 ); cldfbSynDec[1]->Q_cldfb_state = sub( q_result, 1 ); @@ -4173,6 +4204,32 @@ static void ivas_masa_ext_rend_parambin_internal( Word32 Cldfb_RealBuffer_in_fx[6][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_in_fx[6][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word16 q_out; + Word16 q_mat = 15; + Word16 q_inp = Q6; + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + output_fx[ch] = output_fx_buff[ch]; + } + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + FOR( slot = 0; slot < BINAURAL_CHANNELS; slot++ ) + { + q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxDecRe[ch][slot], nBins ) ); + q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxDecIm[ch][slot], nBins ) ); + q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxDecRePrev[ch][slot], nBins ) ); + q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxDecImPrev[ch][slot], nBins ) ); + } + } + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + FOR( slot = 0; slot < 4; slot++ ) + { + q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxRe[ch][slot], nBins ) ); + q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxIm[ch][slot], nBins ) ); + q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxRePrev[ch][slot], nBins ) ); + q_mat = s_min( q_mat, Q_factor_arr( hDiracDecBin->processMtxImPrev[ch][slot], nBins ) ); + } + } FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { output_fx[ch] = output_fx_buff[ch]; @@ -4181,32 +4238,32 @@ static void ivas_masa_ext_rend_parambin_internal( { FOR( slot = 0; slot < BINAURAL_CHANNELS; slot++ ) { - floatToFixed_arr16( hDiracDecBin->processMtxDecRe[ch][slot], hDiracDecBin->processMtxDecRe_fx[ch][slot], Q11, nBins ); - floatToFixed_arr16( hDiracDecBin->processMtxDecIm[ch][slot], hDiracDecBin->processMtxDecIm_fx[ch][slot], Q11, nBins ); - floatToFixed_arr16( hDiracDecBin->processMtxDecRePrev[ch][slot], hDiracDecBin->processMtxDecRePrev_fx[ch][slot], Q11, nBins ); - floatToFixed_arr16( hDiracDecBin->processMtxDecImPrev[ch][slot], hDiracDecBin->processMtxDecImPrev_fx[ch][slot], Q11, nBins ); + floatToFixed_arr16( hDiracDecBin->processMtxDecRe[ch][slot], hDiracDecBin->processMtxDecRe_fx[ch][slot], q_mat, nBins ); + floatToFixed_arr16( hDiracDecBin->processMtxDecIm[ch][slot], hDiracDecBin->processMtxDecIm_fx[ch][slot], q_mat, nBins ); + floatToFixed_arr16( hDiracDecBin->processMtxDecRePrev[ch][slot], hDiracDecBin->processMtxDecRePrev_fx[ch][slot], q_mat, nBins ); + floatToFixed_arr16( hDiracDecBin->processMtxDecImPrev[ch][slot], hDiracDecBin->processMtxDecImPrev_fx[ch][slot], q_mat, nBins ); } } FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { FOR( slot = 0; slot < 4; slot++ ) { - floatToFixed_arr16( hDiracDecBin->processMtxRe[ch][slot], hDiracDecBin->processMtxRe_fx[ch][slot], Q11, nBins ); - floatToFixed_arr16( hDiracDecBin->processMtxIm[ch][slot], hDiracDecBin->processMtxIm_fx[ch][slot], Q11, nBins ); - floatToFixed_arr16( hDiracDecBin->processMtxRePrev[ch][slot], hDiracDecBin->processMtxRePrev_fx[ch][slot], Q11, nBins ); - floatToFixed_arr16( hDiracDecBin->processMtxImPrev[ch][slot], hDiracDecBin->processMtxImPrev_fx[ch][slot], Q11, nBins ); + floatToFixed_arr16( hDiracDecBin->processMtxRe[ch][slot], hDiracDecBin->processMtxRe_fx[ch][slot], q_mat, nBins ); + floatToFixed_arr16( hDiracDecBin->processMtxIm[ch][slot], hDiracDecBin->processMtxIm_fx[ch][slot], q_mat, nBins ); + floatToFixed_arr16( hDiracDecBin->processMtxRePrev[ch][slot], hDiracDecBin->processMtxRePrev_fx[ch][slot], q_mat, nBins ); + floatToFixed_arr16( hDiracDecBin->processMtxImPrev[ch][slot], hDiracDecBin->processMtxImPrev_fx[ch][slot], q_mat, nBins ); } floatToFixed_arrL( hMasaExtRend->cldfbSynRend[ch]->cldfb_state, hMasaExtRend->cldfbSynRend[ch]->cldfb_state_fx, Q11, hMasaExtRend->cldfbSynRend[ch]->p_filter_length ); hMasaExtRend->cldfbSynRend[ch]->Q_cldfb_state = Q11; } FOR( Word16 cha = 0; cha < 6; cha++ ) FOR( slot = 0; slot < 4; slot++ ) - FOR( Word16 ind = 0; ind < 60; ind++ ) + FOR( Word16 ind = 0; ind < 60; ind++ ) { Cldfb_RealBuffer_in_fx[cha][slot][ind] = float_to_fix( Cldfb_RealBuffer_in[cha][slot][ind], Q6 ); Cldfb_ImagBuffer_in_fx[cha][slot][ind] = float_to_fix( Cldfb_ImagBuffer_in[cha][slot][ind], Q6 ); } - ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, max_band_decorr, numInChannels, config_data.processReverb, subframe ); + ivas_dirac_dec_binaural_process_output_fx(hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat); FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 11033bef8369cb41c30e8ff82712b74910365ae5..82b1c2dad6599a60a287ae148fcf741efef87a28 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -815,6 +815,13 @@ void ivas_dirac_rend_close_fx( free(hDirACRend->hoa_encoder); hDirACRend->hoa_encoder = NULL; } +#ifdef IVAS_FLOAT_FIXED + IF (hDirACRend->hoa_encoder_fx != NULL) + { + free(hDirACRend->hoa_encoder_fx); + hDirACRend->hoa_encoder_fx = NULL; + } +#endif /* prototype indexing */ IF (hDirACRend->proto_index_dir != NULL) @@ -832,11 +839,19 @@ void ivas_dirac_rend_close_fx( /* States */ /* free prototype signal buffers */ +#if 1 /* TODO: remove float code */ IF (hDirACRend->proto_frame_f != NULL) { free(hDirACRend->proto_frame_f); hDirACRend->proto_frame_f = NULL; } +#endif + IF (hDirACRend->proto_frame_f_fx != NULL) + { + free(hDirACRend->proto_frame_f_fx); + hDirACRend->proto_frame_f_fx = NULL; + } + FOR (i = 0; i < DIRAC_NUM_DIMS; i++) { @@ -921,6 +936,13 @@ void ivas_dirac_rend_close( free( hDirACRend->hoa_encoder ); hDirACRend->hoa_encoder = NULL; } +#ifdef IVAS_FLOAT_FIXED + IF( hDirACRend->hoa_encoder_fx != NULL ) + { + free( hDirACRend->hoa_encoder_fx ); + hDirACRend->hoa_encoder_fx = NULL; + } +#endif /* prototype indexing */ if ( hDirACRend->proto_index_dir != NULL ) @@ -1448,10 +1470,14 @@ ivas_error ivas_dirac_alloc_mem( hDirAC_mem->proto_power_diff_smooth = NULL; hDirAC_mem->direct_responses_square = NULL; #ifdef IVAS_FLOAT_FIXED - hDirAC_mem->direct_responses_square_fx = NULL; hDirAC_mem->proto_power_smooth_fx = NULL; + hDirAC_mem->proto_power_diff_smooth_fx = NULL; + hDirAC_mem->direct_responses_square_fx = NULL; #endif hDirAC_mem->frame_dec_f = NULL; +#ifdef IVAS_FLOAT_FIXED + hDirAC_mem->frame_dec_f_fx = NULL; +#endif if ( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) { if ( ( hDirAC_mem->cy_auto_dir_smooth = (float *) malloc( sizeof( float ) * size ) ) == NULL ) @@ -1478,6 +1504,15 @@ ivas_error ivas_dirac_alloc_mem( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } set_zero( hDirAC_mem->proto_power_diff_smooth, size ); +#ifdef IVAS_FLOAT_FIXED + if ( ( hDirAC_mem->proto_power_diff_smooth_fx = (Word32 *) malloc( sizeof( Word32 ) * size ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); + } + set32_fx( hDirAC_mem->proto_power_diff_smooth_fx, 0, size ); + hDirAC_mem->proto_power_diff_smooth_len = size; + hDirAC_mem->proto_power_diff_smooth_q = 31; +#endif if ( ( hDirAC_mem->direct_responses_square = (float *) malloc( sizeof( float ) * size ) ) == NULL ) { @@ -1498,12 +1533,22 @@ ivas_error ivas_dirac_alloc_mem( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } +#ifdef IVAS_FLOAT_FIXED + if ( ( hDirAC_mem->frame_dec_f_fx = (Word32 *) malloc( sizeof( Word32 ) * 2 * num_outputs_diff * num_freq_bands ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); + } + hDirAC_mem->frame_dec_f_len = 2 * num_outputs_diff * num_freq_bands; +#endif } } hDirACRend->h_output_synthesis_psd_state.proto_power_smooth = hDirAC_mem->proto_power_smooth; hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth = hDirAC_mem->proto_power_diff_smooth; hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth = hDirAC_mem->cy_auto_dir_smooth; #ifdef IVAS_FLOAT_FIXED + hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx = hDirAC_mem->proto_power_diff_smooth_fx; + hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q = hDirAC_mem->proto_power_diff_smooth_q; + hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_len = hDirAC_mem->proto_power_diff_smooth_len; hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx = hDirAC_mem->cy_auto_dir_smooth_fx; hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth = 0; move16(); @@ -1627,6 +1672,7 @@ ivas_error ivas_dirac_alloc_mem( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } + hDirAC_mem->proto_diffuse_buffer_f_len = 2 * MAX_PARAM_SPATIAL_SUBFRAMES * size; #endif } else @@ -1640,6 +1686,7 @@ ivas_error ivas_dirac_alloc_mem( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } + hDirAC_mem->proto_diffuse_buffer_f_len = 2 * MAX_PARAM_SPATIAL_SUBFRAMES * num_outputs_diff * num_freq_bands; #endif } } @@ -1649,6 +1696,8 @@ ivas_error ivas_dirac_alloc_mem( #ifdef IVAS_FLOAT_FIXED hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx = hDirAC_mem->proto_direct_buffer_f_fx; hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx = hDirAC_mem->proto_diffuse_buffer_f_fx; + hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len = hDirAC_mem->proto_diffuse_buffer_f_len; + hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q = hDirAC_mem->proto_diffuse_buffer_f_q; #endif /* Gains/power factors*/ hDirAC_mem->direct_power_factor = NULL; @@ -1785,10 +1834,16 @@ void ivas_dirac_free_mem_fx( { free( hDirAC_mem->proto_power_smooth_fx ); } +#if 1 /* todo: remove float */ IF (hDirAC_mem->proto_power_diff_smooth != NULL) { free(hDirAC_mem->proto_power_diff_smooth); } +#endif + IF (hDirAC_mem->proto_power_diff_smooth_fx != NULL) + { + free(hDirAC_mem->proto_power_diff_smooth_fx); + } IF (hDirAC_mem->direct_responses_square != NULL) { free(hDirAC_mem->direct_responses_square); @@ -1797,10 +1852,16 @@ void ivas_dirac_free_mem_fx( { free(hDirAC_mem->direct_responses_square_fx); } + IF (hDirAC_mem->frame_dec_f_fx != NULL) + { + free(hDirAC_mem->frame_dec_f_fx); + } +#if 1 /* TODO: remove float free */ IF (hDirAC_mem->frame_dec_f != NULL) { free(hDirAC_mem->frame_dec_f); } +#endif IF (hDirAC_mem->cy_cross_dir_smooth != NULL) { free(hDirAC_mem->cy_cross_dir_smooth); @@ -1829,10 +1890,12 @@ void ivas_dirac_free_mem_fx( { free( hDirAC_mem->proto_direct_buffer_f_fx ); } +#if 1 /* TODO: remove float free */ IF (hDirAC_mem->proto_diffuse_buffer_f != NULL) { free(hDirAC_mem->proto_diffuse_buffer_f); } +#endif IF( hDirAC_mem->proto_diffuse_buffer_f_fx != NULL ) { free( hDirAC_mem->proto_diffuse_buffer_f_fx ); @@ -4180,6 +4243,127 @@ void protoSignalComputation4( * Compute diffuse prototype buffer and smooth power, only for decorrelated bands *------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void ivas_dirac_dec_compute_diffuse_proto_fx( + DIRAC_REND_HANDLE hDirACRend, + const Word16 num_freq_bands, + const Word16 slot_idx /* i : slot index */ +) +{ + Word16 k, l; + Word16 num_freq_bands_diff; + DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params; + DIRAC_OUTPUT_SYNTHESIS_STATE *h_dirac_output_synthesis_state; + Word16 m; + + Word32 *proto_frame_dec_f_fx; + Word32 *p_diff_buffer_fx, *p_diff_buffer_1_fx; + Word32 *p_proto_diff_fx, *p_power_smooth_fx; + Word32 *p_hoa_enc_fx; + + proto_frame_dec_f_fx = hDirACRend->proto_frame_dec_f_fx; + h_dirac_output_synthesis_params = &( hDirACRend->h_output_synthesis_psd_params ); + h_dirac_output_synthesis_state = &( hDirACRend->h_output_synthesis_psd_state ); + + num_freq_bands_diff = h_dirac_output_synthesis_params->max_band_decorr; + move16(); + + IF( num_freq_bands_diff == 0 ) + { + return; + } + + p_diff_buffer_fx = h_dirac_output_synthesis_state->proto_diffuse_buffer_f_fx + imult1616( shl( imult1616( slot_idx, num_freq_bands_diff ), 1 ), hDirACRend->hOutSetup.nchan_out_woLFE ); + p_diff_buffer_1_fx = p_diff_buffer_fx + 1; + p_power_smooth_fx = h_dirac_output_synthesis_state->proto_power_diff_smooth_fx; + + Word16 diffuse_start = slot_idx * 2 * num_freq_bands_diff * hDirACRend->hOutSetup.nchan_out_woLFE; + Word16 diff_e, smooth_e, proto_e, max_e; + Word32 diff_square, diff_square_1, diff_square_sum; + Word16 diff_square_e; + Word16 old_diff_e; + diff_e = sub( 31, h_dirac_output_synthesis_state->proto_diffuse_buffer_f_q ); + old_diff_e = diff_e; + smooth_e = sub( 31, h_dirac_output_synthesis_state->proto_power_diff_smooth_q ); + proto_e = sub( 31, hDirACRend->proto_frame_dec_f_q ); + + IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_PSD_SHD ) + { + diff_square_e = add( shl( proto_e, 1 ), 1 ); + max_e = add( s_max( diff_square_e, smooth_e ), 1 ); + Scale_sig32( p_power_smooth_fx, h_dirac_output_synthesis_state->proto_power_diff_smooth_len, sub( smooth_e, max_e ) ); + FOR( k = 0; k < hDirACRend->hOutSetup.nchan_out_woLFE; k++ ) + { + p_proto_diff_fx = proto_frame_dec_f_fx + shl( imult1616( k, num_freq_bands ), 1 ); + FOR( l = 0; l < num_freq_bands_diff; l++ ) + { + *p_diff_buffer_fx = *( p_proto_diff_fx++ ); + *p_diff_buffer_1_fx = *( p_proto_diff_fx++ ); + + diff_square = Mpy_32_32( *p_diff_buffer_fx, *p_diff_buffer_fx ) >> 1; // 2 * proto_e + 1 + diff_square_1 = Mpy_32_32( *p_diff_buffer_1_fx, *p_diff_buffer_1_fx ) >> 1; // 2 * proto_e + 1 + diff_square_sum = L_add( diff_square, diff_square_1 ); + diff_square_sum = L_shr( diff_square_sum, sub( max_e, diff_square_e ) ); + *p_power_smooth_fx = L_add( *p_power_smooth_fx, diff_square_sum ); + + p_power_smooth_fx++; + p_diff_buffer_fx += 2; + p_diff_buffer_1_fx += 2; + } + } + diff_e = proto_e; + } + ELSE + { + /*DIRAC_SYNTHESIS_PSD_SHD: Virtual LS->HOA encoding*/ + Word16 gb = find_guarded_bits_fx( hDirACRend->num_outputs_diff ); + diff_square_e = add( shl( add( 2, add( proto_e, gb ) ), 1 ), 1 ); + max_e = add( s_max( diff_square_e, smooth_e ), 1 ); + Scale_sig32( p_power_smooth_fx, h_dirac_output_synthesis_state->proto_power_diff_smooth_len, sub( smooth_e, max_e ) ); + FOR( k = 0; k < hDirACRend->hOutSetup.nchan_out_woLFE; k++ ) + { + FOR( l = 0; l < num_freq_bands_diff; l++ ) + { + p_hoa_enc_fx = hDirACRend->hoa_encoder_fx + k; + p_proto_diff_fx = proto_frame_dec_f_fx + shl( l, 1 ); + + *p_diff_buffer_fx = 0; + *p_diff_buffer_1_fx = 0; + + /*LS to HOA*/ + FOR( m = 0; m < hDirACRend->num_outputs_diff; m++ ) + { + *p_diff_buffer_fx = L_add( *p_diff_buffer_fx, L_shr( Mpy_32_32( *p_hoa_enc_fx, *p_proto_diff_fx ), gb ) ); + *p_diff_buffer_1_fx = L_add( *p_diff_buffer_1_fx, L_shr( Mpy_32_32( *p_hoa_enc_fx, *( p_proto_diff_fx + 1 ) ), gb ) ); + p_hoa_enc_fx += hDirACRend->hOutSetup.nchan_out_woLFE; + p_proto_diff_fx += shl( num_freq_bands, 1 ); + } + + diff_square = L_shr( Mpy_32_32( *p_diff_buffer_fx, *p_diff_buffer_fx ), 1 ); // 2*(2 + proto_e + gb) + 1 + diff_square_1 = L_shr( Mpy_32_32( *p_diff_buffer_1_fx, *p_diff_buffer_1_fx ), 1 ); // 2*(2 + proto_e + gb) + 1 + diff_square_sum = L_add( diff_square, diff_square_1 ); + diff_square_sum = L_shr( diff_square_sum, max_e - diff_square_e ); + *p_power_smooth_fx = L_add( *p_power_smooth_fx, diff_square_sum ); + + p_power_smooth_fx++; + + p_diff_buffer_fx += 2; + p_diff_buffer_1_fx += 2; + } + } + diff_e = add( add( 2, proto_e ), gb ); + } + h_dirac_output_synthesis_state->proto_power_diff_smooth_q = sub( 31, max_e ); + + Word16 new_diff_e = s_max( diff_e, old_diff_e ); + Scale_sig32( h_dirac_output_synthesis_state->proto_diffuse_buffer_f_fx, diffuse_start, sub( old_diff_e, new_diff_e ) ); + Scale_sig32( h_dirac_output_synthesis_state->proto_diffuse_buffer_f_fx + diffuse_start, + sub( h_dirac_output_synthesis_state->proto_diffuse_buffer_f_len, diffuse_start ), sub( diff_e, new_diff_e ) ); + h_dirac_output_synthesis_state->proto_diffuse_buffer_f_q = sub( 31, new_diff_e ); + + return; +} +#endif void ivas_dirac_dec_compute_diffuse_proto( DIRAC_REND_HANDLE hDirACRend, const int16_t num_freq_bands, @@ -4256,7 +4440,6 @@ void ivas_dirac_dec_compute_diffuse_proto( return; } - /*------------------------------------------------------------------------- * computeDirectionAngles() * @@ -5338,7 +5521,35 @@ static void ivas_masa_ext_dirac_render_sf( if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_LS || hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_SHD ) { /* Compute diffuse prototypes */ +#ifdef IVAS_FLOAT_FIXED_u + /* Float to fixed */ + if (hDirACRend->h_output_synthesis_psd_params.max_band_decorr != 0) + { + f2me_buf(hDirACRend->proto_frame_dec_f, hDirACRend->proto_frame_dec_f_fx, &hDirACRend->proto_frame_dec_f_q, hDirACRend->proto_frame_dec_f_len); + hDirACRend->proto_frame_dec_f_q = 31 - hDirACRend->proto_frame_dec_f_q; + DIRAC_OUTPUT_SYNTHESIS_STATE *state = &(hDirACRend->h_output_synthesis_psd_state); + f2me_buf(state->proto_power_diff_smooth, state->proto_power_diff_smooth_fx, &state->proto_power_diff_smooth_q, state->proto_power_diff_smooth_len); + state->proto_power_diff_smooth_q = 31 - state->proto_power_diff_smooth_q; + f2me_buf(state->proto_diffuse_buffer_f, state->proto_diffuse_buffer_f_fx, &state->proto_diffuse_buffer_f_q, state->proto_diffuse_buffer_f_len); + state->proto_diffuse_buffer_f_q = 31 - state->proto_diffuse_buffer_f_q; + } + ivas_dirac_dec_compute_diffuse_proto_fx( hDirACRend, hSpatParamRendCom->num_freq_bands, slot_idx ); + /* Fixed to float */ + if (hDirACRend->h_output_synthesis_psd_params.max_band_decorr != 0) + { + DIRAC_OUTPUT_SYNTHESIS_STATE *state = &(hDirACRend->h_output_synthesis_psd_state); + me2f_buf(state->proto_power_diff_smooth_fx, + 31 - state->proto_power_diff_smooth_q, + state->proto_power_diff_smooth, + state->proto_power_diff_smooth_len); + me2f_buf(state->proto_diffuse_buffer_f_fx, + 31 - state->proto_diffuse_buffer_f_q, + state->proto_diffuse_buffer_f, + state->proto_diffuse_buffer_f_len); + } +#else ivas_dirac_dec_compute_diffuse_proto( hDirACRend, hSpatParamRendCom->num_freq_bands, slot_idx ); +#endif } ivas_dirac_dec_output_synthesis_process_slot( reference_power, diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index b5caa3539b431cc089ac3b6aa8552ecb502b91da..2ec9ce5f60aa3f5899f00e40bdc634306fcd1902 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -569,6 +569,13 @@ void ivas_dirac_dec_compute_diffuse_proto( const int16_t num_freq_bands, const int16_t slot_idx ); +#ifdef IVAS_FLOAT_FIXED +void ivas_dirac_dec_compute_diffuse_proto_fx( + DIRAC_REND_HANDLE hDirACRend, + const Word16 num_freq_bands, + const Word16 slot_idx /* i : slot index */ +); +#endif void computeDirectionAngles( float *intensity_real_x, @@ -1501,7 +1508,7 @@ ivas_error ivas_rend_openCrend( const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, HRTFS_CREND_HANDLE hSetOfHRTF, - const int32_t output_Fs + const Word32 output_Fs ); void ivas_rend_closeCrend( @@ -1625,6 +1632,16 @@ void ivas_binaural_reverb_processSubframe_fx( ); #endif +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_reverb_open( + REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ + const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ + const HRTFS_HANDLE hHrtf, /* i : HRTF handle */ + const Word32 *lr_energy_and_iac_fx[], /* i : precomuputed lr energies and iac */ + RENDER_CONFIG_HANDLE hRenderConfig, /* i : Renderer configuration handle */ + const int32_t output_Fs /* i : output sampling rate */ +); +#else ivas_error ivas_reverb_open( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ @@ -1633,6 +1650,7 @@ ivas_error ivas_reverb_open( RENDER_CONFIG_DATA *pConfig, /* i : Reverb configuration */ const int32_t output_Fs /* i : output sampling rate */ ); +#endif // IVAS_FLOAT_FIXED void ivas_reverb_close( REVERB_HANDLE *hReverb /* i/o: Reverberator handle */ @@ -1732,8 +1750,8 @@ void ivas_reverb_iir_filt_init( void ivas_reverb_iir_filt_set( ivas_rev_iir_filter_t *iirFilter, /* i/o: IIR filter */ UWord16 nr_taps, /* i : number of IIR filter taps */ - const float *coefA, /* i : A filter coefficients to set */ - const float *coefB /* i : the B filter coefficients to set */ + const Word16 *coefA, /* i : A filter coefficients to set */ + const Word16 *coefB /* i : the B filter coefficients to set */ ); void ivas_reverb_iir_filt_2taps_feed_blk_fx( ivas_rev_iir_filter_t *iirFilter, /* i/o: IIR filter */ @@ -1841,6 +1859,10 @@ void ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR( const int16_t fft_size ); #ifdef IVAS_FLOAT_FIXED +void ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR_fx( + rv_fftwf_type_complex_fx *spectrum, + Word32 *fft_real, + const Word16 fft_size); void ivas_reverb_define_window_fft_fx( Word32 *pWindow, //output in Q31 const Word16 transitionStart, @@ -1862,8 +1884,8 @@ Word16 ivas_reverb_calc_color_filters_fx( const Word32 *pWindow, const Word16 fft_size, const Word16 delay, - Word32 **pBeqL, - Word32 **pBeqR, + rv_fftwf_type_complex_fx *pBeqL, + rv_fftwf_type_complex_fx *pBeqR, Word16 *q_pBeqL, Word16 *q_pBeqR ); @@ -1884,8 +1906,8 @@ Word16 ivas_reverb_calc_correl_filters_fx( const Word32 *pWindow, //input in Q30 const Word16 fft_size, const Word16 delay, - Word32 **pU, //input in Q31 - Word32 **pV, //input in Q31 + rv_fftwf_type_complex_fx *pU, //input in Q31 + rv_fftwf_type_complex_fx *pV, //input in Q31 Word16 *q_pU, //Output q Word16 *q_pV //output q ); @@ -2292,6 +2314,12 @@ void ivas_render_config_close( RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ ); +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_render_config_init_from_rom_fx( + RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ +); +#endif + ivas_error ivas_render_config_init_from_rom( RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ ); diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c index c51c0e16153a1efa262fd5c3168c8f6c506b9c2f..31bada63e30f378f615812cc0900daff05a6e9cb 100644 --- a/lib_rend/ivas_render_config.c +++ b/lib_rend/ivas_render_config.c @@ -37,7 +37,7 @@ #include "ivas_rom_rend.h" #include "ivas_rom_TdBinauralRenderer.h" #include "wmc_auto.h" - +#include "prot_fx1.h" /*-----------------------------------------------------------------------* * Local constants @@ -97,6 +97,41 @@ void ivas_render_config_close( * Initializes the renderer configuration structure from ROM *-------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_render_config_init_from_rom_fx( + RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ +) +{ + Word16 i; + IF( hRenderConfig == NULL || *hRenderConfig == NULL ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Unexpected null pointer while attempting to fill renderer configuration from ROM" ); + } + ( *hRenderConfig )->roomAcoustics.override = FALSE; + ( *hRenderConfig )->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_N_BANDS; + ( *hRenderConfig )->roomAcoustics.acousticPreDelay = IVAS_REVERB_DEFAULT_PRE_DELAY; + ( *hRenderConfig )->roomAcoustics.inputPreDelay = IVAS_REVERB_DEFAULT_INPUT_DELAY; + ( *hRenderConfig )->roomAcoustics.use_er = IVAS_REVERB_DEFAULT_USE_ER; + set32_fx( &( *hRenderConfig )->roomAcoustics.pFc_input_fx[0], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( &( *hRenderConfig )->roomAcoustics.pAcoustic_rt60_fx[0], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( &( *hRenderConfig )->roomAcoustics.pAcoustic_dsr_fx[0], 0, CLDFB_NO_CHANNELS_MAX ); + + Copy32( ivas_reverb_default_fc_fx, ( *hRenderConfig )->roomAcoustics.pFc_input_fx, IVAS_REVERB_DEFAULT_N_BANDS ); + Copy32( ivas_reverb_default_RT60_fx, ( *hRenderConfig )->roomAcoustics.pAcoustic_rt60_fx, IVAS_REVERB_DEFAULT_N_BANDS ); + Copy32( ivas_reverb_default_DSR_fx, ( *hRenderConfig )->roomAcoustics.pAcoustic_dsr_fx, IVAS_REVERB_DEFAULT_N_BANDS ); + + /*Q6*/ + FOR( i = 0; i < MAX_NUM_OBJECTS; i++ ) + { + ( *hRenderConfig )->directivity_fx[i * 3] = 23040; /* Front cone */ + ( *hRenderConfig )->directivity_fx[i * 3 + 1] = 23040; /* Back cone */ + ( *hRenderConfig )->directivity_fx[i * 3 + 2] = 64; /* Back attenuation */ + } + + return IVAS_ERR_OK; +} +#endif + ivas_error ivas_render_config_init_from_rom( RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ ) @@ -127,4 +162,4 @@ ivas_error ivas_render_config_init_from_rom( } return IVAS_ERR_OK; -} +} \ No newline at end of file diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 92c7681eb27dca99893a87aff2588aa1ac3c4b84..55375c9bde30944affffcc4544dba843982ac0b3 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -81,6 +81,10 @@ static Word16 wrap_rad_fixed( /* should be a divisor of the frame length at any sampling rate and an even number*/ #define FFT_FILTER_WND_FLAT_REGION ( 0.40f ) /* flat section (==1) length of FFT filter window, in proportion to overlap */ #define FFT_FILTER_WND_TRANS_REGION ( 0.15f ) /* transition (1->0) length of FFT filter window, in proportion to overlap */ +#ifdef IVAS_FLOAT_FIXED +#define FFT_FILTER_WND_FLAT_REGION_FX ( 26214 )/*Q16 flat section (==1) length of FFT filter window, in proportion to overlap */ +#define FFT_FILTER_WND_TRANS_REGION_FX ( 9830 ) /*Q16 transition (1->0) length of FFT filter window, in proportion to overlap */ +#endif // IVAS_FLOAT_FIXED #define REF_LF_MIN ( 100.0f ) #define REF_LF_MAX ( 250.0f ) #define REF_HF_MIN ( 5000.0f ) @@ -1494,6 +1498,29 @@ static ivas_error initialize_reverb_filters( * Sets t60 number of taps and coefficients A and B *-----------------------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +static ivas_error set_t60_filter( + REVERB_HANDLE hReverb, + const UWord16 branch, + const UWord16 nr_taps, + const Word16 coefA[], + const Word16 coefB[] ) +{ + IF ( GE_32(branch , hReverb->nr_of_branches) ) + { + return IVAS_ERR_INTERNAL; + } + + IF ( GT_32(nr_taps , IVAS_REV_MAX_IIR_FILTER_LENGTH) ) + { + return IVAS_ERR_INTERNAL; + } + + ivas_reverb_iir_filt_set( &( hReverb->t60[branch] ), nr_taps, coefA, coefB ); + + return IVAS_ERR_OK; +} +#else static ivas_error set_t60_filter( REVERB_HANDLE hReverb, const uint16_t branch, @@ -1515,6 +1542,7 @@ static ivas_error set_t60_filter( return IVAS_ERR_OK; } +#endif #ifdef IVAS_FLOAT_FIXED /*-----------------------------------------------------------------------------------------* @@ -1593,20 +1621,20 @@ static ivas_error set_feedback_gain_fx( static ivas_error set_correl_fft_filter( REVERB_HANDLE hReverb, const UWord16 channel, - rv_fftwf_type_complex *pSpectrum ) + rv_fftwf_type_complex_fx *pSpectrum ) { - if ( channel > 1 ) + IF ( GT_32(channel , 1) ) { return IVAS_ERR_INTERNAL; } - if ( channel == 0 ) + IF ( EQ_32(channel , 0) ) { - ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR( pSpectrum, hReverb->fft_filter_correl_0.fft_spectrum, hReverb->fft_filter_correl_0.fft_size ); + ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR_fx( pSpectrum, hReverb->fft_filter_correl_0.fft_spectrum_fx, hReverb->fft_filter_correl_0.fft_size ); } - else + ELSE { - ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR( pSpectrum, hReverb->fft_filter_correl_1.fft_spectrum, hReverb->fft_filter_correl_1.fft_size ); + ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR_fx( pSpectrum, hReverb->fft_filter_correl_1.fft_spectrum_fx, hReverb->fft_filter_correl_1.fft_size ); } return IVAS_ERR_OK; @@ -1622,20 +1650,20 @@ static ivas_error set_correl_fft_filter( static ivas_error set_color_fft_filter( REVERB_HANDLE hReverb, const UWord16 channel, - rv_fftwf_type_complex *pSpectrum ) + rv_fftwf_type_complex_fx *pSpectrum ) { - if ( channel > 1 ) + IF ( GT_32(channel , 1) ) { return IVAS_ERR_INTERNAL; } - if ( channel == 0 ) + IF ( EQ_32(channel , 0) ) { - ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR( pSpectrum, hReverb->fft_filter_color_0.fft_spectrum, hReverb->fft_filter_color_0.fft_size ); + ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR_fx( pSpectrum, hReverb->fft_filter_color_0.fft_spectrum_fx, hReverb->fft_filter_color_0.fft_size ); } else { - ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR( pSpectrum, hReverb->fft_filter_color_1.fft_spectrum, hReverb->fft_filter_color_1.fft_size ); + ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR_fx( pSpectrum, hReverb->fft_filter_color_1.fft_spectrum_fx, hReverb->fft_filter_color_1.fft_size ); } return IVAS_ERR_OK; @@ -2121,13 +2149,13 @@ static ivas_error setup_FDN_branches( REVERB_HANDLE hReverb, ivas_reverb_params_t *pParams ) { - int16_t nr_coefs, branch_idx, channel_idx; + Word16 nr_coefs, branch_idx, channel_idx; ivas_error error; - float *pCoef_a, *pCoef_b; + Word16 *pCoef_a, *pCoef_b; error = IVAS_ERR_OK; /* initialize feedback branches */ - for ( branch_idx = 0; branch_idx < IVAS_REV_MAX_NR_BRANCHES; branch_idx++ ) + FOR ( branch_idx = 0; branch_idx < IVAS_REV_MAX_NR_BRANCHES; branch_idx++ ) { ivas_rev_delay_line_init( &( hReverb->delay_line[branch_idx] ), hReverb->loop_delay_buffer_fx[branch_idx], init_loop_delay[branch_idx], pParams->pLoop_delays[branch_idx] ); ivas_reverb_iir_filt_init( &( hReverb->t60[branch_idx] ), IVAS_REV_MAX_IIR_FILTER_LENGTH ); @@ -2135,38 +2163,38 @@ static ivas_error setup_FDN_branches( hReverb->mixer_fx[1][branch_idx] = 0; } clear_buffers( hReverb ); - nr_coefs = pParams->t60_filter_order + 1; + nr_coefs = add(pParams->t60_filter_order , 1); - if ( IVAS_REV_MAX_IIR_FILTER_LENGTH < nr_coefs ) + IF ( LT_16(IVAS_REV_MAX_IIR_FILTER_LENGTH , nr_coefs) ) { return IVAS_ERR_INTERNAL; } - else + ELSE { - for ( branch_idx = 0; branch_idx < pParams->nr_loops; branch_idx++ ) + FOR ( branch_idx = 0; branch_idx < pParams->nr_loops; branch_idx++ ) { - pCoef_a = &pParams->pT60_filter_coeff[2 * nr_coefs * branch_idx + nr_coefs]; - pCoef_b = &pParams->pT60_filter_coeff[2 * nr_coefs * branch_idx]; + pCoef_a = &pParams->pT60_filter_coeff_fx[2 * nr_coefs * branch_idx + nr_coefs];/*Q14*/ + pCoef_b = &pParams->pT60_filter_coeff_fx[2 * nr_coefs * branch_idx];/*Q14*/ - if ( ( error = set_t60_filter( hReverb, branch_idx, nr_coefs, pCoef_a, pCoef_b ) ) != IVAS_ERR_OK ) + IF ( ( error = set_t60_filter( hReverb, branch_idx, nr_coefs, pCoef_a, pCoef_b ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = set_feedback_delay( hReverb, branch_idx, pParams->pLoop_delays[branch_idx] ) ) != IVAS_ERR_OK ) + IF ( ( error = set_feedback_delay( hReverb, branch_idx, pParams->pLoop_delays[branch_idx] ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = set_feedback_gain_fx( hReverb, branch_idx, &( pParams->pLoop_feedback_matrix_fx[branch_idx * pParams->nr_loops] ) ) ) != IVAS_ERR_OK ) + IF ( ( error = set_feedback_gain_fx( hReverb, branch_idx, &( pParams->pLoop_feedback_matrix_fx[branch_idx * pParams->nr_loops] ) ) ) != IVAS_ERR_OK ) { return error; } } } - for ( channel_idx = 0; channel_idx < pParams->nr_outputs; channel_idx++ ) + FOR ( channel_idx = 0; channel_idx < pParams->nr_outputs; channel_idx++ ) { - if ( ( error = set_mixer_level_fx( hReverb, channel_idx, &( pParams->pLoop_extract_matrix_fx[channel_idx * pParams->nr_loops] ) ) ) != IVAS_ERR_OK ) + IF ( ( error = set_mixer_level_fx( hReverb, channel_idx, &( pParams->pLoop_extract_matrix_fx[channel_idx * pParams->nr_loops] ) ) ) != IVAS_ERR_OK ) { return error; } @@ -2250,159 +2278,107 @@ ivas_error ivas_reverb_open( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ const HRTFS_HANDLE hHrtf, /* i : HRTF handle */ - const float *lr_energy_and_iac[], /* i : precomuputed lr energies and iac */ + const Word32 *lr_energy_and_iac_fx[], /* i : precomuputed lr energies and iac */ RENDER_CONFIG_HANDLE hRenderConfig, /* i : Renderer configuration handle */ const int32_t output_Fs /* i : output sampling rate */ ) { ivas_error error; REVERB_HANDLE pState = NULL; - int16_t bin_idx, subframe_len, output_frame, predelay_bf_len, loop_idx; + Word16 bin_idx, subframe_len, output_frame, predelay_bf_len, loop_idx; ivas_reverb_params_t params; - rv_fftwf_type_complex pFft_wf_filter_ch0[RV_LENGTH_NR_FC]; - rv_fftwf_type_complex pFft_wf_filter_ch1[RV_LENGTH_NR_FC]; - float pColor_target_l[RV_LENGTH_NR_FC]; - float pColor_target_r[RV_LENGTH_NR_FC]; - float pTime_window[RV_FILTER_MAX_FFT_SIZE]; - float freq_step; - int16_t fft_hist_size, transition_start, transition_length; - int16_t nr_fc_input, nr_fc_fft_filter; + Word16 *pCoeffs_fx = params.pT60_filter_coeff_fx; + Word32 pColor_target_l_fx[RV_LENGTH_NR_FC]; + Word32 pColor_target_r_fx[RV_LENGTH_NR_FC]; + Word32 pTime_window_fx[RV_FILTER_MAX_FFT_SIZE]; + Word32 freq_step_fx; + Word16 fft_hist_size, transition_start, transition_length; + Word16 nr_fc_input, nr_fc_fft_filter; + rv_fftwf_type_complex_fx pFft_wf_filter_ch0_fx[RV_LENGTH_NR_FC]; + rv_fftwf_type_complex_fx pFft_wf_filter_ch1_fx[RV_LENGTH_NR_FC]; error = IVAS_ERR_OK; - output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); - subframe_len = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; + output_frame = extract_l(Mult_32_16( output_Fs , INV_FRAME_PER_SEC_Q15)); + subframe_len = shr(output_frame , 2); /*output_frame / MAX_PARAM_SPATIAL_SUBFRAMES*/ predelay_bf_len = output_frame; nr_fc_input = hRenderConfig->roomAcoustics.nBands; /* Allocate main reverb. handle */ - if ( ( pState = (REVERB_HANDLE) malloc( sizeof( REVERB_DATA ) ) ) == NULL ) + IF ( ( pState = (REVERB_HANDLE) malloc( sizeof( REVERB_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Reverberator " ); } - if ( ( error = set_base_config( ¶ms, output_Fs ) ) != IVAS_ERR_OK ) + IF ( ( error = set_base_config( ¶ms, output_Fs ) ) != IVAS_ERR_OK ) { return error; } /* Allocate memory for feedback delay lines */ - for ( loop_idx = 0; loop_idx < IVAS_REV_MAX_NR_BRANCHES; loop_idx++ ) + FOR ( loop_idx = 0; loop_idx < IVAS_REV_MAX_NR_BRANCHES; loop_idx++ ) { - if ( ( pState->loop_delay_buffer_fx[loop_idx] = (Word32 *) malloc( params.pLoop_delays[loop_idx] * sizeof( float ) ) ) == NULL ) + IF ( ( pState->loop_delay_buffer_fx[loop_idx] = (Word32 *) malloc( params.pLoop_delays[loop_idx] * sizeof( Word32 ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CREND Reverberator" ); } } /* Allocate memory for the pre-delay delay line */ - if ( ( pState->pPredelay_buffer_fx = (Word32 *) malloc( output_frame * sizeof( float ) ) ) == NULL ) + IF ( ( pState->pPredelay_buffer_fx = (Word32 *) malloc( output_frame * sizeof(Word32) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CREND Reverberator" ); } pState->nr_of_branches = IVAS_REV_MAX_NR_BRANCHES; set_fft_and_datablock_sizes( pState, subframe_len ); - nr_fc_fft_filter = ( pState->fft_size >> 1 ) + 1; + nr_fc_fft_filter = add( extract_l( L_shr( pState->fft_size, 1 ) ), 1 ); /* === 'Control logic': compute the reverb processing parameters from the === */ /* === room, source and listener acoustic information provided in the reverb config === */ /* Setting up shared temporary buffers for fc, RT60, DSR, etc. */ - params.pHrtf_avg_pwr_response_l = &pFft_wf_filter_ch0[0][0]; - params.pHrtf_avg_pwr_response_r = params.pHrtf_avg_pwr_response_l + nr_fc_fft_filter; - params.pRt60 = &pFft_wf_filter_ch1[0][0]; - params.pDsr = params.pRt60 + nr_fc_fft_filter; - params.pFc = &pState->fft_filter_color_0.fft_spectrum[0]; - params.pHrtf_inter_aural_coherence = &pState->fft_filter_color_1.fft_spectrum[0]; - + params.pHrtf_avg_pwr_response_l_fx = &pFft_wf_filter_ch0_fx[0][0]; + params.pHrtf_avg_pwr_response_r_fx = params.pHrtf_avg_pwr_response_l_fx + nr_fc_fft_filter; + params.pRt60_fx = &pFft_wf_filter_ch1_fx[0][0]; + params.pDsr_fx = params.pRt60_fx + nr_fc_fft_filter; + params.pFc_fx = &pState->fft_filter_color_0.fft_spectrum_fx[0]; + params.pHrtf_inter_aural_coherence_fx = &pState->fft_filter_color_1.fft_spectrum_fx[0]; /* Note: these temp buffers can only be used before the final step of the FFT filter design : */ /* before calls to ivas_reverb_calc_correl_filters(...) or to ivas_reverb_calc_color_filters(...) */ /* set the uniform frequency grid for FFT filtering */ - freq_step = 0.5f * output_Fs / ( nr_fc_fft_filter - 1 ); - for ( bin_idx = 0; bin_idx < nr_fc_fft_filter; bin_idx++ ) + freq_step_fx = L_mult0( extract_l(L_shr(output_Fs,2)), div_s( 1, ( nr_fc_fft_filter - 1 ) ) );/*Q14:0.5f * output_Fs / ( nr_fc_fft_filter - 1 )*/ + FOR ( bin_idx = 0; bin_idx < nr_fc_fft_filter; bin_idx++ ) { - params.pFc[bin_idx] = freq_step * bin_idx; + params.pFc_fx[bin_idx] = W_extract_l(W_mult0_32_32(freq_step_fx , bin_idx));/*Q14*/ } - if ( hHrtf == NULL && lr_energy_and_iac != NULL ) + IF ( hHrtf == NULL && lr_energy_and_iac_fx != NULL ) { - params.pHrtf_avg_pwr_response_l_const = lr_energy_and_iac[0]; - params.pHrtf_avg_pwr_response_r_const = lr_energy_and_iac[1]; - params.pHrtf_inter_aural_coherence_const = lr_energy_and_iac[2]; + params.pHrtf_avg_pwr_response_l_const_fx = lr_energy_and_iac_fx[0]; + params.pHrtf_avg_pwr_response_r_const_fx = lr_energy_and_iac_fx[1]; + params.pHrtf_inter_aural_coherence_const_fx = lr_energy_and_iac_fx[2]; } /* set up reverb acoustic data on the basis of HRTF data and renderer config */ - -#ifdef IVAS_FLOAT_FIXED - Word32 *pRt60_fx = (Word32 *)malloc(sizeof(Word32) * nr_fc_fft_filter); - Word32 *pFc_fx = (Word32 *)malloc(sizeof(Word32) * nr_fc_fft_filter); + Scale_sig32( params.pFc_fx, nr_fc_fft_filter, 2 ); Word16 *pRt60_e = (Word16 *)malloc(sizeof(Word16) * nr_fc_fft_filter); - Word32 *pDsr_fx = (Word32 *)malloc(sizeof(Word32) * nr_fc_fft_filter); Word16 *pDsr_e = (Word16 *)malloc(sizeof(Word16) * nr_fc_fft_filter); - Word32 *pHrtf_avg_pwr_response_l_fx = (Word32*)malloc(nr_fc_fft_filter * sizeof(Word32)); - Word32 *pHrtf_avg_pwr_response_r_fx = (Word32*)malloc(nr_fc_fft_filter * sizeof(Word32)); - Word32 *pHrtf_inter_aural_coherence_fx = (Word32*)malloc(nr_fc_fft_filter * sizeof(Word32)); - params.pRt60_fx = pRt60_fx; - params.pFc_fx = pFc_fx; params.pRt60_e = pRt60_e; - params.pDsr_fx = pDsr_fx; params.pDsr_e = pDsr_e; - params.pHrtf_avg_pwr_response_l_fx = pHrtf_avg_pwr_response_l_fx; - params.pHrtf_avg_pwr_response_r_fx = pHrtf_avg_pwr_response_r_fx; - params.pHrtf_inter_aural_coherence_fx = pHrtf_inter_aural_coherence_fx; - - for (int i = 0; i < nr_fc_fft_filter; i++) - { - params.pFc_fx[i] = (Word32)(params.pFc[i] * ONE_IN_Q16); - } - - for (int i = 0; i < 60; i++) - { - hRenderConfig->roomAcoustics.pFc_input_fx[i] = (Word32)(hRenderConfig->roomAcoustics.pFc_input[i] * ONE_IN_Q16); - hRenderConfig->roomAcoustics.pAcoustic_rt60_fx[i] = (Word32)((hRenderConfig->roomAcoustics.pAcoustic_rt60[i]) * ONE_IN_Q26); - hRenderConfig->roomAcoustics.pAcoustic_dsr_fx[i] = (Word32)(hRenderConfig->roomAcoustics.pAcoustic_dsr[i] * ONE_IN_Q30); - } - - hRenderConfig->roomAcoustics.inputPreDelay_fx = (Word32) (hRenderConfig->roomAcoustics.inputPreDelay * ONE_IN_Q27 ); - hRenderConfig->roomAcoustics.acousticPreDelay_fx = (Word32) (hRenderConfig->roomAcoustics.acousticPreDelay * ONE_IN_Q27); set_reverb_acoustic_data_fx( ¶ms, input_audio_config, hHrtf, &hRenderConfig->roomAcoustics, subframe_len, nr_fc_input, nr_fc_fft_filter ); - - for (int i = 0; i < nr_fc_fft_filter; i++) { - params.pRt60[i] = fabsf(me2f(pRt60_fx[i], pRt60_e[i])); - params.pDsr[i] = fabsf(me2f(pDsr_fx[i], pDsr_e[i])); - } - - if (hHrtf != NULL) { - for (int i = 0; i < nr_fc_fft_filter; i++) - { - params.pHrtf_avg_pwr_response_l[i] = (float)params.pHrtf_avg_pwr_response_l_fx[i] / (ONE_IN_Q23); - params.pHrtf_avg_pwr_response_r[i] = (float)params.pHrtf_avg_pwr_response_r_fx[i] / (ONE_IN_Q23); - params.pHrtf_inter_aural_coherence[i] = (float)params.pHrtf_inter_aural_coherence_fx[i] / (ONE_IN_Q27); - } - - params.pHrtf_avg_pwr_response_l_const = (const float *)params.pHrtf_avg_pwr_response_l; - params.pHrtf_avg_pwr_response_r_const = (const float *)params.pHrtf_avg_pwr_response_r; - params.pHrtf_inter_aural_coherence_const = (const float *)params.pHrtf_inter_aural_coherence; + Scale_sig32( params.pFc_fx, nr_fc_fft_filter, -2 ); + for ( int i = 0; i < nr_fc_fft_filter; i++ ) + { + params.pRt60_fx[i] = L_abs(params.pRt60_fx[i]); + params.pDsr_fx[i] = L_abs(params.pDsr_fx[i]); } - free(pRt60_fx); - free(pFc_fx); - free(pRt60_e); - free(pDsr_fx); - free(pDsr_e); - free(pHrtf_avg_pwr_response_l_fx); - free(pHrtf_avg_pwr_response_r_fx); - free(pHrtf_inter_aural_coherence_fx); -#else - set_reverb_acoustic_data( ¶ms, input_audio_config, hHrtf, &hRenderConfig->roomAcoustics, subframe_len, nr_fc_input, nr_fc_fft_filter ); -#endif - /* set reverb acoustic configuration based on renderer config */ pState->pConfig.roomAcoustics.override = hRenderConfig->roomAcoustics.override; pState->pConfig.roomAcoustics.nBands = hRenderConfig->roomAcoustics.nBands; - if ( hRenderConfig->roomAcoustics.use_er == 1 ) + IF ( hRenderConfig->roomAcoustics.use_er == 1 ) { pState->pConfig.roomAcoustics.use_er = hRenderConfig->roomAcoustics.use_er; pState->pConfig.roomAcoustics.lowComplexity = hRenderConfig->roomAcoustics.lowComplexity; @@ -2412,250 +2388,138 @@ ivas_error ivas_reverb_open( pState->dmx_gain_fx = calc_dmx_gain_fx(); /* set up predelay - must be after set_base_config() and before compute_t60_coeffs() */ -#ifdef IVAS_FLOAT_FIXED - hRenderConfig->roomAcoustics.acousticPreDelay_fx = floatToFixed( hRenderConfig->roomAcoustics.acousticPreDelay, 27 ); calc_predelay_fx( ¶ms, hRenderConfig->roomAcoustics.acousticPreDelay_fx, output_Fs ); -#else - calc_predelay( ¶ms, hRenderConfig->roomAcoustics.acousticPreDelay, output_Fs ); -#endif // IVAS_FLOAT_FIXED /* set up jot reverb 60 filters - must be set up after set_reverb_acoustic_data() */ -#ifdef IVAS_FLOAT_FIXED - float *pCoeffs = params.pT60_filter_coeff; - Word16 *pCoeffs_fx = params.pT60_filter_coeff_fx; - params.pRt60_fx = (Word32 *)malloc(sizeof(Word32) * nr_fc_fft_filter); - params.pFc_fx = (Word32 *)malloc(sizeof(Word32) * nr_fc_fft_filter); - params.pRt60_e = (Word16 *)malloc(sizeof(Word16) * nr_fc_fft_filter); - for (int i = 0; i < nr_fc_fft_filter; i++) - { - params.pFc_fx[i] = (Word32)(params.pFc[i] * ONE_IN_Q14); - } - - for (int i = 0; i < nr_fc_fft_filter; i++) - { - f2me(params.pRt60[i], ¶ms.pRt60_fx[i], ¶ms.pRt60_e[i]); - } - - for (int i = 0; i < 64; i++) { - pCoeffs_fx[i] = (Word16)(pCoeffs[i] * ( 1 << 14)); - } - if ( ( error = compute_t60_coeffs_fx( ¶ms, nr_fc_fft_filter, output_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - for (int i = 0; i < 64; i++) { - pCoeffs[i] = (float)pCoeffs_fx[i] / (1 << 14); - } -#else - /* set up jot reverb 60 filters - must be set up after set_reverb_acoustic_data() */ - if ( ( error = compute_t60_coeffs( ¶ms, nr_fc_fft_filter, output_Fs ) ) != IVAS_ERR_OK ) + IF ( ( error = compute_t60_coeffs_fx( ¶ms, nr_fc_fft_filter, output_Fs ) ) != IVAS_ERR_OK ) { return error; } -#endif /* Compute target levels (gains) for the coloration filters */ -#ifdef IVAS_FLOAT_FIXED - Word32 *pFc = (Word32*)malloc(nr_fc_fft_filter * sizeof(Word32*)); - Word32 *pDsr = (Word32*)malloc(nr_fc_fft_filter * sizeof(Word32*)); Word32 *pHrtf_avg_pwr_response_l_const = (Word32*)malloc(nr_fc_fft_filter * sizeof(Word32*)); Word32 *pHrtf_avg_pwr_response_r_const = (Word32*)malloc(nr_fc_fft_filter * sizeof(Word32*)); Word32 *pT60_filter_coeff = (Word32*)malloc((params.nr_loops * 4 + 4) * sizeof(Word32*)); - Word32 *pColor_target_l_fx = (Word32*)malloc(nr_fc_fft_filter * sizeof(Word32*)); - Word32 *pColor_target_r_fx = (Word32*)malloc(nr_fc_fft_filter * sizeof(Word32*)); - for (int i = 0; i < nr_fc_fft_filter; i++) + FOR (int i = 0; i < nr_fc_fft_filter; i++) { - pFc[i] = (Word32)(params.pFc[i] * ONE_IN_Q14); - pDsr[i] = (Word32)(params.pDsr[i] * ONE_IN_Q31); - pHrtf_avg_pwr_response_l_const[i] = (Word32)(params.pHrtf_avg_pwr_response_l_const[i] * ONE_IN_Q28); - pHrtf_avg_pwr_response_r_const[i] = (Word32)(params.pHrtf_avg_pwr_response_r_const[i] * ONE_IN_Q28); + params.pDsr_fx[i] = L_shl(params.pDsr_fx[i] , params.pDsr_e[i]); + pHrtf_avg_pwr_response_l_const[i] = L_shl(params.pHrtf_avg_pwr_response_l_const_fx[i] ,5);/*Q23+5*/ + pHrtf_avg_pwr_response_r_const[i] = L_shl(params.pHrtf_avg_pwr_response_r_const_fx[i] ,5);/*Q23+5*/ } - for (int i = 0; i < params.nr_loops * 4 + 4; i++) + FOR (int i = 0; i < params.nr_loops * 4 + 4; i++) { - pT60_filter_coeff[i] = (Word32)(params.pT60_filter_coeff[i] * ONE_IN_Q31); + pT60_filter_coeff[i] = L_shl_sat(params.pT60_filter_coeff_fx[i] ,17); } - ivas_reverb_calc_color_levels_fx(output_Fs, nr_fc_fft_filter, params.nr_loops, pFc, pDsr, pHrtf_avg_pwr_response_l_const, pHrtf_avg_pwr_response_r_const, + ivas_reverb_calc_color_levels_fx(output_Fs, nr_fc_fft_filter, params.nr_loops, params.pFc_fx, params.pDsr_fx, pHrtf_avg_pwr_response_l_const, pHrtf_avg_pwr_response_r_const, params.pLoop_delays, pT60_filter_coeff, pColor_target_l_fx, pColor_target_r_fx); - for (int i = 0; i < nr_fc_fft_filter; i++) - { - pColor_target_l[i] = (float)pColor_target_l_fx[i] / ONE_IN_Q30; - pColor_target_r[i] = (float)pColor_target_r_fx[i] / ONE_IN_Q30; - } - free(pFc); - free(pDsr); + free(pHrtf_avg_pwr_response_l_const); free(pHrtf_avg_pwr_response_r_const); free(pT60_filter_coeff); -#else - ivas_reverb_calc_color_levels( output_Fs, nr_fc_fft_filter, params.nr_loops, params.pFc, params.pDsr, params.pHrtf_avg_pwr_response_l_const, params.pHrtf_avg_pwr_response_r_const, - params.pLoop_delays, params.pT60_filter_coeff, pColor_target_l, pColor_target_r ); -#endif + /* Defining appropriate windowing parameters for FFT filters to prevent aliasing */ fft_hist_size = pState->fft_size - pState->fft_subblock_size; - transition_start = (int16_t) roundf( FFT_FILTER_WND_FLAT_REGION * fft_hist_size ); - transition_length = (int16_t) roundf( FFT_FILTER_WND_TRANS_REGION * fft_hist_size ); + transition_start = round_fx(L_mult0( FFT_FILTER_WND_FLAT_REGION_FX , fft_hist_size )); + transition_length = round_fx(L_mult0( FFT_FILTER_WND_TRANS_REGION_FX , fft_hist_size )); /* Compute the window used for FFT filters */ -#ifdef IVAS_FLOAT_FIXED - Word32 *pTime_window_fx = (Word32*)malloc(512 * sizeof(Word32*)); ivas_reverb_define_window_fft_fx(pTime_window_fx, transition_start, transition_length, nr_fc_fft_filter); - for (int i = 0; i < RV_FILTER_MAX_FFT_SIZE; i++) { - pTime_window[i] = (float)pTime_window_fx[i] / ONE_IN_Q31; - } - free(pTime_window_fx); -#else - ivas_reverb_define_window_fft( pTime_window, transition_start, transition_length, nr_fc_fft_filter ); -#endif - /* === Now, copy parameters from ivas_reverb_params_t into DSP blocks === */ /* === to be used for subsequent audio signal processing === */ pState->do_corr_filter = params.do_corr_filter; /* clear & init jot reverb fft filters */ - if ( ( error = initialize_reverb_filters( pState ) ) != IVAS_ERR_OK ) + IF ( ( error = initialize_reverb_filters( pState ) ) != IVAS_ERR_OK ) { return error; } -#ifdef IVAS_FLOAT_FIXED - Word32** pFft_wf_filter_ch0_fx = (Word32**)malloc(nr_fc_fft_filter * sizeof(Word32*)); - - for (int i = 0; i < nr_fc_fft_filter; i++) { - pFft_wf_filter_ch0_fx[i] = (Word32*)malloc(2 * sizeof(Word32)); - } - - Word32** pFft_wf_filter_ch1_fx = (Word32**)malloc(nr_fc_fft_filter * sizeof(Word32*)); - - for (int i = 0; i < nr_fc_fft_filter; i++) { - pFft_wf_filter_ch1_fx[i] = (Word32*)malloc(2 * sizeof(Word32)); - } - Word32* pWindow_fx = (Word32*)malloc(512 * sizeof(Word32)); -#endif - if ( pState->do_corr_filter ) + Word16 q_pFft_wf_filter_ch0_fx = 23, q_pFft_wf_filter_ch1_fx = 23; + IF ( pState->do_corr_filter ) { + q_pFft_wf_filter_ch0_fx = 31; + q_pFft_wf_filter_ch1_fx = 31; /* Computing correlation filters on the basis of target IA coherence */ -#ifdef IVAS_FLOAT_FIXED - Word16 q_pFft_wf_filter_ch0_fx, q_pFft_wf_filter_ch1_fx; - - for (int i = 0; i < nr_fc_fft_filter; i++) { - pFft_wf_filter_ch0_fx[i][0] = ((Word32)pFft_wf_filter_ch0[i][0] * ONE_IN_Q31); - pFft_wf_filter_ch0_fx[i][1] = ((Word32)pFft_wf_filter_ch0[i][1] * ONE_IN_Q31); + FOR (int i = 0; i < nr_fc_fft_filter; i++) { + pFft_wf_filter_ch0_fx[i][0] = L_shl_sat(pFft_wf_filter_ch0_fx[i][0] , 8); + pFft_wf_filter_ch0_fx[i][1] = L_shl_sat(pFft_wf_filter_ch0_fx[i][1] , 8); } - for (int i = 0; i < nr_fc_fft_filter; i++) { - pFft_wf_filter_ch1_fx[i][0] = (Word32)(pFft_wf_filter_ch1_fx[i][0] * ONE_IN_Q31); - pFft_wf_filter_ch1_fx[i][1] = (Word32)(pFft_wf_filter_ch1_fx[i][1] * ONE_IN_Q31); + FOR (int i = 0; i < nr_fc_fft_filter; i++) { + pFft_wf_filter_ch1_fx[i][0] = L_shl_sat(pFft_wf_filter_ch1_fx[i][0] ,8); + pFft_wf_filter_ch1_fx[i][1] = L_shl_sat(pFft_wf_filter_ch1_fx[i][1] ,8); } - for (int i = 0; i < RV_FILTER_MAX_FFT_SIZE; i++) { - pWindow_fx[i] = (Word32)(pTime_window[i] * ONE_IN_Q30); + FOR (int i = 0; i < RV_FILTER_MAX_FFT_SIZE; i++) { + pTime_window_fx[i] = L_shr( pTime_window_fx[i], 1 );/*Scaling signal down to 30*/ } Word32* pHrtf_inter_aural_coherence_const = (Word32*)malloc(nr_fc_fft_filter * sizeof(Word32)); - for (int i = 0; i < nr_fc_fft_filter; i++) { - pHrtf_inter_aural_coherence_const[i] = (Word32)(params.pHrtf_inter_aural_coherence_const[i] * ONE_IN_Q30); - } - ivas_reverb_calc_correl_filters_fx(pHrtf_inter_aural_coherence_const, pWindow_fx, pState->fft_size, 0, pFft_wf_filter_ch0_fx, pFft_wf_filter_ch1_fx, &q_pFft_wf_filter_ch0_fx, &q_pFft_wf_filter_ch1_fx); - - for (int i = 0; i < nr_fc_fft_filter; i++) { - pFft_wf_filter_ch0[i][0] = (float)pFft_wf_filter_ch0_fx[i][0] / (1u << q_pFft_wf_filter_ch0_fx); - pFft_wf_filter_ch0[i][1] = (float)pFft_wf_filter_ch0_fx[i][1] / (1u << q_pFft_wf_filter_ch0_fx); - } - - for (int i = 0; i < nr_fc_fft_filter; i++) { - pFft_wf_filter_ch1[i][0] = (float)pFft_wf_filter_ch1_fx[i][0] / (1u << q_pFft_wf_filter_ch1_fx); - pFft_wf_filter_ch1[i][1] = (float)pFft_wf_filter_ch1_fx[i][1] / (1u << q_pFft_wf_filter_ch1_fx); + FOR (int i = 0; i < nr_fc_fft_filter; i++) { + pHrtf_inter_aural_coherence_const[i] = L_shl(params.pHrtf_inter_aural_coherence_const_fx[i] , 3);/*Scaling up to Q30*/ } + ivas_reverb_calc_correl_filters_fx(pHrtf_inter_aural_coherence_const, pTime_window_fx, pState->fft_size, 0, pFft_wf_filter_ch0_fx, pFft_wf_filter_ch1_fx, &q_pFft_wf_filter_ch0_fx, &q_pFft_wf_filter_ch1_fx); free(pHrtf_inter_aural_coherence_const); -#else - ivas_reverb_calc_correl_filters( params.pHrtf_inter_aural_coherence_const, pTime_window, pState->fft_size, 0.0f, pFft_wf_filter_ch0, pFft_wf_filter_ch1 ); -#endif + FOR ( int i = 0; i < nr_fc_fft_filter; i++ ) + { + pFft_wf_filter_ch0_fx[i][0] = L_shl( pFft_wf_filter_ch0_fx[i][0], 31 - q_pFft_wf_filter_ch0_fx ); + pFft_wf_filter_ch0_fx[i][1] = L_shl( pFft_wf_filter_ch0_fx[i][1], 31 - q_pFft_wf_filter_ch0_fx ); + } + FOR ( int i = 0; i < nr_fc_fft_filter; i++ ) + { + pFft_wf_filter_ch1_fx[i][0] = L_shl( pFft_wf_filter_ch1_fx[i][0], 31 - q_pFft_wf_filter_ch1_fx ); + pFft_wf_filter_ch1_fx[i][1] = L_shl( pFft_wf_filter_ch1_fx[i][1], 31 - q_pFft_wf_filter_ch1_fx ); + } /* Copying the computed FFT correlation filters to the fft_filter components */ - if ( ( error = set_correl_fft_filter( pState, 0, pFft_wf_filter_ch0 ) ) != IVAS_ERR_OK ) + IF ( ( error = set_correl_fft_filter( pState, 0, pFft_wf_filter_ch0_fx ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = set_correl_fft_filter( pState, 1, pFft_wf_filter_ch1 ) ) != IVAS_ERR_OK ) + IF ( ( error = set_correl_fft_filter( pState, 1, pFft_wf_filter_ch1_fx ) ) != IVAS_ERR_OK ) { return error; } } /* Computing coloration filters on the basis of target responses */ -#if 1 - Word16 q_pFft_wf_filter_ch0_fx, q_pFft_wf_filter_ch1_fx; - - for (int i = 0; i < nr_fc_fft_filter; i++) { - pFft_wf_filter_ch0_fx[i][0] = pFft_wf_filter_ch0[i][0] * 2147483648; - pFft_wf_filter_ch0_fx[i][1] = pFft_wf_filter_ch0[i][1] * 2147483648; - } - for (int i = 0; i < nr_fc_fft_filter; i++) { - pFft_wf_filter_ch1_fx[i][0] = pFft_wf_filter_ch1_fx[i][0] * 2147483648; - pFft_wf_filter_ch1_fx[i][1] = pFft_wf_filter_ch1_fx[i][1] * 2147483648; - } - for (int i = 0; i < RV_FILTER_MAX_FFT_SIZE; i++) { - pWindow_fx[i] = pTime_window[i] * (1 << 30); - } - - for (int i = 0; i < nr_fc_fft_filter; i++) { - pColor_target_l_fx[i] = pColor_target_l[i] * ONE_IN_Q30; - pColor_target_r_fx[i] = pColor_target_r[i] * ONE_IN_Q30; - } - ivas_reverb_calc_color_filters_fx(pColor_target_l_fx, pColor_target_r_fx, pWindow_fx, pState->fft_size, 0, pFft_wf_filter_ch0_fx, pFft_wf_filter_ch1_fx, &q_pFft_wf_filter_ch0_fx, &q_pFft_wf_filter_ch1_fx); - - for (int i = 0; i < nr_fc_fft_filter; i++) { - pFft_wf_filter_ch0[i][0] = (float)pFft_wf_filter_ch0_fx[i][0] / (1u << q_pFft_wf_filter_ch0_fx); - pFft_wf_filter_ch0[i][1] = (float)pFft_wf_filter_ch0_fx[i][1] / (1u << q_pFft_wf_filter_ch0_fx); - } - - for (int i = 0; i < nr_fc_fft_filter; i++) { - pFft_wf_filter_ch1[i][0] = (float)pFft_wf_filter_ch1_fx[i][0] / (1u << q_pFft_wf_filter_ch1_fx); - pFft_wf_filter_ch1[i][1] = (float)pFft_wf_filter_ch1_fx[i][1] / (1u << q_pFft_wf_filter_ch1_fx); + ivas_reverb_calc_color_filters_fx(pColor_target_l_fx, pColor_target_r_fx, pTime_window_fx, pState->fft_size, 0, pFft_wf_filter_ch0_fx, pFft_wf_filter_ch1_fx, &q_pFft_wf_filter_ch0_fx, &q_pFft_wf_filter_ch1_fx); + FOR ( int i = 0; i < nr_fc_fft_filter; i++ ) + { + pFft_wf_filter_ch0_fx[i][0] = L_shl( pFft_wf_filter_ch0_fx[i][0], 31 - q_pFft_wf_filter_ch0_fx ); + pFft_wf_filter_ch0_fx[i][1] = L_shl( pFft_wf_filter_ch0_fx[i][1], 31 - q_pFft_wf_filter_ch0_fx ); } - - for (int i = 0; i < nr_fc_fft_filter; i++) { - free(pFft_wf_filter_ch1_fx[i]); - free(pFft_wf_filter_ch0_fx[i]); + FOR ( int i = 0; i < nr_fc_fft_filter; i++ ) + { + pFft_wf_filter_ch1_fx[i][0] = L_shl( pFft_wf_filter_ch1_fx[i][0], 31 - q_pFft_wf_filter_ch1_fx ); + pFft_wf_filter_ch1_fx[i][1] = L_shl( pFft_wf_filter_ch1_fx[i][1], 31 - q_pFft_wf_filter_ch1_fx ); } - free(pFft_wf_filter_ch1_fx); - free(pFft_wf_filter_ch0_fx); - free(pWindow_fx); - free(pColor_target_r_fx); - free(pColor_target_l_fx); -#else - ivas_reverb_calc_color_filters( pColor_target_l, pColor_target_r, pTime_window, pState->fft_size, 0.0f, pFft_wf_filter_ch0, pFft_wf_filter_ch1 ); -#endif + Scale_sig32( params.pHrtf_inter_aural_coherence_fx, nr_fc_fft_filter, 4 ); /*Scaling ( *hReverb )->fft_filter_color_0.fft_spectrum_fx to Q31*/ + Scale_sig32( params.pFc_fx, nr_fc_fft_filter, 17 ); /*Scaling ( *hReverb )->fft_filter_color_1.fft_spectrum_fx to Q31*/ /* Copying the computed FFT colorations filters to the fft_filter components */ - if ( ( error = set_color_fft_filter( pState, 0, pFft_wf_filter_ch0 ) ) != IVAS_ERR_OK ) + IF ( ( error = set_color_fft_filter( pState, 0, pFft_wf_filter_ch0_fx ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = set_color_fft_filter( pState, 1, pFft_wf_filter_ch1 ) ) != IVAS_ERR_OK ) + IF ( ( error = set_color_fft_filter( pState, 1, pFft_wf_filter_ch1_fx ) ) != IVAS_ERR_OK ) { return error; } /* init predelay */ ivas_rev_delay_line_init( &( pState->predelay_line ), pState->pPredelay_buffer_fx, params.pre_delay, predelay_bf_len ); - for ( Word16 k = 0; k < pState->fft_filter_ols.fft_size; k++ ) - { - pState->fft_filter_correl_0.fft_spectrum_fx[k] = (Word32) ( pState->fft_filter_correl_0.fft_spectrum[k] * ONE_IN_Q31 ); - pState->fft_filter_color_0.fft_spectrum_fx[k] = (Word32) ( pState->fft_filter_color_0.fft_spectrum[k] * ONE_IN_Q31 ); - pState->fft_filter_correl_1.fft_spectrum_fx[k] = (Word32) ( pState->fft_filter_correl_1.fft_spectrum[k] * ONE_IN_Q31 ); - pState->fft_filter_color_1.fft_spectrum_fx[k] = (Word32) ( pState->fft_filter_color_1.fft_spectrum[k] * ONE_IN_Q31 ); - } /* set up feedback delay network */ - if ( ( error = setup_FDN_branches( pState, ¶ms ) ) != IVAS_ERR_OK ) + IF ( ( error = setup_FDN_branches( pState, ¶ms ) ) != IVAS_ERR_OK ) { return error; } - + free( pDsr_e ); + free( pRt60_e ); *hReverb = pState; return error; diff --git a/lib_rend/ivas_reverb_fft_filter.c b/lib_rend/ivas_reverb_fft_filter.c index ff9b2e71cb63da1a041e87f5b36e8fdb3ea53d2d..47b5292659c76f9f8816de3097deac8bc339ffda 100644 --- a/lib_rend/ivas_reverb_fft_filter.c +++ b/lib_rend/ivas_reverb_fft_filter.c @@ -689,6 +689,26 @@ void ivas_reverb_fft_filter_ComplexMul( * * Convert the FFTWF formatted spectrum to fft_real formatted spectrum *-----------------------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR_fx( + rv_fftwf_type_complex_fx *spectrum, + Word32 *fft_real, + const Word16 fft_size ) +{ + Word16 i, h; + + h = shr(fft_size , 1); + fft_real[0] = spectrum[0][0]; + fft_real[h] = spectrum[h][0]; + for ( i = 1; i < h; i++ ) + { + fft_real[i] = spectrum[i][0]; + fft_real[fft_size - i] = spectrum[i][1]; + } + + return; +} +#endif // IVAS_FLOAT_FIXED void ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR( rv_fftwf_type_complex *spectrum, diff --git a/lib_rend/ivas_reverb_filter_design.c b/lib_rend/ivas_reverb_filter_design.c index d146071f0aa07fba064b9777a598f560f49d2449..241abef79b2b1a679d7af42c7f60541c70c012ff 100644 --- a/lib_rend/ivas_reverb_filter_design.c +++ b/lib_rend/ivas_reverb_filter_design.c @@ -192,7 +192,7 @@ static void calc_min_phase( } static void calc_min_phase_fx( - Word32 **pSpectrum, + rv_fftwf_type_complex_fx *pSpectrum, const Word16 fft_size, Word32 *pMinPhase, Word16 *q_pCepstrum @@ -398,7 +398,7 @@ static void calc_min_phase_filter( } static void calc_min_phase_filter_fx( - Word32 **pH_flt, + rv_fftwf_type_complex_fx *pH_flt, const Word16 fft_size, Word16 delay) { @@ -484,7 +484,7 @@ static void apply_window_fft( } static void apply_window_fft_fx( - Word32 **pH_flt, + rv_fftwf_type_complex_fx *pH_flt, const Word32 *pWindow, const Word16 fft_size, Word16 *q_pFilter @@ -849,8 +849,8 @@ Word16 ivas_reverb_calc_color_filters_fx( const Word32 *pWindow, const Word16 fft_size, const Word16 delay, - Word32 **pBeqL, - Word32 **pBeqR, + rv_fftwf_type_complex_fx *pBeqL, + rv_fftwf_type_complex_fx *pBeqR, Word16 *q_pBeqL, Word16 *q_pBeqR ) @@ -932,8 +932,8 @@ Word16 ivas_reverb_calc_correl_filters_fx( const Word32 *pWindow, //input in Q30 const Word16 fft_size, const Word16 delay, - Word32 **pU, //input in Q31 - Word32 **pV, //input in Q31 + rv_fftwf_type_complex_fx *pU, //input in Q31 + rv_fftwf_type_complex_fx *pV, //input in Q31 Word16 *q_pU, //Output q Word16 *q_pV //output q ) @@ -1323,7 +1323,8 @@ void ivas_reverb_interpolate_acoustic_data_fx( input_idx++; } rel_offset = BASOP_Util_Divide3232_Scale(L_sub(pOutput_fc[output_idx], pInput_fc[input_idx]), L_sub(pInput_fc[input_idx + 1], pInput_fc[input_idx]), &rel_offset_e); //q15 - rel_offset = L_shl(rel_offset, 16); + rel_offset = L_shl_sat(rel_offset, 16+rel_offset_e); + rel_offset_e = 0; } } Word32 mult1; diff --git a/lib_rend/ivas_reverb_iir_filter.c b/lib_rend/ivas_reverb_iir_filter.c index 382da50c1e9ed031c90a20408ff592fe42cc8fe6..faf6f857fe60c97aa0420cf14423e977008903dd 100644 --- a/lib_rend/ivas_reverb_iir_filter.c +++ b/lib_rend/ivas_reverb_iir_filter.c @@ -108,15 +108,15 @@ void ivas_reverb_iir_filt_init( void ivas_reverb_iir_filt_set( ivas_rev_iir_filter_t *iirFilter, /* i/o: IIR filter */ UWord16 nr_taps, /* i : number of IIR filter taps */ - const float *coefA, /* i : A filter coefficients to set */ - const float *coefB /* i : the B filter coefficients to set */ + const Word16 *coefA, /* i : A filter coefficients to set */ + const Word16 *coefB /* i : the B filter coefficients to set */ ) { UWord16 i; - IF ( nr_taps > iirFilter->MaxTaps ) + IF ( GT_32(nr_taps , iirFilter->MaxTaps) ) { - nr_taps = (uint16_t) iirFilter->MaxTaps; + nr_taps = (UWord16) iirFilter->MaxTaps; } iirFilter->nr_taps = nr_taps; @@ -126,15 +126,15 @@ void ivas_reverb_iir_filt_set( { FOR ( i = 0; i < iirFilter->nr_taps; i++ ) { - iirFilter->CoefB_fx[i] = (Word32) ( coefB[i] * ONE_IN_Q30 ); + iirFilter->CoefB_fx[i] = L_shl(coefB[i],16) ;/*Q30*/ } } ELSE { FOR ( i = 0; i < iirFilter->nr_taps; i++ ) { - iirFilter->CoefA_fx[i] = (Word32) ( coefA[i] * ONE_IN_Q30 ); - iirFilter->CoefB_fx[i] = (Word32) ( coefB[i] * ONE_IN_Q30 ); + iirFilter->CoefA_fx[i] = L_shl(coefA[i],16) ;/*Q30*/ + iirFilter->CoefB_fx[i] = L_shl(coefB[i],16) ;/*Q30*/ } } diff --git a/lib_rend/ivas_rom_binauralRenderer.c b/lib_rend/ivas_rom_binauralRenderer.c index 7a84cc2d1561cd5c60637ac95263bee503c398fc..310968d998fff60e238c0fa13f826b6ec23781b4 100644 --- a/lib_rend/ivas_rom_binauralRenderer.c +++ b/lib_rend/ivas_rom_binauralRenderer.c @@ -47698,12 +47698,13 @@ const float fastconvReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX] = #ifdef IVAS_FLOAT_FIXED const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] /*Q-31*/= { --741942720,-686022272,-715028288,-775076224,-803800960,-796237568,-770141312,-747545472,-736820992,-711570880, --679682880,-654928832,-633196288,-617506752,-601123648,-580415424,-567025856,-550623424,-536654016,-519776928, --504817568,-493163168,-480456512,-469858688,-456552864,-446008736,-433967776,-425403616,-416412096,-399234400, --392295872,-390756128,-386091776,-384573504,-379121056,-370071552,-367440896,-360672032,-360721408,-363373568, --359359904,-356323360,-351253152,-346943168,-340172160,-336405472,-333613728,-329810528,-325506976,-322043104, --318265664,-314490400,-310715104,-306939840,-303164576,-299389280,-295611872,-291836576,-288061312,-284286048 + 741942720,686022272,715028288,775076224,803800960,796237568,770141312,747545472,736820992, + 711570880,679682880,654928832,633196288,617506752,601123648,580415424,567025856,550623424, + 536654016,519776928,504817568,493163168,480456512,469858688,456552864,446008736,433967776, + 425403616,416412096,399234400,392295872,390756128,386091776,384573504,379121056,370071552, + 367440896,360672032,360721408,363373568,359359904,356323360,351253152,346943168,340172160, + 336405472,333613728,329810528,325506976,322043104,318265664,314490400,310715104,306939840, + 303164576,299389280,295611872,291836576,288061312,284286048 }; #endif // IVAS_FLOAT_FIXED @@ -47720,11 +47721,13 @@ const float parametricReverberationTimes[CLDFB_NO_CHANNELS_MAX] = #ifdef IVAS_FLOAT_FIXED const Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX] /*Q-31*/= { - -412276064,-308677152,-243799520,-201511280,-193589216,-171714944,-143009520,-156122064,-164263168,-176233248, - -183105200,-201571408,-218830736,-244229024,-252642864,-243726512,-270851360,-271235776,-266133360,-249251984, - -211587264,-110556752,-64317136,-54165980,-45404248,-41570988,-35878008,-34847216,-39548060,-39554500,-36715528, - -32682554,-30524332,-20815560,-8581345,-3463891,-2072321,-1380832,-1069446,-895500,-652835,-388694,-249108,-242665, - -219043,-167503,-137438,-128849,-135291,-133143,-130996,-111669,-85899,-64424,-30064,-15032,-6442,-2147,0,0, + 412276064,308677152,243799520,201511280,193589216,171714944,143009520,156122064,164263168, + 176233248,183105200,201571408,218830736,244229024,252642864,243726512,270851360,271235776, + 266133360,249251984,211587264,110556752,64317136,54165980,45404248,41570988,35878008, + 34847216,39548060,39554500,36715528,32682554,30524332,20815560,8581345,3463891, + 2072321,1380832,1069446,895500,652835,388694,249108,242665,219043, + 167503,137438,128849,135291,133143,130996,111669,85899,64424, + 30064,15032,6442,2147,0,0 }; #endif // IVAS_FLOAT_FIXED @@ -47739,15 +47742,15 @@ const float parametricReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX] = }; #ifdef IVAS_FLOAT_FIXED -const Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX]/*Q-31*/ = +const Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX]/*Q-28*/ = { - -1278914560, -1469108608, -2147483647 - 1, -1890004608, -1560359424, -1136244352, -980880320, -822859904, -712393344, - -709882944, -937310016, -1272336768, -1647858688, -2147483647 - 1, -2147483647 - 1, -2147483647 - 1, -2147483647 - 1, -2147483647 - 1, - -2147483647 - 1, -2147483647 - 1, -2147483647 - 1, -2147483647 - 1, -808619904, -378908448, -321778944, -279832160, -294396384, - -628592064, -1246109568, -1574331008, -1577608064, -1642900096, -1631784832, -1183766016, -553299136, -195307200, - -112115824, -117877528, -108836616, -76572824, -47888884, -34220152, -27120570, -22909356, -19503446, -16683800, - -17248588, -23562190, -31726924, -36056252, -35111356, -91716880, -166079936, -142245024, -90293096, -42986180, - -16956530, -6328634, -2001454, -326417 + 159864320,183638576,279548416,236250576,195044928,142030544,122610040,102857488,89049168, + 88735368,117163752,159042096,205982336,298174336,415684640,522399296,684511744,908078208, + 1136966912,1258442624,893532544,352242880,101077488,47363556,40222368,34979020,36799548, + 78574008,155763696,196791376,197201008,205362512,203973104,147970752,69162392,24413400, + 14014478,14734691,13604577,9571603,5986110,4277519,3390071,2863669,2437930, + 2085475,2156073,2945273,3965865,4507031,4388919,11464610,20759992,17780628, + 11286637,5373272,2119566,791079,250181,40802 }; #endif // IVAS_FLOAT_FIXED diff --git a/lib_rend/ivas_rom_binauralRenderer.h b/lib_rend/ivas_rom_binauralRenderer.h index 3a29189236d04f53dc153a7760f03d669ec00808..8354ef582f431bdbe64da7babb2d588f0586b6cb 100644 --- a/lib_rend/ivas_rom_binauralRenderer.h +++ b/lib_rend/ivas_rom_binauralRenderer.h @@ -87,7 +87,7 @@ extern float fastconvReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX]; #ifdef IVAS_FLOAT_FIXED extern const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX];/*Q-31*/ extern const Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX];/*Q-31*/ -extern const Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX];/*Q-31*/ +extern const Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX];/*Q-28*/ #endif // IVAS_FLOAT_FIXED extern const float parametricReverberationTimes[CLDFB_NO_CHANNELS_MAX]; extern const float parametricReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX]; diff --git a/lib_rend/ivas_rom_rend.c b/lib_rend/ivas_rom_rend.c index 539d9acb3b5d6b70291ef794730cec0fddabcfec..bff2bd7ce42d71e2d94fe534c045c3563d219e50 100644 --- a/lib_rend/ivas_rom_rend.c +++ b/lib_rend/ivas_rom_rend.c @@ -687,145 +687,284 @@ const float defaultHRIR_right_avg_power_16kHz[LR_IAC_LENGTH_NR_FC] = { 0.203638f, 0.171419f, 0.139199f, 0.126311f, 0.126311f }; #ifdef IVAS_FLOAT_FIXED -const UWord16 defaultHRIR_coherence_48kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-15*/ = { - 32211, 30587, 25862, 18822, 11164, 4725, 616, 0, 0, 0, 391, 1162, 1415, 1391, 1369, 1263, 947, 562, 379, - 464, 649, 805, 956, 1092, 1095, 970, 900, 898, 824, 639, 482, 465, 528, 533, 431, 283, 164, 85, 34, 6, - 0, 0, 0, 36, 130, 229, 312, 377, 406, 378, 300, 203, 116, 45, 0, 0, 0, 0, 1, 30, 69, 100, 117, 123, 120, - 101, 67, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 31, 59, 76, 79, 68, 50, 29, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 27, 42, 50, 50, 43, 31, 17, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 20, 31, 41, 52, 62, - 71, 79, 88, 96, 103, 110, 117, 123, 128, 130, 130, 128, 123, 114, 103, 91, 76, 59, 41, 23, 6, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 25, 17, 0, 55, 108, 53, 0, 52, 247, 19, 0, 66, 338, 70, 0, 115, 303, 168, 0, 74, 212, 193, 0, 28, 149, - 134, 0, 0, 106, 50, 8, 6, 44, 28, 0 -}; -const UWord16 defaultHRIR_left_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-15*/ = { - 32069, 31863, 31445, 31191, 31222, 31295, 31151, 30899, 30926, 31400, 31932, 32143, 32002, 31737, 31524, - 31367, 31210, 31068, 30981, 30907, 30745, 30482, 30254, 30187, 30217, 30173, 30053, 29970, 29954, 29932, - 29873, 29838, 29891, 30001, 30076, 30074, 30038, 30029, 30042, 30022, 29950, 29863, 29802, 29756, 29693, - 29603, 29511, 29442, 29391, 29324, 29224, 29114, 29030, 28968, 28887, 28768, 28652, 28590, 28555, 28503, - 28437, 28401, 28413, 28449, 28472, 28486, 28529, 28624, 28747, 28864, 28979, 29136, 29356, 29598, 29813, - 30015, 30241, 30484, 30697, 30848, 30956, 31056, 31153, 31207, 31186, 31110, 31025, 30937, 30804, 30595, - 30363, 30154, 29951, 29709, 29421, 29127, 28860, 28604, 28325, 28020, 27731, 27496, 27304, 27123, 26956, - 26860, 26860, 26920, 27001, 27101, 27250, 27451, 27663, 27848, 28006, 28173, 28359, 28531, 28649, 28726, - 28810, 28905, 28960, 28948, 28898, 28847, 28793, 28702, 28560, 28396, 28248, 28119, 27978, 27806, 27630, - 27493, 27388, 27261, 27097, 26941, 26821, 26713, 26579, 26421, 26276, 26169, 26084, 25993, 25898, 25835, - 25828, 25856, 25879, 25896, 25949, 26049, 26160, 26243, 26305, 26382, 26482, 26570, 26614, 26627, 26654, - 26703, 26734, 26717, 26681, 26679, 26697, 26694, 26661, 26630, 26630, 26654, 26670, 26664, 26659, 26688, - 26748, 26798, 26811, 26824, 26895, 27002, 27062, 27084, 27145, 27265, 27379, 27439, 27491, 27599, 27746, - 27852, 27897, 27955, 28057, 28091, 27925, 27603, 27238, 26740, 25949, 24880, 23702, 22488, 21123, 19491, - 17693, 15981, 14436, 12776, 10592, 7813, 4890, 2543, 1069, 348, 80, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; -const UWord16 defaultHRIR_right_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-15*/ = { - 32069, 31863, 31445, 31191, 31222, 31295, 31151, 30899, 30926, 31400, 31932, 32143, 32002, 31737, 31524, - 31367, 31210, 31068, 30980, 30907, 30745, 30482, 30254, 30187, 30217, 30173, 30053, 29970, 29954, 29932, - 29873, 29838, 29891, 30001, 30076, 30074, 30038, 30029, 30042, 30022, 29950, 29863, 29802, 29756, 29693, - 29603, 29511, 29442, 29391, 29324, 29224, 29114, 29030, 28968, 28887, 28768, 28652, 28590, 28555, 28503, - 28437, 28401, 28413, 28449, 28472, 28486, 28529, 28624, 28747, 28864, 28979, 29136, 29356, 29598, 29813, - 30015, 30241, 30484, 30697, 30848, 30956, 31056, 31153, 31207, 31186, 31110, 31025, 30937, 30804, 30595, - 30364, 30154, 29951, 29709, 29421, 29127, 28860, 28604, 28325, 28020, 27731, 27496, 27304, 27123, 26956, - 26860, 26860, 26920, 27001, 27101, 27250, 27451, 27663, 27848, 28006, 28173, 28359, 28531, 28649, 28726, - 28810, 28905, 28960, 28948, 28897, 28847, 28793, 28702, 28560, 28396, 28248, 28119, 27978, 27806, 27630, - 27493, 27388, 27261, 27097, 26941, 26821, 26713, 26579, 26421, 26276, 26169, 26084, 25993, 25898, 25835, - 25828, 25856, 25879, 25896, 25949, 26049, 26160, 26243, 26305, 26382, 26482, 26570, 26614, 26627, 26654, - 26703, 26734, 26717, 26681, 26679, 26697, 26694, 26661, 26630, 26630, 26654, 26670, 26664, 26659, 26688, - 26748, 26798, 26811, 26824, 26895, 27002, 27062, 27084, 27145, 27265, 27379, 27439, 27491, 27599, 27746, - 27852, 27897, 27955, 28057, 28090, 27925, 27603, 27238, 26739, 25949, 24880, 23702, 22488, 21123, 19491, - 17693, 15981, 14436, 12776, 10592, 7813, 4890, 2543, 1069, 348, 80, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; -const UWord16 defaultHRIR_coherence_32kHz_fx[257] /*Q-15*/ = { - 32012,31549,29232,25671,21280,16002,11011,6448,3083,552,157,0,0,0,88,309,807,1275,1355,1353,1297,1279, - 1213,1075,806,522,304,230,254,387,509,615,715,813,905,940,938,856,788,744,737,725,657,543,399,318,287, - 328,374,403,358,280,179,96,34,5,0,0,0,0,0,0,0,0,0,7,45,98,162,212,256,293,300,291,246,189,123,63,20,3, - 0,0,0,0,0,0,0,0,0,0,0,8,23,31,36,38,34,25,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,11,18,23,19,10,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,11,19,25,28,27,24,16,8,1,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,5,9,15,21,28,35,41,48,55,62,68,74, - 79,83,87,91,94,98,102,106,111,119,127,136,145,155,166,177,189,200,210,219,226,232,237,239,239,233,224, - 211,193,174,149,123,97,83,77,81,82 -}; -const UWord16 defaultHRIR_left_avg_power_32kHz_fx[257] /*Q-15*/ = { - 34171,34113,33819,33565,33338,33397,33493,33645,33642,33572,33391,33314,33308,33603,33918,34267,34419, - 34473,34327,34162,33984,33890,33804,33727,33619,33507,33410,33339,33285,33182,33038,32833,32634,32464, - 32400,32383,32399,32360,32296,32193,32118,32060,32045,32018,31983,31916,31868,31850,31897,31963,32035, - 32067,32073,32036,32005,31984,31979,31972,31946,31895,31826,31744,31668,31604,31546,31486,31409,31316, - 31212,31114,31026,30953,30880,30801,30697,30581,30458,30352,30254,30168,30071,29965,29838,29714,29591, - 29503,29422,29352,29272,29187,29096,29020,28956,28928,28903,28879,28839,28796,28758,28744,28748,28783, - 28816,28846,28871,28902,28959,29045,29150,29266,29375,29471,29564,29659,29772,29887,30006,30089,30153, - 30190,30215,30237,30263,30280,30290,30248,30187,30098,30003,29907,29813,29701,29576,29403,29225,29037, - 28868,28704,28543,28361,28165,27941,27724,27516,27327,27141,26948,26738,26518,26298,26093,25910,25750, - 25598,25449,25305,25163,25065,24991,24954,24947,24948,24954,24967,24985,25043,25113,25202,25280,25350, - 25397,25443,25489,25556,25622,25686,25720,25741,25741,25745,25752,25765,25767,25752,25703,25641,25562, - 25486,25413,25336,25245,25135,25000,24859,24722,24599,24486,24373,24250,24112,23969,23831,23716,23612, - 23515,23401,23277,23139,23004,22873,22757,22637,22515,22365,22208,22039,21877,21720,21576,21432,21287, - 21125,20963,20801,20668,20550,20461,20370,20278,20176,20089,20024,20008,20007,20017,20019,20014,20051, - 20122,20243,20403,20584,20814,21138,21523,21921,22069,21841,20583,18845,16215,13564,10899,9201,7926,7286, - 7157 -}; -const UWord16 defaultHRIR_right_avg_power_32kHz_fx[257] /*Q-15*/ = { - 34171,34113,33819,33565,33338,33397,33493,33645,33642,33572,33391,33314,33308,33603,33918,34267,34419, - 34473,34327,34162,33984,33890,33804,33727,33619,33507,33410,33339,33285,33182,33038,32833,32634,32464, - 32400,32383,32399,32360,32296,32193,32118,32060,32045,32018,31983,31916,31868,31850,31897,31963,32035, - 32067,32074,32036,32005,31984,31979,31972,31946,31895,31826,31744,31668,31604,31546,31486,31409,31316, - 31212,31114,31026,30953,30880,30801,30697,30581,30458,30352,30254,30168,30071,29965,29838,29714,29591, - 29503,29422,29352,29272,29187,29096,29020,28956,28928,28902,28879,28839,28796,28758,28744,28748,28783, - 28816,28846,28871,28902,28959,29045,29150,29266,29375,29471,29564,29659,29772,29888,30006,30089,30153, - 30190,30214,30236,30263,30280,30290,30248,30187,30098,30003,29907,29813,29701,29576,29403,29225,29037, - 28868,28704,28543,28361,28165,27941,27724,27516,27327,27142,26948,26738,26518,26298,26093,25910,25750, - 25598,25449,25305,25163,25065,24991,24954,24947,24948,24954,24967,24985,25043,25113,25202,25280,25350, - 25396,25443,25489,25556,25622,25686,25720,25741,25741,25745,25752,25764,25767,25752,25703,25641,25562, - 25486,25413,25336,25246,25136,25000,24859,24722,24599,24486,24373,24250,24112,23969,23831,23716,23612, - 23515,23401,23277,23139,23004,22873,22757,22637,22515,22365,22208,22039,21877,21720,21576,21432,21287, - 21125,20963,20801,20668,20550,20461,20370,20278,20176,20089,20024,20008,20007,20017,20019,20015,20051, - 20122,20243,20403,20584,20814,21138,21524,21922,22069,21841,20583,18845,16215,13564,10899,9201,7926,7286, - 7157 -}; -const UWord16 defaultHRIR_coherence_16kHz_fx[257] /*Q-15*/ = { - 31768,31768,31304,30146,28987,27616,25398,23180,20962,18325,15689,13052,10721,8465,6210,4393,2867,1342, - 374,240,106,0,0,0,0,0,0,0,83,188,293,489,745,1001,1166,1193,1220,1236,1212,1188,1164,1163,1162,1162,1115, - 1057,998,893,756,620,497,395,294,214,223,232,241,301,360,420,466,510,553,592,628,664,698,729,761,785,779, - 773,767,729,691,653,630,611,592,585,586,587,575,543,511,471,403,334,265,225,185,145,152,170,189,208,228, - 249,250,223,196,163,109,54,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,7,13,19,42,64,86, - 102,116,130,134,132,130,118,92,66,42,28,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,24,63,103,157,235,312,398,518,638,758,937,1117,1296,1533,1784,2035,2136,2136 -}; -const UWord16 defaultHRIR_left_avg_power_16kHz_fx[257] /*Q-15*/ = { - 36465,36465,36392,36209,36026,35860,35762,35664,35565,35651,35736,35821,35904,35987,36069,36071,36020, - 35969,35903,35814,35725,35656,35663,35671,35678,35800,35921,36043,36201,36368,36535,36661,36759,36857, - 36895,36841,36788,36718,36578,36439,36299,36213,36127,36041,35999,35967,35935,35873,35790,35707,35610, - 35492,35373,35268,35212,35157,35101,35062,35022,34983,34867,34732,34598,34449,34292,34135,34026,33990, - 33954,33930,33953,33977,34000,33932,33864,33795,33687,33568,33449,33373,33325,33278,33241,33219,33197, - 33162,33074,32986,32897,32811,32725,32639,32623,32626,32628,32639,32657,32675,32669,32627,32585,32543, - 32497,32452,32407,32390,32374,32357,32309,32252,32195,32114,32017,31919,31838,31779,31721,31665,31621, - 31578,31534,31418,31302,31186,31052,30914,30775,30679,30610,30542,30474,30406,30339,30253,30093,29934, - 29774,29612,29450,29287,29196,29122,29048,28966,28879,28792,28665,28481,28296,28115,27946,27777,27607, - 27525,27443,27361,27255,27143,27031,26870,26675,26481,26303,26149,25995,25854,25769,25684,25599,25461, - 25323,25185,25006,24816,24627,24481,24364,24246,24144,24065,23985,23888,23724,23559,23395,23214,23033, - 22852,22754,22677,22600,22522,22443,22365,22239,22044,21848,21657,21487,21316,21146,21109,21073,21036, - 20964,20883,20801,20633,20407,20181,19982,19825,19668,19541,19536,19530,19524,19411,19299,19186,18934, - 18647,18360,18149,17988,17828,17735,17744,17753,17722,17532,17342,17152,16740,16328,15915,15723,15586, - 15449,15527,15748,15969,16047,15911,15774,15458,14421,13384,12347,10837,9328,7819,6672,5617,4561,4138, - 4138 -}; -const UWord16 defaultHRIR_right_avg_power_16kHz_fx[257] /*Q-15*/ = { - 36465,36465,36392,36209,36026,35860,35762,35664,35565,35651,35736,35821,35904,35987,36069,36071,36020, - 35969,35903,35814,35725,35656,35663,35670,35678,35800,35921,36043,36201,36368,36535,36660,36759,36857, - 36895,36841,36788,36718,36578,36439,36299,36213,36127,36041,35999,35967,35935,35873,35790,35707,35610, - 35492,35373,35268,35212,35157,35101,35062,35022,34983,34867,34732,34598,34449,34292,34135,34026,33990, - 33954,33930,33953,33977,34000,33932,33864,33795,33687,33568,33449,33373,33325,33278,33241,33219,33197, - 33162,33074,32986,32897,32811,32725,32639,32623,32625,32628,32639,32657,32675,32669,32627,32585,32543, - 32497,32452,32407,32390,32374,32357,32309,32252,32195,32114,32017,31919,31838,31779,31721,31665,31622, - 31578,31534,31418,31302,31186,31052,30913,30775,30679,30610,30542,30474,30406,30339,30253,30093,29934, - 29774,29612,29450,29287,29196,29122,29048,28966,28879,28792,28665,28481,28296,28115,27946,27777,27607, - 27525,27443,27361,27255,27143,27031,26870,26675,26481,26303,26149,25995,25854,25769,25684,25599,25461, - 25323,25185,25006,24816,24627,24481,24364,24246,24144,24065,23985,23888,23724,23559,23395,23214,23033, - 22852,22754,22677,22600,22522,22443,22365,22239,22044,21848,21657,21487,21316,21146,21109,21073,21037, - 20964,20883,20801,20633,20407,20181,19982,19825,19668,19541,19536,19530,19524,19411,19299,19186,18934, - 18647,18360,18149,17988,17828,17735,17744,17753,17722,17532,17342,17152,16740,16328,15915,15723,15586, - 15449,15527,15748,15969,16047,15911,15774,15458,14421,13384,12347,10837,9328,7819,6672,5617,4561,4138, - 4138 +const Word32 defaultHRIR_coherence_48kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-27*/ = { + 131936432,125285536,105934832,77097344,45729324,19356880,2523696,0,0, + 0,1602425,4763253,5796595,5698884,5608690,5175704,3880368,2303444, + 1553033,1902670,2661537,3300414,3919560,4475624,4485288,3976468,3688169, + 3682129,3375844,2619661,1976758,1906026,2165066,2186943,1765500,1162325, + 671759,348160,140123,27783,0,0,0,148981,534991, + 939926,1281242,1547798,1665910,1550617,1228897,835102,478486,185757, + 0,0,0,0,4294,124554,284273,410840,479828, + 507343,493652,417417,278367,114890,0,0,0,0, + 0,0,0,0,0,29125,130728,242531,313264, + 326954,282528,204816,121735,46976,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,31943,114353,173543, + 205218,205755,176362,128043,69927,20803,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,3355,38117,83214,127372,170993,215553,257966, + 294607,327222,360643,395137,425738,452447,480096,507208,525462, + 533247,534186,526804,505463,469896,424799,372856,312190,242397, + 168711,95831,28319,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,102810,72074,0, + 226962,443858,219445,0,214882,1013209,77846,0,273535, + 1385798,289239,0,472983,1241648,688671,0,306821,870536, + 792153,0,115695,613375,552574,0,0,434462,205890, + 34762,26709,182938,117843,0 +}; +const Word32 defaultHRIR_left_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { + 8209721,8156956,8050127,7984940,7992858,8011649,7974747,7910306,7917252, + 8038476,8174723,8228729,8192717,8124794,8070352,8029995,7989956,7953608, + 7931152,7912210,7870745,7803402,7745101,7727896,7735563,7724331,7693670, + 7672548,7668253,7662666,7647508,7638633,7652147,7680265,7699593,7698955, + 7689828,7687614,7690835,7685852,7667229,7645042,7629506,7617787,7601639, + 7578545,7554822,7537315,7524279,7507108,7481430,7453328,7431803,7415991, + 7395254,7364820,7335141,7319069,7310202,7296948,7280120,7270700,7273946, + 7282989,7288836,7292510,7303600,7327768,7359376,7389357,7418784,7458856, + 7515186,7577119,7632232,7684091,7741771,7803922,7858506,7897295,7924793, + 7950529,7975309,7989134,7983815,7964337,7942418,7920028,7885853,7832460, + 7773178,7719675,7667640,7605540,7531820,7456659,7388182,7322718,7251305, + 7173342,7099371,7039023,6989942,6943645,6900871,6876377,6876200,6891753, + 6912280,6938008,6976184,7027514,7081939,7129159,7169768,7212416,7260113, + 7303961,7334160,7353923,7375390,7399868,7413919,7410756,7397888,7384995, + 7371128,7347783,7311469,7269433,7231533,7198642,7162562,7118413,7073358, + 7038218,7011467,6978885,6936976,6896929,6866243,6838636,6804318,6763793, + 6726715,6699377,6677726,6654422,6630095,6613880,6612001,6619165,6625113, + 6629517,6642997,6668750,6697196,6718344,6734173,6753895,6779589,6802146, + 6813185,6816633,6823486,6836086,6844013,6839567,6830432,6829887,6834652, + 6833897,6825424,6817447,6817430,6823444,6827572,6826137,6824845,6832135, + 6847612,6860472,6863735,6867082,6885344,6912573,6928050,6933679,6949215, + 6980018,7009084,7024486,7037715,7065515,7103221,7130283,7141717,7156523, + 7182804,7191302,7148830,7066479,6973039,6845448,6642997,6369529,6067757, + 5757018,5407708,4989863,4529504,4091224,3695693,3270760,2711684,2000297, + 1252050,651123,273904,89170,20652,2843,209,134,134, + 125,117,92,75,75,75,58,50,50, + 58,50,41,41,50,41,41,41,41, + 41,41,41,41,41,41,41,41,41, + 41,41,41,41,41 +}; +const Word32 defaultHRIR_right_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { + 8209721,8156956,8050144,7984965,7992850,8011640,7974756,7910323,7917252, + 8038484,8174707,8228738,8192709,8124794,8070361,8030003,7989948,7953583, + 7931127,7912202,7870737,7803402,7745101,7727896,7735563,7724331,7693679, + 7672548,7668236,7662658,7647491,7638624,7652147,7680265,7699609,7698964, + 7689820,7687597,7690827,7685844,7667229,7645050,7629472,7617779,7601639, + 7578545,7554822,7537315,7524288,7507133,7481447,7453337,7431803,7415982, + 7395229,7364812,7335141,7319077,7310185,7296931,7280120,7270700,7273955, + 7282998,7288836,7292494,7303583,7327776,7359401,7389382,7418776,7458856, + 7515186,7577127,7632241,7684082,7741787,7803939,7858523,7897295,7924793, + 7950529,7975309,7989125,7983824,7964320,7942426,7920062,7885853,7832443, + 7773194,7719675,7667640,7605556,7531829,7456675,7388199,7322726,7251305, + 7173333,7099379,7039032,6989967,6943653,6900880,6876377,6876226,6891753, + 6912271,6937999,6976184,7027514,7081931,7129151,7169768,7212416,7260122, + 7303961,7334160,7353940,7375398,7399868,7413910,7410731,7397871,7384978, + 7371145,7347791,7311477,7269450,7231542,7198633,7162554,7118413,7073358, + 7038218,7011475,6978885,6936976,6896920,6866226,6838628,6804310,6763785, + 6726707,6699369,6677709,6654414,6630095,6613889,6612010,6619148,6625071, + 6629508,6642989,6668750,6697204,6718352,6734190,6753920,6779597,6802146, + 6813210,6816641,6823495,6836095,6844030,6839559,6830457,6829904,6834677, + 6833905,6825416,6817455,6817421,6823428,6827555,6826129,6824837,6832135, + 6847620,6860472,6863735,6867082,6885336,6912582,6928059,6933679,6949232, + 6980026,7009084,7024477,7037706,7065489,7103188,7130275,7141708,7156497, + 7182812,7191285,7148847,7066488,6973047,6845439,6642997,6369529,6067757, + 5757001,5407699,4989863,4529504,4091224,3695702,3270751,2711693,2000297, + 1252050,651123,273904,89170,20652,2843,209,134,134, + 125,117,92,75,75,75,58,50,50, + 58,50,41,41,50,41,41,41,41, + 41,41,41,41,41,41,41,41,41, + 41,41,41,41,41 +}; +const Word32 defaultHRIR_coherence_32kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-27*/ = { + 131125216,129227112,119736576,105149792,87165424,65548180,45102524,26414452,12630962, + 2261837,646258,0,0,0,362790,1269699,3305916,5226035, + 5552185,5544266,5313545,5242007,4972498,4406099,3304843,2138491,1245809, + 945832,1040724,1586856,2087488,2519669,2930509,3330210,3706959,3852988, + 3845069,3506438,3230889,3049963,3020838,2972117,2692944,2226269,1634369, + 1306206,1176284,1344056,1533169,1651817,1468073,1147695,736184,393929, + 141465,23622,0,0,0,0,0,0,0, + 0,0,31004,186025,403995,663840,869999,1052669,1200174, + 1230910,1195208,1010927,774704,504121,258100,82812,13824,0, + 0,0,0,0,0,0,0,0,0, + 0,35567,94757,127104,150189,159048,139586,103616,29662, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,13287,46305,75833,95294,77980,44426,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,13153,45768,78383,106434, + 117574,114487,101871,68719,36641,6039,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,1476, + 5234,21072,40667,63619,89120,116098,144015,171932,199715, + 227901,255818,281723,304405,324941,341584,357824,373796,388962, + 403995,419296,437818,458621,488820,521301,557674,596329,636728, + 680886,727728,776315,821546,862751,897916,926773,952409,971870, + 980460,981802,955227,918049,865167,793897,713233,613106,507477, + 398224,342255,316082,334604,338228 +}; +const Word32 defaultHRIR_left_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { + 8747993,8732977,8657866,8592845,8534553,8549703,8574332,8613196,8612450, + 8594632,8548151,8528631,8527079,8602383,8683241,8772412,8811402,8825092, + 8787822,8745552,8699960,8676052,8653847,8634210,8606620,8577981,8553109, + 8534922,8521190,8494783,8457906,8405301,8354525,8310963,8294462,8290268, + 8294278,8284279,8267812,8241648,8222362,8207531,8203647,8196752,8187852, + 8170672,8158450,8153660,8165857,8182684,8201064,8209352,8210920,8201391, + 8193506,8188086,8186669,8185008,8178398,8165219,8147653,8126564,8107262, + 8090653,8075973,8060647,8040892,8017060,7990510,7965369,7942812,7924139, + 7905508,7885266,7858574,7828903,7797253,7770124,7745051,7723047,7698192, + 7671231,7638683,7606840,7575458,7552800,7532081,7514280,7493736,7472068, + 7448614,7429295,7412736,7405756,7399180,7393182,7382990,7372018,7362119, + 7358680,7359552,7368629,7377118,7384718,7391127,7398953,7413675,7435679, + 7462522,7492302,7520043,7544714,7568412,7592915,7621662,7651325,7681599, + 7702873,7719423,7728886,7735043,7740672,7747517,7751812,7754412,7743650, + 7728089,7705339,7680970,7656341,7632308,7603568,7571683,7527366,7481606, + 7433699,7390347,7348345,7307132,7260525,7210319,7153108,7097458,7044149, + 6995864,6948351,6898883,6845179,6788657,6732512,6680016,6632990,6592154, + 6553113,6515029,6478094,6441947,6416664,6397714,6388260,6386465,6386851, + 6388319,6391700,6396364,6411102,6429029,6451720,6471844,6489796,6501641, + 6513435,6525204,6542518,6559405,6575670,6584344,6589771,6589813,6590845, + 6592531,6595845,6596365,6592707,6580091,6564161,6543961,6524642,6505902, + 6486113,6462969,6434800,6400113,6364034,6328861,6297445,6268521,6239597, + 6208098,6172732,6136241,6100909,6071330,6044722,6020084,5990858,5959116, + 5923599,5889046,5855634,5825838,5795177,5763938,5725518,5685253,5642211, + 5600763,5560540,5523688,5486661,5449525,5408043,5366612,5325264,5291257, + 5260940,5238031,5214778,5191290,5165126,5142795,5126186,5122067,5121799, + 5124433,5124877,5123837,5133241,5151268,5182239,5223192,5269715,5328527, + 5411331,5510141,5612029,5649811,5591443,5269488,4824515,4151102,3472472, + 2790361,2355655,2029229,1865232,1832432 +}; +const Word32 defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { + 8747984,8732969,8657857,8592837,8534561,8549686,8574315,8613188,8612450, + 8594632,8548151,8528622,8527070,8602392,8683241,8772404,8811402,8825109, + 8787822,8745552,8699951,8676044,8653847,8634226,8606620,8577964,8553100, + 8534914,8521190,8494808,8457931,8405310,8354525,8310963,8294471,8290276, + 8294278,8284287,8267820,8241639,8222362,8207540,8203664,8196752,8187826, + 8170663,8158450,8153685,8165873,8182684,8201064,8209360,8210945,8201416, + 8193531,8188095,8186669,8185008,8178398,8165219,8147653,8126539,8107237, + 8090644,8075973,8060664,8040875,8017043,7990510,7965369,7942812,7924122, + 7905499,7885283,7858574,7828903,7797270,7770116,7745034,7723056,7698192, + 7671222,7638675,7606840,7575466,7552809,7532089,7514280,7493736,7472068, + 7448597,7429287,7412753,7405756,7399163,7393174,7382981,7372009,7362111, + 7358680,7359560,7368637,7377126,7384718,7391135,7398970,7413692,7435679, + 7462514,7492293,7520026,7544705,7568403,7592915,7621688,7651341,7681582, + 7702873,7719423,7728877,7735026,7740663,7747517,7751829,7754437,7743650, + 7728080,7705330,7680970,7656349,7632308,7603568,7571700,7527383,7481623, + 7433716,7390363,7348353,7307132,7260525,7210327,7153125,7097475,7044149, + 6995872,6948359,6898883,6845179,6788657,6732520,6680024,6632990,6592154, + 6553113,6515037,6478102,6441947,6416664,6397714,6388269,6386457,6386843, + 6388327,6391700,6396347,6411102,6429029,6451712,6471844,6489796,6501624, + 6513427,6525213,6542518,6559405,6575653,6584327,6589763,6589813,6590845, + 6592531,6595836,6596365,6592716,6580099,6564169,6543978,6524642,6505894, + 6486122,6462994,6434817,6400122,6364034,6328852,6297428,6268521,6239597, + 6208090,6172723,6136241,6100909,6071330,6044722,6020076,5990842,5959107, + 5923599,5889037,5855617,5825829,5795169,5763921,5725518,5685253,5642194, + 5600755,5560548,5523688,5486661,5449508,5408026,5366603,5325256,5291257, + 5260949,5238040,5214778,5191281,5165134,5142795,5126194,5122075,5121799, + 5124441,5124877,5123854,5133241,5151259,5182230,5223192,5269715,5328527, + 5411340,5510149,5612037,5649820,5591435,5269472,4824498,4151094,3472472, + 2790378,2355663,2029237,1865240,1832432 +}; +const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-27*/ = { + 130123416,130123416,128225040,123478832,118732624,113118568,104033232,94947768,85862304, + 75063144,64263984,53464828,43914296,34675820,25437480,17993766,11746601,5499437, + 1532229,985023,437818,0,0,0,0,0,0, + 0,343865,773496,1203261,2004810,3054258,4103707,4777480,4887673, + 4998000,5066316,4966727,4867271,4767816,4765534,4763253,4760971,4569174, + 4329998,4090822,3659312,3099355,2539533,2037290,1621350,1205543,880065, + 916304,952677,988916,1233058,1477200,1721342,1912602,2090441,2268413, + 2427327,2573490,2719788,2859643,2989834,3120025,3219078,3193576,3168075, + 3142574,2987686,2832665,2677778,2583691,2504771,2425851,2397128,2401692, + 2406255,2356594,2225464,2094333,1933137,1651280,1369423,1087566,924357, + 761148,597940,625051,699677,774302,854295,937779,1021128,1026631, + 915230,803830,670014,446676,223338,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,5100,30735, + 56371,81872,173140,264408,355542,419698,477144,534455,552037, + 543044,533918,485599,378494,271254,173946,115964,57982,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,671,1476,2415,99723,261321,423054,646795, + 963549,1280302,1632087,2124129,2616037,3108080,3841982,4575885,5309922, + 6280181,7309766,8339216,8750996,8750996 +}; +const Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { + 9335246,9335246,9316514,9269680,9222847,9180350,9155201,9130044,9104894, + 9126688,9148473,9170267,9191549,9212688,9233844,9234423,9221295,9208167, + 9191205,9168497,9145789,9127997,9129884,9131780,9133676,9164823,9195978, + 9227125,9267550,9310290,9353038,9385225,9410374,9435531,9445170,9431538, + 9417907,9399855,9364128,9328409,9292682,9270670,9248667,9226655,9215783, + 9207688,9199593,9183605,9162356,9141108,9116244,9085961,9055678,9028608, + 9014432,9000255,8986078,8975962,8965845,8955728,8926108,8891606,8857103, + 8819145,8778896,8738639,8710806,8701604,8692401,8686227,8692209,8698190, + 8704171,8686706,8669232,8651767,8623917,8593466,8563024,8543554,8531399, + 8519252,8509748,8504203,8498667,8489716,8467083,8444459,8421835,8399773, + 8377711,8355649,8351698,8352268,8352847,8355833,8360430,8365027,8363484, + 8352721,8341959,8331028,8319460,8307884,8296308,8292063,8287827,8283582, + 8271142,8256647,8242159,8221389,8196442,8171494,8150547,8135607,8120659, + 8106465,8095225,8083992,8072760,8043073,8013394,7983706,7949422,7913997, + 7878564,7853893,7836394,7818904,7801472,7784141,7766811,7744782,7703972, + 7663169,7622359,7580802,7539253,7497696,7474266,7455367,7436467,7415496, + 7393140,7370784,7338471,7291235,7244007,7197551,7154232,7110914,7067595, + 7046615,7025627,7004647,6977485,6948779,6920073,6878751,6829015,6779278, + 6733644,6694184,6654724,6618804,6597044,6575284,6553524,6518183,6482842, + 6447501,6401632,6353137,6304634,6267229,6237215,6207201,6181045,6160677, + 6140310,6115580,6073427,6031275,5989122,5942817,5896503,5850198,5825150, + 5805428,5785707,5765742,5745626,5725510,5693398,5643285,5593180,5544358, + 5500720,5457091,5413454,5404126,5394797,5385469,5366930,5346085,5325239, + 5282164,5224274,5166376,5115566,5075376,5035186,5002731,5001238,4999736, + 4998243,4969436,4940630,4911823,4847290,4773822,4700355,4646282,4605153, + 4564023,4540250,4542523,4544788,4536869,4488241,4439612,4390983,4285488, + 4179984,4074489,4025282,3990150,3955019,3974925,4031523,4088129,4108127, + 4073222,4038317,3957300,3691818,3426335,3160861,2774481,2388110,2001740, + 1708239,1437966,1167685,1059581,1059581 +}; +const Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { + 9335246,9335246,9316514,9269689,9222855,9180358,9155201,9130035,9104869, + 9126663,9148465,9170258,9191540,9212688,9233827,9234415,9221295,9208175, + 9191213,9168488,9145755,9127963,9129867,9131772,9133676,9164831,9195978, + 9227133,9267550,9310281,9353021,9385200,9410357,9435506,9445153,9431522, + 9417899,9399855,9364119,9328384,9292648,9270653,9248658,9226663,9215792, + 9207688,9199593,9183596,9162348,9141100,9116236,9085953,9055678,9028617, + 9014432,9000255,8986070,8975962,8965853,8955745,8926116,8891614,8857103, + 8819145,8778888,8738631,8710789,8701587,8692385,8686219,8692200,8698181, + 8704162,8686697,8669232,8651775,8623917,8593466,8563016,8543546,8531390, + 8519244,8509739,8504203,8498675,8489724,8467100,8444468,8421844,8399773, + 8377703,8355641,8351681,8352252,8352830,8355817,8360414,8365019,8363475, + 8352721,8341959,8331037,8319469,8307893,8296316,8292072,8287835,8283591, + 8271142,8256647,8242151,8221381,8196433,8171494,8150547,8135616,8120676, + 8106482,8095250,8084009,8072777,8043081,8013385,7983698,7949405,7913972, + 7878547,7853876,7836386,7818904,7801481,7784150,7766819,7744790,7703980, + 7663161,7622350,7580793,7539244,7497696,7474258,7455358,7436459,7415487, + 7393132,7370776,7338471,7291244,7244016,7197560,7154241,7110914,7067587, + 7046607,7025627,7004647,6977485,6948770,6920064,6878742,6829006,6779270, + 6733644,6694184,6654724,6618813,6597053,6575301,6553549,6518191,6482842, + 6447492,6401623,6353137,6304643,6267229,6237215,6207201,6181037,6160677, + 6140310,6115580,6073427,6031275,5989122,5942817,5896512,5850207,5825167, + 5805445,5785723,5765750,5745626,5725493,5693382,5643276,5593180,5544375, + 5500729,5457074,5413429,5404109,5394789,5385478,5366939,5346093,5325247, + 5282172,5224282,5166384,5115574,5075384,5035195,5002739,5001238,4999736, + 4998243,4969436,4940630,4911823,4847290,4773814,4700338,4646274,4605153, + 4564023,4540258,4542523,4544788,4536878,4488249,4439612,4390983,4285480, + 4179984,4074489,4025282,3990150,3955019,3974925,4031523,4088129,4108127, + 4073222,4038317,3957292,3691809,3426327,3160844,2774473,2388110,2001740, + 1708239,1437966,1167685,1059573,1059573 }; #endif // IVAS_FLOAT_FIXED /*----------------------------------------------------------------------------------* @@ -904,6 +1043,44 @@ const Word32 t_design_11_elevation_int[70] = //Q22 * Reverberator ROM tables *-----------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +const Word32 ivas_reverb_default_fc_fx[IVAS_REVERB_DEFAULT_N_BANDS] /*Q16*/ = +{ + 1310720 , 1638400 , 2064384 , 2621440 , 3276800 , + 4128768 , 5242880 , 6553600 , 8192000 , + 10485760 , 13107200 , 16384000 , 20643840 , + 26214400 , 32768000 , 41287680 , 52428800 , + 65536000 , 81920000 , 104857600 , 131072000 , + 163840000 , 206438400 , 262144000 , 327680000 , + 412876800 , 524288000 , 655360000 , 819200000 , + 1048576000 , 1310720000 +}; + +const Word32 ivas_reverb_default_RT60_fx[IVAS_REVERB_DEFAULT_N_BANDS] /*Q30*/ = +{ + 1462651136 , 1555422464 , 1413903232 , 1695116160 , 1585487232 , + 1498299392 , 1383945856 , 1445471232 , 1155238784 , + 1116798848 , 1177894784 , 1165009920 , 1171452288 , + 1117121024 , 1127321600 , 1148796416 , 1184122496 , + 1257781120 , 1184015104 , 1145252992 , 1132797568 , + 1133119744 , 1129683712 , 1134837760 , 1118946304 , + 1050355712 , 864222592 , 815442496 , 772503552 , + 662305408 , 644577984 +}; + +const Word32 ivas_reverb_default_DSR_fx[IVAS_REVERB_DEFAULT_N_BANDS] /*Q0*/ = +{ + 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , + 0 , 0 , 0 , 0 , + 0 , 0 , 0 +}; +#endif + const float ivas_reverb_default_fc[IVAS_REVERB_DEFAULT_N_BANDS] = { 20.0f, 25.0f, 31.5f, 40.0f, diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index 9418f2e62901593f4b867f8805568c17e0361138..6c2831c63544a12fc10b2572edb3defb29fdc80e 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -121,17 +121,17 @@ extern const float defaultHRIR_left_avg_power_16kHz[LR_IAC_LENGTH_NR_FC]; extern const float defaultHRIR_right_avg_power_16kHz[LR_IAC_LENGTH_NR_FC]; #ifdef IVAS_FLOAT_FIXED -extern const UWord16 defaultHRIR_coherence_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-15*/ -extern const UWord16 defaultHRIR_left_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-15*/ -extern const UWord16 defaultHRIR_right_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-15*/ +extern const Word32 defaultHRIR_coherence_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-27*/ +extern const Word32 defaultHRIR_left_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ +extern const Word32 defaultHRIR_right_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ -extern const UWord16 defaultHRIR_coherence_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-15*/ -extern const UWord16 defaultHRIR_left_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-15*/ -extern const UWord16 defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-15*/ +extern const Word32 defaultHRIR_coherence_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-27*/ +extern const Word32 defaultHRIR_left_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ +extern const Word32 defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ -extern const UWord16 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-15*/ -extern const UWord16 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-15*/ -extern const UWord16 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-15*/ +extern const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-27*/ +extern const Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ +extern const Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ #endif // IVAS_FLOAT_FIXED /*----------------------------------------------------------------------------------* * t-design and SN3D normalization table @@ -155,6 +155,12 @@ extern const Word32 t_design_11_elevation_int[70]; * Reverberator ROM tables *-----------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +extern const Word32 ivas_reverb_default_fc_fx[]; +extern const Word32 ivas_reverb_default_RT60_fx[]; +extern const Word32 ivas_reverb_default_DSR_fx[]; +#endif + extern const float ivas_reverb_default_fc[]; extern const float ivas_reverb_default_RT60[]; extern const float ivas_reverb_default_DSR[]; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index dc2dec4eff0114ca6727061af16f43b71d747ee3..9a3b054f2eaebb952df9c6e69a21aa32dd5102da 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -255,6 +255,11 @@ typedef struct dirac_dec_stack_mem { /*Decorrelator*/ float *frame_dec_f; +#ifdef IVAS_FLOAT_FIXED + Word32 *frame_dec_f_fx; + Word16 frame_dec_f_q; + Word16 frame_dec_f_len; +#endif /*Prototypes*/ float *proto_direct_buffer_f; @@ -272,10 +277,14 @@ typedef struct dirac_dec_stack_mem /*Prototypes*/ Word32 *proto_direct_buffer_f_fx; Word32 *proto_diffuse_buffer_f_fx; + Word16 proto_diffuse_buffer_f_len; + Word16 proto_diffuse_buffer_f_q; /*Prototype NRGs*/ Word32 *proto_power_smooth_fx; Word32 *proto_power_diff_smooth_fx; + Word16 proto_power_diff_smooth_q; + Word16 proto_power_diff_smooth_len; /*Gain or power factors for directional and diffuse streams*/ Word32 *direct_power_factor_fx; @@ -401,6 +410,9 @@ typedef struct dirac_output_synthesis_state_structure Word16 *proto_power_smooth_prev_fx; /* Smoothed power of the prototype signals of the previous synthesis block. Size: num_freq_bands*num_channels. */ Word32 *proto_power_diff_smooth_fx; + Word16 proto_power_diff_smooth_q; + Word16 proto_power_diff_smooth_len; + Word16 *proto_power_diff_smooth_prev_fx; /* only pointer to local buffers */ @@ -408,6 +420,7 @@ typedef struct dirac_output_synthesis_state_structure Word16 proto_direct_buffer_f_q; Word32 *proto_diffuse_buffer_f_fx; /* Buffer for diffuse sound prototype signals. Size: 2*num_freq_bands*num_channels*buffer_length (complex interleaved). */ Word16 proto_diffuse_buffer_f_q; + Word16 proto_diffuse_buffer_f_len; /* Output gain memories */ Word32 *gains_dir_prev_fx; /* Direct sound gains of current synthesis block. Size: num_freq_bands*num_channel. */ @@ -595,7 +608,8 @@ typedef struct ivas_dirac_rend_data_structure Word16 *diffuse_response_function_fx; Word16 diffuse_response_function_q; // Q15 Word16 *frequency_axis_fx; - Word32 *hoa_encoder_fx; + Word32 *hoa_encoder_fx; // Q29 + Word16 hoa_encoder_len; #endif float *hoa_encoder; #ifndef IVAS_FLOAT_FIXED @@ -624,9 +638,13 @@ typedef struct ivas_dirac_rend_data_structure float *proto_frame_f; float *proto_frame_dec_f; #ifdef IVAS_FLOAT_FIXED - Word16 *proto_frame_f_fx; + Word32 *proto_frame_f_fx; Word16 proto_frame_f_q; - Word16 *proto_frame_dec_f_fx; + Word16 proto_frame_f_len; + + Word32 *proto_frame_dec_f_fx; + Word16 proto_frame_dec_f_q; + Word16 proto_frame_dec_f_len; #endif DIRAC_DEC_STACK_MEM stack_mem; @@ -1185,6 +1203,7 @@ typedef struct ivas_rev_iir_filter_t typedef float rv_fftwf_type_complex[2]; /* complex type of fftwf library */ #ifdef IVAS_FLOAT_FIXED +typedef Word32 rv_fftwf_type_complex_fx[2]; /* complex type of fftwf library */ /* Convertion block for FFT filter: from time domain to frequency domain (with OLS) and back */ typedef struct ivas_reverb_t2f_f2t_t { @@ -1645,7 +1664,7 @@ typedef struct TDREND_HRFILT_FiltSet_struct Word16 *Elev_p_fx; Word16 *LeftFiltSet_p_fx; Word16 *RightFiltSet_p_fx; - const UWord16 *lr_energy_and_iac_fx[3]; /* left/right energy and interaural coherence for late reverb *//*Q-15*/ + const Word32 *lr_energy_and_iac_fx[3]; /* left/right energy and interaural coherence for late reverb */ Word32 latency_s_fx;/*Q-31*/ #endif // IVAS_FLOAT_FIXED float *lr_energy_and_iac_dyn[3]; @@ -1983,7 +2002,7 @@ typedef struct ivas_hrtfs_parambin_struct Word16 hrtfShCoeffsIm_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS];/*Q-14*/ Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX];/*Q-31*/ Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX];/*Q-31*/ - Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX];/*Q-31*/ + Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX];/*Q-28*/ #endif // IVAS_FLOAT_FIXED float parametricReverberationTimes[CLDFB_NO_CHANNELS_MAX]; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index c7eb4e35c0b4cf2d466ff8a51054bb921f788f44..037c04dbd9eff49cfac40250dba33ef21596de30 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -2095,10 +2095,45 @@ static ivas_error setRendInputActiveIsm( if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { +#if 1 /*Cleanup changes: float to fixed*/ + IF( hRendCfg ) + { + hRendCfg->roomAcoustics.acousticPreDelay_fx = floatToFixed( hRendCfg->roomAcoustics.acousticPreDelay, 27 ); + FOR( int i = 0; i < 60; i++ ) + { + hRendCfg->roomAcoustics.pFc_input_fx[i] = (Word32) ( hRendCfg->roomAcoustics.pFc_input[i] * ONE_IN_Q16 ); + hRendCfg->roomAcoustics.pAcoustic_rt60_fx[i] = (Word32) ( ( hRendCfg->roomAcoustics.pAcoustic_rt60[i] ) * ONE_IN_Q26 ); + hRendCfg->roomAcoustics.pAcoustic_dsr_fx[i] = (Word32) ( hRendCfg->roomAcoustics.pAcoustic_dsr[i] * ONE_IN_Q30 ); + } + + hRendCfg->roomAcoustics.inputPreDelay_fx = (Word32) ( hRendCfg->roomAcoustics.inputPreDelay * ONE_IN_Q27 ); + hRendCfg->roomAcoustics.dimensions.x_fx = (Word32) ( hRendCfg->roomAcoustics.dimensions.x * 4194304 ); // Q10.22, min value:1, max :999.0 + hRendCfg->roomAcoustics.dimensions.y_fx = (Word32) ( hRendCfg->roomAcoustics.dimensions.y * 4194304 ); // Q10.22 + hRendCfg->roomAcoustics.dimensions.z_fx = (Word32) ( hRendCfg->roomAcoustics.dimensions.z * 4194304 ); // Q10.22 + + + FOR( int ii = 0; ii < 6; ii++ ) + { + hRendCfg->roomAcoustics.AbsCoeff_fx[ii] = (Word32) ( hRendCfg->roomAcoustics.AbsCoeff[ii] * 1073741824 ); // Q2.30 min :0 max 1 + } + + hRendCfg->roomAcoustics.ListenerOrigin.x_fx = (Word32) ( hRendCfg->roomAcoustics.ListenerOrigin.x * 4194304 ); //( 2147483648 >> 2 ); + hRendCfg->roomAcoustics.ListenerOrigin.y_fx = (Word32) ( hRendCfg->roomAcoustics.ListenerOrigin.y * ( 4194304 ) ); + hRendCfg->roomAcoustics.ListenerOrigin.z_fx = (Word32) ( hRendCfg->roomAcoustics.ListenerOrigin.z * ( 4194304 ) ); + } +#endif // 1 if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } +#if 1 /*Cleanup changes: fixed to float*/ + IF(inputIsm->crendWrapper->hHrtfCrend != NULL ) + { + inputIsm->crendWrapper->hHrtfCrend->gain_lfe = fixedToFloat( inputIsm->crendWrapper->hHrtfCrend->gain_lfe_fx, 14 ); + inputIsm->crendWrapper->hHrtfCrend->latency_s = fixedToFloat( inputIsm->crendWrapper->hHrtfCrend->latency_s_fx, 31 ); + fixedToFloat_arr( inputIsm->crendWrapper->hHrtfCrend->inv_diffuse_weight_fx, inputIsm->crendWrapper->hHrtfCrend->inv_diffuse_weight, 15, 16 ); + } +#endif } else if ( outConfig == IVAS_AUDIO_CONFIG_MASA1 || outConfig == IVAS_AUDIO_CONFIG_MASA2 ) { @@ -2116,10 +2151,28 @@ static ivas_error setRendInputActiveIsm( if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { +#ifdef IVAS_FLOAT_FIXED +#if 1 /*TODO:To be removed later*/ + hRendCfg->roomAcoustics.acousticPreDelay_fx = floatToFixed( hRendCfg->roomAcoustics.acousticPreDelay, 27 ); + for ( int i = 0; i < 60; i++ ) + { + hRendCfg->roomAcoustics.pFc_input_fx[i] = (Word32) ( hRendCfg->roomAcoustics.pFc_input[i] * ONE_IN_Q16 ); + hRendCfg->roomAcoustics.pAcoustic_rt60_fx[i] = (Word32) ( ( hRendCfg->roomAcoustics.pAcoustic_rt60[i] ) * ONE_IN_Q26 ); + hRendCfg->roomAcoustics.pAcoustic_dsr_fx[i] = (Word32) ( hRendCfg->roomAcoustics.pAcoustic_dsr[i] * ONE_IN_Q30 ); + } + + hRendCfg->roomAcoustics.inputPreDelay_fx = (Word32) ( hRendCfg->roomAcoustics.inputPreDelay * ONE_IN_Q27 ); +#endif + if ( ( error = ivas_reverb_open( &( inputIsm->hReverb ), outConfig, NULL,inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } +#else if ( ( error = ivas_reverb_open( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, hRendCfg, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } +#endif // IVAS_FLOAT_FIXED } } @@ -3514,19 +3567,72 @@ static ivas_error initMcBinauralRendering( if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && inputMc->hReverb == NULL ) { +#ifdef IVAS_FLOAT_FIXED +#if 1 /*TODO:To be removed later*/ + hRendCfg->roomAcoustics.acousticPreDelay_fx = floatToFixed( hRendCfg->roomAcoustics.acousticPreDelay, 27 ); + for ( int i = 0; i < 60; i++ ) + { + hRendCfg->roomAcoustics.pFc_input_fx[i] = (Word32) ( hRendCfg->roomAcoustics.pFc_input[i] * ONE_IN_Q16 ); + hRendCfg->roomAcoustics.pAcoustic_rt60_fx[i] = (Word32) ( ( hRendCfg->roomAcoustics.pAcoustic_rt60[i] ) * ONE_IN_Q26 ); + hRendCfg->roomAcoustics.pAcoustic_dsr_fx[i] = (Word32) ( hRendCfg->roomAcoustics.pAcoustic_dsr[i] * ONE_IN_Q30 ); + } + + hRendCfg->roomAcoustics.inputPreDelay_fx = (Word32) ( hRendCfg->roomAcoustics.inputPreDelay * ONE_IN_Q27 ); +#endif + if ( ( error = ivas_reverb_open( &( inputMc->hReverb ), outConfig, NULL,inputMc->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, outSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } +#else if ( ( error = ivas_reverb_open( &( inputMc->hReverb ), outConfig, NULL, inputMc->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, hRendCfg, outSampleRate ) ) != IVAS_ERR_OK ) { return error; } +#endif } } else if ( !useTDRend && inputMc->crendWrapper == NULL ) { /* open CREND */ +#if 1 /*Cleanup changes: float to fixed*/ + IF( hRendCfg ) + { + hRendCfg->roomAcoustics.acousticPreDelay_fx = floatToFixed( hRendCfg->roomAcoustics.acousticPreDelay, 27 ); + FOR( int i = 0; i < 60; i++ ) + { + hRendCfg->roomAcoustics.pFc_input_fx[i] = (Word32) ( hRendCfg->roomAcoustics.pFc_input[i] * ONE_IN_Q16 ); + hRendCfg->roomAcoustics.pAcoustic_rt60_fx[i] = (Word32) ( ( hRendCfg->roomAcoustics.pAcoustic_rt60[i] ) * ONE_IN_Q26 ); + hRendCfg->roomAcoustics.pAcoustic_dsr_fx[i] = (Word32) ( hRendCfg->roomAcoustics.pAcoustic_dsr[i] * ONE_IN_Q30 ); + } + + hRendCfg->roomAcoustics.inputPreDelay_fx = (Word32) ( hRendCfg->roomAcoustics.inputPreDelay * ONE_IN_Q27 ); + hRendCfg->roomAcoustics.dimensions.x_fx = (Word32) ( hRendCfg->roomAcoustics.dimensions.x * 4194304 ); // Q10.22, min value:1, max :999.0 + hRendCfg->roomAcoustics.dimensions.y_fx = (Word32) ( hRendCfg->roomAcoustics.dimensions.y * 4194304 ); // Q10.22 + hRendCfg->roomAcoustics.dimensions.z_fx = (Word32) ( hRendCfg->roomAcoustics.dimensions.z * 4194304 ); // Q10.22 + + + FOR( int ii = 0; ii < 6; ii++ ) + { + hRendCfg->roomAcoustics.AbsCoeff_fx[ii] = (Word32) ( hRendCfg->roomAcoustics.AbsCoeff[ii] * 1073741824 ); // Q2.30 min :0 max 1 + } + + hRendCfg->roomAcoustics.ListenerOrigin.x_fx = (Word32) ( hRendCfg->roomAcoustics.ListenerOrigin.x * 4194304 ); //( 2147483648 >> 2 ); + hRendCfg->roomAcoustics.ListenerOrigin.y_fx = (Word32) ( hRendCfg->roomAcoustics.ListenerOrigin.y * ( 4194304 ) ); + hRendCfg->roomAcoustics.ListenerOrigin.z_fx = (Word32) ( hRendCfg->roomAcoustics.ListenerOrigin.z * ( 4194304 ) ); + } +#endif // 1 if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, NULL, outSampleRate ) ) != IVAS_ERR_OK ) { return error; } +#if 1 /*Cleanup changes: fixed to float*/ + IF( inputMc->crendWrapper->hHrtfCrend != NULL ) + { + inputMc->crendWrapper->hHrtfCrend->gain_lfe = fixedToFloat( inputMc->crendWrapper->hHrtfCrend->gain_lfe_fx, 14 ); + inputMc->crendWrapper->hHrtfCrend->latency_s = fixedToFloat( inputMc->crendWrapper->hHrtfCrend->latency_s_fx, 31 ); + fixedToFloat_arr( inputMc->crendWrapper->hHrtfCrend->inv_diffuse_weight_fx, inputMc->crendWrapper->hHrtfCrend->inv_diffuse_weight, 15, 16 ); + } +#endif } /* Initialise the EFAP handle for rotation on input layout */ @@ -4040,6 +4146,33 @@ static ivas_error updateSbaPanGains( const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg ) { +#if 1 /*Cleanup changes: float to fixed*/ + IF( hRendCfg ) + { + hRendCfg->roomAcoustics.acousticPreDelay_fx = floatToFixed( hRendCfg->roomAcoustics.acousticPreDelay, 27 ); + FOR( int i = 0; i < 60; i++ ) + { + hRendCfg->roomAcoustics.pFc_input_fx[i] = (Word32) ( hRendCfg->roomAcoustics.pFc_input[i] * ONE_IN_Q16 ); + hRendCfg->roomAcoustics.pAcoustic_rt60_fx[i] = (Word32) ( ( hRendCfg->roomAcoustics.pAcoustic_rt60[i] ) * ONE_IN_Q26 ); + hRendCfg->roomAcoustics.pAcoustic_dsr_fx[i] = (Word32) ( hRendCfg->roomAcoustics.pAcoustic_dsr[i] * ONE_IN_Q30 ); + } + + hRendCfg->roomAcoustics.inputPreDelay_fx = (Word32) ( hRendCfg->roomAcoustics.inputPreDelay * ONE_IN_Q27 ); + hRendCfg->roomAcoustics.dimensions.x_fx = (Word32) ( hRendCfg->roomAcoustics.dimensions.x * 4194304 ); // Q10.22, min value:1, max :999.0 + hRendCfg->roomAcoustics.dimensions.y_fx = (Word32) ( hRendCfg->roomAcoustics.dimensions.y * 4194304 ); // Q10.22 + hRendCfg->roomAcoustics.dimensions.z_fx = (Word32) ( hRendCfg->roomAcoustics.dimensions.z * 4194304 ); // Q10.22 + + + FOR( int ii = 0; ii < 6; ii++ ) + { + hRendCfg->roomAcoustics.AbsCoeff_fx[ii] = (Word32) ( hRendCfg->roomAcoustics.AbsCoeff[ii] * 1073741824 ); // Q2.30 min :0 max 1 + } + + hRendCfg->roomAcoustics.ListenerOrigin.x_fx = (Word32) ( hRendCfg->roomAcoustics.ListenerOrigin.x * 4194304 ); //( 2147483648 >> 2 ); + hRendCfg->roomAcoustics.ListenerOrigin.y_fx = (Word32) ( hRendCfg->roomAcoustics.ListenerOrigin.y * ( 4194304 ) ); + hRendCfg->roomAcoustics.ListenerOrigin.z_fx = (Word32) ( hRendCfg->roomAcoustics.ListenerOrigin.z * ( 4194304 ) ); + } +#endif // 1 ivas_error error; AUDIO_CONFIG inConfig; rendering_context rendCtx; @@ -4100,6 +4233,14 @@ static ivas_error updateSbaPanGains( return error; } +#if 1 /*Cleanup changes: fixed to float*/ + IF( inputSba->crendWrapper->hHrtfCrend != NULL ) + { + inputSba->crendWrapper->hHrtfCrend->gain_lfe = fixedToFloat( inputSba->crendWrapper->hHrtfCrend->gain_lfe_fx, 14 ); + inputSba->crendWrapper->hHrtfCrend->latency_s = fixedToFloat( inputSba->crendWrapper->hHrtfCrend->latency_s_fx, 31 ); + fixedToFloat_arr( inputSba->crendWrapper->hHrtfCrend->inv_diffuse_weight_fx, inputSba->crendWrapper->hHrtfCrend->inv_diffuse_weight, 15, 16 ); + } +#endif return IVAS_ERR_OK; } #else @@ -5901,10 +6042,18 @@ ivas_error IVAS_REND_InitConfig( { return error; } +#ifdef IVAS_FLOAT_FIXED + IF ((error = ivas_render_config_init_from_rom_fx(&hIvasRend->hRendererConfig)) != IVAS_ERR_OK) + { + return error; + } +#endif + /*FLOAT CODE*/ if ( ( error = ivas_render_config_init_from_rom( &hIvasRend->hRendererConfig ) ) != IVAS_ERR_OK ) { return error; } + /*----------*/ } else { @@ -10592,8 +10741,20 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( } hDirACRend->hoa_encoder = NULL; +#ifdef IVAS_FLOAT_FIXED + hDirACRend->hoa_encoder_fx = NULL; +#endif if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_SHD ) { +#ifdef IVAS_FLOAT_FIXED + IF ( ( hDirACRend->hoa_encoder_fx = (Word32 *) malloc( nchan_out_woLFE * hDirACRend->num_outputs_diff * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); + } + + set32_fx( hDirACRend->hoa_encoder_fx, 0, nchan_out_woLFE * hDirACRend->num_outputs_diff ); + hDirACRend->hoa_encoder_len = nchan_out_woLFE * hDirACRend->num_outputs_diff; +#endif if ( ( hDirACRend->hoa_encoder = (float *) malloc( nchan_out_woLFE * hDirACRend->num_outputs_diff * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) );