From cc2872a7ac2fca01624760996230002a17bdd479 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 20 May 2024 21:20:57 +0530 Subject: [PATCH] LTV crash issue fix for stereo, OMASA formats and float code cleanup [x] LTV crash fix for stereo format streams caused due to incorrect table values and intermediate float to fix conversions [stereo at 16.4 kbps, 32kHz in, 16kHz out, DTX on] [stereo at 16.4 kbps, 32kHz in, 16kHz out, random FER at 5%, DTX on] [stereo at 13.2 kbps, 32kHz in, 32kHz out, DTX on, random FER at 5%, bandwidth switching] [stereo at 16.4 kbps, 16kHz in, 16kHz out, DTX on, random FER at 5%] [stereo at 32 kbps, 48kHz in, 48kHz out, DTX on, random FER at 5%, bandwidth switching] [stereo bitrate switching from 13.2 kbps to 128 kbps, 32kHz in, 32kHz out] [x] LTV crash fix for OMASA and MASA formats. [OMASA 1Dir1TC 4ISM at br sw techs 13.2 to 512 kbps start 32 kbps, 48kHz in, 48kHz out, BINAURAL out, JBM Prof 5] [OMASA 1Dir2TC 4ISM at br sw techs 13.2 to 512 kbps start 80 kbps, 48kHz in, 48kHz out, FOA out, JBM Prof 5] [MASA 1dir 2TC bitrate switching from 13.2 kbps to 512 kbps, 48kHz in, 16kHz out, BINAURAL out, JBM Prof 5] [x] Float code clean up in init_dec_fx.c, dirac dec and dirac lib_rend files --- lib_com/float_to_fix_ops.c | 92 - lib_com/ivas_sns_com_fx.c | 2 +- lib_com/lsf_tools_fx.c | 16 +- lib_com/rom_com.c | 28 +- lib_com/stat_com.h | 2 +- lib_dec/acelp_core_dec_ivas_fx.c | 14 +- lib_dec/fd_cng_dec.c | 23 +- lib_dec/init_dec_fx.c | 1925 ++++++++---------- lib_dec/ivas_core_dec.c | 27 - lib_dec/ivas_cpe_dec_fx.c | 14 - lib_dec/ivas_dirac_dec.c | 6 +- lib_dec/ivas_ism_dtx_dec.c | 4 +- lib_dec/ivas_jbm_dec.c | 132 +- lib_dec/ivas_mc_param_dec.c | 12 +- lib_dec/ivas_sce_dec_fx.c | 5 - lib_dec/ivas_stereo_cng_dec.c | 10 +- lib_dec/jbm_pcmdsp_apa.c | 2 +- lib_dec/tonalMDCTconcealment_fx.c | 12 + lib_rend/ivas_dirac_dec_binaural_functions.c | 20 +- lib_rend/ivas_dirac_decorr_dec.c | 238 ++- lib_rend/ivas_dirac_onsets_dec.c | 31 +- lib_rend/ivas_dirac_output_synthesis_dec.c | 3 +- lib_rend/ivas_dirac_rend.c | 46 +- lib_rend/ivas_prot_rend.h | 7 + lib_rend/ivas_rotation.c | 7 + lib_rend/lib_rend.c | 4 + 26 files changed, 1089 insertions(+), 1593 deletions(-) diff --git a/lib_com/float_to_fix_ops.c b/lib_com/float_to_fix_ops.c index 57c6ded70..8ed6c56c0 100644 --- a/lib_com/float_to_fix_ops.c +++ b/lib_com/float_to_fix_ops.c @@ -831,15 +831,6 @@ void fixed_to_float_stereo_tcx_core_dec( if ( EQ_16( st->core, ACELP_CORE ) ) { - - for ( int p = 0; p < st->L_frame / 2; p++ ) - { - //st->hTcxDec->syn_OverlFB_float[p] = (float) st->hTcxDec->syn_OverlFB[p] / (float) pow( 2, st->Q_syn ); - //st->hTcxDec->syn_Overl_float[p] = (float) st->hTcxDec->syn_Overl[p] / (float) pow( 2, st->Q_syn ); - //st->hTcxDec->old_syn_Overl_float[p] = (float) st->hTcxDec->old_syn_Overl[p] * 2 * ( 1u << st->Q_syn ); - //st->hTcxDec->syn_Overl_TDACFB_float[p] = (float) st->hTcxDec->syn_Overl_TDACFB[p] * 2 * (float) pow( 2, st->Q_syn ); - //st->hTcxDec->syn_Overl_TDAC_float[p] = (float) st->hTcxDec->syn_Overl_TDAC[p] * 2 * (float) pow( 2, st->Q_syn ); - } if (st->hHQ_core->Q_old_wtda >= 0) { for ( int p = 0; p < st->L_frame; p++ ) @@ -855,35 +846,8 @@ void fixed_to_float_stereo_tcx_core_dec( st->hHQ_core->old_out[p] = (float) st->hHQ_core->old_out_fx[p] * ( 1u << (-st->hHQ_core->Q_old_wtda) ); } } - //for ( int p = 0; p < st->L_frame; p++ ) - //{ - // st->hTcxDec->old_excFB[p] = (float) ( st->hTcxDec->old_excFB_fx[p] ) / ( 1u << st->Q_exc ); - //} } - //if ( st->lpcQuantization ) - //{ - // st->safety_net = st->safety_net; - // st->mid_lsf_int = st->mid_lsf_int; - //} - - //hTcxDec->tcxltp_last_gain_unmodified_float = fixedToFloat( hTcxDec->tcxltp_last_gain_unmodified, Q15 ); - - //st->hTcxDec->conceal_eof_gain_float = fixedToFloat( st->hTcxDec->conceal_eof_gain, Q14 ); - - //st->hTcxDec->CngLevelBackgroundTrace_bfi = fix16_to_float( st->hTcxDec->conCngLevelBackgroundTrace, 15 - st->hTcxDec->conCngLevelBackgroundTrace_e ); - - //fixedToFloat_arr( hTcxDec->old_synth, hTcxDec->old_synth_float, 0, hTcxDec->old_synth_len ); - //fixedToFloat_arr( hTcxDec->synth_history_fx, hTcxDec->synth_history, 0, NS2SA_fx2( st->output_Fs, PH_ECU_MEM_NS ) ); - //st->hTcxDec->q_synth_history_fx = 0; - - //fixedToFloat_arr( hTcxDec->old_synthFB_fx, hTcxDec->old_synthFB, 0, NS2SA_fx2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) + hTcxDec->old_synth_lenFB ); - - //if ( !st->tcxonly ) - //{ - // fixedToFloat_arr( st->p_bpf_noise_buf, st->p_bpf_noise_buf_float, 0, L_FRAME_16k ); - //} - st->hBPF->pst_mem_deemp_err_fx = (Word16)st->mem_error; /*=================================*/ if ( st->hFdCngDec != NULL && ( st->sr_core == INT_FS_12k8 || st->sr_core == INT_FS_16k ) && st->total_brate <= MAX_ACELP_BRATE ) @@ -902,62 +866,14 @@ void fixed_to_float_stereo_tcx_core_dec( ( ( st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT ) && ( st->hFdCngDec->hFdCngCom->active_frame_counter > 0 ) ) || ( ( st->bfi == 1 ) && ( st->nbLostCmpt == 1 ) ) ) ) || ( st->m_frame_type == ZERO_FRAME ) ) { - //st->hTcxDec->CngLevelBackgroundTrace_bfi = fix_to_float( st->hTcxDec->CngLevelBackgroundTrace_bfi_fx, ( 31 - st->hTcxDec->CngLevelBackgroundTrace_bfi_exp ) ); - //st->hTcxDec->CngLevelBackgroundTrace_bfi = fix16_to_float( st->hTcxDec->conCngLevelBackgroundTrace, ( 15 - st->hTcxDec->conCngLevelBackgroundTrace_e) ); - //st->cngTDLevel_float = fixedToFloat( st->cngTDLevel, ( 15 - st->cngTDLevel_e ) ); - //for ( int p = 0; p < st->hFdCngDec->hFdCngCom->fftlen; p++ ) - //{ - // st->hFdCngDec->hFdCngCom->fftBuffer_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->fftBuffer[p] / ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp ) ) ); - //} - if(( 31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) >= 0) - { - for ( int p = 0; p < ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); p++ ) - { - st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->cngNoiseLevel[p] / ( 1u << ( 31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) ) ); - } - } - else{ - for ( int p = 0; p < ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); p++ ) - { - st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->cngNoiseLevel[p] * ( 1u << ( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp - 31) ) ); - } - } - for ( int p = 0; p < ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); p++ ) - { - //st->hFdCngDec->bandNoiseShape_float[p] = ( (float) st->hFdCngDec->bandNoiseShape[p] / ( 1u << ( 31 - st->hFdCngDec->bandNoiseShape_exp ) ) ); - } - - for ( int p = 0; p < st->hFdCngDec->npart_shaping; p++ ) { st->hFdCngDec->msNoiseEst_float[p] = (float) st->hFdCngDec->msNoiseEst[p] / ( 1u << ( 31 - st->hFdCngDec->msNoiseEst_exp ) ); } - if ( st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT ) - { - for ( int p = 0; p < L_FRAME16k - st->hFdCngDec->hFdCngCom->startBand; p++ ) - { - //st->hFdCngDec->smoothed_psd[st->hFdCngDec->hFdCngCom->startBand + p] = ( (float) st->hFdCngDec->smoothed_psd_fx[st->hFdCngDec->hFdCngCom->startBand + p] / ( 1u << ( 31 - st->hFdCngDec->msNoiseEst_exp ) ) ); - } - st->hFdCngDec->q_smoothed_psd = sub( 31 , st->hFdCngDec->msNoiseEst_exp ); - } - - //int A_cng_q = 14; - if ( st->element_mode != IVAS_CPE_MDCT || st->core == ACELP_CORE ) - { - //A_cng_q = 15 - norm_s( st->hFdCngDec->hFdCngCom->A_cng[0] ); - } - //Scale_sig(st->hFdCngDec->hFdCngCom->A_cng, M + 1, A_cng_q - norm_s(st->hFdCngDec->hFdCngCom->A_cng[0] - 1)); - - for ( int p = 0; p < M; p++ ) - { - //st->hFdCngDec->hFdCngCom->A_cng_flt[p] = ( (float) st->hFdCngDec->hFdCngCom->A_cng[p] / ( 1u << A_cng_q ) ); - } } } } - - //me2f_buf(st->hIGFDec->virtualSpec, st->hIGFDec->virtualSpec_e, st->hIGFDec->virtualSpecBuf, (N_MAX_TCX - IGF_START_MN)); IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) ) { @@ -969,14 +885,6 @@ void fixed_to_float_stereo_tcx_core_dec( { st->hHQ_core->old_out[ind] = (float) st->hHQ_core->old_out_fx[ind] / ( (float) pow( 2, st->hHQ_core->Q_old_wtda ) ); } - FOR( Word16 ind = 0; ind < L_FRAME32k / 2; ind++ ) - { - //st->hTcxDec->syn_Overl_float[ind] = (float) st->hTcxDec->syn_Overl[ind] / ( (float) pow( 2, st->Q_syn + 1 ) ); - } - FOR( Word16 ind = 0; ind < L_FRAME_MAX / 2; ind++ ) - { - //st->hTcxDec->syn_OverlFB_float[ind] = (float) st->hTcxDec->syn_OverlFB[ind] / ( (float) pow( 2, st->Q_syn ) ); - } } } #endif // IVAS_FLOAT_FIXED diff --git a/lib_com/ivas_sns_com_fx.c b/lib_com/ivas_sns_com_fx.c index d04de5815..d192118d9 100644 --- a/lib_com/ivas_sns_com_fx.c +++ b/lib_com/ivas_sns_com_fx.c @@ -138,7 +138,7 @@ void sns_compute_scf_fx( FOR( i = 0; i < FDNS_NPTS; i++ ) { xs[i] = Mpy_32_16_1( xs[i], pow_tilt[i] ); - xs[i] = L_shl( xs[i], Q8 ); // xs => Q12 + xs[i] = L_shl( xs[i], Q6 ); // xs => Q10 } /* Noise floor at -40dB */ diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index d1aa039b5..05934803f 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -1206,10 +1206,12 @@ void E_LPC_f_lsp_a_conversion(const Word16 *lsp, Word16 *a, const Word16 m) { #ifdef BASOP_NOGLOB t0 = L_max(t0, L_abs(L_add_o(f1[i], f2[i], &Overflow))); + t0 = L_max(t0, L_abs(L_sub_o(f1[i], f2[i], &Overflow))); #else t0 = L_max(t0, L_abs(L_add(f1[i], f2[i]))); + t0 = L_max(t0, L_abs(L_sub(f1[i], f2[i]))); #endif - t0 = L_max(t0, L_abs(L_sub(f1[i], f2[i]))); + } k = s_min(norm_l(t0), 6); a[0] = shl(256, k); @@ -1237,9 +1239,17 @@ void E_LPC_f_lsp_a_conversion(const Word16 *lsp, Word16 *a, const Word16 m) #endif /* a[j] = 0.5*(f1[i] - f2[i]) */ - t0 = L_sub(f1[i], f2[i]); +#ifdef BASOP_NOGLOB + t0 = L_sub_o(f1[i], f2[i], &Overflow); +#else + t0 = L_sub(f1[i], f2[i]); +#endif t0 = L_shl(t0, k); - a[j] = round_fx(t0); /* from Q23 to Qx and * 0.5 */ +#ifdef BASOP_NOGLOB + a[j] = round_fx_o(t0, &Overflow); /* from Q23 to Qx and * 0.5 */ +#else + a[j] = round_fx(t0); /* from Q23 to Qx and * 0.5 */ +#endif j--; } diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index 256fc16d7..f41b789b1 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -10980,25 +10980,25 @@ const SCALE_SETUP scaleTableMono[SIZE_SCALE_TABLE_MONO] = const SCALE_SETUP scaleTable_cn_only[SIZE_SCALE_TABLE_CN] = { - { 0, 0, 8000, -3.5f, 20295/*1.2387211385 Q14*/ /*-3.5f*/, 20295 }, - { 0, 8000, 9600, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/, 16306 }, - { 0, 9600, 13200, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, - { 0, 13200, 16400, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/, 9583 }, + { 0, 0, 8000, -3.5f, 20295/*1.2387211385 Q14*/ /*-3.5f*/, -28672 }, + { 0, 8000, 9600, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/, -24576 }, + { 0, 9600, 13200, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, -20480 }, + { 0, 13200, 16400, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/, -16384 }, { 0, 16400,128001, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 }, - { 1, 0, 8000, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/, 16306 }, - { 1, 8000, 9600, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, - { 1, 9600, 13200, -1.5f, 6759/*0.4125375748 Q14*/ /*-1.5f*/, 6759 }, - { 1, 13200, 16400, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, - { 1, 16400, 24400, -0.5f, 1999/*0.1220184565 Q14*/ /*-0.5f*/, 1999 }, + { 1, 0, 8000, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/, -24576 }, + { 1, 8000, 9600, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, -20480 }, + { 1, 9600, 13200, -1.5f, 6759/*0.4125375748 Q14*/ /*-1.5f*/, -12288 }, + { 1, 13200, 16400, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, -20480 }, + { 1, 16400, 24400, -0.5f, 1999/*0.1220184565 Q14*/ /*-0.5f*/, -4096 }, { 1, 24400,128001, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 }, - { 2, 0, 8000, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, - { 2, 8000, 9600, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, - { 2, 9600, 13200, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/, 9583 }, - { 2, 13200, 16400, -1.0f, 4242/*0.2589254379 Q14*/ /*-1.0f*/, 4242 }, + { 2, 0, 8000, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, -20480 }, + { 2, 8000, 9600, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, -20480 }, + { 2, 9600, 13200, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/, -16384 }, + { 2, 13200, 16400, -1.0f, 4242/*0.2589254379 Q14*/ /*-1.0f*/, -8192 }, - { 2, 16400, 24400, -0.5f, 1999/*0.1220184565 Q14*/ /*-0.5f*/, 1999 }, + { 2, 16400, 24400, -0.5f, 1999/*0.1220184565 Q14*/ /*-0.5f*/, -4096 }, { 2, 24400, 32000, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 }, { 2, 32000,128001, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 } }; diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 3c9f4cfbc..e58393e8d 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -461,7 +461,7 @@ typedef struct Word16 exp_cldfb_periodog; Word32 cngNoiseLevel[FFTCLDFBLEN]; /* Noise level applied for the CNG in each (sub)band */ - Word16 q_cngNoiseLevel; + //Word16 q_cngNoiseLevel; Word16 cngNoiseLevelExp; int16_t seed; /* Seed memory (for random function) */ diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index ef617eed6..baebf97be 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -136,7 +136,13 @@ ivas_error acelp_core_dec_ivas_fx( ivas_error error; Word32 bpf_error_signal_fx[L_FRAME16k]; +#ifdef MSAN_FIX + set32_fx(bpf_error_signal_fx, 0, L_FRAME16k); +#endif Word16 bpf_error_signal_16fx[L_FRAME16k]; +#ifdef MSAN_FIX + set_s(bpf_error_signal_16fx, 0, L_FRAME16k); +#endif Word16 tmp; error = IVAS_ERR_OK; @@ -1981,13 +1987,6 @@ void acelp_decoder_state_float2fix(Decoder_State *st/*, STEREO_CNG_DEC_HANDLE hS if(st->cldfbSynHB) floatToFixed_arrL(st->cldfbSynHB->cldfb_state, st->cldfbSynHB->cldfb_state_fx, Q10, st->cldfbSynHB->p_filter_length); floatToFixed_arrL(st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_fx, Q10, st->cldfbSyn->p_filter_length); - - //FdCng - if ( st->hFdCngDec ) - { - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = Q31 - 4; - floatToFixed_arrL(st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, Q31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN); - } } void acelp_decoder_state_fix2float(Decoder_State *st) { @@ -2006,7 +2005,6 @@ void acelp_decoder_state_fix2float(Decoder_State *st) { //FdCng if ( st->hFdCngDec ) { - fixedToFloat_arrL( st->hFdCngDec->hFdCngCom->cngNoiseLevel, st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, Q31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN ); if ((st->hFdCngDec != NULL || st->idchan == 1) && st->element_mode != IVAS_CPE_MDCT) { if (st->element_mode == IVAS_CPE_TD || st->flag_cna || (st->cng_type == FD_CNG && st->total_brate <= ACELP_32k) || (st->cng_type == LP_CNG && st->core_brate <= SID_2k40)) diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 80cfcdce9..102dde8cd 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -1457,21 +1457,17 @@ void FdCng_decodeSID_ivas_fx( if (hFdCngCom->CngBandwidth == NB) { - //sidNoiseEst_flt[N - 1] *= NB_LAST_BAND_SCALE_FLT; sidNoiseEst[N - 1] = Mpy_32_16_1(sidNoiseEst[N - 1], NB_LAST_BAND_SCALE); } if (hFdCngCom->CngBandwidth == SWB && hFdCngCom->CngBitrate <= ACELP_13k20) { - //sidNoiseEst_flt[N - 1] *= SWB_13k2_LAST_BAND_SCALE_FLT; sidNoiseEst[N - 1] = Mpy_32_16_1(sidNoiseEst[N - 1], SWB_13k2_LAST_BAND_SCALE); } - //scalebands_flt(sidNoiseEst_flt, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, hFdCngCom->stopBand - hFdCngCom->startBand, hFdCngCom->cngNoiseLevel_flt, 1); scalebands(sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, hFdCngCom->stopBand - hFdCngCom->startBand, hFdCngCom->cngNoiseLevel, 1); hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; - //lpc_from_spectrum_flt(hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, st->preemph_fac_float); lpc_from_spectrum(hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, st->preemph_fac); return; @@ -2013,10 +2009,7 @@ void generate_masking_noise_ivas_fx( const int16_t nchan_out /* i : number of output channels */ ) { - float *cngNoiseLevel_flt = hFdCngCom->cngNoiseLevel_flt; - Word32 max_cngNoiseLevel = 0; Word32 *cngNoiseLevel_fx = hFdCngCom->cngNoiseLevel; - Word16 noise_exp; Word32 *ptr_level_fx = cngNoiseLevel_fx; Word32 *fftBuffer_fx = hFdCngCom->fftBuffer; Word16 i; @@ -2027,16 +2020,6 @@ void generate_masking_noise_ivas_fx( Word16 *seed = &( hFdCngCom->seed ); Word32 scale_fx = 0x40000000; // 1.0 in Q30 - FOR( i = 0; i < FFTCLDFBLEN; i++ ) - { - max_cngNoiseLevel = L_max( L_abs( (Word32) cngNoiseLevel_flt[i] ), max_cngNoiseLevel ); - } - noise_exp = norm_l( max_cngNoiseLevel ); - FOR( i = 0; i < FFTCLDFBLEN; i++ ) - { - cngNoiseLevel_fx[i] = float_to_fix( cngNoiseLevel_flt[i], noise_exp ); - } - /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */ *exp_out = Q15; IF( hFdCngCom->likelihood_noisy_speech_32fx > DELTA_MASKING_NOISE_Q31 ) @@ -2093,7 +2076,7 @@ void generate_masking_noise_ivas_fx( { rand_gauss_fx( &fftBuffer_fx[0], seed, *exp_out); // Q15 ptr_r_fx = fftBuffer_fx + 2; - Word16 exp1 = 32 - noise_exp; + Word16 exp1 = 32 - hFdCngCom->cngNoiseLevelExp; Word32 mpy1 = Sqrt32( Mpy_32_32( scale_fx, *ptr_level_fx ), &exp1 ); // Q = noise_exp-1 mpy1 = L_shl( mpy1, exp1 ); // Q31 fftBuffer_fx[0] = Mpy_32_32( fftBuffer_fx[0], mpy1 ); /* DC component in FFT */ // Q = Q15 @@ -2110,7 +2093,7 @@ void generate_masking_noise_ivas_fx( { /* Real part in FFT bins */ rand_gauss_fx( ptr_r_fx, seed, *exp_out); // Q15 - Word16 exp2 = 32 - noise_exp; + Word16 exp2 = 32 - hFdCngCom->cngNoiseLevelExp; Word32 mpy2 = Sqrt32( L_shr( Mpy_32_32( scale_fx, *ptr_level_fx ), 1 ), &exp2 ); // Q = noise_exp-1 ( *ptr_r_fx ) = L_shl( Mpy_32_32( *ptr_r_fx, mpy2 ), exp2 ); // Q = Q15 ptr_r_fx += 2; @@ -2170,6 +2153,7 @@ void generate_masking_noise_ivas_fx( * not called based on signal statistics *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void generate_masking_noise_update_seed( HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ ) @@ -2199,6 +2183,7 @@ void generate_masking_noise_update_seed( return; } +#endif #ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------- diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index ef0539a24..332eef94e 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -837,1180 +837,893 @@ ivas_error init_decoder_fx( } +/*----------------------------------------------------------------------* + * init_decoder_ivas_fx() + * + * Initialization of static variables for the IVAS decoder + *----------------------------------------------------------------------*/ ivas_error init_decoder_ivas_fx( - Decoder_State *st_fx, /* o: Decoder static variables structure */ - const Word16 idchan, /* i : channel ID */ - const MC_MODE mc_mode /* i : MC mode */ + Decoder_State *st_fx, /* o: Decoder static variables structure */ + const Word16 idchan, /* i : channel ID */ + const MC_MODE mc_mode /* i : MC mode */ ) { - Word16 i; - ivas_error error; - - error = IVAS_ERR_OK; - - /*-----------------------------------------------------------------* - * General parameters - *-----------------------------------------------------------------*/ - - st_fx->codec_mode = MODE1; - move16(); - st_fx->last_codec_mode = MODE1; - move16(); - st_fx->core = ACELP_CORE; - move16(); - st_fx->L_frame = L_FRAME; - move16(); - st_fx->extl = -1; - move16(); - st_fx->extl_orig = -1; /* extension layer */ - move16(); - st_fx->extl_brate_orig = 0; /* extension layer bitrate */ - move16(); - st_fx->last_bits_frame_nominal = -1; - move16(); - st_fx->total_brate = ACELP_8k00; - move16(); - st_fx->last_total_brate = -1; - move16(); - st_fx->last_total_brate_ber = -1; - move32(); - st_fx->core_brate = ACELP_8k00; - move16(); - st_fx->ini_frame = 0; - move16(); - st_fx->bwidth = NB; - move16(); - st_fx->last_bwidth = NB; - move16(); - st_fx->extl_brate = 0; - move16(); - -#ifdef ISM_DISABLE - if ( st_fx->ivas_format != ISM_FORMAT ) - { - st_fx->coder_type = GENERIC; - st_fx->last_coder_type = GENERIC; + Word16 i; + ivas_error error; + + error = IVAS_ERR_OK; + move32(); + + /*-----------------------------------------------------------------* + * General parameters + *-----------------------------------------------------------------*/ + + st_fx->codec_mode = MODE1; + move16(); + st_fx->last_codec_mode = MODE1; + move16(); + st_fx->core = ACELP_CORE; + move16(); + st_fx->L_frame = L_FRAME; + move16(); + st_fx->extl = -1; + move16(); + st_fx->extl_orig = -1; /* extension layer */ + move16(); + st_fx->extl_brate_orig = 0; /* extension layer bitrate */ + move16(); + st_fx->last_bits_frame_nominal = -1; + move16(); + st_fx->total_brate = ACELP_8k00; + move16(); + st_fx->last_total_brate = -1; + move16(); + st_fx->last_total_brate_ber = -1; + move32(); + st_fx->core_brate = ACELP_8k00; + move16(); + st_fx->ini_frame = 0; + move16(); + st_fx->bwidth = NB; + move16(); + st_fx->last_bwidth = NB; + move16(); + st_fx->extl_brate = 0; + move16(); + st_fx->coder_type = GENERIC; /* low-rate mode flag */ + move16(); + st_fx->last_coder_type = GENERIC; + move16(); + st_fx->inactive_coder_type_flag = 0; + move16(); + st_fx->last_L_frame = st_fx->L_frame; + move16(); + st_fx->last_core_brate = st_fx->core_brate; + move16(); + st_fx->last_core = -1; + move16(); + st_fx->last_extl = st_fx->extl; + move16(); + + st_fx->flag_ACELP16k = set_ACELP_flag( st_fx->element_mode, st_fx->total_brate, st_fx->total_brate, idchan, 0, -1, -1 ); + + /*-----------------------------------------------------------------* + * ACELP core parameters + *-----------------------------------------------------------------*/ + + /* LSF initilaizations */ + Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); + + init_lvq_fx( st_fx->offset_scale1_fx, st_fx->offset_scale2_fx, st_fx->offset_scale1_p_fx, st_fx->offset_scale2_p_fx, st_fx->no_scales_fx, st_fx->no_scales_p_fx ); + + set16_fx( st_fx->mem_MA_fx, 0, M ); + + st_fx->dm_fx.prev_state = 0; /* This corresponds to st_fx->dispMem in FLP */ + move16(); + st_fx->dm_fx.prev_gain_code = L_deposit_l( 0 ); + FOR( i = 2; i < 8; i++ ) + { + st_fx->dm_fx.prev_gain_pit[i - 2] = 0; + move16(); + } + st_fx->tilt_code_fx = 0; + move16(); + st_fx->gc_threshold_fx = 0; + move32(); + st_fx->last_good = UNVOICED_CLAS; + move16(); + st_fx->clas_dec = UNVOICED_CLAS; + move16(); + st_fx->low_rate_mode = 0; /* low-rate mode flag */ + move16(); + st_fx->last_low_rate_mode = 0; /* low-rate mode flag */ + move16(); + st_fx->lp_gainp_fx = 0; + move16(); + st_fx->lp_gainc_fx = 0; + move16(); + + set16_fx( st_fx->old_exc_fx, 0, L_EXC_MEM_DEC ); + + /* AVQ pre-quantizer memory */ + st_fx->mem_preemp_preQ_fx = 0; + move16(); + st_fx->last_nq_preQ = 0; + move16(); + st_fx->use_acelp_preq = 0; + move16(); + + st_fx->mem_deemph_fx = 0; + move16(); + + set16_fx( st_fx->mem_syn1_fx, 0, M ); + set16_fx( st_fx->mem_syn2_fx, 0, M ); + st_fx->stab_fac_fx = 0; + move16(); + st_fx->stab_fac_smooth_fx = 0; + move16(); + set16_fx( st_fx->agc_mem_fx, 0, 2 ); + set16_fx( st_fx->mem_syn3_fx, 0, M ); + + st_fx->stab_fac_smooth_lt_fx = 0; + move16(); + st_fx->log_energy_diff_lt_fx = 0; + move32(); + st_fx->log_energy_old_fx = 0; + move32(); + + Copy( GEWB_Ave_fx, st_fx->lsf_old_fx, M ); + lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_12k8 ); + + st_fx->mid_lsf_int = 0; + move16(); + st_fx->safety_net = 0; + move16(); + + /* FEC */ + st_fx->scaling_flag = 0; + move16(); + st_fx->lp_ener_FEC_av = 500000; + move32(); + st_fx->lp_ener_FEC_max = 500000; + move32(); + st_fx->prev_bfi = 0; + move16(); + st_fx->lp_ener_FER_fx = 15360; /*60 in Q8*/ + move16(); + st_fx->old_enr_LP = 0; + move16(); + st_fx->lp_ener_fx = L_deposit_l( 0 ); + st_fx->enr_old_fx = L_deposit_l( 0 ); + st_fx->bfi_pitch_fx = L_SUBFR_Q6; + move16(); + st_fx->bfi_pitch_frame = L_FRAME; + move16(); + set16_fx( st_fx->mem_syn_clas_estim_fx, 0, L_SYN_MEM_CLAS_ESTIM ); + st_fx->classifier_Q_mem_syn = 0; + move16(); + st_fx->last_con_tcx = 0; + move16(); + + FOR( i = 0; i < 2 * NB_SUBFR16k; i++ ) + { + st_fx->old_pitch_buf_fx[i] = L_shl( L_SUBFR, 16 ); /*15Q16*/ + move32(); + } + + st_fx->upd_cnt = MAX_UPD_CNT; + move16(); + Copy( GEWB_Ave_fx, st_fx->lsfoldbfi0_fx, M ); + Copy( GEWB_Ave_fx, st_fx->lsfoldbfi1_fx, M ); + Copy( GEWB_Ave_fx, st_fx->lsf_adaptive_mean_fx, M ); + + st_fx->seed_acelp = RANDOM_INITSEED; + move16(); + st_fx->seed = RANDOM_INITSEED; + move16(); + st_fx->nbLostCmpt = 0; + move16(); + st_fx->decision_hyst = 0; + move16(); + st_fx->unv_cnt = 0; + move16(); + st_fx->ge_sm_fx = L_deposit_l( 640 ); /*Q(GE_SHIFT)*/ + st_fx->uv_count = 0; + move16(); + st_fx->act_count = 3; + move16(); + Copy( st_fx->lsp_old_fx, st_fx->lspold_s_fx, M ); + st_fx->noimix_seed = RANDOM_INITSEED; + move16(); + st_fx->min_alpha_fx = 32767; /*1; Q15*/ + move16(); + st_fx->exc_pe_fx = 0; + move16(); +#ifdef MSAN_FIX + st_fx->Q_stat_noise = 31; + move16(); +#endif + st_fx->prev_coder_type = GENERIC; + move16(); + + st_fx->tilt_wb_fx = 0; + move16(); + + st_fx->last_voice_factor_fx = 0; + move16(); + + 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(); + + /*-----------------------------------------------------------------* + * parameters for AC mode (GSC) + *-----------------------------------------------------------------*/ + + st_fx->GSC_noisy_speech = 0; + move16(); + st_fx->GSC_IVAS_mode = 0; + move16(); + st_fx->Last_GSC_noisy_speech_flag = 0; + move16(); + + IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + { + IF( ( st_fx->hGSCDec = (GSC_DEC_HANDLE) count_malloc( sizeof( GSC_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for GSC\n" ) ); + } + + GSC_dec_init_ivas_fx( st_fx->hGSCDec ); + } + ELSE + { + st_fx->hGSCDec = NULL; + } + + /*-----------------------------------------------------------------* + * parameters for fast recovery (WI) + *-----------------------------------------------------------------*/ + + IF( EQ_32( st_fx->output_Fs, 16000 ) && EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + IF( ( st_fx->hWIDec = (WI_DEC_HANDLE) count_malloc( sizeof( WI_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FEC WI\n" ) ); + } + set16_fx( st_fx->hWIDec->old_exc2_fx, 0, L_EXC_MEM ); + set16_fx( st_fx->hWIDec->old_syn2_fx, 0, L_EXC_MEM ); + } + ELSE + { + st_fx->hWIDec = NULL; + } + + /* NB post-filter */ + /*-----------------------------------------------------------------* + * NB/formant post-filter + *-----------------------------------------------------------------*/ + IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + { + IF( ( st_fx->hPFstat = (PFSTAT_HANDLE) count_malloc( sizeof( PFSTAT ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for NB/formant postflter\n" ) ); + } + + Init_post_filter_fx( st_fx->hPFstat ); + st_fx->psf_lp_noise_fx = 0; + move16(); + } + ELSE + { + st_fx->hPFstat = NULL; + } + + /*-----------------------------------------------------------------* + * HF (6-7kHz) (zero) BWE parameters + *-----------------------------------------------------------------*/ + + IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + { + IF( ( st_fx->hBWE_zero = (ZERO_BWE_DEC_HANDLE) malloc( sizeof( ZERO_BWE_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for zero BWE\n" ) ); + } + + hf_synth_init_fx( st_fx->hBWE_zero ); +#ifdef MSAN_FIX + set16_fx( st_fx->hBWE_zero->mem_hp400_fx, 0, 6 ); +#endif + } + ELSE + { + st_fx->hBWE_zero = NULL; + } + + /*-----------------------------------------------------------------* + * LD music post-filter + *-----------------------------------------------------------------*/ + + IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + { + IF( ( st_fx->hMusicPF = (MUSIC_POSTFILT_HANDLE) count_malloc( sizeof( MUSIC_POSTFILT_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LD music postflter\n" ) ); + } + + music_postfilt_init( st_fx->hMusicPF ); + } + ELSE + { + st_fx->hMusicPF = NULL; + } + + /*-----------------------------------------------------------------* + * CNG and DTX + *-----------------------------------------------------------------*/ + + st_fx->first_CNG = 0; + move16(); + st_fx->cng_type = -1; + move16(); + st_fx->last_active_brate = ACELP_7k20; + move32(); + st_fx->last_CNG_L_frame = L_FRAME; + move16(); + st_fx->last_vad_fx = 0; + move16(); + st_fx->active_cnt = 20; + move16(); + + IF( EQ_16( idchan, 0 ) && ( EQ_16( st_fx->element_mode, EVS_MONO ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) ) + { + if ( ( st_fx->hTdCngDec = (TD_CNG_DEC_HANDLE) count_malloc( sizeof( TD_CNG_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); + } + + td_cng_dec_init_ivas_fx( st_fx ); + } + ELSE + { + st_fx->hTdCngDec = NULL; + } + + st_fx->masa_sid_format = 0; + move16(); + st_fx->Q_stat_noise_ge = GE_SHIFT; + move16(); + + /*-----------------------------------------------------------------* + * HQ core parameters + *-----------------------------------------------------------------*/ + + st_fx->prev_old_bfi = 0; + move16(); + + set16_fx( st_fx->delay_buf_out_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP ); + set16_fx( st_fx->previoussynth_fx, 0, L_FRAME48k ); + + set32_fx( st_fx->delay_buf_out32_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP ); + set32_fx( st_fx->previoussynth_fx_32, 0, L_FRAME48k ); + + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + set16_fx( st_fx->old_synth_sw_fx, 0, NS2SA( 48000, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ) ); + } + + IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) ) + { + IF( ( st_fx->hHQ_core = (HQ_DEC_HANDLE) malloc( sizeof( HQ_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ core\n" ) ); + } + + /* HQ core initialization */ +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED // To be removed when fixed version is available. + HQ_core_dec_init_flt( st_fx->hHQ_core ); +#endif + HQ_core_dec_init_fx( st_fx->hHQ_core ); + + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + /* HQ NB FEC initialization */ + IF( ( st_fx->hHQ_nbfec = (HQ_NBFEC_HANDLE) malloc( sizeof( HQ_NBFEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ NB FEC\n" ) ); + } + + HQ_nbfec_init_fx( st_fx->hHQ_nbfec ); + } + ELSE + { + st_fx->hHQ_nbfec = NULL; + } + } + ELSE + { + st_fx->hHQ_core = NULL; + st_fx->hHQ_nbfec = NULL; + } + + /*-----------------------------------------------------------------* + * TBE parameters + *-----------------------------------------------------------------*/ + + IF( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + { + if ( ( st_fx->hBWE_TD = (TD_BWE_DEC_HANDLE) malloc( sizeof( TD_BWE_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); + } + + td_bwe_dec_init_ivas_fx( st_fx, st_fx->hBWE_TD, st_fx->output_Fs ); +#ifdef MSAN_FIX + st_fx->hBWE_TD->prev_hb_synth_fx_exp = 31; + move16(); +#endif + } + ELSE + { + st_fx->hBWE_TD = NULL; + } + + st_fx->old_bwe_delay = -1; /*Q0*/ + move16(); + set16_fx( st_fx->hb_prev_synth_buffer_fx, 0, NS2SA_fx2( 48000, DELAY_BWE_TOTAL_NS ) ); + + /*-----------------------------------------------------------------* + * SWB BWE parameters + *-----------------------------------------------------------------*/ + + IF( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + { + IF( ( st_fx->hBWE_FD = (FD_BWE_DEC_HANDLE) malloc( sizeof( FD_BWE_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FD BWE\n" ) ); + } + + fd_bwe_dec_init( st_fx, st_fx->hBWE_FD ); + } + ELSE + { + st_fx->hBWE_FD = NULL; + } + + /*-----------------------------------------------------------------* + * WB/SWB bandwidth switching parameters + *-----------------------------------------------------------------*/ + + st_fx->tilt_swb_fx = 0; + move16(); + st_fx->prev_ener_shb_fx = 0; + move16(); + st_fx->prev_enerLH_fx = 0; + move16(); + st_fx->enerLH_fx = L_deposit_l( 0 ); + st_fx->enerLL_fx = L_deposit_l( 0 ); + st_fx->prev_enerLL_fx = 0; + move16(); + st_fx->prev_fractive = 0; + move16(); + st_fx->prev_bws_cnt = 0; + move16(); + st_fx->bws_cnt = N_WS2N_FRAMES; + move16(); + st_fx->bws_cnt1 = N_NS2W_FRAMES; + move16(); + st_fx->attenu_fx = 3277; + move16(); + st_fx->last_inner_frame = L_FRAME8k; + move16(); + + /*-----------------------------------------------------------------* + * HR SWB BWE parameters + *-----------------------------------------------------------------*/ + + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + IF( ( st_fx->hBWE_FD_HR = (HR_BWE_DEC_HANDLE) count_malloc( sizeof( HR_BWE_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HR BWE\n" ) ); + } + + hr_bwe_dec_init( st_fx->hBWE_FD_HR ); + } + ELSE + { + st_fx->hBWE_FD_HR = NULL; + } + + /*----------------------------------------------------------------------------------* + * AMR-WB IO mode parameters + *----------------------------------------------------------------------------------*/ + + IF( st_fx->Opt_AMR_WB || EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + IF( ( st_fx->hAmrwb_IO = (AMRWB_IO_DEC_HANDLE) count_malloc( sizeof( AMRWB_IO_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for AMR-WB IO\n" ) ); + } + + /* AMR-WB IO init */ + amr_wb_dec_init_fx( st_fx->hAmrwb_IO ); + + /* AMR-WB IO HF synth init */ + hf_synth_amr_wb_init_fx( st_fx->hAmrwb_IO ); + } + ELSE + { + st_fx->hAmrwb_IO = NULL; + } + + /*-----------------------------------------------------------------* + * channel-aware mode parameters + *-----------------------------------------------------------------*/ + + set16_fx( st_fx->tilt_code_dec_fx, 0, NB_SUBFR16k ); + st_fx->use_partial_copy = 0; + move16(); + st_fx->prev_use_partial_copy = 0; + move16(); + st_fx->rf_flag = 0; + move16(); + st_fx->rf_flag_last = 0; + move16(); + st_fx->prev_rf_frame_type = 0; + move16(); + st_fx->next_coder_type = 0; + move16(); + st_fx->rf_target_bits = 0; + move16(); + st_fx->rf_indx_nelp_fid = 0; + move16(); + st_fx->rf_indx_nelp_iG1 = 0; + move16(); + st_fx->rf_indx_nelp_iG2[0] = 0; + move16(); + st_fx->rf_indx_nelp_iG2[1] = 0; + move16(); + st_fx->rf_indx_tbeGainFr = 0; + move16(); + + /*-----------------------------------------------------------------* + * Bass post-filter parameters + *-----------------------------------------------------------------*/ + + st_fx->bpf_off = 0; + move16(); + + IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + { + IF( ( st_fx->hBPF = (BPF_DEC_HANDLE) malloc( sizeof( BPF_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for BPF\n" ) ); + } + + bass_psfilter_init_fx( st_fx->hBPF ); + } + ELSE + { + st_fx->hBPF = NULL; } -#endif - st_fx->coder_type = GENERIC; /* low-rate mode flag */ - move16(); - st_fx->last_coder_type = GENERIC; - move16(); - st_fx->inactive_coder_type_flag = 0; - move16(); - st_fx->last_L_frame = st_fx->L_frame; - move16(); - st_fx->last_core_brate = st_fx->core_brate; - move16(); - st_fx->last_core = -1; - move16(); - st_fx->last_extl = st_fx->extl; - move16(); - - st_fx->flag_ACELP16k = set_ACELP_flag(st_fx->element_mode, st_fx->total_brate, st_fx->total_brate, idchan, 0, -1, -1); - - /*-----------------------------------------------------------------* - * ACELP core parameters - *-----------------------------------------------------------------*/ - - /* LSF initilaizations */ -#ifdef ISM_DISABLE // Remove once fixed version is present. - // if ( st_fx->ivas_format != ISM_FORMAT ) - // { - //mvr2r(GEWB_Ave, st_fx->mem_AR, M); - - //set_f(st_fx->mem_MA, 0, M); - //set_f(st_fx->dispMem, 0, 8); - //st_fx->tilt_code = 0.0f; - //st_fx->gc_threshold = 0.0f; - //} -#endif - Copy(GEWB_Ave_fx, st_fx->mem_AR_fx, M); - init_lvq_fx(st_fx->offset_scale1_fx, st_fx->offset_scale2_fx, st_fx->offset_scale1_p_fx, st_fx->offset_scale2_p_fx, st_fx->no_scales_fx, st_fx->no_scales_p_fx); + /*-----------------------------------------------------------------* + * FD BPF & resampling tools parameters + *-----------------------------------------------------------------*/ - set16_fx(st_fx->mem_MA_fx, 0, M); + IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + { + /* open analysis for max. SR 48kHz */ + IF( ( error = openCldfb_ivas_fx( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) + { + return error; + } - st_fx->dm_fx.prev_state = 0; - move16(); /* This corresponds to st_fx->dispMem in FLP */ - st_fx->dm_fx.prev_gain_code = L_deposit_l(0); - FOR(i = 2; i < 8; i++) - { - st_fx->dm_fx.prev_gain_pit[i - 2] = 0; - move16(); - } - st_fx->tilt_code_fx = 0; - move16(); - st_fx->gc_threshold_fx = 0; + /* open analysis BPF for max. SR 16kHz */ + IF( ( error = openCldfb_ivas_fx( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + ELSE + { + st_fx->cldfbAna = NULL; + st_fx->cldfbBPF = NULL; + } -#ifdef ISM_DISABLE - if ( st_fx->ivas_format != ISM_FORMAT ) + /* open synthesis for output SR */ + IF( ( error = openCldfb_ivas_fx( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) { - st_fx->last_good = UNVOICED_CLAS; + return error; } -#endif - st_fx->last_good = UNVOICED_CLAS; - move16(); - st_fx->clas_dec = UNVOICED_CLAS; - move16(); - st_fx->low_rate_mode = 0; /* low-rate mode flag */ - st_fx->last_low_rate_mode = 0; /* low-rate mode flag */ - -#ifdef ISM_DISABLE // Remove once fixed version is present. - //if ( st_fx->ivas_format != ISM_FORMAT ) - //{ - //st_fx->lp_gainp = 0.0f; - //st_fx->lp_gainc = 0.0f; - - //set_f(st_fx->old_exc, 0, L_EXC_MEM_DEC); - //} -#endif - st_fx->lp_gainp_fx = 0; + st_fx->cldfbSynHB = NULL; + st_fx->last_active_bandsToZero_bwdec = 0; move16(); - st_fx->lp_gainc_fx = 0; + st_fx->perc_bwddec = 0; + move16(); + st_fx->last_flag_filter_NB = 0; + move16(); + st_fx->active_frame_cnt_bwddec = 0; + move16(); + st_fx->total_frame_cnt_bwddec = 0; move16(); + set16_fx( st_fx->flag_buffer, 0, 20 ); + st_fx->avg_nrg_LT = 0; + move32(); - set16_fx(st_fx->old_exc_fx, 0, L_EXC_MEM_DEC); - -//++To be removed -#ifndef IVAS_FLOAT_FIXED - mvr2r( GEWB_Ave, st_fx->lsf_old, M ); - lsf2lsp( st_fx->lsf_old, st_fx->lsp_old, M, INT_FS_12k8 ); -#endif//IVAS_FLOAT_FIXED -//++To be removed - -#ifdef ISM_DISABLE // Remove once fixed version is present. - if ( st_fx->ivas_format != ISM_FORMAT ) - { - /* AVQ pre-quantizer memory */ - //st_fx->mem_preemp_preQ = 0.0f; - st_fx->last_nq_preQ = 0; - st_fx->last_code_preq = 0; - st_fx->use_acelp_preq = 0; - - -#ifndef IVAS_FLOAT_FIXED - st_fx->stab_fac = 0.0f; - st_fx->mem_deemph = 0.0f; - set_f(st_fx->mem_syn1, 0, M); - set_f(st_fx->mem_syn2, 0, M); - st_fx->stab_fac_smooth = 0.0f; - set_f(st_fx->agc_mem2, 0, 2); - set_f(st_fx->mem_syn3, 0, M); -#endif // #ifndef IVAS_FLOAT_FIXED - - //st_fx->stab_fac_smooth_lt = 0.0f; - //st_fx->log_energy_diff_lt = 0.0f; - //st_fx->log_energy_old = 0.0f; - - // mvr2r(GEWB_Ave, st_fx->lsf_old, M); - // lsf2lsp(st_fx->lsf_old, st_fx->lsp_old, M, INT_FS_12k8); - - st_fx->mid_lsf_int = 0; - st_fx->safety_net = 0; - } -#endif + /*-----------------------------------------------------------------* + * Noise gate parameters + *-----------------------------------------------------------------*/ - /* AVQ pre-quantizer memory */ - st_fx->mem_preemp_preQ_fx = 0; - move16(); - st_fx->last_nq_preQ = 0; - move16(); - st_fx->use_acelp_preq = 0; - move16(); - - st_fx->mem_deemph_fx = 0; - move16(); - - set16_fx(st_fx->mem_syn1_fx, 0, M); - move16(); - set16_fx(st_fx->mem_syn2_fx, 0, M); - st_fx->stab_fac_fx = 0; - move16(); - st_fx->stab_fac_smooth_fx = 0; - move16(); - set16_fx(st_fx->agc_mem_fx, 0, 2); - set16_fx(st_fx->mem_syn3_fx, 0, M); - - st_fx->stab_fac_smooth_lt_fx = 0; - st_fx->log_energy_diff_lt_fx = 0; - st_fx->log_energy_old_fx = 0; - - Copy(GEWB_Ave_fx, st_fx->lsf_old_fx, M); - lsf2lsp_fx(st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_12k8); + set16_fx( st_fx->old_Aq_12_8_fx + 1, 0, M ); + st_fx->old_Aq_12_8_fx[0] = ONE_IN_Q12; + move16(); + st_fx->Ng_ener_ST_fx = -13056; /*-51 IN Q8*/ + move16(); + st_fx->old_Es_pred_fx = 0; + move16(); + set16_fx( st_fx->old_Aq_12_8_fx + 1, 0, M ); + st_fx->old_Aq_12_8_fx[0] = 4096; /*1 in Q12*/ + move16(); - st_fx->mid_lsf_int = 0; - st_fx->safety_net = 0; + /*-----------------------------------------------------------------* + * SC-VBR parameters + *-----------------------------------------------------------------*/ -#ifdef ISM_DISABLE // To be removed when fixed version is available. - if ( st_fx->ivas_format != ISM_FORMAT ) - { - /* FEC */ - st_fx->scaling_flag = 0; - //st_fx->lp_ener_FEC_av_float = 5.0e5f; - //st_fx->lp_ener_FEC_max_float = 5.0e5f; - st_fx->prev_bfi = 0; - //st_fx->lp_ener_bfi = 60.0f; - //st_fx->old_enr_LP_float = 0.0f; - //st_fx->lp_ener = 0.0f; - //st_fx->enr_old = 0.0f; - //st_fx->bfi_pitch = (float)L_SUBFR; - st_fx->bfi_pitch_frame = L_FRAME; - //set_f(st_fx->mem_syn_clas_estim, 0.0f, L_SYN_MEM_CLAS_ESTIM); - st_fx->last_con_tcx = 0; - - //for (i = 0; i < 2 * NB_SUBFR16k; i++) - //{ - // st_fx->old_pitch_buf[i] = (float)L_SUBFR; - //} - - st_fx->upd_cnt = MAX_UPD_CNT; - - //mvr2r(GEWB_Ave, st_fx->lsfoldbfi0, M); - //mvr2r(GEWB_Ave, st_fx->lsfoldbfi1, M); - //mvr2r(GEWB_Ave, st_fx->lsf_adaptive_mean, M); - - st_fx->seed_acelp = RANDOM_INITSEED; - st_fx->seed = RANDOM_INITSEED; - st_fx->nbLostCmpt = 0; - st_fx->decision_hyst = 0; - } -#endif + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + IF( ( st_fx->hSC_VBR = (SC_VBR_DEC_HANDLE) count_malloc( sizeof( SC_VBR_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SC-VBR\n" ) ); + } - /* FEC */ - st_fx->scaling_flag = 0; - move16(); - st_fx->lp_ener_FEC_av = 500000; - move32(); - st_fx->lp_ener_FEC_max = 500000; - move32(); - st_fx->prev_bfi = 0; - move16(); - st_fx->lp_ener_FER_fx = 15360; - move16(); /*60 in Q8*/ - st_fx->old_enr_LP = 0; - move16(); - st_fx->lp_ener_fx = L_deposit_l(0); - st_fx->enr_old_fx = L_deposit_l(0); - st_fx->bfi_pitch_fx = L_SUBFR_Q6; - move16(); - st_fx->bfi_pitch_frame = L_FRAME; - move16(); - set16_fx(st_fx->mem_syn_clas_estim_fx, 0, L_SYN_MEM_CLAS_ESTIM); - st_fx->classifier_Q_mem_syn = 0; - move16(); - st_fx->last_con_tcx = 0; - move16(); - - FOR(i = 0; i < 2 * NB_SUBFR16k; i++) - { - st_fx->old_pitch_buf_fx[i] = L_SUBFR << 16; - move32(); /*15Q16*/ - } - - st_fx->upd_cnt = MAX_UPD_CNT; - move16(); - Copy(GEWB_Ave_fx, st_fx->lsfoldbfi0_fx, M); - Copy(GEWB_Ave_fx, st_fx->lsfoldbfi1_fx, M); - Copy(GEWB_Ave_fx, st_fx->lsf_adaptive_mean_fx, M); - - st_fx->seed_acelp = RANDOM_INITSEED; - move16(); - st_fx->seed = RANDOM_INITSEED; - move16(); - st_fx->nbLostCmpt = 0; - move16(); - st_fx->decision_hyst = 0; - move16(); - -#ifdef ISM_DISABLE // To be removed when fixed version is available. - /* Stationary noise UV modification */ - if ( st_fx->ivas_format != ISM_FORMAT ) - { - st_fx->unv_cnt = 0; - //st_fx->ge_sm = 10; - st_fx->uv_count = 0; - st_fx->act_count = 3; - - //mvr2r(st_fx->lsp_old, st_fx->lspold_s, M); - st_fx->noimix_seed = RANDOM_INITSEED; - //st_fx->exc_pe = 0; - - st_fx->prev_coder_type = GENERIC; - //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)); - - st_fx->old_bfi_cnt = 0; + sc_vbr_dec_init( st_fx->hSC_VBR ); + } + ELSE + { + st_fx->hSC_VBR = NULL; } -#endif - //st_fx->min_alpha = 1; - st_fx->unv_cnt = 0; - move16(); - st_fx->ge_sm_fx = L_deposit_l(640); /*Q(GE_SHIFT)*/ - st_fx->uv_count = 0; - move16(); - st_fx->act_count = 3; - move16(); - Copy(st_fx->lsp_old_fx, st_fx->lspold_s_fx, M); - st_fx->noimix_seed = RANDOM_INITSEED; - move16(); - st_fx->min_alpha_fx = 32767; - move16(); /*1; Q15*/ - st_fx->exc_pe_fx = 0; - move16(); -#ifdef MSAN_FIX - st_fx->Q_stat_noise = 31; - move16(); -#endif - st_fx->prev_coder_type = GENERIC; - move16(); - - st_fx->tilt_wb_fx = 0; - move16(); - st_fx->last_voice_factor_fx = 0; + st_fx->last_ppp_mode_dec = 0; move16(); - - 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; + st_fx->old_ppp_mode = 0; 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; + st_fx->ppp_mode_dec = 0; + move16(); + st_fx->last_nelp_mode_dec = 0; + move16(); + st_fx->nelp_mode_dec = 0; + move16(); + st_fx->prev_gain_pit_dec_fx = 0; + move16(); + st_fx->prev_tilt_code_dec_fx = 0; + move16(); + st_fx->vbr_hw_BWE_disable_dec = 0; + move16(); + st_fx->last_vbr_hw_BWE_disable_dec = 0; move16(); - /*-----------------------------------------------------------------* - * parameters for AC mode (GSC) - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * TCX core + *-----------------------------------------------------------------*/ -#ifdef ISM_DISABLE // To be removed when fixed version is available. - if ( st_fx->ivas_format != ISM_FORMAT ) + /* TCX-LTP */ + IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) { - st_fx->GSC_noisy_speech = 0; - st_fx->GSC_IVAS_mode = 0; - st_fx->Last_GSC_noisy_speech_flag = 0; - } -#endif - st_fx->GSC_noisy_speech = 0; - st_fx->GSC_IVAS_mode = 0; - st_fx->Last_GSC_noisy_speech_flag = 0; - - IF((idchan == 0 && NE_16(st_fx->element_mode, IVAS_CPE_MDCT)) || EQ_16(st_fx->element_mode, IVAS_CPE_TD)) - { - IF((st_fx->hGSCDec = (GSC_DEC_HANDLE)count_malloc(sizeof(GSC_DEC_DATA))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for GSC\n")); - } -#ifdef ISM_DISABLE // To be removed when fixed version is available. -#ifndef IVAS_FLOAT_FIXED - if ( st_fx->ivas_format != ISM_FORMAT ) - { - GSC_dec_init_ivas(st_fx->hGSCDec); - } -#endif -#endif - GSC_dec_init_ivas_fx(st_fx->hGSCDec); - } - ELSE - { - st_fx->hGSCDec = NULL; - } - - /*-----------------------------------------------------------------* - * parameters for fast recovery (WI) - *-----------------------------------------------------------------*/ - - IF(EQ_32(st_fx->output_Fs, 16000) && EQ_16(st_fx->element_mode, EVS_MONO)) - { - IF((st_fx->hWIDec = (WI_DEC_HANDLE)count_malloc(sizeof(WI_DEC_DATA))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FEC WI\n")); - } -#ifdef ISM_DISABLE // To be removed when fixed version is available. -#ifndef IVAS_FLOAT_FIXED - if ( st_fx->ivas_format != ISM_FORMAT ) + IF( ( st_fx->hTcxLtpDec = (TCX_LTP_DEC_HANDLE) count_malloc( sizeof( TCX_LTP_DEC_DATA ) ) ) == NULL ) { - set_f(st_fx->hWIDec->old_exc2, 0, L_EXC_MEM); - set_f(st_fx->hWIDec->old_syn2, 0, L_EXC_MEM); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TCX-LTP handle\n" ) ); } -#endif -#endif - set16_fx(st_fx->hWIDec->old_exc2_fx, 0, L_EXC_MEM); - set16_fx(st_fx->hWIDec->old_syn2_fx, 0, L_EXC_MEM); - } - ELSE - { - st_fx->hWIDec = NULL; - } - - /* NB post-filter */ - /*-----------------------------------------------------------------* - * NB/formant post-filter - *-----------------------------------------------------------------*/ - IF((idchan == 0 && NE_16(st_fx->element_mode, IVAS_CPE_MDCT)) || EQ_16(st_fx->element_mode, IVAS_CPE_TD)) - { - IF((st_fx->hPFstat = (PFSTAT_HANDLE)count_malloc(sizeof(PFSTAT))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for NB/formant postflter\n")); - } - -#ifndef IVAS_FLOAT_FIXED - Init_post_filter_ivas(st_fx->hPFstat); - st_fx->psf_lp_noise = 0.0f; -#endif - Init_post_filter_fx(st_fx->hPFstat); - st_fx->psf_lp_noise_fx = 0; - } - ELSE - { - st_fx->hPFstat = NULL; - } - - /*-----------------------------------------------------------------* - * HF (6-7kHz) (zero) BWE parameters - *-----------------------------------------------------------------*/ - - IF((idchan == 0 && NE_16(st_fx->element_mode, IVAS_CPE_MDCT)) || EQ_16(st_fx->element_mode, IVAS_CPE_TD)) - { - IF((st_fx->hBWE_zero = (ZERO_BWE_DEC_HANDLE)malloc(sizeof(ZERO_BWE_DEC_DATA))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for zero BWE\n")); - } - - hf_synth_init_fx(st_fx->hBWE_zero); -#ifdef MSAN_FIX - set16_fx( st_fx->hBWE_zero->mem_hp400_fx, 0, 6 ); -#endif - } - ELSE - { - st_fx->hBWE_zero = NULL; - } - - /*-----------------------------------------------------------------* - * LD music post-filter - *-----------------------------------------------------------------*/ - - IF((idchan == 0 && NE_16(st_fx->element_mode, IVAS_CPE_MDCT)) || EQ_16(st_fx->element_mode, IVAS_CPE_TD)) - { - IF((st_fx->hMusicPF = (MUSIC_POSTFILT_HANDLE)count_malloc(sizeof(MUSIC_POSTFILT_DATA))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LD music postflter\n")); - } - -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED // To be removed when fixed version is available. - music_postfilt_init_flt(st_fx->hMusicPF); -#endif - music_postfilt_init(st_fx->hMusicPF); - } - ELSE - { - st_fx->hMusicPF = NULL; - } - - /*-----------------------------------------------------------------* - * CNG and DTX - *-----------------------------------------------------------------*/ - - st_fx->first_CNG = 0; - move16(); - st_fx->cng_type = -1; - move16(); - st_fx->last_active_brate = ACELP_7k20; - move32(); - st_fx->last_CNG_L_frame = L_FRAME; - move16(); - -#ifdef ISM_DISABLE // To be removed when fixed version is available. - if ( st_fx->ivas_format != ISM_FORMAT ) - { - st_fx->last_vad = 0; } -#endif - st_fx->last_vad_fx = 0; - move16(); - - st_fx->active_cnt = 20; - move16(); - - IF(idchan == 0 && (EQ_16(st_fx->element_mode, EVS_MONO) || EQ_16(st_fx->element_mode, IVAS_CPE_DFT) || EQ_16(st_fx->element_mode, IVAS_CPE_TD))) - { - if ((st_fx->hTdCngDec = (TD_CNG_DEC_HANDLE)count_malloc(sizeof(TD_CNG_DEC_DATA))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n")); - } - -#ifdef IVAS_FLOAT_FIXED - td_cng_dec_init_ivas_fx( st_fx ); -#else - td_cng_dec_init( st_fx ); -#endif // IVAS_FLOAT_FIXED - } - ELSE - { - st_fx->hTdCngDec = NULL; - } - - st_fx->masa_sid_format = 0; - move16(); - st_fx->Q_stat_noise_ge = GE_SHIFT; - move16(); - - /*-----------------------------------------------------------------* - * HQ core parameters - *-----------------------------------------------------------------*/ - - st_fx->prev_old_bfi = 0; - - set16_fx(st_fx->delay_buf_out_fx, 0, HQ_DELTA_MAX* HQ_DELAY_COMP); - set16_fx(st_fx->previoussynth_fx, 0, L_FRAME48k); - - set32_fx(st_fx->delay_buf_out32_fx, 0, HQ_DELTA_MAX* HQ_DELAY_COMP); - set32_fx(st_fx->previoussynth_fx_32, 0, L_FRAME48k); - - IF(EQ_16(st_fx->element_mode, EVS_MONO)) - { - set16_fx(st_fx->old_synth_sw_fx, 0, NS2SA(48000, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS)); - } - - IF((idchan == 0 || EQ_16(st_fx->element_mode, IVAS_CPE_MDCT) || EQ_16(st_fx->element_mode, IVAS_SCE) || EQ_16(st_fx->element_mode, EVS_MONO))) - { - IF((st_fx->hHQ_core = (HQ_DEC_HANDLE)malloc(sizeof(HQ_DEC_DATA))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ core\n")); - } - - /* HQ core initialization */ - -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED // To be removed when fixed version is available. - HQ_core_dec_init_flt(st_fx->hHQ_core); -#endif - HQ_core_dec_init_fx(st_fx->hHQ_core); - - IF(EQ_16(st_fx->element_mode, EVS_MONO)) - { - /* HQ NB FEC initialization */ - IF((st_fx->hHQ_nbfec = (HQ_NBFEC_HANDLE)malloc(sizeof(HQ_NBFEC_DATA))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ NB FEC\n")); - } -#ifndef IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED // To be removed when fixed version is available. - HQ_nbfec_init_flt(st_fx->hHQ_nbfec); -#endif -#endif - HQ_nbfec_init_fx(st_fx->hHQ_nbfec); - } - ELSE - { - st_fx->hHQ_nbfec = NULL; - move16(); - } - } - ELSE - { - st_fx->hHQ_core = NULL; - st_fx->hHQ_nbfec = NULL; - move16(); move16(); - } - - /*-----------------------------------------------------------------* - * TBE parameters - *-----------------------------------------------------------------*/ - - IF(idchan == 0 && NE_16(st_fx->element_mode, IVAS_CPE_MDCT)) - { - if ((st_fx->hBWE_TD = (TD_BWE_DEC_HANDLE)malloc(sizeof(TD_BWE_DEC_DATA))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n")); - } - - td_bwe_dec_init_ivas_fx(st_fx, st_fx->hBWE_TD, st_fx->output_Fs); -#ifdef MSAN_FIX - st_fx->hBWE_TD->prev_hb_synth_fx_exp = 31; -#endif - } - ELSE - { - st_fx->hBWE_TD = NULL; - } - -#ifdef ISM_DISABLE // To be removed when fixed version is available. - if ( st_fx->ivas_format != ISM_FORMAT ) + ELSE { - st_fx->old_bwe_delay = -1; - //set_f(st_fx->hb_prev_synth_buffer, 0, NS2SA(48000, DELAY_BWE_TOTAL_NS)); + st_fx->hTcxLtpDec = NULL; } -#endif - st_fx->old_bwe_delay = -1; /*Q0*/ move16(); - set16_fx(st_fx->hb_prev_synth_buffer_fx, 0, NS2SA_fx2(48000, DELAY_BWE_TOTAL_NS)); - - /*-----------------------------------------------------------------* - * SWB BWE parameters - *-----------------------------------------------------------------*/ - IF(idchan == 0 && NE_16(st_fx->element_mode, IVAS_CPE_MDCT)) - { - IF((st_fx->hBWE_FD = (FD_BWE_DEC_HANDLE)malloc(sizeof(FD_BWE_DEC_DATA))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FD BWE\n")); - } + /* TCX core */ + IF( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + { + IF( ( st_fx->hTcxDec = (TCX_DEC_HANDLE) malloc( sizeof( TCX_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxDec\n" ) ); + } -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED // To be removed when fixed version is available. - // fd_bwe_dec_init_flt(st_fx->hBWE_FD); -#endif + set32_fx( st_fx->hTcxDec->FBTCXdelayBuf_32, 0, 111 ); - fd_bwe_dec_init(st_fx, st_fx->hBWE_FD); - } - ELSE - { - st_fx->hBWE_FD = NULL; - } - - /*-----------------------------------------------------------------* - * WB/SWB bandwidth switching parameters - *-----------------------------------------------------------------*/ - -#ifdef ISM_DISABLE // To be removed when fixed version is available. - if ( st_fx->ivas_format != ISM_FORMAT ) - { - //st_fx->tilt_swb = 0.0f; - //st_fx->prev_ener_shb = 0.0f; - //st_fx->prev_enerLH = 0.0f; - //st_fx->enerLH = 0.0f; - //st_fx->enerLL = 0.0f; - //st_fx->prev_enerLL = 0.0f; - st_fx->prev_fractive = 0; - st_fx->prev_bws_cnt = 0; - st_fx->bws_cnt = N_WS2N_FRAMES; - st_fx->bws_cnt1 = N_NS2W_FRAMES; + st_fx->hTcxDec->old_synthFB_fx = st_fx->hTcxDec->synth_history_fx + NS2SA( st_fx->output_Fs, PH_ECU_MEM_NS ); + st_fx->hTcxDec->prev_good_synth_fx = st_fx->hTcxDec->old_synthFB_fx + NS2SA( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ); } -#endif - st_fx->tilt_swb_fx = 0; - move16(); - - st_fx->prev_ener_shb_fx = 0; - move16(); - st_fx->prev_enerLH_fx = 0; - move16(); - st_fx->enerLH_fx = L_deposit_l(0); - st_fx->enerLL_fx = L_deposit_l(0); - st_fx->prev_enerLL_fx = 0; - move16(); - st_fx->prev_fractive = 0; - move16(); - st_fx->prev_bws_cnt = 0; - move16(); - st_fx->bws_cnt = N_WS2N_FRAMES; - move16(); - st_fx->bws_cnt1 = N_NS2W_FRAMES; - move16(); - st_fx->attenu_fx = 3277; - move16(); - - st_fx->last_inner_frame = L_FRAME8k; - move16(); - - /*-----------------------------------------------------------------* - * HR SWB BWE parameters - *-----------------------------------------------------------------*/ - - IF(EQ_16(st_fx->element_mode, EVS_MONO)) - { - IF((st_fx->hBWE_FD_HR = (HR_BWE_DEC_HANDLE)count_malloc(sizeof(HR_BWE_DEC_DATA))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HR BWE\n")); - } -#ifdef ISM_DISABLE // To be removed when fixed version is available. -#ifndef IVAS_FLOAT_FIXED - if ( st_fx->ivas_format != ISM_FORMAT ) + ELSE + { + st_fx->hTcxDec = NULL; + } + + /* TCX config. data structure */ + IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + { + IF( ( st_fx->hTcxCfg = (TCX_CONFIG_HANDLE) count_malloc( sizeof( TCX_config ) ) ) == NULL ) { - hr_bwe_dec_init_flt(st_fx->hBWE_FD_HR); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) ); } -#endif -#endif - hr_bwe_dec_init(st_fx->hBWE_FD_HR); - } - ELSE - { - st_fx->hBWE_FD_HR = NULL; - } - - /*----------------------------------------------------------------------------------* - * AMR-WB IO mode parameters - *----------------------------------------------------------------------------------*/ - - IF(st_fx->Opt_AMR_WB || EQ_16(st_fx->element_mode, EVS_MONO)) - { - IF((st_fx->hAmrwb_IO = (AMRWB_IO_DEC_HANDLE)count_malloc(sizeof(AMRWB_IO_DEC_DATA))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for AMR-WB IO\n")); - } - -#ifdef ISM_DISABLE // To be removed when fixed version is available. - if ( st_fx->ivas_format != ISM_FORMAT ) + } + ELSE + { + st_fx->hTcxCfg = NULL; + } + + /* Tonal MDCT concealment data structure */ + IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + { + IF( ( st_fx->hTonalMDCTConc = (TonalMDCTConcealPtr) malloc( sizeof( TonalMDCTConceal_INSTANCE ) ) ) == NULL ) { - /* AMR-WB IO init */ - amr_wb_dec_init(st_fx->hAmrwb_IO); - - /* AMR-WB IO HF synth init */ - hf_synth_amr_wb_init(st_fx->hAmrwb_IO); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TonalMDCTConcealment\n" ) ); } -#endif - /* AMR-WB IO init */ - amr_wb_dec_init_fx(st_fx->hAmrwb_IO); - - /* AMR-WB IO HF synth init */ - hf_synth_amr_wb_init_fx(st_fx->hAmrwb_IO); - } - ELSE - { - st_fx->hAmrwb_IO = NULL; - } - - /*-----------------------------------------------------------------* - * channel-aware mode parameters - *-----------------------------------------------------------------*/ - - set16_fx(st_fx->tilt_code_dec_fx, 0, NB_SUBFR16k); - - st_fx->use_partial_copy = 0; - move16(); - st_fx->prev_use_partial_copy = 0; - move16(); - st_fx->rf_flag = 0; - move16(); - st_fx->rf_flag_last = 0; - st_fx->prev_rf_frame_type = 0; - move16(); - st_fx->next_coder_type = 0; - move16(); - - st_fx->rf_target_bits = 0; - move16(); - - st_fx->rf_indx_nelp_fid = 0; - move16(); - st_fx->rf_indx_nelp_iG1 = 0; - move16(); - st_fx->rf_indx_nelp_iG2[0] = 0; - move16(); - st_fx->rf_indx_nelp_iG2[1] = 0; - move16(); - st_fx->rf_indx_tbeGainFr = 0; - move16(); - - - /*-----------------------------------------------------------------* - * Bass post-filter parameters - *-----------------------------------------------------------------*/ - - st_fx->bpf_off = 0; - - IF((idchan == 0 && NE_16(st_fx->element_mode, IVAS_CPE_MDCT)) || EQ_16(st_fx->element_mode, IVAS_CPE_TD)) - { - IF((st_fx->hBPF = (BPF_DEC_HANDLE)malloc(sizeof(BPF_DEC_DATA))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for BPF\n")); - } -#ifndef IVAS_FLOAT_FIXED - bass_psfilter_init(st_fx->hBPF); -#endif - bass_psfilter_init_fx(st_fx->hBPF); - } - ELSE - { - st_fx->hBPF = NULL; - } - - /*-----------------------------------------------------------------* - * FD BPF & resampling tools parameters - *-----------------------------------------------------------------*/ - - IF ((idchan == 0 && NE_16(st_fx->element_mode , IVAS_CPE_MDCT)) || EQ_16(st_fx->element_mode, IVAS_CPE_TD)) - { - /* open analysis for max. SR 48kHz */ - IF ((error = openCldfb_ivas_fx(&st_fx->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS)) != IVAS_ERR_OK) - { - return error; - } - - /* open analysis BPF for max. SR 16kHz */ - IF ((error = openCldfb_ivas_fx(&st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS)) != IVAS_ERR_OK) - { - return error; - } - } - ELSE { - st_fx->cldfbAna = NULL; - st_fx->cldfbBPF = NULL; - } - - /* open synthesis for output SR */ - IF ((error = openCldfb_ivas_fx(&st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs, CLDFB_PROTOTYPE_1_25MS)) != IVAS_ERR_OK) - { - return error; - } - -#if 0//def IVAS_FLOAT_FIXED_TO_BE_REMOVED // To be removed when fixed version is available. - if ((idchan == 0 && st_fx->element_mode != IVAS_CPE_MDCT) || st_fx->element_mode == IVAS_CPE_TD) - { - /* open analysis for max. sampling rate 48kHz */ - if ((error = openCldfb_ivas(&st_fx->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS)) != IVAS_ERR_OK) - { - return error; - } - - /* open analysis BPF for max. internal sampling rate 16kHz */ - if ((error = openCldfb_ivas(&st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS)) != IVAS_ERR_OK) - { - return error; - } - } - else - { - st_fx->cldfbAna = NULL; - st_fx->cldfbBPF = NULL; - } - - /* open synthesis for output sampling rate */ - if ((error = openCldfb_ivas(&st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs, CLDFB_PROTOTYPE_1_25MS)) != IVAS_ERR_OK) - { - return error; - } -#endif + } + ELSE + { + st_fx->hTonalMDCTConc = NULL; + } - st_fx->cldfbSynHB = NULL; + /*-----------------------------------------------------------------* + * IGF + *-----------------------------------------------------------------*/ - st_fx->last_active_bandsToZero_bwdec = 0; - st_fx->perc_bwddec = 0; - st_fx->last_flag_filter_NB = 0; - st_fx->active_frame_cnt_bwddec = 0; - st_fx->total_frame_cnt_bwddec = 0; - set16_fx(st_fx->flag_buffer, 0, 20); - st_fx->avg_nrg_LT = 0; + IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + { + IF( ( st_fx->hIGFDec = (IGF_DEC_INSTANCE_HANDLE) malloc( sizeof( IGFDEC_INSTANCE ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for IGF\n" ) ); + } - /*-----------------------------------------------------------------* - * Noise gate parameters - *-----------------------------------------------------------------*/ + st_fx->igf = 0; + move16(); + init_igf_dec( st_fx->hIGFDec ); + } + ELSE + { + st_fx->hIGFDec = NULL; + } -#ifdef ISM_DISABLE // To be removed when fixed version is available. - if ( st_fx->ivas_format != ISM_FORMAT ) + /*-----------------------------------------------------------------* + * Mode 2 initialization + *-----------------------------------------------------------------*/ + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { - //st_fx->ng_ener_ST = -51.0f; - - //st_fx->old_Es_pred = 0; - //set_f(st_fx->old_Aq_12_8 + 1, 0, M); - //st_fx->old_Aq_12_8[0] = 1; + IF( ( st_fx->hPlcInfo = (T_PLCInfo_HANDLE) malloc( sizeof( T_PLCInfo ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for PLC handle\n" ) ); + } } -#endif -#ifdef IVAS_FLOAT_FIXED - set16_fx(st_fx->old_Aq_12_8_fx + 1, 0, M); - st_fx->old_Aq_12_8_fx[0] = ONE_IN_Q12; -#endif - st_fx->Ng_ener_ST_fx = -13056; - move16(); /*-51 IN Q8*/ - st_fx->old_Es_pred_fx = 0; - move16(); - set16_fx(st_fx->old_Aq_12_8_fx + 1, 0, M); - st_fx->old_Aq_12_8_fx[0] = 4096; - move16(); /*1 in Q12*/ - - /*-----------------------------------------------------------------* - * SC-VBR parameters - *-----------------------------------------------------------------*/ - - IF(EQ_16(st_fx->element_mode, EVS_MONO)) - { - IF((st_fx->hSC_VBR = (SC_VBR_DEC_HANDLE)count_malloc(sizeof(SC_VBR_DEC_DATA))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SC-VBR\n")); - } -#ifndef IVAS_FLOAT_FIXED - if ( st_fx->ivas_format != ISM_FORMAT ) - { - sc_vbr_dec_init_flt(st_fx->hSC_VBR); - } -#endif - sc_vbr_dec_init(st_fx->hSC_VBR); - } - ELSE - { - st_fx->hSC_VBR = NULL; - } - -#ifdef ISM_DISABLE // To be removed when fixed version is available. - if ( st_fx->ivas_format != ISM_FORMAT ) - { - st_fx->last_ppp_mode_dec = 0; - st_fx->old_ppp_mode = 0; - st_fx->ppp_mode_dec = 0; - st_fx->last_nelp_mode_dec = 0; - st_fx->nelp_mode_dec = 0; - //st_fx->prev_gain_pit_dec = 0.0f; - //st_fx->prev_tilt_code_dec = 0.0f; - st_fx->vbr_hw_BWE_disable_dec = 0; - st_fx->last_vbr_hw_BWE_disable_dec = 0; + ELSE + { + st_fx->hPlcInfo = NULL; } -#endif - st_fx->last_ppp_mode_dec = 0; - move16(); - st_fx->old_ppp_mode = 0; - move16(); - st_fx->ppp_mode_dec = 0; - move16(); - st_fx->last_nelp_mode_dec = 0; - move16(); - st_fx->nelp_mode_dec = 0; - move16(); - st_fx->prev_gain_pit_dec_fx = 0; - move16(); - st_fx->prev_tilt_code_dec_fx = 0; - move16(); - st_fx->vbr_hw_BWE_disable_dec = 0; - move16(); - st_fx->last_vbr_hw_BWE_disable_dec = 0; - move16(); - - /*-----------------------------------------------------------------* - * TCX core - *-----------------------------------------------------------------*/ - - /* TCX-LTP */ - IF((idchan == 0 || EQ_16(st_fx->element_mode, IVAS_CPE_MDCT))) - { - IF((st_fx->hTcxLtpDec = (TCX_LTP_DEC_HANDLE)count_malloc(sizeof(TCX_LTP_DEC_DATA))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TCX-LTP handle\n")); - } - } - ELSE - { - st_fx->hTcxLtpDec = NULL; - } - - /* TCX core */ - IF(idchan == 0 || EQ_16(st_fx->element_mode, IVAS_CPE_MDCT)) - { - IF((st_fx->hTcxDec = (TCX_DEC_HANDLE)malloc(sizeof(TCX_DEC_DATA))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxDec\n")); - } - -#ifndef IVAS_FLOAT_FIXED - set_f(st_fx->hTcxDec->FBTCXdelayBuf_float, 0.0f, 111); - // - st_fx->hTcxDec->old_synthFB = st_fx->hTcxDec->synth_history + NS2SA(st_fx->output_Fs, PH_ECU_MEM_NS); - st_fx->hTcxDec->prev_good_synth = st_fx->hTcxDec->old_synthFB + NS2SA(st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS); -#endif - set32_fx(st_fx->hTcxDec->FBTCXdelayBuf_32, 0, 111); - - st_fx->hTcxDec->old_synthFB_fx = st_fx->hTcxDec->synth_history_fx + NS2SA(st_fx->output_Fs, PH_ECU_MEM_NS); - st_fx->hTcxDec->prev_good_synth_fx = st_fx->hTcxDec->old_synthFB_fx + NS2SA(st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS); - } - ELSE - { - st_fx->hTcxDec = NULL; - } - - /* TCX config. data structure */ - IF((idchan == 0 || EQ_16(st_fx->element_mode, IVAS_CPE_MDCT))) - { - IF((st_fx->hTcxCfg = (TCX_CONFIG_HANDLE)count_malloc(sizeof(TCX_config))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n")); - } - } - ELSE - { - st_fx->hTcxCfg = NULL; - } - - /* Tonal MDCT concealment data structure */ - IF((idchan == 0 || EQ_16(st_fx->element_mode, IVAS_CPE_MDCT))) - { - IF ((st_fx->hTonalMDCTConc = (TonalMDCTConcealPtr)malloc(sizeof(TonalMDCTConceal_INSTANCE))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TonalMDCTConcealment\n")); - } - } - ELSE - { - st_fx->hTonalMDCTConc = NULL; - } - - - - /*-----------------------------------------------------------------* - * IGF - *-----------------------------------------------------------------*/ - - IF((idchan == 0 || EQ_16(st_fx->element_mode, IVAS_CPE_MDCT))) - { - IF((st_fx->hIGFDec = (IGF_DEC_INSTANCE_HANDLE)malloc(sizeof(IGFDEC_INSTANCE))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for IGF\n")); - } - - st_fx->igf = 0; - move16(); - init_igf_dec(st_fx->hIGFDec); -#ifdef ISM_DISABLE // To be removed when fixed version is available. - if ( st_fx->ivas_format != ISM_FORMAT ) + + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + IF( ( st_fx->hTECDec = (TEC_DEC_HANDLE) malloc( sizeof( TEC_DEC_DATA ) ) ) == NULL ) { - init_igf_dec_flt(st_fx->hIGFDec); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TEC\n" ) ); } -#endif - } - ELSE - { - st_fx->hIGFDec = NULL; - } - - /*-----------------------------------------------------------------* - * Mode 2 initialization - *-----------------------------------------------------------------*/ - IF(EQ_16(st_fx->element_mode, EVS_MONO)) - { - IF ((st_fx->hPlcInfo = (T_PLCInfo_HANDLE)malloc(sizeof(T_PLCInfo))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for PLC handle\n")); - } - } - ELSE - { - st_fx->hPlcInfo = NULL; - } - - IF(EQ_16(st_fx->element_mode, EVS_MONO)) - { - IF ((st_fx->hTECDec = (TEC_DEC_HANDLE)malloc(sizeof(TEC_DEC_DATA))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TEC\n")); - } - } - ELSE - { - st_fx->hTECDec = NULL; - } - - - - /* Init Decoder */ - Word16 Q_syn_Overl_TDAC = 0, Q_fer_samples = 0, Q_syn_Overl = 0, Q_syn_Overl_TDACFB = 0, Q_syn_OverlFB = 0, Q_old_out = 0, Q_old_outLB = 0, Q_old_Aq_12_8 = 0; - open_decoder_LPD_ivas_fx(st_fx, st_fx->total_brate, st_fx->last_total_brate, st_fx->bwidth, 0, st_fx->element_mode, 1, &Q_syn_Overl_TDAC, &Q_fer_samples, &Q_syn_Overl, &Q_syn_Overl_TDACFB, &Q_syn_OverlFB, &Q_old_out, &Q_old_outLB, &Q_old_Aq_12_8); + } + ELSE + { + st_fx->hTECDec = NULL; + } + + /* Init Decoder */ + Word16 Q_syn_Overl_TDAC = 0, Q_fer_samples = 0, Q_syn_Overl = 0, Q_syn_Overl_TDACFB = 0, Q_syn_OverlFB = 0, Q_old_out = 0, Q_old_outLB = 0, Q_old_Aq_12_8 = 0; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + open_decoder_LPD_ivas_fx( st_fx, st_fx->total_brate, st_fx->last_total_brate, st_fx->bwidth, 0, st_fx->element_mode, 1, &Q_syn_Overl_TDAC, &Q_fer_samples, &Q_syn_Overl, &Q_syn_Overl_TDACFB, &Q_syn_OverlFB, &Q_old_out, &Q_old_outLB, &Q_old_Aq_12_8 ); #ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED // To be removed when fixed version is available. - open_decoder_LPD(st_fx, st_fx->total_brate, st_fx->last_total_brate, st_fx->bwidth, 0, st_fx->element_mode, 1); + open_decoder_LPD( st_fx, st_fx->total_brate, st_fx->last_total_brate, st_fx->bwidth, 0, st_fx->element_mode, 1 ); #endif - /* PLC mode initialization */ - st_fx->m_decodeMode = DEC_NO_FRAM_LOSS; - move16(); - - /* Init bandwidth / frame_type */ - st_fx->m_frame_type = ACTIVE_FRAME; - move16(); - st_fx->m_old_frame_type = ACTIVE_FRAME; - move16(); - - IF ((idchan == 0 && NE_16(st_fx->element_mode, IVAS_CPE_MDCT))) - { - resampleCldfb_ivas_fx(st_fx->cldfbAna, L_mult0( st_fx->L_frame, FRAMES_PER_SEC )); - resampleCldfb_ivas_fx(st_fx->cldfbBPF, L_mult0( st_fx->L_frame, FRAMES_PER_SEC )); -#ifdef ISM_DISABLE // To be removed when fixed version is available. - if ( st_fx->ivas_format != ISM_FORMAT ) + /* PLC mode initialization */ + st_fx->m_decodeMode = DEC_NO_FRAM_LOSS; + move16(); + + /* Init bandwidth / frame_type */ + st_fx->m_frame_type = ACTIVE_FRAME; + move16(); + st_fx->m_old_frame_type = ACTIVE_FRAME; + move16(); + + IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + { + resampleCldfb_ivas_fx( st_fx->cldfbAna, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) ); + resampleCldfb_ivas_fx( st_fx->cldfbBPF, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) ); + } + + /*-----------------------------------------------------------------* + * FD-CNG decoder + *-----------------------------------------------------------------*/ + + IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( idchan, 0 ) ) && NE_16( mc_mode, MC_MODE_MCT ) && NE_16( mc_mode, MC_MODE_PARAMUPMIX ) ) + { + /* Create FD_CNG instance */ + + IF( ( error = createFdCngDec_fx( &st_fx->hFdCngDec ) ) != IVAS_ERR_OK ) { - resampleCldfb_ivas(st_fx->cldfbAna, st_fx->L_frame * FRAMES_PER_SEC); - resampleCldfb_ivas(st_fx->cldfbBPF, st_fx->L_frame * FRAMES_PER_SEC); + return error; } -#endif - } - /*-----------------------------------------------------------------* - * FD-CNG decoder - *-----------------------------------------------------------------*/ + /* Init FD-CNG */ + initFdCngDec_ivas_fx( st_fx, st_fx->cldfbSyn->scale ); + } + ELSE + { + st_fx->hFdCngDec = NULL; + } - IF((EQ_16(st_fx->element_mode, IVAS_CPE_MDCT) || idchan == 0) && NE_16(mc_mode, MC_MODE_MCT) && NE_16(mc_mode, MC_MODE_PARAMUPMIX)) - { - /* Create FD_CNG instance */ + st_fx->cngTDLevel = 0; + move16(); + st_fx->cngTDLevel_e = 0; + move16(); + st_fx->lp_noise = -167772160l /*-20.f Q23*/; + move32(); + st_fx->force_lpd_reset = 0; + move16(); - IF ((error = createFdCngDec_fx(&st_fx->hFdCngDec)) != IVAS_ERR_OK) - { - return error; - } - /* Init FD-CNG */ -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED // To be removed when fixed version is available. - initFdCngDec(st_fx); -#endif - initFdCngDec_ivas_fx(st_fx, st_fx->cldfbSyn->scale); - } - ELSE - { - st_fx->hFdCngDec = NULL; - } - - st_fx->cngTDLevel = 0; - move16(); - st_fx->cngTDLevel_e = 0; - move16(); - st_fx->lp_noise = -167772160l/*-20.f Q23*/; - st_fx->force_lpd_reset = 0; - move16(); - -#ifdef ISM_DISABLE // To be removed when fixed version is available. - //if ( st_fx->ivas_format != ISM_FORMAT ) - //{ - //st_fx->cngTDLevel_float = 0.f; - //st_fx->lp_noise_float = -20.0f; - //} -#endif + /*-----------------------------------------------------------------* + * initialzie Q values + *-----------------------------------------------------------------*/ - /*-----------------------------------------------------------------* - * initialzie Q values - *-----------------------------------------------------------------*/ - - st_fx->Q_syn2 = 0; - move16(); - st_fx->Q_exc = 8; - st_fx->prev_Q_exc = 0; - move16(); - st_fx->Q_syn = 0; - move16(); - st_fx->prev_Q_syn = 0; - move16(); - - FOR(i = 0; i < L_Q_MEM; i++) - { - st_fx->Q_subfr[i] = 8; - move16(); - } + st_fx->Q_syn2 = 0; + move16(); + st_fx->Q_exc = 8; + move16(); + st_fx->prev_Q_exc = 0; + move16(); + st_fx->Q_syn = 0; + move16(); + st_fx->prev_Q_syn = 0; + move16(); - st_fx->prev_Q_exc_fr = 0; - move16(); - st_fx->prev_Q_syn_fr = 0; - move16(); + FOR( i = 0; i < L_Q_MEM; i++ ) + { + st_fx->Q_subfr[i] = 8; + move16(); + } - /*-----------------------------------------------------------------* - * IVAS parameters - *-----------------------------------------------------------------*/ + st_fx->prev_Q_exc_fr = 0; + move16(); + st_fx->prev_Q_syn_fr = 0; + move16(); - st_fx->tdm_LRTD_flag = 0; /* LRTD stereo mode flag */ - st_fx->cna_dirac_flag = 0; /* CNA in DirAC flag */ - st_fx->cng_sba_flag = 0; /* CNG in SBA flag */ - st_fx->cng_ism_flag = 0; + /*-----------------------------------------------------------------* + * IVAS parameters + *-----------------------------------------------------------------*/ - return error; + st_fx->tdm_LRTD_flag = 0; /* LRTD stereo mode flag */ + move16(); + st_fx->cna_dirac_flag = 0; /* CNA in DirAC flag */ + move16(); + st_fx->cng_sba_flag = 0; /* CNG in SBA flag */ + move16(); + st_fx->cng_ism_flag = 0; + move16(); + return error; } - /*----------------------------------------------------------------------* * reset_preecho_dec() * diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index fc2bf862c..e25cfe2bc 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -333,13 +333,6 @@ ivas_error ivas_core_dec( fixedToFloat_arr( sts[k]->hHQ_core->old_out_LB_fx, sts[k]->hHQ_core->old_outLB, 0, L_FRAME32k ); } } - IF( sts[0]->element_mode == IVAS_CPE_MDCT && sts[0]->total_brate == SID_2k40 ) - { - FOR( Word16 ch = 0; ch < CPE_CHANNELS; ++ch ) - { - 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 ); - } - } #endif @@ -634,21 +627,6 @@ ivas_error ivas_core_dec( { sts[ch]->hFdCngDec->msNoiseEst_float[p] = ( (float) sts[ch]->hFdCngDec->msNoiseEst[p] / ( 1u << ( 31 - sts[ch]->hFdCngDec->msNoiseEst_exp ) ) ); } - - for ( int p = 0; p < s_min( 340, sts[ch]->hFdCngDec->hFdCngCom->stopFFTbin - sts[ch]->hFdCngDec->hFdCngCom->startBand ); p++ ) - { - sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[p] = ( (float) sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel[p] / ( 1u << ( 31 - sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) ) ); - } - } - else if ( ( ( sts[ch]->bfi == 1 ) && ( sts[ch]->nbLostCmpt == 1 ) ) && ( sum_f( sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt + sts[ch]->hFdCngDec->hFdCngCom->startBand, sts[ch]->hFdCngDec->hFdCngCom->stopFFTbin - sts[ch]->hFdCngDec->hFdCngCom->startBand ) > 0.01f ) ) - { - if ( sts[ch]->element_mode == IVAS_CPE_MDCT && sts[ch]->core != ACELP_CORE ) - { - for ( int p = 0; p < s_min( 340, sts[ch]->hFdCngDec->hFdCngCom->stopFFTbin - sts[ch]->hFdCngDec->hFdCngCom->startBand ); p++ ) - { - sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[p] = ( (float) sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel[p] / ( 1u << ( 31 - sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) ) ); - } - } } } @@ -722,11 +700,6 @@ ivas_error ivas_core_dec( sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 27; TonalMdctConceal_whiten_noise_shape_ivas_fx( sts[n], L_FRAME16k, ON_FIRST_GOOD_FRAME ); - - for ( int p = 0; p < sts[n]->hFdCngDec->hFdCngCom->stopFFTbin - sts[n]->hFdCngDec->hFdCngCom->startBand; p++ ) - { - sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[p] = (float) sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevel[p] / ( 1u << ( 31 - sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) ); - } } } } diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index e3bb1fe3d..2fa750755 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -589,14 +589,6 @@ ivas_error ivas_cpe_dec_fx( } } - 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); - } - } - #endif /* core decoder */ @@ -658,14 +650,8 @@ ivas_error ivas_cpe_dec_fx( q_dft = hCPE->hStereoDft->q_dft; //TODO : To check this - hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->q_cngNoiseLevel = Q31 - hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp; stereo_dtf_cng_fx( hCPE, ivas_total_brate, DFT_fx, output_frame, q_dft ); - - fixedToFloat_arrL( &hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel[0], - &hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[0], - hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->q_cngNoiseLevel, - FFTCLDFBLEN ); } /* decoding */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 80f3e11ed..5ec1d414c 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -750,14 +750,14 @@ static ivas_error ivas_dirac_rend_config_fx( } ELSE IF( EQ_16( flag_config, DIRAC_RECONFIGURE ) && ( !hDirACRend->proto_signal_decorr_on && proto_signal_decorr_on_old ) ) { - ivas_dirac_dec_decorr_close( &hDirACRend->h_freq_domain_decorr_ap_params, &hDirACRend->h_freq_domain_decorr_ap_state ); + ivas_dirac_dec_decorr_close_fx( &hDirACRend->h_freq_domain_decorr_ap_params, &hDirACRend->h_freq_domain_decorr_ap_state ); } ELSE IF( EQ_16( flag_config, DIRAC_RECONFIGURE ) && hDirACRend->proto_signal_decorr_on && proto_signal_decorr_on_old ) { IF( NE_16( nchan_transport, nchan_transport_old ) || NE_16( hDirACRend->num_outputs_diff, num_outputs_diff_old ) || EQ_16( flag_config_inp, DIRAC_RECONFIGURE_MODE ) ) { /* close and reopen the decorrelator */ - ivas_dirac_dec_decorr_close( &hDirACRend->h_freq_domain_decorr_ap_params, &hDirACRend->h_freq_domain_decorr_ap_state ); + ivas_dirac_dec_decorr_close_fx( &hDirACRend->h_freq_domain_decorr_ap_params, &hDirACRend->h_freq_domain_decorr_ap_state ); #ifdef IVAS_FLOAT_FIXED IF( ( error = ivas_dirac_dec_decorr_open_fx( &( hDirACRend->h_freq_domain_decorr_ap_params ), &( hDirACRend->h_freq_domain_decorr_ap_state ), hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff, hDirACRend->num_protos_diff, hDirACRend->synthesisConf, hDirACRend->frequency_axis_fx, nchan_transport > 2 ? 4 : nchan_transport, output_Fs ) ) != IVAS_ERR_OK ) @@ -1729,7 +1729,7 @@ ivas_error ivas_dirac_dec_config_fx( /* This is required to keep BE in rate switching. This probably means that 1TC and 2TC MASA perform differently. */ IF( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params != NULL && !( st_ivas->ivas_format == MASA_FORMAT && st_ivas->nSCE > 0 ) ) { - ivas_dirac_dec_decorr_close( &st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params, &st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_state ); // done + ivas_dirac_dec_decorr_close_fx( &st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params, &st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_state ); // done } IF( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c index 6aa3e6b78..0e22492ac 100644 --- a/lib_dec/ivas_ism_dtx_dec.c +++ b/lib_dec/ivas_ism_dtx_dec.c @@ -289,8 +289,7 @@ void ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( } return; } -#endif // IVAS_FLOAT_FIXED - +#else void ivas_ism_dtx_limit_noise_energy_for_near_silence( SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder structures */ const int16_t sce_id_dtx, /* i : SCE DTX ID */ @@ -328,3 +327,4 @@ void ivas_ism_dtx_limit_noise_energy_for_near_silence( return; } +#endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 289027ca4..d94f11435 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -233,33 +233,15 @@ ivas_error ivas_jbm_dec_tc( } #ifdef IVAS_FLOAT_FIXED -#if 1 Word16 Q_cngNoiseLevel[MAX_SCE]; - Word16 cng_noise_level_len, ch; - HANDLE_FD_CNG_COM hFdCngCom; - FOR( ch = 0; ch < 4; ch++ ) + FOR( Word16 ch = 0; ch < 4; ch++ ) { IF( st_ivas->hSCE[ch] != NULL ) { - hFdCngCom = st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom; - cng_noise_level_len = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); - Q_cngNoiseLevel[ch] = Q_factor_arrL( hFdCngCom->cngNoiseLevel_flt, cng_noise_level_len ); - floatToFixed_arrL( hFdCngCom->cngNoiseLevel_flt, hFdCngCom->cngNoiseLevel, Q_cngNoiseLevel[ch], cng_noise_level_len ); + Q_cngNoiseLevel[ch] = sub(31, st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp); } } -#endif ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport, Q_cngNoiseLevel ); -#if 1 - FOR( ch = 0; ch < 4; ch++ ) - { - IF( st_ivas->hSCE[ch] != NULL ) - { - hFdCngCom = st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom; - cng_noise_level_len = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); - fixedToFloat_arrL( hFdCngCom->cngNoiseLevel, hFdCngCom->cngNoiseLevel_flt, Q_cngNoiseLevel[ch], cng_noise_level_len ); - } - } -#endif #endif // IVAS_FLOAT_FIXED } ELSE IF( st_ivas->ism_mode == ISM_MODE_PARAM ) @@ -3325,27 +3307,6 @@ void ivas_jbm_dec_feed_tc_to_renderer( { nchan_transport = 1; /* Only one channel transported */ } - - if ( ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag ) || - ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) && ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) ) ) - { - Word32 max_cngNoiseLevel = 0; - Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; - FOR( i = 0; i < FFTCLDFBLEN; i++ ) - { - max_cngNoiseLevel = L_max( L_abs( (Word32) st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[i] ), max_cngNoiseLevel ); - } - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = norm_l( max_cngNoiseLevel ); - - //floatToFixed_arr( st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, Q13, M + 1 ); - - floatToFixed_arrL( st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN ); - - //for ( i = 0; i < FFTLEN; i++ ) - //{ - // st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx[i] = float_to_fix( st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt[i], 15 ); - //} - } #endif ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); @@ -3487,27 +3448,6 @@ void ivas_jbm_dec_feed_tc_to_renderer( { nchan_transport = 1; /* Only one channel transported */ } - - if ( ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag ) || - ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) && ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) ) ) - { - Word32 max_cngNoiseLevel = 0; - Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; - FOR( i = 0; i < FFTCLDFBLEN; i++ ) - { - max_cngNoiseLevel = L_max( L_abs( (Word32) st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[i] ), max_cngNoiseLevel ); - } - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = norm_l( max_cngNoiseLevel ); - - //floatToFixed_arr( st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, Q13, M + 1 ); - - floatToFixed_arrL( st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN ); - - //for ( i = 0; i < FFTLEN; i++ ) - //{ - // st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx[i] = float_to_fix( st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt[i], 15 ); - //} - } #endif ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); #if 1 @@ -3624,27 +3564,6 @@ void ivas_jbm_dec_feed_tc_to_renderer( { nchan_transport = 1; /* Only one channel transported */ } - - if ( ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag ) || - ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) && ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) ) ) - { - Word32 max_cngNoiseLevel = 0; - Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; - FOR( i = 0; i < FFTCLDFBLEN; i++ ) - { - max_cngNoiseLevel = L_max( L_abs( (Word32) st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[i] ), max_cngNoiseLevel ); - } - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = norm_l( max_cngNoiseLevel ); - - //floatToFixed_arr( st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, Q13, M + 1 ); - - floatToFixed_arrL( st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN ); - - //for ( i = 0; i < FFTLEN; i++ ) - //{ - // st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx[i] = float_to_fix( st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt[i], 15 ); - //} - } #endif ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); #if 1 @@ -3692,10 +3611,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( if ( ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag ) || ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) && ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) ) ) { - Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; - //fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, 15, st->hFdCngDec->hFdCngCom->fftlen); - - //fixedToFloat_arrL( st->hFdCngDec->hFdCngCom->exc_cng_32fx, st->hFdCngDec->hFdCngCom->exc_cng_flt, 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp - 9, st->hFdCngDec->hFdCngCom->frameSize ); + Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; fixedToFloat_arrL( st_ivas->hTcBuffer->tc_fx[1], st_ivas->hTcBuffer->tc[1], 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp - 9, st->hFdCngDec->hFdCngCom->frameSize ); } #endif @@ -3763,27 +3679,6 @@ void ivas_jbm_dec_feed_tc_to_renderer( { nchan_transport = 1; /* Only one channel transported */ } - - if ( ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag ) || - ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) && ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) ) ) - { - Word32 max_cngNoiseLevel = 0; - Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; - FOR( i = 0; i < FFTCLDFBLEN; i++ ) - { - max_cngNoiseLevel = L_max( L_abs( (Word32) st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[i] ), max_cngNoiseLevel ); - } - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = norm_l( max_cngNoiseLevel ); - - //floatToFixed_arr( st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, Q13, M + 1 ); - - floatToFixed_arrL( st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN ); - - //for ( i = 0; i < FFTLEN; i++ ) - //{ - // st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx[i] = float_to_fix( st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt[i], 15 ); - //} - } #endif ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); #if 1 @@ -4016,27 +3911,6 @@ void ivas_jbm_dec_feed_tc_to_renderer( { nchan_transport = 1; /* Only one channel transported */ } - - if ( ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag ) || - ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) && ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) ) ) - { - Word32 max_cngNoiseLevel = 0; - Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; - FOR( i = 0; i < FFTCLDFBLEN; i++ ) - { - max_cngNoiseLevel = L_max( L_abs( (Word32) st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[i] ), max_cngNoiseLevel ); - } - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = norm_l( max_cngNoiseLevel ); - - //floatToFixed_arr( st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, Q13, M + 1 ); - - floatToFixed_arrL( st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN ); - - //for ( i = 0; i < FFTLEN; i++ ) - //{ - // st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx[i] = float_to_fix( st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt[i], 15 ); - //} - } #endif ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); #if 1 diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 4d13c4049..c55f1b039 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1512,7 +1512,7 @@ ivas_error ivas_param_mc_dec_reconfig_fx( Word16 len; /* close decorrelator */ - ivas_dirac_dec_decorr_close( &hParamMC->h_freq_domain_decorr_ap_params, &hParamMC->h_freq_domain_decorr_ap_state ); + ivas_dirac_dec_decorr_close_fx( &hParamMC->h_freq_domain_decorr_ap_params, &hParamMC->h_freq_domain_decorr_ap_state ); /* deallocate diffuse prototype info */ IF ( hParamMC->diff_proto_info ) @@ -1586,10 +1586,6 @@ ivas_error ivas_param_mc_dec_reconfig_fx( set_zero_fx( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_1_fx, len ); set_zero_fx( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_2_fx, len ); hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.q_onset_detector = Q31; -#if 1/*To be removed later*/ - set_zero( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_1, len ); - set_zero( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_2, len ); -#endif } } hParamMC->max_band_energy_compensation = hParamMC->band_grouping[hParamMC->hMetadataPMC->nbands_coded]; @@ -2363,7 +2359,7 @@ void ivas_param_mc_dec_close_fx( IF( hParamMC->h_freq_domain_decorr_ap_params != NULL || hParamMC->h_freq_domain_decorr_ap_state != NULL ) { - ivas_dirac_dec_decorr_close( &hParamMC->h_freq_domain_decorr_ap_params, &hParamMC->h_freq_domain_decorr_ap_state ); + ivas_dirac_dec_decorr_close_fx( &hParamMC->h_freq_domain_decorr_ap_params, &hParamMC->h_freq_domain_decorr_ap_state ); } /* parameter decoding */ @@ -4528,10 +4524,6 @@ static void ivas_param_mc_dec_init_fx( set_zero_fx( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_1_fx, len ); set_zero_fx( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_2_fx, len ); hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.q_onset_detector = Q31; -#if 1/*Floating point intialization: to be removed later*/ - set_zero( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_1, len ); - set_zero( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_2, len ); -#endif } max_param_band_residual = 0; diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index b27f665e3..c49a1fac3 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -243,11 +243,6 @@ ivas_error ivas_sce_dec_fx( 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); } - - IF(st->hFdCngDec != NULL && (st->element_mode == IVAS_CPE_MDCT && st->total_brate == SID_2k40)) - { - f2me_buf(st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, &st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, st->hFdCngDec->hFdCngCom->stopBand - st->hFdCngDec->hFdCngCom->startBand); - } #endif set32_fx(output[0], 0, L_FRAME48k); diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index 21fda4add..c103dff09 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -1200,7 +1200,7 @@ static void stereo_dft_generate_comfort_noise_fx( lp_noise = 0; move32(); ptr_level = hFdCngCom->cngNoiseLevel + sub(sub(hFdCngCom->stopFFTbin , hFdCngCom->startBand) , 1); ptr_tmp = cngNoiseLevel_upd + sub(shr(sub( hFdCngCom->stopFFTbin , hFdCngCom->startBand ) , 1) , 1); - rshift_cng = sub(hFdCngCom->q_cngNoiseLevel, sub(shl(q_cngNoiseLevel_upd, 1), Q31)); + rshift_cng = sub(sub(31, hFdCngCom->cngNoiseLevelExp), sub(shl(q_cngNoiseLevel_upd, 1), Q31)); FOR ( i = 0; i < shr(sub( hFdCngCom->stopFFTbin , hFdCngCom->startBand ) , 1); i++ ) { IF (norm_l(*ptr_tmp) >= rshift_cng) @@ -1252,7 +1252,7 @@ static void stereo_dft_generate_comfort_noise_fx( ptr_level = hFdCngCom->cngNoiseLevel; ptr_r = DFT[chan] + hFdCngCom->startBand + k * STEREO_DFT32MS_N_MAX; ptr_i = ptr_r + 1; - q_cngNoiseLevel = hFdCngCom->q_cngNoiseLevel; + q_cngNoiseLevel = sub(Q31, hFdCngCom->cngNoiseLevelExp); FOR( i = 0; i < shr( sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), 1 ); i++ ) { Word16 q_sqrt; @@ -1318,7 +1318,7 @@ static void stereo_dft_generate_comfort_noise_fx( IF( hStereoCng->last_act_element_mode == IVAS_CPE_TD && chan > 0 ) { - Word32 log_lp_noise = L_add( L_shl( sub( Q31, hFdCngCom->q_cngNoiseLevel ), Q25 ), BASOP_Util_Log2( lp_noise + DELTA_FX ) ); + Word32 log_lp_noise = L_add( L_shl( hFdCngCom->cngNoiseLevelExp, Q25 ), BASOP_Util_Log2( lp_noise + DELTA_FX ) ); // log10(x) is computed as log2(x) * log10(2) // log_lp_noise at this stage is in Q25. where as the structure value is in Q23 // Hence the 16-bit constant log10(2) will be stored in Q13 @@ -1329,7 +1329,7 @@ static void stereo_dft_generate_comfort_noise_fx( ELSE IF( EQ_16( chan, 0 ) ) { Word16 q_lp_noise = 0; // st->hFdCngDec->q_lp_noise; // to be populated appropriately. - Word32 log_lp_noise = L_add( L_shl( sub( Q31, hFdCngCom->q_cngNoiseLevel ), Q25 ), BASOP_Util_Log2( lp_noise + DELTA_FX ) ); + Word32 log_lp_noise = L_add( L_shl( hFdCngCom->cngNoiseLevelExp, Q25 ), BASOP_Util_Log2( lp_noise + DELTA_FX ) ); move16(); // log10(x) is computed as log2(x) * log10(2) // log_lp_noise at this stage is in Q25. where as the structure value is in Q23 @@ -1353,7 +1353,7 @@ static void stereo_dft_generate_comfort_noise_fx( /* update smoothed periodogram used by stereo CNA in SID and NO_DATA frames from cngNoiseLevel_flt */ FOR( i = hFdCngCom->startBand; i < hFdCngCom->stopFFTbin; i++ ) { - Word16 l_shift_val = sub(st->hFdCngDec->q_smoothed_psd, hFdCngCom->q_cngNoiseLevel); + Word16 l_shift_val = sub(st->hFdCngDec->q_smoothed_psd, sub(Q31, hFdCngCom->cngNoiseLevelExp)); move16(); l_shift_val = max_smoothed_psd == 0 ? 0 :l_shift_val; ftmp = hFdCngCom->cngNoiseLevel[i - hFdCngCom->startBand]; diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index 744bfea7b..328cfaab7 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -1836,7 +1836,7 @@ static bool shrink_frm( frm_in += l_frm; #ifdef IVAS_FLOAT_FIXED - Word16 frm_in_fx[960*4]; + Word16 frm_in_fx[APA_BUF]; for ( i = 0; i < l_frm/*960*ps->num_channels*/; i++ ) { frm_in_fx[i] = (Word16) frm_in[i]; diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index 640e19ee7..d709b697f 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -149,16 +149,28 @@ ivas_error TonalMDCTConceal_Init_ivas_fx( hTonalMDCTConc->tcx_cfg = hTcxCfg; hTonalMDCTConc->lastBlockData.spectralData = hTonalMDCTConc->spectralDataBuffers[0]; +#ifdef MSAN_FIX + set_s(hTonalMDCTConc->lastBlockData.spectralData, 0, L_FRAME_MAX); +#endif move16(); hTonalMDCTConc->secondLastBlockData.spectralData = hTonalMDCTConc->spectralDataBuffers[1]; +#ifdef MSAN_FIX + set_s( hTonalMDCTConc->secondLastBlockData.spectralData, 0, L_FRAME_MAX ); +#endif move16(); hTonalMDCTConc->secondLastPowerSpectrum = hTonalMDCTConc->secondLastBlockData.spectralData; move16(); hTonalMDCTConc->secondLastPowerSpectrum_exp = hTonalMDCTConc->secondLastBlockData.spectralData_exp; move16(); hTonalMDCTConc->lastBlockData.scaleFactors = hTonalMDCTConc->scaleFactorsBuffers[0]; +#ifdef MSAN_FIX + set_s(hTonalMDCTConc->lastBlockData.scaleFactors, 0, FDNS_NPTS); +#endif move16(); hTonalMDCTConc->secondLastBlockData.scaleFactors = hTonalMDCTConc->scaleFactorsBuffers[1]; +#ifdef MSAN_FIX + set_s(hTonalMDCTConc->secondLastBlockData.scaleFactors, 0, FDNS_NPTS); +#endif move16(); hTonalMDCTConc->lastBlockData.scaleFactors_exp = hTonalMDCTConc->scaleFactorsBuffers_exp[0]; move16(); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 3fb71bb4d..15a45f4a7 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -481,7 +481,7 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( if ( hDiracDecBin->h_freq_domain_decorr_ap_params != NULL ) { - ivas_dirac_dec_decorr_close( &hDiracDecBin->h_freq_domain_decorr_ap_params, &hDiracDecBin->h_freq_domain_decorr_ap_state ); + ivas_dirac_dec_decorr_close_fx( &hDiracDecBin->h_freq_domain_decorr_ap_params, &hDiracDecBin->h_freq_domain_decorr_ap_state ); } if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( hDiracDecBin->hTdDecorr ), &( hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) @@ -563,7 +563,7 @@ void ivas_dirac_dec_close_binaural_data( ivas_td_decorr_dec_close( &( ( *hBinaural )->hTdDecorr ) ); IF( ( *hBinaural )->h_freq_domain_decorr_ap_params != NULL ) { - ivas_dirac_dec_decorr_close( &( *hBinaural )->h_freq_domain_decorr_ap_params, &( *hBinaural )->h_freq_domain_decorr_ap_state ); + ivas_dirac_dec_decorr_close_fx( &( *hBinaural )->h_freq_domain_decorr_ap_params, &( *hBinaural )->h_freq_domain_decorr_ap_state ); } free( *hBinaural ); @@ -1118,7 +1118,6 @@ static void ivas_dirac_dec_binaural_internal( const int16_t subframe ) { #if 1 - double maxim = 0; Word16 q_input = 11; #ifdef MSAN_FIX_ Word16 nchan_tc; @@ -1167,21 +1166,6 @@ static void ivas_dirac_dec_binaural_internal( IF( abs_s( (Word16) st_ivas->cldfbAnaDec[1]->scale_flt ) != 0 ) st_ivas->cldfbAnaDec[1]->q_scale = norm_s( (Word16) st_ivas->cldfbAnaDec[1]->scale_flt ); st_ivas->cldfbAnaDec[1]->scale = (Word16) ( st_ivas->cldfbAnaDec[1]->scale_flt * ( 1 << st_ivas->cldfbAnaDec[1]->q_scale ) ); - maxim = 0; - IF( st_ivas->hSCE[0] && st_ivas->hSCE[0]->hCoreCoder[0] ) - FOR( Word16 ind = 0; ind < FFTCLDFBLEN; ind++ ) - { - maxim = fmax( maxim, fabs( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[ind] ) ); - } - IF( st_ivas->hSCE[0] && st_ivas->hSCE[0]->hCoreCoder[0] ) - st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0; - IF( st_ivas->hSCE[0] && st_ivas->hSCE[0]->hCoreCoder[0] && L_abs( (Word32) maxim ) != 0 ) - st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 31 - norm_l( (Word32) maxim ); - IF( st_ivas->hSCE[0] && st_ivas->hSCE[0]->hCoreCoder[0] ) - FOR( Word16 ind = 0; ind < FFTCLDFBLEN; ind++ ) - { - st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel[ind] = (Word32) ( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[ind] * ( 1LL << ( 31 - st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) ) ); - } Word16 q_cldfb[6][CLDFB_SLOTS_PER_SUBFRAME] = { 0 }; FOR( Word16 ind = 0; ind < 6; ind++ ) { diff --git a/lib_rend/ivas_dirac_decorr_dec.c b/lib_rend/ivas_dirac_decorr_dec.c index 607bbce5e..b476af9e3 100644 --- a/lib_rend/ivas_dirac_decorr_dec.c +++ b/lib_rend/ivas_dirac_decorr_dec.c @@ -1493,6 +1493,181 @@ void ivas_dirac_dec_decorr_process_fx( * *------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void ivas_dirac_dec_decorr_close_fx( + HANDLE_DIRAC_DECORR_PARAMS *ph_freq_domain_decorr_ap_params, + HANDLE_DIRAC_DECORR_STATE *ph_freq_domain_decorr_ap_state) +{ + DIRAC_ONSET_DETECTION_STATE *dirac_onset_detection_state; + + /*-----------------------------------------------------------------* + * check input handles + *-----------------------------------------------------------------*/ + + if (ph_freq_domain_decorr_ap_params == NULL || ph_freq_domain_decorr_ap_state == NULL) + { + return; + } + + if (*ph_freq_domain_decorr_ap_params == NULL || *ph_freq_domain_decorr_ap_state == NULL) + { + return; + } + + /*-----------------------------------------------------------------* + * free onset filter arrays + *-----------------------------------------------------------------*/ + + dirac_onset_detection_state = &(*ph_freq_domain_decorr_ap_state)->h_onset_detection_power_state; + +#ifdef IVAS_FLOAT_FIXED + IF(dirac_onset_detection_state->onset_detector_1_fx != NULL) + { + free(dirac_onset_detection_state->onset_detector_1_fx); + dirac_onset_detection_state->onset_detector_1_fx = NULL; + } + + IF(dirac_onset_detection_state->onset_detector_2_fx != NULL) + { + free(dirac_onset_detection_state->onset_detector_2_fx); + dirac_onset_detection_state->onset_detector_2_fx = NULL; + } +#endif + + /*-----------------------------------------------------------------* + * memory deallocation + *-----------------------------------------------------------------*/ + + /* free decorrelation buffer */ + if ((*ph_freq_domain_decorr_ap_state)->decorr_buffer != NULL) + { + free((*ph_freq_domain_decorr_ap_state)->decorr_buffer); + (*ph_freq_domain_decorr_ap_state)->decorr_buffer = NULL; + } + + /* free ducker smoothed direct energy buffer */ + if ((*ph_freq_domain_decorr_ap_state)->direct_energy_smooth != NULL) + { + free((*ph_freq_domain_decorr_ap_state)->direct_energy_smooth); + (*ph_freq_domain_decorr_ap_state)->direct_energy_smooth = NULL; + } + + /* free ducker smoothed reverb energy buffer */ + if ((*ph_freq_domain_decorr_ap_state)->reverb_energy_smooth != NULL) + { + free((*ph_freq_domain_decorr_ap_state)->reverb_energy_smooth); + (*ph_freq_domain_decorr_ap_state)->reverb_energy_smooth = NULL; + } + +#ifdef IVAS_FLOAT_FIXED + IF((*ph_freq_domain_decorr_ap_state)->decorr_buffer_fx != NULL) + { + free((*ph_freq_domain_decorr_ap_state)->decorr_buffer_fx); + (*ph_freq_domain_decorr_ap_state)->decorr_buffer_fx = NULL; + } + + /* free ducker smoothed direct energy buffer */ + IF((*ph_freq_domain_decorr_ap_state)->direct_energy_smooth_fx != NULL) + { + free((*ph_freq_domain_decorr_ap_state)->direct_energy_smooth_fx); + (*ph_freq_domain_decorr_ap_state)->direct_energy_smooth_fx = NULL; + } + + /* free ducker smoothed reverb energy buffer */ + IF((*ph_freq_domain_decorr_ap_state)->reverb_energy_smooth_fx != NULL) + { + free((*ph_freq_domain_decorr_ap_state)->reverb_energy_smooth_fx); + (*ph_freq_domain_decorr_ap_state)->reverb_energy_smooth_fx = NULL; + } +#endif + + /* free pre-delay param buffer */ + if ((*ph_freq_domain_decorr_ap_params)->pre_delay != NULL) + { + free((*ph_freq_domain_decorr_ap_params)->pre_delay); + (*ph_freq_domain_decorr_ap_params)->pre_delay = NULL; + } + + /* free filter length param buffer */ + if ((*ph_freq_domain_decorr_ap_params)->filter_length != NULL) + { + free((*ph_freq_domain_decorr_ap_params)->filter_length); + (*ph_freq_domain_decorr_ap_params)->filter_length = NULL; + } + + /* free filter coeff param buffers */ + if ((*ph_freq_domain_decorr_ap_params)->filter_coeff_num_real != NULL) + { + free((*ph_freq_domain_decorr_ap_params)->filter_coeff_num_real); + (*ph_freq_domain_decorr_ap_params)->filter_coeff_num_real = NULL; + } + + /* free pre-delay param buffer */ + if ((*ph_freq_domain_decorr_ap_params)->filter_coeff_den_real != NULL) + { + free((*ph_freq_domain_decorr_ap_params)->filter_coeff_den_real); + (*ph_freq_domain_decorr_ap_params)->filter_coeff_den_real = NULL; + } + + /* free pre-delay param buffer */ + if ((*ph_freq_domain_decorr_ap_params)->phase_coeff_imag != NULL) + { + free((*ph_freq_domain_decorr_ap_params)->phase_coeff_imag); + (*ph_freq_domain_decorr_ap_params)->phase_coeff_imag = NULL; + } + + /* free pre-delay param buffer */ + if ((*ph_freq_domain_decorr_ap_params)->phase_coeff_real != NULL) + { + free((*ph_freq_domain_decorr_ap_params)->phase_coeff_real); + (*ph_freq_domain_decorr_ap_params)->phase_coeff_real = NULL; + } + + /* free pre-delay param buffer */ + if ((*ph_freq_domain_decorr_ap_params)->split_frequency_bands != NULL) + { + free((*ph_freq_domain_decorr_ap_params)->split_frequency_bands); + (*ph_freq_domain_decorr_ap_params)->split_frequency_bands = NULL; + } + +#ifdef IVAS_FLOAT_FIXED + IF((*ph_freq_domain_decorr_ap_params)->filter_coeff_num_real_fx != NULL) + { + free((*ph_freq_domain_decorr_ap_params)->filter_coeff_num_real_fx); + (*ph_freq_domain_decorr_ap_params)->filter_coeff_num_real_fx = NULL; + } + + IF((*ph_freq_domain_decorr_ap_params)->filter_coeff_den_real_fx != NULL) + { + free((*ph_freq_domain_decorr_ap_params)->filter_coeff_den_real_fx); + (*ph_freq_domain_decorr_ap_params)->filter_coeff_den_real_fx = NULL; + } + + /* free pre-delay param buffer */ + IF((*ph_freq_domain_decorr_ap_params)->phase_coeff_imag_fx != NULL) + { + free((*ph_freq_domain_decorr_ap_params)->phase_coeff_imag_fx); + (*ph_freq_domain_decorr_ap_params)->phase_coeff_imag_fx = NULL; + } + + /* free pre-delay param buffer */ + IF((*ph_freq_domain_decorr_ap_params)->phase_coeff_real_fx != NULL) + { + free((*ph_freq_domain_decorr_ap_params)->phase_coeff_real_fx); + (*ph_freq_domain_decorr_ap_params)->phase_coeff_real_fx = NULL; + } +#endif + /* free pointers to state and parameter structs */ + free(*ph_freq_domain_decorr_ap_params); + *ph_freq_domain_decorr_ap_params = NULL; + + free(*ph_freq_domain_decorr_ap_state); + *ph_freq_domain_decorr_ap_state = NULL; + + return; +} +#else + void ivas_dirac_dec_decorr_close( HANDLE_DIRAC_DECORR_PARAMS *ph_freq_domain_decorr_ap_params, HANDLE_DIRAC_DECORR_STATE *ph_freq_domain_decorr_ap_state ) @@ -1530,19 +1705,6 @@ void ivas_dirac_dec_decorr_close( free(dirac_onset_detection_state->onset_detector_2); dirac_onset_detection_state->onset_detector_2 = NULL; } -#ifdef IVAS_FLOAT_FIXED - IF( dirac_onset_detection_state->onset_detector_1_fx != NULL ) - { - free( dirac_onset_detection_state->onset_detector_1_fx ); - dirac_onset_detection_state->onset_detector_1_fx = NULL; - } - - IF( dirac_onset_detection_state->onset_detector_2_fx != NULL ) - { - free( dirac_onset_detection_state->onset_detector_2_fx ); - dirac_onset_detection_state->onset_detector_2_fx = NULL; - } -#endif /*-----------------------------------------------------------------* * memory deallocation @@ -1569,28 +1731,6 @@ void ivas_dirac_dec_decorr_close( (*ph_freq_domain_decorr_ap_state)->reverb_energy_smooth = NULL; } -#ifdef IVAS_FLOAT_FIXED - IF( ( *ph_freq_domain_decorr_ap_state )->decorr_buffer_fx != NULL ) - { - free( ( *ph_freq_domain_decorr_ap_state )->decorr_buffer_fx ); - ( *ph_freq_domain_decorr_ap_state )->decorr_buffer_fx = NULL; - } - - /* free ducker smoothed direct energy buffer */ - IF( ( *ph_freq_domain_decorr_ap_state )->direct_energy_smooth_fx != NULL ) - { - free( ( *ph_freq_domain_decorr_ap_state )->direct_energy_smooth_fx ); - ( *ph_freq_domain_decorr_ap_state )->direct_energy_smooth_fx = NULL; - } - - /* free ducker smoothed reverb energy buffer */ - IF( ( *ph_freq_domain_decorr_ap_state )->reverb_energy_smooth_fx != NULL ) - { - free( ( *ph_freq_domain_decorr_ap_state )->reverb_energy_smooth_fx ); - ( *ph_freq_domain_decorr_ap_state )->reverb_energy_smooth_fx = NULL; - } -#endif - /* free pre-delay param buffer */ if ((*ph_freq_domain_decorr_ap_params)->pre_delay != NULL) { @@ -1640,33 +1780,6 @@ void ivas_dirac_dec_decorr_close( (*ph_freq_domain_decorr_ap_params)->split_frequency_bands = NULL; } -#ifdef IVAS_FLOAT_FIXED - IF( ( *ph_freq_domain_decorr_ap_params )->filter_coeff_num_real_fx != NULL ) - { - free( ( *ph_freq_domain_decorr_ap_params )->filter_coeff_num_real_fx ); - ( *ph_freq_domain_decorr_ap_params )->filter_coeff_num_real_fx = NULL; - } - - IF( ( *ph_freq_domain_decorr_ap_params )->filter_coeff_den_real_fx != NULL ) - { - free( ( *ph_freq_domain_decorr_ap_params )->filter_coeff_den_real_fx ); - ( *ph_freq_domain_decorr_ap_params )->filter_coeff_den_real_fx = NULL; - } - - /* free pre-delay param buffer */ - IF( ( *ph_freq_domain_decorr_ap_params )->phase_coeff_imag_fx != NULL ) - { - free( ( *ph_freq_domain_decorr_ap_params )->phase_coeff_imag_fx ); - ( *ph_freq_domain_decorr_ap_params )->phase_coeff_imag_fx = NULL; - } - - /* free pre-delay param buffer */ - IF( ( *ph_freq_domain_decorr_ap_params )->phase_coeff_real_fx != NULL ) - { - free( ( *ph_freq_domain_decorr_ap_params )->phase_coeff_real_fx ); - ( *ph_freq_domain_decorr_ap_params )->phase_coeff_real_fx = NULL; - } -#endif /* free pointers to state and parameter structs */ free(*ph_freq_domain_decorr_ap_params); *ph_freq_domain_decorr_ap_params = NULL; @@ -1677,6 +1790,7 @@ void ivas_dirac_dec_decorr_close( return; } +#endif // IVAS_FLOAT_FIXED /*------------------------------------------------------------------------- * Local functions *------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_dirac_onsets_dec.c b/lib_rend/ivas_dirac_onsets_dec.c index d2aec25dd..0f0eb51a4 100644 --- a/lib_rend/ivas_dirac_onsets_dec.c +++ b/lib_rend/ivas_dirac_onsets_dec.c @@ -164,21 +164,6 @@ ivas_error ivas_dirac_dec_onset_detection_open( dirac_onset_detection_params->max_band_decorr = max_band_decorr; /* memory allocation */ -#ifdef IVAS_FLOAT_FIXED - IF((dirac_onset_detection_state->onset_detector_1_fx = (Word32 *)malloc(sizeof(Word32) * num_protos_diff * dirac_onset_detection_params->max_band_decorr)) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for onset detection\n")); - } - IF((dirac_onset_detection_state->onset_detector_2_fx = (Word32 *)malloc(sizeof(Word32) * num_protos_diff * dirac_onset_detection_params->max_band_decorr)) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for onset detection\n")); - } - /* init to zero */ - set32_fx(dirac_onset_detection_state->onset_detector_1_fx, 0, num_protos_diff * dirac_onset_detection_params->max_band_decorr); - set32_fx(dirac_onset_detection_state->onset_detector_2_fx, 0, num_protos_diff * dirac_onset_detection_params->max_band_decorr); - dirac_onset_detection_state->q_onset_detector = Q31; -#endif - /*to be cleand up*/ IF((dirac_onset_detection_state->onset_detector_1 = (float *)malloc(sizeof(float) * num_protos_diff * dirac_onset_detection_params->max_band_decorr)) == NULL) { return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for onset detection\n")); @@ -214,7 +199,7 @@ ivas_error ivas_dirac_dec_onset_detection_open_fx( dirac_onset_detection_params->max_band_decorr = max_band_decorr; /* memory allocation */ -#ifdef IVAS_FLOAT_FIXED + IF( ( dirac_onset_detection_state->onset_detector_1_fx = (Word32 *) malloc( sizeof( Word32 ) * num_protos_diff * dirac_onset_detection_params->max_band_decorr ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for onset detection\n" ) ); @@ -227,20 +212,6 @@ ivas_error ivas_dirac_dec_onset_detection_open_fx( set32_fx(dirac_onset_detection_state->onset_detector_1_fx, 0, num_protos_diff * dirac_onset_detection_params->max_band_decorr); set32_fx(dirac_onset_detection_state->onset_detector_2_fx, 0, num_protos_diff * dirac_onset_detection_params->max_band_decorr); dirac_onset_detection_state->q_onset_detector = Q31; -#endif - /*to be cleand up*/ - IF( ( dirac_onset_detection_state->onset_detector_1 = (float *) malloc( sizeof( float ) * num_protos_diff * dirac_onset_detection_params->max_band_decorr ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for onset detection\n" ) ); - } - IF( ( dirac_onset_detection_state->onset_detector_2 = (float *) malloc( sizeof( float ) * num_protos_diff * dirac_onset_detection_params->max_band_decorr ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for onset detection\n" ) ); - } - - /* init to zero */ - set_zero( dirac_onset_detection_state->onset_detector_1, num_protos_diff * dirac_onset_detection_params->max_band_decorr ); - set_zero( dirac_onset_detection_state->onset_detector_2, num_protos_diff * dirac_onset_detection_params->max_band_decorr ); return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 421048ba9..67f70250c 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -102,8 +102,9 @@ static void normalizePanningGains_fx( Word32 *direct_response_fx, Word16 *q_dire #endif #ifndef IVAS_FLOAT_FIXED static void spreadCoherencePanningHoa( const int16_t azimuth, const int16_t elevation, const float spreadCoh, float *direct_response, const int16_t num_channels_dir, const int16_t ambisonics_order ); - +#ifndef IVAS_FLOAT_FIXED static void spreadCoherencePanningVbap( const int16_t azimuth, const int16_t elevation, const float spreadCoh, float *direct_response, const int16_t num_channels_dir, const VBAP_HANDLE hVBAPdata ); +#endif // !IVAS_FLOAT_FIXED static void normalizePanningGains( float *direct_response, const int16_t num_channels_dir ); #endif diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 50a0bbcc5..ef12aa814 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -447,7 +447,6 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx( hSpatParamRendCom->subframes_rendered = 0; hSpatParamRendCom->slots_rendered = 0; hSpatParamRendCom->num_slots = DEFAULT_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME; - hSpatParamRendCom->num_freq_bands = (int16_t) ( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ); var1 = BASOP_Util_Divide3232_Scale(output_Fs, CLDFB_BANDWIDTH, &exp_tmp3); var2 = shl(1, 15 - exp_tmp3 - 1 ); hSpatParamRendCom->num_freq_bands = shr(add(var1, var2), 15 - exp_tmp3); @@ -464,22 +463,14 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx( { IF( hodirac_flag && hSpatParamRendCom->azimuth2 == NULL ) { -#ifdef IVAS_FLOAT_FIXED if ( ( error = ivas_dirac_allocate_parameters_fx( hSpatParamRendCom, 2 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_dirac_allocate_parameters( hSpatParamRendCom, 2 ) ) != IVAS_ERR_OK ) -#endif { return error; } } ELSE IF( !hodirac_flag && hSpatParamRendCom->azimuth2 != NULL ) { -#ifdef IVAS_FLOAT_FIXED ivas_dirac_deallocate_parameters_fx( hSpatParamRendCom, 2 ); -#else - ivas_dirac_deallocate_parameters( hSpatParamRendCom, 2 ); -#endif } } @@ -523,31 +514,18 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx( hSpatParamRendCom->render_to_md_map[map_idx] = hSpatParamRendCom->dirac_read_idx + map_idx / num_slots_in_subfr; } } -#ifdef IVAS_FLOAT_FIXED + IF( ( error = ivas_dirac_allocate_parameters_fx( hSpatParamRendCom, 1 ) ) != IVAS_ERR_OK ) { return error; } -#else - if ( ( error = ivas_dirac_allocate_parameters( hSpatParamRendCom, 1 ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif IF( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT || ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && hodirac_flag ) ) { -#ifdef IVAS_FLOAT_FIXED IF( ( error = ivas_dirac_allocate_parameters_fx( hSpatParamRendCom, 2 ) ) != IVAS_ERR_OK ) { return error; } -#else - if ( ( error = ivas_dirac_allocate_parameters( hSpatParamRendCom, 2 ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif } ELSE { @@ -769,7 +747,7 @@ void ivas_dirac_rend_close_fx( /* close Decorrelator sub-module */ IF (hDirACRend->proto_signal_decorr_on) { - ivas_dirac_dec_decorr_close(&hDirACRend->h_freq_domain_decorr_ap_params, &hDirACRend->h_freq_domain_decorr_ap_state); + ivas_dirac_dec_decorr_close_fx(&hDirACRend->h_freq_domain_decorr_ap_params, &hDirACRend->h_freq_domain_decorr_ap_state); } /* Params */ @@ -890,7 +868,7 @@ void ivas_dirac_rend_close_fx( return; } -#endif +#else void ivas_dirac_rend_close( DIRAC_REND_HANDLE *hDirACRend_out ) @@ -923,15 +901,6 @@ void ivas_dirac_rend_close( hDirACRend->frequency_axis = NULL; } - // this should be removed when close_fx is called// -#ifdef IVAS_FLOAT_FIXED - IF( hDirACRend->frequency_axis_fx != NULL ) - { - free( hDirACRend->frequency_axis_fx ); - hDirACRend->frequency_axis_fx = NULL; - } -#endif - if ( hDirACRend->diffuse_response_function != NULL ) { free( hDirACRend->diffuse_response_function ); @@ -943,13 +912,6 @@ void ivas_dirac_rend_close( free( hDirACRend->hoa_encoder ); hDirACRend->hoa_encoder = NULL; } -#ifdef IVAS_FLOAT_FIXED - IF( hDirACRend->hoa_encoder_fx != NULL ) - { - free( hDirACRend->hoa_encoder_fx ); - hDirACRend->hoa_encoder_fx = NULL; - } -#endif /* prototype indexing */ if ( hDirACRend->proto_index_dir != NULL ) @@ -1003,7 +965,7 @@ void ivas_dirac_rend_close( return; } - +#endif /*------------------------------------------------------------------------- * ivas_dirac_deallocate_parameters() * diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 6cdabb683..59657b592 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -774,6 +774,13 @@ void ivas_dirac_dec_decorr_close( HANDLE_DIRAC_DECORR_PARAMS *ph_dirac_decorr_params, HANDLE_DIRAC_DECORR_STATE *ph_dirac_decorr_state ); +#ifdef IVAS_FLOAT_FIXED +void ivas_dirac_dec_decorr_close_fx( + HANDLE_DIRAC_DECORR_PARAMS *ph_dirac_decorr_params, + HANDLE_DIRAC_DECORR_STATE *ph_dirac_decorr_state +); +#endif // IVAS_FLOAT_FIXED + ivas_error ivas_dirac_dec_output_synthesis_open( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 33874261e..4c5c7da2e 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -3317,6 +3317,13 @@ void SHrotmatgen_fx( move32(); Word16 R_lm1[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM]; + +#ifdef MSAN_FIX + FOR(i = 0; i < HEADROT_SHMAT_DIM; i++) + { + set_s(R_lm1[i], 0, HEADROT_SHMAT_DIM); + } +#endif Word16 R_l[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM]; Word32 result; SHrotmat[0][0] = ONE_IN_Q14; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index aba41dfe4..ce3c64321 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -13932,7 +13932,11 @@ static void freeMasaExtRenderer( if ( hMasaExtRend->hDirACRend != NULL ) { +#ifdef IVAS_FLOAT_FIXED + ivas_dirac_rend_close_fx( &hMasaExtRend->hDirACRend ); +#else ivas_dirac_rend_close( &hMasaExtRend->hDirACRend ); +#endif // IVAS_FLOAT_FIXED } if ( hMasaExtRend->hSpatParamRendCom != NULL ) -- GitLab