diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 93712860a5dc550bfab1989ee23e789b02e32ff1..860fa74772bf2205c28ef11ef70d09175e531e5d 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -2717,8 +2717,7 @@ enum #define LG10 24660 /* 10*log10(2) in Q13 */ #define LG10_s3_0 16440 /* 10*log10(2)/1.55 = 1.00343331 in Q14 */ #define LOG2_10 27213 /* log base 2 of 10 in Q12 */ -#define LOG10_2 646456993 /* log base 10 of 2 in Q31 */ - +#define INV_LOG10_2_Q31 646456993 /* inverse log base 10 of 2 in Q31 */ #define MU_MA_FX 10923 /* original prediction factor for the AMR WB tables (Q15) */ #define E_MIN_FXQ15 115 /* Q15*/ @@ -3025,6 +3024,8 @@ extern const Word16 Idx2Freq_Tbl[]; #define FS_16K_IN_NS_Q31 34360 #define ONE_BY_THREE_Q15 10923 /* 1/3.f in Q15 */ +#define THREE_Q21 6291456 +#define SIX_Q21 12582912 typedef enum { diff --git a/lib_com/float_to_fix_ops.c b/lib_com/float_to_fix_ops.c index 5024b356e57dd5ea6f0a24eab70dd9f3c29d5282..fbe22060b06fa0adf8a65dd4997ff49e81e60064 100644 --- a/lib_com/float_to_fix_ops.c +++ b/lib_com/float_to_fix_ops.c @@ -320,7 +320,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( 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 ); + //st->hTcxDec->conceal_eof_gain = (Word16) floatToFixed( st->hTcxDec->conceal_eof_gain_float, 14 ); } IF( st->hHQ_core ) { @@ -363,20 +363,9 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( st->last_gain_syn_deemph = 0; IF( hBWE_TD ) { - Q_state_lsyn_filt_shb = Q_factor_arr( hBWE_TD->state_lsyn_filt_shb, 6 ); - floatToFixed_arr( hBWE_TD->state_lsyn_filt_shb, hBWE_TD->state_lsyn_filt_shb_fx, Q_state_lsyn_filt_shb, 6 ); - Q_state_lsyn_filt_dwn_shb = Q_factor_arr( hBWE_TD->state_lsyn_filt_dwn_shb, 6 ); - floatToFixed_arr( hBWE_TD->state_lsyn_filt_dwn_shb, hBWE_TD->state_lsyn_filt_dwn_shb_fx, Q_state_lsyn_filt_dwn_shb, 6 ); - Q_mem_resamp_HB = Q_factor_arr( hBWE_TD->mem_resamp_HB, 13 ); - floatToFixed_arr( hBWE_TD->mem_resamp_HB, hBWE_TD->mem_resamp_HB_fx, Q_mem_resamp_HB, 13 ); Q_syn_overlap = Q_factor_arr( hBWE_TD->syn_overlap, 20 ); floatToFixed_arr( hBWE_TD->syn_overlap, hBWE_TD->syn_overlap_fx, Q_syn_overlap, 20 ); - Q_int_3_over_2_tbemem_dec = Q_factor_arr( hBWE_TD->int_3_over_2_tbemem_dec, 15 ); - Q_mem_resamp_HB_32k = Q_factor_arr( hBWE_TD->mem_resamp_HB_32k, 7 ); - floatToFixed_arr( hBWE_TD->int_3_over_2_tbemem_dec, hBWE_TD->int_3_over_2_tbemem_dec_fx, Q_int_3_over_2_tbemem_dec, INTERP_3_2_MEM_LEN ); - floatToFixed_arr( hBWE_TD->mem_resamp_HB_32k, hBWE_TD->mem_resamp_HB_32k_fx, Q_mem_resamp_HB_32k, 7 ); } - //st->TcxBandwidth = (Word16) floatToFixed( st->TcxBandwidth_float, 15 ); } else { @@ -405,18 +394,8 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( IF( st->hBWE_TD != NULL ) { - Q_state_lsyn_filt_shb = Q_factor_arr( hBWE_TD->state_lsyn_filt_shb, 6 ); - Q_state_lsyn_filt_dwn_shb = Q_factor_arr( hBWE_TD->state_lsyn_filt_dwn_shb, 6 ); - Q_mem_resamp_HB = Q_factor_arr( hBWE_TD->mem_resamp_HB, 13 ); Q_syn_overlap = Q_factor_arr( hBWE_TD->syn_overlap, 20 ); - Q_int_3_over_2_tbemem_dec = Q_factor_arr( hBWE_TD->int_3_over_2_tbemem_dec, 15 ); - Q_mem_resamp_HB_32k = Q_factor_arr( hBWE_TD->mem_resamp_HB_32k, 7 ); - fixedToFloat_arr( hBWE_TD->state_lsyn_filt_shb_fx, hBWE_TD->state_lsyn_filt_shb, Q_state_lsyn_filt_shb, 6 ); - fixedToFloat_arr( hBWE_TD->state_lsyn_filt_dwn_shb_fx, hBWE_TD->state_lsyn_filt_dwn_shb, Q_state_lsyn_filt_dwn_shb, 6 ); - fixedToFloat_arr( hBWE_TD->mem_resamp_HB_fx, hBWE_TD->mem_resamp_HB, Q_mem_resamp_HB, 13 ); fixedToFloat_arr( hBWE_TD->syn_overlap_fx, hBWE_TD->syn_overlap, Q_syn_overlap, 20 ); - fixedToFloat_arr( hBWE_TD->int_3_over_2_tbemem_dec_fx, hBWE_TD->int_3_over_2_tbemem_dec, Q_int_3_over_2_tbemem_dec, 15 ); - fixedToFloat_arr( hBWE_TD->mem_resamp_HB_32k_fx, hBWE_TD->mem_resamp_HB_32k, Q_mem_resamp_HB_32k, 7 ); } IF( st->hTcxDec ) { @@ -431,7 +410,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( 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->conceal_eof_gain_float = fixedToFloat( st->hTcxDec->conceal_eof_gain, 14 ); st->hTcxDec->CngLevelBackgroundTrace_bfi = fixedToFloat( st->hTcxDec->CngLevelBackgroundTrace_bfi_fx, 15 ); } @@ -562,7 +541,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( 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 ); + //st->hTcxDec->conceal_eof_gain = (Word16) floatToFixed( st->hTcxDec->conceal_eof_gain_float, 14 ); } IF( st->hHQ_core ) { @@ -604,18 +583,8 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( st->last_gain_syn_deemph = 0; IF( hBWE_TD ) { - Q_state_lsyn_filt_shb = Q_factor_arr( hBWE_TD->state_lsyn_filt_shb, 6 ); - floatToFixed_arr( hBWE_TD->state_lsyn_filt_shb, hBWE_TD->state_lsyn_filt_shb_fx, Q_state_lsyn_filt_shb, 6 ); - Q_state_lsyn_filt_dwn_shb = Q_factor_arr( hBWE_TD->state_lsyn_filt_dwn_shb, 6 ); - floatToFixed_arr( hBWE_TD->state_lsyn_filt_dwn_shb, hBWE_TD->state_lsyn_filt_dwn_shb_fx, Q_state_lsyn_filt_dwn_shb, 6 ); - Q_mem_resamp_HB = Q_factor_arr( hBWE_TD->mem_resamp_HB, 13 ); - floatToFixed_arr( hBWE_TD->mem_resamp_HB, hBWE_TD->mem_resamp_HB_fx, Q_mem_resamp_HB, 13 ); Q_syn_overlap = Q_factor_arr( hBWE_TD->syn_overlap, 20 ); floatToFixed_arr( hBWE_TD->syn_overlap, hBWE_TD->syn_overlap_fx, Q_syn_overlap, 20 ); - Q_int_3_over_2_tbemem_dec = Q_factor_arr( hBWE_TD->int_3_over_2_tbemem_dec, 15 ); - Q_mem_resamp_HB_32k = Q_factor_arr( hBWE_TD->mem_resamp_HB_32k, 7 ); - floatToFixed_arr( hBWE_TD->int_3_over_2_tbemem_dec, hBWE_TD->int_3_over_2_tbemem_dec_fx, Q_int_3_over_2_tbemem_dec, INTERP_3_2_MEM_LEN ); - floatToFixed_arr( hBWE_TD->mem_resamp_HB_32k, hBWE_TD->mem_resamp_HB_32k_fx, Q_mem_resamp_HB_32k, 7 ); } } else @@ -643,21 +612,10 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( st->hIGFDec->igfData.pSpecFlat_float = &st->hIGFDec->igfData.pSpecFlatBuf[0]; st->hIGFDec->igfData.igfInfo.nfSeed = &st->hIGFDec->igfData.igfInfo.nfSeedBuf[0]; } - //st->TcxBandwidth_float = fixedToFloat( st->TcxBandwidth, 15 ); IF( st->hBWE_TD != NULL ) { - Q_state_lsyn_filt_shb = Q_factor_arr( hBWE_TD->state_lsyn_filt_shb, 6 ); - Q_state_lsyn_filt_dwn_shb = Q_factor_arr( hBWE_TD->state_lsyn_filt_dwn_shb, 6 ); - Q_mem_resamp_HB = Q_factor_arr( hBWE_TD->mem_resamp_HB, 13 ); Q_syn_overlap = Q_factor_arr( hBWE_TD->syn_overlap, 20 ); - Q_int_3_over_2_tbemem_dec = Q_factor_arr( hBWE_TD->int_3_over_2_tbemem_dec, 15 ); - Q_mem_resamp_HB_32k = Q_factor_arr( hBWE_TD->mem_resamp_HB_32k, 7 ); - fixedToFloat_arr( hBWE_TD->state_lsyn_filt_shb_fx, hBWE_TD->state_lsyn_filt_shb, Q_state_lsyn_filt_shb, 6 ); - fixedToFloat_arr( hBWE_TD->state_lsyn_filt_dwn_shb_fx, hBWE_TD->state_lsyn_filt_dwn_shb, Q_state_lsyn_filt_dwn_shb, 6 ); - fixedToFloat_arr( hBWE_TD->mem_resamp_HB_fx, hBWE_TD->mem_resamp_HB, Q_mem_resamp_HB, 13 ); fixedToFloat_arr( hBWE_TD->syn_overlap_fx, hBWE_TD->syn_overlap, Q_syn_overlap, 20 ); - fixedToFloat_arr( hBWE_TD->int_3_over_2_tbemem_dec_fx, hBWE_TD->int_3_over_2_tbemem_dec, Q_int_3_over_2_tbemem_dec, 15 ); - fixedToFloat_arr( hBWE_TD->mem_resamp_HB_32k_fx, hBWE_TD->mem_resamp_HB_32k, Q_mem_resamp_HB_32k, 7 ); } IF( st->hTcxDec ) { @@ -672,7 +630,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( 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->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; st->hTcxDec->conCngLevelBackgroundTrace_e = 0; @@ -750,7 +708,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( st->hTcxDec->old_excFB_fx[p] = (Word16) ( st->hTcxDec->old_excFB[p] * ( 1u << st->Q_exc ) ); } st->prev_Q_syn = st->Q_syn; - st->hTcxDec->conceal_eof_gain = (Word16) floatToFixed( st->hTcxDec->conceal_eof_gain_float, Q14 ); + //st->hTcxDec->conceal_eof_gain = (Word16) floatToFixed( st->hTcxDec->conceal_eof_gain_float, Q14 ); st->hTcxDec->conCngLevelBackgroundTrace = (Word16) floatToFixed( st->hTcxDec->CngLevelBackgroundTrace_bfi, Q15 - st->hTcxDec->conCngLevelBackgroundTrace_e ); if ( st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) { @@ -870,7 +828,8 @@ void fixed_to_float_stereo_tcx_core_dec( } 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->conceal_eof_gain_float = fixedToFloat( st->hTcxDec->conceal_eof_gain, Q14 ); st->hTcxDec->CngLevelBackgroundTrace_bfi = fixedToFloat( st->hTcxDec->conCngLevelBackgroundTrace, 15 - st->hTcxDec->conCngLevelBackgroundTrace_e ); diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index 70e7bbab26785d56a690e669f1e55ab29d408fbe..f50352022909b9d2083c076009ca2bcd886955b3 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -189,7 +189,7 @@ static Word16 ivas_imax2_jacobsen_mag_fx( IF( NE_32( numer, 0 ) && NE_32( denom, 0 ) ) { tmp = BASOP_Util_Divide3232_Scale( numer, denom, &tmp_e ); - tmp = shl( tmp, tmp_e ); // Q15 + tmp = shl_sat( tmp, tmp_e ); // Q15 posi = shl_sat( mult_r( tmp, C_JACOB_FX ), Q1 ); // Q15 } ELSE diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 6af132d21edad1813ba64eee93861537eff6781d..f59965da9e15bf8592aa79e3852cf1698dc816b6 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -2631,7 +2631,6 @@ void acelp_decoder_state_float2fix(Decoder_State *st, STEREO_CNG_DEC_HANDLE hSte //FdCng if ( st->hFdCngDec ) { - //floatToFixed_arrL( st->hFdCngDec->hFdCngCom->sidNoiseEst_flt, st->hFdCngDec->hFdCngCom->sidNoiseEst, 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); @@ -2642,8 +2641,6 @@ 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); - //st->hFdCngDec->partNoiseShape_exp = 31 - Q4; - //floatToFixed_arrL(st->hFdCngDec->partNoiseShape_float, st->hFdCngDec->partNoiseShape, Q31 - st->hFdCngDec->partNoiseShape_exp, NPART); /*CNA: ApplyFdCng*/ if ((st->hFdCngDec != NULL || st->idchan == 1) && st->element_mode != IVAS_CPE_MDCT) { diff --git a/lib_dec/bass_psfilter.c b/lib_dec/bass_psfilter.c index cd1be6136a660a43013f1bf022827b8dc2d75a93..fec418241fcc0c351de5191e4f76e6f3c3755a1e 100644 --- a/lib_dec/bass_psfilter.c +++ b/lib_dec/bass_psfilter.c @@ -718,11 +718,11 @@ Word16 res_bpf_adapt_fx( } error_nrg = L_shr( error_nrg, 1 ); // Q0 error_nrg = Mpy_32_16_1( error_nrg, 6553 /* 0.2f in Q15 */ ); /* Division by 5 for average value */ - bpf_error_ratio = LT_32( ( L_shr( error_nrg, 1 ) ), res_hb_nrg ) ? (Word16) ( L_shl( ( L_shl( error_nrg, Q5 ) / res_hb_nrg ), Q7 ) ) : shl( ONE_IN_Q12, 1 ); /* Form decision variable and apply limit */ + bpf_error_ratio = LT_32( ( L_shr( error_nrg, 1 ) ), res_hb_nrg ) ? (Word16) ( L_shl( ( L_shl( error_nrg, Q5 ) / res_hb_nrg ), Q8 ) ) : shl( ONE_IN_Q12, 1 ); /* Form decision variable and apply limit */ bpf_error_ratio = add( mult( STEREO_DFT_BPF_ADAPT_BETA_FX, bpf_error_ratio ), mult( sub( MAX_16, STEREO_DFT_BPF_ADAPT_BETA_FX ), hStereoDft->bpf_error_ratio_mem_fx ) ); hStereoDft->bpf_error_ratio_mem_fx = bpf_error_ratio; - res_bpf_flag = (Word16) LT_16( bpf_error_ratio, ONE_IN_Q12 ); + res_bpf_flag = (Word16) LT_16( bpf_error_ratio, ONE_IN_Q13 ); return res_bpf_flag; } diff --git a/lib_dec/core_dec_init.c b/lib_dec/core_dec_init.c index d2e00d93a9cc149221761ef7c5899db98ac6e4c3..92fb2b89fba7f27acdbd3c53c4b44eb007de40b2 100644 --- a/lib_dec/core_dec_init.c +++ b/lib_dec/core_dec_init.c @@ -535,11 +535,11 @@ void open_decoder_LPD_flt( otherwise some data from MODE1 would be needed here */ #if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) st->last_concealed_gain_syn_deemph_float = 1.f; -#endif // #if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) if (hTcxDec != NULL) { hTcxDec->conceal_eof_gain_float = 1.0f; } +#endif // #if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) } /* Post processing */ #if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index b92493183f47548b0f10d972d79e284d2d1f12f0..ba7a2af099cd2666087e389897e341c15205ab55 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -175,7 +175,9 @@ ivas_error core_switching_pre_dec_ivas_fx( { st->last_core = HQ_CORE; move16(); - Copy( st->hTcxDec->FBTCXdelayBuf, st->prev_synth_buffer_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); + //Copy( st->hTcxDec->FBTCXdelayBuf, st->prev_synth_buffer_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); + Copy32( st->hTcxDec->FBTCXdelayBuf, st->prev_synth_buffer32_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); + //Copy_Scale_sig_32_16( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); //Q11 -> Q0 } IF( st->hHQ_core != NULL ) diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c index 82b515c144c12e381c6dc74613c68654255174d7..af60516cf0a429330683938f23a59979e270a33c 100644 --- a/lib_dec/hf_synth_fx.c +++ b/lib_dec/hf_synth_fx.c @@ -47,7 +47,7 @@ static void AdaptiveStartBand_fx( Word16 *start_band, const Word32 rate, const * - initialization of 400 Hz high pass filter * - initialization of band pass 6kHz to 7kHz FIR filter *-------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED + void hf_synth_init_fx( ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ ) @@ -75,41 +75,6 @@ void hf_synth_reset_fx( set16_fx(hBWE_zero->mem_hf_fx, 0, ( L_FIR - 1 ) ); set16_fx(hBWE_zero->mem_syn_hf_fx, 0, M); - set16_fx(hBWE_zero->mem_hp400_fx, 0, 6); - - set16_fx(hBWE_zero->delay_syn_hf_fx, 0, NS2SA(16000, DELAY_CLDFB_NS)); - set16_fx(hBWE_zero->mem_hp_interp_fx, 0, INTERP_3_1_MEM_LEN); - - return; -} -#else -void hf_synth_init_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ -) -{ - - hBWE_zero->seed2 = RANDOM_INITSEED; - set16_fx(hBWE_zero->mem_hf_fx, 0, 2 * L_FILT16k); - set16_fx(hBWE_zero->mem_syn_hf_fx, 0, M); - set16_fx(hBWE_zero->mem_hp400_fx, 0, 4); - set16_fx(hBWE_zero->delay_syn_hf_fx, 0, NS2SA(16000, DELAY_CLDFB_NS)); - set16_fx(hBWE_zero->mem_hp_interp_fx, 0, INTERP_3_1_MEM_LEN); - - return; -} -void hf_synth_reset_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ -) -{ - Word16 i; - - FOR(i = 0; i < L_FRAME16k; i++) - { - Random(&hBWE_zero->seed2); - } - - set16_fx(hBWE_zero->mem_hf_fx, 0, 2 * L_FILT16k); - set16_fx(hBWE_zero->mem_syn_hf_fx, 0, M); set16_fx(hBWE_zero->mem_hp400_fx, 0, 4); /* TBV -> mem_hp400_fx has a length of 6, but only 4 values initialized in EVS ??? */ set16_fx(hBWE_zero->delay_syn_hf_fx, 0, NS2SA(16000, DELAY_CLDFB_NS)); @@ -117,7 +82,6 @@ void hf_synth_reset_fx( return; } -#endif /*---------------------------------------------------------------------* * hf_synth() diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 302c87efbf8dbf93b1812b034b10bb33651a604a..7ad048e8df20b90c343a3adaeb3b0a9374aaf879 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -1136,7 +1136,7 @@ ivas_error init_decoder_ivas_fx( //st_fx->tilt_wb = 0.0f; //st_fx->last_voice_factor = 0.0f; - set_f(st_fx->prev_synth_buffer, 0, NS2SA(48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS)); + //set_f(st_fx->prev_synth_buffer, 0, NS2SA(48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS)); st_fx->old_bfi_cnt = 0; } @@ -1169,6 +1169,7 @@ ivas_error init_decoder_ivas_fx( set16_fx(st_fx->prev_synth_buffer_fx, 0, NS2SA_fx2(48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS)); st_fx->Qprev_synth_buffer_fx = 15; move16(); + set32_fx(st_fx->prev_synth_buffer32_fx, 0, NS2SA_fx2(48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS)); st_fx->old_bfi_cnt = 0; move16(); diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 67d302c9896ade21037a37db73378100956188e2..f3d44cf003be06fa6546fa9c3844002b50062a38 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -171,6 +171,7 @@ ivas_error ivas_core_dec( Word16 synth_16fx[CPE_CHANNELS][L_FRAME48k]; Word32 pitch_buf_32fx[CPE_CHANNELS][NB_SUBFR16k]; Word16 tdm_lsfQ_PCh_fx[M], tdm_lspQ_PCh_fx[M]; + Word32 conceal_eof_gain32; #endif #ifdef BASOP_NOGLOB Flag Overflow; @@ -183,48 +184,45 @@ ivas_error ivas_core_dec( * General initialization *-----------------------------------------------------------------*/ -#ifndef TO_BE_REMOVED_CONVERSION - Word16 k; - - if ( hSCE != NULL ) - { - sts = hSCE->hCoreCoder; - } - else - { - sts = hCPE->hCoreCoder; - } - - //core_coding_part will go in this loop, once the things are done - for ( k = 0; k < n_channels; k++ ) - { - if ( sts[k]->hTcxDec != NULL ) - { - floatToFixed_arr( sts[k]->hHQ_core->old_out, sts[k]->hHQ_core->old_out_fx, 0, L_FRAME48k ); - floatToFixed_arr( sts[k]->hHQ_core->old_outLB, sts[k]->hHQ_core->old_out_LB_fx, 0, L_FRAME32k ); - floatToFixed_arrL( sts[k]->hHQ_core->old_outLB, sts[k]->hHQ_core->old_outLB_fx, 11, L_FRAME32k ); - sts[k]->hTcxDec->conceal_eof_gain32 = floatToFixed( sts[k]->hTcxDec->conceal_eof_gain_float, 15 ); - //f2me_16( sts[k]->last_concealed_gain_syn_deemph_float, &sts[k]->last_concealed_gain_syn_deemph, &sts[k]->last_concealed_gain_syn_deemph_e ); - } - } - - if ( hCPE != NULL && hCPE->last_element_mode == IVAS_CPE_MDCT && hCPE->element_mode == IVAS_CPE_DFT ) - { - floatToFixed_arrL( hCPE->input_mem_LB[0], hCPE->input_mem_LB_fx[0], 11, STEREO_DFT32MS_OVL_16k ); - // fixedToFloat_arrL(hCPE->old_outLB_mdct_fx, hCPE->old_outLB_mdct, 11, STEREO_MDCT2DFT_FADE_LEN_48k); - } - - IF( sts[0]->element_mode == IVAS_CPE_MDCT && sts[0]->total_brate == SID_2k40 ) - { - FOR( Word16 ch = 0; ch < CPE_CHANNELS; ++ch ) - { - //f2me_buf( sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst_flt, sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst, &sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEstExp, sts[ch]->hFdCngDec->hFdCngCom->npart ); - f2me_buf( sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel, &sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, sts[ch]->hFdCngDec->hFdCngCom->stopBand - sts[ch]->hFdCngDec->hFdCngCom->startBand ); - floatToFixed_arr( sts[ch]->hFdCngDec->hFdCngCom->A_cng_flt, sts[ch]->hFdCngDec->hFdCngCom->A_cng, Q14, M + 1 ); - } - } - -#endif +//#ifndef TO_BE_REMOVED_CONVERSION +// Word16 k; +// +// if ( hSCE != NULL ) +// { +// sts = hSCE->hCoreCoder; +// } +// else +// { +// sts = hCPE->hCoreCoder; +// } +// +// //core_coding_part will go in this loop, once the things are done +// for ( k = 0; k < n_channels; k++ ) +// { +// if ( sts[k]->hTcxDec != NULL ) +// { +// floatToFixed_arr( sts[k]->hHQ_core->old_out, sts[k]->hHQ_core->old_out_fx, 0, L_FRAME48k ); +// floatToFixed_arr( sts[k]->hHQ_core->old_outLB, sts[k]->hHQ_core->old_out_LB_fx, 0, L_FRAME32k ); +// floatToFixed_arrL( sts[k]->hHQ_core->old_outLB, sts[k]->hHQ_core->old_outLB_fx, 11, L_FRAME32k ); +// //sts[k]->hTcxDec->conceal_eof_gain32 = floatToFixed( sts[k]->hTcxDec->conceal_eof_gain_float, 15 ); +// } +// } +// +// if ( hCPE != NULL && hCPE->last_element_mode == IVAS_CPE_MDCT && hCPE->element_mode == IVAS_CPE_DFT ) +// { +// floatToFixed_arrL( hCPE->input_mem_LB[0], hCPE->input_mem_LB_fx[0], 11, STEREO_DFT32MS_OVL_16k ); +// } +// +// IF( sts[0]->element_mode == IVAS_CPE_MDCT && sts[0]->total_brate == SID_2k40 ) +// { +// FOR( Word16 ch = 0; ch < CPE_CHANNELS; ++ch ) +// { +// f2me_buf( sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel, &sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, sts[ch]->hFdCngDec->hFdCngCom->stopBand - sts[ch]->hFdCngDec->hFdCngCom->startBand ); +// floatToFixed_arr( sts[ch]->hFdCngDec->hFdCngCom->A_cng_flt, sts[ch]->hFdCngDec->hFdCngCom->A_cng, Q14, M + 1 ); +// } +// } +// +//#endif use_cldfb_for_dft = 0; tdm_LRTD_flag = -1; @@ -315,11 +313,11 @@ ivas_error ivas_core_dec( IF( !st->bfi && st->prev_bfi && ( st->last_core_bfi == TCX_20_CORE || st->last_core_bfi == TCX_10_CORE ) && st->hTcxDec != NULL ) { -#ifdef IVAS_FLOAT_FIXED + conceal_eof_gain32 = L_shl( L_deposit_l( st->hTcxDec->conceal_eof_gain ), 1 ); FOR( i = 0; i < st->hTcxDec->L_frameTCX; i++ ) { - L_tmp = Mpy_32_16_1( st->hTcxDec->conceal_eof_gain32, st->hHQ_core->old_out_fx[i] ); + L_tmp = Mpy_32_16_1( conceal_eof_gain32, st->hHQ_core->old_out_fx[i] ); L_tmp = Mpy_32_16_1( L_tmp, st->last_concealed_gain_syn_deemph ); L_tmp = L_shl( L_tmp, st->last_concealed_gain_syn_deemph_e ); st->hHQ_core->old_out_fx[i] = extract_l( L_tmp ); // Q0 @@ -327,25 +325,16 @@ ivas_error ivas_core_dec( FOR( i = 0; i < st->L_frame; i++ ) { - L_tmp = Mpy_32_16_1( st->hTcxDec->conceal_eof_gain32, st->hHQ_core->old_out_LB_fx[i] ); + L_tmp = Mpy_32_16_1( conceal_eof_gain32, st->hHQ_core->old_out_LB_fx[i] ); L_tmp = Mpy_32_16_1( L_tmp, st->last_concealed_gain_syn_deemph ); L_tmp = L_shl( L_tmp, st->last_concealed_gain_syn_deemph_e ); st->hHQ_core->old_out_LB_fx[i] = extract_l( L_tmp ); // Q0 } Copy_Scale_sig_16_32( st->hHQ_core->old_out_LB_fx, st->hHQ_core->old_outLB_fx, st->L_frame, 11 ); -#else - v_multc( st->hHQ_core->old_out, st->hTcxDec->conceal_eof_gain_float * st->last_concealed_gain_syn_deemph_float, st->hHQ_core->old_out, st->hTcxDec->L_frameTCX ); - v_multc( st->hHQ_core->old_outLB, st->hTcxDec->conceal_eof_gain_float * st->last_concealed_gain_syn_deemph_float, st->hHQ_core->old_outLB, st->L_frame ); -#endif } -#ifdef IVAS_FLOAT_FIXED set16_fx( voice_factors_fx[n], 0, NB_SUBFR16k ); set16_fx( hb_synth_fx[n], 0, L_FRAME48k ); -#else - set_f( voice_factors[n], 0.f, NB_SUBFR16k ); - set_f( hb_synth[n], 0.0f, L_FRAME48k ); -#endif /*------------------------------------------------------------------* * Decision matrix (selection of technologies) @@ -353,16 +342,9 @@ ivas_error ivas_core_dec( IF( st->bfi != 1 ) { -#ifdef IVAS_FLOAT_FIXED ivas_decision_matrix_dec_fx( st, &sharpFlag[n], &core_switching_flag[n], element_brate, nchan_out ); -#else - ivas_decision_matrix_dec( st, &sharpFlag[n], &core_switching_flag[n], element_brate, nchan_out ); -#endif -#ifdef IVAS_FLOAT_FIXED + synchonize_channels_mdct_sid_fx( sts, n ); -#else - synchonize_channels_mdct_sid( sts, n ); -#endif IF( st->bfi != 1 ) /* note: st->bfi can be changed from 0 to 1 in ivas_decision_matrix_dec() when BER is detected */ { @@ -387,28 +369,16 @@ ivas_error ivas_core_dec( Word16 ovl, fade_len; IF( sts[0]->L_frame != sts[0]->last_L_frame ) { -#ifdef IVAS_FLOAT_FIXED L_lerp_fx_q11( sts[0]->hHQ_core->old_outLB_fx, sts[0]->hHQ_core->old_outLB_fx, sts[0]->L_frame, sts[0]->last_L_frame ); Copy_Scale_sig_32_16( sts[0]->hHQ_core->old_outLB_fx, sts[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, -11 ); -#else - lerp_flt( sts[0]->hHQ_core->old_outLB, sts[0]->hHQ_core->old_outLB, sts[0]->L_frame, sts[0]->last_L_frame ); -#endif } IF( sts[0]->L_frame != L_FRAME16k ) { ovl = mult( sts[0]->L_frame, 5120 ); /*STEREO_DFT32MS_OVL_16k/L_FRAME16k = 5/32 = 5120 (Q15)*/ -#ifdef IVAS_FLOAT_FIXED L_lerp_fx_q11( hCPE->input_mem_LB_fx[0], hCPE->input_mem_LB_fx[0], ovl, STEREO_DFT32MS_OVL_16k ); -#else - lerp_flt( hCPE->input_mem_LB[0], hCPE->input_mem_LB[0], ovl, STEREO_DFT32MS_OVL_16k ); -#endif fade_len = mult( sts[0]->L_frame, 12288 ); /* STEREO_MDCT2DFT_FADE_LEN_48k/L_FRAME16k = 3/8 = 12288 (Q15)*/ -#ifdef IVAS_FLOAT_FIXED L_lerp_fx_q11( hCPE->old_outLB_mdct_fx, hCPE->old_outLB_mdct_fx, fade_len, STEREO_MDCT2DFT_FADE_LEN_48k ); -#else - lerp_flt( hCPE->old_outLB_mdct, hCPE->old_outLB_mdct, fade_len, STEREO_MDCT2DFT_FADE_LEN_48k ); -#endif } } @@ -432,9 +402,6 @@ ivas_error ivas_core_dec( IF( sts[0]->element_mode == IVAS_CPE_MDCT && sts[0]->total_brate == SID_2k40 ) { -#ifdef IVAS_FLOAT_FIXED - - IF( sts[0]->cng_sba_flag ) { FdCngDecodeDiracMDCTStereoSID_fx( hCPE ); @@ -443,16 +410,6 @@ ivas_error ivas_core_dec( { FdCngDecodeMDCTStereoSID_fx( hCPE ); } -#else - if ( sts[0]->cng_sba_flag ) - { - FdCngDecodeDiracMDCTStereoSID( hCPE ); - } - else - { - FdCngDecodeMDCTStereoSID( hCPE ); - } -#endif } /*------------------------------------------------------------------* @@ -472,7 +429,7 @@ ivas_error ivas_core_dec( } // n_channels loop // sts is initialized here - for ( k = 0; k < n_channels; k++ ) + for (Word16 k = 0; k < n_channels; k++ ) { if ( sts[k]->hTcxDec != NULL ) { @@ -486,7 +443,6 @@ ivas_error ivas_core_dec( { FOR( Word16 ch = 0; ch < CPE_CHANNELS; ++ch ) { - //me2f_buf( sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst, sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEstExp, sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst_flt, sts[ch]->hFdCngDec->hFdCngCom->npart ); me2f_buf( sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel, sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, sts[ch]->hFdCngDec->hFdCngCom->stopBand - sts[ch]->hFdCngDec->hFdCngCom->startBand ); fixedToFloat_arr( sts[ch]->hFdCngDec->hFdCngCom->A_cng, sts[ch]->hFdCngDec->hFdCngCom->A_cng_flt, Q14, M + 1 ); } @@ -498,7 +454,7 @@ ivas_error ivas_core_dec( * Core Decoding *-----------------------------------------------------------------*/ - for ( n = 0; n < n_channels; n++ ) + FOR ( n = 0; n < n_channels; n++ ) { st = sts[n]; @@ -506,17 +462,17 @@ ivas_error ivas_core_dec( * Initialization *-----------------------------------------------------------------*/ - if ( st->bfi == 1 ) + IF ( st->bfi == 1 ) { st->nbLostCmpt++; } - else + ELSE { - if ( st->prev_bfi == 1 ) + IF ( st->prev_bfi == 1 ) { st->prev_nbLostCmpt = st->nbLostCmpt; } - else + ELSE { st->prev_nbLostCmpt = 0; } @@ -525,7 +481,7 @@ ivas_error ivas_core_dec( } st->enablePlcWaveadjust = 0; - if ( n == 1 ) + IF ( n == 1 ) { sts[1]->BER_detect |= sts[0]->BER_detect; } @@ -540,14 +496,13 @@ ivas_error ivas_core_dec( * Preprocessing (preparing) for ACELP/HQ core switching *---------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED #if 1 /*Float to fix conversions*/ Word16 Q_hb_prev_synth_buffer, - Q_FBTCXdelayBuf = 15, Q_prev_synth_buffer, Q_syn_Overl = 15, Q_fer_samples = 15, Q_old_syn_Overl = 15, /*Q_olapBufferAna = 15,*/ Q_olapBufferSynth = 15, + Q_FBTCXdelayBuf = 15, /*Q_prev_synth_buffer, */Q_syn_Overl = 15, Q_fer_samples = 15, Q_old_syn_Overl = 15, /*Q_olapBufferAna = 15,*/ Q_olapBufferSynth = 15, Q_olapBufferSynth2 = 15, Q_old_synthFB = 15; /*Initializing with max values to avoid warnings*/ Q_hb_prev_synth_buffer = Q_factor_arr( st->hb_prev_synth_buffer, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); - Q_prev_synth_buffer = Q_factor_arr( st->prev_synth_buffer, 96 ); + //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 ) ); IF( st->hHQ_core ) @@ -556,8 +511,9 @@ ivas_error ivas_core_dec( } IF( st->hTcxDec ) { - Q_FBTCXdelayBuf = Q_factor_arr( st->hTcxDec->FBTCXdelayBuf_float, 111 ); - Q_prev_synth_buffer = s_min( Q_prev_synth_buffer, Q_FBTCXdelayBuf ); + //Q_FBTCXdelayBuf = Q_factor_arr( st->hTcxDec->FBTCXdelayBuf_float, 111 ); + //Q_prev_synth_buffer = s_min( Q_prev_synth_buffer, Q_FBTCXdelayBuf ); + //Q_prev_synth_buffer = s_min( Q_prev_synth_buffer, 11 ); 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; } @@ -568,12 +524,14 @@ ivas_error ivas_core_dec( } IF( st->hTcxDec ) { - floatToFixed_arr16( st->hTcxDec->FBTCXdelayBuf_float, st->hTcxDec->FBTCXdelayBuf, Q_prev_synth_buffer, 111 ); + //floatToFixed_arr16( st->hTcxDec->FBTCXdelayBuf_float, st->hTcxDec->FBTCXdelayBuf, Q_prev_synth_buffer, 111 ); + //floatToFixed_arrL( st->hTcxDec->FBTCXdelayBuf_float, st->hTcxDec->FBTCXdelayBuf_32, OUTPUT_Q, 111 ); floatToFixed_arr( st->hTcxDec->syn_Overl_float, st->hTcxDec->syn_Overl, Q_syn_Overl, 320 ); floatToFixed_arr16( st->hTcxDec->old_syn_Overl_float, st->hTcxDec->old_syn_Overl, Q_old_syn_Overl, L_FRAME32k / 2 ); } - floatToFixed_arr16( st->prev_synth_buffer, st->prev_synth_buffer_fx, Q_prev_synth_buffer, 96 ); - st->q_prev_synth_buffer_fx = Q_prev_synth_buffer; + //floatToFixed_arr16( st->prev_synth_buffer, st->prev_synth_buffer_fx, Q_prev_synth_buffer, 96 ); + //floatToFixed_arr16( st->prev_synth_buffer, st->prev_synth_buffer_fx, 0, 96 ); + //st->q_prev_synth_buffer_fx = 0; IF( st->cldfbAna ) { floatToFixed_arr32( st->cldfbAna->cldfb_state, st->cldfbAna->cldfb_state_fx, Q10, st->cldfbAna->cldfb_state_length ); @@ -585,10 +543,6 @@ ivas_error ivas_core_dec( IF( st->hFdCngDec ) { - //Q_olapBufferAna = Q_factor_arr( st->hFdCngDec->hFdCngCom->olapBufferAna_flt, FFTLEN ) - 1; - //floatToFixed_arr16( st->hFdCngDec->hFdCngCom->olapBufferAna_flt, st->hFdCngDec->hFdCngCom->olapBufferAna_fx, Q_olapBufferAna, L_FRAME32k ); - //Q_olapBufferSynth = Q_factor_arrL( st->hFdCngDec->hFdCngCom->olapBufferSynth_flt, 640 ) - 2; - //floatToFixed_arr32( st->hFdCngDec->hFdCngCom->olapBufferSynth_flt, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, Q_olapBufferSynth, 640 ); Q_olapBufferSynth2 = Q_factor_arrL( st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, 640 ) - 1; floatToFixed_arr32( st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, Q_olapBufferSynth2, 640 ); } @@ -612,8 +566,10 @@ ivas_error ivas_core_dec( } #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->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, 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 ); + //st->q_prev_synth_buffer_fx = 0; IF( st->hTcxDec ) { @@ -632,20 +588,12 @@ ivas_error ivas_core_dec( } IF( st->hFdCngDec ) { - //fixedToFloat_arr( st->hFdCngDec->hFdCngCom->olapBufferAna_fx, st->hFdCngDec->hFdCngCom->olapBufferAna_flt, Q_olapBufferAna, L_FRAME32k ); fixedToFloat_arrL( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, Q_olapBufferSynth2, L_FRAME32k ); - //fixedToFloat_arrL( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_flt, Q_olapBufferSynth, L_FRAME32k ); } #endif -#else - if ( ( error = core_switching_pre_dec( st, output_frame, sts[0]->last_core_brate, nchan_out, last_element_mode, last_element_brate ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif flag_sec_CNA = -1; - if ( hCPE != NULL ) + IF ( hCPE != NULL ) { flag_sec_CNA = sts[1]->flag_cna; } @@ -656,11 +604,12 @@ ivas_error ivas_core_dec( * HQ core decoding *---------------------------------------------------------------------*/ - if ( st->core == ACELP_CORE ) + IF ( st->core == ACELP_CORE ) { /* ACELP core decoder */ -#ifdef IVAS_FLOAT_FIXED + Word16 output_fx[L_FRAME48k], synth_fxl[L_FRAME48k], old_syn_12k8_16k_fx_16[L_FRAME16k]; + set_s(output_fx, 0, L_FRAME48k); Word16 save_hb_synth_fx_arr[L_FRAME48k], *save_hb_synth_fx; if (save_hb_synth) { @@ -673,13 +622,15 @@ ivas_error ivas_core_dec( /* float2fix, to be removed */ acelp_decoder_state_float2fix(st, hCPE == NULL ? NULL : hCPE->hStereoCng); - if (hStereoTD) { - floatToFixed_arr(hStereoTD->tdm_Pri_pitch_buf, hStereoTD->tdm_Pri_pitch_buf_fx, Q6, NB_SUBFR); - } - if ( ( error = acelp_core_dec_ivas_fx( st, output_fx, synth_fxl, save_hb_synth_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16, sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lspQ_PCh_fx, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hCPE == NULL ? NULL : hCPE->hStereoCng, read_sid_info ) ) != IVAS_ERR_OK ) + //if (hStereoTD) { + // floatToFixed_arr(hStereoTD->tdm_Pri_pitch_buf, hStereoTD->tdm_Pri_pitch_buf_fx, Q6, NB_SUBFR); + //} + + IF ( ( error = acelp_core_dec_ivas_fx( st, output_fx, synth_fxl, save_hb_synth_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16, sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lspQ_PCh_fx, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hCPE == NULL ? NULL : hCPE->hStereoCng, read_sid_info ) ) != IVAS_ERR_OK ) { return error; } + /* fix2float, to be removed */ acelp_decoder_state_fix2float(st, hCPE == NULL ? NULL : hCPE->hStereoCng); fixedToFloat_arr(output_fx, output[n], st->Q_syn2, L_FRAME48k); @@ -692,17 +643,10 @@ ivas_error ivas_core_dec( //fixedToFloat_arr(old_syn_12k8_16k_fx, old_syn_12k8_16k[n], -1, L_FRAME16k); Copy_Scale_sig_16_32(old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n],L_FRAME16k,Q11 - (-1)); //fixedToFloat_arr(pitch_buf_fx[n], pitch_buf[n], Q6, NB_SUBFR16k); -#else - if ((error = acelp_core_dec(st, output[n], synth[n], save_hb_synth, bwe_exc_extended[n], voice_factors[n], old_syn_12k8_16k[n], sharpFlag[n], pitch_buf[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lspQ_PCh, tdm_lsfQ_PCh, 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; - } -#endif } Copy_Scale_sig_32_16(st->previoussynth_fx_32, st->previoussynth_fx, L_FRAME48k, 0); -#ifdef IVAS_FLOAT_FIXED IF( ( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { Word16 Qsyn_temp = st->Q_syn; //Q gets change in below function. @@ -723,18 +667,10 @@ ivas_error ivas_core_dec( stereo_tcx_dec_mode_switch_reconf_To_fixed_2( st, 0, last_element_mode, frameMode[n]); fixed_to_float_stereo_tcx_core_dec( st, output[n] ); } -#else - if ( ( st->core == TCX_20_CORE || st->core == TCX_10_CORE ) && st->element_mode != IVAS_CPE_MDCT ) - { - /* TCX decoder */ - stereo_tcx_core_dec( st, frameMode[n], output[n], synth[n], pitch_buf[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hCPE == NULL ? NULL : hCPE->hStereoCng, nchan_out, st_ivas == NULL ? 0 : st_ivas->ivas_format ); - } -#endif // IVAS_FLOAT_FIXED if ( st->core == HQ_CORE ) { /* HQ core decoder */ -#ifdef IVAS_FLOAT_FIXED Word16 synth_fxl[L_FRAME48k]; Word16 output_fx[L_FRAME48k]; Q_synth = 0; @@ -744,9 +680,6 @@ ivas_error ivas_core_dec( hHQ_core = st->hHQ_core; - //st->Q_syn = 0; - //st->Q_exc = 0; - st->hHQ_core->Q_old_wtda = -1; st->hHQ_core->Q_old_wtda_LB = -1; @@ -778,37 +711,31 @@ ivas_error ivas_core_dec( fixedToFloat_arr( st->hTcxDec->prev_good_synth_fx - tmp_size, st->hTcxDec->prev_good_synth - tmp_size, 0, 2 * output_frame + tmp_size ); #endif -#else - hq_core_dec( st, synth[n], output_frame, NORMAL_HQ_CORE, core_switching_flag[n], output[n] ); -#endif + } /*---------------------------------------------------------------------* * TD stereo updates *---------------------------------------------------------------------*/ - if ( st->element_mode == IVAS_CPE_TD && n == 0 ) + IF ( st->element_mode == IVAS_CPE_TD && n == 0 ) { -#ifdef IVAS_FLOAT_FIXED /* To be cleaned up once the caller function is converted // These changes are for system testing of fixed changes made */ - Word16 tdm_Pri_pitch_buf_fx[NB_SUBFR]; + //Word16 tdm_Pri_pitch_buf_fx[NB_SUBFR]; 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); td_stereo_param_updt_fx( st->lsp_old_fx, st->lsf_old_fx, st->old_pitch_buf_16_fx + st->nb_subfr, - tdm_lspQ_PCh_fx, tdm_lsfQ_PCh_fx, tdm_Pri_pitch_buf_fx, st->flag_ACELP16k, hStereoTD->tdm_use_IAWB_Ave_lpc, Q16 ); + tdm_lspQ_PCh_fx, tdm_lsfQ_PCh_fx, hStereoTD->tdm_Pri_pitch_buf_fx, st->flag_ACELP16k, hStereoTD->tdm_use_IAWB_Ave_lpc, Q6 ); 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); - for ( i = 0; i < NB_SUBFR; i++ ) - { - hStereoTD->tdm_Pri_pitch_buf[i] = fix16_to_float( tdm_Pri_pitch_buf_fx[i], Q16 ); - } - -#else - td_stereo_param_updt( st->lsp_old, st->lsf_old, st->old_pitch_buf + st->nb_subfr, tdm_lspQ_PCh, tdm_lsfQ_PCh, hStereoTD->tdm_Pri_pitch_buf, st->flag_ACELP16k, hStereoTD->tdm_use_IAWB_Ave_lpc ); -#endif + //for ( i = 0; i < NB_SUBFR; i++ ) + //{ + // //hStereoTD->tdm_Pri_pitch_buf[i] = fix16_to_float( tdm_Pri_pitch_buf_fx[i], Q16 ); + // hStereoTD->tdm_Pri_pitch_buf[i] = fix16_to_float( tdm_Pri_pitch_buf_fx[i], Q6 ); + //} } } /* n_channels loop */ @@ -817,18 +744,18 @@ ivas_error ivas_core_dec( * MDCT stereo: joint TCX Core Decoding *---------------------------------------------------------------------*/ - if ( sts[0]->element_mode == IVAS_CPE_MDCT ) + IF ( sts[0]->element_mode == IVAS_CPE_MDCT ) { /* active-frame decoding */ - if ( sts[0]->core_brate > SID_2k40 ) + IF ( sts[0]->core_brate > SID_2k40 ) { - if ( hMCT ) + IF ( hMCT ) { pop_wmops(); return error; } - else + ELSE { #ifdef IVAS_FLOAT_FIXED #if 1 @@ -846,7 +773,6 @@ ivas_error ivas_core_dec( output_fx[ch] = malloc( sizeof( Word32 ) * L_FRAME48k ); // synth_fx[ch] = malloc(sizeof(Word16) * L_FRAME48k); stereo_tcx_dec_mode_switch_reconf_To_fixed( sts[ch], 1, hCPE->last_element_mode ); - //sts[ch]->hTcxLtpDec->tcxltp_gain = float_to_fix16( sts[ch]->hTcxLtpDec->tcxltp_gain_float, Q15 ); st = sts[ch]; IF( st->hTonalMDCTConc ) @@ -937,8 +863,8 @@ ivas_error ivas_core_dec( floatToFixed_arr( st->hTonalMDCTConc->lastPcmOut_float, st->hTonalMDCTConc->lastPcmOut, 0, s_min( 960, st->hTonalMDCTConc->nSamples ) ); IF( st->hTonalMDCTConc ) floatToFixed_arr( st->hTonalMDCTConc->secondLastPcmOut_float, st->hTonalMDCTConc->secondLastPcmOut, 0, s_min( 960, st->hTonalMDCTConc->nSamples ) / 2 ); - IF( st->hTcxDec ) - st->hTcxDec->conceal_eof_gain = (Word16) floatToFixed( st->hTcxDec->conceal_eof_gain_float, Q14 ); + //IF( st->hTcxDec ) + //st->hTcxDec->conceal_eof_gain = (Word16) floatToFixed( st->hTcxDec->conceal_eof_gain_float, Q14 ); IF( st->hTcxDec ) f2me_16( st->hTcxDec->CngLevelBackgroundTrace_bfi, &st->hTcxDec->conCngLevelBackgroundTrace, &st->hTcxDec->conCngLevelBackgroundTrace_e ); if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) @@ -997,8 +923,7 @@ ivas_error ivas_core_dec( 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->hTcxLtpDec->tcxltp_gain_float = fix16_to_float( st->hTcxLtpDec->tcxltp_gain, Q15 ); - st->hTcxDec->conceal_eof_gain_float = fix16_to_float( st->hTcxDec->conceal_eof_gain, Q14 ); + //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 ) { @@ -1129,7 +1054,7 @@ ivas_error ivas_core_dec( } } /* for inactive frames with mono output, copy and (if necessary) downmix buffers */ - else if ( hCPE->nchan_out == 1 ) + ELSE IF( hCPE->nchan_out == 1 ) { #ifdef IVAS_FLOAT_FIXED /* To be cleaned up once the caller function is converted // These changes are for system testing of fixed changes made */ @@ -1173,9 +1098,6 @@ ivas_error ivas_core_dec( } } - //f2me_buf( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst_flt, sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst, &sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, NPART ); - //f2me_buf( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst_flt, sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst, &sts[1]->hFdCngDec->hFdCngCom->sidNoiseEstExp, NPART ); - 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 ); @@ -1183,20 +1105,15 @@ ivas_error ivas_core_dec( 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]->delay_buf_out, sts[0]->delay_buf_out_fx, &sts[0]->exp_delay_buf_out, HQ_DELTA_MAX * HQ_DELAY_COMP ); /*To remove exp component Q0*/ - //f2me_buf_16( sts[1]->delay_buf_out, sts[1]->delay_buf_out_fx, &sts[1]->exp_delay_buf_out, HQ_DELTA_MAX * HQ_DELAY_COMP ); f2me_buf_16( sts[0]->hHQ_core->old_out, sts[0]->hHQ_core->old_out_fx, &sts[0]->hHQ_core->exp_old_out, L_FRAME48k ); f2me_buf_16( sts[1]->hHQ_core->old_out, sts[1]->hHQ_core->old_out_fx, &sts[1]->hHQ_core->exp_old_out, L_FRAME48k ); } updateBuffersForDmxMdctStereo_fx( hCPE, output_frame, output_fx[0], output_fx[1], synth_fxl ); - //me2f_buf( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst, sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst_flt, NPART ); - //me2f_buf( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst, sts[1]->hFdCngDec->hFdCngCom->sidNoiseEstExp, sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst_flt, NPART ); 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]->delay_buf_out_fx, sts[0]->exp_delay_buf_out, sts[0]->delay_buf_out, HQ_DELTA_MAX * HQ_DELAY_COMP ); /*To remove exp component Q0*/ 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 ); } @@ -1341,27 +1258,6 @@ ivas_error ivas_core_dec( { st->hBWE_TD->syn_overlap_fx_32[ii] = (Word32)(st->hBWE_TD->syn_overlap[ii] * (1 << 11)); } - for (int ii = 0; ii < INTERP_3_2_MEM_LEN; ii++) - { - st->hBWE_TD->int_3_over_2_tbemem_dec_fx_32[ii] = (Word32)(st->hBWE_TD->int_3_over_2_tbemem_dec[ii] * (1 << 11)); - } - for (int ii = 0; ii < L_SHB_TRANSITION_LENGTH; ii++) - { - st->hBWE_TD->old_tbe_synth_fx_32[ii] = (Word32)(st->hBWE_TD->old_tbe_synth[ii] * (1 << 11)); - } - for (int ii = 0; ii < 2 * ALLPASSSECTIONS_STEEP + 1; ii++) - { - st->hBWE_TD->mem_resamp_HB_32k_fx_32[ii] = (Word32)(st->hBWE_TD->mem_resamp_HB_32k[ii] * (1 << 11)); - } - for (int ii = 0; ii < 2 * ALLPASSSECTIONS_STEEP; ii++) - { - st->hBWE_TD->state_lsyn_filt_dwn_shb_fx_32[ii] = (Word32)(st->hBWE_TD->state_lsyn_filt_dwn_shb[ii] * (1 << 11)); - st->hBWE_TD->state_lsyn_filt_shb_fx_32[ii] = (Word32)(st->hBWE_TD->state_lsyn_filt_shb[ii] * (1 << 11)); - } - for (int ii = 0; ii < INTERP_3_1_MEM_LEN; ii++) - { - st->hBWE_TD->mem_resamp_HB_fx_32[ii] = (Word32)(st->hBWE_TD->mem_resamp_HB[ii] * (1 << 11)); - } } } } @@ -1416,23 +1312,19 @@ ivas_error ivas_core_dec( delta = shr(Fs_kHz, 3); } - //Word16 delay_comp = i_mult2(delta, HQ_DELAY_COMP); - IF(st->hHQ_core != NULL) { floatToFixed_arr(st->hHQ_core->old_out, st->hHQ_core->old_out_fx, 0, L_FRAME48k); } - if (st->hTcxDec != NULL) - { - st->hTcxDec->conceal_eof_gain = (Word16)floatToFixed(st->hTcxDec->conceal_eof_gain_float, 14); - } + //if (st->hTcxDec != NULL) + //{ + // st->hTcxDec->conceal_eof_gain = (Word16)floatToFixed(st->hTcxDec->conceal_eof_gain_float, 14); + //} /*size of synth is choosen as delay comp to start with*/ /*-------------------cldfb-start-------------------------*/ - //Word16 cldfb_size = (Word16)(st->L_frame / 16 + 0.5); - floatToFixed_arrL(st->bpf_noise_buf_float, st->bpf_noise_buf_32, 11, L_FRAME_16k); if (st->cldfbAna != NULL) { @@ -1448,11 +1340,8 @@ ivas_error ivas_core_dec( } /*-------------------cldfb-end---------------------------*/ - - //Word32 old_syn_12k8_16k_fx[L_FRAME16k]; Word16 q_audio, old_syn_fx; old_syn_fx = Q11; - //floatToFixed_arrL(old_syn_12k8_16k[n], old_syn_12k8_16k_fx, old_syn_fx, L_FRAME16k); q_audio = Q12; #endif @@ -1472,21 +1361,21 @@ ivas_error ivas_core_dec( } /* Memories Scaling */ - Copy_Scale_sig_32_16(st->hBWE_TD->syn_overlap_fx_32, st->hBWE_TD->syn_overlap_fx, sub(11, st->prev_Q_bwe_syn2), L_SHB_LAHEAD); - Copy_Scale_sig_32_16(st->hBWE_TD->old_tbe_synth_fx_32, st->hBWE_TD->old_tbe_synth_fx, sub(11, st->prev_Qx), L_SHB_TRANSITION_LENGTH); - Copy_Scale_sig_32_16(st->hBWE_TD->state_lsyn_filt_dwn_shb_fx_32, st->hBWE_TD->state_lsyn_filt_dwn_shb_fx, sub(11, st->prev_Qx), add(shl(ALLPASSSECTIONS_STEEP, 1), 1)); - Copy_Scale_sig_32_16(st->hBWE_TD->state_lsyn_filt_shb_fx_32, st->hBWE_TD->state_lsyn_filt_shb_fx, sub(11, st->prev_Qx), add(shl(ALLPASSSECTIONS_STEEP, 1), 1)); - Copy_Scale_sig_32_16(st->hBWE_TD->mem_resamp_HB_fx_32, st->hBWE_TD->mem_resamp_HB_fx, sub(11, st->prev_Qx), INTERP_3_1_MEM_LEN); + Copy_Scale_sig_32_16(st->hBWE_TD->syn_overlap_fx_32, st->hBWE_TD->syn_overlap_fx, L_SHB_LAHEAD, st->prev_Q_bwe_syn2 - Q11); + 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); + Copy_Scale_sig_32_16(st->hBWE_TD->state_lsyn_filt_dwn_shb_fx_32, st->hBWE_TD->state_lsyn_filt_dwn_shb_fx, shl(ALLPASSSECTIONS_STEEP, 1), st->prev_Qx - Q11); + Copy_Scale_sig_32_16(st->hBWE_TD->state_lsyn_filt_shb_fx_32, st->hBWE_TD->state_lsyn_filt_shb_fx, shl(ALLPASSSECTIONS_STEEP, 1), st->prev_Qx - Q11); + Copy_Scale_sig_32_16(st->hBWE_TD->mem_resamp_HB_fx_32, st->hBWE_TD->mem_resamp_HB_fx, INTERP_3_1_MEM_LEN, st->prev_Qx - Q11); } /* Memories Re-Scaling */ IF(st->hBWE_TD != NULL) { - Copy_Scale_sig_16_32(st->hBWE_TD->syn_overlap_fx, st->hBWE_TD->syn_overlap_fx_32, negate(sub(11, st->prev_Q_bwe_syn2)), L_SHB_LAHEAD); - Copy_Scale_sig_16_32(st->hBWE_TD->old_tbe_synth_fx, st->hBWE_TD->old_tbe_synth_fx_32, negate(sub(11, st->prev_Qx)), L_SHB_TRANSITION_LENGTH); - Copy_Scale_sig_16_32(st->hBWE_TD->state_lsyn_filt_dwn_shb_fx, st->hBWE_TD->state_lsyn_filt_dwn_shb_fx_32, negate(sub(11, st->prev_Qx)), add(shl(ALLPASSSECTIONS_STEEP, 1), 1)); - Copy_Scale_sig_16_32(st->hBWE_TD->state_lsyn_filt_shb_fx, st->hBWE_TD->state_lsyn_filt_shb_fx_32, negate(sub(11, st->prev_Qx)), add(shl(ALLPASSSECTIONS_STEEP, 1), 1)); - Copy_Scale_sig_16_32(st->hBWE_TD->mem_resamp_HB_fx, st->hBWE_TD->mem_resamp_HB_fx_32, sub(11, st->prev_Qx), INTERP_3_1_MEM_LEN); + Copy_Scale_sig_16_32(st->hBWE_TD->syn_overlap_fx, st->hBWE_TD->syn_overlap_fx_32, L_SHB_LAHEAD, Q11 - st->prev_Q_bwe_syn2); + Copy_Scale_sig_16_32(st->hBWE_TD->old_tbe_synth_fx, st->hBWE_TD->old_tbe_synth_fx_32, L_SHB_TRANSITION_LENGTH, Q11 - st->prev_Qx); + Copy_Scale_sig_16_32(st->hBWE_TD->state_lsyn_filt_dwn_shb_fx, st->hBWE_TD->state_lsyn_filt_dwn_shb_fx_32, shl(ALLPASSSECTIONS_STEEP, 1), Q11 - st->prev_Qx); + Copy_Scale_sig_16_32(st->hBWE_TD->state_lsyn_filt_shb_fx, st->hBWE_TD->state_lsyn_filt_shb_fx_32, shl(ALLPASSSECTIONS_STEEP, 1), Q11 - st->prev_Qx); + Copy_Scale_sig_16_32(st->hBWE_TD->mem_resamp_HB_fx, st->hBWE_TD->mem_resamp_HB_fx_32, INTERP_3_1_MEM_LEN, Q11 - st->prev_Qx); Copy(st->hBWE_TD->mem_resamp_HB_fx, st->hBWE_TD->state_32and48k_WB_upsample_fx, 2 * ALLPASSSECTIONS_STEEP); } /*---------------------------------------------------------------------* @@ -1569,12 +1458,6 @@ ivas_error ivas_core_dec( /*------------------reset-code-start---------------------*/ - /*reset function flags*/ - Word8 reset_wb_tbe_synth = 0; - Word8 reset_swb_tbe = 0; - - /* reset WB BWE buffers */ - IF(NE_16(st->last_extl, WB_BWE) && EQ_16(st->extl, WB_BWE) && st->hBWE_FD != NULL) { @@ -1602,10 +1485,7 @@ ivas_error ivas_core_dec( #ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED - //Word32 bwe_exc_extended_fx[CPE_CHANNELS][L_FRAME32k + NL_BUFF_OFFSET]; - //Word16 voice_factors_fx[CPE_CHANNELS][NB_SUBFR16k]; 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; @@ -1624,10 +1504,6 @@ ivas_error ivas_core_dec( FD_BWE_DEC_HANDLE hBWE_FD; hBWE_FD = st->hBWE_FD; - - //floatToFixed_arrL( old_syn_12k8_16k[n], old_syn_12k8_16k_fx, Q11, L_FRAME16k ); // Can be removed got from last fn - - //floatToFixed_arrL( bwe_exc_extended[n], bwe_exc_extended_fx[n], 2 * st->Q_exc, L_FRAME32k + NL_BUFF_OFFSET ); floatToFixed_arr( hb_synth[n], hb_synth_fx_16[n], Q_hb_synth_fx, L_FRAME48k ); floatToFixed_arr( output[n], output_fx_16[n], Q_input, L_FRAME48k ); floatToFixed_arr( synth[n], synth_fx_16[n], Q_synth_fx, L_FRAME48k ); @@ -1643,10 +1519,6 @@ ivas_error ivas_core_dec( test(); test(); test(); - IF(hBWE_TD != NULL) - { - //Copy_Scale_sig_32_16(hBWE_TD->syn_overlap_fx_32, hBWE_TD->syn_overlap_fx, -st->prev_Q_bwe_syn2, L_SHB_LAHEAD); // Check - } IF( EQ_16( st->extl, WB_TBE ) ) { /* WB TBE decoder */ @@ -1663,6 +1535,7 @@ ivas_error ivas_core_dec( Q_hb_synth_fx = ivas_wb_bwe_dec_fx( st, output_fx_16[n], synth_fx_16[n], hb_synth_fx_16[n], use_cldfb_for_dft, output_frame, voice_factors_fx[n], pitch_buf_fx[n], &Q_synth_fx ); } + /* Memories Re-Scaling */ Copy_Scale_sig_16_32( hb_synth_fx_16[n], hb_synth_fx32, L_FRAME48k, Q11 - Q_hb_synth_fx ); Copy_Scale_sig_16_32( output_fx_16[n], output_fx32, L_FRAME48k, Q11 - Q_input ); Copy_Scale_sig_16_32( synth_fx_16[n], synth_fx32, L_FRAME48k, Q11 - Q_synth_fx ); @@ -1744,7 +1617,6 @@ ivas_error ivas_core_dec( move16(); FOR( i = 0; i < j; i++ ) { - /*hb_synth[i] *= (i*tmp);*/ hb_synth_fx32[i] = Mpy_32_16_1( hb_synth_fx32[i], tmp16_2 ); /* Q11 */ move32(); #ifdef BASOP_NOGLOB @@ -1762,7 +1634,6 @@ 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 */ -#ifdef IVAS_FLOAT_FIXED Word16 synth_fxl[960], hb_synth_fxl[960]; /* Q-2 */ Word16 q = 2; //st->prev_Q_bwe_syn2 = 0; @@ -1779,40 +1650,18 @@ ivas_error ivas_core_dec( 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_16_32(st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, 2 * ALLPASSSECTIONS_STEEP, -(st->prev_Q_bwe_syn2 - Q11)); -#endif } #ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED - //fixedToFloat_arrL(bwe_exc_extended_fx[n], bwe_exc_extended[n], 2 * st->Q_exc, L_FRAME32k + NL_BUFF_OFFSET); - fixedToFloat_arrL(hb_synth_fx32, hb_synth[n], Q11, L_FRAME48k); fixedToFloat_arrL(output_fx32, output[n], Q11, L_FRAME48k); fixedToFloat_arrL(synth_fx32, synth[n], Q11, L_FRAME48k); IF(hBWE_TD != NULL) { - fixedToFloat_arr(hBWE_TD->state_lsyn_filt_shb_fx, hBWE_TD->state_lsyn_filt_shb, st->prev_Qx, 2 * ALLPASSSECTIONS_STEEP); - fixedToFloat_arr(hBWE_TD->state_lsyn_filt_dwn_shb_fx, hBWE_TD->state_lsyn_filt_dwn_shb, st->prev_Qx, 2 * ALLPASSSECTIONS_STEEP); - - fixedToFloat_arr(hBWE_TD->mem_resamp_HB_fx, hBWE_TD->mem_resamp_HB, st->prev_Qx, INTERP_3_1_MEM_LEN); - fixedToFloat_arr(hBWE_TD->old_bwe_exc_extended_fx, hBWE_TD->old_bwe_exc_extended, st->prev_Q_bwe_exc - 16, NL_BUFF_OFFSET); - fixedToFloat_arr(hBWE_TD->syn_overlap_fx, hBWE_TD->syn_overlap, st->prev_Q_bwe_syn2, L_SHB_LAHEAD); // Check - - for (int ii = 0; ii < INTERP_3_2_MEM_LEN; ii++) - { - st->hBWE_TD->int_3_over_2_tbemem_dec[ii] = fixedToFloat(st->hBWE_TD->int_3_over_2_tbemem_dec_fx_32[ii], Q11); - } - for (int ii = 0; ii < L_SHB_TRANSITION_LENGTH; ii++) - { - st->hBWE_TD->old_tbe_synth[ii] = fixedToFloat(hBWE_TD->old_tbe_synth_fx_32[ii], Q11); - } - for (int ii = 0; ii < 2 * ALLPASSSECTIONS_STEEP + 1; ii++) - { - st->hBWE_TD->mem_resamp_HB_32k[ii] = fixedToFloat(st->hBWE_TD->mem_resamp_HB_32k_fx_32[ii], Q11); - } } #endif /*-------------------------------------------------------------------* @@ -1833,12 +1682,6 @@ ivas_error ivas_core_dec( floatToFixed_arrL( hCPE->hStereoDft->hb_stefi_sig, hCPE->hStereoDft->hb_stefi_sig_fx, q, L_FRAME48k + NS2SA( 48000, STEREO_DFT_TD_STEFI_DELAY_NS ) ); hCPE->hStereoDft->td_gain_fx[0] = 1; } - if ( hCPE->hStereoDftDmx != NULL ) - { - - hCPE->hStereoDftDmx->targetGain_fx = (Word32) ( hCPE->hStereoDftDmx->targetGain * ( 1u << 29 ) ); - } - 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 ); @@ -1923,7 +1766,7 @@ ivas_error ivas_core_dec( move16(); FOR ( i = 0; i < tmps; i++ ) { - hb_synth_fx[n][i] = mult_r(hb_synth_fx[i], sin_table256_fx[tmp16]); + hb_synth_fx[n][i] = mult_r(hb_synth_fx[n][i], sin_table256_fx[tmp16]); move16(); tmp16 = add(tmp16, incr); } @@ -1982,7 +1825,6 @@ ivas_error ivas_core_dec( tmp16 = 0; FOR (i=0; iold_bwe_delay; i++) { - /*tmp_buffer[tmps - 1 - i] += st->hb_prev_synth_buffer[st->old_bwe_delay - 1 - i] * sin_table256[i * incr];*/ tmp_buffer_fx[tmps - 1 - i] = round_fx(L_mac(L_mult(tmp_buffer_fx[tmps - 1 - i], 32767), st->hb_prev_synth_buffer_fx[st->old_bwe_delay - 1 - i], sin_table256_fx[tmp16/*i * incr*/])); tmp16 = add(tmp16, incr); } @@ -2024,7 +1866,7 @@ ivas_error ivas_core_dec( } ELSE { - Copy32( hb_synth_fx[n] + output_frame - tmps, st->hb_prev_synth_buffer_fx, tmps ); //ToDo: Scale Signl with appropriate Q. + 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 mvr2r(hb_synth[n] + output_frame - tmps, st->hb_prev_synth_buffer, tmps); #endif @@ -2211,7 +2053,7 @@ ivas_error ivas_core_dec( { FOR(Word32 kk = 0; kk < 111; kk++) { - hCPE->hCoreCoder[ch_ind]->hTcxDec->FBTCXdelayBuf_32[kk] = (Word32)(hCPE->hCoreCoder[ch_ind]->hTcxDec->FBTCXdelayBuf_float[kk] * (1 << OUTPUT_Q)); + //hCPE->hCoreCoder[ch_ind]->hTcxDec->FBTCXdelayBuf_32[kk] = (Word32)(hCPE->hCoreCoder[ch_ind]->hTcxDec->FBTCXdelayBuf_float[kk] * (1 << OUTPUT_Q)); } } } @@ -2235,7 +2077,7 @@ ivas_error ivas_core_dec( { FOR(Word32 kk = 0; kk < 111; kk++) { - hSCE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf_32[kk] = (Word32)(hSCE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf_float[kk] * (1 << OUTPUT_Q)); + //hSCE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf_32[kk] = (Word32)(hSCE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf_float[kk] * (1 << OUTPUT_Q)); } } IF(hSCE->hCoreCoder[0]->hTcxLtpDec != NULL) @@ -2301,6 +2143,10 @@ ivas_error ivas_core_dec( IF ((EQ_16(st->codec_mode, MODE1) && st->hTcxDec != NULL) && ((EQ_16(st->core, ACELP_CORE) && !(EQ_16(st->bfi, 1) && EQ_16(st->con_tcx, 1))) || EQ_16(st->core, HQ_CORE))) { Word16 exp_prev_synth_buffer = 0, exp_old_out = 0, exp_delay_buf_out = 0, exp_ouput = 0, exp_synth_history = 0/*, temp = 0*/; move16(); move16(); move16(); move16(); move16(); move16(); + + Copy_Scale_sig32_16( st->prev_synth_buffer32_fx, st->prev_synth_buffer_fx, NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); + st->q_prev_synth_buffer_fx = 0; + exp_ouput = Find_Max_Norm32(output_fx[n], output_frame); exp_ouput += 11; exp_prev_synth_buffer = Find_Max_Norm16(st->prev_synth_buffer_fx, NS2SA(48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS)); @@ -2397,7 +2243,7 @@ ivas_error ivas_core_dec( { FOR(Word32 kk = 0; kk < 111; kk++) { - hCPE->hCoreCoder[ch_ind]->hTcxDec->FBTCXdelayBuf_float[kk] = (float)hCPE->hCoreCoder[ch_ind]->hTcxDec->FBTCXdelayBuf_32[kk] / (1 << OUTPUT_Q); + //hCPE->hCoreCoder[ch_ind]->hTcxDec->FBTCXdelayBuf_float[kk] = (float)hCPE->hCoreCoder[ch_ind]->hTcxDec->FBTCXdelayBuf_32[kk] / (1 << OUTPUT_Q); } } } @@ -2472,7 +2318,7 @@ ivas_error ivas_core_dec( { FOR(Word32 kk = 0; kk < 111; kk++) { - hSCE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf_float[kk] = (float)hSCE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf_32[kk] / (1 << OUTPUT_Q); + //hSCE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf_float[kk] = (float)hSCE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf_32[kk] / (1 << OUTPUT_Q); } } IF(hSCE->hCoreCoder[0]->hTcxLtpDec != NULL) diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index a8f9a12d03cd73c3517ce6dc7222bca64cd6d21f..0ddca0f1063fd03105086611db50cd53df8c9b58 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -335,11 +335,11 @@ ivas_error ivas_cpe_dec_fx( floatToFixed_arrL(&hCPE->input_mem_LB[n][0], &hCPE->input_mem_LB_fx[n][0], q_temp, STEREO_DFT32MS_OVL_16k); } - if (hCPE->hCoreCoder[n] != NULL) - { - floatToFixed_arrL(&hCPE->hCoreCoder[n]->prev_synth_buffer[0], &hCPE->hCoreCoder[n]->prev_synth_buffer32_fx[0], q_temp, NS2SA(48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS)); - floatToFixed_arr(&hCPE->hCoreCoder[n]->prev_synth_buffer[0], &hCPE->hCoreCoder[n]->prev_synth_buffer_fx[0], 0, NS2SA(48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS)); - } + //if (hCPE->hCoreCoder[n] != NULL) + //{ + // floatToFixed_arrL(&hCPE->hCoreCoder[n]->prev_synth_buffer[0], &hCPE->hCoreCoder[n]->prev_synth_buffer32_fx[0], q_temp, NS2SA(48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS)); + // floatToFixed_arr(&hCPE->hCoreCoder[n]->prev_synth_buffer[0], &hCPE->hCoreCoder[n]->prev_synth_buffer_fx[0], 0, NS2SA(48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS)); + //} } stereo_switching_dec( hCPE, ivas_total_brate ); @@ -358,11 +358,11 @@ ivas_error ivas_cpe_dec_fx( { fixedToFloat_arrL(&hCPE->input_mem_LB_fx[n][0], &hCPE->input_mem_LB[n][0], q_temp, STEREO_DFT32MS_OVL_16k); } - if (hCPE->hCoreCoder[n] != NULL) - { - fixedToFloat_arrL(&hCPE->hCoreCoder[n]->prev_synth_buffer32_fx[0], &hCPE->hCoreCoder[n]->prev_synth_buffer[0], q_temp, NS2SA(48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS)); + //if (hCPE->hCoreCoder[n] != NULL) + //{ + //fixedToFloat_arrL(&hCPE->hCoreCoder[n]->prev_synth_buffer32_fx[0], &hCPE->hCoreCoder[n]->prev_synth_buffer[0], q_temp, NS2SA(48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS)); //fixedToFloat_arrL(&hCPE->hCoreCoder[n]->prev_synth_buffer_fx[0], &hCPE->hCoreCoder[n]->prev_synth_buffer[0], 0, NS2SA(48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS)); - } + //} } /*----------------------------------------------------------------* * Configuration of stereo decoder @@ -642,6 +642,40 @@ ivas_error ivas_cpe_dec_fx( IF( NE_16( hCPE->element_mode, IVAS_CPE_DFT ) || ( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF ) ) ) { +#ifndef TO_BE_REMOVED_CONVERSION + Word16 k; + + //{ + // sts = hCPE->hCoreCoder; + //} + + //core_coding_part will go in this loop, once the things are done + for (k = 0; k < n_channels; k++) + { + if (sts[k]->hTcxDec != NULL) + { + floatToFixed_arr(sts[k]->hHQ_core->old_out, sts[k]->hHQ_core->old_out_fx, 0, L_FRAME48k); + floatToFixed_arr(sts[k]->hHQ_core->old_outLB, sts[k]->hHQ_core->old_out_LB_fx, 0, L_FRAME32k); + floatToFixed_arrL(sts[k]->hHQ_core->old_outLB, sts[k]->hHQ_core->old_outLB_fx, 11, L_FRAME32k); + //sts[k]->hTcxDec->conceal_eof_gain32 = floatToFixed( sts[k]->hTcxDec->conceal_eof_gain_float, 15 ); + } + } + + if (hCPE != NULL && hCPE->last_element_mode == IVAS_CPE_MDCT && hCPE->element_mode == IVAS_CPE_DFT) + { + floatToFixed_arrL(hCPE->input_mem_LB[0], hCPE->input_mem_LB_fx[0], 11, STEREO_DFT32MS_OVL_16k); + } + + IF(sts[0]->element_mode == IVAS_CPE_MDCT && sts[0]->total_brate == SID_2k40) + { + FOR(Word16 ch = 0; ch < CPE_CHANNELS; ++ch) + { + f2me_buf(sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel, &sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, sts[ch]->hFdCngDec->hFdCngCom->stopBand - sts[ch]->hFdCngDec->hFdCngCom->startBand); + floatToFixed_arr(sts[ch]->hFdCngDec->hFdCngCom->A_cng_flt, sts[ch]->hFdCngDec->hFdCngCom->A_cng, Q14, M + 1); + } + } + +#endif IF( ( error = ivas_core_dec( st_ivas, NULL, hCPE, st_ivas->hMCT, n_channels, output_flt, outputHB, NULL, st_ivas->sba_dirac_stereo_flag ) ) != IVAS_ERR_OK ) { return error; @@ -672,6 +706,40 @@ ivas_error ivas_cpe_dec_fx( set_f( DFT[0], 0.0f, STEREO_DFT_BUF_MAX ); set_f( DFT[1], 0.0f, STEREO_DFT_BUF_MAX ); +#ifndef TO_BE_REMOVED_CONVERSION + Word16 k; + + //{ + // sts = hCPE->hCoreCoder; + //} + + //core_coding_part will go in this loop, once the things are done + for (k = 0; k < n_channels; k++) + { + if (sts[k]->hTcxDec != NULL) + { + floatToFixed_arr(sts[k]->hHQ_core->old_out, sts[k]->hHQ_core->old_out_fx, 0, L_FRAME48k); + floatToFixed_arr(sts[k]->hHQ_core->old_outLB, sts[k]->hHQ_core->old_out_LB_fx, 0, L_FRAME32k); + floatToFixed_arrL(sts[k]->hHQ_core->old_outLB, sts[k]->hHQ_core->old_outLB_fx, 11, L_FRAME32k); + //sts[k]->hTcxDec->conceal_eof_gain32 = floatToFixed( sts[k]->hTcxDec->conceal_eof_gain_float, 15 ); + } + } + + if (hCPE != NULL && hCPE->last_element_mode == IVAS_CPE_MDCT && hCPE->element_mode == IVAS_CPE_DFT) + { + floatToFixed_arrL(hCPE->input_mem_LB[0], hCPE->input_mem_LB_fx[0], 11, STEREO_DFT32MS_OVL_16k); + } + + IF(sts[0]->element_mode == IVAS_CPE_MDCT && sts[0]->total_brate == SID_2k40) + { + FOR(Word16 ch = 0; ch < CPE_CHANNELS; ++ch) + { + f2me_buf(sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel, &sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, sts[ch]->hFdCngDec->hFdCngCom->stopBand - sts[ch]->hFdCngDec->hFdCngCom->startBand); + floatToFixed_arr(sts[ch]->hFdCngDec->hFdCngCom->A_cng_flt, sts[ch]->hFdCngDec->hFdCngCom->A_cng, Q14, M + 1); + } + } + +#endif /* core decoder */ IF( ( error = ivas_core_dec( NULL, NULL, hCPE, st_ivas->hMCT, n_channels, output_flt, outputHB, DFT, 0 ) ) != IVAS_ERR_OK ) @@ -1128,10 +1196,10 @@ ivas_error ivas_cpe_dec_fx( } } - FOR( Word32 k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); k++ ) - { - hCPE->hCoreCoder[n]->prev_synth_buffer32_fx[k] = (Word32) ( hCPE->hCoreCoder[n]->prev_synth_buffer[k] * ( 1 << output_q ) ); - } + //FOR( Word32 k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); k++ ) + //{ + // hCPE->hCoreCoder[n]->prev_synth_buffer32_fx[k] = (Word32) ( hCPE->hCoreCoder[n]->prev_synth_buffer[k] * ( 1 << output_q ) ); + //} //FOR( Word32 k = 0; k < HQ_DELTA_MAX * HQ_DELAY_COMP; k++ ) //{ // hCPE->hCoreCoder[n]->delay_buf_out32_fx[k] = (Word32) ( hCPE->hCoreCoder[n]->delay_buf_out[k] * ( 1 << output_q ) ); @@ -1140,7 +1208,7 @@ ivas_error ivas_cpe_dec_fx( { FOR( Word32 k = 0; k < 111; k++ ) { - hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] = (Word32) ( hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] * ( 1 << output_q ) ); + //hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] = (Word32) ( hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] * ( 1 << output_q ) ); } } } @@ -1210,10 +1278,10 @@ ivas_error ivas_cpe_dec_fx( 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++ ) - { - hCPE->hCoreCoder[n]->prev_synth_buffer[k] = (float) hCPE->hCoreCoder[n]->prev_synth_buffer32_fx[k] / ( 1 << output_q ); - } + //FOR( Word32 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 << output_q ); + //} //FOR( Word32 k = 0; k < HQ_DELTA_MAX * HQ_DELAY_COMP; k++ ) //{ // hCPE->hCoreCoder[n]->delay_buf_out[k] = (float) hCPE->hCoreCoder[n]->delay_buf_out32_fx[k] / ( 1 << output_q ); @@ -1222,7 +1290,7 @@ ivas_error ivas_cpe_dec_fx( { FOR( Word32 k = 0; k < 111; k++ ) { - hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] = (float) hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] / ( 1 << output_q ); + //hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] = (float) hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] / ( 1 << output_q ); } } } diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index da8ddb41050259a570fb7c394325eea5d89af790..fff08a3a15e9e2719bb45403647de51ac0092fb1 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -3610,13 +3610,13 @@ void ivas_dirac_dec_render_sf( Word32 Cldfb_RealBuffer_Temp_fx[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Temp_fx[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word16 cldfb_buf_q; + Word16 offset; Word32 pppQMfFrame_ts_re_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word32 pppQMfFrame_ts_im_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; 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;; - Word16 Q_cldfb_scale; + 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_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]; @@ -3657,7 +3657,8 @@ void ivas_dirac_dec_render_sf( reference_power_smooth_fx = ( DirAC_mem.reference_power_fx == NULL ) ? NULL : DirAC_mem.reference_power_fx + hSpatParamRendCom->num_freq_bands; onset_filter_fx = DirAC_mem.onset_filter_fx; onset_filter_subframe_fx = ( DirAC_mem.onset_filter_fx == NULL ) ? NULL : DirAC_mem.onset_filter_fx + hSpatParamRendCom->num_freq_bands; - + q_cldfb = Q11; + move16(); //////////////////////////////////////////////////////////////////////////// to be removed /////////////////////////////////////////////////////////////////// reference_power_smooth_fx = &reference_power_fix[hSpatParamRendCom->num_freq_bands]; onset_filter_subframe_fx = &onset_filter_subframe_fix[hSpatParamRendCom->num_freq_bands]; @@ -3723,7 +3724,7 @@ void ivas_dirac_dec_render_sf( } ELSE { - Word32 offset = i_mult( hSpatParamRendCom->num_freq_bands, add( hSpatParamRendCom->slots_rendered, slot_idx ) ); + offset = i_mult( hSpatParamRendCom->num_freq_bands, add( hSpatParamRendCom->slots_rendered, slot_idx ) ); FOR( ch = 0; ch < nchan_transport; ch++ ) { floatToFixed_arrL32( &st_ivas->hTcBuffer->tc[hDirACRend->sba_map_tc[ch]][offset], &st_ivas->hTcBuffer->tc_fx[hDirACRend->sba_map_tc[ch]][offset], Q11, hSpatParamRendCom->num_freq_bands ); @@ -3745,6 +3746,60 @@ void ivas_dirac_dec_render_sf( st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth_fx = floatToFixed_32( st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth, st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth_q ); st_ivas->hMasa->hMasaLfeSynth->targetEneTransSmooth_fx = floatToFixed_32( st_ivas->hMasa->hMasaLfeSynth->targetEneTransSmooth, st_ivas->hMasa->hMasaLfeSynth->targetEneTransSmooth_q ); } + + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) + { + floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); + IF( hDirACRend->masa_stereo_type_detect ) + { + IF( hDirACRend->masa_stereo_type_detect->subtract_target_ratio_db == -INFINITY ) + { + hDirACRend->masa_stereo_type_detect->subtract_target_ratio_db_fx = MIN_32; + } + ELSE + { + hDirACRend->masa_stereo_type_detect->subtract_target_ratio_db_fx = floatToFixed( hDirACRend->masa_stereo_type_detect->subtract_target_ratio_db, Q21 ); + } + hDirACRend->masa_stereo_type_detect->subtract_power_y_fx = 0; + hDirACRend->masa_stereo_type_detect->q_subtract_power_y = Q31; + } + } + ELSE IF( NE_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + SWITCH( nchan_transport ) + { + case 11: + case 8: + case 6: + case 4: + floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff ); + BREAK; + case 2: + IF( hDirACRend->hOutSetup.is_loudspeaker_setup ) + { + floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 3, hSpatParamRendCom->num_freq_bands ) ); + } + ELSE + { + floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); + IF(hDirACRend->masa_stereo_type_detect) + { + IF(hDirACRend->masa_stereo_type_detect->subtract_target_ratio_db == -INFINITY) + { + hDirACRend->masa_stereo_type_detect->subtract_target_ratio_db_fx = MIN_32; + } + ELSE + { + hDirACRend->masa_stereo_type_detect->subtract_target_ratio_db_fx = floatToFixed(hDirACRend->masa_stereo_type_detect->subtract_target_ratio_db, Q21); + } + } + } + BREAK; + case 1: + floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hSpatParamRendCom->num_freq_bands ); + BREAK; + } + } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// hodirac_flag = ivas_get_hodirac_flag_fx( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ); @@ -3927,18 +3982,20 @@ void ivas_dirac_dec_render_sf( FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { index_slot = add( slot_idx_start, slot_idx ); - Word32 offset = i_mult( hSpatParamRendCom->num_freq_bands, index_slot ); + offset = i_mult( hSpatParamRendCom->num_freq_bands, index_slot ); /* CLDFB Analysis*/ FOR( ch = 0; ch < nchan_transport; ch++ ) { - Q_cldfb_scale = Q11; + q_temp_cldfb = Q11; move16(); cldfbAnalysis_ts_fx_fixed_q( &st_ivas->hTcBuffer->tc_fx[hDirACRend->sba_map_tc[ch]][offset], Cldfb_RealBuffer_Temp_fx[ch][slot_idx], Cldfb_ImagBuffer_Temp_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, - st_ivas->cldfbAnaDec[ch], &Q_cldfb_scale ); + st_ivas->cldfbAnaDec[ch], &q_temp_cldfb ); } + q_cldfb = q_temp_cldfb; + move16(); } IF( L_and( NE_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ), NE_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) ) @@ -3967,6 +4024,8 @@ void ivas_dirac_dec_render_sf( Copy32( pppQMfFrame_ts_re_fx[ch][slot_idx], Cldfb_RealBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); Copy32( pppQMfFrame_ts_im_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); } + q_cldfb = Q6; + move16(); } ELSE IF( L_and( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ), EQ_16( nchan_transport, 2 ) ) ) { @@ -3979,27 +4038,28 @@ void ivas_dirac_dec_render_sf( ELSE { /* CLDFB Analysis*/ - Word32 offset = i_mult( hSpatParamRendCom->num_freq_bands, index_slot ); + offset = i_mult( hSpatParamRendCom->num_freq_bands, index_slot ); FOR( ch = 0; ch < nchan_transport; ch++ ) { - Q_cldfb_scale = Q11; + q_temp_cldfb = Q11; move16(); cldfbAnalysis_ts_fx_fixed_q( &st_ivas->hTcBuffer->tc_fx[hDirACRend->sba_map_tc[ch]][offset], Cldfb_RealBuffer_fx[ch][0], Cldfb_ImagBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands, - st_ivas->cldfbAnaDec[ch], &Q_cldfb_scale ); + st_ivas->cldfbAnaDec[ch], &q_temp_cldfb ); } + q_cldfb = q_temp_cldfb; + move16(); } /* CNG in DirAC, extra CLDFB ana for CNA*/ IF( EQ_16( st_ivas->nchan_transport, 1 ) && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && !( L_or( EQ_16( st_ivas->ivas_format, SBA_FORMAT ), EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ) ) { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; - Q_cldfb_scale = Q11; - move16(); Word16 Q_input = Q11; move16(); + q_temp_cldfb = Q11; generate_masking_noise_dirac_fx( st->hFdCngDec->hFdCngCom, st_ivas->cldfbAnaDec[1], st_ivas->hTcBuffer->tc_fx[1], @@ -4007,26 +4067,125 @@ void ivas_dirac_dec_render_sf( Cldfb_ImagBuffer_fx[1][0], index_slot, st->cna_dirac_flag && st->flag_cna, - ( L_or( EQ_32( st->core_brate, FRAME_NO_DATA ), EQ_32( st->core_brate, SID_2k40 ) ) ) && EQ_16( st->cng_type, FD_CNG ) && st->cng_sba_flag, Q_input, &Q_cldfb_scale ); - Scale_sig32( Cldfb_RealBuffer_fx[1][0], CLDFB_NO_CHANNELS_MAX, sub( Q6, Q_cldfb_scale ) ); - Scale_sig32( Cldfb_ImagBuffer_fx[1][0], CLDFB_NO_CHANNELS_MAX, sub( Q6, Q_cldfb_scale ) ); + ( L_or( EQ_32( st->core_brate, FRAME_NO_DATA ), EQ_32( st->core_brate, SID_2k40 ) ) ) && EQ_16( st->cng_type, FD_CNG ) && st->cng_sba_flag, Q_input, &q_temp_cldfb ); + Scale_sig32( Cldfb_RealBuffer_fx[1][0], CLDFB_NO_CHANNELS_MAX, sub( Q6, q_temp_cldfb ) ); + Scale_sig32( Cldfb_ImagBuffer_fx[1][0], CLDFB_NO_CHANNELS_MAX, sub( Q6, q_temp_cldfb ) ); } /* LFE synthesis */ IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && !hDirACRend->hOutSetup.separateChannelEnabled && !( EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && EQ_16( hDirACRend->hOutSetup.num_lfe, 0 ) ) ) { - Word16 cldfb_q = Q6; - move16(); ivas_lfe_synth_with_cldfb_fx( st_ivas->hMasa->hMasaLfeSynth, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS - 1], Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS - 1], slot_idx, md_idx, - nchan_transport, cldfb_q ); + nchan_transport, q_cldfb ); } + /*-----------------------------------------------------------------* + * protoype signal computation + *-----------------------------------------------------------------*/ + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + IF( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && EQ_16( st_ivas->hCombinedOrientationData->shd_rot_max_order, 0 ) ) + { + protoSignalComputation_shd_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, + proto_direct_buffer_f_fx, + &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, + proto_diffuse_buffer_f_fx, + &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, + reference_power_fix, &DirAC_mem.reference_power_q, + slot_idx, nchan_transport, + hDirACRend->num_outputs_diff, + hSpatParamRendCom->num_freq_bands, + p_Rmat_fx, q_cldfb ); + } + ELSE + { + protoSignalComputation_shd_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, + proto_direct_buffer_f_fx, + &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, + proto_diffuse_buffer_f_fx, + &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, + reference_power_fix, &DirAC_mem.reference_power_q, + slot_idx, nchan_transport, + hDirACRend->num_outputs_diff, + hSpatParamRendCom->num_freq_bands, + 0, q_cldfb ); + } + } + ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) + { + protoSignalComputation2_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, 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, + reference_power_fix, + &DirAC_mem.reference_power_q, + proto_power_smooth_fx, + &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, + 0, slot_idx, hSpatParamRendCom->num_freq_bands, hDirACRend->masa_stereo_type_detect, + q_cldfb ); + } + ELSE + { + SWITCH( nchan_transport ) + { + case 11: + case 8: + case 6: + case 4: + protoSignalComputation4_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, + 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, + reference_power_fix, + &DirAC_mem.reference_power_q, + proto_power_smooth_fx, + &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, + slot_idx, hDirACRend->num_outputs_diff, + hSpatParamRendCom->num_freq_bands, + hDirACRend->hoa_decoder, + nchan_transport, + hDirACRend->sba_map_tc, q_cldfb ); + BREAK; + case 2: + protoSignalComputation2_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, 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, + reference_power_fix, + &DirAC_mem.reference_power_q, + proto_power_smooth_fx, + &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, + hDirACRend->hOutSetup.is_loudspeaker_setup, + slot_idx, + hSpatParamRendCom->num_freq_bands, + hDirACRend->masa_stereo_type_detect, + q_cldfb ); + BREAK; + case 1: + protoSignalComputation1_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, + 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, + reference_power_fix, + &DirAC_mem.reference_power_q, + proto_power_smooth_fx, + &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, + slot_idx, + hDirACRend->num_protos_diff, + hSpatParamRendCom->num_freq_bands, q_cldfb ); + BREAK; + default: + return; + } + } - /////////////////////////////////////////////////////// to be removed ///////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////// to be removed /////////////////////////////////////////////////////////////// IF( EQ_16( hDirAC->hConfig->dec_param_estim, FALSE ) && EQ_16( slot_idx, 0 ) ) { IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) @@ -4094,129 +4253,76 @@ void ivas_dirac_dec_render_sf( st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth = fixedToFloat_32( st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth_fx, st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth_q ); st_ivas->hMasa->hMasaLfeSynth->targetEneTransSmooth = fixedToFloat_32( st_ivas->hMasa->hMasaLfeSynth->targetEneTransSmooth_fx, st_ivas->hMasa->hMasaLfeSynth->targetEneTransSmooth_q ); } - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - /*-----------------------------------------------------------------* - * protoype signal computation - *-----------------------------------------------------------------*/ - q_cldfb = Q6; - move16(); IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - IF( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && EQ_16( st_ivas->hCombinedOrientationData->shd_rot_max_order, 0 ) ) - { - protoSignalComputation_shd_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, - proto_direct_buffer_f_fx, - &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, - proto_diffuse_buffer_f_fx, - &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, - reference_power_fix, &DirAC_mem.reference_power_q, - slot_idx, nchan_transport, - hDirACRend->num_outputs_diff, - hSpatParamRendCom->num_freq_bands, - p_Rmat_fx, q_cldfb ); - } - ELSE - { - protoSignalComputation_shd_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, - proto_direct_buffer_f_fx, - &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, - proto_diffuse_buffer_f_fx, - &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, - reference_power_fix, &DirAC_mem.reference_power_q, - slot_idx, nchan_transport, - hDirACRend->num_outputs_diff, - hSpatParamRendCom->num_freq_bands, - 0, q_cldfb ); - } - /////////////////////////////////////////// to be removed /////////////////////////////////////////////// fixedToFloat_arrL32( &proto_direct_buffer_f_fx[i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, nchan_transport ) )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, nchan_transport ) ), hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, 2 * nchan_transport * hSpatParamRendCom->num_freq_bands ); fixedToFloat_arrL32( &proto_diffuse_buffer_f_fx[i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) )], hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f + i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ), hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, 2 * s_min( nchan_transport, hDirACRend->num_outputs_diff ) * hSpatParamRendCom->num_freq_bands ); IF( nchan_transport >= 4 ) { fixedToFloat_arrL32( reference_power_fix, reference_power, DirAC_mem.reference_power_q, 5 * hSpatParamRendCom->num_freq_bands ); } - ///////////////////////////////////////////////////////////////////////////////////////////////////////// + IF( nchan_transport == 4 && p_Rmat_fx != 0 ) + { + FOR( i = 0; i < 4; i++ ) + { + fixedToFloat_arrL32( Cldfb_RealBuffer_fx[i][0], Cldfb_RealBuffer[i][0], Q6, hSpatParamRendCom->num_freq_bands ); + fixedToFloat_arrL32( Cldfb_ImagBuffer_fx[i][0], Cldfb_ImagBuffer[i][0], Q6, hSpatParamRendCom->num_freq_bands ); + } + } } - else if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_MONO ) + ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) { - protoSignalComputation2( Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirACRend->proto_frame_f, - hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, - reference_power, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, - 0, slot_idx, hSpatParamRendCom->num_freq_bands, hDirACRend->masa_stereo_type_detect ); + 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( reference_power_fix, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); + IF( hDirACRend->masa_stereo_type_detect ) + { + 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 ); + } } - else + ELSE { - switch ( nchan_transport ) + SWITCH( nchan_transport ) { case 11: case 8: case 6: case 4: - ///////////////////////////////////////// to be removed ///////////////////////////////////////// - floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff ); - /////////////////////////////////////////////////////////////////////////////////////////////// - protoSignalComputation4_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, - 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, - reference_power_fix, - &DirAC_mem.reference_power_q, - proto_power_smooth_fx, - &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, - slot_idx, hDirACRend->num_outputs_diff, - hSpatParamRendCom->num_freq_bands, - hDirACRend->hoa_decoder, - nchan_transport, - hDirACRend->sba_map_tc, q_cldfb ); - //////////////////////////////////////////////// to be removed ///////////////////////////////////////////////////////// - Word16 offset = i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); + 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( reference_power_fix, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - break; + BREAK; case 2: - protoSignalComputation2( Cldfb_RealBuffer, Cldfb_ImagBuffer, - hDirACRend->proto_frame_f, - hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, - reference_power, - hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, - hDirACRend->hOutSetup.is_loudspeaker_setup, - slot_idx, - hSpatParamRendCom->num_freq_bands, - hDirACRend->masa_stereo_type_detect ); - break; + IF( hDirACRend->hOutSetup.is_loudspeaker_setup ) + { + 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( 3, hSpatParamRendCom->num_freq_bands ) ); + fixedToFloat_arrL32( &proto_direct_buffer_f_fx[i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 3 )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 3 ), hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); + } + ELSE + { + 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 ) ); + IF( hDirACRend->masa_stereo_type_detect ) + { + 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( reference_power_fix, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); + BREAK; case 1: - ////////////////////////////////// to be removed ///////////////////////////////////////////////////////// - floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hSpatParamRendCom->num_freq_bands ); - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - protoSignalComputation1_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, - 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, - reference_power_fix, - &DirAC_mem.reference_power_q, - proto_power_smooth_fx, - &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, - slot_idx, - hDirACRend->num_protos_diff, - hSpatParamRendCom->num_freq_bands, q_cldfb ); - ////////////////////////////// to be removed /////////////////////////////////////////////////////////////////////////////////////// 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( reference_power_fix, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - break; - default: - return; + BREAK; } } + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #else float dirEne; float surCohEner; diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index b0fafc05de1edd0908aebbecbdd5ffacc176658f..d6560e17b4860c81d7bf16047391fa58453eafff 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -520,13 +520,6 @@ static ivas_error ivas_ism_bitrate_switching_dec( st_ivas->hCombinedOrientationData->Rmat_fx[0][ind1][ind2] = (Word32) ( st_ivas->hCombinedOrientationData->Rmat[0][ind1][ind2] * ( 1 << 15 ) ); } } - if ( st_ivas->hMasaIsmData ) - { - for ( Word16 ch_idx = 0; ch_idx < st_ivas->hMasaIsmData->delayBuffer_nchan; ch_idx++ ) - { - floatToFixed_arr32( st_ivas->hMasaIsmData->delayBuffer[ch_idx], st_ivas->hMasaIsmData->delayBuffer_fx[ch_idx], Q11, st_ivas->hMasaIsmData->delayBuffer_size ); - } - } if ( st_ivas->hSbaIsmData ) { for ( Word16 ch_idx = 0; ch_idx < st_ivas->hSbaIsmData->delayBuffer_nchan; ch_idx++ ) diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index c596935460d275faf1a76de74dc59a256a8d9981..f6a08c7e08fee7fcd23bea55557dfd8c7a74485d 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -719,22 +719,6 @@ ivas_error ivas_omasa_separate_object_renderer_open( set32_fx( st_ivas->hMasaIsmData->delayBuffer_fx[i], 0, st_ivas->hMasaIsmData->delayBuffer_size ); } - // To be removed later ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - IF ( ( st_ivas->hMasaIsmData->delayBuffer = (float **) malloc( st_ivas->hMasaIsmData->delayBuffer_nchan * sizeof( float * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM delay buffer \n" ) ); - } - - FOR ( i = 0; i < st_ivas->hMasaIsmData->delayBuffer_nchan; i++ ) - { - IF ( ( st_ivas->hMasaIsmData->delayBuffer[i] = (float *) malloc( st_ivas->hMasaIsmData->delayBuffer_size * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM delay buffer \n" ) ); - } - set_zero( st_ivas->hMasaIsmData->delayBuffer[i], st_ivas->hMasaIsmData->delayBuffer_size ); - } - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - return IVAS_ERR_OK; } #endif @@ -797,20 +781,6 @@ void ivas_omasa_separate_object_renderer_close( free( st_ivas->hMasaIsmData->delayBuffer_fx ); st_ivas->hMasaIsmData->delayBuffer_fx = NULL; - // To be removed later ////////////////////////////////////////////////// - FOR ( i = 0; i < st_ivas->hMasaIsmData->delayBuffer_nchan; i++ ) - { - IF ( st_ivas->hMasaIsmData->delayBuffer[i] != NULL ) - { - free( st_ivas->hMasaIsmData->delayBuffer[i] ); - st_ivas->hMasaIsmData->delayBuffer[i] = NULL; - } - } - - free( st_ivas->hMasaIsmData->delayBuffer ); - st_ivas->hMasaIsmData->delayBuffer = NULL; - ////////////////////////////////////////////////////////////////////////// - } } @@ -827,6 +797,7 @@ void ivas_omasa_separate_object_renderer_close( * Rendering separated objects and mixing them to the parametrically rendered signals for JBM *-------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_omasa_separate_object_render_jbm( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const uint16_t nSamplesRendered, /* i : number of samples rendered */ @@ -844,10 +815,6 @@ void ivas_omasa_separate_object_render_jbm( int16_t j, k, j2; int16_t obj; float gains[MAX_OUTPUT_CHANNELS]; -#ifdef IVAS_FLOAT_FIXED - Word32 gains_fx[MAX_OUTPUT_CHANNELS]; - set32_fx(gains_fx, 0, MAX_OUTPUT_CHANNELS); -#endif float g1, g2; int16_t lfe_index; int16_t azimuth, elevation; @@ -929,11 +896,7 @@ void ivas_omasa_separate_object_render_jbm( { for ( k = 0; k < n_samples_sf; k++ ) { -#ifdef IVAS_FLOAT_FIXED - hRendererData->interpolator_fx[k] = div_s( k, n_samples_sf ); -#else hRendererData->interpolator[k] = (float) k / ( (float) n_samples_sf ); -#endif } hRendererData->interpolator_length = n_samples_sf; } @@ -959,17 +922,7 @@ void ivas_omasa_separate_object_render_jbm( if ( hVBAPdata != NULL ) { -#ifdef IVAS_FLOAT_FIXED - vbap_determine_gains_fx(hVBAPdata, gains_fx, azimuth, elevation, 1); - FOR (int i = 0; i < MAX_OUTPUT_CHANNELS; i++) { - gains[i] = fix_to_float(gains_fx[i], Q29); - } -#else vbap_determine_gains( hVBAPdata, gains, azimuth, elevation, 1 ); -#endif - /*Word32 gains_fx[16]; - vbap_determine_gains_fx( hVBAPdata, gains_fx, azimuth, elevation, 1 ); - for (j = 0; j < nchan_out_woLFE; j++) gains[j] = (float)gains_fx[j] / (float)(1 << 29);*/ } else { @@ -987,32 +940,16 @@ void ivas_omasa_separate_object_render_jbm( j2 = j; } -#ifdef IVAS_FLOAT_FIXED - if ( fabsf( gains[j] ) > 0.0f || fabsf( fix_to_float( hRendererData->prev_gains_fx[obj][j], Q30 ) ) > 0.0f ) -#else if ( fabsf( gains[j] ) > 0.0f || fabsf( hRendererData->prev_gains[obj][j] ) > 0.0f ) -#endif { for ( k = 0; k < n_samples_sf; k++ ) { -#ifdef IVAS_FLOAT_FIXED - g1 = fix16_to_float(hRendererData->interpolator_fx[k],Q15); -#else g1 = hRendererData->interpolator[k]; -#endif g2 = 1.0f - g1; -#ifdef IVAS_FLOAT_FIXED - output_f_local[j2][k + offsetSamples] += ( g1 * gains[j] + g2 * fix_to_float( hRendererData->prev_gains_fx[obj][j], Q30 ) ) * input_f[obj][k + offsetSamples]; -#else output_f_local[j2][k + offsetSamples] += ( g1 * gains[j] + g2 * hRendererData->prev_gains[obj][j] ) * input_f[obj][k + offsetSamples]; -#endif } } -#ifdef IVAS_FLOAT_FIXED - hRendererData->prev_gains_fx[obj][j] = float_to_fix(gains[j], Q30); -#else hRendererData->prev_gains[obj][j] = gains[j]; -#endif } offsetSamples += n_samples_sf; @@ -1021,7 +958,7 @@ void ivas_omasa_separate_object_render_jbm( return; } -#ifdef IVAS_FLOAT_FIXED +#else void ivas_omasa_separate_object_render_jbm_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const UWord16 nSamplesRendered, /* i : number of samples rendered */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index ffb4813bba0acc63cb8d634958878306473067b5..ec1c6f4b8d831bcbd5bbd3ca06efc39f6fe569f6 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -314,7 +314,7 @@ ivas_error ivas_jbm_dec_tc( } 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; + //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; } @@ -462,7 +462,7 @@ ivas_error ivas_jbm_dec_tc( } 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; + //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; } @@ -581,10 +581,6 @@ ivas_error ivas_jbm_dec_tc( #ifdef IVAS_FLOAT_FIXED // Float to fix conversion starts here. - FOR( Word32 l = 0; l < st_ivas->nchan_ism; l++ ) - { - st_ivas->hMasaIsmData->q_azimuth_old_fx[l] = float_to_fix( st_ivas->hMasaIsmData->q_azimuth_old[l], Q22 ); - } IF( st_ivas->hMasa->hMasaLfeSynth != NULL ) { FOR( Word32 j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) @@ -648,20 +644,6 @@ ivas_error ivas_jbm_dec_tc( } } } - FOR( Word32 l = 0; l < st_ivas->nchan_ism; l++ ) - { - st_ivas->hMasaIsmData->q_azimuth_old[l] = fix_to_float( st_ivas->hMasaIsmData->q_azimuth_old_fx[l], Q22 ); - } - IF( st_ivas->hMasaIsmData != NULL ) - { - FOR( Word32 k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++ ) - { - FOR( Word32 j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - st_ivas->hMasaIsmData->masa_to_total_energy_ratio[k][j] = fix_to_float( st_ivas->hMasaIsmData->masa_to_total_energy_ratio_fx[k][j], Q30 ); - } - } - } st_ivas->hMasa->data.dir_decode_quality = fix16_to_float( st_ivas->hMasa->data.dir_decode_quality_fx, Q14 ); IF( st_ivas->hMasa->hMasaLfeSynth != NULL ) { @@ -743,7 +725,7 @@ ivas_error ivas_jbm_dec_tc( } 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 ); + //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 ); } @@ -886,7 +868,7 @@ ivas_error ivas_jbm_dec_tc( { 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 ); + //floatToFixed_arrL( hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float, hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32, Q11, 111 ); } @@ -918,7 +900,7 @@ 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 ) ); + //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 ) @@ -1089,7 +1071,7 @@ ivas_error ivas_jbm_dec_tc( 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 ); + //st->hTcxDec->conceal_eof_gain_float = fix16_to_float( st->hTcxDec->conceal_eof_gain, Q14 ); /*-------------------cldfb-start-------------------------*/ @@ -1135,58 +1117,6 @@ ivas_error ivas_jbm_dec_tc( sts[n]->hBWE_FD->prev_flag = sts[n]->hBWE_FD->prev_flag; } - /* reset TBE buffers */ - if ( sts[n]->hBWE_TD != NULL ) - { - IF( ( ( EQ_16( sts[n]->extl, SWB_TBE ) || EQ_16( sts[n]->extl, FB_TBE ) || EQ_16( sts[n]->extl, SWB_CNG ) ) && - ( NE_16( sts[n]->L_frame, sts[n]->last_L_frame ) || ( NE_16( sts[n]->last_extl, SWB_TBE ) && NE_16( sts[n]->last_extl, FB_TBE ) ) || EQ_16( sts[n]->last_core, HQ_CORE ) ) ) || - ( LT_16( sts[n]->bwidth, sts[n]->last_bwidth ) && NE_16( sts[n]->last_extl, SWB_TBE ) ) || sts[n]->old_ppp_mode || ( ( EQ_16( sts[n]->prev_coder_type, AUDIO ) || EQ_16( sts[n]->prev_coder_type, INACTIVE ) ) && sts[n]->bws_cnt > 0 ) || ( sts[n]->bws_cnt == 0 && EQ_16( sts[n]->prev_bws_cnt, N_WS2N_FRAMES ) ) ) - { - - reset_swb_tbe = 1; - - IF( EQ_16( output_frame, L_FRAME16k ) ) - { - fixedToFloat_arr( sts[n]->hBWE_TD->mem_resamp_HB_32k_fx, sts[n]->hBWE_TD->mem_resamp_HB_32k, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); - } - fixedToFloat_arr( sts[n]->hBWE_TD->int_3_over_2_tbemem_dec_fx, sts[n]->hBWE_TD->int_3_over_2_tbemem_dec, 0, INTERP_3_2_MEM_LEN ); - } - ELSE IF( sts[n]->hBWE_TD != NULL && ( sts[n]->last_core == TCX_20_CORE || sts[n]->last_core == TCX_10_CORE ) ) - { - /*------------TBEreset_dec_ivas_fx-start------------------*/ - IF( EQ_16( sts[n]->bwidth, WB ) ) - { - reset_wb_tbe_synth = 1; - - fixedToFloat_arr( sts[n]->hBWE_TD->syn_overlap_fx, sts[n]->hBWE_TD->syn_overlap, 0, L_SHB_LAHEAD ); - } - ELSE IF( EQ_16( sts[n]->bwidth, SWB ) || EQ_16( sts[n]->bwidth, FB ) ) - { - reset_swb_tbe = 1; - fixedToFloat_arr( sts[n]->hBWE_TD->int_3_over_2_tbemem_dec_fx, sts[n]->hBWE_TD->int_3_over_2_tbemem_dec, 0, INTERP_3_2_MEM_LEN ); // setting to zero - fixedToFloat_arr( sts[n]->hBWE_TD->mem_resamp_HB_32k_fx, sts[n]->hBWE_TD->mem_resamp_HB_32k, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); // setting to zero - } - /*------------TBEreset_dec_ivas_fx-end--------------------*/ - } - - IF( NE_16( sts[n]->last_extl, WB_TBE ) && EQ_16( sts[n]->extl, WB_TBE ) ) - { - reset_wb_tbe_synth = 1; - fixedToFloat_arr( sts[n]->hBWE_TD->syn_overlap_fx, sts[n]->hBWE_TD->syn_overlap, 0, L_SHB_LAHEAD ); // setting to zero - } - - IF( reset_swb_tbe ) - { - fixedToFloat_arr( sts[n]->hBWE_TD->syn_overlap_fx, sts[n]->hBWE_TD->syn_overlap, 0, L_SHB_LAHEAD ); // setting to zero - } - IF( reset_wb_tbe_synth ) - { - fixedToFloat_arr( sts[n]->hBWE_TD->state_lsyn_filt_shb_fx, sts[n]->hBWE_TD->state_lsyn_filt_shb, 0, 2 * ALLPASSSECTIONS_STEEP ); // setting to zero - fixedToFloat_arr( sts[n]->hBWE_TD->state_lsyn_filt_dwn_shb_fx, sts[n]->hBWE_TD->state_lsyn_filt_dwn_shb, 0, 2 * ALLPASSSECTIONS_STEEP ); // setting to zero - fixedToFloat_arr( sts[n]->hBWE_TD->mem_resamp_HB_fx, sts[n]->hBWE_TD->mem_resamp_HB, 0, INTERP_3_1_MEM_LEN ); // setting to zero - } - } - /*------------------reset-code-end-----------------------*/ @@ -1206,7 +1136,7 @@ ivas_error ivas_jbm_dec_tc( { for ( k = 0; k < 111; k++ ) { - hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] = (float) hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] / ( 1u << q_output ); + //hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] = (float) hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] / ( 1u << q_output ); } } IF( hCPE->hCoreCoder[n]->hTcxLtpDec ) @@ -1240,13 +1170,13 @@ 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->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++ ) @@ -1585,10 +1515,8 @@ ivas_error ivas_jbm_dec_tc( 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_arr(&hCPE->hStereoDft->smooth_fac[0][0], &hCPE->hStereoDft->smooth_fac_fx[0][0], Q15, sizeof(hCPE->hStereoDft->smooth_fac_fx) / sizeof(hCPE->hStereoDft->smooth_fac_fx[0][0])); 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->mixer_mat_smooth[0][0][0], &hCPE->hStereoDft->mixer_mat_smooth_fx[0][0][0], Q31, sizeof(hCPE->hStereoDft->mixer_mat_smooth_fx) / sizeof(hCPE->hStereoDft->mixer_mat_smooth_fx[0][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++) @@ -1657,10 +1585,8 @@ ivas_error ivas_jbm_dec_tc( 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->mixer_mat_smooth_fx[0][0][0], &hCPE->hStereoDft->mixer_mat_smooth[0][0][0], Q31, sizeof(hCPE->hStereoDft->mixer_mat_smooth_fx) / sizeof(hCPE->hStereoDft->mixer_mat_smooth_fx[0][0][0])); 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_arr(&hCPE->hStereoDft->smooth_fac_fx[0][0], &hCPE->hStereoDft->smooth_fac[0][0], Q15, sizeof(hCPE->hStereoDft->smooth_fac_fx) / sizeof(hCPE->hStereoDft->smooth_fac_fx[0][0])); } for (int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++) { @@ -1990,10 +1916,6 @@ ivas_error ivas_jbm_dec_tc( else tmp_nchan_ism = st_ivas->nchan_ism; ///////////////////////////////////// Float to fix conversion starts here. /////////////////////////////////// - FOR( Word32 l = 0; l < st_ivas->nchan_ism; l++ ) - { - st_ivas->hMasaIsmData->q_azimuth_old_fx[l] = float_to_fix( st_ivas->hMasaIsmData->q_azimuth_old[l], Q22 ); - } IF( st_ivas->hMasa->hMasaLfeSynth != NULL ) { FOR( Word32 j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) @@ -2145,20 +2067,6 @@ ivas_error ivas_jbm_dec_tc( } } } - FOR( Word32 l = 0; l < st_ivas->nchan_ism; l++ ) - { - st_ivas->hMasaIsmData->q_azimuth_old[l] = fix_to_float( st_ivas->hMasaIsmData->q_azimuth_old_fx[l], Q22 ); - } - IF( st_ivas->hMasaIsmData != NULL ) - { - FOR( Word32 k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++ ) - { - FOR( Word32 j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - st_ivas->hMasaIsmData->masa_to_total_energy_ratio[k][j] = fix_to_float( st_ivas->hMasaIsmData->masa_to_total_energy_ratio_fx[k][j], Q30 ); - } - } - } st_ivas->hMasa->data.dir_decode_quality = fix16_to_float( st_ivas->hMasa->data.dir_decode_quality_fx, Q14 ); IF( st_ivas->hMasa->hMasaLfeSynth != NULL ) { @@ -2196,7 +2104,7 @@ ivas_error ivas_jbm_dec_tc( { 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; + //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; } @@ -2338,7 +2246,7 @@ ivas_error ivas_jbm_dec_tc( } 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 ); + //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 ); } @@ -2481,7 +2389,7 @@ ivas_error ivas_jbm_dec_tc( { 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 ); + //floatToFixed_arrL( hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float, hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32, Q11, 111 ); } @@ -2514,7 +2422,7 @@ 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 ) ); + //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 ) @@ -2681,7 +2589,7 @@ ivas_error ivas_jbm_dec_tc( 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 ); + //st->hTcxDec->conceal_eof_gain_float = fix16_to_float( st->hTcxDec->conceal_eof_gain, Q14 ); /*-------------------cldfb-start-------------------------*/ @@ -2725,61 +2633,6 @@ ivas_error ivas_jbm_dec_tc( sts[n]->hBWE_FD->prev_flag = sts[n]->hBWE_FD->prev_flag; } - /* reset TBE buffers */ - if ( sts[n]->hBWE_TD != NULL ) - { - IF( ( ( EQ_16( sts[n]->extl, SWB_TBE ) || EQ_16( sts[n]->extl, FB_TBE ) || EQ_16( sts[n]->extl, SWB_CNG ) ) && - ( NE_16( sts[n]->L_frame, sts[n]->last_L_frame ) || ( NE_16( sts[n]->last_extl, SWB_TBE ) && NE_16( sts[n]->last_extl, FB_TBE ) ) || EQ_16( sts[n]->last_core, HQ_CORE ) ) ) || - ( LT_16( sts[n]->bwidth, sts[n]->last_bwidth ) && NE_16( sts[n]->last_extl, SWB_TBE ) ) || sts[n]->old_ppp_mode || ( ( EQ_16( sts[n]->prev_coder_type, AUDIO ) || EQ_16( sts[n]->prev_coder_type, INACTIVE ) ) && sts[n]->bws_cnt > 0 ) || ( sts[n]->bws_cnt == 0 && EQ_16( sts[n]->prev_bws_cnt, N_WS2N_FRAMES ) ) ) - { - - reset_swb_tbe = 1; - - IF( EQ_16( output_frame, L_FRAME16k ) ) - { - fixedToFloat_arr( sts[n]->hBWE_TD->mem_resamp_HB_32k_fx, sts[n]->hBWE_TD->mem_resamp_HB_32k, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); - } - fixedToFloat_arr( sts[n]->hBWE_TD->int_3_over_2_tbemem_dec_fx, sts[n]->hBWE_TD->int_3_over_2_tbemem_dec, 0, INTERP_3_2_MEM_LEN ); - } - ELSE IF( sts[n]->hBWE_TD != NULL && ( sts[n]->last_core == TCX_20_CORE || sts[n]->last_core == TCX_10_CORE ) ) - { - /*------------TBEreset_dec_ivas_fx-start------------------*/ - IF( EQ_16( sts[n]->bwidth, WB ) ) - { - reset_wb_tbe_synth = 1; - - fixedToFloat_arr( sts[n]->hBWE_TD->syn_overlap_fx, sts[n]->hBWE_TD->syn_overlap, 0, L_SHB_LAHEAD ); - } - ELSE IF( EQ_16( sts[n]->bwidth, SWB ) || EQ_16( sts[n]->bwidth, FB ) ) - { - reset_swb_tbe = 1; - fixedToFloat_arr( sts[n]->hBWE_TD->int_3_over_2_tbemem_dec_fx, sts[n]->hBWE_TD->int_3_over_2_tbemem_dec, 0, INTERP_3_2_MEM_LEN ); // setting to zero - fixedToFloat_arr( sts[n]->hBWE_TD->mem_resamp_HB_32k_fx, sts[n]->hBWE_TD->mem_resamp_HB_32k, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); // setting to zero - } - /*------------TBEreset_dec_ivas_fx-end--------------------*/ - } - - IF( NE_16( sts[n]->last_extl, WB_TBE ) && EQ_16( sts[n]->extl, WB_TBE ) ) - { - reset_wb_tbe_synth = 1; - fixedToFloat_arr( sts[n]->hBWE_TD->syn_overlap_fx, sts[n]->hBWE_TD->syn_overlap, 0, L_SHB_LAHEAD ); // setting to zero - } - - IF( reset_swb_tbe ) - { - fixedToFloat_arr( sts[n]->hBWE_TD->syn_overlap_fx, sts[n]->hBWE_TD->syn_overlap, 0, L_SHB_LAHEAD ); // setting to zero - } - IF( reset_wb_tbe_synth ) - { - fixedToFloat_arr( sts[n]->hBWE_TD->state_lsyn_filt_shb_fx, sts[n]->hBWE_TD->state_lsyn_filt_shb, 0, 2 * ALLPASSSECTIONS_STEEP ); // setting to zero - fixedToFloat_arr( sts[n]->hBWE_TD->state_lsyn_filt_dwn_shb_fx, sts[n]->hBWE_TD->state_lsyn_filt_dwn_shb, 0, 2 * ALLPASSSECTIONS_STEEP ); // setting to zero - fixedToFloat_arr( sts[n]->hBWE_TD->mem_resamp_HB_fx, sts[n]->hBWE_TD->mem_resamp_HB, 0, INTERP_3_1_MEM_LEN ); // setting to zero - } - } - - /*------------------reset-code-end-----------------------*/ - - for ( int p = 0; p < L_FRAME48k; p++ ) { @@ -2796,7 +2649,7 @@ ivas_error ivas_jbm_dec_tc( { for ( k = 0; k < 111; k++ ) { - hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] = (float) hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] / ( 1u << q_output ); + //hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] = (float) hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] / ( 1u << q_output ); } } IF( hCPE->hCoreCoder[n]->hTcxLtpDec ) @@ -2834,7 +2687,7 @@ ivas_error ivas_jbm_dec_tc( { 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 ); + //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 ) @@ -3067,10 +2920,8 @@ ivas_error ivas_jbm_dec_tc( 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_arr(&hCPE->hStereoDft->smooth_fac[0][0], &hCPE->hStereoDft->smooth_fac_fx[0][0], Q15, sizeof(hCPE->hStereoDft->smooth_fac_fx) / sizeof(hCPE->hStereoDft->smooth_fac_fx[0][0])); 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->mixer_mat_smooth[0][0][0], &hCPE->hStereoDft->mixer_mat_smooth_fx[0][0][0], Q31, sizeof(hCPE->hStereoDft->mixer_mat_smooth_fx) / sizeof(hCPE->hStereoDft->mixer_mat_smooth_fx[0][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++) @@ -3139,10 +2990,8 @@ ivas_error ivas_jbm_dec_tc( 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->mixer_mat_smooth_fx[0][0][0], &hCPE->hStereoDft->mixer_mat_smooth[0][0][0], Q31, sizeof(hCPE->hStereoDft->mixer_mat_smooth_fx) / sizeof(hCPE->hStereoDft->mixer_mat_smooth_fx[0][0][0])); 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_arr(&hCPE->hStereoDft->smooth_fac_fx[0][0], &hCPE->hStereoDft->smooth_fac[0][0], Q15, sizeof(hCPE->hStereoDft->smooth_fac_fx) / sizeof(hCPE->hStereoDft->smooth_fac_fx[0][0])); } for (int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++) { @@ -3558,7 +3407,7 @@ ivas_error ivas_jbm_dec_tc( { 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 ); + //floatToFixed_arrL( hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float, hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32, Q11, 111 ); } @@ -3591,7 +3440,7 @@ 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 ) ); + //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 ) @@ -3758,7 +3607,7 @@ ivas_error ivas_jbm_dec_tc( 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 ); + //st->hTcxDec->conceal_eof_gain_float = fix16_to_float( st->hTcxDec->conceal_eof_gain, Q14 ); /*-------------------cldfb-start-------------------------*/ @@ -3803,61 +3652,6 @@ ivas_error ivas_jbm_dec_tc( sts[n]->hBWE_FD->prev_flag = sts[n]->hBWE_FD->prev_flag; } - /* reset TBE buffers */ - if ( sts[n]->hBWE_TD != NULL ) - { - IF( ( ( EQ_16( sts[n]->extl, SWB_TBE ) || EQ_16( sts[n]->extl, FB_TBE ) || EQ_16( sts[n]->extl, SWB_CNG ) ) && - ( NE_16( sts[n]->L_frame, sts[n]->last_L_frame ) || ( NE_16( sts[n]->last_extl, SWB_TBE ) && NE_16( sts[n]->last_extl, FB_TBE ) ) || EQ_16( sts[n]->last_core, HQ_CORE ) ) ) || - ( LT_16( sts[n]->bwidth, sts[n]->last_bwidth ) && NE_16( sts[n]->last_extl, SWB_TBE ) ) || sts[n]->old_ppp_mode || ( ( EQ_16( sts[n]->prev_coder_type, AUDIO ) || EQ_16( sts[n]->prev_coder_type, INACTIVE ) ) && sts[n]->bws_cnt > 0 ) || ( sts[n]->bws_cnt == 0 && EQ_16( sts[n]->prev_bws_cnt, N_WS2N_FRAMES ) ) ) - { - - reset_swb_tbe = 1; - - IF( EQ_16( output_frame, L_FRAME16k ) ) - { - fixedToFloat_arr( sts[n]->hBWE_TD->mem_resamp_HB_32k_fx, sts[n]->hBWE_TD->mem_resamp_HB_32k, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); - } - fixedToFloat_arr( sts[n]->hBWE_TD->int_3_over_2_tbemem_dec_fx, sts[n]->hBWE_TD->int_3_over_2_tbemem_dec, 0, INTERP_3_2_MEM_LEN ); - } - ELSE IF( sts[n]->hBWE_TD != NULL && ( sts[n]->last_core == TCX_20_CORE || sts[n]->last_core == TCX_10_CORE ) ) - { - /*------------TBEreset_dec_ivas_fx-start------------------*/ - IF( EQ_16( sts[n]->bwidth, WB ) ) - { - reset_wb_tbe_synth = 1; - - fixedToFloat_arr( sts[n]->hBWE_TD->syn_overlap_fx, sts[n]->hBWE_TD->syn_overlap, 0, L_SHB_LAHEAD ); - } - ELSE IF( EQ_16( sts[n]->bwidth, SWB ) || EQ_16( sts[n]->bwidth, FB ) ) - { - reset_swb_tbe = 1; - fixedToFloat_arr( sts[n]->hBWE_TD->int_3_over_2_tbemem_dec_fx, sts[n]->hBWE_TD->int_3_over_2_tbemem_dec, 0, INTERP_3_2_MEM_LEN ); // setting to zero - fixedToFloat_arr( sts[n]->hBWE_TD->mem_resamp_HB_32k_fx, sts[n]->hBWE_TD->mem_resamp_HB_32k, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); // setting to zero - } - /*------------TBEreset_dec_ivas_fx-end--------------------*/ - } - - IF( NE_16( sts[n]->last_extl, WB_TBE ) && EQ_16( sts[n]->extl, WB_TBE ) ) - { - reset_wb_tbe_synth = 1; - fixedToFloat_arr( sts[n]->hBWE_TD->syn_overlap_fx, sts[n]->hBWE_TD->syn_overlap, 0, L_SHB_LAHEAD ); // setting to zero - } - - IF( reset_swb_tbe ) - { - fixedToFloat_arr( sts[n]->hBWE_TD->syn_overlap_fx, sts[n]->hBWE_TD->syn_overlap, 0, L_SHB_LAHEAD ); // setting to zero - } - IF( reset_wb_tbe_synth ) - { - fixedToFloat_arr( sts[n]->hBWE_TD->state_lsyn_filt_shb_fx, sts[n]->hBWE_TD->state_lsyn_filt_shb, 0, 2 * ALLPASSSECTIONS_STEEP ); // setting to zero - fixedToFloat_arr( sts[n]->hBWE_TD->state_lsyn_filt_dwn_shb_fx, sts[n]->hBWE_TD->state_lsyn_filt_dwn_shb, 0, 2 * ALLPASSSECTIONS_STEEP ); // setting to zero - fixedToFloat_arr( sts[n]->hBWE_TD->mem_resamp_HB_fx, sts[n]->hBWE_TD->mem_resamp_HB, 0, INTERP_3_1_MEM_LEN ); // setting to zero - } - } - - /*------------------reset-code-end-----------------------*/ - - for ( int p = 0; p < L_FRAME48k; p++ ) { @@ -3874,7 +3668,7 @@ ivas_error ivas_jbm_dec_tc( { for ( k = 0; k < 111; k++ ) { - hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] = (float) hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] / ( 1u << q_output ); + //hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] = (float) hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] / ( 1u << q_output ); } } IF( hCPE->hCoreCoder[n]->hTcxLtpDec ) @@ -3912,7 +3706,7 @@ ivas_error ivas_jbm_dec_tc( { 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 ); + //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 ) @@ -4196,7 +3990,7 @@ ivas_error ivas_jbm_dec_tc( { 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 ); + //floatToFixed_arrL( hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float, hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32, Q11, 111 ); } @@ -4229,7 +4023,7 @@ 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 ) ); + //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 ) @@ -4396,7 +4190,7 @@ ivas_error ivas_jbm_dec_tc( 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 ); + //st->hTcxDec->conceal_eof_gain_float = fix16_to_float( st->hTcxDec->conceal_eof_gain, Q14 ); /*-------------------cldfb-start-------------------------*/ @@ -4441,61 +4235,6 @@ ivas_error ivas_jbm_dec_tc( sts[n]->hBWE_FD->prev_flag = sts[n]->hBWE_FD->prev_flag; } - /* reset TBE buffers */ - if ( sts[n]->hBWE_TD != NULL ) - { - IF( ( ( EQ_16( sts[n]->extl, SWB_TBE ) || EQ_16( sts[n]->extl, FB_TBE ) || EQ_16( sts[n]->extl, SWB_CNG ) ) && - ( NE_16( sts[n]->L_frame, sts[n]->last_L_frame ) || ( NE_16( sts[n]->last_extl, SWB_TBE ) && NE_16( sts[n]->last_extl, FB_TBE ) ) || EQ_16( sts[n]->last_core, HQ_CORE ) ) ) || - ( LT_16( sts[n]->bwidth, sts[n]->last_bwidth ) && NE_16( sts[n]->last_extl, SWB_TBE ) ) || sts[n]->old_ppp_mode || ( ( EQ_16( sts[n]->prev_coder_type, AUDIO ) || EQ_16( sts[n]->prev_coder_type, INACTIVE ) ) && sts[n]->bws_cnt > 0 ) || ( sts[n]->bws_cnt == 0 && EQ_16( sts[n]->prev_bws_cnt, N_WS2N_FRAMES ) ) ) - { - - reset_swb_tbe = 1; - - IF( EQ_16( output_frame, L_FRAME16k ) ) - { - fixedToFloat_arr( sts[n]->hBWE_TD->mem_resamp_HB_32k_fx, sts[n]->hBWE_TD->mem_resamp_HB_32k, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); - } - fixedToFloat_arr( sts[n]->hBWE_TD->int_3_over_2_tbemem_dec_fx, sts[n]->hBWE_TD->int_3_over_2_tbemem_dec, 0, INTERP_3_2_MEM_LEN ); - } - ELSE IF( sts[n]->hBWE_TD != NULL && ( sts[n]->last_core == TCX_20_CORE || sts[n]->last_core == TCX_10_CORE ) ) - { - /*------------TBEreset_dec_ivas_fx-start------------------*/ - IF( EQ_16( sts[n]->bwidth, WB ) ) - { - reset_wb_tbe_synth = 1; - - fixedToFloat_arr( sts[n]->hBWE_TD->syn_overlap_fx, sts[n]->hBWE_TD->syn_overlap, 0, L_SHB_LAHEAD ); - } - ELSE IF( EQ_16( sts[n]->bwidth, SWB ) || EQ_16( sts[n]->bwidth, FB ) ) - { - reset_swb_tbe = 1; - fixedToFloat_arr( sts[n]->hBWE_TD->int_3_over_2_tbemem_dec_fx, sts[n]->hBWE_TD->int_3_over_2_tbemem_dec, 0, INTERP_3_2_MEM_LEN ); // setting to zero - fixedToFloat_arr( sts[n]->hBWE_TD->mem_resamp_HB_32k_fx, sts[n]->hBWE_TD->mem_resamp_HB_32k, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); // setting to zero - } - /*------------TBEreset_dec_ivas_fx-end--------------------*/ - } - - IF( NE_16( sts[n]->last_extl, WB_TBE ) && EQ_16( sts[n]->extl, WB_TBE ) ) - { - reset_wb_tbe_synth = 1; - fixedToFloat_arr( sts[n]->hBWE_TD->syn_overlap_fx, sts[n]->hBWE_TD->syn_overlap, 0, L_SHB_LAHEAD ); // setting to zero - } - - IF( reset_swb_tbe ) - { - fixedToFloat_arr( sts[n]->hBWE_TD->syn_overlap_fx, sts[n]->hBWE_TD->syn_overlap, 0, L_SHB_LAHEAD ); // setting to zero - } - IF( reset_wb_tbe_synth ) - { - fixedToFloat_arr( sts[n]->hBWE_TD->state_lsyn_filt_shb_fx, sts[n]->hBWE_TD->state_lsyn_filt_shb, 0, 2 * ALLPASSSECTIONS_STEEP ); // setting to zero - fixedToFloat_arr( sts[n]->hBWE_TD->state_lsyn_filt_dwn_shb_fx, sts[n]->hBWE_TD->state_lsyn_filt_dwn_shb, 0, 2 * ALLPASSSECTIONS_STEEP ); // setting to zero - fixedToFloat_arr( sts[n]->hBWE_TD->mem_resamp_HB_fx, sts[n]->hBWE_TD->mem_resamp_HB, 0, INTERP_3_1_MEM_LEN ); // setting to zero - } - } - - /*------------------reset-code-end-----------------------*/ - - for ( int p = 0; p < L_FRAME48k; p++ ) { @@ -4512,7 +4251,7 @@ ivas_error ivas_jbm_dec_tc( { for ( k = 0; k < 111; k++ ) { - hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] = (float) hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] / ( 1u << q_output ); + //hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] = (float) hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] / ( 1u << q_output ); } } IF( hCPE->hCoreCoder[n]->hTcxLtpDec ) @@ -4550,7 +4289,7 @@ ivas_error ivas_jbm_dec_tc( { 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 ); + //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 ) @@ -4810,7 +4549,7 @@ ivas_error ivas_jbm_dec_tc( { 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 ); + //floatToFixed_arrL( hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float, hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32, Q11, 111 ); } @@ -4843,7 +4582,7 @@ 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 ) ); + //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 ) @@ -5008,7 +4747,7 @@ ivas_error ivas_jbm_dec_tc( 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 ); + //st->hTcxDec->conceal_eof_gain_float = fix16_to_float( st->hTcxDec->conceal_eof_gain, Q14 ); /*-------------------cldfb-start-------------------------*/ @@ -5053,61 +4792,6 @@ ivas_error ivas_jbm_dec_tc( sts[n]->hBWE_FD->prev_flag = sts[n]->hBWE_FD->prev_flag; } - /* reset TBE buffers */ - if ( sts[n]->hBWE_TD != NULL ) - { - IF( ( ( EQ_16( sts[n]->extl, SWB_TBE ) || EQ_16( sts[n]->extl, FB_TBE ) || EQ_16( sts[n]->extl, SWB_CNG ) ) && - ( NE_16( sts[n]->L_frame, sts[n]->last_L_frame ) || ( NE_16( sts[n]->last_extl, SWB_TBE ) && NE_16( sts[n]->last_extl, FB_TBE ) ) || EQ_16( sts[n]->last_core, HQ_CORE ) ) ) || - ( LT_16( sts[n]->bwidth, sts[n]->last_bwidth ) && NE_16( sts[n]->last_extl, SWB_TBE ) ) || sts[n]->old_ppp_mode || ( ( EQ_16( sts[n]->prev_coder_type, AUDIO ) || EQ_16( sts[n]->prev_coder_type, INACTIVE ) ) && sts[n]->bws_cnt > 0 ) || ( sts[n]->bws_cnt == 0 && EQ_16( sts[n]->prev_bws_cnt, N_WS2N_FRAMES ) ) ) - { - - reset_swb_tbe = 1; - - IF( EQ_16( output_frame, L_FRAME16k ) ) - { - fixedToFloat_arr( sts[n]->hBWE_TD->mem_resamp_HB_32k_fx, sts[n]->hBWE_TD->mem_resamp_HB_32k, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); - } - fixedToFloat_arr( sts[n]->hBWE_TD->int_3_over_2_tbemem_dec_fx, sts[n]->hBWE_TD->int_3_over_2_tbemem_dec, 0, INTERP_3_2_MEM_LEN ); - } - ELSE IF( sts[n]->hBWE_TD != NULL && ( sts[n]->last_core == TCX_20_CORE || sts[n]->last_core == TCX_10_CORE ) ) - { - /*------------TBEreset_dec_ivas_fx-start------------------*/ - IF( EQ_16( sts[n]->bwidth, WB ) ) - { - reset_wb_tbe_synth = 1; - - fixedToFloat_arr( sts[n]->hBWE_TD->syn_overlap_fx, sts[n]->hBWE_TD->syn_overlap, 0, L_SHB_LAHEAD ); - } - ELSE IF( EQ_16( sts[n]->bwidth, SWB ) || EQ_16( sts[n]->bwidth, FB ) ) - { - reset_swb_tbe = 1; - fixedToFloat_arr( sts[n]->hBWE_TD->int_3_over_2_tbemem_dec_fx, sts[n]->hBWE_TD->int_3_over_2_tbemem_dec, 0, INTERP_3_2_MEM_LEN ); // setting to zero - fixedToFloat_arr( sts[n]->hBWE_TD->mem_resamp_HB_32k_fx, sts[n]->hBWE_TD->mem_resamp_HB_32k, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); // setting to zero - } - /*------------TBEreset_dec_ivas_fx-end--------------------*/ - } - - IF( NE_16( sts[n]->last_extl, WB_TBE ) && EQ_16( sts[n]->extl, WB_TBE ) ) - { - reset_wb_tbe_synth = 1; - fixedToFloat_arr( sts[n]->hBWE_TD->syn_overlap_fx, sts[n]->hBWE_TD->syn_overlap, 0, L_SHB_LAHEAD ); // setting to zero - } - - IF( reset_swb_tbe ) - { - fixedToFloat_arr( sts[n]->hBWE_TD->syn_overlap_fx, sts[n]->hBWE_TD->syn_overlap, 0, L_SHB_LAHEAD ); // setting to zero - } - IF( reset_wb_tbe_synth ) - { - fixedToFloat_arr( sts[n]->hBWE_TD->state_lsyn_filt_shb_fx, sts[n]->hBWE_TD->state_lsyn_filt_shb, 0, 2 * ALLPASSSECTIONS_STEEP ); // setting to zero - fixedToFloat_arr( sts[n]->hBWE_TD->state_lsyn_filt_dwn_shb_fx, sts[n]->hBWE_TD->state_lsyn_filt_dwn_shb, 0, 2 * ALLPASSSECTIONS_STEEP ); // setting to zero - fixedToFloat_arr( sts[n]->hBWE_TD->mem_resamp_HB_fx, sts[n]->hBWE_TD->mem_resamp_HB, 0, INTERP_3_1_MEM_LEN ); // setting to zero - } - } - - /*------------------reset-code-end-----------------------*/ - - for ( int p = 0; p < L_FRAME48k; p++ ) { @@ -5124,7 +4808,7 @@ ivas_error ivas_jbm_dec_tc( { for ( k = 0; k < 111; k++ ) { - hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] = (float) hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] / ( 1u << q_output ); + //hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] = (float) hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] / ( 1u << q_output ); } } IF( hCPE->hCoreCoder[n]->hTcxLtpDec ) @@ -5162,7 +4846,7 @@ ivas_error ivas_jbm_dec_tc( { 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 ); + //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 ) @@ -5283,10 +4967,6 @@ ivas_error ivas_jbm_dec_tc( /* read McMASA parameters from the bitstream */ #ifdef IVAS_FLOAT_FIXED // Float to fix conversion starts here. - FOR( Word32 l = 0; l < st_ivas->nchan_ism; l++ ) - { - st_ivas->hMasaIsmData->q_azimuth_old_fx[l] = float_to_fix( st_ivas->hMasaIsmData->q_azimuth_old[l], Q22 ); - } IF( st_ivas->hMasa->hMasaLfeSynth != NULL ) { FOR( Word32 j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) @@ -5350,20 +5030,6 @@ ivas_error ivas_jbm_dec_tc( } } } - FOR( Word32 l = 0; l < st_ivas->nchan_ism; l++ ) - { - st_ivas->hMasaIsmData->q_azimuth_old[l] = fix_to_float( st_ivas->hMasaIsmData->q_azimuth_old_fx[l], Q22 ); - } - IF( st_ivas->hMasaIsmData != NULL ) - { - FOR( Word32 k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++ ) - { - FOR( Word32 j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - st_ivas->hMasaIsmData->masa_to_total_energy_ratio[k][j] = fix_to_float( st_ivas->hMasaIsmData->masa_to_total_energy_ratio_fx[k][j], Q30 ); - } - } - } st_ivas->hMasa->data.dir_decode_quality = fix16_to_float( st_ivas->hMasa->data.dir_decode_quality_fx, Q14 ); IF( st_ivas->hMasa->hMasaLfeSynth != NULL ) { @@ -5444,7 +5110,7 @@ ivas_error ivas_jbm_dec_tc( } 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; + //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; } @@ -5494,7 +5160,7 @@ ivas_error ivas_jbm_dec_tc( } 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 ); + //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 ); } @@ -5665,10 +5331,8 @@ ivas_error ivas_jbm_dec_tc( 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_arr(&hCPE->hStereoDft->smooth_fac[0][0], &hCPE->hStereoDft->smooth_fac_fx[0][0], Q15, sizeof(hCPE->hStereoDft->smooth_fac_fx) / sizeof(hCPE->hStereoDft->smooth_fac_fx[0][0])); 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->mixer_mat_smooth[0][0][0], &hCPE->hStereoDft->mixer_mat_smooth_fx[0][0][0], Q31, sizeof(hCPE->hStereoDft->mixer_mat_smooth_fx) / sizeof(hCPE->hStereoDft->mixer_mat_smooth_fx[0][0][0])); } IF (st_ivas->hSpar != NULL) { @@ -5740,9 +5404,7 @@ ivas_error ivas_jbm_dec_tc( 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->mixer_mat_smooth_fx[0][0][0], &hCPE->hStereoDft->mixer_mat_smooth[0][0][0], Q31, sizeof(hCPE->hStereoDft->mixer_mat_smooth_fx) / sizeof(hCPE->hStereoDft->mixer_mat_smooth_fx[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_arr(&hCPE->hStereoDft->smooth_fac_fx[0][0], &hCPE->hStereoDft->smooth_fac[0][0], Q15, sizeof(hCPE->hStereoDft->smooth_fac_fx) / sizeof(hCPE->hStereoDft->smooth_fac_fx[0][0])); } IF (st_ivas->hSpar != NULL) { @@ -8240,6 +7902,7 @@ ivas_error ivas_jbm_dec_render( * * Flush samples if renderer granularity changes on a bitrate change *--------------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED ivas_error ivas_jbm_dec_flush_renderer_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -8497,8 +8160,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( ivas_syn_output_fx( p_output_fx,Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out,data); return IVAS_ERR_OK; } -#endif // IVAS_FLOAT_FIXED - +#else ivas_error ivas_jbm_dec_flush_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t tc_granularity_new, /* i : new renderer granularity */ @@ -8926,6 +8588,7 @@ ivas_error ivas_jbm_dec_flush_renderer( return IVAS_ERR_OK; } +#endif /*--------------------------------------------------------------------------* diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 167ad9237e74f26fd4b3ad0739f5dab908fbb6b6..7efec9664a753984a6068fcbe568526c188122da 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -126,6 +126,7 @@ static void read_ism_ratio_index_fx( Word16 ratio_ism_idx[MASA_FREQUENCY_BANDS][ #endif +#ifndef IVAS_FLOAT_FIXED /*-----------------------------------------------------------------------* * ivas_masa_decode() * @@ -825,8 +826,7 @@ ivas_error ivas_masa_decode( return error /* *nb_bits_read*/; } - -#ifdef IVAS_FLOAT_FIXED +#else /*-----------------------------------------------------------------------* * ivas_masa_decode_fx() * @@ -1419,20 +1419,6 @@ ivas_error ivas_masa_decode_fx( } } } - FOR( Word32 n = 0; n < st_ivas->nchan_ism; n++ ) - { - st_ivas->hMasaIsmData->q_azimuth_old[n] = fix_to_float( st_ivas->hMasaIsmData->q_azimuth_old_fx[n], Q22 ); - } - IF( st_ivas->hMasaIsmData != NULL ) - { - FOR( Word32 k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++ ) - { - FOR( Word32 j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - st_ivas->hMasaIsmData->masa_to_total_energy_ratio[k][j] = fix_to_float( st_ivas->hMasaIsmData->masa_to_total_energy_ratio_fx[k][j], Q30 ); - } - } - } hMasa->data.dir_decode_quality = fix16_to_float( hMasa->data.dir_decode_quality_fx, Q14 ); if ( hMasa->hMasaLfeSynth != NULL ) { @@ -3284,13 +3270,6 @@ ivas_error ivas_masa_dec_reconfigure( st_ivas->hCombinedOrientationData->Rmat_fx[0][ind1][ind2] = (Word32) ( st_ivas->hCombinedOrientationData->Rmat[0][ind1][ind2] * ( 1 << 15 ) ); } } - if ( st_ivas->hMasaIsmData ) - { - for ( Word16 ch_idx = 0; ch_idx < st_ivas->hMasaIsmData->delayBuffer_nchan; ch_idx++ ) - { - floatToFixed_arr32( st_ivas->hMasaIsmData->delayBuffer[ch_idx], st_ivas->hMasaIsmData->delayBuffer_fx[ch_idx], Q11, st_ivas->hMasaIsmData->delayBuffer_size ); - } - } if ( st_ivas->hSbaIsmData ) { for ( Word16 ch_idx = 0; ch_idx < st_ivas->hSbaIsmData->delayBuffer_nchan; ch_idx++ ) @@ -3805,13 +3784,6 @@ ivas_error ivas_masa_dec_reconfigure_fx( st_ivas->hCombinedOrientationData->Rmat_fx[0][ind1][ind2] = (Word32) ( st_ivas->hCombinedOrientationData->Rmat[0][ind1][ind2] * ( 1 << 15 ) ); } } - if ( st_ivas->hMasaIsmData ) - { - for ( Word16 ch_idx = 0; ch_idx < st_ivas->hMasaIsmData->delayBuffer_nchan; ch_idx++ ) - { - floatToFixed_arr32( st_ivas->hMasaIsmData->delayBuffer[ch_idx], st_ivas->hMasaIsmData->delayBuffer_fx[ch_idx], Q11, st_ivas->hMasaIsmData->delayBuffer_size ); - } - } if ( st_ivas->hSbaIsmData ) { for ( Word16 ch_idx = 0; ch_idx < st_ivas->hSbaIsmData->delayBuffer_nchan; ch_idx++ ) @@ -5890,6 +5862,7 @@ static void decode_ism_ratios_fx( #endif +#ifndef IVAS_FLOAT_FIXED static int16_t ivas_decode_masaism_metadata( IVAS_QMETADATA_HANDLE hQMetaData, MASA_DECODER_HANDLE hMasa, @@ -6053,8 +6026,7 @@ static int16_t ivas_decode_masaism_metadata( return ( nb_bits_read - *next_bit_pos ); } - -#ifdef IVAS_FLOAT_FIXED +#else static Word16 ivas_decode_masaism_metadata_fx( IVAS_QMETADATA_HANDLE hQMetaData, MASA_DECODER_HANDLE hMasa, diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 3942a5f9f78d6bdf5a243e373d6ef91a58c1df3c..faec090b78ee1b5e1b5414dd9246174fe474bcef 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -563,10 +563,10 @@ ivas_error ivas_mct_dec( for ( int k = 0; k < output_frame; k++ ) { hCPE->hCoreCoder[n]->hHQ_core->oldOut_fx[k] = (Word32) ( hCPE->hCoreCoder[n]->hHQ_core->old_out[k] * ( 1u << q ) ); - if ( k < 111 ) - { - hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] = (Word32) ( hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] * ( 1u << q ) ); - } + //if ( k < 111 ) + //{ + // hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] = (Word32) ( hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] * ( 1u << q ) ); + //} if ( k < HQ_DELTA_MAX * HQ_DELAY_COMP ) { hCPE->hCoreCoder[n]->delay_buf_out32_fx[k] = (Word32) ( hCPE->hCoreCoder[n]->delay_buf_out[k] * ( 1u << q ) ); @@ -588,10 +588,10 @@ ivas_error ivas_mct_dec( } hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_gain_post_prev = (Word16) ( hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_gain_post_prev_float * ONE_IN_Q15 ); hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_gain = (Word16) ( hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_gain_float * ONE_IN_Q15 ); - for ( int p = 0; p < 111; p++ ) - { - hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[p] = (Word32) ( hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[p] * ( 1u << q ) ); - } + //for ( int p = 0; p < 111; p++ ) + //{ + // hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[p] = (Word32) ( hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[p] * ( 1u << q ) ); + //} ivas_post_proc_fx( NULL, hCPE, n, synth_fx[n], NULL, output_frame, 1 ); @@ -611,13 +611,13 @@ ivas_error ivas_mct_dec( hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_float[p] = (float) hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_mem_in_32[p] / ( 1u << q ); } } - if ( !( NE_16( hCPE->hCoreCoder[n]->core, TCX_20_CORE ) && NE_16( hCPE->hCoreCoder[n]->core, TCX_10_CORE ) ) ) - { - for ( int k = 0; k < 111; k++ ) - { - hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] = (float) hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] / ( 1u << q ); - } - } + //if ( !( NE_16( hCPE->hCoreCoder[n]->core, TCX_20_CORE ) && NE_16( hCPE->hCoreCoder[n]->core, TCX_10_CORE ) ) ) + //{ + // for ( int k = 0; k < 111; k++ ) + // { + // hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] = (float) hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] / ( 1u << q ); + // } + //} hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_gain_post_prev_float = (float) hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_gain_post_prev / ONE_IN_Q15; hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_gain_float = (float) hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_gain / ONE_IN_Q15; if ( !( ( hCPE->hCoreCoder[n]->element_mode != IVAS_CPE_DFT && !( st_ivas->sba_dirac_stereo_flag && hCPE->hCoreCoder[n]->element_mode != IVAS_CPE_MDCT ) ) || ( hCPE->hCoreCoder[n]->element_mode == IVAS_CPE_DFT && hCPE->nchan_out == 1 && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF ) ) ) @@ -1111,6 +1111,9 @@ ivas_error ivas_mct_dec_fx( Word32 output_fx_[L_FRAME48k]; mvl2l(output_fx[cpe_id * CPE_CHANNELS + n], output_fx_, L_FRAME48k); Scale_sig32(output_fx_, L_FRAME48k, sub(Q16, Q11)); + Copy_Scale_sig32_16(sts[n]->prev_synth_buffer32_fx, sts[n]->prev_synth_buffer_fx, NS2SA(48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS), -11); + sts[n]->q_prev_synth_buffer_fx = 0; + save_synthesis_hq_fec_fx( sts[n], output_fx_, output_frame, hCPE ); /* CoreCoder common updates */ @@ -2005,13 +2008,6 @@ static ivas_error ivas_mc_dec_reconfig( st_ivas->hCombinedOrientationData->Rmat_fx[0][ind1][ind2] = (Word32) ( st_ivas->hCombinedOrientationData->Rmat[0][ind1][ind2] * ( 1 << 15 ) ); } } - if ( st_ivas->hMasaIsmData ) - { - for ( Word16 ch_idx = 0; ch_idx < st_ivas->hMasaIsmData->delayBuffer_nchan; ch_idx++ ) - { - floatToFixed_arr32( st_ivas->hMasaIsmData->delayBuffer[ch_idx], st_ivas->hMasaIsmData->delayBuffer_fx[ch_idx], Q11, st_ivas->hMasaIsmData->delayBuffer_size ); - } - } if ( st_ivas->hSbaIsmData ) { for ( Word16 ch_idx = 0; ch_idx < st_ivas->hSbaIsmData->delayBuffer_nchan; ch_idx++ ) diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index dccf07af14c42f5e8ba85f765dd9ef034570e078..98019a12e950ae3a3f097562dcb0818c5b37943f 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -184,13 +184,6 @@ ivas_error ivas_omasa_data_open( hMasaIsmData->preprocEneRealized[bin] = 0.0f; } - hMasaIsmData->delayBuffer = NULL; - - for ( ch = 0; ch < MAX_NUM_OBJECTS; ch++ ) - { - hMasaIsmData->q_elevation_old[ch] = 0.0f; - hMasaIsmData->q_azimuth_old[ch] = 0.0f; - } ///////////////////////////////////////////////////////////////////////////////////////////////////////////// st_ivas->hMasaIsmData = hMasaIsmData; @@ -257,18 +250,6 @@ void ivas_omasa_data_close( return; } - // To be removed later ///////////////////////////////////////////////// - IF ( ( *hMasaIsmData )->delayBuffer != NULL ) - { - FOR ( i = 0; i < ( *hMasaIsmData )->delayBuffer_nchan; i++ ) - { - free( ( *hMasaIsmData )->delayBuffer[i] ); - } - free( ( *hMasaIsmData )->delayBuffer ); - ( *hMasaIsmData )->delayBuffer = NULL; - } - ///////////////////////////////////////////////////////////////////////// - IF ( ( *hMasaIsmData )->delayBuffer_fx != NULL ) { FOR ( i = 0; i < ( *hMasaIsmData )->delayBuffer_nchan; i++ ) @@ -1239,30 +1220,7 @@ void ivas_omasa_dirac_rend_jbm( #ifdef IVAS_FLOAT_FIXED Word16 q_output = 31, q_inverse_matrix = 31; Word32 **output_fx, data_separated_objects_fx[4][960]; - FOR(Word16 ind = 0; ind < st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; ind++) - { - FOR(Word16 ind2 = 0; ind2 < 960; ind2++) - { - IF(L_abs((Word32)output_f[ind][ind2])!=0) q_output = s_min(q_output, norm_l((Word32)output_f[ind][ind2])); - IF((ind < st_ivas->nchan_ism) && L_abs((Word32)data_separated_objects[ind][ind2])!=0) q_output = s_min(q_output, norm_l((Word32)data_separated_objects[ind][ind2])); - } - } - /*FOR(Word16 ind1 = 0; ind1 < st_ivas->hDecoderConfig->Opt_tsm; ind1++) - { - FOR(Word16 ind2 = 0; ind2 < *nSamplesRendered; ind2++) - { - IF(L_abs((Word32)st_ivas->hTcBuffer->tc[ind1][ind2])!=0) q_output = s_min(q_output, norm_l((Word32)st_ivas->hTcBuffer->tc[ind1][ind2])); - } - }*/ - FOR(Word16 ind1 = 0; ind1 < st_ivas->hMasaIsmData->delayBuffer_nchan; ind1++) - { - FOR(Word16 ind2 = 0; ind2 < st_ivas->hMasaIsmData->delayBuffer_size; ind2++) - { - IF(L_abs((Word32)st_ivas->hMasaIsmData->delayBuffer[ind1][ind2])!=0)q_output = s_min(q_output, norm_l((Word32)st_ivas->hMasaIsmData->delayBuffer[ind1][ind2])); - } - } - - q_output -= 2; // guard bit + q_output = Q11; FOR(Word16 ind = 0; ind < MAX_NUM_OBJECTS; ind++) { FOR(Word16 ind2 = 0; ind2 < nSamplesAsked; ind2++) @@ -1301,13 +1259,6 @@ void ivas_omasa_dirac_rend_jbm( } } } - FOR(Word16 ind1 = 0; ind1 < st_ivas->hMasaIsmData->delayBuffer_nchan; ind1++) - { - FOR(Word16 ind2 = 0; ind2 < st_ivas->hMasaIsmData->delayBuffer_size; ind2++) - { - st_ivas->hMasaIsmData->delayBuffer_fx[ind1][ind2] = floatToFixed(st_ivas->hMasaIsmData->delayBuffer[ind1][ind2] , q_output); - } - } FOR(Word16 ind1 = 0; ind1 < MAX_CICP_CHANNELS - 1; ind1++) { FOR(Word16 ind2 = 0; ind2 < MAX_OUTPUT_CHANNELS; ind2++) @@ -1317,7 +1268,6 @@ void ivas_omasa_dirac_rend_jbm( } ivas_omasa_separate_object_render_jbm_fx( st_ivas, *nSamplesRendered, data_separated_objects_fx, output_fx, subframes_rendered, slots_rendered ); - //ivas_omasa_separate_object_render_jbm( st_ivas, *nSamplesRendered, data_separated_objects, output_f, subframes_rendered, slots_rendered ); FOR(Word16 ind = 0; ind < st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; ind++) { @@ -1345,14 +1295,6 @@ void ivas_omasa_dirac_rend_jbm( } } } - FOR(Word16 ind1 = 0; ind1 < st_ivas->hMasaIsmData->delayBuffer_nchan; ind1++) - { - FOR(Word16 ind2 = 0; ind2 < st_ivas->hMasaIsmData->delayBuffer_size; ind2++) - { - st_ivas->hMasaIsmData->delayBuffer[ind1][ind2] = fixedToFloat(st_ivas->hMasaIsmData->delayBuffer_fx[ind1][ind2], q_output); - } - } - //dbgwrite2_txt(output_f[1],960,"../omasa_soutput_f.txt"); #else ivas_omasa_separate_object_render_jbm( st_ivas, *nSamplesRendered, data_separated_objects, output_f, subframes_rendered, slots_rendered ); @@ -1401,12 +1343,10 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm( v_multc( tc_local[n], gain, tc_local[n], tcBufferSize ); #ifdef IVAS_FLOAT_FIXED floatToFixed_arr32( st_ivas->hTcBuffer->tc[n + 2], st_ivas->hTcBuffer->tc_fx[n + 2], 11, st_ivas->hSpatParamRendCom->num_slots * st_ivas->hSpatParamRendCom->slot_size ); - floatToFixed_arr32(st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_fx[n], 11, st_ivas->hMasaIsmData->delayBuffer_size); Word32 *tc_local_fx[MAX_TRANSPORT_CHANNELS]; tc_local_fx[n] = st_ivas->hTcBuffer->tc_fx[n + 2]; delay_signal_fx( tc_local_fx[n], tcBufferSize, st_ivas->hMasaIsmData->delayBuffer_fx[n], st_ivas->hMasaIsmData->delayBuffer_size ); fixedToFloat_arrL( st_ivas->hTcBuffer->tc_fx[n + 2], st_ivas->hTcBuffer->tc[n + 2], 11, st_ivas->hSpatParamRendCom->num_slots * st_ivas->hSpatParamRendCom->slot_size ); - fixedToFloat_arrL( st_ivas->hMasaIsmData->delayBuffer_fx[n], st_ivas->hMasaIsmData->delayBuffer[n], 11, st_ivas->hMasaIsmData->delayBuffer_size ); #else delay_signal_float( tc_local[n], tcBufferSize, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); #endif // IVAS_FLOAT_FIXED diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 85871fdd596a21b7d3e44e93cccb12396fb89888..a284b74c45e187707f4af691dc5d2a49c710800a 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -276,13 +276,6 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->hCombinedOrientationData->Rmat_fx[0][ind1][ind2] = (Word32) ( st_ivas->hCombinedOrientationData->Rmat[0][ind1][ind2] * ( 1 << 15 ) ); } } - if ( st_ivas->hMasaIsmData ) - { - for ( Word16 ch_idx = 0; ch_idx < st_ivas->hMasaIsmData->delayBuffer_nchan; ch_idx++ ) - { - floatToFixed_arr32( st_ivas->hMasaIsmData->delayBuffer[ch_idx], st_ivas->hMasaIsmData->delayBuffer_fx[ch_idx], Q11, st_ivas->hMasaIsmData->delayBuffer_size ); - } - } if ( st_ivas->hSbaIsmData ) { for ( Word16 ch_idx = 0; ch_idx < st_ivas->hSbaIsmData->delayBuffer_nchan; ch_idx++ ) diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index b73d9082fb6c1198a68c07ba9dac5740e82fdfc8..f22dd6458a8e078934b67677c2c51a70af060137 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -248,6 +248,35 @@ ivas_error ivas_sce_dec_fx( { output_flt[0][k] = (float) output[0][k] / ONE_IN_Q11; } +#ifndef TO_BE_REMOVED_CONVERSION + //Word16 k; + + //{ + // sts = hCPE->hCoreCoder; + //} + + //core_coding_part will go in this loop, once the things are done + /* for (k = 0; k < n_channels; k++) + {*/ + if (st->hTcxDec != NULL) + { + floatToFixed_arr(st->hHQ_core->old_out, st->hHQ_core->old_out_fx, 0, L_FRAME48k); + floatToFixed_arr(st->hHQ_core->old_outLB, st->hHQ_core->old_out_LB_fx, 0, L_FRAME32k); + floatToFixed_arrL(st->hHQ_core->old_outLB, st->hHQ_core->old_outLB_fx, 11, L_FRAME32k); + //sts[k]->hTcxDec->conceal_eof_gain32 = floatToFixed( sts[k]->hTcxDec->conceal_eof_gain_float, 15 ); + } + /*}*/ + + IF(st->hFdCngDec != NULL && (st->element_mode == IVAS_CPE_MDCT && st->total_brate == SID_2k40)) + { + //FOR(Word16 ch = 0; ch < CPE_CHANNELS; ++ch) + { + f2me_buf(st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, &st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, st->hFdCngDec->hFdCngCom->stopBand - st->hFdCngDec->hFdCngCom->startBand); + floatToFixed_arr(st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, Q14, M + 1); + } + } + +#endif #endif // !IVAS_FLOAT_FIXED_TO_BE_REMOVED IF( ( error = ivas_core_dec( st_ivas, hSCE, NULL, NULL, 1, output_flt, outputHB_flt, NULL, st_ivas->sba_dirac_stereo_flag ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 0db56ddccfb8f8b34be10e5e6bfb3dca155d967f..a312c195baaec9340fe2f76e421ec797d77cce53 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -225,14 +225,16 @@ typedef struct stereo_dft_dec_data_struct float res_hb_nrg_mem; #endif float bpf_error_signal_last; +#ifndef IVAS_FLOAT_FIXED float bpf_error_ratio_mem; +#endif #ifdef IVAS_FLOAT_FIXED Word32 DFT_past_DMX_fx[STEREO_DFT_PAST_MAX][STEREO_DFT32MS_N_32k]; /* Past DMX for residual prediction */ Word32 past_res_pred_gain_fx[STEREO_DFT_PAST_MAX][STEREO_DFT_BAND_MAX]; /* Q31 */ Word32 res_gains_ind_fx[2][2 * STEREO_DFT_BAND_MAX]; /* Q26 */ Word32 res_hb_nrg_mem_fx; /* Q0 */ Word32 bpf_error_signal_last_fx; - Word16 bpf_error_ratio_mem_fx; + Word16 bpf_error_ratio_mem_fx; /* Q13 */ Word16 q_dft; Word16 q_ip_mem; Word16 q_ap_delay_mem_fx; @@ -320,28 +322,33 @@ typedef struct stereo_dft_dec_data_struct int16_t frame_nodata; int16_t frame_sid; +#ifndef IVAS_FLOAT_FIXED float scale; -#ifdef IVAS_FLOAT_FIXED - Word16 scale_fx; +#else + Word16 scale_fx; /* Q15 */ #endif /* 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 sg_mean; +#endif int16_t sg_mem_corrupt; int16_t recovery_flg; float smooth_buf[SBA_DIRAC_STEREO_NUM_BANDS][SBA_DIRAC_NRG_SMOOTH_LONG + 1]; +#ifndef IVAS_FLOAT_FIXED float smooth_fac[NB_DIV][SBA_DIRAC_STEREO_NUM_BANDS]; +#endif #ifdef IVAS_FLOAT_FIXED /* PLC on residual signal */ - Word32 sg_mean_fx; + Word32 sg_mean_fx; /* Q31 */ Word32 res_mem_fx[STEREO_DFT_RES_BW_MAX]; Word32 past_dmx_nrg_fx; 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]; + Word16 smooth_fac_fx[NB_DIV][SBA_DIRAC_STEREO_NUM_BANDS]; /* Q15 */ Word16 q_smooth_buf_fx; Word16 q_hb_nrg; Word16 q_hb_nrg_subr; @@ -349,17 +356,16 @@ typedef struct stereo_dft_dec_data_struct #endif int16_t first_frame; +#ifndef IVAS_FLOAT_FIXED float mixer_mat_smooth[2][4][2 * IVAS_MAX_NUM_BANDS]; -#ifdef IVAS_FLOAT_FIXED - Word32 mixer_mat_smooth_fx[2][4][2 * IVAS_MAX_NUM_BANDS]; -#endif float g_L_prev; float g_R_prev; const float *max_smooth_gains, *min_smooth_gains; -#ifdef IVAS_FLOAT_FIXED - Word32 g_L_prev_fx; - Word32 g_R_prev_fx; - const Word16 *max_smooth_gains_fx, *min_smooth_gains_fx; +#else + Word32 mixer_mat_smooth_fx[2][4][2 * IVAS_MAX_NUM_BANDS]; /* Q31 */ + Word32 g_L_prev_fx; /* Q31 */ + Word32 g_R_prev_fx; /* Q31 */ + const Word16 *max_smooth_gains_fx, *min_smooth_gains_fx; /* Q15 */ #endif } STEREO_DFT_DEC_DATA, *STEREO_DFT_DEC_DATA_HANDLE; @@ -438,7 +444,9 @@ typedef struct stereo_td_dec_data_structure int16_t tdm_lp_reuse_flag; /* Flag that indicate if it is possible to reuse the LP coefficient from the primary channel or not */ int16_t tdm_low_rate_mode; /* secondary channel low rate mode flag */ +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) float tdm_Pri_pitch_buf[NB_SUBFR]; +#endif Word16 tdm_Pri_pitch_buf_fx[NB_SUBFR]; int16_t tdm_Pitch_reuse_flag; int16_t tdm_LRTD_flag; @@ -1262,11 +1270,12 @@ typedef struct ivas_masa_ism_data_structure int16_t elevation_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; float energy_ratio_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR][CLDFB_NO_CHANNELS_MAX]; #ifdef IVAS_FLOAT_FIXED - Word32 energy_ratio_ism_fx[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR][CLDFB_NO_CHANNELS_MAX]; // Q30 + Word32 energy_ratio_ism_fx[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR][CLDFB_NO_CHANNELS_MAX]; /* Q30 */ #endif +#ifndef IVAS_FLOAT_FIXED float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; -#ifdef IVAS_FLOAT_FIXED - Word32 masa_to_total_energy_ratio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; // Q30 +#else + Word32 masa_to_total_energy_ratio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* Q30 */ #endif int16_t azimuth_ism_edited[MAX_NUM_OBJECTS]; int16_t elevation_ism_edited[MAX_NUM_OBJECTS]; @@ -1276,11 +1285,12 @@ typedef struct ivas_masa_ism_data_structure int16_t azimuth_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; int16_t elevation_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; +#ifndef IVAS_FLOAT_FIXED float q_azimuth_old[MAX_NUM_OBJECTS]; float q_elevation_old[MAX_NUM_OBJECTS]; -#ifdef IVAS_FLOAT_FIXED - Word32 q_azimuth_old_fx[MAX_NUM_OBJECTS]; - Word32 q_elevation_old_fx[MAX_NUM_OBJECTS]; +#else + Word32 q_azimuth_old_fx[MAX_NUM_OBJECTS]; /* Q22 */ + Word32 q_elevation_old_fx[MAX_NUM_OBJECTS]; /* Q22 */ #endif float ismPreprocMatrix[2][2][CLDFB_NO_CHANNELS_MAX]; @@ -1290,9 +1300,11 @@ typedef struct ivas_masa_ism_data_structure float preprocEneTarget[CLDFB_NO_CHANNELS_MAX]; float preprocEneRealized[CLDFB_NO_CHANNELS_MAX]; +#ifndef IVAS_FLOAT_FIXED float **delayBuffer; +#endif #ifdef IVAS_FLOAT_FIXED - Word32 **delayBuffer_fx; + Word32 **delayBuffer_fx; /* Q11 */ Word16 ismPreprocMatrix_fx[2][2][CLDFB_NO_CHANNELS_MAX]; Word32 eneMoveIIR_fx[2][CLDFB_NO_CHANNELS_MAX]; Word32 enePreserveIIR_fx[2][CLDFB_NO_CHANNELS_MAX]; diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index f0b562271741d1c0df0cf0c0dc788a01e95ba5cb..9f3b0ba788288340c9535c18ca1a457e965a6334 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -453,19 +453,11 @@ void stereo_dft_dec_open( { hStereoDft->min_smooth_gains_fx = min_smooth_gains2_fx; hStereoDft->max_smooth_gains_fx = max_smooth_gains2_fx; - - /* TODO: remove floating point dependency */ - hStereoDft->min_smooth_gains = min_smooth_gains2; - hStereoDft->max_smooth_gains = max_smooth_gains2; } ELSE { hStereoDft->min_smooth_gains_fx = min_smooth_gains1_fx; hStereoDft->max_smooth_gains_fx = max_smooth_gains1_fx; - - /* TODO: remove floating point dependency */ - hStereoDft->min_smooth_gains = min_smooth_gains1; - hStereoDft->max_smooth_gains = max_smooth_gains1; } hStereoDft->q_hb_stefi_sig_fx = Q31; hStereoDft->q_ap_fade_mem_fx = Q31; @@ -709,13 +701,13 @@ void stereo_dft_dec_reset( hStereoDft->reverb_flag = 0; hStereoDft->bpf_error_signal_last = 0.0f; - hStereoDft->bpf_error_ratio_mem = 1.0f; #ifndef IVAS_FLOAT_FIXED + hStereoDft->bpf_error_ratio_mem = 1.0f; hStereoDft->res_hb_nrg_mem = 0.0f; #else hStereoDft->res_hb_nrg_mem_fx = 0; hStereoDft->bpf_error_signal_last_fx = 0; - hStereoDft->bpf_error_ratio_mem_fx = ONE_IN_Q12; + hStereoDft->bpf_error_ratio_mem_fx = ONE_IN_Q13; #endif // IVAS_FLOAT_FIXED /*reset parameters*/ @@ -795,7 +787,11 @@ void stereo_dft_dec_reset( set_zero( hStereoDft->res_mem, STEREO_DFT_RES_BW_MAX ); hStereoDft->time_offs = 0; hStereoDft->past_dmx_nrg = 0; +#ifdef IVAS_FLOAT_FIXED + hStereoDft->sg_mean_fx = 0; +#else hStereoDft->sg_mean = 0.0f; +#endif hStereoDft->sg_mem_corrupt = 0; hStereoDft->recovery_flg = 0; @@ -803,8 +799,13 @@ void stereo_dft_dec_reset( { set_zero( hStereoDft->smooth_buf[i], SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); } +#ifndef IVAS_FLOAT_FIXED set_zero( hStereoDft->smooth_fac[0], SBA_DIRAC_STEREO_NUM_BANDS ); set_zero( hStereoDft->smooth_fac[1], SBA_DIRAC_STEREO_NUM_BANDS ); +#else + set16_fx( hStereoDft->smooth_fac_fx[0], 0, SBA_DIRAC_STEREO_NUM_BANDS ); + set16_fx( hStereoDft->smooth_fac_fx[1], 0, SBA_DIRAC_STEREO_NUM_BANDS ); +#endif #ifdef IVAS_FLOAT_FIXED hStereoDft->itd_xfade_target_fx = 0; @@ -834,6 +835,18 @@ void stereo_dft_dec_reset( hStereoDft->ipd_xfade_prev = 0.0f; #endif +#ifdef IVAS_FLOAT_FIXED + FOR( b = 0; b < hStereoDft->nbands; b++ ) + { + FOR( i = 0; i < 2; i++ ) + { + FOR( j = 0; j < 4; j++ ) + { + hStereoDft->mixer_mat_smooth_fx[i][j][b] = 0; + } + } + } +#else for ( b = 0; b < hStereoDft->nbands; b++ ) { for ( i = 0; i < 2; i++ ) @@ -844,9 +857,15 @@ void stereo_dft_dec_reset( } } } +#endif hStereoDft->first_frame = 1; +#ifdef IVAS_FLOAT_FIXED + hStereoDft->g_L_prev_fx = 0; + hStereoDft->g_R_prev_fx = 0; +#else hStereoDft->g_L_prev = 0.f; hStereoDft->g_R_prev = 0.f; +#endif #ifdef IVAS_FLOAT_FIXED set_val_Word32( hStereoDft->ap_delay_mem_fx, 0, NS2SA( 16000, 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 d8090097287bba4649ca51402e96b13b374b24e1..72c52a0d70126b91ef75cb6b5edd69fa9b5b64eb 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -150,7 +150,7 @@ void stereo_dft_dec_reset_fx( move32(); hStereoDft->bpf_error_signal_last_fx = 0; move32(); - hStereoDft->bpf_error_ratio_mem_fx = ONE_IN_Q12; + hStereoDft->bpf_error_ratio_mem_fx = ONE_IN_Q13; move16(); /*reset parameters*/ @@ -208,8 +208,8 @@ void stereo_dft_dec_reset_fx( { set_val_Word32( hStereoDft->smooth_buf_fx[i], 0, SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); } - set_val_Word16( &hStereoDft->smooth_fac_fx[0][0], 0, SBA_DIRAC_STEREO_NUM_BANDS ); - set_zero( hStereoDft->smooth_fac[1], SBA_DIRAC_STEREO_NUM_BANDS ); + set_val_Word16( hStereoDft->smooth_fac_fx[0], 0, SBA_DIRAC_STEREO_NUM_BANDS ); + set_val_Word16( hStereoDft->smooth_fac_fx[1], 0, SBA_DIRAC_STEREO_NUM_BANDS ); hStereoDft->itd_xfade_target_fx = 0; move32(); hStereoDft->itd_xfade_step_fx = 0; move32(); diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 0178161545b0245cb1ae8a200ff7e8cbad3555fc..781800cfd06b63fd3077670f45da8ae55d2aa05a 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -1719,6 +1719,7 @@ ivas_error stereo_memory_dec_fx( } set16_fx(st->hTcxDec->FBTCXdelayBuf, 0, 111); + set32_fx(st->hTcxDec->FBTCXdelayBuf_32, 0, 111); st->hTcxDec->old_synthFB_fx = st->hTcxDec->synth_history_fx + NS2SA(st->output_Fs, PH_ECU_MEM_NS); st->hTcxDec->prev_good_synth_fx = st->hTcxDec->old_synthFB_fx + NS2SA(st->output_Fs, PH_ECU_LOOKAHEAD_NS); @@ -2171,10 +2172,10 @@ void synchro_synthesis( hCPE->hStereoDft->hTcxLtpDec->tcxltp_gain = (Word16) ( hCPE->hStereoDft->hTcxLtpDec->tcxltp_gain_float * ONE_IN_Q15 ); } hCPE->hCoreCoder[0]->hTcxLtpDec->tcxltp_gain = (Word16) ( hCPE->hCoreCoder[0]->hTcxLtpDec->tcxltp_gain_float * ONE_IN_Q15 ); - for ( int p = 0; p < 111; p++ ) - { - hCPE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf_32[p] = (Word32) ( hCPE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf_float[p] * ( 1u << q ) ); - } + //for ( int p = 0; p < 111; p++ ) + //{ + // hCPE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf_32[p] = (Word32) ( hCPE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf_float[p] * ( 1u << q ) ); + //} ivas_post_proc_fx( NULL, hCPE, 0, output_fx[0], output_fx, output_frame, sba_dirac_stereo_flag ); @@ -2425,10 +2426,10 @@ void synchro_synthesis( } } hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_gain = (Word16) ( hCPE->hCoreCoder[n]->hTcxLtpDec->tcxltp_gain_float * ONE_IN_Q15 ); - for ( int p = 0; p < 111; p++ ) - { - hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[p] = (Word32) ( hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[p] * ( 1u << q ) ); - } + //for ( int p = 0; p < 111; p++ ) + //{ + // hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[p] = (Word32) ( hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[p] * ( 1u << q ) ); + //} ivas_post_proc_fx( NULL, hCPE, n, output_fx[n], output_fx, output_frame, 0 ); @@ -3032,10 +3033,10 @@ void synchro_synthesis_fx( 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++ ) - { - hCPE->hCoreCoder[n]->prev_synth_buffer[k] = (float) hCPE->hCoreCoder[n]->prev_synth_buffer32_fx[k] / ( 1 << output_q ); - } + //FOR( Word32 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 << output_q ); + //} //FOR( Word32 k = 0; k < HQ_DELTA_MAX * HQ_DELAY_COMP; k++ ) //{ // hCPE->hCoreCoder[n]->delay_buf_out[k] = (float) hCPE->hCoreCoder[n]->delay_buf_out32_fx[k] / ( 1 << output_q ); @@ -3044,7 +3045,7 @@ void synchro_synthesis_fx( { FOR( Word32 k = 0; k < 111; k++ ) { - hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] = (float) hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] / ( 1 << output_q ); + //hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_float[k] = (float) hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32[k] / ( 1 << output_q ); } } } @@ -3187,10 +3188,12 @@ void stereo_switching_dec( } FOR( i = 0; i < delay_comp_TD; i++ ) { - Word64 temp_result = (Word64) hCPE->hCoreCoder[1]->prev_synth_buffer_fx[i] * tmpF_fx; + Word64 temp_result; // 16bit buffer - hCPE->hCoreCoder[1]->prev_synth_buffer_fx[i] = saturate( W_extract_l(W_shr( temp_result, 27 )) ); + //temp_result = (Word64) hCPE->hCoreCoder[1]->prev_synth_buffer_fx[i] * tmpF_fx; + //hCPE->hCoreCoder[1]->prev_synth_buffer_fx[i] = saturate( W_extract_l(W_shr( temp_result, 27 )) ); // 32bit buffer + temp_result = (Word64) hCPE->hCoreCoder[1]->prev_synth_buffer32_fx[i] * tmpF_fx; hCPE->hCoreCoder[1]->prev_synth_buffer32_fx[i] = W_sat_l( W_shr( temp_result, 27 ) ); } FOR( i = 0; i < L_DEC_MEM_LEN_ICA; i++ ) @@ -3404,7 +3407,10 @@ void stereo_switching_dec( sts[1]->pit_res_max = sts[0]->pit_res_max; sts[1]->pit_res_max_past = sts[0]->pit_res_max_past; sts[1]->hTcxDec->L_frameTCX = sts[0]->hTcxDec->L_frameTCX; +#if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) sts[1]->hTcxDec->conceal_eof_gain_float = sts[0]->hTcxDec->conceal_eof_gain_float; +#endif + sts[1]->hTcxDec->conceal_eof_gain = sts[0]->hTcxDec->conceal_eof_gain; } return; diff --git a/lib_dec/ivas_stereo_td_dec.c b/lib_dec/ivas_stereo_td_dec.c index f3c3c4ee4ab95c557dbf2d6da91f6ae86ee85eab..7af9d7b22d39c467551a5c4306890dc76329d681 100644 --- a/lib_dec/ivas_stereo_td_dec.c +++ b/lib_dec/ivas_stereo_td_dec.c @@ -269,7 +269,7 @@ void tdm_configure_dec( } hCPE->hStereoDftDmx->targetGain_fx = power_table[tmpS]; #ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED - hCPE->hStereoDftDmx->targetGain = fixedToFloat(hCPE->hStereoDftDmx->targetGain_fx, 29 ); + //hCPE->hStereoDftDmx->targetGain = fixedToFloat(hCPE->hStereoDftDmx->targetGain_fx, 29 ); #endif } ELSE diff --git a/lib_dec/ivas_td_low_rate_dec.c b/lib_dec/ivas_td_low_rate_dec.c index f32863d6739146179400f0cb1b781c5cdfe6c3db..17ece8eb856e10eb604e118aa1a12b74a90c31ee 100644 --- a/lib_dec/ivas_td_low_rate_dec.c +++ b/lib_dec/ivas_td_low_rate_dec.c @@ -372,7 +372,6 @@ void decod_gen_2sbfr( const float tdm_Pri_pitch_buf[] /* i : pitch values for primary channel */ ) { -#ifndef IVAS_FLOAT_FIXED int16_t T0, T0_frac, T0_min, T0_max; /* integer pitch variables */ float gain_pit = 0.0f; /* pitch gain */ float gain_code = 0.0f; /* gain/normalized gain of the algebraic excitation */ @@ -488,59 +487,6 @@ void decod_gen_2sbfr( st->prev_gain_pit_dec = gain_pit; return; -#else - st->Q_exc = 0; - - /*hGSCDec float2fix*/ - st->GSC_noisy_speech = st->GSC_noisy_speech; - //st->lp_gainc_fx = float_to_fix16( st->lp_gainc, Q3 ); - st->dm_fx.prev_state = float_to_fix16(st->dispMem[0], 0); - st->dm_fx.prev_gain_code = floatToFixed(st->dispMem[1], Q16); - floatToFixed_arr(&(st->dispMem[2]), st->dm_fx.prev_gain_pit, Q14, 6); - st->last_good = st->last_good; - st->Last_GSC_noisy_speech_flag = st->Last_GSC_noisy_speech_flag; - st->last_coder_type = st->last_coder_type; - /*hGSCDec end*/ - - Word16 Aq_fx[NB_SUBFR16k * (M + 1)]; - Word16 pitch_buf_fx[NB_SUBFR16k]; - Word16 voice_factors_fx[5]; - Word16 old_exc_fx[L_EXC_DEC], *exc_fx; - Word16 old_exc2_fx[L_FRAME16k + L_EXC_MEM], *exc2_fx; - Word16 bwe_exc_fx[L_FRAME32k], * p_bwe_exc_fx; - Word16 gain_buf_fx[NB_SUBFR16k]; - Word16 tdm_Pri_pitch_buf_fx[NB_SUBFR]; - floatToFixed_arr((Float32 *)Aq, Aq_fx, Q12, NB_SUBFR16k * (M + 1)); - floatToFixed_arr((Float32 *)tdm_Pri_pitch_buf, tdm_Pri_pitch_buf_fx, Q6, NB_SUBFR); - floatToFixed_arr(exc - L_EXC_MEM_DEC, old_exc_fx, st->Q_exc, L_EXC_DEC); - exc_fx = old_exc_fx + L_EXC_MEM_DEC; - exc2_fx = old_exc2_fx + L_EXC_MEM; - floatToFixed_arr(gain_buf, gain_buf_fx, Q14, NB_SUBFR16k); - if (bwe_exc) { - set_s(bwe_exc_fx, 0, L_FRAME32k); - p_bwe_exc_fx = bwe_exc_fx; - } - else { - p_bwe_exc_fx = NULL; - } - decod_gen_2sbfr_ivas_fx( st, sharpFlag, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, p_bwe_exc_fx, gain_buf_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx); - fixedToFloat_arr( pitch_buf_fx, pitch_buf, Q6, NB_SUBFR16k ); - fixedToFloat_arr( voice_factors_fx, voice_factors, Q15, 5 ); - fixedToFloat_arr( exc_fx, exc, st->Q_exc, L_FRAME ); - fixedToFloat_arr( exc2_fx, exc2, st->Q_exc, L_FRAME ); - fixedToFloat_arr(gain_buf_fx, gain_buf, Q14, NB_SUBFR16k); - if (bwe_exc) { - fixedToFloat_arr(p_bwe_exc_fx, bwe_exc, st->Q_exc, L_FRAME32k); - } - - /*hGSCDec fix2float*/ - st->GSC_noisy_speech = st->GSC_noisy_speech; - //st->lp_gainc = fixedToFloat( st->lp_gainc_fx, Q3 ); - st->dispMem[0] = fixedToFloat(st->dm_fx.prev_state, 0); - st->dispMem[1] = fixedToFloat(st->dm_fx.prev_gain_code, Q16); - fixedToFloat_arr(st->dm_fx.prev_gain_pit, &(st->dispMem[2]), Q14, 6); -/*hGSCDec end*/ -#endif } #endif #ifdef IVAS_FLOAT_FIXED diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index f29b6e5735b79d440adcd73623165f69cf9379f5..1b3a8c897c3bf75a10a65cffa92aa3b7b1a5c1da 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -735,13 +735,13 @@ typedef struct tcx_dec_structure Word16 conLastFrameLevel, conLastFrameLevel_e;/*Q15*/ #if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) float old_gaintcx_bfi_float; + float conceal_eof_gain_float; #endif Word16 old_gaintcx_bfi, old_gaintcx_bfi_e; - float conceal_eof_gain_float; Word16 conceal_eof_gain; /*Q14*/ #ifdef IVAS_FLOAT_FIXED - Word32 conceal_eof_gain32; /*have been created for further calculation */ + //Word32 conceal_eof_gain32; /*have been created for further calculation */ #endif #if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) float damping_float; @@ -2452,10 +2452,10 @@ typedef struct Decoder_State float mem_preemp_preQ; /* ACELP@16kHz - prequantizer preemhasis memory */ float psf_lp_noise; /* NB post-filter - long-term noise */ float last_voice_factor; + float prev_synth_buffer[NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS )]; #endif // #if (defined EVS_FLOAT) || !(defined IVAS_FLOAT_FIXED) Word16 last_voice_factor_fx; /* Q6*/ - float prev_synth_buffer[NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS )]; int16_t old_bfi_cnt; /* HQ core - # of bfi until previous frame(for FEC) */ diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 5d2c2e3cef88ae694c986fab1b84791e8805b2aa..11033bef8369cb41c30e8ff82712b74910365ae5 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -2858,6 +2858,765 @@ void protoSignalComputation1( return; } +#ifdef IVAS_FLOAT_FIXED +/*------------------------------------------------------------------------- + * protoSignalComputation2_fx() + * + * + *-------------------------------------------------------------------------*/ + +void protoSignalComputation2_fx( + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], + Word32 *proto_frame_f_fx, + Word16 *q_proto_frame_f, + Word32 *proto_direct_buffer_f_fx, + Word16 *q_proto_direct_buffer_f, + Word32 *reference_power_fx, + Word16 *q_reference_power, + Word32 *proto_power_smooth_fx, + Word16 *q_proto_power_smooth, + const Word16 isloudspeaker, + const Word16 slot_index, + const Word16 num_freq_bands, + MASA_STEREO_TYPE_DETECT *stereo_type_detect, + Word16 q_cldfb ) +{ + Word16 l; + Word16 dipole_freq_range[2]; + Word32 *p_proto_buffer_fx; + Word32 Real_aux_fx, Imag_aux_fx, re_aux, im_aux; + Word32 re1, im1, re2, im2; + Word32 RealSubtract_fx, ImagSubtract_fx; + Word32 left_bb_power_fx, right_bb_power_fx, total_bb_power_fx, lr_bb_power_fx; + Word32 left_hi_power_fx, right_hi_power_fx, total_hi_power_fx, lr_hi_power_fx; + Word32 sum_power_fx, Left_power_fx, Right_power_fx; + Word16 q_lr_bb_power, q_lr_hi_power; + Word32 lr_total_bb_ratio_fx, lr_total_hi_ratio_fx; + Word32 min_sum_total_ratio_fx, min_sum_total_ratio_db_fx; + Word32 sum_total_ratio_fx[MASA_SUM_FREQ_RANGE_BINS]; + Word16 q_sum_total_ratio; + Word32 a_fx, b_fx, a2_fx, b2_fx; + Word16 interpolatorSpaced_fx, interpolatorDmx_fx; + Word32 tempSpaced_fx, tempDmx_fx; + Word16 q_shift, min_q_shift, exp, q_temp, temp_q_shift, q_temp2; + Word32 temp; + + /* Calculate maximum possible shift for the buffers RealBuffer_fx and ImagBuffer_fx */ + min_q_shift = Q31; + move16(); + temp_q_shift = Q31; + move16(); + q_sum_total_ratio = Q31; + move16(); + exp = 0; + move16(); + interpolatorSpaced_fx = 0; + move16(); + interpolatorDmx_fx = MAX16B; + move16(); + + /* Calculate the max shift possible for the buffers RealBuffer_fx and ImagBuffer_fx */ + FOR( l = 0; l < 2; l++ ) + { + q_shift = s_min( L_norm_arr( RealBuffer_fx[l][0], num_freq_bands ), L_norm_arr( ImagBuffer_fx[l][0], num_freq_bands ) ); + min_q_shift = s_min( min_q_shift, q_shift ); + + q_shift = s_min( L_norm_arr( RealBuffer_fx[l][0], MASA_SUM_FREQ_RANGE_BINS ), L_norm_arr( ImagBuffer_fx[l][0], MASA_SUM_FREQ_RANGE_BINS ) ); + temp_q_shift = s_min( temp_q_shift, q_shift ); + } + + min_q_shift = sub( min_q_shift, 2 ); // guard bits + temp_q_shift = sub( temp_q_shift, 2 ); // guard bits + + /* Upscaling of the buffer proto_power_smooth_fx */ + IF( isloudspeaker ) + { + q_shift = getScaleFactor32( proto_power_smooth_fx, i_mult( 3, num_freq_bands ) ); + scale_sig32( proto_power_smooth_fx, i_mult( 3, num_freq_bands ), sub( q_shift, 1 ) ); + } + ELSE + { + q_shift = getScaleFactor32( proto_power_smooth_fx, i_mult( 2, num_freq_bands ) ); + scale_sig32( proto_power_smooth_fx, i_mult( 2, num_freq_bands ), sub( q_shift, 1 ) ); + } + *q_proto_power_smooth = add( *q_proto_power_smooth, sub( q_shift, 1 ) ); + + IF( isloudspeaker ) + { + p_proto_buffer_fx = proto_direct_buffer_f_fx + i_mult( i_mult( i_mult( slot_index, 2 ), num_freq_bands ), 3 ); + + q_temp = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); + move16(); + + FOR( l = 0; l < num_freq_bands; l++ ) + { + re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); + im1 = L_shl( ImagBuffer_fx[0][0][l], min_q_shift ); + re2 = L_shl( RealBuffer_fx[1][0][l], min_q_shift ); + im2 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift ); + + Real_aux_fx = L_add( re1, re2 ); + Imag_aux_fx = L_add( im1, im2 ); + + Left_power_fx = Madd_32_32( Mpy_32_32( re1, re1 ), im1, im1 ); + Right_power_fx = Madd_32_32( Mpy_32_32( re2, re2 ), im2, im2 ); + + reference_power_fx[l] = L_add( Left_power_fx, Right_power_fx ); + move32(); + + temp = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); + + IF( LT_16( q_temp, *q_proto_power_smooth ) ) + { + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); + move32(); + } + ELSE + { + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + move32(); + } + + p_proto_buffer_fx[i_mult( 2, l )] = Real_aux_fx; + move32(); + p_proto_buffer_fx[add( i_mult( 2, l ), 1 )] = Imag_aux_fx; + move32(); + + temp = Madd_32_32( Mpy_32_32( re1, re1 ), im1, im1 ); + + IF( LT_16( q_temp, *q_proto_power_smooth ) ) + { + proto_power_smooth_fx[add( l, num_freq_bands )] = L_add( L_shr( proto_power_smooth_fx[add( l, num_freq_bands )], sub( *q_proto_power_smooth, q_temp ) ), temp ); + move32(); + } + ELSE + { + proto_power_smooth_fx[add( l, num_freq_bands )] = L_add( proto_power_smooth_fx[add( l, num_freq_bands )], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + move32(); + } + + p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = re1; + move32(); + p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = im1; + move32(); + + temp = Madd_32_32( Mpy_32_32( re2, re2 ), im2, im2 ); + IF( LT_16( q_temp, *q_proto_power_smooth ) ) + { + proto_power_smooth_fx[add( l, i_mult( 2, num_freq_bands ) )] = L_add( L_shr( proto_power_smooth_fx[add( l, i_mult( 2, num_freq_bands ) )], sub( *q_proto_power_smooth, q_temp ) ), temp ); + move32(); + } + ELSE + { + proto_power_smooth_fx[add( l, i_mult( 2, num_freq_bands ) )] = L_add( proto_power_smooth_fx[add( l, i_mult( 2, num_freq_bands ) )], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + move32(); + } + + p_proto_buffer_fx[add( i_mult( 4, num_freq_bands ), i_mult( 2, l ) )] = re2; + move32(); + p_proto_buffer_fx[add( add( i_mult( 4, num_freq_bands ), i_mult( 2, l ) ), 1 )] = im2; + move32(); + + proto_frame_f_fx[i_mult( 2, l )] = Real_aux_fx; + move32(); + proto_frame_f_fx[add( i_mult( 2, l ), 1 )] = Imag_aux_fx; + move32(); + + proto_frame_f_fx[add( i_mult( 2, num_freq_bands ), i_mult( 2, l ) )] = re1; + move32(); + proto_frame_f_fx[add( add( i_mult( 2, num_freq_bands ), i_mult( 2, l ) ), 1 )] = im1; + move32(); + proto_frame_f_fx[add( i_mult( 4, num_freq_bands ), i_mult( 2, l ) )] = re2; + move32(); + proto_frame_f_fx[add( add( i_mult( 4, num_freq_bands ), i_mult( 2, l ) ), 1 )] = im2; + move32(); + } + } + ELSE IF( stereo_type_detect != NULL ) + { + p_proto_buffer_fx = proto_direct_buffer_f_fx + i_mult( i_mult( i_mult( slot_index, 2 ), num_freq_bands ), 2 ); + + left_bb_power_fx = 0; + right_bb_power_fx = 0; + total_bb_power_fx = 0; + + left_hi_power_fx = 0; + right_hi_power_fx = 0; + total_hi_power_fx = 0; + + dipole_freq_range[0] = stereo_type_detect->dipole_freq_range[0]; + dipole_freq_range[1] = stereo_type_detect->dipole_freq_range[1]; + + a_fx = 21474836; /*0.01 in Q31*/ /* Temporal smoothing coefficient */ + move32(); + b_fx = L_sub( ONE_IN_Q31, a_fx ); /* Temporal smoothing coefficient */ + a2_fx = 214748365; /*0.1 in Q31*/ /* Temporal smoothing coefficient */ + move32(); + b2_fx = L_sub( ONE_IN_Q31, a2_fx ); /* Temporal smoothing coefficient */ + + IF( GT_16( stereo_type_detect->interpolator, 0 ) ) + { + IF( EQ_16( stereo_type_detect->type_change_direction, MASA_STEREO_SPACED_MICS ) ) + { + interpolatorSpaced_fx = BASOP_Util_Divide1616_Scale( stereo_type_detect->interpolator, MASA_STEREO_INTERPOLATION_SLOTS, &exp ); + interpolatorSpaced_fx = shl( interpolatorSpaced_fx, exp ); // Q15 + interpolatorDmx_fx = sub( MAX16B, interpolatorSpaced_fx ); // Q15 + } + ELSE + { + interpolatorDmx_fx = BASOP_Util_Divide1616_Scale( stereo_type_detect->interpolator, MASA_STEREO_INTERPOLATION_SLOTS, &exp ); + interpolatorDmx_fx = shl( interpolatorDmx_fx, exp ); // Q15 + interpolatorSpaced_fx = sub( MAX16B, interpolatorDmx_fx ); // Q15 + } + } + + min_q_shift = sub( min_q_shift, idiv1616( find_guarded_bits_fx( num_freq_bands ), 2 ) ); + + q_temp = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); + move16(); + q_temp2 = sub( add( add( q_cldfb, temp_q_shift ), add( q_cldfb, temp_q_shift ) ), 31 ); + move16(); + + FOR( l = 0; l < num_freq_bands; l++ ) + { + re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); + im1 = L_shl( ImagBuffer_fx[0][0][l], min_q_shift ); + re2 = L_shl( RealBuffer_fx[1][0][l], min_q_shift ); + im2 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift ); + + /* Compute sum signal */ + Real_aux_fx = L_add( re1, re2 ); + Imag_aux_fx = L_add( im1, im2 ); + + /* Compute reference power */ + Left_power_fx = Madd_32_32( Mpy_32_32( re1, re1 ), im1, im1 ); + Right_power_fx = Madd_32_32( Mpy_32_32( re2, re2 ), im2, im2 ); + + reference_power_fx[l] = L_add( Left_power_fx, Right_power_fx ); + move32(); + + left_bb_power_fx = L_add( left_bb_power_fx, Left_power_fx ); + right_bb_power_fx = L_add( right_bb_power_fx, Right_power_fx ); + total_bb_power_fx = L_add( total_bb_power_fx, reference_power_fx[l] ); + + IF( GT_16( l, MASA_HI_FREQ_START_BIN ) ) + { + left_hi_power_fx = L_add( left_hi_power_fx, Left_power_fx ); + right_hi_power_fx = L_add( right_hi_power_fx, Right_power_fx ); + total_hi_power_fx = L_add( total_hi_power_fx, reference_power_fx[l] ); + } + + IF( LT_16( l, s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ) ) ) + { + re_aux = L_shl( Real_aux_fx, sub( temp_q_shift, min_q_shift ) ); + im_aux = L_shl( Imag_aux_fx, sub( temp_q_shift, min_q_shift ) ); + + sum_power_fx = Madd_32_32( Mpy_32_32( re_aux, re_aux ), im_aux, im_aux ); + temp = Mpy_32_32( a_fx, sum_power_fx ); + + IF( LT_16( q_temp2, stereo_type_detect->q_sum_power ) ) + { + stereo_type_detect->sum_power_fx[l] = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->sum_power_fx[l] ), sub( stereo_type_detect->q_sum_power, q_temp2 ) ) ); + move32(); + } + ELSE + { + stereo_type_detect->sum_power_fx[l] = L_add( L_shr( temp, sub( q_temp2, stereo_type_detect->q_sum_power ) ), Mpy_32_32( b_fx, stereo_type_detect->sum_power_fx[l] ) ); + move32(); + } + + temp = Mpy_32_32( a_fx, reference_power_fx[l] ); + IF( LT_16( q_temp, stereo_type_detect->q_total_power ) ) + { + stereo_type_detect->total_power_fx[l] = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->total_power_fx[l] ), sub( stereo_type_detect->q_total_power, q_temp ) ) ); + move32(); + } + ELSE + { + stereo_type_detect->total_power_fx[l] = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_total_power ) ), Mpy_32_32( b_fx, stereo_type_detect->total_power_fx[l] ) ); + move32(); + } + + sum_total_ratio_fx[l] = BASOP_Util_Divide3232_Scale( stereo_type_detect->sum_power_fx[l], L_add( stereo_type_detect->total_power_fx[l], EPSILON_FX ), &exp ); + move32(); + q_sum_total_ratio = add( sub( 15, exp ), sub( s_min( stereo_type_detect->q_sum_power, q_temp2 ), s_min( stereo_type_detect->q_total_power, q_temp ) ) ); + sum_total_ratio_fx[l] = L_shl( sum_total_ratio_fx[l], sub( Q15, q_sum_total_ratio ) ); + move32(); + } + + IF( EQ_16( l, 0 ) ) + { + RealSubtract_fx = L_sub( re1, re2 ); + ImagSubtract_fx = L_sub( im1, im2 ); + + temp = Madd_32_32( Mpy_32_32( RealSubtract_fx, RealSubtract_fx ), ImagSubtract_fx, ImagSubtract_fx ); + IF( LT_16( q_temp, stereo_type_detect->q_subtract_power_y ) ) + { + stereo_type_detect->subtract_power_y_fx = L_add( L_shr( stereo_type_detect->subtract_power_y_fx, sub( stereo_type_detect->q_subtract_power_y, q_temp ) ), temp ); + stereo_type_detect->q_subtract_power_y = q_temp; + move16(); + } + ELSE + { + stereo_type_detect->subtract_power_y_fx = L_add( stereo_type_detect->subtract_power_y_fx, L_shr( temp, sub( q_temp, stereo_type_detect->q_subtract_power_y ) ) ); + } + } + + /* Compute protos (and their power) for direct sound rendering */ + + /* W prototype */ + IF( GT_16( stereo_type_detect->interpolator, 0 ) ) + { + IF( L_or( LT_16( l, sub( dipole_freq_range[1], 1 ) ), GE_16( l, MASA_SUM_PROTO_START_BIN ) ) ) + { + Real_aux_fx = Madd_32_16( Mpy_32_16_1( Real_aux_fx, shr( interpolatorSpaced_fx, 1 ) ), Real_aux_fx, interpolatorDmx_fx ); + Imag_aux_fx = Madd_32_16( Mpy_32_16_1( Imag_aux_fx, shr( interpolatorSpaced_fx, 1 ) ), Imag_aux_fx, interpolatorDmx_fx ); + + temp = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); + IF( LT_16( q_temp, *q_proto_power_smooth ) ) + { + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); + move32(); + } + ELSE + { + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + move32(); + } + + p_proto_buffer_fx[i_mult( 2, l )] = Real_aux_fx; + move32(); + p_proto_buffer_fx[add( i_mult( 2, l ), 1 )] = Imag_aux_fx; + move32(); + } + ELSE + { + tempSpaced_fx = Madd_32_32( Mpy_32_32( re1, re1 ), im1, im1 ); + tempDmx_fx = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); + + temp = Madd_32_16( Mpy_32_16_1( tempSpaced_fx, interpolatorSpaced_fx ), tempDmx_fx, interpolatorDmx_fx ); + IF( LT_16( q_temp, *q_proto_power_smooth ) ) + { + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); + move32(); + } + ELSE + { + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + move32(); + } + + p_proto_buffer_fx[i_mult( 2, l )] = Madd_32_16( Mpy_32_16_1( re1, interpolatorSpaced_fx ), Real_aux_fx, interpolatorDmx_fx ); + move32(); + p_proto_buffer_fx[add( i_mult( 2, l ), 1 )] = Madd_32_16( Mpy_32_16_1( im1, interpolatorSpaced_fx ), Imag_aux_fx, interpolatorDmx_fx ); + move32(); + } + } + ELSE IF( EQ_16( stereo_type_detect->masa_stereo_type, MASA_STEREO_SPACED_MICS ) ) + { + IF( L_or( LT_16( l, sub( dipole_freq_range[1], 1 ) ), GE_16( l, MASA_SUM_PROTO_START_BIN ) ) ) + { + Real_aux_fx = L_shr( Real_aux_fx, 1 ); + Imag_aux_fx = L_shr( Imag_aux_fx, 1 ); + + temp = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); + IF( LT_16( q_temp, *q_proto_power_smooth ) ) + { + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); + move32(); + } + ELSE + { + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + move32(); + } + + p_proto_buffer_fx[i_mult( 2, l )] = Real_aux_fx; + move32(); + p_proto_buffer_fx[add( i_mult( 2, l ), 1 )] = Imag_aux_fx; + move32(); + } + ELSE + { + temp = Madd_32_32( Mpy_32_32( re1, re1 ), im1, im1 ); + IF( LT_16( q_temp, *q_proto_power_smooth ) ) + { + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); + move32(); + } + ELSE + { + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + move32(); + } + + p_proto_buffer_fx[i_mult( 2, l )] = re1; + move32(); + p_proto_buffer_fx[add( i_mult( 2, l ), 1 )] = im1; + move32(); + } + } + ELSE + { + temp = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); + IF( LT_16( q_temp, *q_proto_power_smooth ) ) + { + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); + move32(); + } + ELSE + { + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + move32(); + } + + p_proto_buffer_fx[i_mult( 2, l )] = Real_aux_fx; + move32(); + p_proto_buffer_fx[add( i_mult( 2, l ), 1 )] = Imag_aux_fx; + move32(); + } + + /* Y prototype */ + IF( GT_16( stereo_type_detect->interpolator, 0 ) ) + { + IF( LT_16( l, dipole_freq_range[0] ) ) + { + p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = Madd_32_16( Mpy_32_16_1( p_proto_buffer_fx[i_mult( 2, l )], interpolatorSpaced_fx ), L_sub( re1, re2 ), interpolatorDmx_fx ); + move32(); + p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = Madd_32_16( Mpy_32_16_1( p_proto_buffer_fx[add( i_mult( 2, l ), 1 )], interpolatorSpaced_fx ), L_sub( im1, im2 ), interpolatorDmx_fx ); + move32(); + } + ELSE IF( LT_16( l, dipole_freq_range[1] ) ) + { + p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = Madd_32_16( Mpy_32_16_1( L_sub( im1, im2 ), interpolatorSpaced_fx ), L_sub( re1, re2 ), interpolatorDmx_fx ); + move32(); + p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = Madd_32_16( Mpy_32_16_1( -L_sub( re1, re2 ), interpolatorSpaced_fx ), L_sub( im1, im2 ), interpolatorDmx_fx ); + move32(); + } + ELSE + { + p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = Madd_32_16( Mpy_32_16_1( p_proto_buffer_fx[i_mult( 2, l )], interpolatorSpaced_fx ), L_sub( re1, re2 ), interpolatorDmx_fx ); + move32(); + p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = Madd_32_16( Mpy_32_16_1( p_proto_buffer_fx[add( i_mult( 2, l ), 1 )], interpolatorSpaced_fx ), L_sub( im1, im2 ), interpolatorDmx_fx ); + move32(); + } + + temp = Madd_32_32( Mpy_32_32( p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )], p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] ), p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )], p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] ); + IF( LT_16( q_temp, *q_proto_power_smooth ) ) + { + proto_power_smooth_fx[add( l, num_freq_bands )] = L_add( L_shr( proto_power_smooth_fx[add( l, num_freq_bands )], sub( *q_proto_power_smooth, q_temp ) ), temp ); + move32(); + } + ELSE + { + proto_power_smooth_fx[add( l, num_freq_bands )] = L_add( proto_power_smooth_fx[add( l, num_freq_bands )], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + move32(); + } + } + ELSE IF( EQ_16( stereo_type_detect->masa_stereo_type, MASA_STEREO_SPACED_MICS ) ) + { + IF( LT_16( l, dipole_freq_range[0] ) ) /* proto = W */ + { + p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = p_proto_buffer_fx[i_mult( 2, l )]; + move32(); + p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = p_proto_buffer_fx[add( i_mult( 2, l ), 1 )]; + move32(); + proto_power_smooth_fx[add( l, num_freq_bands )] = proto_power_smooth_fx[l]; + move32(); + } + ELSE IF( LT_16( l, dipole_freq_range[1] ) ) /* proto = -i * (x1-x2) * eq */ + { + p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = L_sub( im1, im2 ); + move32(); + p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = -L_sub( re1, re2 ); + move32(); + + temp = Madd_32_32( Mpy_32_32( p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )], p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] ), p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )], p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] ); + IF( LT_16( q_temp, *q_proto_power_smooth ) ) + { + proto_power_smooth_fx[add( l, num_freq_bands )] = L_add( L_shr( proto_power_smooth_fx[add( l, num_freq_bands )], sub( *q_proto_power_smooth, q_temp ) ), temp ); + move32(); + } + ELSE + { + proto_power_smooth_fx[add( l, num_freq_bands )] = L_add( proto_power_smooth_fx[add( l, num_freq_bands )], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + move32(); + } + } + ELSE /* proto = W */ + { + p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = p_proto_buffer_fx[i_mult( 2, l )]; + move32(); + p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = p_proto_buffer_fx[add( i_mult( 2, l ), 1 )]; + move32(); + proto_power_smooth_fx[add( l, num_freq_bands )] = proto_power_smooth_fx[l]; + move32(); + } + } + ELSE + { + p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = L_sub( re1, re2 ); + move32(); + p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = L_sub( im1, im2 ); + move32(); + + temp = Madd_32_32( Mpy_32_32( p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )], p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] ), p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )], p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] ); + IF( LT_16( q_temp, *q_proto_power_smooth ) ) + { + proto_power_smooth_fx[add( l, num_freq_bands )] = L_add( L_shr( proto_power_smooth_fx[add( l, num_freq_bands )], sub( *q_proto_power_smooth, q_temp ) ), temp ); + move32(); + } + ELSE + { + proto_power_smooth_fx[add( l, num_freq_bands )] = L_add( proto_power_smooth_fx[add( l, num_freq_bands )], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + move32(); + } + } + + /* Compute protos for decorrelation */ + proto_frame_f_fx[i_mult( 2, l )] = Real_aux_fx; + move32(); + proto_frame_f_fx[i_mult( 2, l ) + 1] = Imag_aux_fx; + move32(); + proto_frame_f_fx[add( i_mult( 2, num_freq_bands ), i_mult( 2, l ) )] = re1; + move32(); + proto_frame_f_fx[add( add( i_mult( 2, num_freq_bands ), i_mult( 2, l ) ), 1 )] = im1; + move32(); + proto_frame_f_fx[add( i_mult( 4, num_freq_bands ), i_mult( 2, l ) )] = re2; + move32(); + proto_frame_f_fx[add( add( i_mult( 4, num_freq_bands ), i_mult( 2, l ) ), 1 )] = im2; + move32(); + } + + stereo_type_detect->q_sum_power = s_min( stereo_type_detect->q_sum_power, q_temp2 ); + stereo_type_detect->q_total_power = s_min( stereo_type_detect->q_total_power, q_temp ); + q_sum_total_ratio = Q15; + move16(); + + IF( GT_16( stereo_type_detect->interpolator, 0 ) ) + { + stereo_type_detect->interpolator++; + IF( EQ_16( stereo_type_detect->interpolator, MASA_STEREO_INTERPOLATION_SLOTS ) ) + { + stereo_type_detect->interpolator = 0; + move16(); + stereo_type_detect->current_stereo_type = stereo_type_detect->type_change_direction; + } + } + + temp = Mpy_32_32( a_fx, left_bb_power_fx ); + IF( LT_16( q_temp, stereo_type_detect->q_left_bb_power ) ) + { + stereo_type_detect->left_bb_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->left_bb_power_fx ), sub( stereo_type_detect->q_left_bb_power, q_temp ) ) ); + stereo_type_detect->q_left_bb_power = q_temp; + move16(); + } + ELSE + { + stereo_type_detect->left_bb_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_left_bb_power ) ), Mpy_32_32( b_fx, stereo_type_detect->left_bb_power_fx ) ); + } + + temp = Mpy_32_32( a_fx, right_bb_power_fx ); + IF( LT_16( q_temp, stereo_type_detect->q_right_bb_power ) ) + { + stereo_type_detect->right_bb_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->right_bb_power_fx ), sub( stereo_type_detect->q_right_bb_power, q_temp ) ) ); + stereo_type_detect->q_right_bb_power = q_temp; + move16(); + } + ELSE + { + stereo_type_detect->right_bb_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_right_bb_power ) ), Mpy_32_32( b_fx, stereo_type_detect->right_bb_power_fx ) ); + } + + temp = Mpy_32_32( a_fx, total_bb_power_fx ); + IF( LT_16( q_temp, stereo_type_detect->q_total_bb_power ) ) + { + stereo_type_detect->total_bb_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->total_bb_power_fx ), sub( stereo_type_detect->q_total_bb_power, q_temp ) ) ); + stereo_type_detect->q_total_bb_power = q_temp; + move16(); + } + ELSE + { + stereo_type_detect->total_bb_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_total_bb_power ) ), Mpy_32_32( b_fx, stereo_type_detect->total_bb_power_fx ) ); + } + + IF( LT_16( stereo_type_detect->q_left_bb_power, stereo_type_detect->q_right_bb_power ) ) + { + lr_bb_power_fx = L_min( stereo_type_detect->left_bb_power_fx, L_shr( stereo_type_detect->right_bb_power_fx, sub( stereo_type_detect->q_right_bb_power, stereo_type_detect->q_left_bb_power ) ) ); + q_lr_bb_power = stereo_type_detect->q_left_bb_power; + } + ELSE + { + lr_bb_power_fx = L_min( L_shr( stereo_type_detect->left_bb_power_fx, sub( stereo_type_detect->q_left_bb_power, stereo_type_detect->q_right_bb_power ) ), stereo_type_detect->right_bb_power_fx ); + q_lr_bb_power = stereo_type_detect->q_right_bb_power; + } + q_lr_bb_power = sub( q_lr_bb_power, 1 ); /* = (lr_bb_power_fx * 2) */ + + temp = BASOP_Util_Divide3232_Scale( lr_bb_power_fx, L_add( stereo_type_detect->total_bb_power_fx, EPSILON_FX ), &exp ); + exp = sub( 31, add( sub( 15, exp ), sub( q_lr_bb_power, stereo_type_detect->q_total_bb_power ) ) ); + temp = BASOP_Util_Log2( temp ); + IF( NE_32( temp, MIN_32 ) ) + { + temp = Mpy_32_32( L_add( L_shl( exp, Q25 ), temp ), INV_LOG10_2_Q31 ); // Q25 + } + // 20480 = 10 in Q11 + lr_total_bb_ratio_fx = Mpy_32_16_1( temp, 20480 ); // Q21 + + temp = Mpy_32_32( a_fx, left_hi_power_fx ); + IF( LT_16( q_temp, stereo_type_detect->q_left_hi_power ) ) + { + stereo_type_detect->left_hi_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->left_hi_power_fx ), sub( stereo_type_detect->q_left_hi_power, q_temp ) ) ); + stereo_type_detect->q_left_hi_power = q_temp; + move16(); + } + ELSE + { + stereo_type_detect->left_hi_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_left_hi_power ) ), Mpy_32_32( b_fx, stereo_type_detect->left_hi_power_fx ) ); + } + + temp = Mpy_32_32( a_fx, right_hi_power_fx ); + IF( LT_16( q_temp, stereo_type_detect->q_right_hi_power ) ) + { + stereo_type_detect->right_hi_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->right_hi_power_fx ), sub( stereo_type_detect->q_right_hi_power, q_temp ) ) ); + stereo_type_detect->q_right_hi_power = q_temp; + move16(); + } + ELSE + { + stereo_type_detect->right_hi_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_right_hi_power ) ), Mpy_32_32( b_fx, stereo_type_detect->right_hi_power_fx ) ); + } + + temp = Mpy_32_32( a_fx, total_hi_power_fx ); + IF( LT_16( q_temp, stereo_type_detect->q_total_hi_power ) ) + { + stereo_type_detect->total_hi_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->total_hi_power_fx ), sub( stereo_type_detect->q_total_hi_power, q_temp ) ) ); + stereo_type_detect->q_total_hi_power = q_temp; + move16(); + } + ELSE + { + stereo_type_detect->total_hi_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_total_hi_power ) ), Mpy_32_32( b_fx, stereo_type_detect->total_hi_power_fx ) ); + } + + IF( LT_16( stereo_type_detect->q_left_hi_power, stereo_type_detect->q_right_hi_power ) ) + { + lr_hi_power_fx = L_min( stereo_type_detect->left_hi_power_fx, L_shr( stereo_type_detect->right_hi_power_fx, sub( stereo_type_detect->q_right_hi_power, stereo_type_detect->q_left_hi_power ) ) ); + q_lr_hi_power = stereo_type_detect->q_left_hi_power; + } + ELSE + { + lr_hi_power_fx = L_min( L_shr( stereo_type_detect->left_hi_power_fx, sub( stereo_type_detect->q_left_hi_power, stereo_type_detect->q_right_hi_power ) ), stereo_type_detect->right_hi_power_fx ); + q_lr_hi_power = stereo_type_detect->q_right_hi_power; + } + q_lr_hi_power = sub( q_lr_hi_power, 1 ); /* = (q_lr_hi_power * 2) */ + + temp = BASOP_Util_Divide3232_Scale( lr_hi_power_fx, L_add( stereo_type_detect->total_hi_power_fx, EPSILON_FX ), &exp ); + exp = sub( 31, add( sub( 15, exp ), sub( q_lr_hi_power, stereo_type_detect->q_total_hi_power ) ) ); + temp = BASOP_Util_Log2( temp ); + IF( NE_32( temp, MIN_32 ) ) + { + temp = Mpy_32_32( L_add( L_shl( exp, Q25 ), temp ), INV_LOG10_2_Q31 ); // Q25 + } + // 20480 = 10 in Q11 + lr_total_hi_ratio_fx = Mpy_32_16_1( temp, 20480 ); // Q21 + + minimum_l( sum_total_ratio_fx, s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ), &min_sum_total_ratio_fx ); + exp = sub( 31, q_sum_total_ratio ); + temp = BASOP_Util_Log2( min_sum_total_ratio_fx ); + IF( NE_32( temp, MIN_32 ) ) + { + temp = Mpy_32_32( L_add( L_shl( exp, Q25 ), temp ), INV_LOG10_2_Q31 ); // Q25 + } + // 20480 = 10 in Q11 + min_sum_total_ratio_db_fx = Mpy_32_16_1( temp, 20480 ); // Q21 + + stereo_type_detect->lr_total_bb_ratio_db_fx = lr_total_bb_ratio_fx; // Q21 + move32(); + stereo_type_detect->lr_total_hi_ratio_db_fx = lr_total_hi_ratio_fx; // Q21 + move32(); + stereo_type_detect->min_sum_total_ratio_db_fx = min_sum_total_ratio_db_fx; // Q21 + move32(); + + ivas_masa_stereotype_detection_fx( stereo_type_detect ); + } + ELSE + { + p_proto_buffer_fx = proto_direct_buffer_f_fx + i_mult( i_mult( i_mult( slot_index, 2 ), num_freq_bands ), 2 ); + + q_temp = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); + move16(); + + FOR( l = 0; l < num_freq_bands; l++ ) + { + re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); + re2 = L_shl( RealBuffer_fx[1][0][l], min_q_shift ); + im1 = L_shl( ImagBuffer_fx[0][0][l], min_q_shift ); + im2 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift ); + + Real_aux_fx = L_add( re1, re2 ); + Imag_aux_fx = L_add( im1, im2 ); + + reference_power_fx[l] = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); + + IF( LT_16( q_temp, *q_proto_power_smooth ) ) + { + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), reference_power_fx[l] ); + move32(); + } + ELSE + { + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( reference_power_fx[l], sub( q_temp, *q_proto_power_smooth ) ) ); + move32(); + } + + p_proto_buffer_fx[i_mult( 2, l )] = Real_aux_fx; + move32(); + p_proto_buffer_fx[add( i_mult( 2, l ), 1 )] = Imag_aux_fx; + move32(); + + p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = L_sub( re1, re2 ); + move32(); + p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = L_sub( im1, im2 ); + move32(); + + temp = Madd_32_32( Mpy_32_32( p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )], p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] ), p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )], p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] ); + IF( LT_16( q_temp, *q_proto_power_smooth ) ) + { + proto_power_smooth_fx[add( l, num_freq_bands )] = L_add( L_shr( proto_power_smooth_fx[add( l, num_freq_bands )], sub( *q_proto_power_smooth, q_temp ) ), temp ); + move32(); + } + ELSE + { + proto_power_smooth_fx[add( l, num_freq_bands )] = L_add( proto_power_smooth_fx[add( l, num_freq_bands )], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + move32(); + } + + proto_frame_f_fx[i_mult( 2, l )] = Real_aux_fx; + move32(); + proto_frame_f_fx[add( i_mult( 2, l ), 1 )] = Imag_aux_fx; + move32(); + + proto_frame_f_fx[add( i_mult( 2, num_freq_bands ), i_mult( 2, l ) )] = re1; + move32(); + proto_frame_f_fx[add( add( i_mult( 2, num_freq_bands ), i_mult( 2, l ) ), 1 )] = im1; + move32(); + proto_frame_f_fx[add( i_mult( 4, num_freq_bands ), i_mult( 2, l ) )] = re2; + move32(); + proto_frame_f_fx[add( add( i_mult( 4, num_freq_bands ), i_mult( 2, l ) ), 1 )] = im2; + move32(); + } + } + + *q_proto_frame_f = add( q_cldfb, min_q_shift ); + *q_proto_direct_buffer_f = add( q_cldfb, min_q_shift ); + *q_proto_power_smooth = s_min( *q_proto_power_smooth, q_temp ); + *q_reference_power = q_temp; + move16(); + + return; +} +#endif /*------------------------------------------------------------------------- * protoSignalComputation2() * @@ -3184,7 +3943,6 @@ void protoSignalComputation2( return; } - #ifdef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------- * protoSignalComputation4_fx() @@ -3590,17 +4348,27 @@ void ivas_masa_init_stereotype_detection_fx( stereo_type_detect->dipole_freq_range[1] = 3; stereo_type_detect->left_bb_power_fx = 0; /* Broadband estimates */ + stereo_type_detect->q_left_bb_power = Q31; stereo_type_detect->right_bb_power_fx = 0; + stereo_type_detect->q_right_bb_power = Q31; stereo_type_detect->total_bb_power_fx = 0; + stereo_type_detect->q_total_bb_power = Q31; stereo_type_detect->left_hi_power_fx = 0; /* High-frequency estimates */ + stereo_type_detect->q_left_hi_power = Q31; stereo_type_detect->right_hi_power_fx = 0; + stereo_type_detect->q_right_hi_power = Q31; stereo_type_detect->total_hi_power_fx = 0; + stereo_type_detect->q_total_hi_power = Q31; + + set32_fx(stereo_type_detect->sum_power_fx, 0,MASA_SUM_FREQ_RANGE_BINS); + set32_fx(stereo_type_detect->total_power_fx, 0, MASA_SUM_FREQ_RANGE_BINS); - set16_fx(stereo_type_detect->sum_power_fx, 0,MASA_SUM_FREQ_RANGE_BINS); - set16_fx(stereo_type_detect->total_power_fx, 0, MASA_SUM_FREQ_RANGE_BINS); + stereo_type_detect->q_sum_power = Q31; + stereo_type_detect->q_total_power = Q31; stereo_type_detect->subtract_power_y_fx = 0; + stereo_type_detect->q_subtract_power_y = Q31; stereo_type_detect->subtract_power_y_smooth_fx = 0; stereo_type_detect->target_power_y_smooth_fx = 0; @@ -3648,6 +4416,145 @@ void ivas_masa_init_stereotype_detection( return; } +#ifdef IVAS_FLOAT_FIXED +/*------------------------------------------------------------------------- + * ivas_masa_stereotype_detection_fx() + * + * Detect the type of the transport audio signals + *------------------------------------------------------------------------*/ + +void ivas_masa_stereotype_detection_fx( + MASA_STEREO_TYPE_DETECT *stereo_type_detect ) +{ + Word32 lr_total_bb_ratio_db_fx; + Word32 lr_total_hi_ratio_db_fx; + Word32 min_sum_total_ratio_db_fx; + Word32 subtract_target_ratio_db_fx; + Word32 change_to_spaced_fx; + Word16 change_to_spaced_selection; + Word32 change_to_downmix_fx; + Word32 change_to_downmix2_fx; + Word16 change_to_downmix_selection; + Word32 subtract_temp_fx; + Word32 min_sum_temp_fx; + Word32 lr_total_bb_temp_fx; + Word32 lr_total_hi_temp_fx; + Word16 exp; + Word32 temp; + + lr_total_bb_ratio_db_fx = stereo_type_detect->lr_total_bb_ratio_db_fx; + move32(); + lr_total_hi_ratio_db_fx = stereo_type_detect->lr_total_hi_ratio_db_fx; + move32(); + min_sum_total_ratio_db_fx = stereo_type_detect->min_sum_total_ratio_db_fx; + move32(); + subtract_target_ratio_db_fx = stereo_type_detect->subtract_target_ratio_db_fx; + move32(); + exp = 0; + move16(); + + /* Determine if the determined features match the spaced mic type */ + change_to_spaced_selection = 0; + move16(); + IF( LT_32( subtract_target_ratio_db_fx, -THREE_Q21 ) ) + { + temp = L_sub( L_shr( -subtract_target_ratio_db_fx, 1 ), L_shr( THREE_Q21, 1 ) ); + subtract_temp_fx = BASOP_Util_Divide3232_Scale( temp, THREE_Q21, &exp ); + subtract_temp_fx = L_shl( subtract_temp_fx, add( exp, 1 ) ); // Q15 + + min_sum_temp_fx = BASOP_Util_Divide3232_Scale( -min_sum_total_ratio_db_fx, SIX_Q21, &exp ); + min_sum_temp_fx = L_shl( min_sum_temp_fx, exp ); // Q15 + min_sum_temp_fx = L_max( min_sum_temp_fx, 0 ); + + lr_total_bb_temp_fx = BASOP_Util_Divide3232_Scale( lr_total_bb_ratio_db_fx, SIX_Q21, &exp ); + lr_total_bb_temp_fx = L_shl( lr_total_bb_temp_fx, exp ); // Q15 + + change_to_spaced_fx = L_add( L_add( subtract_temp_fx, min_sum_temp_fx ), lr_total_bb_temp_fx ); // Q15 + + IF( GE_32( change_to_spaced_fx, ONE_IN_Q15 ) ) + { + change_to_spaced_selection = 1; + move16(); + } + } + + /* Determine if the determined features match the downmix type, according to a metric */ + change_to_downmix_selection = 0; + move16(); + IF( GT_32( subtract_target_ratio_db_fx, 0 ) ) + { + subtract_temp_fx = BASOP_Util_Divide3232_Scale( subtract_target_ratio_db_fx, THREE_Q21, &exp ); + subtract_temp_fx = L_shl( subtract_temp_fx, exp ); // Q15 + + min_sum_temp_fx = BASOP_Util_Divide3232_Scale( L_add( min_sum_total_ratio_db_fx, ONE_IN_Q21 ), SIX_Q21, &exp ); + min_sum_temp_fx = L_shl( min_sum_temp_fx, exp ); // Q15 + + lr_total_bb_temp_fx = BASOP_Util_Divide3232_Scale( -lr_total_bb_ratio_db_fx, SIX_Q21, &exp ); + lr_total_bb_temp_fx = L_shl( lr_total_bb_temp_fx, exp ); // Q15 + + change_to_downmix_fx = L_add( L_add( subtract_temp_fx, min_sum_temp_fx ), lr_total_bb_temp_fx ); // Q15 + + IF( GE_32( change_to_downmix_fx, ONE_IN_Q15 ) ) + { + change_to_downmix_selection = 1; + move16(); + } + } + + /* Determine if the determined features match the downmix type, according to another metric */ + IF( LT_32( lr_total_hi_ratio_db_fx, -25165824 ) ) // 25165824 = 12.0 in Q21 + { + // 8388608 = 4.0 in Q21 + subtract_temp_fx = BASOP_Util_Divide3232_Scale( L_add( subtract_target_ratio_db_fx, 8388608 ), THREE_Q21, &exp ); + subtract_temp_fx = L_shl( subtract_temp_fx, exp ); // Q15 + + min_sum_temp_fx = BASOP_Util_Divide3232_Scale( min_sum_total_ratio_db_fx, THREE_Q21, &exp ); + min_sum_temp_fx = L_shl( min_sum_temp_fx, exp ); // Q15 + + lr_total_hi_temp_fx = BASOP_Util_Divide3232_Scale( L_sub( -lr_total_hi_ratio_db_fx, 25165824 ), THREE_Q21, &exp ); // 25165824 = 12.0 in Q21 + lr_total_hi_temp_fx = L_shl( lr_total_hi_temp_fx, exp ); // Q15 + + change_to_downmix2_fx = L_add( L_add( subtract_temp_fx, min_sum_temp_fx ), lr_total_hi_temp_fx ); // Q15 + + IF( GE_32( change_to_downmix2_fx, ONE_IN_Q15 ) ) + { + change_to_downmix_selection = 1; + move16(); + } + } + + IF( LT_16( stereo_type_detect->counter, 400 ) ) + { + stereo_type_detect->counter++; + } + ELSE + { + IF( EQ_16( change_to_spaced_selection, 1 ) ) + { + stereo_type_detect->masa_stereo_type = MASA_STEREO_SPACED_MICS; + move16(); + } + ELSE IF( EQ_16( change_to_downmix_selection, 1 ) ) + { + stereo_type_detect->masa_stereo_type = MASA_STEREO_DOWNMIX; + move16(); + } + } + + IF( EQ_16( stereo_type_detect->interpolator, 0 ) ) + { + IF( NE_16( stereo_type_detect->current_stereo_type, stereo_type_detect->masa_stereo_type ) ) + { + stereo_type_detect->interpolator = 1; + move16(); + stereo_type_detect->type_change_direction = stereo_type_detect->masa_stereo_type; + move16(); + } + } + + return; +} +#endif /*------------------------------------------------------------------------- * ivas_masa_stereotype_detection() * diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 122e8298f12bc8bd4f22366d27a8346c15b54e55..b5caa3539b431cc089ac3b6aa8552ecb502b91da 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -491,6 +491,25 @@ void protoSignalComputation1( const int16_t num_freq_bands ); +#ifdef IVAS_FLOAT_FIXED +void protoSignalComputation2_fx( + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], + Word32 *proto_frame_f_fx, + Word16 *q_proto_frame_f, + Word32 *proto_direct_buffer_f_fx, + Word16 *q_proto_direct_buffer_f, + Word32 *reference_power_fx, + Word16 *q_reference_power, + Word32 *proto_power_smooth_fx, + Word16 *q_proto_power_smooth, + const Word16 isloudspeaker, + const Word16 slot_index, + const Word16 num_freq_bands, + MASA_STEREO_TYPE_DETECT *stereo_type_detect, + Word16 q_cldfb +); +#endif void protoSignalComputation2( float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], @@ -570,6 +589,11 @@ void ivas_masa_init_stereotype_detection_fx( ); #endif +#ifdef IVAS_FLOAT_FIXED +void ivas_masa_stereotype_detection_fx( + MASA_STEREO_TYPE_DETECT *stereo_type_detect +); +#endif void ivas_masa_stereotype_detection( MASA_STEREO_TYPE_DETECT *stereo_type_detect ); diff --git a/lib_rend/ivas_reverb_filter_design.c b/lib_rend/ivas_reverb_filter_design.c index e496e879c5d46c986dbce6a017c0de01b1e2757f..d146071f0aa07fba064b9777a598f560f49d2449 100644 --- a/lib_rend/ivas_reverb_filter_design.c +++ b/lib_rend/ivas_reverb_filter_design.c @@ -1147,7 +1147,7 @@ void ivas_reverb_calc_color_levels_fx( H_filter = L_add(L_shr(L_add(L_shr(Mpy_32_32(coefB[0], coefB[0]), 1), L_shr(Mpy_32_32(coefB[1], coefB[1]), 1)), 2), L_shr(Mpy_32_32(coefB[0], Mpy_32_32(coefB[1], L_shl(cos_w, 15))), 1)); //q = 28 H_filter = BASOP_Util_Divide3232_Scale(H_filter, L_add(ONE_IN_Q28, L_shr(L_add(L_shr(Mpy_32_32(coefA[1], coefA[1]), 2), Mpy_32_32(coefA[1], L_shl(cos_w, 15))), 1)), &temp); H_filter = Sqrt32(L_shl(H_filter, 16), &temp); - T60_est = BASOP_Util_Divide3232_Scale(L_shl(i_mult(-3, pLoop_delays[loop_idx]), 2), Mpy_32_32(Mpy_32_32(L_add(BASOP_Util_Log2(H_filter), L_shl(temp, 25)), LOG10_2), L_shl(output_Fs, 8)), &temp);//conversion of log2 to log10. + T60_est = BASOP_Util_Divide3232_Scale(L_shl(i_mult(-3, pLoop_delays[loop_idx]), 2), Mpy_32_32(Mpy_32_32(L_add(BASOP_Util_Log2(H_filter), L_shl(temp, 25)), INV_LOG10_2_Q31), L_shl(output_Fs, 8)), &temp);//conversion of log2 to log10. T60_est = L_shl(T60_est, 16); t60[freq_idx] = BASOP_Util_Add_Mant32Exp(T60_est, temp, t60[freq_idx], t60_e[freq_idx], &result_e); t60_e[freq_idx] = result_e; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 3f0ee5e5ab17d2755b84ee04c41fc7e093519c0b..dc2dec4eff0114ca6727061af16f43b71d747ee3 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -473,25 +473,34 @@ typedef struct float subtract_target_ratio_db; #ifdef IVAS_FLOAT_FIXED - Word16 left_bb_power_fx; - Word16 right_bb_power_fx; - Word16 total_bb_power_fx; - - Word16 left_hi_power_fx; - Word16 right_hi_power_fx; - Word16 total_hi_power_fx; - - Word16 sum_power_fx[MASA_SUM_FREQ_RANGE_BINS]; - Word16 total_power_fx[MASA_SUM_FREQ_RANGE_BINS]; - - Word16 subtract_power_y_fx; + Word32 left_bb_power_fx; + Word16 q_left_bb_power; + Word32 right_bb_power_fx; + Word16 q_right_bb_power; + Word32 total_bb_power_fx; + Word16 q_total_bb_power; + + Word32 left_hi_power_fx; + Word16 q_left_hi_power; + Word32 right_hi_power_fx; + Word16 q_right_hi_power; + Word32 total_hi_power_fx; + Word16 q_total_hi_power; + + Word32 sum_power_fx[MASA_SUM_FREQ_RANGE_BINS]; + Word16 q_sum_power; + Word32 total_power_fx[MASA_SUM_FREQ_RANGE_BINS]; + Word16 q_total_power; + + Word32 subtract_power_y_fx; + Word16 q_subtract_power_y; Word16 subtract_power_y_smooth_fx; Word16 target_power_y_smooth_fx; - Word16 lr_total_bb_ratio_db_fx; - Word16 lr_total_hi_ratio_db_fx; - Word16 min_sum_total_ratio_db_fx; - Word16 subtract_target_ratio_db_fx; + Word32 lr_total_bb_ratio_db_fx; + Word32 lr_total_hi_ratio_db_fx; + Word32 min_sum_total_ratio_db_fx; + Word32 subtract_target_ratio_db_fx; #endif int16_t counter;