diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index 8859370e3f1f899c3c862c9303e76685defd3323..10a30424705a4801e10c3e3f805731ed1a3cbdc8 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -856,12 +856,12 @@ void cldfbAnalysis_ts_fx( /* FFT of DST IV */ Word16 q_shift; - q_shift = sub(s_min(getScaleFactor32(rBuffer_fx, 2 * CLDFB_NO_CHANNELS_MAX), getScaleFactor32(iBuffer_fx, 2 * CLDFB_NO_CHANNELS_MAX)), find_guarded_bits_fx(M2)); + q_shift = sub(s_min(getScaleFactor32(rBuffer_fx, 2 * M2), getScaleFactor32(iBuffer_fx, 2 * M2)), find_guarded_bits_fx(M2)); *q_cldfb = add(*q_cldfb, q_shift); - for (Word16 ind = 0; ind < 2 * CLDFB_NO_CHANNELS_MAX; ind++) { + for (Word16 ind = 0; ind < 2 * M2; ind++) { rBuffer_fx[ind] = L_shl(rBuffer_fx[ind], q_shift); } - for (Word16 ind = 0; ind < 2 * CLDFB_NO_CHANNELS_MAX; ind++) { + for (Word16 ind = 0; ind < 2 * M2; ind++) { iBuffer_fx[ind] = L_shl(iBuffer_fx[ind], q_shift); } fft_cldfb_fx( rBuffer_fx, M2 ); @@ -878,12 +878,12 @@ void cldfbAnalysis_ts_fx( /* FFT of DCT IV */ fft_cldfb_fx( iBuffer_fx, M2 ); - q_shift = s_min(getScaleFactor32(rBuffer_fx, 2 * CLDFB_NO_CHANNELS_MAX), getScaleFactor32(iBuffer_fx, 2 * CLDFB_NO_CHANNELS_MAX)); + q_shift = s_min(getScaleFactor32(rBuffer_fx, 2 * M2), getScaleFactor32(iBuffer_fx, 2 * M2)); *q_cldfb = add(*q_cldfb, q_shift); - for (Word16 ind = 0; ind < 2 * CLDFB_NO_CHANNELS_MAX; ind++) { + for (Word16 ind = 0; ind < 2 * M2; ind++) { rBuffer_fx[ind] = L_shl(rBuffer_fx[ind], q_shift); } - for (Word16 ind = 0; ind < 2 * CLDFB_NO_CHANNELS_MAX; ind++) { + for (Word16 ind = 0; ind < 2 * M2; ind++) { iBuffer_fx[ind] = L_shl(iBuffer_fx[ind], q_shift); } diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index e2fdcf85362fa7f7d45490ff754f3b152572a9f2..a559680b14e7dace47fc73014a37dfd1a4c3ee27 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -163,6 +163,7 @@ void ivas_initFdCngCom_fx( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale ) set32_fx( hFdCngCom->olapBufferSynth_fx, 0, FFTLEN ); set32_fx( hFdCngCom->olapBufferSynth2_fx, 0, FFTLEN ); set32_fx( hFdCngCom->exc_cng_32fx, 0, L_FRAME16k ); + set16_fx( hFdCngCom->exc_cng, 0, L_FRAME16k ); hFdCngCom->likelihood_noisy_speech_32fx = 0; move32(); diff --git a/lib_com/float_to_fix_ops.c b/lib_com/float_to_fix_ops.c index ebc877ac056d54013a815e86bb514229b4e5e91e..3620d6fe7c5223ab77dc7c854b2f59e99cefc3e7 100644 --- a/lib_com/float_to_fix_ops.c +++ b/lib_com/float_to_fix_ops.c @@ -269,15 +269,12 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( //H_IGF_INFO hIGFInfo = &hPrivateData->igfInfo; //ACELP_config *pConfigAcelp = &( st->acelp_cfg ); Word16 i = 0, - Q_old_synth = 0, Q_syn = 0, Q_synth_history = 0, /*Q_fer_samples = 0,*/ + Q_old_synth = 0, Q_syn = 0,/* Q_synth_history = 0,*/ /*Q_fer_samples = 0,*/ Q_cldfbAna_cldfb_state = 0, Q_cldfbBPF_cldfb_state = 0, Q_cldfbSyn_cldfb_state = 0, Q_cldfbSynHB_cldfb_state = 0;//, //Q_pst_old_syn = 0, //delay_comp = 0; Word16 Q_lsf_cng = Q_factor( 6400 ); - Word16 Q_tcxltp_mem_in = 0, Q_tcxltp_mem_out = 0; - TD_BWE_DEC_HANDLE hBWE_TD = st->hBWE_TD; - Word16 Q_state_lsyn_filt_shb = 0, Q_state_lsyn_filt_dwn_shb = 0, Q_mem_resamp_HB = 0, Q_syn_overlap = 0, Q_int_3_over_2_tbemem_dec = 0, Q_mem_resamp_HB_32k = 0/*, Q_prev_fb_ener_adjust = 0 */; if ( tofix ) { @@ -497,9 +494,6 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( //Q_pst_old_syn = 0, //delay_comp = 0; - Word16 Q_tcxltp_mem_in = 0, Q_tcxltp_mem_out = 0; - TD_BWE_DEC_HANDLE hBWE_TD = st->hBWE_TD; - Word16 Q_state_lsyn_filt_shb = 0, Q_state_lsyn_filt_dwn_shb = 0, Q_mem_resamp_HB = 0, Q_syn_overlap = 0, Q_int_3_over_2_tbemem_dec = 0, Q_mem_resamp_HB_32k = 0/*, Q_prev_fb_ener_adjust = 0*/; if ( tofix ) { @@ -791,7 +785,7 @@ void fixed_to_float_stereo_tcx_core_dec( Decoder_State *st, Word16 *signal_out ) { - TCX_DEC_HANDLE hTcxDec = st->hTcxDec; + //TCX_DEC_HANDLE hTcxDec = st->hTcxDec; //Word16 q_Aq; //st->hTcxDec->tcxltp_last_gain_unmodified_float = (Word16) fixedToFloat( st->hTcxDec->tcxltp_last_gain_unmodified, Q15 ); @@ -840,7 +834,7 @@ void fixed_to_float_stereo_tcx_core_dec( fixedToFloat_arr( st->p_bpf_noise_buf, st->p_bpf_noise_buf_float, 0, L_FRAME_16k ); } - st->hBPF->pst_mem_deemp_err_fx = st->mem_error; + 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 ) { diff --git a/lib_dec/core_dec_init.c b/lib_dec/core_dec_init.c index 458f82feb7aab3496758de7b71af34668b355587..662e4bc38b19eebdf889467527911e322bdebff3 100644 --- a/lib_dec/core_dec_init.c +++ b/lib_dec/core_dec_init.c @@ -58,7 +58,6 @@ void open_decoder_LPD( const int16_t is_init /* i : indicate call during initialization */ ) { - int16_t i; int16_t mem_syn_r_size_old; int16_t mem_syn_r_size_new; int16_t fscaleFB; diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index eb61ce095900e7deaf961b499ce71de30314751f..e43ef4bed0a792eee1507b1ee24cee9bb90c283d 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -1447,8 +1447,9 @@ ivas_error init_decoder_ivas_fx( } #ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED // To be removed when fixed version is available. - //fd_bwe_dec_init_flt(st_fx->hBWE_FD); + // fd_bwe_dec_init_flt(st_fx->hBWE_FD); #endif + fd_bwe_dec_init(st_fx, st_fx->hBWE_FD); } ELSE @@ -1822,6 +1823,9 @@ ivas_error init_decoder_ivas_fx( { return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TonalMDCTConcealment\n")); } +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED + set_zero(st_fx->hTonalMDCTConc->timeDataBuffer_float, ( 3 * L_FRAME_MAX ) / 2); +#endif } ELSE { diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 02f158a3d2ef6f6a7b9d3534e503b07eeafbdcf6..f5c63a08eb9fa118846e2ed049a808a22f960b6f 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1980,6 +1980,9 @@ void ivas_binRenderer_close( IF( ( *hBinRenderer )->hReverb != NULL ) { ivas_binaural_reverb_close( &( ( *hBinRenderer )->hReverb ) ); +#ifdef IVAS_FLOAT_FIXED + ivas_binaural_reverb_close_fx( &( ( *hBinRenderer )->hReverb ) ); +#endif } free( *hBinRenderer ); diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index f4fe287de3be7f4a4b6e9e10c0c9428d521fd39d..0ad040129cc5f313d9025368f9af12ddc09ab0a8 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -105,47 +105,21 @@ ivas_error ivas_core_dec( STEREO_ICBWE_DEC_HANDLE hStereoICBWE; STEREO_TD_DEC_DATA_HANDLE hStereoTD; int16_t sharpFlag[CPE_CHANNELS]; - //float synth[CPE_CHANNELS][L_FRAME48k]; - //float tmp_buffer[L_FRAME48k]; - //float output[CPE_CHANNELS][L_FRAME48k]; - //fixedToFloat_arrL(output_32_fx[0],output[0],Q11,L_FRAME48k); - //if(n_channels > 1)fixedToFloat_arrL(output_32_fx[1],output[1],Q11,L_FRAME48k); -#ifdef IVAS_FLOAT_FIXED - //Word32 synth_fx[CPE_CHANNELS][L_FRAME48k]; - //set_zero( tmp_buffer, L_FRAME48k ); Word16 tmp_buffer_fx[L_FRAME48k]; - //Word32 tmp_buffer_fx_32[L_FRAME48k]; set_s(tmp_buffer_fx, 0, L_FRAME48k); Word16 tmp16 = 0, tmp16_2, j; Word16 Q_white_exc; Q_white_exc = 0; -#endif + int16_t tmps, incr; - //float bwe_exc_extended[CPE_CHANNELS][L_FRAME32k + NL_BUFF_OFFSET]; -#ifdef IVAS_FLOAT_FIXED Word32 bwe_exc_extended_fx[CPE_CHANNELS][L_FRAME32k + NL_BUFF_OFFSET]; -#endif - //float voice_factors[CPE_CHANNELS][NB_SUBFR16k]; -#ifdef IVAS_FLOAT_FIXED + Word16 voice_factors_fx[CPE_CHANNELS][NB_SUBFR16k]; -#else - float voice_factors[CPE_CHANNELS][NB_SUBFR16k]; - float tmp; -#endif int16_t core_switching_flag[CPE_CHANNELS]; - //float old_syn_12k8_16k[CPE_CHANNELS][L_FRAME16k]; - //float pitch_buf[CPE_CHANNELS][NB_SUBFR16k]; -#ifdef IVAS_FLOAT_FIXED + Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k]; Word32 old_syn_12k8_16k_fx[CPE_CHANNELS][L_FRAME16k]; - //for ( i = 0; i < CPE_CHANNELS; i++ ) - //{ - // for ( int j = 0; j < NB_SUBFR16k; j++ ) - // { - // pitch_buf[i][j] = 0.f; - // } - //} -#endif + int16_t unbits[CPE_CHANNELS]; int16_t sid_bw[CPE_CHANNELS]; FRAME_MODE frameMode[CPE_CHANNELS]; @@ -153,25 +127,17 @@ ivas_error ivas_core_dec( int32_t element_brate, output_Fs; int32_t last_element_brate; int16_t use_cldfb_for_dft; - //float *p_output_mem; Word32 *p_output_mem_fx; int16_t flag_sec_CNA; int16_t read_sid_info; int16_t last_element_mode; int16_t nchan_out; - //float *save_hb_synth; Word32 *save_hb_synth_32_fx; ivas_error error; Word32 L_tmp; Word16 Q_synth; - //Word32 *output_32p_fx[CPE_CHANNELS]; Word16 output_16_fx[CPE_CHANNELS][L_FRAME48k]; - //Word32 output_32_fx[CPE_CHANNELS][L_FRAME48k]; - //output_32p_fx[0] = output_32_fx[0]; - //output_32p_fx[1] = output_32_fx[1]; - //float hb_synth[CPE_CHANNELS][L_FRAME48k]; Word16 hb_synth_16_fx[CPE_CHANNELS][L_FRAME48k]; - //Word32 hb_synth_32_fx[CPE_CHANNELS][L_FRAME48k]; Word16 synth_16_fx[CPE_CHANNELS][L_FRAME48k]; Word32 synth_32_fx[CPE_CHANNELS][L_FRAME48k]; @@ -180,17 +146,12 @@ ivas_error ivas_core_dec( { set16_fx( pitch_buf_fx[i], 0, NB_SUBFR16k ); set16_fx( output_16_fx[i], 0, L_FRAME48k ); - //set16_fx(hb_synth_16_fx[i], 0, L_FRAME48k); } -#ifdef IVAS_FLOAT_FIXED - //Word16 hb_synth_fx[6][L_FRAME48k]; /*not sure about number of channels so kept it as 6 will change it later*/ - //Word16 output_16fx[CPE_CHANNELS][L_FRAME48k]; - //Word16 synth_16fx[CPE_CHANNELS][L_FRAME48k]; Word32 pitch_buf_32fx[CPE_CHANNELS][NB_SUBFR16k]; Word16 tdm_lsfQ_PCh_fx[M], tdm_lspQ_PCh_fx[M]; Word32 conceal_eof_gain32; -#endif + #ifdef BASOP_NOGLOB Flag Overflow; #endif @@ -202,41 +163,6 @@ ivas_error ivas_core_dec( * General initialization *-----------------------------------------------------------------*/ -//#ifndef TO_BE_REMOVED_CONVERSION -// Word16 k; -// -// if ( hSCE != NULL ) -// { -// sts = hSCE->hCoreCoder; -// } -// else -// { -// sts = hCPE->hCoreCoder; -// } -// -// //core_coding_part will go in this loop, once the things are done -// for ( k = 0; k < n_channels; k++ ) -// { -// if ( sts[k]->hTcxDec != NULL ) -// { -// floatToFixed_arr( sts[k]->hHQ_core->old_out, sts[k]->hHQ_core->old_out_fx, 0, L_FRAME48k ); -// floatToFixed_arr( sts[k]->hHQ_core->old_outLB, sts[k]->hHQ_core->old_out_LB_fx, 0, L_FRAME32k ); -// floatToFixed_arrL( sts[k]->hHQ_core->old_outLB, sts[k]->hHQ_core->old_outLB_fx, 11, L_FRAME32k ); -// //sts[k]->hTcxDec->conceal_eof_gain32 = floatToFixed( sts[k]->hTcxDec->conceal_eof_gain_float, 15 ); -// } -// } -// -// IF( sts[0]->element_mode == IVAS_CPE_MDCT && sts[0]->total_brate == SID_2k40 ) -// { -// FOR( Word16 ch = 0; ch < CPE_CHANNELS; ++ch ) -// { -// f2me_buf( sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel, &sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, sts[ch]->hFdCngDec->hFdCngCom->stopBand - sts[ch]->hFdCngDec->hFdCngCom->startBand ); -// floatToFixed_arr( sts[ch]->hFdCngDec->hFdCngCom->A_cng_flt, sts[ch]->hFdCngDec->hFdCngCom->A_cng, Q14, M + 1 ); -// } -// } -// -//#endif - use_cldfb_for_dft = 0; tdm_LRTD_flag = -1; read_sid_info = 1; /* read SID by default */ @@ -249,7 +175,6 @@ ivas_error ivas_core_dec( last_element_brate = hSCE->last_element_brate; /* note: this parameter is unused */ last_element_mode = IVAS_SCE; hStereoTD = NULL; - //p_output_mem = NULL; p_output_mem_fx = NULL; nchan_out = 1; IF( st_ivas != NULL && st_ivas->ivas_format == ISM_FORMAT ) @@ -284,7 +209,6 @@ ivas_error ivas_core_dec( } output_Fs = sts[0]->output_Fs; - // output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); output_frame = extract_l( Mpy_32_16_1( output_Fs, INV_FRAME_PER_SEC_Q15 ) ); FOR( n = 0; n < n_channels; n++ ) @@ -404,13 +328,11 @@ ivas_error ivas_core_dec( IF( sba_dirac_stereo_flag && hSCE && sts[0]->total_brate <= SID_2k40 && sts[0]->cng_type == FD_CNG ) { - //save_hb_synth = hSCE->save_hb_synth; floatToFixed_arrL( hSCE->save_hb_synth, hSCE->save_hb_synth_fx, Q11, output_frame ); save_hb_synth_32_fx = hSCE->save_hb_synth_fx; } ELSE { - //save_hb_synth = NULL; save_hb_synth_32_fx = NULL; } @@ -440,8 +362,6 @@ ivas_error ivas_core_dec( } #ifndef TO_BE_REMOVED_CONVERSION - // n_channels loop - // sts is initialized here for (Word16 k = 0; k < n_channels; k++ ) { if ( sts[k]->hTcxDec != NULL ) @@ -449,15 +369,12 @@ ivas_error ivas_core_dec( fixedToFloat_arr( sts[k]->hHQ_core->old_out_fx, sts[k]->hHQ_core->old_out, 0, L_FRAME48k ); fixedToFloat_arr( sts[k]->hHQ_core->old_out_LB_fx, sts[k]->hHQ_core->old_outLB, 0, L_FRAME32k ); } - //fixedToFloat_arr( voice_factors_fx[k], voice_factors[k], 15, NB_SUBFR16k ); - //fixedToFloat_arrL( hb_synth_32_fx[k], hb_synth[k], 0, L_FRAME48k ); // 0 is assumed as original values are set to 0 } IF( sts[0]->element_mode == IVAS_CPE_MDCT && sts[0]->total_brate == SID_2k40 ) { 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 ); - //fixedToFloat_arr( sts[ch]->hFdCngDec->hFdCngCom->A_cng, sts[ch]->hFdCngDec->hFdCngCom->A_cng_flt, Q14, M + 1 ); } } @@ -510,41 +427,8 @@ ivas_error ivas_core_dec( *---------------------------------------------------------------------*/ #if 1 /*Float to fix conversions*/ - Word16/* Q_hb_prev_synth_buffer,*/ - /*Q_FBTCXdelayBuf = 15,*/ /*Q_prev_synth_buffer, */Q_syn_Overl = 15,/* Q_fer_samples = 15, */Q_old_syn_Overl = 15, /*Q_olapBufferAna = 15,*/ Q_olapBufferSynth = 15, - Q_olapBufferSynth2 = 15, Q_old_synthFB = 15; /*Initializing with max values to avoid warnings*/ - - //Q_hb_prev_synth_buffer = Q_factor_arr( st->hb_prev_synth_buffer, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); - //Q_prev_synth_buffer = Q_factor_arr( st->prev_synth_buffer, 96 ); - //floatToFixed_arr( st->hb_prev_synth_buffer, st->hb_prev_synth_buffer_fx, Q_hb_prev_synth_buffer, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); - - //IF( st->hHQ_core ) - //{ - // Q_fer_samples = Q_factor_arr( st->hHQ_core->fer_samples, 960 ); - //} - IF( st->hTcxDec ) - { - //Q_FBTCXdelayBuf = Q_factor_arr( st->hTcxDec->FBTCXdelayBuf_float, 111 ); - //Q_prev_synth_buffer = s_min( Q_prev_synth_buffer, Q_FBTCXdelayBuf ); - //Q_prev_synth_buffer = s_min( Q_prev_synth_buffer, 11 ); - //Q_syn_Overl = Q_factor_arr( st->hTcxDec->syn_Overl_float, 320 ); - //Q_old_syn_Overl = Q_factor_arr( st->hTcxDec->old_syn_Overl_float, L_FRAME32k / 2 ) - 1; - } - //Q_syn_Overl = s_min( 0, Q_syn_Overl ) - 1; - //IF( st->hHQ_core ) - //{ - - //} - IF( st->hTcxDec ) - { - //floatToFixed_arr16( st->hTcxDec->FBTCXdelayBuf_float, st->hTcxDec->FBTCXdelayBuf, Q_prev_synth_buffer, 111 ); - //floatToFixed_arrL( st->hTcxDec->FBTCXdelayBuf_float, st->hTcxDec->FBTCXdelayBuf_32, OUTPUT_Q, 111 ); - //floatToFixed_arr( st->hTcxDec->syn_Overl_float, st->hTcxDec->syn_Overl, Q_syn_Overl, 320 ); - //floatToFixed_arr16( st->hTcxDec->old_syn_Overl_float, st->hTcxDec->old_syn_Overl, Q_old_syn_Overl, L_FRAME32k / 2 ); - } - //floatToFixed_arr16( st->prev_synth_buffer, st->prev_synth_buffer_fx, Q_prev_synth_buffer, 96 ); - //floatToFixed_arr16( st->prev_synth_buffer, st->prev_synth_buffer_fx, 0, 96 ); - //st->q_prev_synth_buffer_fx = 0; + Word16 Q_olapBufferSynth = 15, Q_olapBufferSynth2 = 15; /*Initializing with max values to avoid warnings*/ + IF( st->cldfbAna ) { floatToFixed_arr32( st->cldfbAna->cldfb_state, st->cldfbAna->cldfb_state_fx, Q10, st->cldfbAna->cldfb_state_length ); @@ -554,22 +438,9 @@ ivas_error ivas_core_dec( floatToFixed_arr32( st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_fx, Q11, st->cldfbSyn->cldfb_state_length ); } - //IF( st->hFdCngDec ) - //{ - // Q_olapBufferSynth2 = Q_factor_arrL( st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, 640 ) - 1; - // floatToFixed_arr32( st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, Q_olapBufferSynth2, 640 ); - //} IF( st->cldfbBPF ) floatToFixed_arr32( st->cldfbBPF->cldfb_state, st->cldfbBPF->cldfb_state_fx, Q11, st->cldfbBPF->cldfb_state_length ); - IF( ( EQ_16( st->core, ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) ) - { - IF( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && LE_32( st->element_brate, IVAS_24k4 ) && GT_32( last_element_brate, IVAS_24k4 ) ) - { - //Q_old_synthFB = Q_factor_arr( st->hTcxDec->old_synthFB, st->hTcxDec->old_synth_lenFB ) - 1; - //floatToFixed_arr16( st->hTcxDec->old_synthFB, st->hTcxDec->old_synthFB_fx, Q_old_synthFB, st->hTcxDec->old_synth_lenFB ); - } - } #endif Copy_Scale_sig_16_32( st->previoussynth_fx, st->previoussynth_fx_32, L_FRAME48k, 0 ); @@ -578,16 +449,6 @@ ivas_error ivas_core_dec( return error; } #if 1 /*Fixed to float function changes*/ - //fixedToFloat_arr( st->hb_prev_synth_buffer_fx, st->hb_prev_synth_buffer, Q_hb_prev_synth_buffer, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); - //fixedToFloat_arr( st->prev_synth_buffer_fx, st->prev_synth_buffer, Q_prev_synth_buffer, 96 ); - //st->q_prev_synth_buffer_fx = Q_prev_synth_buffer; - //fixedToFloat_arr( st->prev_synth_buffer_fx, st->prev_synth_buffer, 0, 96 ); - //st->q_prev_synth_buffer_fx = 0; - - IF( st->hTcxDec ) - { - //fixedToFloat_arr( st->hTcxDec->old_syn_Overl, st->hTcxDec->old_syn_Overl_float, Q_old_syn_Overl, L_FRAME32k / 2 ); - } IF( st->cldfbAna ) fixedToFloat_arrL( st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_state, Q10, st->cldfbAna->cldfb_state_length ); @@ -595,14 +456,6 @@ ivas_error ivas_core_dec( fixedToFloat_arrL( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_state, Q11, st->cldfbSyn->cldfb_state_length ); IF( st->cldfbBPF ) fixedToFloat_arrL( st->cldfbBPF->cldfb_state_fx, st->cldfbBPF->cldfb_state, Q11, st->cldfbBPF->cldfb_state_length ); - IF( st->hHQ_core ) - { - - } - //IF( st->hFdCngDec ) - //{ - // fixedToFloat_arrL( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, Q_olapBufferSynth2, L_FRAME32k ); - //} #endif flag_sec_CNA = -1; @@ -620,7 +473,7 @@ ivas_error ivas_core_dec( IF ( st->core == ACELP_CORE ) { /* ACELP core decoder */ - Word16 /*output_fx[L_FRAME48k],*//* synth_fxl[L_FRAME48k],*/ old_syn_12k8_16k_fx_16[L_FRAME16k]; + Word16 old_syn_12k8_16k_fx_16[L_FRAME16k]; set_s(output_16_fx[n], 0, L_FRAME48k); Word16 save_hb_synth_fx_arr[L_FRAME48k], *save_hb_synth_16_fx; IF (save_hb_synth_32_fx) { @@ -629,13 +482,10 @@ ivas_error ivas_core_dec( ELSE { save_hb_synth_16_fx = NULL; } - //Word32 bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]; /* float2fix, to be removed */ - acelp_decoder_state_float2fix(st/*, hCPE == NULL ? NULL : hCPE->hStereoCng*/); - //if (hStereoTD) { - // floatToFixed_arr(hStereoTD->tdm_Pri_pitch_buf, hStereoTD->tdm_Pri_pitch_buf_fx, Q6, NB_SUBFR); - //} + acelp_decoder_state_float2fix(st); + IF( st->hFdCngDec != NULL ) { Scale_sig32( st->hFdCngDec->msNoiseEst, NPART_SHAPING, sub( st->hFdCngDec->msNoiseEst_exp, 27 ) ); @@ -652,26 +502,22 @@ ivas_error ivas_core_dec( /* fix2float, to be removed */ Copy_Scale_sig_16_32(output_16_fx[n],output_32_fx[n],L_FRAME48k, Q11 - st->Q_syn2); Scale_sig(output_16_fx[n], L_FRAME48k, -st->Q_syn2); - acelp_decoder_state_fix2float(st/*, hCPE == NULL ? NULL : hCPE->hStereoCng*/); - //fixedToFloat_arr(output_16_fx[n], output[n], 0, L_FRAME48k); - //fixedToFloat_arr(synth_16_fx[n], synth[n], 0, L_FRAME48k); + acelp_decoder_state_fix2float(st); + if ( save_hb_synth_32_fx ) { Copy_Scale_sig_16_32( save_hb_synth_16_fx, save_hb_synth_32_fx, output_frame, Q11 ); fixedToFloat_arrL( hSCE->save_hb_synth_fx, hSCE->save_hb_synth, negate( Q11 ), output_frame ); } - //fixedToFloat_arrL(bwe_exc_extended_fx, bwe_exc_extended[n], 2*st->Q_exc, L_FRAME32k + NL_BUFF_OFFSET); - //fixedToFloat_arr(voice_factors_fx[n], voice_factors[n], Q15, NB_SUBFR16k); - //fixedToFloat_arr(old_syn_12k8_16k_fx, old_syn_12k8_16k[n], -1, L_FRAME16k); + Copy_Scale_sig_16_32(old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n],L_FRAME16k,Q11 - (-1)); - //fixedToFloat_arr(pitch_buf_fx[n], pitch_buf[n], Q6, NB_SUBFR16k); } Copy_Scale_sig_32_16(st->previoussynth_fx_32, st->previoussynth_fx, L_FRAME48k, 0); IF( ( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - Word16 Qsyn_temp = st->Q_syn; //Q gets change in below function. + Word16 Qsyn_temp = st->Q_syn; stereo_tcx_dec_mode_switch_reconf_To_fixed_2( st, 1, last_element_mode, frameMode[n]); /* TCX decoder */ @@ -682,10 +528,7 @@ ivas_error ivas_core_dec( stereo_tcx_core_dec_fx( st, frameMode[n], output_16_fx[n], synth_16_fx[n], pitch_buf_32fx[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hCPE == NULL ? NULL : hCPE->hStereoCng, nchan_out, st_ivas == NULL ? 0 : st_ivas->ivas_format ); - //fixedToFloat_arr( output_16_fx[n], output[n], 0, st->L_frame ); Copy_Scale_sig_16_32(output_16_fx[n],output_32_fx[n],L_FRAME48k,Q11); - //fixedToFloat_arr( synth_16_fx[n], synth[n], 0, st->hTcxDec->L_frameTCX ); - //fixedToFloat_arrL( pitch_buf_32fx[n], pitch_buf[n], Q6, NB_SUBFR16k ); Copy_Scale_sig_32_16(pitch_buf_32fx[n], pitch_buf_fx[n],NB_SUBFR16k,0); @@ -696,26 +539,18 @@ ivas_error ivas_core_dec( if ( st->core == HQ_CORE ) { /* HQ core decoder */ - //Word16 synth_fxl[L_FRAME48k]; - //Word16 output_fx[L_FRAME48k]; Q_synth = 0; Word16 Q_output = 0; HQ_DEC_HANDLE hHQ_core; - Word16 tmp_size = NS2SA( output_frame * FRAMES_PER_SEC, PH_ECU_LOOKAHEAD_NS ); hHQ_core = st->hHQ_core; st->hHQ_core->Q_old_wtda = -1; st->hHQ_core->Q_old_wtda_LB = -1; - //floatToFixed_arr( synth[n], synth_16_fx[n], st->Q_syn, L_FRAME48k ); - //floatToFixed_arr( output[n], output_16_fx[n], st->Q_syn, L_FRAME48k ); - #ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED floatToFixed_arr( hHQ_core->old_out, hHQ_core->old_out_fx, hHQ_core->Q_old_wtda, L_FRAME48k ); floatToFixed_arr( hHQ_core->old_outLB, hHQ_core->old_out_LB_fx, hHQ_core->Q_old_wtda_LB, L_FRAME32k ); - //floatToFixed_arr( st->hTcxDec->old_syn_Overl_float, st->hTcxDec->old_syn_Overl, -1, L_FRAME32k / 2 ); - //floatToFixed_arr( st->hTcxDec->prev_good_synth - tmp_size, st->hTcxDec->prev_good_synth_fx - tmp_size, 0, 2 * output_frame + tmp_size ); #endif ivas_hq_core_dec_fx( st, synth_16_fx[n], &Q_synth, output_frame, NORMAL_HQ_CORE, core_switching_flag[n], output_16_fx[n], &Q_output ); @@ -723,15 +558,10 @@ ivas_error ivas_core_dec( Copy_Scale_sig_16_32(output_16_fx[n], output_32_fx[n], L_FRAME48k, Q11 - Q_output); Scale_sig(synth_16_fx[n], L_FRAME48k, -Q_synth); Scale_sig(output_16_fx[n], L_FRAME48k, -Q_output); - //fixedToFloat_arr( synth_16_fx[n], synth[n], 0, L_FRAME48k ); - //fixedToFloat_arr( output_16_fx[n], output[n], 0, L_FRAME48k ); #ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED fixedToFloat_arr( hHQ_core->old_out_fx, hHQ_core->old_out, hHQ_core->Q_old_wtda, L_FRAME48k ); fixedToFloat_arr( hHQ_core->old_out_LB_fx, hHQ_core->old_outLB, hHQ_core->Q_old_wtda_LB, L_FRAME32k ); - //fixedToFloat_arr( st->hTcxDec->old_syn_Overl, st->hTcxDec->old_syn_Overl_float, -1, L_FRAME32k / 2 ); - //fixedToFloat_arr( st->hTcxDec->prev_good_synth_fx - tmp_size, st->hTcxDec->prev_good_synth - tmp_size, 0, 2 * output_frame + tmp_size ); - #endif } @@ -742,22 +572,12 @@ ivas_error ivas_core_dec( IF ( st->element_mode == IVAS_CPE_TD && n == 0 ) { - /* To be cleaned up once the caller function is converted // These changes are for system testing of fixed changes made */ - - //Word16 tdm_Pri_pitch_buf_fx[NB_SUBFR]; - Copy_Scale_sig_32_16(hCPE->hCoreCoder[0]->old_pitch_buf_fx, hCPE->hCoreCoder[0]->old_pitch_buf_16_fx, 2 * NB_SUBFR16k + 2, -10); td_stereo_param_updt_fx( st->lsp_old_fx, st->lsf_old_fx, st->old_pitch_buf_16_fx + st->nb_subfr, tdm_lspQ_PCh_fx, tdm_lsfQ_PCh_fx, hStereoTD->tdm_Pri_pitch_buf_fx, st->flag_ACELP16k, hStereoTD->tdm_use_IAWB_Ave_lpc, Q6 ); Copy_Scale_sig_16_32(hCPE->hCoreCoder[0]->old_pitch_buf_16_fx, hCPE->hCoreCoder[0]->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, 10); - - //for ( i = 0; i < NB_SUBFR; i++ ) - //{ - // //hStereoTD->tdm_Pri_pitch_buf[i] = fix16_to_float( tdm_Pri_pitch_buf_fx[i], Q16 ); - // hStereoTD->tdm_Pri_pitch_buf[i] = fix16_to_float( tdm_Pri_pitch_buf_fx[i], Q6 ); - //} } } /* n_channels loop */ @@ -781,8 +601,6 @@ ivas_error ivas_core_dec( { #if 1 Word16 e_sig = 17; - //Word32 *output_fx[CPE_CHANNELS]; - //Word16 synth_fx_16[CPE_CHANNELS][L_FRAME48k]; Word16 ch; sts = hCPE->hCoreCoder; Word16 will_estimate_noise_on_channel[CPE_CHANNELS]; @@ -791,103 +609,26 @@ ivas_error ivas_core_dec( will_estimate_noise_on_channel[1] = sts[1]->core == TCX_20_CORE && !sts[1]->VAD; FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { - //output_fx[ch] = malloc( sizeof( Word32 ) * L_FRAME48k ); - // synth_fx[ch] = malloc(sizeof(Word16) * L_FRAME48k); stereo_tcx_dec_mode_switch_reconf_To_fixed( sts[ch], 1, hCPE->last_element_mode ); st = sts[ch]; - IF( st->hTonalMDCTConc ) - { - FOR( i = 0; i < s_min( st->hTonalMDCTConc->nScaleFactors, 64 ); i++ ) - { - //st->hTonalMDCTConc->scaleFactorsBackground_fx[i] = floatToFixed( st->hTonalMDCTConc->scaleFactorsBackground_flt[i], 15 ); - } - - //if ( sts[0]->bfi && st->tonal_mdct_plc_active && st->hTonalMDCTConc->pTCI ) - //{ - // FOR( i = 0; i < s_min( st->hTonalMDCTConc->pTCI->numIndexes, 30 ); i++ ) - // { - // float pd = st->hTonalMDCTConc->pTCI->phaseDiff_float[i]; - // if ( pd >= PI2 ) - // pd = fmodf( pd, PI2 ) - PI2; - // st->hTonalMDCTConc->pTCI->phaseDiff[i] = (Word16) floatToFixed( pd, Q12 ); - // } - // FOR( i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++ ) - // { - // float pd = st->hTonalMDCTConc->pTCI->phase_currentFramePredicted_float[i]; - // pd = fmodf( pd, PI2 ); - // st->hTonalMDCTConc->pTCI->phase_currentFramePredicted[i] = (Word16) ( pd * ( 1u << Q13 ) ); - // } - //} - } - //IF( st->hTcxDec ) - //st->hTcxDec->tcxltp_last_gain_unmodified = (Word16) floatToFixed( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 ); - - //if ( !sts[0]->bfi && ( will_estimate_noise_on_channel[0] || will_estimate_noise_on_channel[1] ) ) - //{ - // sts[ch]->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx = floatToFixed( sts[ch]->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt, 31 ); - //} - IF( will_estimate_noise_on_channel[0] || will_estimate_noise_on_channel[1] || sts[ch]->bfi ) - { - //for ( int p = 0; p < s_min( sts[ch]->hFdCngDec->hFdCngCom->fftlen, 640 ); p++ ) - //{ - // sts[ch]->hFdCngDec->hFdCngCom->fftBuffer[p] = (Word32) ( sts[ch]->hFdCngDec->hFdCngCom->fftBuffer_flt[p] * ( 1u << ( 31 - sts[ch]->hFdCngDec->hFdCngCom->fftBuffer_exp ) ) ); - //} - //sts[ch]->hFdCngDec->msNoiseEst_exp = 31 - Q4; - //for ( int p = 0; p < NPART_SHAPING; p++ ) - //{ - //sts[ch]->hFdCngDec->msNoiseEst[p] = (Word32) ( sts[ch]->hFdCngDec->msNoiseEst_float[p] * ( 1u << ( 31 - sts[ch]->hFdCngDec->msNoiseEst_exp ) ) ); - //} - //sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 31 - Q3; // Q3 - //IF( st->hFdCngDec && st->hFdCngDec->hFdCngCom ) - //{ - //FOR( Word16 ind = 0; ind < 340; ind++ ) - //{ - //st->hFdCngDec->hFdCngCom->cngNoiseLevel[ind] = (Word32) ( st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[ind] * ( 1LL << ( 31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) ) ); - //} - //st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = float_to_fix16( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt, 15 ); - //} - } - - //IF( st->hTcxDec ) - //floatToFixed_arr( st->hTcxDec->syn_Overl_float, st->hTcxDec->syn_Overl, st->Q_syn, L_FRAME32k / 2 ); - //IF( st->hTcxDec ) - //floatToFixed_arr( st->hTcxDec->syn_OverlFB_float, st->hTcxDec->syn_OverlFB, st->Q_syn, L_FRAME_MAX / 2 ); st->prev_Q_syn = st->Q_syn; IF( st->hHQ_core ) floatToFixed_arr( st->hHQ_core->old_outLB, st->hHQ_core->old_out_LB_fx, st->Q_syn, L_FRAME32k ); - //IF( st->hTcxDec ) - //floatToFixed_arr( st->hTcxDec->syn_Overl_TDACFB_float, st->hTcxDec->syn_Overl_TDACFB, -1 - st->Q_syn, L_FRAME_MAX / 2 ); - //IF( st->hTcxDec ) - //floatToFixed_arr( st->hTcxDec->syn_Overl_TDAC_float, st->hTcxDec->syn_Overl_TDAC, -1 - st->Q_syn, L_FRAME32k / 2 ); - //IF( st->hTcxDec ) - //floatToFixed_arr( st->hTcxDec->old_syn_Overl_float, st->hTcxDec->old_syn_Overl, -1 - st->Q_syn, L_FRAME32k / 2 ); - - //IF( st->hTcxDec ) - //floatToFixed_arr( st->hTcxDec->old_excFB, st->hTcxDec->old_excFB_fx, st->Q_exc, s_min( 960, st->L_frame ) ); if ( !st->tcxonly ) { floatToFixed_arr( st->p_bpf_noise_buf_float, st->p_bpf_noise_buf, 0, L_FRAME_16k ); } - //IF( st->hTcxDec ) - //floatToFixed_arr( st->hTcxDec->old_synth_float, st->hTcxDec->old_synth, st->Q_syn, 1280 ); - //IF( st->hTcxDec ) - //floatToFixed_arr( st->hTcxDec->synth_history, st->hTcxDec->synth_history_fx, st->Q_syn, s_min( 2496, NS2SA( st->output_Fs, PH_ECU_MEM_NS ) ) ); - IF( st->hHQ_core ) floatToFixed_arr( st->hHQ_core->old_out, st->hHQ_core->old_out_fx, st->Q_syn, 960 ); IF( st->hTonalMDCTConc ) floatToFixed_arr( st->hTonalMDCTConc->lastPcmOut_float, st->hTonalMDCTConc->lastPcmOut, 0, s_min( 960, st->hTonalMDCTConc->nSamples ) ); IF( st->hTonalMDCTConc ) floatToFixed_arr( st->hTonalMDCTConc->secondLastPcmOut_float, st->hTonalMDCTConc->secondLastPcmOut, 0, s_min( 960, st->hTonalMDCTConc->nSamples ) / 2 ); - //IF( st->hTcxDec ) - //st->hTcxDec->conceal_eof_gain = (Word16) floatToFixed( st->hTcxDec->conceal_eof_gain_float, Q14 ); - //IF( st->hTcxDec ) - //f2me_16( st->hTcxDec->CngLevelBackgroundTrace_bfi, &st->hTcxDec->conCngLevelBackgroundTrace, &st->hTcxDec->conCngLevelBackgroundTrace_e ); if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) { st->hTcxDec->conLastFrameLevel_e = 0; @@ -900,8 +641,6 @@ ivas_error ivas_core_dec( st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; IF( st->hTcxDec ) st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; - //IF( st->hFdCngDec && st->hFdCngDec->hFdCngCom ) - //floatToFixed_arr( st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, 15, 17 ); } IF( st_ivas->hLsSetUpConversion ) @@ -928,63 +667,18 @@ ivas_error ivas_core_dec( FOR( ch = 0; ch < 2; ch++ ) { stereo_tcx_dec_mode_switch_reconf_To_fixed( sts[ch], 0, hCPE->last_element_mode ); - //me2f_buf( sts[ch]->hIGFDec->virtualSpec, sts[ch]->hIGFDec->virtualSpec_e, sts[ch]->hIGFDec->virtualSpec_float, ( N_MAX_TCX - IGF_START_MN ) ); + st = hCPE->hCoreCoder[ch]; - //fixedToFloat_arr( st->hTcxDec->syn_OverlFB, st->hTcxDec->syn_OverlFB_float, st->Q_syn, L_FRAME_MAX / 2 ); - //fixedToFloat_arr( st->hTcxDec->syn_Overl, st->hTcxDec->syn_Overl_float, st->Q_syn, L_FRAME32k / 2 ); - //st->hTcxDec->tcxltp_last_gain_unmodified_float = fix16_to_float( st->hTcxDec->tcxltp_last_gain_unmodified, Q15 ); - //st->hTcxDec->conceal_eof_gain_float = fix16_to_float( st->hTcxDec->conceal_eof_gain, Q14 ); - - //if ( sts[ch]->last_core != -1 && sts[ch]->nbLostCmpt == 1 ) - //{ - // if ( !( sts[ch]->rf_flag && sts[ch]->use_partial_copy && ( sts[ch]->rf_frame_type == RF_TCXTD1 || sts[ch]->rf_frame_type == RF_TCXTD2 ) ) ) - // { - // IF( sts[ch]->hTonalMDCTConc != NULL && sts[ch]->last_core == TCX_20_CORE && sts[ch]->second_last_core == TCX_20_CORE && ( ( sts[ch]->old_fpitch <= L_shl( sts[ch]->L_frame, 15 ) ) || ( sts[ch]->hTcxDec->tcxltp_last_gain_unmodified <= 13107 /*0.4f*/ ) ) - // /* it is fine to call the detection even if no ltp information - // is available, meaning that st->old_fpitch == - // st->tcxltp_second_last_pitch == st->L_frame */ - // && ( sts[ch]->old_fpitch == sts[ch]->hTcxDec->tcxltp_second_last_pitch ) && !sts[ch]->last_tns_active && !sts[ch]->second_last_tns_active ) - // { - - // if ( sts[ch]->hTonalMDCTConc->pTCI->numIndexes < MAX_NUMBER_OF_IDX ) - // { - // FOR( i = 0; i < s_min( 30, sts[ch]->hTonalMDCTConc->pTCI->numIndexes ); i++ ) - // { - // sts[ch]->hTonalMDCTConc->pTCI->phaseDiff_float[i] = fixedToFloat( sts[ch]->hTonalMDCTConc->pTCI->phaseDiff[i], Q12 ); - // } - // FOR( i = 0; i < MAX_NUMBER_OF_IDX * GROUP_LENGTH; i++ ) - // { - // sts[ch]->hTonalMDCTConc->pTCI->phase_currentFramePredicted_float[i] = fixedToFloat( sts[ch]->hTonalMDCTConc->pTCI->phase_currentFramePredicted[i], Q13 ); - // } - // } - // } - // } - //} - - //if ( !sts[0]->bfi && ( will_estimate_noise_on_channel[0] || will_estimate_noise_on_channel[1] ) ) - //{ - // sts[ch]->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt = fixedToFloat( sts[ch]->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx, 31 ); - //} IF( will_estimate_noise_on_channel[0] || will_estimate_noise_on_channel[1] || sts[ch]->bfi ) { if ( !sts[ch]->bfi ) { - //for ( int p = 0; p < s_min( 640, sts[ch]->hFdCngDec->hFdCngCom->fftlen ); p++ ) - //{ - // sts[ch]->hFdCngDec->hFdCngCom->fftBuffer_flt[p] = ( (float) sts[ch]->hFdCngDec->hFdCngCom->fftBuffer[p] / ( 1u << ( 31 - sts[ch]->hFdCngDec->hFdCngCom->fftBuffer_exp ) ) ); - //} for ( int p = 0; p < s_min( 62, sts[ch]->hFdCngDec->npart_shaping ); p++ ) { sts[ch]->hFdCngDec->msNoiseEst_float[p] = ( (float) sts[ch]->hFdCngDec->msNoiseEst[p] / ( 1u << ( 31 - sts[ch]->hFdCngDec->msNoiseEst_exp ) ) ); } - - for ( int p = 0; p < s_min( 320, sts[ch]->hFdCngDec->hFdCngCom->stopFFTbin - sts[ch]->hFdCngDec->hFdCngCom->startBand ); p++ ) - { - //sts[ch]->hFdCngDec->bandNoiseShape_float[p] = ( (float) sts[ch]->hFdCngDec->bandNoiseShape[p] / ( 1u << ( 31 - sts[ch]->hFdCngDec->bandNoiseShape_exp ) ) ); - } - 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 ) ) ); @@ -998,32 +692,10 @@ ivas_error ivas_core_dec( { sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[p] = ( (float) sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel[p] / ( 1u << ( 31 - sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) ) ); } - for ( int p = 0; p < FDNS_NPTS; p++ ) - { - //sts[ch]->hTonalMDCTConc->scaleFactorsBackground_flt[p] = (float) sts[ch]->hTonalMDCTConc->scaleFactorsBackground_fx[p] / ONE_IN_Q16; - } - } - if ( sts[ch]->element_mode != IVAS_CPE_MDCT || sts[ch]->core == ACELP_CORE ) - { - //int A_cng_q = 15 - norm_s( sts[ch]->hFdCngDec->hFdCngCom->A_cng[0] ); - for ( int p = 0; p < M; p++ ) - { - //sts[ch]->hFdCngDec->hFdCngCom->A_cng_flt[p] = ( (float) sts[ch]->hFdCngDec->hFdCngCom->A_cng[p] / ( 1u << A_cng_q ) ); - } } } } - //for ( int p = 0; p < s_min( 960, st->L_frame ); p++ ) - //{ - // st->hTcxDec->old_excFB[p] = (float) ( st->hTcxDec->old_excFB_fx[p] ) / ( 1u << st->Q_exc ); - //} - for ( int p = 0; p < s_min( 320, st->L_frame / 2 ); p++ ) - { - //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) ( (float) st->hTcxDec->syn_Overl_TDACFB[p] * 2 * pow( 2, st->Q_syn ) ); - //st->hTcxDec->syn_Overl_TDAC_float[p] = (float) ( (float) st->hTcxDec->syn_Overl_TDAC[p] * 2 * pow( 2, st->Q_syn ) ); - } for ( int p = 0; p < 640; p++ ) { st->hHQ_core->old_outLB[p] = (float) st->hHQ_core->old_out_LB_fx[p] / ( 1u << st->Q_syn ); @@ -1034,19 +706,11 @@ ivas_error ivas_core_dec( fixedToFloat_arr( st->p_bpf_noise_buf, st->p_bpf_noise_buf_float, 0, L_FRAME_16k ); } - - //fixedToFloat_arr( st->hTcxDec->old_synth, st->hTcxDec->old_synth_float, st->Q_syn, 1280 ); - //fixedToFloat_arr( st->hTcxDec->synth_history_fx, st->hTcxDec->synth_history, st->Q_syn, s_min( 2496, NS2SA( st->output_Fs, PH_ECU_MEM_NS ) ) ); - //fixedToFloat_arr( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synthFB, st->Q_syn, s_min( 2496, st->hTcxDec->old_synth_lenFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ) ); - for ( int p = 0; p < 960; p++ ) { st->hHQ_core->old_out[p] = (float) st->hHQ_core->old_out_fx[p] / ( 1u << st->Q_syn ); } - //IF( st->hTcxDec ) - //st->hTcxDec->CngLevelBackgroundTrace_bfi = me2f_16( st->hTcxDec->conCngLevelBackgroundTrace, st->hTcxDec->conCngLevelBackgroundTrace_e ); - IF( st->hTonalMDCTConc && st->hTonalMDCTConc->lastPcmOut_float ) fixedToFloat_arr( st->hTonalMDCTConc->lastPcmOut, st->hTonalMDCTConc->lastPcmOut_float, 0, s_min( 960, st->hTonalMDCTConc->nSamples ) ); IF( sts[0]->bfi == 0 && !st->hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive ) @@ -1055,11 +719,6 @@ ivas_error ivas_core_dec( Scale_sig(synth_16_fx[0],L_FRAME48k,e_sig - 15); Scale_sig(synth_16_fx[1],L_FRAME48k,e_sig - 15); - - //fixedToFloat_arr( synth_16_fx[0], synth[0], 0, 960 ); - //fixedToFloat_arr( synth_16_fx[1], synth[1], 0, 960 ); - //fixedToFloat_arrL( output_32_fx[0], output[0], Q11, 960 ); - //fixedToFloat_arrL( output_32_fx[1], output[1], Q11, 960 ); #endif } } @@ -1067,54 +726,12 @@ ivas_error ivas_core_dec( ELSE IF( hCPE->nchan_out == 1 ) { #ifdef IVAS_FLOAT_FIXED - /* To be cleaned up once the caller function is converted // These changes are for system testing of fixed changes made */ - //double max_synth = 0.0f; - //Word16 Q_syn = 15/*, synth_fxl[CPE_CHANNELS][L_FRAME48k]*/; - //double max_output = 0.0f; - //Word16 Q_output = 31; - //Word32 output_fx[CPE_CHANNELS][L_FRAME48k]; sts[0] = hCPE->hCoreCoder[0]; sts[1] = hCPE->hCoreCoder[1]; if ( hCPE->last_element_brate <= IVAS_SID_5k2 ) { - /*for ( int jj = 0; jj < output_frame; jj++ ) - { - max_synth = max( max_synth, fabs( synth[0][jj] ) ); - } - if ( (Word16) max_synth != 0 ) - { - Q_syn = norm_s( (Word16) max_synth ); - }*/ - - /*for ( int jj = 0; jj < output_frame; jj++ ) - { - synth_16_fx[0][jj] = float_to_fix16( synth[0][jj], 0 ); - }*/ - - //for ( int jj = 0; jj < output_frame; jj++ ) - //{ - // max_output = max( max_output, fabs( output[0][jj] ) ); - //} - //if ( (Word32) max_output != 0 ) - //{ - // Q_output = norm_l( (Word32) max_output ); - //} - - //for ( int jj = 0; jj < output_frame; jj++ ) - //{ - // output_32_fx[0][jj] = float_to_fix( output[0][jj], Q11 ); - //} - } - - if ( hCPE->last_element_brate <= IVAS_SID_5k2 ) - { - //f2me_buf_16( sts[0]->hTcxLtpDec->tcxltp_mem_in_float, sts[0]->hTcxLtpDec->tcxltp_mem_in, &sts[0]->hTcxLtpDec->exp_tcxltp_mem_in, TCXLTP_MAX_DELAY ); - //f2me_buf_16( sts[1]->hTcxLtpDec->tcxltp_mem_in_float, sts[1]->hTcxLtpDec->tcxltp_mem_in, &sts[1]->hTcxLtpDec->exp_tcxltp_mem_in, TCXLTP_MAX_DELAY ); - //f2me_buf_16( sts[0]->hTcxLtpDec->tcxltp_mem_out_float, sts[0]->hTcxLtpDec->tcxltp_mem_out, &sts[0]->hTcxLtpDec->exp_tcxltp_mem_out, L_FRAME48k ); - //f2me_buf_16( sts[1]->hTcxLtpDec->tcxltp_mem_out_float, sts[1]->hTcxLtpDec->tcxltp_mem_out, &sts[1]->hTcxLtpDec->exp_tcxltp_mem_out, L_FRAME48k ); - f2me_buf_16( sts[0]->hHQ_core->old_out, sts[0]->hHQ_core->old_out_fx, &sts[0]->hHQ_core->exp_old_out, L_FRAME48k ); f2me_buf_16( sts[1]->hHQ_core->old_out, sts[1]->hHQ_core->old_out_fx, &sts[1]->hHQ_core->exp_old_out, L_FRAME48k ); } @@ -1122,27 +739,10 @@ ivas_error ivas_core_dec( if ( hCPE->last_element_brate <= IVAS_SID_5k2 ) { - //me2f_buf_16( sts[0]->hTcxLtpDec->tcxltp_mem_in, sts[0]->hTcxLtpDec->exp_tcxltp_mem_in, sts[0]->hTcxLtpDec->tcxltp_mem_in_float, TCXLTP_MAX_DELAY ); - //me2f_buf_16( sts[0]->hTcxLtpDec->tcxltp_mem_out, sts[0]->hTcxLtpDec->exp_tcxltp_mem_out, sts[0]->hTcxLtpDec->tcxltp_mem_out_float, L_FRAME48k ); me2f_buf_16( sts[0]->hHQ_core->old_out_fx, sts[0]->hHQ_core->exp_old_out, sts[0]->hHQ_core->old_out, L_FRAME48k ); me2f_buf_16( sts[1]->hHQ_core->old_out_fx, sts[1]->hHQ_core->exp_old_out, sts[1]->hHQ_core->old_out, L_FRAME48k ); } - //for ( i = 1; i < CPE_CHANNELS; i++ ) - //{ - // for ( int jj = 0; jj < L_FRAME48k; jj++ ) - // { - // output[i][jj] = fix_to_float( output_32_fx[i][jj], Q11 ); - // } - //} - - /*for ( i = 1; i < CPE_CHANNELS; i++ ) - { - for ( int jj = 0; jj < output_frame; jj++ ) - { - synth[i][jj] = fix16_to_float( synth_16_fx[i][jj], 0 ); - } - }*/ #else updateBuffersForDmxMdctStereo( hCPE, output_frame, output, synth ); #endif @@ -1155,17 +755,8 @@ ivas_error ivas_core_dec( { IF ( NE_16(sts[n]->last_core_bfi, ACELP_CORE) ) { - //sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 27; - //for ( int p = 0; p < sts[n]->hFdCngDec->hFdCngCom->stopFFTbin - sts[n]->hFdCngDec->hFdCngCom->startBand; p++ ) - //{ - //sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevel[p] = (Word32) ( sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[p] * ( 1u << ( 31 - sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) ) ); - //} Scale_sig32(sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, sub(sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 27)); sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 27; - for ( int p = 0; p < FDNS_NPTS; p++ ) - { - //sts[n]->hTonalMDCTConc->scaleFactorsBackground_fx[p] = (Word32) ( sts[n]->hTonalMDCTConc->scaleFactorsBackground_flt[p] * ONE_IN_Q16 ); - } TonalMdctConceal_whiten_noise_shape_ivas_fx( sts[n], L_FRAME16k, ON_FIRST_GOOD_FRAME ); @@ -1173,10 +764,6 @@ ivas_error ivas_core_dec( { sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[p] = (float) sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevel[p] / ( 1u << ( 31 - sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) ); } - for ( int p = 0; p < FDNS_NPTS; p++ ) - { - //sts[n]->hTonalMDCTConc->scaleFactorsBackground_flt[p] = (float) sts[n]->hTonalMDCTConc->scaleFactorsBackground_fx[p] / ONE_IN_Q16; - } } } } @@ -1189,43 +776,15 @@ ivas_error ivas_core_dec( if ( sts[0]->element_mode == IVAS_CPE_TD && hCPE->hStereoCng != NULL ) { /* To be cleaned up once the caller function is converted // These changes are for system testing of fixed changes made */ - //Word32 output_fx[CPE_CHANNELS][L_FRAME16k]; - Word16 Q_c_PS_LT = 31, Q_output = 31; - double max_output_fx = 0; - - //for ( i = 0; i < CPE_CHANNELS; i++ ) - //{ - // for ( int jj = 0; jj < L_FRAME16k; jj++ ) - // { - // max_output_fx = max( max_output_fx, fabs( output[i][jj] ) ); - // } - //} - - if ( (Word32) max_output_fx != 0 ) - { - Q_output = norm_l( (Word32) max_output_fx ); - } - Q_output = 11; - //for ( i = 0; i < CPE_CHANNELS; i++ ) - //{ - // for ( int jj = 0; jj < L_FRAME16k; jj++ ) - // { - // output_32_fx[i][jj] = float_to_fix( output[i][jj], Q11 ); - // } - //} - - //if ( (Word32) hCPE->hStereoCng->c_PS_LT != 0 ) - //{ - // Q_c_PS_LT = norm_l( (Word32) hCPE->hStereoCng->c_PS_LT ); - //} - //Word32 c_PS_LT_fx = float_to_fix( hCPE->hStereoCng->c_PS_LT, Q_c_PS_LT ); + Word16 Q_c_PS_LT = 31, Q_output = 11; + Word32 c_PS_LT_fx = L_deposit_h( hCPE->hStereoCng->c_PS_LT_fx); Q_c_PS_LT = Q31; stereo_cng_compute_PScorr_fx( output_32_fx[0], output_32_fx[1], &Q_output, &c_PS_LT_fx, Q_c_PS_LT, sts[0]->L_frame, sts[1]->L_frame ); hCPE->hStereoCng->c_PS_LT_fx = extract_h( c_PS_LT_fx ); - //hCPE->hStereoCng->c_PS_LT = fix_to_float( c_PS_LT_fx, Q_c_PS_LT ); + } /*---------------------------------------------------------------------* @@ -1241,28 +800,7 @@ ivas_error ivas_core_dec( *---------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED - //Word32 hb_synth_fxg[CPE_CHANNELS][L_FRAME48k]; - if (st->last_core == ACELP_CORE && (st->core == TCX_20_CORE || st->core == TCX_10_CORE || st->core == HQ_CORE) && st->hBWE_TD != NULL) - { - FOR(int ch_ind = 0; ch_ind < n_channels; ch_ind++) - { - FOR(int ind = 0; ind < L_FRAME48k; ind++) - { - //hb_synth_32_fx[ch_ind][ind] = (Word32)(hb_synth[ch_ind][ind] * (1 << 11)); - } - } - //if (st->hBWE_TD != NULL) - //{ - // for (int i = 0; i < L_SHB_LAHEAD; i++) - // { - // for (int ii = 0; ii < L_SHB_LAHEAD; ii++) - // { - // st->hBWE_TD->syn_overlap_fx_32[ii] = (Word32)(st->hBWE_TD->syn_overlap[ii] * (1 << 11)); - // } - // } - //} - } /*cldfb struct*/ IF(st->hBWE_TD != NULL) { @@ -1276,32 +814,16 @@ ivas_error ivas_core_dec( st->hHQ_core->Q_old_postdec = 0; st->hHQ_core->Q_old_wtda = 0; } - st->bws_cnt = st->bws_cnt; - st->coder_type = st->coder_type; - st->prev_coder_type = st->prev_coder_type; - st->prev_bws_cnt = st->prev_bws_cnt; - st->old_ppp_mode = st->old_ppp_mode; /*------------------fix-to-fix-end-----------------------*/ - //Word16 *synth_fx16; - //Word16 *output_mem_fx; - Word16 output_mem_16_fx[L_FRAME48k]; Word16 *p_output_mem_16; - //synth_fx16 = (Word16 *)malloc(L_FRAME48k * sizeof(Word16)); - //Word32 output_fx32[L_FRAME48k]; - //output_mem_fx = (Word16 *)malloc(NS2SA(st->output_Fs, 3125000) * sizeof(Word16)); - - IF(p_output_mem_fx != NULL) { - //floatToFixed_arrL(p_output_mem, p_output_mem_fx, Q11, NS2SA_fx2(output_Fs, STEREO_DFT32MS_OVL_NS)); p_output_mem_16 = output_mem_16_fx; Copy_Scale_sig_32_16(p_output_mem_fx, p_output_mem_16, NS2SA_fx2(output_Fs, STEREO_DFT32MS_OVL_NS), negate(Q11)); - - //floatToFixed_arr(p_output_mem, output_mem_fx, 0, NS2SA(st->output_Fs, 3125000)); } ELSE { @@ -1309,31 +831,13 @@ ivas_error ivas_core_dec( set16_fx(output_mem_16_fx, 0, NS2SA(st->output_Fs, 3125000)); } - //floatToFixed_arr(synth[n], synth_16_fx[n], Q_synth, L_FRAME48k); - //floatToFixed_arrL(output[n], output_32_fx[n], Q11, L_FRAME48k); Scale_sig32(output_32_fx[n], L_FRAME48k, Q4 - Q11); - Word16 s_tmp; - s_tmp = extract_l(L_shr(st->output_Fs, 13)); - Word16 Fs_kHz = shl(add(s_tmp, 1), 3); - - Word16 delta = 1; - move16(); - IF(GE_16(output_frame, L_FRAME16k)) - { - delta = shr(Fs_kHz, 3); - } - IF(st->hHQ_core != NULL) { floatToFixed_arr(st->hHQ_core->old_out, st->hHQ_core->old_out_fx, 0, L_FRAME48k); } - //if (st->hTcxDec != NULL) - //{ - // st->hTcxDec->conceal_eof_gain = (Word16)floatToFixed(st->hTcxDec->conceal_eof_gain_float, 14); - //} - /*size of synth is choosen as delay comp to start with*/ /*-------------------cldfb-start-------------------------*/ @@ -1431,22 +935,9 @@ ivas_error ivas_core_dec( Scale_sig32(output_32_fx[n], L_FRAME48k, Q11 - Q4); #ifdef IVAS_FLOAT_FIXED - if (st->last_core == ACELP_CORE && (st->core == TCX_20_CORE || st->core == TCX_10_CORE || st->core == HQ_CORE) && st->hBWE_TD != NULL) - { - // Delete from here - FOR(int ch_ind = 0; ch_ind < n_channels; ch_ind++) - { - //fixedToFloat_arrL(hb_synth_32_fx[ch_ind], hb_synth[ch_ind], 11, L_FRAME48k); - } - } if (hSCE != NULL) { if (hSCE->save_synth != NULL)fixedToFloat_arrL(hSCE->save_synth_fx, hSCE->save_synth, Q11, output_frame); } - if (sba_dirac_stereo_flag && st->element_mode != IVAS_CPE_MDCT && !(st->core_brate == SID_2k40 && st->cng_type == FD_CNG)) - { - //mvr2r(synth[n], hSCE->save_synth, output_frame); - //fixedToFloat_arrL(hSCE->save_synth_fx, hSCE->save_synth, Q11,output_frame); - } /*-------------------cldfb-start-------------------------*/ /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ @@ -1466,8 +957,7 @@ ivas_error ivas_core_dec( /*-------------------cldfb-end---------------------------*/ Scale_sig(synth_16_fx[n], L_FRAME48k, negate(Q_synth)); - //fixedToFloat_arr(synth_16_fx[n], synth[n], 0, L_FRAME48k); - //fixedToFloat_arrL(output_32_fx[n], output[n], Q11, L_FRAME48k); + IF(st->hHQ_core != NULL) { fixedToFloat_arr(st->hHQ_core->old_out_fx, st->hHQ_core->old_out, 0, L_FRAME48k); @@ -1488,15 +978,6 @@ ivas_error ivas_core_dec( st->hBWE_FD->prev_flag = st->hBWE_FD->prev_flag; } - //free(synth_fx16); - //free(output_mem_fx); - - if (sba_dirac_stereo_flag && hSCE && st->core_brate == SID_2k40 && st->cng_type == FD_CNG) - { - //mvr2r(synth[n], hSCE->save_synth, output_frame); - //fixedToFloat_arrL(hSCE->save_synth_fx, hSCE->save_synth, Q11,output_frame); - } - #endif /*---------------------------------------------------------------------* * WB TBE decoding @@ -1505,14 +986,7 @@ ivas_error ivas_core_dec( #ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED - //Word16 hb_synth_fx_16[CPE_CHANNELS][L_FRAME48k]; - //Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k]; - //Word16 output_fx_16[CPE_CHANNELS][L_FRAME48k]; - //Word16 synth_fx_16[CPE_CHANNELS][L_FRAME48k]; Word16 Q_input, Q_hb_synth_fx, Q_synth_fx; - - //Word32 synth_fx32[L_FRAME48k]; - //Word32 hb_synth_fx32[L_FRAME48k]; Word16 Q_syn_hb; Q_input = 0; @@ -1526,14 +1000,8 @@ ivas_error ivas_core_dec( FD_BWE_DEC_HANDLE hBWE_FD; hBWE_FD = st->hBWE_FD; - //floatToFixed_arrL( old_syn_12k8_16k[n], old_syn_12k8_16k_fx, Q11, L_FRAME16k ); // Can be removed got from last fn - - //floatToFixed_arrL( bwe_exc_extended[n], bwe_exc_extended_fx[n], 2 * st->Q_exc, L_FRAME32k + NL_BUFF_OFFSET ); Copy_Scale_sig_32_16(output_32_fx[n], output_16_fx[n], L_FRAME48k, negate(Q11)); Copy_Scale_sig_32_16(hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, negate(Q11)); - //floatToFixed_arr( hb_synth[n], hb_synth_16_fx[n], Q_hb_synth_fx, L_FRAME48k ); - //floatToFixed_arr( output[n], output_16_fx[n], Q_input, L_FRAME48k ); - //floatToFixed_arr( synth[n], synth_16_fx[n], Q_synth_fx, L_FRAME48k ); IF( hBWE_TD != NULL ) { @@ -1598,7 +1066,7 @@ ivas_error ivas_core_dec( ivas_swb_tbe_dec_fx( st, hStereoICBWE, bwe_exc_extended_fx[n], st->Q_exc, voice_factors_fx[n], old_syn_12k8_16k_fx[n], tmp_buffer_fx /*fb_exc*/, hb_synth_32_fx[n], pitch_buf_fx[n], &Q_white_exc ); - Copy_Scale_sig_32_16( st->hBWE_TD->old_tbe_synth_fx_32, st->hBWE_TD->old_tbe_synth_fx, L_SHB_TRANSITION_LENGTH, st->prev_Qx - Q11 ); // Check + Copy_Scale_sig_32_16( st->hBWE_TD->old_tbe_synth_fx_32, st->hBWE_TD->old_tbe_synth_fx, L_SHB_TRANSITION_LENGTH, st->prev_Qx - Q11 ); IF( GT_16(Q_white_exc, 31 )) { @@ -1617,10 +1085,9 @@ ivas_error ivas_core_dec( /* SWB BWE decoder */ Q_syn_hb = swb_bwe_dec_fx32( st, output_32_fx[n], synth_32_fx[n], hb_synth_32_fx[n], use_cldfb_for_dft, output_frame ); - // Output Scale_sig32( hb_synth_32_fx[n], output_frame, Q11 - Q_syn_hb ); - Copy_Scale_sig_32_16( st->hBWE_FD->L_old_wtda_swb_fx32, st->hBWE_FD->L_old_wtda_swb_fx, output_frame, hBWE_FD->old_wtda_swb_fx_exp - Q11 ); // Check + Copy_Scale_sig_32_16( st->hBWE_FD->L_old_wtda_swb_fx32, st->hBWE_FD->L_old_wtda_swb_fx, output_frame, hBWE_FD->old_wtda_swb_fx_exp - Q11 ); } /*---------------------------------------------------------------------* @@ -1661,9 +1128,8 @@ ivas_error ivas_core_dec( IF ( ( output_frame >= L_FRAME32k && st->hTdCngDec != NULL ) || ( st->element_mode == IVAS_CPE_DFT && st->bwidth >= SWB && st->hTdCngDec != NULL ) ) { /* SHB CNG decoder */ - Word16 synth_fxl[960]/*, hb_synth_fxl[960]*/; /* Q-2 */ + Word16 synth_fxl[960]; /* Q-2 */ Word16 q = 2; - //st->prev_Q_bwe_syn2 = 0; Copy_Scale_sig_32_16(hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -(Q11 + q)); Copy_Scale_sig_32_16(synth_32_fx[n], synth_fxl, L_FRAME48k, -(Q11 + q)); Scale_sig(st->hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, (Q8 - st->prev_Q_bwe_syn)); @@ -1681,15 +1147,9 @@ ivas_error ivas_core_dec( #ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED - //fixedToFloat_arrL(hb_synth_32_fx[n], hb_synth[n], Q11, L_FRAME48k); - //fixedToFloat_arrL(output_32_fx[n], output[n], Q11, L_FRAME48k); - //fixedToFloat_arrL(synth_32_fx[n], synth[n], Q11, L_FRAME48k); - //Copy_Scale_sig_32_16(synth_32_fx[n],synth_16_fx[n],L_FRAME48k,negate(Q11)); - IF(hBWE_TD != NULL) { fixedToFloat_arr(hBWE_TD->old_bwe_exc_extended_fx, hBWE_TD->old_bwe_exc_extended, st->prev_Q_bwe_exc - 16, NL_BUFF_OFFSET); - //fixedToFloat_arr(hBWE_TD->syn_overlap_fx, hBWE_TD->syn_overlap, st->prev_Q_bwe_syn2, L_SHB_LAHEAD); // Check } #endif /*-------------------------------------------------------------------* @@ -1698,12 +1158,7 @@ ivas_error ivas_core_dec( test(); IF ( EQ_16(n, 0) && GE_16(st->element_mode, IVAS_CPE_DFT )) { - //Word32 *hb_synth_0 = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); - //Word32 *hb_synth_1 = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); Word16 q = 11; - //floatToFixed_arrL( hb_synth[0], hb_synth_32_fx[0], q, L_FRAME48k ); - //floatToFixed_arrL( hb_synth[1], hb_synth_32_fx[1], q, L_FRAME48k ); - if ( hCPE->hStereoDft != NULL ) { @@ -1713,10 +1168,6 @@ ivas_error ivas_core_dec( Scale_sig( tmp_buffer_fx, L_FRAME48k, Q11 - Q_white_exc ); stereo_icBWE_dec_fx( hCPE, hb_synth_32_fx[0], hb_synth_32_fx[1], tmp_buffer_fx /*fb_synth_ref*/, voice_factors_fx[0], output_frame, &q ); - - //fixedToFloat_arrL( hb_synth_32_fx[0], hb_synth[0], q, L_FRAME48k ); - //fixedToFloat_arrL( hb_synth_32_fx[1], hb_synth[1], q, L_FRAME48k ); - Scale_sig32(hb_synth_32_fx[0], L_FRAME48k, sub(Q11 , q)); Scale_sig32(hb_synth_32_fx[1], L_FRAME48k, sub(Q11 , q)); @@ -1733,10 +1184,6 @@ ivas_error ivas_core_dec( hCPE->hStereoDft->td_gain[0] = 0; } } - - - //free( hb_synth_0 ); - //free( hb_synth_1 ); } IF( EQ_16( st->element_mode, EVS_MONO ) ) @@ -1802,13 +1249,6 @@ ivas_error ivas_core_dec( } set16_fx( st->hb_prev_synth_buffer_fx, 0, tmps ); -#if 1 //To be removed - /*for (i = 0; i < tmps; i++) - { - hb_synth[n][i] *= sin_table256[i * incr]; - }*/ - //set_f(st->hb_prev_synth_buffer, 0.0f, tmps); -#endif } ELSE IF ( LT_16(tmps, st->old_bwe_delay )) { @@ -1824,15 +1264,7 @@ ivas_error ivas_core_dec( tmp16 = add(tmp16, incr); } Copy(tmp_buffer_fx, st->hb_prev_synth_buffer_fx, tmps); -#if 0 //To be removed - for (i = 0; i < tmps; i++) - { - tmp_buffer[i] = st->hb_prev_synth_buffer[i] * sin_table256[255 - i * incr] + - st->hb_prev_synth_buffer[st->old_bwe_delay - 1 - i] * sin_table256[i * incr]; - } - mvr2r(tmp_buffer, st->hb_prev_synth_buffer, tmps); -#endif } ELSE IF ( GT_16(tmps, st->old_bwe_delay )) { @@ -1860,56 +1292,25 @@ ivas_error ivas_core_dec( } Copy( tmp_buffer_fx, st->hb_prev_synth_buffer_fx, tmps ); - -#if 0 //To be removed - for (i = 0; i < st->old_bwe_delay; i++) - { - tmp_buffer[i] = st->hb_prev_synth_buffer[i] * sin_table256[255 - i * incr]; - } - - for (; i < tmps; i++) - { - tmp_buffer[i] = 0.0f; - } - - for (i = 0; i < st->old_bwe_delay; i++) - { - tmp_buffer[tmps - 1 - i] += st->hb_prev_synth_buffer[st->old_bwe_delay - 1 - i] * sin_table256[i * incr]; - } - - mvr2r(tmp_buffer, st->hb_prev_synth_buffer, tmps); -#endif } test(); test(); test(); IF ( ( NE_16(st->element_mode, IVAS_CPE_TD) && !use_cldfb_for_dft ) || ( EQ_16(hCPE->element_mode, IVAS_CPE_TD) && tdm_LRTD_flag ) ) { /* Delay hb_synth */ - Word32 /*hb_synth_fxl[960],*/ hb_prev_synth_buffer_fx_32[111]; - //floatToFixed_arrL(hb_synth[n], hb_synth_fxl, Q11, 960); - //floatToFixed_arrL(st->hb_prev_synth_buffer, hb_prev_synth_buffer_fx_32, Q11, 111); + Word32 hb_prev_synth_buffer_fx_32[111]; Copy_Scale_sig_16_32(st->hb_prev_synth_buffer_fx, hb_prev_synth_buffer_fx_32, 111, 11); delay_signal_fx( hb_synth_32_fx[n], output_frame, hb_prev_synth_buffer_fx_32, tmps ); Copy_Scale_sig_32_16(hb_prev_synth_buffer_fx_32, st->hb_prev_synth_buffer_fx, 111, -11); - - //fixedToFloat_arrL(hb_synth_fxl, hb_synth[n], Q11, 960); - //fixedToFloat_arrL(hb_prev_synth_buffer_fx_32, st->hb_prev_synth_buffer, Q11, 111); } ELSE { - Copy_Scale_sig_32_16(hb_synth_32_fx[n] + output_frame - tmps, st->hb_prev_synth_buffer_fx, tmps,negate(Q11)); //ToDo: Scale Signl with appropriate Q. -#if 0 // TO BE REMOVED - mvr2r(hb_synth[n] + output_frame - tmps, st->hb_prev_synth_buffer, tmps); -#endif + Copy_Scale_sig_32_16(hb_synth_32_fx[n] + output_frame - tmps, st->hb_prev_synth_buffer_fx, tmps,negate(Q11)); } st->old_bwe_delay = tmps; #ifndef IVAS_FLOAT_FIXED - if ( st->hBWE_TD != NULL ) - { - //mvr2r( hb_synth[n], st->hBWE_TD->old_hb_synth, output_frame ); - } IF( st->hBWE_TD != NULL ) { Copy_Scale_sig_32_16( hb_synth_32_fx[n], st->hBWE_TD->old_hb_synth_fx, output_frame, negate( Q11 ) ); @@ -1921,10 +1322,7 @@ ivas_error ivas_core_dec( IF ( GE_16(output_frame, L_FRAME32k) && GT_16(st->extl, SWB_CNG) && EQ_16(st->core, ACELP_CORE) && st->hTdCngDec != NULL ) { #ifdef IVAS_FLOAT_FIXED - //Word32 hb_synth_fxl[960]; - //Word32 L_tmp; Word16 exp, fra; - //floatToFixed_arrL(hb_synth[n], hb_synth_32_fx[n], Q11, 960); #endif SWITCH(output_frame) { @@ -1969,33 +1367,6 @@ ivas_error ivas_core_dec( * - updates for potential TD->DFT stereo switching *----------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED - // TO DO delete below - //Word32 output_fx[CPE_CHANNELS][L_FRAME48k]; - //Word32 synth_fxg[CPE_CHANNELS][L_FRAME48k]; - //Word32 hb_synth_fxg[CPE_CHANNELS][L_FRAME48k]; - - FOR(int ch_ind = 0; ch_ind < n_channels; ch_ind++) - { - FOR(int ind = 0; ind < L_FRAME48k; ind++) - { - //output_32_fx[ch_ind][ind] = (Word32)(output[ch_ind][ind] * (1 << 11)); - //synth_32_fx[ch_ind][ind] = (Word32)(synth[ch_ind][ind] * (1 << 11)); - //hb_synth_32_fx[ch_ind][ind] = (Word32)(hb_synth[ch_ind][ind] * (1 << 11)); - } - } - //Word16 q_DFT[2] = { 3, 3 }; - //Word32 DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX]; - - //IF(DFT != NULL) - //{ - // FOR(int ind = 0; ind < CPE_CHANNELS; ind++) - // { - // FOR(int jj = 0; jj < STEREO_DFT_BUF_MAX; jj++) - // { - // DFT_fx[ind][jj] = (Word32)(DFT[ind][jj] * (1 << q_DFT[ind])); - // } - // } - //} if (hCPE != NULL) { @@ -2022,44 +1393,6 @@ ivas_error ivas_core_dec( } } } - IF(hCPE->hStereoDft != NULL) - { - FOR(int ind = 0; ind < NS2SA(16000, DELAY_BWE_TOTAL_NS); ind++) - { - hCPE->hStereoDft->ap_delay_mem_fx[ind] = (Word32)(hCPE->hStereoDft->ap_delay_mem[ind] * (1 << 11)); - } - hCPE->hStereoDft->q_ap_delay_mem_fx = 11; - IF(hCPE->hStereoDft->hTcxLtpDec != NULL) - { - FOR(Word32 p = 0; p < L_FRAME48k; p++) - { - //hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] = (Word32)(hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] * (1u << OUTPUT_Q)); - } - FOR(Word32 p = 0; p < TCXLTP_MAX_DELAY; p++) - { - //hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] = (Word32)(hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] * (1u << OUTPUT_Q)); - } - } - - } - IF(hCPE->hCoreCoder[ch_ind]->hTcxLtpDec != NULL) - { - FOR(Word32 p = 0; p < L_FRAME48k; p++) - { - //hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_out_32[p] = (Word32)(hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_out_float[p] * (1u << OUTPUT_Q)); - } - FOR(Word32 p = 0; p < TCXLTP_MAX_DELAY; p++) - { - //hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_in_32[p] = (Word32)(hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_in_float[p] * (1u << OUTPUT_Q)); - } - } - IF(hCPE->hCoreCoder[ch_ind]->hTcxDec != NULL) - { - FOR(Word32 kk = 0; kk < 111; kk++) - { - //hCPE->hCoreCoder[ch_ind]->hTcxDec->FBTCXdelayBuf_32[kk] = (Word32)(hCPE->hCoreCoder[ch_ind]->hTcxDec->FBTCXdelayBuf_float[kk] * (1 << OUTPUT_Q)); - } - } } } if (hSCE != NULL) @@ -2077,24 +1410,6 @@ ivas_error ivas_core_dec( hSCE->hCoreCoder[0]->hHQ_core->oldOut_fx[ind] = (Word32)(hSCE->hCoreCoder[0]->hHQ_core->old_out[ind] * (1 << 11)); } } - IF(hSCE->hCoreCoder[0]->hTcxDec != NULL) - { - FOR(Word32 kk = 0; kk < 111; kk++) - { - //hSCE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf_32[kk] = (Word32)(hSCE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf_float[kk] * (1 << OUTPUT_Q)); - } - } - IF(hSCE->hCoreCoder[0]->hTcxLtpDec != NULL) - { - FOR(Word32 p = 0; p < L_FRAME48k; p++) - { - //hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_out_32[p] = (Word32)(hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_out_float[p] * (1u << OUTPUT_Q)); - } - FOR(Word32 p = 0; p < TCXLTP_MAX_DELAY; p++) - { - //hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_in_32[p] = (Word32)(hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_in_float[p] * (1u << OUTPUT_Q)); - } - } } } @@ -2184,7 +1499,6 @@ ivas_error ivas_core_dec( Scale_sig(st->prev_synth_buffer_fx, NS2SA(48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS), exp_max - st->q_prev_synth_buffer_fx); Scale_sig(st->hTcxDec->synth_history_fx + output_frame, 2 * output_frame - NS2SA(st->output_Fs, DELAY_CLDFB_NS) + NS2SA(st->output_Fs, PH_ECU_MEM_NS) - output_frame, exp_max - st->Q_syn); - //st->hTcxDec->q_synth_history_fx = exp_max - st->q_prev_synth_buffer_fx; st->q_prev_synth_buffer_fx = exp_max - st->q_prev_synth_buffer_fx; } /* Save synthesis for HQ FEC */ @@ -2197,26 +1511,7 @@ ivas_error ivas_core_dec( Scale_sig( st->delay_buf_out_fx, NS2SA( st->output_Fs, DELAY_CLDFB_NS ), -exp_max ); #ifdef IVAS_FLOAT_FIXED - // TO DO delete below - FOR( int ch_ind = 0; ch_ind < n_channels; ch_ind++ ) - { - FOR( i = 0; i < L_FRAME48k; i++ ) - { - //output[ch_ind][i] = fixedToFloat(output_32_fx[ch_ind][i], 11); - //synth[ch_ind][i] = (float) synth_32_fx[ch_ind][i] / (float) ( 1 << 11 ); - //hb_synth[ch_ind][i] = (float) hb_synth_32_fx[ch_ind][i] / (float) ( 1 << 11 ); - } - } - //IF( DFT != NULL ) - //{ - // FOR( i = 0; i < CPE_CHANNELS; i++ ) - // { - // FOR( Word16 jj = 0; jj < STEREO_DFT_BUF_MAX; jj++ ) - // { - // DFT[i][jj] = (float) DFT_fx[i][jj] / (float) ( 1 << q_DFT[i] ); - // } - // } - //} + if ( hCPE != NULL ) { @@ -2242,43 +1537,6 @@ ivas_error ivas_core_dec( hCPE->hCoreCoder[ch_ind]->p_bpf_noise_buf_float[ind] = (float) hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[ind] / (float) ( 1 << 11 ); } } - IF(hCPE->hCoreCoder[ch_ind]->hTcxLtpDec != NULL) - { - FOR(Word32 p = 0; p < L_FRAME48k; p++) - { - //hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_out_float[p] = (float)hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_out_32[p] / (1u << OUTPUT_Q); - } - FOR(Word32 p = 0; p < TCXLTP_MAX_DELAY; p++) - { - //hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_in_float[p] = (float)hCPE->hCoreCoder[ch_ind]->hTcxLtpDec->tcxltp_mem_in_32[p] / (1u << OUTPUT_Q); - } - } - IF(hCPE->hCoreCoder[ch_ind]->hTcxDec != NULL) - { - FOR(Word32 kk = 0; kk < 111; kk++) - { - //hCPE->hCoreCoder[ch_ind]->hTcxDec->FBTCXdelayBuf_float[kk] = (float)hCPE->hCoreCoder[ch_ind]->hTcxDec->FBTCXdelayBuf_32[kk] / (1 << OUTPUT_Q); - } - } - } - IF( hCPE->hStereoDft != NULL ) - { - FOR( int ind = 0; ind < NS2SA( 16000, DELAY_BWE_TOTAL_NS ); ind++ ) - { - hCPE->hStereoDft->ap_delay_mem[ind] = (float) hCPE->hStereoDft->ap_delay_mem_fx[ind] / (float) ( 1 << 11 ); - } - - IF(hCPE->hStereoDft->hTcxLtpDec != NULL) - { - FOR(Word32 p = 0; p < L_FRAME48k; p++) - { - //hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_float[p] = (float)hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_out_32[p] / (1u << OUTPUT_Q); - } - FOR(Word32 p = 0; p < TCXLTP_MAX_DELAY; p++) - { - //hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_float[p] = (float)hCPE->hStereoDft->hTcxLtpDec->tcxltp_mem_in_32[p] / (1u << OUTPUT_Q); - } - } } } } @@ -2298,34 +1556,8 @@ ivas_error ivas_core_dec( hSCE->hCoreCoder[0]->hHQ_core->old_out[ind] = (float) hSCE->hCoreCoder[0]->hHQ_core->oldOut_fx[ind] / (float) ( 1 << 11 ); } } - IF(hSCE->hCoreCoder[0]->hTcxDec != NULL) - { - FOR(Word32 kk = 0; kk < 111; kk++) - { - //hSCE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf_float[kk] = (float)hSCE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf_32[kk] / (1 << OUTPUT_Q); - } - } - IF(hSCE->hCoreCoder[0]->hTcxLtpDec != NULL) - { - FOR(Word32 p = 0; p < L_FRAME48k; p++) - { - //hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_out_float[p] = (float)hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_out_32[p] / (1u << OUTPUT_Q); - } - FOR(Word32 p = 0; p < TCXLTP_MAX_DELAY; p++) - { - //hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_in_float[p] = (float)hSCE->hCoreCoder[0]->hTcxLtpDec->tcxltp_mem_in_32[p] / (1u << OUTPUT_Q); - } - } } } - - if ((st->last_codec_mode == MODE1 && st->hTcxDec != NULL) && ((st->last_core == ACELP_CORE && !(st->bfi == 1 && st->last_con_tcx == 1)) || st->last_core == HQ_CORE)) - { - for (i = 0; i < 2 * output_frame + NS2SA(st->output_Fs, PH_ECU_LOOKAHEAD_NS); i++) - { - //fix2f_16(&st->hTcxDec->synth_history_fx[i], &st->hTcxDec->synth_history[i], st->hTcxDec->q_synth_history_fx); - } - } #endif } /* n_channels loop */ diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index e52a7b5635def3ffc9295f013b3ade200a6f8070..d6b5c3d6db0ac0fd55a65516047c1fd2d53540f0 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -108,8 +108,6 @@ ivas_error ivas_cpe_dec_fx( element_brate_ref = hCPE->element_brate; move32(); -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED -#endif /*------------------------------------------------------------------* * Read stereo technology info & audio bandwidth *-----------------------------------------------------------------*/ @@ -122,12 +120,6 @@ ivas_error ivas_cpe_dec_fx( * dynamically allocate data structures depending on the actual stereo mode *----------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED - IF( ( error = stereo_memory_dec( ivas_total_brate, hCPE, nb_bits_metadata, st_ivas->hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) - { - return error; - } -#else #if 1 // Float to fix conversions float maxim = 0; Word16 q_output_mem, q_buff_LBTCX_mem, q_input_mem_LB, q_old_out = 31, q_old_out_LB = 31, q_tcxltp_mem_in_float; @@ -136,17 +128,6 @@ ivas_error ivas_cpe_dec_fx( q_buff_LBTCX_mem = 11; q_input_mem_LB = q_buff_LBTCX_mem; maxim = 0; - //FOR( Word16 ind1 = 0; ind1 < 2; ind1++ ) - //{ - // IF( hCPE->hCoreCoder[ind1] && hCPE->hCoreCoder[ind1]->hHQ_core ) - // FOR( Word16 ind2 = 0; ind2 < st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC; ind2++ ) - // { - // maxim = fmaxf( fabsf( hCPE->hCoreCoder[ind1]->hHQ_core->old_out[ind2] ), maxim ); - // } - //} - //IF( maxim > 1.f ) - //q_old_out = norm_l( (Word32) maxim ); - //q_old_out -= 1; q_old_out = Q11; FOR( Word16 ind1 = 0; ind1 < 2; ind1++ ) { @@ -185,12 +166,6 @@ ivas_error ivas_cpe_dec_fx( IF( hCPE->hCoreCoder[ind2] && hCPE->hCoreCoder[ind2]->cldfbSyn ) hCPE->hCoreCoder[ind2]->cldfbSyn->scale = (Word16) ( hCPE->hCoreCoder[ind2]->cldfbSyn->scale_flt * ( 1u << norm_s( (Word16) hCPE->hCoreCoder[0]->cldfbSyn->scale_flt ) ) ); } - FOR(Word16 ind = 0; ind < L_FRAME16k / 2; ind++) { - //IF(hCPE->hCoreCoder[0] && hCPE->hCoreCoder[0]->hTcxDec) - //hCPE->hCoreCoder[0]->hTcxDec->old_syn_Overl_32[ind] = (Word32)(hCPE->hCoreCoder[0]->hTcxDec->old_syn_Overl_float[ind] * (ONE_IN_Q11)); - //IF(hCPE->hCoreCoder[1] && hCPE->hCoreCoder[1]->hTcxDec) - //hCPE->hCoreCoder[1]->hTcxDec->old_syn_Overl_32[ind] = (Word32)(hCPE->hCoreCoder[1]->hTcxDec->old_syn_Overl_float[ind] * (ONE_IN_Q11)); - } #endif // Float to fix conversions IF( ( error = stereo_memory_dec_fx( ivas_total_brate, hCPE, nb_bits_metadata, st_ivas->hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) @@ -214,13 +189,6 @@ ivas_error ivas_cpe_dec_fx( hCPE->hCoreCoder[ind1]->hHQ_core->old_outLB[ind2] = (float) ( hCPE->hCoreCoder[ind1]->hHQ_core->old_outLB_fx[ind2] ) / ( 1 << q_old_out_LB ); } } - FOR(Word16 ind = 0; ind < L_FRAME16k / 2; ind++) { - //IF(hCPE->hCoreCoder[0] && hCPE->hCoreCoder[0]->hTcxDec) - //hCPE->hCoreCoder[0]->hTcxDec->old_syn_Overl_float[ind] = (float)hCPE->hCoreCoder[0]->hTcxDec->old_syn_Overl_32[ind] / (float)(ONE_IN_Q11); - //IF(hCPE->hCoreCoder[1] && hCPE->hCoreCoder[1]->hTcxDec) - //hCPE->hCoreCoder[1]->hTcxDec->old_syn_Overl_float[ind] = (float)hCPE->hCoreCoder[1]->hTcxDec->old_syn_Overl_32[ind] / (float)(ONE_IN_Q11); - } -#endif // Fix to float conversions #endif /*------------------------------------------------------------------* @@ -598,13 +566,6 @@ ivas_error ivas_cpe_dec_fx( floatToFixed_arrL( sts[k]->hHQ_core->old_outLB, sts[k]->hHQ_core->old_outLB_fx, 11, L_FRAME32k ); } } - - IF( sts[0]->element_mode == IVAS_CPE_MDCT && sts[0]->total_brate == SID_2k40 ) - { - //f2me_buf(sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel, &sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, sts[ch]->hFdCngDec->hFdCngCom->stopBand - sts[ch]->hFdCngDec->hFdCngCom->startBand); - //floatToFixed_arr(sts[ch]->hFdCngDec->hFdCngCom->A_cng_flt, sts[ch]->hFdCngDec->hFdCngCom->A_cng, Q14, M + 1); - } - #endif IF( ( error = ivas_core_dec( st_ivas, NULL, hCPE, st_ivas->hMCT, n_channels, output, outputHB_fx, NULL, st_ivas->sba_dirac_stereo_flag ) ) != IVAS_ERR_OK ) { @@ -626,10 +587,9 @@ ivas_error ivas_cpe_dec_fx( test(); IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && !( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF ) ) ) { - float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX]; Word32 DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX]; - set_f( DFT[0], 0.0f, STEREO_DFT_BUF_MAX ); - set_f( DFT[1], 0.0f, STEREO_DFT_BUF_MAX ); + set32_fx( DFT_fx[0], 0, STEREO_DFT_BUF_MAX ); + set32_fx( DFT_fx[1], 0, STEREO_DFT_BUF_MAX ); #ifndef TO_BE_REMOVED_CONVERSION Word16 k; @@ -648,13 +608,10 @@ ivas_error ivas_cpe_dec_fx( FOR(Word16 ch = 0; ch < CPE_CHANNELS; ++ch) { f2me_buf(sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel, &sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, sts[ch]->hFdCngDec->hFdCngCom->stopBand - sts[ch]->hFdCngDec->hFdCngCom->startBand); - //floatToFixed_arr(sts[ch]->hFdCngDec->hFdCngCom->A_cng_flt, sts[ch]->hFdCngDec->hFdCngCom->A_cng, Q14, M + 1); } } #endif - set32_fx( DFT_fx[0], 0, STEREO_DFT_BUF_MAX ); - set32_fx( DFT_fx[1], 0, STEREO_DFT_BUF_MAX ); /* core decoder */ IF( ( error = ivas_core_dec( NULL, NULL, hCPE, st_ivas->hMCT, n_channels, output, outputHB_fx, DFT_fx, 0 ) ) != IVAS_ERR_OK ) @@ -662,11 +619,7 @@ ivas_error ivas_cpe_dec_fx( return error; } - fixedToFloat_arrL( DFT_fx[0], DFT[0], hCPE->hStereoDft->q_dft, STEREO_DFT_BUF_MAX ); - fixedToFloat_arrL( DFT_fx[1], DFT[1], hCPE->hStereoDft->q_dft, STEREO_DFT_BUF_MAX ); - // Scaling of DFT's - // Word16 q_dft_tmp = s_min(getScaleFactor32(DFT_fx[0], STEREO_DFT_BUF_MAX), getScaleFactor32(DFT_fx[1], STEREO_DFT_BUF_MAX)); Word16 shift; Word32 tmp1, tmp2; maximum_abs_32_fx( DFT_fx[0], STEREO_DFT_BUF_MAX, &tmp1 ); @@ -694,14 +647,8 @@ ivas_error ivas_cpe_dec_fx( test(); IF( GT_16( hCPE->hStereoDft->res_cod_band_max, 0 ) && !st_ivas->bfi ) { -#ifndef IVAS_FLOAT_FIXED - stereo_dft_dec_res( hCPE, res_buf, output_flt[1] ); - - stereo_dft_dec_analyze( hCPE, output[1], DFT, 1, L_FRAME8k, output_frame, DFT_STEREO_DEC_ANA_LB, 0, 0 ); -#else - // Word32 output_fix[L_FRAME8k]; - hCPE->hStereoDft->q_res_cod_mem_fx = 0; // keeping same as shift needed inside. - floatToFixed_arrL( hCPE->hStereoDft->res_cod_mem, hCPE->hStereoDft->res_cod_mem_fx, Q16, sizeof( hCPE->hStereoDft->res_cod_mem_fx ) / sizeof( hCPE->hStereoDft->res_cod_mem_fx[0] ) ); + Word16 q = Q11; + Word16 q_out_DFT[2]; Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->old_pitch_buf_fx, hCPE->hCoreCoder[0]->old_pitch_buf_16_fx, 2 * NB_SUBFR16k + 2, -10 ); @@ -709,78 +656,23 @@ ivas_error ivas_cpe_dec_fx( Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->old_pitch_buf_16_fx, hCPE->hCoreCoder[0]->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, 10 ); - fixedToFloat_arrL( hCPE->hStereoDft->res_cod_mem_fx, hCPE->hStereoDft->res_cod_mem, Q16, sizeof( hCPE->hStereoDft->res_cod_mem_fx ) / sizeof( hCPE->hStereoDft->res_cod_mem_fx[0] ) ); - Scale_sig32( output[1], L_FRAME8k, Q11 - Q15 ); // Q15 -> Q11 -#endif - Word16 q = Q11; - Word16 q_out_DFT[2]; + q_out_DFT[0] = q_out_DFT[1] = hCPE->hStereoDft->q_dft; - // output in Q11, q not modified - // q_out_DFT only of 1 modified - stereo_dft_dec_analyze_fx( hCPE, output[1], DFT_fx, 1, L_FRAME8k, output_frame, DFT_STEREO_DEC_ANA_LB, 0, 0, &q, q_out_DFT ); // q not modified + stereo_dft_dec_analyze_fx( hCPE, output[1], DFT_fx, 1, L_FRAME8k, output_frame, DFT_STEREO_DEC_ANA_LB, 0, 0, &q, q_out_DFT ); Scale_sig32( DFT_fx[1], STEREO_DFT_BUF_MAX, hCPE->hStereoDft->q_dft - q_out_DFT[1] ); } - fixedToFloat_arrL( DFT_fx[0], DFT[0], hCPE->hStereoDft->q_dft, STEREO_DFT_BUF_MAX ); - fixedToFloat_arrL( DFT_fx[1], DFT[1], hCPE->hStereoDft->q_dft, STEREO_DFT_BUF_MAX ); - /* DFT stereo CNG */ -#ifndef IVAS_FLOAT_FIXED - stereo_dtf_cng( hCPE, ivas_total_brate, DFT, output_frame ); -#else { Word16 q_dft; -#if 0 - Word16 q_smoothed_psd; - float max_val = 0.0; - int i_max_val = 0, i_max_val_psd = 0; - for (int ii = 0; ii < sizeof(DFT) / sizeof(DFT[0]); ii++) - { - for (int jj = 0; jj < sizeof(DFT[0]) / sizeof(DFT[0][0]); jj++) - { - if (max_val < fabs(DFT[ii][jj])) - { - max_val = (float)fabs(DFT[ii][jj]); - } - } - } - //max_val = 0.0; - //for (int ii = 0; ii < sizeof(sts[0]->hFdCngDec->smoothed_psd) / sizeof(sts[0]->hFdCngDec->smoothed_psd[0]); ii++) - //{ - // if (max_val < fabs(sts[0]->hFdCngDec->smoothed_psd[ii])) - // { - // max_val = (float)fabs(sts[0]->hFdCngDec->smoothed_psd[ii]); - // } - //} - //i_max_val_psd = (int)max_val; - //sts[0]->hFdCngDec->q_smoothed_psd = norm_l(i_max_val_psd) - Q4; - i_max_val = (int)max_val; - if (i_max_val !=0) - q_dft = s_min(Q8, norm_l(i_max_val)); - else - q_dft = Q8; -#endif q_dft = hCPE->hStereoDft->q_dft; - // hCPE->hStereoDft->q_dft = norm_l(i_max_val); - // IF (hCPE->hStereoDft->q_dft > Q8) - //{ - // hCPE->hStereoDft->q_dft = Q8; - //} - //floatToFixed_arrL(sts[0]->hFdCngDec->bandNoiseShape_float, sts[0]->hFdCngDec->bandNoiseShape, Q31 - sts[0]->hFdCngDec->bandNoiseShape_exp, FFTLEN2); - floatToFixed_arrL(&DFT[0][0], &DFT_fx[0][0], q_dft, sizeof(DFT) / sizeof(DFT[0][0])); - //floatToFixed_arr(&hCPE->hCoreCoder[0]->hTdCngDec->shb_lpcCNG[0], &hCPE->hCoreCoder[0]->hTdCngDec->shb_lpcCNG_fx[0], Q15, sizeof(hCPE->hCoreCoder[0]->hTdCngDec->shb_lpcCNG_fx) / sizeof(hCPE->hCoreCoder[0]->hTdCngDec->shb_lpcCNG_fx[0])); floatToFixed_arr(&hCPE->hStereoCng->cm[0], &hCPE->hStereoCng->cm_fx[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); floatToFixed_arr(&hCPE->hStereoCng->coh[0], &hCPE->hStereoCng->coh_fx[0], Q15, sizeof(hCPE->hStereoCng->coh_fx) / sizeof(hCPE->hStereoCng->coh_fx[0]) ); - //floatToFixed_arrL(&sts[0]->hFdCngDec->smoothed_psd[0], &sts[0]->hFdCngDec->smoothed_psd_fx[0], sts[0]->hFdCngDec->q_smoothed_psd, sizeof(sts[0]->hFdCngDec->smoothed_psd_fx) / sizeof(sts[0]->hFdCngDec->smoothed_psd_fx[0])); - //floatToFixed_arrL(&hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[0], - // &hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel[0], - // 0, - // FFTCLDFBLEN); //TODO : To check this hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->q_cngNoiseLevel = Q31 - hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp; @@ -790,59 +682,15 @@ ivas_error ivas_cpe_dec_fx( &hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[0], hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->q_cngNoiseLevel, FFTCLDFBLEN ); - // fixedToFloat_arrL(&sts[0]->hFdCngDec->smoothed_psd_fx[0], &sts[0]->hFdCngDec->smoothed_psd[0], sts[0]->hFdCngDec->q_smoothed_psd, sizeof(sts[0]->hFdCngDec->smoothed_psd_fx) / sizeof(sts[0]->hFdCngDec->smoothed_psd_fx[0])); fixedToFloat_arr( &hCPE->hStereoCng->coh_fx[0], &hCPE->hStereoCng->coh[0], Q15, sizeof( hCPE->hStereoCng->coh_fx ) / sizeof( hCPE->hStereoCng->coh_fx[0] ) ); fixedToFloat_arr( &hCPE->hStereoCng->cm_fx[0], &hCPE->hStereoCng->cm[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); - // fixedToFloat_arr(&hCPE->hCoreCoder[0]->hTdCngDec->shb_lpcCNG_fx[0], &hCPE->hCoreCoder[0]->hTdCngDec->shb_lpcCNG[0], Q15, sizeof(hCPE->hCoreCoder[0]->hTdCngDec->shb_lpcCNG) / sizeof(hCPE->hCoreCoder[0]->hTdCngDec->shb_lpcCNG[0])); - // fixedToFloat_arrL(sts[0]->hFdCngDec->bandNoiseShape, sts[0]->hFdCngDec->bandNoiseShape_float, Q31 - sts[0]->hFdCngDec->bandNoiseShape_exp, FFTLEN2); - fixedToFloat_arrL( &DFT_fx[0][0], &DFT[0][0], q_dft, sizeof( DFT ) / sizeof( DFT[0][0] ) ); } -#endif /* decoding */ IF( EQ_16( hCPE->nchan_out, 1 ) ) { #if 1 float l_hb_nrg = 0.0, l_hb_nrg_subr = 0.0; -#if 0 - float max_val = 0.0; - int i_max_val = 0, i_max_val_psd; - //for (int ii = 0; ii < sizeof(sts[0]->hFdCngDec->smoothed_psd) / sizeof(sts[0]->hFdCngDec->smoothed_psd[0]); ii++) - //{ - // if (max_val < fabs(sts[0]->hFdCngDec->smoothed_psd[ii])) - // { - // max_val = (float)fabs(sts[0]->hFdCngDec->smoothed_psd[ii]); - // } - //} - //i_max_val_psd = (int)max_val; - //sts[0]->hFdCngDec->q_smoothed_psd = norm_l(i_max_val_psd) - Q4; - max_val = 0.0; - for (int ii = 0; ii < sizeof(DFT) / sizeof(DFT[0]); ii++) - { - for (int jj = 0; jj < sizeof(DFT[0]) / sizeof(DFT[0][0]); jj++) - { - if (max_val < fabs(DFT[ii][jj])) - { - max_val = (float)fabs(DFT[ii][jj]); - } - } - } - i_max_val = (int)max_val; - hCPE->hStereoDft->q_dft = norm_l(i_max_val) - Q6; - IF(hCPE->hStereoDft->q_dft > Q15) - { - hCPE->hStereoDft->q_dft = Q15; - } - ELSE IF(hCPE->hStereoDft->q_dft < 0) - { - hCPE->hStereoDft->q_dft = 0; - } - //hCPE->hStereoDft->q_dft = s_min(hCPE->hStereoDft->q_dft, sts[0]->hFdCngDec->q_smoothed_psd); - IF(hCPE->hStereoDft->q_dft < 0) - { - hCPE->hStereoDft->q_dft = 0; - } -#endif IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) { hCPE->hStereoDft->q_smoothed_nrg = hCPE->hStereoDft->q_dft; @@ -853,8 +701,9 @@ ivas_error ivas_cpe_dec_fx( hCPE->hStereoDft->first_frame = 0; } - floatToFixed_arrL( &DFT[0][0], &DFT_fx[0][0], hCPE->hStereoDft->q_dft, sizeof( DFT ) / sizeof( DFT[0][0] ) ); - floatToFixed_arrL( &hCPE->hStereoDft->res_cod_mem[0], &hCPE->hStereoDft->res_cod_mem_fx[0], hCPE->hStereoDft->q_dft, sizeof( hCPE->hStereoDft->res_cod_mem_fx ) / sizeof( hCPE->hStereoDft->res_cod_mem_fx[0] ) ); + scale_sig32( hCPE->hStereoDft->res_cod_mem_fx, STEREO_DFT_OVL_8k, sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_res_cod_mem_fx ) ); + hCPE->hStereoDft->q_res_cod_mem_fx = hCPE->hStereoDft->q_dft; + for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_subr_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_subr_fx[0] ); ii++ ) { if ( l_hb_nrg_subr < hCPE->hStereoDft->hb_nrg_subr[ii] ) @@ -896,18 +745,9 @@ ivas_error ivas_cpe_dec_fx( #endif stereo_dft_unify_dmx_fx( hCPE->hStereoDft, sts[0], DFT_fx, hCPE->input_mem_fx[1], hCPE->hStereoCng->prev_sid_nodata ); #if 1 - if ( hCPE->hStereoDft->res_cod_band_max > 0 ) - { - if ( !sts[0]->bfi ) - { - fixedToFloat_arrL( &hCPE->hStereoDft->res_mem_fx[0], &hCPE->hStereoDft->res_mem[0], hCPE->hStereoDft->q_res_mem, 2 * hCPE->hStereoDft->band_limits[hCPE->hStereoDft->res_cod_band_max] ); - } - else - { - fixedToFloat_arrL( &hCPE->hStereoDft->res_cod_mem_fx[0], &hCPE->hStereoDft->res_cod_mem[0], hCPE->hStereoDft->q_res_cod_mem_fx, sizeof( hCPE->hStereoDft->res_cod_mem_fx ) / sizeof( hCPE->hStereoDft->res_cod_mem_fx[0] ) ); - } - } - fixedToFloat_arrL( &DFT_fx[0][0], &DFT[0][0], hCPE->hStereoDft->q_dft, ( sizeof( DFT ) / ( 2 * sizeof( DFT[0][0] ) ) ) ); + scale_sig32( hCPE->hStereoDft->res_cod_mem_fx, STEREO_DFT_OVL_8k, sub( Q16, hCPE->hStereoDft->q_res_cod_mem_fx ) ); + hCPE->hStereoDft->q_res_cod_mem_fx = Q16; + for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_subr_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_subr_fx[0] ); ii++ ) { hCPE->hStereoDft->hb_nrg_subr[0] = ( (float) hCPE->hStereoDft->hb_nrg_subr_fx[0] * ( (float) ( 1 << hCPE->hStereoDft->q_hb_nrg_subr ) ) ); @@ -923,46 +763,8 @@ ivas_error ivas_cpe_dec_fx( ELSE { float l_hb_nrg = 0.0, l_hb_nrg_subr = 0.0; +#if 1 { -#if 0 - float max_val = 0.0; - int i_max_val = 0, i_max_val_psd; - //for (int ii = 0; ii < sizeof(sts[0]->hFdCngDec->smoothed_psd) / sizeof(sts[0]->hFdCngDec->smoothed_psd[0]); ii++) - //{ - // if (max_val < fabs(sts[0]->hFdCngDec->smoothed_psd[ii])) - // { - // max_val = (float)fabs(sts[0]->hFdCngDec->smoothed_psd[ii]); - // } - //} - //i_max_val_psd = (int)max_val; - //sts[0]->hFdCngDec->q_smoothed_psd = norm_l(i_max_val_psd) - Q4; - max_val = 0.0; - for (int ii = 0; ii < sizeof(DFT) / sizeof(DFT[0]); ii++) - { - for (int jj = 0; jj < sizeof(DFT[0]) / sizeof(DFT[0][0]); jj++) - { - if (max_val < fabs(DFT[ii][jj])) - { - max_val = (float)fabs(DFT[ii][jj]); - } - } - } - i_max_val = (int)max_val; - hCPE->hStereoDft->q_dft = norm_l(i_max_val) - Q6; - IF (hCPE->hStereoDft->q_dft > Q15) - { - hCPE->hStereoDft->q_dft = Q15; - } - ELSE IF(hCPE->hStereoDft->q_dft < 0) - { - hCPE->hStereoDft->q_dft = 0; - } - //hCPE->hStereoDft->q_dft = s_min(hCPE->hStereoDft->q_dft, sts[0]->hFdCngDec->q_smoothed_psd); - IF (hCPE->hStereoDft->q_dft < 0) - { - hCPE->hStereoDft->q_dft = 0; - } -#endif IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) { hCPE->hStereoDft->q_smoothed_nrg = hCPE->hStereoDft->q_dft; @@ -973,10 +775,9 @@ ivas_error ivas_cpe_dec_fx( hCPE->hStereoDft->first_frame = 0; } - // sts[0]->hFdCngDec->cna_rescale_fact_fx = (Word16)floatToFixed(sts[0]->hFdCngDec->cna_rescale_fact, 15); - // floatToFixed_arrL(&sts[0]->hFdCngDec->smoothed_psd[0], &sts[0]->hFdCngDec->smoothed_psd_fx[0], sts[0]->hFdCngDec->q_smoothed_psd, sizeof(sts[0]->hFdCngDec->smoothed_psd_fx) / sizeof(sts[0]->hFdCngDec->smoothed_psd_fx[0])); - floatToFixed_arrL( &DFT[0][0], &DFT_fx[0][0], hCPE->hStereoDft->q_dft, sizeof( DFT ) / sizeof( DFT[0][0] ) ); - floatToFixed_arrL( &hCPE->hStereoDft->res_cod_mem[0], &hCPE->hStereoDft->res_cod_mem_fx[0], hCPE->hStereoDft->q_dft, sizeof( hCPE->hStereoDft->res_cod_mem_fx ) / sizeof( hCPE->hStereoDft->res_cod_mem_fx[0] ) ); + scale_sig32( hCPE->hStereoDft->res_cod_mem_fx, STEREO_DFT_OVL_8k, sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_res_cod_mem_fx ) ); + hCPE->hStereoDft->q_res_cod_mem_fx = hCPE->hStereoDft->q_dft; + for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_subr_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_subr_fx[0] ); ii++ ) { if ( l_hb_nrg_subr < hCPE->hStereoDft->hb_nrg_subr[ii] ) @@ -1014,15 +815,12 @@ ivas_error ivas_cpe_dec_fx( hCPE->hStereoDft->hb_nrg_fx[ii] = (Word32) ( hCPE->hStereoDft->hb_nrg[ii] / ( (float) ( 1 << hCPE->hStereoDft->q_hb_nrg ) ) ); } - // floatToFixed_arr(&sts[0]->hFdCngDec->cna_cm[0], &sts[0]->hFdCngDec->cna_cm_fx[0], Q15, sizeof(sts[0]->hFdCngDec->cna_cm_fx) / sizeof(sts[0]->hFdCngDec->cna_cm_fx[0])); floatToFixed_arr( &hCPE->hStereoCng->cm[0], &hCPE->hStereoCng->cm_fx[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); - // floatToFixed_arr(&sts[0]->hFdCngDec->cna_g_state[0], &sts[0]->hFdCngDec->cna_g_state_fx[0], Q15, sizeof(sts[0]->hFdCngDec->cna_g_state_fx) / sizeof(sts[0]->hFdCngDec->cna_g_state_fx[0])); } +#endif stereo_dft_dec_fx( hCPE->hStereoDft, sts[0], DFT_fx, hCPE->input_mem_fx[1], hCPE->hStereoCng, 0, 0, 0, 0, 0, 0, MAX_PARAM_SPATIAL_SUBFRAMES ); +#if 1 { - // sts[0]->hFdCngDec->cna_rescale_fact = fixedToFloat(sts[0]->hFdCngDec->cna_rescale_fact_fx, 15); - // fixedToFloat_arrL(&sts[0]->hFdCngDec->smoothed_psd_fx[0], &sts[0]->hFdCngDec->smoothed_psd[0], sts[0]->hFdCngDec->q_smoothed_psd, sizeof(sts[0]->hFdCngDec->smoothed_psd_fx) / sizeof(sts[0]->hFdCngDec->smoothed_psd_fx[0])); - fixedToFloat_arrL( &DFT_fx[0][0], &DFT[0][0], hCPE->hStereoDft->q_dft, sizeof( DFT ) / sizeof( DFT[0][0] ) ); for ( int ii = 0; ii < sizeof( hCPE->hStereoDft->hb_nrg_subr_fx ) / sizeof( hCPE->hStereoDft->hb_nrg_subr_fx[0] ); ii++ ) { hCPE->hStereoDft->hb_nrg_subr[0] = ( (float) hCPE->hStereoDft->hb_nrg_subr_fx[0] * ( (float) ( 1 << hCPE->hStereoDft->q_hb_nrg_subr ) ) ); @@ -1031,12 +829,13 @@ ivas_error ivas_cpe_dec_fx( { hCPE->hStereoDft->hb_nrg[ii] = ( (float) hCPE->hStereoDft->hb_nrg_fx[ii] * ( (float) ( 1 << hCPE->hStereoDft->q_hb_nrg ) ) ); } - // fixedToFloat_arr(&sts[0]->hFdCngDec->cna_cm_fx[0], &sts[0]->hFdCngDec->cna_cm[0], Q15, sizeof(sts[0]->hFdCngDec->cna_cm_fx) / sizeof(sts[0]->hFdCngDec->cna_cm_fx[0])); fixedToFloat_arr( &hCPE->hStereoCng->cm_fx[0], &hCPE->hStereoCng->cm[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); - // fixedToFloat_arr(&sts[0]->hFdCngDec->cna_g_state_fx[0], &sts[0]->hFdCngDec->cna_g_state[0], Q15, sizeof(sts[0]->hFdCngDec->cna_g_state_fx) / sizeof(sts[0]->hFdCngDec->cna_g_state_fx[0])); fixedToFloat_arrL( &hCPE->hStereoDft->td_gain_fx[0], &hCPE->hStereoDft->td_gain[0], Q15, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); - fixedToFloat_arrL( &hCPE->hStereoDft->res_cod_mem_fx[0], &hCPE->hStereoDft->res_cod_mem[0], hCPE->hStereoDft->q_dft, sizeof( hCPE->hStereoDft->res_cod_mem_fx ) / sizeof( hCPE->hStereoDft->res_cod_mem_fx[0] ) ); + + scale_sig32( hCPE->hStereoDft->res_cod_mem_fx, STEREO_DFT_OVL_8k, sub( Q16, hCPE->hStereoDft->q_res_cod_mem_fx ) ); + hCPE->hStereoDft->q_res_cod_mem_fx = Q16; } +#endif } FOR( n = 0; n < hCPE->nchan_out; n++ ) @@ -1050,15 +849,7 @@ ivas_error ivas_cpe_dec_fx( /* synthesis iFFT */ FOR( n = 0; n < hCPE->nchan_out; n++ ) { -#ifndef IVAS_FLOAT_FIXED - stereo_dft_dec_synthesize( hCPE, DFT, n, output_flt[n], output_frame ); -#else - floatToFixed_arrL( &DFT[n][0], &DFT_fx[n][0], hCPE->hStereoDft->q_dft, sizeof( DFT[n] ) / sizeof( DFT[0][0] ) ); - stereo_dft_dec_synthesize_fx( hCPE, DFT_fx, n, output[n], output_frame ); - - fixedToFloat_arrL( &DFT_fx[n][0], &DFT[n][0], hCPE->hStereoDft->q_dft, sizeof( DFT_fx[n] ) / sizeof( DFT_fx[0][0] ) ); -#endif } // delete below @@ -1202,8 +993,6 @@ ivas_error ivas_cpe_dec_fx( st_ivas->BER_detect = s_or( st_ivas->BER_detect, sts[0]->BER_detect ); st_ivas->BER_detect = s_or( st_ivas->BER_detect, sts[1]->BER_detect ); -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED -#endif pop_wmops(); return error; diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 2715e6abe92926e657d396e8b59bb9bbbcee6e09..34be75e2e6c9166ad2f991dffcd3a026dde9089a 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -3599,7 +3599,7 @@ void ivas_dirac_dec_render_sf_fx( float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - int16_t index, num_freq_bands; + int16_t index = 0, num_freq_bands = 0; /* local copies of azi, ele, diffuseness */ Word16 azimuth[CLDFB_NO_CHANNELS_MAX]; @@ -3623,8 +3623,9 @@ void ivas_dirac_dec_render_sf_fx( Word32 Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; set_zero_fx(surCohRatio_fx, CLDFB_NO_CHANNELS_MAX); - Word16 q_cldfb, q_temp_cldfb;; + Word16 q_cldfb, q_temp_cldfb = 0; //Word32 proto_frame_f_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX]; + Word32 proto_direct_buffer_f_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX]; Word32 proto_power_smooth_fx[2 * CLDFB_NO_CHANNELS_MAX * MAX_OUTPUT_CHANNELS]; Word32 reference_power_fix[5 * CLDFB_NO_CHANNELS_MAX]; @@ -3810,7 +3811,7 @@ void ivas_dirac_dec_render_sf_fx( } IF( EQ_16( hDirAC->hConfig->dec_param_estim, TRUE ) ) { - Word16 val = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; + //Word16 val = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; FOR( i = 0; i < 32; i++ ) { Word16 exp1 = 0, exp2 = 0, exp3 = 0; @@ -5477,7 +5478,9 @@ void ivas_dirac_dec_render_sf_fx( if ( fabsf( gain ) > 0.0f || fabsf( prev_gain ) > 0.0f ) { float *tc_re, *tc_im; + float *w1, w2; + w1 = &st_ivas->hIsmRendererData->interpolator[interp_offset]; tc_re = pppQMfFrame_ts_re[nchan_transport + i][0]; tc_im = pppQMfFrame_ts_im[nchan_transport + i][0]; diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 374a0dc9ac13af4f6668455bec359a87eef86649..2d3686cfad963824351d5d8871f77edda7b961ae 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -1441,7 +1441,7 @@ Word16 computeMixingMatrices_fx( Word32 svd_u_buffer_fx[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; Word32 svd_v_buffer_fx[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; - Word16 mat_mult_buffer1_fx_e; + //Word16 mat_mult_buffer1_fx_e; Word16 Cx_fx_e; Word16 Cy_fx_e; Word16 svd_u_buffer_fx_e[MAX_OUTPUT_CHANNELS]; @@ -1493,7 +1493,7 @@ Word16 computeMixingMatrices_fx( Word32 adj_fx[MAX_OUTPUT_CHANNELS]; Word16 adj_e[MAX_OUTPUT_CHANNELS]; Word32 *adj_fx_p; - Word32 adj_buff_fx[MAX_OUTPUT_CHANNELS]; + //Word32 adj_buff_fx[MAX_OUTPUT_CHANNELS]; Word16 adj_fx_e; Word32 *Cr_p_fx, *Cy_tilde_p_fx, *Cy_p_fx; @@ -2278,8 +2278,8 @@ Word16 computeMixingMatricesResidual_fx( { Word16 i, j; Word16 out = EXIT_SUCCESS; - Word16 lengthCx = num_outputs; - Word16 lengthCy = num_outputs; + Word16 lengthCx = extract_l(num_outputs); + Word16 lengthCy = extract_l(num_outputs); #ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED float svd_in_buffer[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; @@ -2303,7 +2303,7 @@ Word16 computeMixingMatricesResidual_fx( Word32 mat_mult_buffer1_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; Word32 adj_fx[MAX_OUTPUT_CHANNELS]; Word32 mat_mult_buffer3_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; - Word16 mixing_matrix_e, mat_mult_buffer1_e, adj_e, mat_mult_buffer3_e, mat_mult_buffer2_e; + Word16 mixing_matrix_e = 0, mat_mult_buffer1_e, adj_e, mat_mult_buffer3_e, mat_mult_buffer2_e; Word32 svd_s_buffer_fx[MAX_OUTPUT_CHANNELS]; Word16 svd_s_buffer_fx_e; @@ -2487,7 +2487,7 @@ Word16 computeMixingMatricesResidual_fx( *-----------------------------------------------------------------*/ /* Computing Cy_hat_diag */ - Copy32(Cx_fx, Cy_hat_diag_fx, num_outputs); + Copy32(Cx_fx, Cy_hat_diag_fx, extract_l(num_outputs)); Cy_hat_diag_e = Cx_e; FOR ( i = 0; i < lengthCy; ++i ) @@ -2545,7 +2545,7 @@ Word16 computeMixingMatricesResidual_fx( { L_tmp = Mpy_32_32(Ky_fx[i + j * num_outputs], fac_fx); mat_mult_buffer1_fx[i + j * num_outputs] = L_tmp; - mat_mult_buffer1_buff_e[i + j * num_outputs] = L_add( Ky_fx_e[i + j * num_outputs], Kx_fx_e[i] ); + mat_mult_buffer1_buff_e[i + j * num_outputs] = extract_l(L_add( Ky_fx_e[i + j * num_outputs], Kx_fx_e[i] )); } } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 4cf481f52ced6c4cdfcb774c6bc886751f618e36..b962184bbc9d86e0c9c6b6bb893bf4c0bcde1dfb 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -3935,7 +3935,7 @@ void ivas_destroy_dec( free( st_ivas->mem_hp20_out_fx ); st_ivas->mem_hp20_out_fx = NULL; } -#else +#endif IF(st_ivas->mem_hp20_out != NULL) { FOR(i = 0; i < getNumChanSynthesis(st_ivas); i++) @@ -3946,7 +3946,6 @@ void ivas_destroy_dec( free(st_ivas->mem_hp20_out); st_ivas->mem_hp20_out = NULL; } -#endif /* ISM metadata handles */ ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); @@ -4067,11 +4066,16 @@ void ivas_destroy_dec( IF ( st_ivas->hBinRendererTd != NULL ) { ivas_td_binaural_close( &st_ivas->hBinRendererTd ); +#ifdef IVAS_FLOAT_FIXED + ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd ); +#endif } ELSE IF ( st_ivas->hHrtfTD != NULL ) { BSplineModelEvalDealloc( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval ); - +#ifdef IVAS_FLOAT_FIXED + BSplineModelEvalDealloc_fx( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval ); +#endif ivas_HRTF_binary_close( &st_ivas->hHrtfTD ); } diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index f11f5cb76a5213428e439b8cb02920a2c4c30fcc..f684450d42b77b7b8012488c50800b84c2825582 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -41,6 +41,7 @@ #include "ivas_prot_fx.h" #include "prot_fx2.h" #endif // IVAS_FLOAT_FIXED +#define IVAS_FLOAT_FIXED_TO_BE_REMOVED /*-------------------------------------------------------------------------* * ivas_ism_bitrate_switching_dec() @@ -108,6 +109,12 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( { return error; } +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED + IF( ( error = ivas_hp20_dec_reconfig( st_ivas, nchan_transport_old ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif /* save old IntSetup, might be needed for JBM flushing...*/ intern_config_old = st_ivas->intern_config; diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 953792c7bd8fb0c4882482571d140633c71ce539..e17a48831349c88de09e152cd54f9e3c17b47266 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1839,7 +1839,7 @@ void ivas_param_ism_dec_digest_tc( { #ifdef IVAS_FLOAT_FIXED ivas_param_ism_dec_dequant_DOA_fx( hParamIsmDec, st_ivas->nchan_ism ); - for ( int i = 0; i < 11; i++ ) + for ( i = 0; i < 11; i++ ) { for ( int j = 0; j < 1; j++ ) { @@ -1850,7 +1850,7 @@ void ivas_param_ism_dec_digest_tc( } } ivas_param_ism_dec_dequant_powrat_fx( hParamIsmDec ); - for ( int i = 0; i < 11; i++ ) + for ( i = 0; i < 11; i++ ) { for ( int j = 0; j < 1; j++ ) { diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index d9e80e09ad84f463ac1b93ebb79616ffd2f6ef22..0e7d2deaa6e98067ba14788444fe1401991fe0c0 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -236,7 +236,10 @@ void ivas_ism_render_sf( ) { int16_t i, j, k, j2; - float *g1, g2, *tc; + float g2, *tc; +#ifndef IVAS_FLOAT_FIXED + float *g1; +#endif int16_t num_objects, nchan_out_woLFE, lfe_index; int16_t azimuth, elevation; int16_t tc_offset; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 32aa6f4a47a79d397ef1617bbd4d848992033d88..385c0505b54b939550006c05c586ed3ab6a84c1e 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -339,7 +339,7 @@ ivas_error ivas_jbm_dec_tc( { st_ivas->hSpatParamRendCom->energy_ratio1[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->energy_ratio1_fx[i][j], 30 ); st_ivas->hSpatParamRendCom->diffuseness_vector[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->diffuseness_vector_fx[i][j], 30 ); - IF( EQ_16( st_ivas->hQMetaData->no_directions, 2 ) ) + IF( EQ_32( st_ivas->hQMetaData->no_directions, 2 ) ) { st_ivas->hSpatParamRendCom->energy_ratio2[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->energy_ratio2_fx[i][j], 30 ); st_ivas->hSpatParamRendCom->spreadCoherence2[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->spreadCoherence2_fx[i][j], 15 ); @@ -810,10 +810,10 @@ ivas_error ivas_jbm_dec_tc( IF( hCPE->hStereoDft != NULL ) { scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); + scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); + hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; + floatToFixed_arrL( &hCPE->hStereoDft->td_gain[0], &hCPE->hStereoDft->td_gain_fx[0], Q31, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); - floatToFixed_arrL( &hCPE->hStereoDft->ap_delay_mem[0], &hCPE->hStereoDft->ap_delay_mem_fx[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); - hCPE->hStereoDft->q_smooth_buf_fx = Q7; - floatToFixed_arrL( &hCPE->hStereoDft->smooth_buf[0][0], &hCPE->hStereoDft->smooth_buf_fx[0][0], hCPE->hStereoDft->q_smooth_buf_fx, sizeof( hCPE->hStereoDft->smooth_buf_fx ) / sizeof( hCPE->hStereoDft->smooth_buf_fx[0][0] ) ); floatToFixed_arrL( &st_ivas->hSpar->hMdDec->mixer_mat_prev[0][0][0][0], &st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0], Q31, sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx ) / sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0] ) ); } for ( int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++ ) @@ -874,10 +874,11 @@ ivas_error ivas_jbm_dec_tc( IF( hCPE->hStereoDft != NULL ) { scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); + scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); + hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; + fixedToFloat_arrL( &hCPE->hStereoDft->td_gain_fx[0], &hCPE->hStereoDft->td_gain[0], Q31, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); - fixedToFloat_arrL( &hCPE->hStereoDft->ap_delay_mem_fx[0], &hCPE->hStereoDft->ap_delay_mem[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); fixedToFloat_arrL( &st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0], &st_ivas->hSpar->hMdDec->mixer_mat_prev[0][0][0][0], Q31, sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx ) / sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0] ) ); - fixedToFloat_arrL( &hCPE->hStereoDft->smooth_buf_fx[0][0], &hCPE->hStereoDft->smooth_buf[0][0], hCPE->hStereoDft->q_smooth_buf_fx, sizeof( hCPE->hStereoDft->smooth_buf_fx ) / sizeof( hCPE->hStereoDft->smooth_buf_fx[0][0] ) ); } for ( int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++ ) { @@ -1202,7 +1203,7 @@ ivas_error ivas_jbm_dec_tc( { st_ivas->hSpatParamRendCom->energy_ratio1[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->energy_ratio1_fx[i][j], 30 ); st_ivas->hSpatParamRendCom->diffuseness_vector[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->diffuseness_vector_fx[i][j], 30 ); - IF( EQ_16( st_ivas->hQMetaData->no_directions, 2 ) ) + IF( EQ_32( st_ivas->hQMetaData->no_directions, 2 ) ) { st_ivas->hSpatParamRendCom->energy_ratio2[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->energy_ratio2_fx[i][j], 30 ); st_ivas->hSpatParamRendCom->spreadCoherence2[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->spreadCoherence2_fx[i][j], 15 ); @@ -1698,10 +1699,10 @@ ivas_error ivas_jbm_dec_tc( IF( hCPE->hStereoDft != NULL ) { scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); + scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); + hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; + floatToFixed_arrL( &hCPE->hStereoDft->td_gain[0], &hCPE->hStereoDft->td_gain_fx[0], Q31, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); - floatToFixed_arrL( &hCPE->hStereoDft->ap_delay_mem[0], &hCPE->hStereoDft->ap_delay_mem_fx[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); - hCPE->hStereoDft->q_smooth_buf_fx = Q7; - floatToFixed_arrL( &hCPE->hStereoDft->smooth_buf[0][0], &hCPE->hStereoDft->smooth_buf_fx[0][0], hCPE->hStereoDft->q_smooth_buf_fx, sizeof( hCPE->hStereoDft->smooth_buf_fx ) / sizeof( hCPE->hStereoDft->smooth_buf_fx[0][0] ) ); floatToFixed_arrL( &st_ivas->hSpar->hMdDec->mixer_mat_prev[0][0][0][0], &st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0], Q31, sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx ) / sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0] ) ); } for ( int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++ ) @@ -1759,10 +1760,11 @@ ivas_error ivas_jbm_dec_tc( IF( hCPE->hStereoDft != NULL ) { scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); + scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); + hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; + fixedToFloat_arrL( &hCPE->hStereoDft->td_gain_fx[0], &hCPE->hStereoDft->td_gain[0], Q31, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); - fixedToFloat_arrL( &hCPE->hStereoDft->ap_delay_mem_fx[0], &hCPE->hStereoDft->ap_delay_mem[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); fixedToFloat_arrL( &st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0], &st_ivas->hSpar->hMdDec->mixer_mat_prev[0][0][0][0], Q31, sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx ) / sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0] ) ); - fixedToFloat_arrL( &hCPE->hStereoDft->smooth_buf_fx[0][0], &hCPE->hStereoDft->smooth_buf[0][0], hCPE->hStereoDft->q_smooth_buf_fx, sizeof( hCPE->hStereoDft->smooth_buf_fx ) / sizeof( hCPE->hStereoDft->smooth_buf_fx[0][0] ) ); } for ( int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++ ) { @@ -2636,7 +2638,7 @@ ivas_error ivas_jbm_dec_tc( { st_ivas->hSpatParamRendCom->energy_ratio1[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->energy_ratio1_fx[i][j], 30 ); st_ivas->hSpatParamRendCom->diffuseness_vector[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->diffuseness_vector_fx[i][j], 30 ); - IF( EQ_16( st_ivas->hQMetaData->no_directions, 2 ) ) + IF( EQ_32( st_ivas->hQMetaData->no_directions, 2 ) ) { st_ivas->hSpatParamRendCom->energy_ratio2[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->energy_ratio2_fx[i][j], 30 ); st_ivas->hSpatParamRendCom->spreadCoherence2[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->spreadCoherence2_fx[i][j], 15 ); @@ -2838,10 +2840,10 @@ ivas_error ivas_jbm_dec_tc( IF( hCPE->hStereoDft != NULL ) { scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); + scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); + hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; + floatToFixed_arrL( &hCPE->hStereoDft->td_gain[0], &hCPE->hStereoDft->td_gain_fx[0], Q31, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); - floatToFixed_arrL( &hCPE->hStereoDft->ap_delay_mem[0], &hCPE->hStereoDft->ap_delay_mem_fx[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); - hCPE->hStereoDft->q_smooth_buf_fx = Q7; - floatToFixed_arrL( &hCPE->hStereoDft->smooth_buf[0][0], &hCPE->hStereoDft->smooth_buf_fx[0][0], hCPE->hStereoDft->q_smooth_buf_fx, sizeof( hCPE->hStereoDft->smooth_buf_fx ) / sizeof( hCPE->hStereoDft->smooth_buf_fx[0][0] ) ); } IF( st_ivas->hSpar != NULL ) { @@ -2903,9 +2905,10 @@ ivas_error ivas_jbm_dec_tc( IF( hCPE->hStereoDft != NULL ) { scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); + scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); + hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; + fixedToFloat_arrL( &hCPE->hStereoDft->td_gain_fx[0], &hCPE->hStereoDft->td_gain[0], Q31, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); - fixedToFloat_arrL( &hCPE->hStereoDft->ap_delay_mem_fx[0], &hCPE->hStereoDft->ap_delay_mem[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); - fixedToFloat_arrL( &hCPE->hStereoDft->smooth_buf_fx[0][0], &hCPE->hStereoDft->smooth_buf[0][0], hCPE->hStereoDft->q_smooth_buf_fx, sizeof( hCPE->hStereoDft->smooth_buf_fx ) / sizeof( hCPE->hStereoDft->smooth_buf_fx[0][0] ) ); } IF( st_ivas->hSpar != NULL ) { @@ -2913,8 +2916,6 @@ ivas_error ivas_jbm_dec_tc( for ( int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++ ) { fixedToFloat_arrL( &hCPE->hStereoDft->td_gain_fx[0], &hCPE->hStereoDft->td_gain[0], Q31, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); - fixedToFloat_arrL( &hCPE->hStereoDft->ap_delay_mem_fx[0], &hCPE->hStereoDft->ap_delay_mem[0], q, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); - fixedToFloat_arrL( &hCPE->hStereoDft->smooth_buf_fx[0][0], &hCPE->hStereoDft->smooth_buf[0][0], hCPE->hStereoDft->q_smooth_buf_fx, sizeof( hCPE->hStereoDft->smooth_buf_fx ) / sizeof( hCPE->hStereoDft->smooth_buf_fx[0][0] ) ); } IF( st_ivas->hSpar != NULL ) { @@ -4945,7 +4946,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( } f2me_buf(st_ivas->hParamMC->proto_matrix_int, st_ivas->hParamMC->proto_matrix_int_fx, &st_ivas->hParamMC->proto_matrix_int_e, nchan_transport * nchan_out_transport); - ivas_param_mc_dec_digest_tc_fx( st_ivas, (uint8_t) n_render_timeslots, p_data_f_fx, in_q ); + ivas_param_mc_dec_digest_tc_fx( st_ivas, (uint8_t) n_render_timeslots, (Word32 **)p_data_f_fx, in_q ); me2f_buf_16(st_ivas->hParamMC->h_output_synthesis_params.interpolator_fx, 0, st_ivas->hParamMC->h_output_synthesis_params.interpolator, n_render_timeslots ); diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index a97e1163b2ff28a9c291540b512b8f5678cee535..08390996311369251b8722183907e381c6da7162 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -3299,7 +3299,7 @@ ivas_error ivas_masa_dec_reconfigure( nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); DECODER_CONFIG_HANDLE hDecoderConfig; hDecoderConfig = st_ivas->hDecoderConfig; - Word16 numch_in, numch_out, num_md_sub_frames, q1 = 30, q2 = 30; + Word16 numch_in = 0, numch_out, num_md_sub_frames, q1 = 30, q2 = 30; ; Word16 numch_out_dirac = hDecoderConfig->nchan_out; IF( hSpar ) @@ -3774,6 +3774,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( IF( LT_16( n_samples_granularity, st_ivas->hTcBuffer->n_samples_granularity ) ) { #ifdef IVAS_FLOAT_FIXED + IF( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, n_samples_granularity, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, MC_MODE_NONE, ISM_MASA_MODE_DISC, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 09d03335f276a856bb9c78b7628ccd53ef4578ef..43326c559d31adee977a8ead10a3f92fc448dabb 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -222,6 +222,9 @@ ivas_error ivas_param_mc_dec_open( } hParamMC->ls_conv_dmx_matrix = NULL; +#ifdef IVAS_FLOAT_FIXED + hParamMC->ls_conv_dmx_matrix_fx = NULL; +#endif // IVAS_FLOAT_FIXED if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) { @@ -489,7 +492,7 @@ ivas_error ivas_param_mc_dec_open( /* output synthesis */ #ifdef IVAS_FLOAT_FIXED - floatToFixed_arrL( proto_matrix, proto_matrix_fx, Q30, MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS ); + floatToFixed_arrL( proto_matrix, proto_matrix_fx, Q30, nchan_out_transport * nchan_transport); if ( ( error = ivas_dirac_dec_output_synthesis_cov_open_fx( &( hParamMC->h_output_synthesis_params ), &( hParamMC->h_output_synthesis_cov_state ), hParamMC->max_band_decorr, PARAM_MC_MAX_NSLOTS, hParamMC->hMetadataPMC->num_parameter_bands, max_param_band_residual, nchan_transport, nchan_out_cov, proto_matrix_fx ) ) != IVAS_ERR_OK ) { return error; @@ -1894,13 +1897,26 @@ void ivas_param_mc_dec_close( free( hParamMC->icc_q ); hParamMC->icc_q = NULL; } +#ifdef IVAS_FLOAT_FIXED + if ( hParamMC->icc_q_fx != NULL ) + { + free( hParamMC->icc_q_fx ); + hParamMC->icc_q_fx = NULL; + } +#endif if ( hParamMC->icld_q != NULL ) { free( hParamMC->icld_q ); hParamMC->icld_q = NULL; } - +#ifdef IVAS_FLOAT_FIXED + if ( hParamMC->icld_q_fx != NULL ) + { + free( hParamMC->icld_q_fx ); + hParamMC->icld_q_fx = NULL; + } +#endif /* diffuse prototype info */ if ( hParamMC->diff_proto_info ) { @@ -1948,12 +1964,26 @@ void ivas_param_mc_dec_close( free( hParamMC->ls_conv_dmx_matrix ); hParamMC->ls_conv_dmx_matrix = NULL; } +#ifdef IVAS_FLOAT_FIXED + if ( hParamMC->ls_conv_dmx_matrix_fx != NULL ) + { + free( hParamMC->ls_conv_dmx_matrix_fx ); + hParamMC->ls_conv_dmx_matrix_fx = NULL; + } +#endif if ( hParamMC->proto_matrix_int != NULL ) { free( hParamMC->proto_matrix_int ); hParamMC->proto_matrix_int = NULL; } +#ifdef IVAS_FLOAT_FIXED + if ( hParamMC->proto_matrix_int_fx != NULL ) + { + free( hParamMC->proto_matrix_int_fx ); + hParamMC->proto_matrix_int_fx = NULL; + } +#endif if ( hParamMC->hoa_encoder != NULL ) { @@ -2705,7 +2735,7 @@ void ivas_param_mc_dec_render( Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 output_f_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; Word32 *p_output_f_fx[MAX_OUTPUT_CHANNELS]; - for (int i = 0; i < MAX_OUTPUT_CHANNELS; i++) { + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++) { p_output_f_fx[i] = output_f_fx[i]; } #endif @@ -2796,7 +2826,7 @@ void ivas_param_mc_dec_render( for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { Word16 len = slot_idx_start_cldfb_synth * hParamMC->num_freq_bands + hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx]; - for (int i = 0; i < nchan_out_cldfb; i++) + for ( i = 0; i < nchan_out_cldfb; i++) { floatToFixed_arrL(output_f[i], output_f_fx[i], Q11, len); } @@ -2873,8 +2903,7 @@ void ivas_param_mc_dec_render( } Word16 Q_hoa_encoder = 31; floatToFixed_arrL(hParamMC->hoa_encoder, hParamMC->hoa_encoder_fx, Q_hoa_encoder, st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS ); - //Word32 Cldfb_RealBuffer_fx[16][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - //Word32 Cldfb_ImagBuffer_fx[16][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word16 Q_Cldfb_ImagBuffer, Q_Cldfb_RealBuffer; Q_Cldfb_ImagBuffer = Q_factor_arrL( &Cldfb_ImagBuffer[0][0][0], 16 * MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX ) - 5;/*max value =MAX_INTERN_CHANNELS(=16)*Cldfb_ImagBuffer_fx*/ Q_Cldfb_RealBuffer = Q_factor_arrL( &Cldfb_RealBuffer[0][0][0], 16 * MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX ) - 5; diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index e72aadc1e32669172c0895086843faac8f356830..12fbda0d4d8fea87f6130a587ba1c18eff5ae110 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -531,9 +531,9 @@ static void ivas_param_upmix_dec_decorr_subframes( int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); { - Word32 i, q_format[MC_PARAMUPMIX_COMBINATIONS]; + Word32 i, q_format[MC_PARAMUPMIX_COMBINATIONS]; - FOR( i = 0; i < nchan_internal; i++ ) + FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) { q_format[i] = Q11; } @@ -542,7 +542,7 @@ static void ivas_param_upmix_dec_decorr_subframes( FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) { - Scale_sig32(pPcm_tmp_fx[i], nSamplesToDecorr, Q11- q_format[i]); + Scale_sig32(pPcm_tmp_fx[i], nSamplesToDecorr, Q11- extract_l(q_format[i])); } } for ( ch = 0; ch < nchan_internal; ch++ ) @@ -782,7 +782,7 @@ static void ivas_mc_paramupmix_dec_sf( //to be deleted if (st_ivas->hCombinedOrientationData) { - for (int i = 0; i < 3; i++) + for ( i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { @@ -794,7 +794,7 @@ static void ivas_mc_paramupmix_dec_sf( /* Implement binaural rendering */ - Word32 input_q = 6; + Word16 input_q = 6; /* Implement binaural rendering */ ivas_binRenderer_fx(st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, diff --git a/lib_dec/ivas_mct_core_dec.c b/lib_dec/ivas_mct_core_dec.c index d6af26d16d63f403090edb24798dcb3a99265a48..cc2281d50972c4038149ac7f608d87ebd72dc3cf 100644 --- a/lib_dec/ivas_mct_core_dec.c +++ b/lib_dec/ivas_mct_core_dec.c @@ -354,7 +354,7 @@ void ivas_mct_core_dec( x_e = 31 - q_x[ch]; decoder_tcx_IGF_mono_fx( st, x_fx[ch][k], &x_e, &x_len, L_frame, left_rect, bfi, k ); q_x[ch] = 31 - x_e; - for ( int i = 0; i < x_len; i++ ) + for ( i = 0; i < x_len; i++ ) { x_fx[ch][k][i] = L_shr( x_fx[ch][k][i], q_x[ch] - Q12 ); } @@ -377,7 +377,7 @@ void ivas_mct_core_dec( apply_MCT_dec_fx( hMCT, sts, x_fx, q_x ); FOR( ch = 0; ch < nChannels; ch++ ) { - for ( int i = 0; i < L_FRAME48k / 2; i++ ) + for ( i = 0; i < L_FRAME48k / 2; i++ ) { x_fx[ch][0][i] = L_shr( x_fx[ch][0][i], q_x[ch] - Q12 ); x_fx[ch][1][i] = L_shr( x_fx[ch][1][i], q_x[ch] - Q12 ); diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 29294304c1aa40864c91436bcfe79e170099c7d7..31047a2c0aa931b1a43dc44f3bd74262d8964f32 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -307,7 +307,7 @@ ivas_error ivas_mct_dec_fx( Word16 Aq_fx[MCT_MAX_BLOCKS][CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )]; Word32 output_lfe_ch_fx[L_FRAME48k]; Word16 q_output = 11; - Word16 n, k, l, i, j; + Word16 n, k, i; Word32 *x_fx[CPE_CHANNELS][NB_DIV]; Word16 x_e[MAX_CICP_CHANNELS][NB_DIV]; @@ -1499,7 +1499,7 @@ static ivas_error ivas_mc_dec_reconfig( nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); DECODER_CONFIG_HANDLE hDecoderConfig; hDecoderConfig = st_ivas->hDecoderConfig; - Word16 numch_in, numch_out, num_md_sub_frames, q1 = 30, q2 = 30; + Word16 numch_in = 0, numch_out, num_md_sub_frames, q1 = 30, q2 = 30; ; Word16 numch_out_dirac = hDecoderConfig->nchan_out; IF( hSpar ) diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index b85d47ec8a143b8488d263867158388512b27b8d..fa0aa44a1f869746ac9fe645716e8c5efbdb0ca1 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -923,7 +923,7 @@ void ivas_mdct_core_invQ_fx( Word16 tmp_ms_sig[CPE_CHANNELS][N_MAX]; Word16 tmp_ms_sig_e[CPE_CHANNELS]; Word32 concealment_noise_fx[CPE_CHANNELS][L_FRAME48k]; - Word16 concealment_noise_e[CPE_CHANNELS] = { 0 }, concealment_noise_len[CPE_CHANNELS]; + Word16 concealment_noise_e[CPE_CHANNELS] = { 0 }; TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode_bfi; Word16 q_l = 0, q_r = 0; diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index d5d213297219946b32170dec0fae8b215fc3818a..e2f467250b3a3b461112d9ddc6ecbd2068f3593c 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -1389,7 +1389,7 @@ void ivas_omasa_dirac_rend_jbm( #endif #ifdef IVAS_FLOAT_FIXED - Word16 q_output = 31, q_inverse_matrix = 31; + Word16 q_output = 31; Word32 **output_fx, data_separated_objects_fx[4][960]; q_output = Q11; FOR(Word16 ind = 0; ind < MAX_NUM_OBJECTS; ind++) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 5b8eb9c6bb96f1d6fffb5e78964dc0a25ea15ecd..dbf60af77a406a193a5e989e94f4e084f8df7dc2 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -272,9 +272,8 @@ ivas_error ivas_sba_dec_reconfigure( hSpar = st_ivas->hSpar; uint16_t nchan_internal; nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); - DECODER_CONFIG_HANDLE hDecoderConfig; hDecoderConfig = st_ivas->hDecoderConfig; - Word16 numch_in, numch_out, num_md_sub_frames, q1 = 30, q2 = 30; + Word16 numch_in = 0, numch_out, q1 = 30, q2 = 30; ; Word16 numch_out_dirac = hDecoderConfig->nchan_out; IF( hSpar ) diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index c84872f48b6ac5c295e629f0b60a7a4b5c052ed6..aea3b567c65c7768a328aa02f265c8b7bcfbb4d6 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -548,7 +548,7 @@ void destroy_sce_dec( free( hSCE->save_hb_synth ); hSCE->save_hb_synth = NULL; } -#else +#endif // IVAS_FLOAT_FIXED_TO_BE_REMOVED IF( hSCE->save_synth_fx != NULL ) { free( hSCE->save_synth_fx ); @@ -559,7 +559,6 @@ void destroy_sce_dec( free( hSCE->save_hb_synth_fx ); hSCE->save_hb_synth_fx = NULL; } -#endif // IVAS_FLOAT_FIXED_TO_BE_REMOVED free( hSCE ); diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index c4e649072ecd66a389d25014a2199329f377e395..2fc6f2facc3fde39619ab6eea8df7c719c6802f4 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1022,7 +1022,7 @@ void ivas_spar_get_cldfb_gains_fx( /* compute time-domain cross-fade for considered time slots*/ tmp_idx = sub( cf_start, imult1616( cf_cldfb_start, stride ) ); Word32 pFilterbank_cross_fade_fx[192];// Temporarily added to stored fixed value of hSpar->hFbMixer->pFilterbank_cross_fade_fx - floatToFixed_arrL( hSpar->hFbMixer->pFilterbank_cross_fade, pFilterbank_cross_fade_fx, 31, cf_len ); + floatToFixed_arrL( (float *)hSpar->hFbMixer->pFilterbank_cross_fade, pFilterbank_cross_fade_fx, Q31, cf_len ); FOR( sample = 0; sample < cf_len; sample++ ) { tgt_fx[tmp_idx++] = pFilterbank_cross_fade_fx[sample]; @@ -1108,7 +1108,7 @@ void ivas_spar_get_cldfb_gains_fx( { tmp = L_add(tmp,Mult_32_32(Tt_T_inv_fx[slot_row][slot_col] , Tt_tgt_fx[slot_col])); } - weights_fx[add(cf_cldfb_start , slot_row)] = L_shr(L_max( L_min( tmp, L_shl(1, (output_q-10)) ), 0 ), output_q - 10- Q_weights);/*Q_weights*/ + weights_fx[add(cf_cldfb_start , slot_row)] = extract_l(L_shr(L_max( L_min( tmp, L_shl(1, (output_q-10)) ), 0 ), output_q - 10- Q_weights));/*Q_weights*/ } hSpar->hFbMixer->cldfb_cross_fade_q = Q_weights; @@ -2691,7 +2691,6 @@ void ivas_spar_dec_digest_tc_fx( Word32 *pPcm_tmp[MAX_SPAR_INTERNAL_CHANNELS]; Word32 *p_tc[MAX_SPAR_INTERNAL_CHANNELS]; Word32 Pcm_tmp[MAX_SPAR_INTERNAL_CHANNELS][L_FRAME48k]; - Word32 i, j; Word16 q_format = Q14; ch_sba_idx = 0; move16(); @@ -3177,7 +3176,7 @@ void ivas_spar_dec_upmixer_sf_fx( #ifdef IVAS_FLOAT_FIXED /*Float to fixed*/ FOR ( in_ch = 0; in_ch < numch_in; in_ch++ ) { - FOR ( Word16 i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ ) + FOR ( i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ ) { st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] = (Word32) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] * ( 1LL << ( Q11 ) ) ); } @@ -3214,9 +3213,9 @@ void ivas_spar_dec_upmixer_sf_fx( { md_idx = hSpar->render_to_md_map[ts + slot_idx_start]; #if 1 /*TODO: To be removed later when ivas_spar_get_parameters is integerated*/ - FOR( Word16 in_ch = 0; in_ch < numch_in; in_ch++ ) + FOR( in_ch = 0; in_ch < numch_in; in_ch++ ) { - FOR( Word16 i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ ) + FOR( i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ ) { st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] ) / ( 1LL << ( Q11 ) ) ); /*Rounding off*/ } @@ -3234,11 +3233,11 @@ void ivas_spar_dec_upmixer_sf_fx( } } } - FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) + FOR( out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) { IF( st_ivas->cldfbSynDec[out_ch] ) { - FOR( Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++ ) + FOR( i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++ ) { st_ivas->cldfbSynDec[out_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx[i] ) / (float) ( 1LL << ( Q11 ) ) ); } @@ -3246,7 +3245,7 @@ void ivas_spar_dec_upmixer_sf_fx( } #endif ivas_spar_get_parameters( hSpar, hDecoderConfig, md_idx, numch_out, numch_in, num_spar_bands, mixer_mat ); - FOR ( int i = 0; i < numch_out; i++ ) + FOR ( i = 0; i < numch_out; i++ ) { FOR ( int j = 0; j < numch_in; j++ ) { @@ -3343,7 +3342,7 @@ void ivas_spar_dec_upmixer_sf_fx( } } #if 1 /*TODO: To be removed when ivas_spar_get_parameters is integerated*/ - FOR( int i = 0; i < numch_out; i++ ) + FOR( i = 0; i < numch_out; i++ ) { FOR( int j = 0; j < numch_in; j++ ) { @@ -3362,7 +3361,7 @@ void ivas_spar_dec_upmixer_sf_fx( { FOR ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { - FOR ( Word16 i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + FOR ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) { cldfb_in_ts_re[in_ch][ts][i] = (float) ( cldfb_in_ts_re_fx[in_ch][ts][i] ) / (float) ( 1LL << 6 ); /*Resultant q is 6*/ cldfb_in_ts_im[in_ch][ts][i] = (float) ( cldfb_in_ts_im_fx[in_ch][ts][i] ) / (float) ( 1LL << 6 ); /*Resultant q is 6*/ @@ -3387,7 +3386,7 @@ void ivas_spar_dec_upmixer_sf_fx( { IF( st_ivas->cldfbSynDec[out_ch] ) { - FOR( Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++ ) + FOR( i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++ ) { st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx[i] = float_to_fix( st_ivas->cldfbSynDec[out_ch]->cldfb_state[i] ,Q11); } @@ -3509,7 +3508,7 @@ void ivas_spar_dec_upmixer_sf( slot_idx_start = hSpar->slots_rendered; #ifdef IVAS_FLOAT_FIXED - for ( int i = 0; i < s_max(st_ivas->nchan_ism,0)+ nchan_internal; i++ ) + for ( i = 0; i < s_max(st_ivas->nchan_ism,0)+ nchan_internal; i++ ) { floatToFixed_arr32( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], Q11, st_ivas->hTcBuffer->n_samples_available ); } @@ -3667,7 +3666,7 @@ void ivas_spar_dec_upmixer_sf( #ifdef IVAS_FLOAT_FIXED/*Float to fixed*/ for (in_ch = 0; in_ch < numch_in; in_ch++) { - for (Word16 i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++) + for ( i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++) { st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] = (Word32)(st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] * (1LL << (Q11))); } @@ -3707,13 +3706,13 @@ void ivas_spar_dec_upmixer_sf( { for ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { - for ( Word16 i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) { cldfb_in_ts_re[in_ch][ts][i] = (float) ( cldfb_in_ts_re_fx[in_ch][ts][i] ) / (float) ( 1LL << 6 ); /*q_cldfb-5*/ cldfb_in_ts_im[in_ch][ts][i] = (float) ( cldfb_in_ts_im_fx[in_ch][ts][i] ) / (float) ( 1LL << 6 ); /*q_cldfb-5*/ } } - for ( Word16 i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ ) + for ( i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ ) { st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = (float) ( ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] + ( 1 << 10 ) ) / ( 1LL << ( Q11 ) ) ); /*Rounding off*/ } diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 695c72ec4637ac4116343963fd90f6d72151cc00..4b92c24689f01f7d6824354fb72c7dae7e45257e 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -3766,13 +3766,12 @@ void ivas_spar_to_dirac( int16_t azi[IVAS_MAX_NUM_BANDS]; int16_t ele[IVAS_MAX_NUM_BANDS]; float dvx[IVAS_MAX_NUM_BANDS], dvy[IVAS_MAX_NUM_BANDS], dvz[IVAS_MAX_NUM_BANDS]; - Word32 dvx_q, dvy_q, dvz_q; Word32 dvx_fx[IVAS_MAX_NUM_BANDS], dvy_fx[IVAS_MAX_NUM_BANDS], dvz_fx[IVAS_MAX_NUM_BANDS]; float radius; - Word32 radius_fx,radius_q; + Word32 radius_fx; float en_ratio, res_pow; Word32 en_ratio_fx, res_pow_fx; - Word32 en_ratio_q, res_pow_q; + Word32 res_pow_q; int16_t num_slots_in_subfr; int16_t tmp_write_idx_param_band; int16_t tmp_write_idx_band; @@ -3859,7 +3858,6 @@ void ivas_spar_to_dirac( radius = sqrtf(dvx[band] * dvx[band] + dvy[band] * dvy[band]); - float check_qzi = atan2f(dvy[band], dvx[band]); Word16 check_azi_fx = BASOP_util_atan2(dvy_fx[band], dvx_fx[band],0); Word32 check_azi_fx_32 = L_shl(check_azi_fx,16); Word16 check_azi_fx_res; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 154a589fa654a819c4bd6f247a60c0fdc1a5598a..7685ba8a259bf4bba783de3963111a2478adbe99 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -245,12 +245,12 @@ typedef struct stereo_dft_dec_data_struct Word16 q_DFT_past_DMX_fx[STEREO_DFT_PAST_MAX]; Word32 res_global_gain_fx; /* Q15 */ #endif // IVAS_FLOAT_FIXED - float res_cod_mem[STEREO_DFT_OVL_8k]; #ifndef IVAS_FLOAT_FIXED + float res_cod_mem[STEREO_DFT_OVL_8k]; float buff_LBTCX_mem[NS2SA( 16000, STEREO_DFT32MS_OVL_NS )]; #endif // IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED - Word32 res_cod_mem_fx[STEREO_DFT_OVL_8k]; + Word32 res_cod_mem_fx[STEREO_DFT_OVL_8k]; /* Q(q_res_cod_mem_fx) */ Word32 buff_LBTCX_mem_fx[NS2SA( 16000, STEREO_DFT32MS_OVL_NS )]; /* Q11 */ Word16 q_res_cod_mem_fx; #endif @@ -265,29 +265,29 @@ typedef struct stereo_dft_dec_data_struct int16_t attackPresent; int16_t wasTransient; +#ifndef IVAS_FLOAT_FIXED float lt_pred_gain; float lt_pred_gain_variation; float lt_var_mean_ratio; -#ifndef IVAS_FLOAT_FIXED float stefi_short_gain; float stefi_long_gain; #endif basic_allpass_t ap1, ap2, ap3; - float ap_delay_mem[NS2SA( 16000, DELAY_BWE_TOTAL_NS )]; #ifndef IVAS_FLOAT_FIXED + float ap_delay_mem[NS2SA( 16000, DELAY_BWE_TOTAL_NS )]; float ap_fade_mem[STEREO_DFT_ALLPASS_FADELEN_16k]; #endif #ifdef IVAS_FLOAT_FIXED Word16 stab_fac_smooth_res_fx; /* low-pass filtered stability factor */ /* Q15 */ - Word32 lt_pred_gain_fx; - Word32 lt_pred_gain_variation_fx; - Word32 lt_var_mean_ratio_fx; - Word16 stefi_short_gain_fx; /* Q15 */ - Word16 stefi_long_gain_fx; /* Q15 */ + Word32 lt_pred_gain_fx; /* Q(q_lt_pred_gain) */ + Word32 lt_pred_gain_variation_fx; /* Q(q_lt_pred_gain) */ + Word32 lt_var_mean_ratio_fx; /* Q31 */ + Word16 stefi_short_gain_fx; /* Q15 */ + Word16 stefi_long_gain_fx; /* Q15 */ Word16 q_lt_pred_gain; - Word32 ap_delay_mem_fx[NS2SA( 16000, DELAY_BWE_TOTAL_NS )]; - Word32 ap_fade_mem_fx[STEREO_DFT_ALLPASS_FADELEN_16k]; /* Q(q_ap_fade_mem_fx) */ + Word32 ap_delay_mem_fx[NS2SA( 16000, DELAY_BWE_TOTAL_NS )]; /* Q(q_ap_fade_mem_fx) */ + Word32 ap_fade_mem_fx[STEREO_DFT_ALLPASS_FADELEN_16k]; /* Q(q_ap_fade_mem_fx) */ Word16 q_ap_fade_mem_fx; #endif @@ -336,7 +336,9 @@ typedef struct stereo_dft_dec_data_struct #endif /* PLC on residual signal */ +#ifndef IVAS_FLOAT_FIXED float res_mem[STEREO_DFT_RES_BW_MAX]; +#endif int16_t time_offs; #ifndef IVAS_FLOAT_FIXED float past_dmx_nrg; @@ -345,17 +347,17 @@ typedef struct stereo_dft_dec_data_struct int16_t sg_mem_corrupt; int16_t recovery_flg; - float smooth_buf[SBA_DIRAC_STEREO_NUM_BANDS][SBA_DIRAC_NRG_SMOOTH_LONG + 1]; #ifndef IVAS_FLOAT_FIXED + float smooth_buf[SBA_DIRAC_STEREO_NUM_BANDS][SBA_DIRAC_NRG_SMOOTH_LONG + 1]; float smooth_fac[NB_DIV][SBA_DIRAC_STEREO_NUM_BANDS]; #endif #ifdef IVAS_FLOAT_FIXED /* PLC on residual signal */ - Word32 sg_mean_fx; /* Q31 */ - Word32 res_mem_fx[STEREO_DFT_RES_BW_MAX]; - Word32 past_dmx_nrg_fx; /* Q(2 * q_dft) */ - Word32 smooth_buf_fx[SBA_DIRAC_STEREO_NUM_BANDS][SBA_DIRAC_NRG_SMOOTH_LONG + 1]; - Word16 smooth_fac_fx[NB_DIV][SBA_DIRAC_STEREO_NUM_BANDS]; /* Q15 */ + Word32 sg_mean_fx; /* Q31 */ + Word32 res_mem_fx[STEREO_DFT_RES_BW_MAX]; /* Q(q_res_mem) */ + Word32 past_dmx_nrg_fx; /* Q(2 * q_dft) */ + Word32 smooth_buf_fx[SBA_DIRAC_STEREO_NUM_BANDS][SBA_DIRAC_NRG_SMOOTH_LONG + 1]; /* Q(q_smooth_buf_fx) */ + Word16 smooth_fac_fx[NB_DIV][SBA_DIRAC_STEREO_NUM_BANDS]; /* Q15 */ Word16 q_smooth_buf_fx; Word16 q_hb_nrg; Word16 q_hb_nrg_subr; diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index d178c08fc0eb0919bb59ae55fa012116c2570821..7ac9987ad00a184576135cc0f4027f194eb28aa4 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -606,9 +606,11 @@ void stereo_dft_dec_reset( /*residual coding*/ set_s( hStereoDft->res_cod_mode, hStereoDft->hConfig->res_cod_mode, STEREO_DFT_DEC_DFT_NB ); hStereoDft->res_cod_band_max = dft_band_res_cod[hStereoDft->hConfig->band_res][hStereoDft->hConfig->res_cod_mode]; +#ifndef IVAS_FLOAT_FIXED set_zero( hStereoDft->res_cod_mem, STEREO_DFT_OVL_8k ); -#ifdef IVAS_FLOAT_FIXED +#else set_l( hStereoDft->res_cod_mem_fx, 0, STEREO_DFT_OVL_8k ); + hStereoDft->q_res_cod_mem_fx = Q16; #endif hStereoDft->res_pred_band_min = max( STEREO_DFT_RES_PRED_BAND_MIN, hStereoDft->res_cod_band_max ); @@ -659,10 +661,10 @@ void stereo_dft_dec_reset( hStereoDft->wasTransient = 0; hStereoDft->attackPresent = 0; +#ifndef IVAS_FLOAT_FIXED hStereoDft->lt_pred_gain = 0.0f; hStereoDft->lt_pred_gain_variation = 0.0f; hStereoDft->lt_var_mean_ratio = STEREO_DFT_RES_RATIO_LIMIT; -#ifndef IVAS_FLOAT_FIXED hStereoDft->stefi_short_gain = 1.0f; hStereoDft->stefi_long_gain = 0.0f; #else @@ -686,10 +688,12 @@ void stereo_dft_dec_reset( init_basic_allpass( &hStereoDft->ap3, dft_ap_gains[2], dft_ap_delays[2] ); #endif - set_zero( hStereoDft->ap_delay_mem, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); #ifdef IVAS_FLOAT_FIXED + set32_fx( hStereoDft->ap_delay_mem_fx, 0, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); set32_fx( hStereoDft->ap_fade_mem_fx, 0, STEREO_DFT_ALLPASS_FADELEN_16k ); + hStereoDft->q_ap_delay_mem_fx = Q11; #else + set_zero( hStereoDft->ap_delay_mem, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); set_zero( hStereoDft->ap_fade_mem, STEREO_DFT_ALLPASS_FADELEN_16k ); #endif hStereoDft->ap_wasTransient = 0; @@ -713,7 +717,11 @@ void stereo_dft_dec_reset( #endif /* PLC parameters */ +#ifdef IVAS_FLOAT_FIXED + set32_fx( hStereoDft->res_mem_fx, 0, STEREO_DFT_RES_BW_MAX ); +#else set_zero( hStereoDft->res_mem, STEREO_DFT_RES_BW_MAX ); +#endif hStereoDft->time_offs = 0; #ifdef IVAS_FLOAT_FIXED hStereoDft->past_dmx_nrg_fx = 0; @@ -725,14 +733,19 @@ void stereo_dft_dec_reset( hStereoDft->sg_mem_corrupt = 0; hStereoDft->recovery_flg = 0; +#ifndef IVAS_FLOAT_FIXED for ( i = 0; i < SBA_DIRAC_STEREO_NUM_BANDS; i++ ) { set_zero( hStereoDft->smooth_buf[i], SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); } -#ifndef IVAS_FLOAT_FIXED set_zero( hStereoDft->smooth_fac[0], SBA_DIRAC_STEREO_NUM_BANDS ); set_zero( hStereoDft->smooth_fac[1], SBA_DIRAC_STEREO_NUM_BANDS ); #else + FOR( i = 0; i < SBA_DIRAC_STEREO_NUM_BANDS; i++ ) + { + set32_fx( hStereoDft->smooth_buf_fx[i], 0, SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); + } + hStereoDft->q_smooth_buf_fx = Q7; set16_fx( hStereoDft->smooth_fac_fx[0], 0, SBA_DIRAC_STEREO_NUM_BANDS ); set16_fx( hStereoDft->smooth_fac_fx[1], 0, SBA_DIRAC_STEREO_NUM_BANDS ); #endif @@ -821,6 +834,7 @@ void stereo_dft_dec_reset( { set_val_Word32( hStereoDft->smooth_buf_fx[i], 0, SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); } + hStereoDft->q_smooth_buf_fx = Q7; set_val_Word16( hStereoDft->smooth_fac_fx[0], 0, SBA_DIRAC_STEREO_NUM_BANDS ); set_val_Word16( hStereoDft->smooth_fac_fx[1], 0, SBA_DIRAC_STEREO_NUM_BANDS ); @@ -1060,6 +1074,7 @@ void stereo_dft_dec_update( mvr2r( hStereoDft->hb_nrg, hStereoDft->hb_nrg + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); mvr2r( hStereoDft->td_gain, hStereoDft->td_gain + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); +#ifndef IVAS_FLOAT_FIXED if ( sba_dirac_stereo_flag ) { /* buffer update, push back by 2 because of 2 subframes */ @@ -1071,6 +1086,19 @@ void stereo_dft_dec_update( } } } +#else + IF( sba_dirac_stereo_flag ) + { + /* buffer update, push back by 2 because of 2 subframes */ + FOR( b = 0; b < hStereoDft->nbands; b++ ) + { + FOR( i = SBA_DIRAC_NRG_SMOOTH_LONG; i > 1; i-- ) + { + hStereoDft->smooth_buf_fx[b][i] = hStereoDft->smooth_buf_fx[b][i - 2]; + } + } + } +#endif return; } diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index a259839b3ec38606bcaea868085a6ed8cef5edc1..002582f2247fa1fae16c8b5d247b9ed8dd324f9a 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -131,6 +131,7 @@ void stereo_dft_dec_reset_fx( set_s( hStereoDft->res_cod_mode, hStereoDft->hConfig->res_cod_mode, STEREO_DFT_DEC_DFT_NB ); hStereoDft->res_cod_band_max = dft_band_res_cod[hStereoDft->hConfig->band_res][hStereoDft->hConfig->res_cod_mode]; set_val_Word32( hStereoDft->res_cod_mem_fx, 0, STEREO_DFT_OVL_8k ); + hStereoDft->q_res_cod_mem_fx = Q16; hStereoDft->res_pred_band_min = s_max( STEREO_DFT_RES_PRED_BAND_MIN, hStereoDft->res_cod_band_max ); move32(); @@ -178,6 +179,8 @@ void stereo_dft_dec_reset_fx( set_val_Word32( hStereoDft->ap_delay_mem_fx, 0, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); set_val_Word32( hStereoDft->ap_fade_mem_fx, 0, STEREO_DFT_ALLPASS_FADELEN_16k ); + hStereoDft->q_ap_delay_mem_fx = Q11; + move16(); hStereoDft->ap_wasTransient = 0; move16(); set_val_Word32( hStereoDft->smooth_dmx_nrg_fx, 0, STEREO_DFT_BAND_MAX ); @@ -207,6 +210,7 @@ void stereo_dft_dec_reset_fx( { set_val_Word32( hStereoDft->smooth_buf_fx[i], 0, SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); } + hStereoDft->q_smooth_buf_fx = Q7; set_val_Word16( hStereoDft->smooth_fac_fx[0], 0, SBA_DIRAC_STEREO_NUM_BANDS ); set_val_Word16( hStereoDft->smooth_fac_fx[1], 0, SBA_DIRAC_STEREO_NUM_BANDS ); @@ -1202,6 +1206,7 @@ void stereo_dft_dec_res_fx( IF ( EQ_16(hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET - 1], STEREO_DFT_RES_COD_OFF) ) { set_val_Word32( hCPE->hStereoDft->res_cod_mem_fx, 0, STEREO_DFT_OVL_8k ); + hCPE->hStereoDft->q_res_cod_mem_fx = Q16; set_val_Word32( hCPE->input_mem_fx[1], 0, NS2SA( 8000, STEREO_DFT32MS_OVL_NS ) ); set_val_Word16( hCPE->hStereoDft->hBpf->pst_old_syn_fx, 0, STEREO_DFT_NBPSF_PIT_MAX_8k ); hCPE->hStereoDft->hBpf->pst_mem_deemp_err_fx = 0; @@ -1215,20 +1220,20 @@ void stereo_dft_dec_res_fx( { /*OLA*/ /*overlapping parts*/ - Word16 q_shift = hCPE->hStereoDft->q_res_cod_mem_fx; + Word16 q_shift = sub( hCPE->hStereoDft->q_res_cod_mem_fx, Q16 ); move16(); - FOR ( i = 0; i < STEREO_DFT_OVL_8k; i++ ) + FOR( i = 0; i < STEREO_DFT_OVL_8k; i++ ) { - win[i] = extract_h(L_add(hCPE->hStereoDft->res_cod_mem_fx[i], L_shl(L_mult(win[i], hCPE->hStereoDft->win_8k_fx[i]), q_shift))); + win[i] = extract_h( L_add( hCPE->hStereoDft->res_cod_mem_fx[i], L_shl( L_mult( win[i], hCPE->hStereoDft->win_8k_fx[i] ), q_shift ) ) ); move16(); - hCPE->hStereoDft->res_cod_mem_fx[i] = L_mult(win[L_FRAME8k + i], hCPE->hStereoDft->win_8k_fx[STEREO_DFT_OVL_8k - 1 - i]); + hCPE->hStereoDft->res_cod_mem_fx[i] = L_mult( win[L_FRAME8k + i], hCPE->hStereoDft->win_8k_fx[STEREO_DFT_OVL_8k - 1 - i] ); move32(); } - IF (NE_16(q_shift, 0)) + IF( NE_16( q_shift, 0 ) ) { - v_shr_16(&win[STEREO_DFT_OVL_8k], negate(q_shift), &win[STEREO_DFT_OVL_8k], L_FRAME8k); + v_shr_16( &win[STEREO_DFT_OVL_8k], negate( q_shift ), &win[STEREO_DFT_OVL_8k], L_FRAME8k ); } - hCPE->hStereoDft->q_res_cod_mem_fx = 0; + hCPE->hStereoDft->q_res_cod_mem_fx = Q16; move16(); } ELSE diff --git a/lib_dec/ivas_stereo_dft_plc_fx.c b/lib_dec/ivas_stereo_dft_plc_fx.c index fd39b1cec1cf8a893cf76fadb5bfe2487811ba33..37d3841e0d62bd49bd3507de962403e3b1f11323 100644 --- a/lib_dec/ivas_stereo_dft_plc_fx.c +++ b/lib_dec/ivas_stereo_dft_plc_fx.c @@ -129,6 +129,7 @@ void stereo_dft_res_ecu_fx( v_multc_fixed_16( res_buf, fac, res_buf, L_FRAME8k ); Copy32( res_buf + ( OFFSET8k - ZP8k ), &hStereoDft->res_cod_mem_fx[0], STEREO_DFT_OVL_8k ); + hStereoDft->q_res_cod_mem_fx = hStereoDft->q_dft; Copy32( res_buf + ZP8k, input_mem, NS2SA( 8000, STEREO_DFT32MS_OVL_NS ) ); /* Store memory for cross-fade to next frame, in case of good frame */ hStereoDft->q_ip_mem = hStereoDft->q_dft; diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 5d1c93a94f7d34f7e0653c101e4c05c8f23e01a6..b112333378f190f53e07e0119cd9793dd0ff8d51 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -3035,10 +3035,8 @@ void stereo_switching_dec( } /* reset residual coding / ESF (secondary channel) */ -#ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED - set_zero( hCPE->hStereoDft->res_cod_mem, STEREO_DFT_OVL_8k ); -#endif set32_fx( hCPE->hStereoDft->res_cod_mem_fx, 0, STEREO_DFT_OVL_8k ); + hCPE->hStereoDft->q_res_cod_mem_fx = Q16; set32_fx( hCPE->input_mem_fx[1], 0, NS2SA( sts[0]->output_Fs, STEREO_DFT32MS_OVL_NS ) ); } diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 1684c486ba4d32865d4ebdfe8cf404307fe130ea..9c42a0bf6b801348e51c1cf34f525fa1a6eaaa9e 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2244,8 +2244,9 @@ ivas_error IVAS_DEC_VoIP_GetSamples( { return IVAS_ERR_UNKNOWN; } + #ifdef IVAS_FLOAT_FIXED - if ( GT_16( maxScaling, 20 ) ) + IF ( GT_32( maxScaling, 20 ) ) { maxScaling = 20; move16(); diff --git a/lib_dec/lsf_dec.c b/lib_dec/lsf_dec.c index 5ae2b382e53385b2af64e06a0d052b2c35162320..01ab068f90fb01df72678f16857c9bbef27e114b 100644 --- a/lib_dec/lsf_dec.c +++ b/lib_dec/lsf_dec.c @@ -518,7 +518,7 @@ void lsf_end_dec( #ifdef IVAS_FLOAT_FIXED Word16 tdm_lsfQ_PCh_fx[M]; Word16 pred3_fx[M]; - for (int i = 0; i < M; i++) + for ( i = 0; i < M; i++) { tdm_lsfQ_PCh_fx[i] = (Word16)((tdm_lsfQ_PCh[i]) * 2.56f); pred3_fx[i] = (Word16)((pred3[i]) * 2.56f); @@ -526,7 +526,7 @@ void lsf_end_dec( tdm_SCh_LSF_intra_pred_fx(st->element_brate, tdm_lsfQ_PCh_fx, pred3_fx); - for (int i = 0; i < M; i++) + for (i = 0; i < M; i++) { pred3[i] = (pred3_fx[i]) / 2.56f; } diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c index c427203d2082b54029a7707c2a0b65ac08ca919b..cbdffc62beb7365d87a3f5a88461ac122b3b0a01 100644 --- a/lib_dec/swb_tbe_dec.c +++ b/lib_dec/swb_tbe_dec.c @@ -560,7 +560,7 @@ void calc_tilt_bwe_fx_loc( Word16 headroom_left_r0 = W_norm(r0_fx); Word16 headroom_left_r1 = W_norm(r1_fx); Word16 r0_q = 0, r1_q = 0; - Word16 r0_bits_occ = 0, r1_bits_occ = 0; + //Word16 r0_bits_occ = 0, r1_bits_occ = 0; IF(headroom_left_r0 < 32) { r0_fx = W_shr(r0_fx, (32 - headroom_left_r0)); diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index eb81feee492637087cc90c7748ce53aadfbe2f19..2f9f66ac574e2c9d7da72128bf672a1ec6f4acc1 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -4561,7 +4561,6 @@ void fb_tbe_dec_ivas_fx( Word16 i; Word16 ratio = 0; Word32 fb_exc_energy = 0; - Word32 L_tmp; Word16 fb_synth[L_FRAME48k]; TD_BWE_DEC_HANDLE hBWE_TD; hBWE_TD = st->hBWE_TD; @@ -5016,7 +5015,7 @@ void td_bwe_dec_init_ivas_fx( } set16_fx(hBWE_TD->mem_resamp_HB_fx, 0, INTERP_3_1_MEM_LEN); - set32_fx(hBWE_TD->mem_resamp_HB_32k_fx, 0, 2 * ALLPASSSECTIONS_STEEP + 1); + set16_fx(hBWE_TD->mem_resamp_HB_32k_fx, 0, 2 * ALLPASSSECTIONS_STEEP + 1); set16_fx(hBWE_TD->mem_resamp_HB_32k_fx, 0, 2 * ALLPASSSECTIONS_STEEP + 1); set32_fx(hBWE_TD->mem_resamp_HB_32k_fx_32, 0, 2 * ALLPASSSECTIONS_STEEP + 1); @@ -5084,6 +5083,7 @@ void td_bwe_dec_init_fx( } set16_fx(hBWE_TD->mem_resamp_HB_fx, 0, INTERP_3_1_MEM_LEN); + set16_fx(hBWE_TD->mem_resamp_HB_32k_fx, 0, 2 * ALLPASSSECTIONS_STEEP + 1); set32_fx(hBWE_TD->mem_resamp_HB_32k_fx_32, 0, 2 * ALLPASSSECTIONS_STEEP + 1); diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index 1de27b44cfe15aca3226139d2845f2835212b3d7..e79dcd83cd7bc46dcdb8011a9081a8c19c03c342 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -783,10 +783,10 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( // hTonalMDCTConc->nSamplesCore, // floorPowerSpectrum); - ivas_DetectTonalComponents_fx(hTonalMDCTConc->pTCI->indexOfTonalPeak, - hTonalMDCTConc->pTCI->lowerIndex, - hTonalMDCTConc->pTCI->upperIndex, - &hTonalMDCTConc->pTCI->numIndexes, + ivas_DetectTonalComponents_fx((Word16 *)hTonalMDCTConc->pTCI->indexOfTonalPeak, + (Word16 *)hTonalMDCTConc->pTCI->lowerIndex, + (Word16 *)hTonalMDCTConc->pTCI->upperIndex, + (Word16 *)&hTonalMDCTConc->pTCI->numIndexes, hTonalMDCTConc->lastPitchLag, pitchLag, hTonalMDCTConc->lastBlockData.spectralData, @@ -836,7 +836,7 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( } ELSE { - FOR( Word16 i = 0; i < FDNS_NPTS; i++ ) + FOR( i = 0; i < FDNS_NPTS; i++ ) { invScaleFactors_fx[i] = L_shl(invScaleFactors[i], 1 + invScaleFactors_exp[i]); // Q16 } @@ -930,10 +930,10 @@ static void CalcPowerSpecAndDetectTonalComponents( set32_fx(powerSpectrum+hTonalMDCTConc->nSamples, 0, sub(hTonalMDCTConc->nSamplesCore, hTonalMDCTConc->nSamples)); } - DetectTonalComponents(hTonalMDCTConc->pTCI->indexOfTonalPeak, - hTonalMDCTConc->pTCI->lowerIndex, - hTonalMDCTConc->pTCI->upperIndex, - &hTonalMDCTConc->pTCI->numIndexes, + DetectTonalComponents((Word16 *)hTonalMDCTConc->pTCI->indexOfTonalPeak, + (Word16 *)hTonalMDCTConc->pTCI->lowerIndex, + (Word16 *)hTonalMDCTConc->pTCI->upperIndex, + (Word16 *)&hTonalMDCTConc->pTCI->numIndexes, hTonalMDCTConc->lastPitchLag, pitchLag, hTonalMDCTConc->lastBlockData.spectralData, @@ -1152,12 +1152,12 @@ void TonalMDCTConceal_Detect( move32(); } - RefineTonalComponents(hTonalMDCTConc->pTCI->indexOfTonalPeak, - hTonalMDCTConc->pTCI->lowerIndex, - hTonalMDCTConc->pTCI->upperIndex, + RefineTonalComponents((Word16 *)hTonalMDCTConc->pTCI->indexOfTonalPeak, + (Word16 *)hTonalMDCTConc->pTCI->lowerIndex, + (Word16 *)hTonalMDCTConc->pTCI->upperIndex, hTonalMDCTConc->pTCI->phaseDiff, hTonalMDCTConc->pTCI->phase_currentFramePredicted, - &hTonalMDCTConc->pTCI->numIndexes, + (Word16 *)&hTonalMDCTConc->pTCI->numIndexes, hTonalMDCTConc->lastPitchLag, pitchLag, hTonalMDCTConc->lastBlockData.spectralData, @@ -1278,7 +1278,7 @@ void TonalMDCTConceal_Detect_ivas_fx( { //sns_shape_spectrum(powerSpectrum, psychParamsCurrent, hTonalMDCTConc->secondLastBlockData.scaleFactors, hTonalMDCTConc->nSamplesCore); Word16 power_spectrum_q; - FOR(Word16 i = 0; i < FDNS_NPTS; i++) + FOR( i = 0; i < FDNS_NPTS; i++) { sns_int_scf_fx[i] = L_shl(hTonalMDCTConc->secondLastBlockData.scaleFactors[i], 1 + hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i]); // Q16 } @@ -1296,12 +1296,12 @@ void TonalMDCTConceal_Detect_ivas_fx( move32(); } - RefineTonalComponents(hTonalMDCTConc->pTCI->indexOfTonalPeak, - hTonalMDCTConc->pTCI->lowerIndex, - hTonalMDCTConc->pTCI->upperIndex, + RefineTonalComponents((Word16 *)hTonalMDCTConc->pTCI->indexOfTonalPeak, + (Word16 *)hTonalMDCTConc->pTCI->lowerIndex, + (Word16 *)hTonalMDCTConc->pTCI->upperIndex, hTonalMDCTConc->pTCI->phaseDiff, hTonalMDCTConc->pTCI->phase_currentFramePredicted, - &hTonalMDCTConc->pTCI->numIndexes, + (Word16 *)&hTonalMDCTConc->pTCI->numIndexes, hTonalMDCTConc->lastPitchLag, pitchLag, hTonalMDCTConc->lastBlockData.spectralData, diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 79482e455e39804fde699a478ccb2917d45d812d..33f28aa24b5b255a301a8f0d0723dd37fc4f02c7 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -375,7 +375,6 @@ ivas_error ivas_spar_md_enc_init_fx( { Word32 pFC[IVAS_MAX_NUM_BANDS]; Word16 table_idx; - Word32 PR_minmax_fx[2]; Word16 num_channels, i, j, k; ivas_sba_get_spar_hoa_md_flag(sba_order, hEncoderConfig->ivas_total_brate, &hMdEnc->spar_hoa_md_flag, &hMdEnc->spar_hoa_dirac2spar_md_flag); diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index ef7b6f36afc65425a0ef374a49a3ff3dc35af34c..4245124f779e208f1903dc000204137b58ba5472 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -2954,6 +2954,13 @@ void ivas_rend_closeCrend( } } +#ifdef IVAS_FLOAT_FIXED + if ( hCrend->lfe_delay_line_fx != NULL ) + { + free( hCrend->lfe_delay_line_fx ); + hCrend->lfe_delay_line_fx = NULL; + } +#endif if ( hCrend->lfe_delay_line != NULL ) { free( hCrend->lfe_delay_line ); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 48d74e8f8afdf4e58a786257c0e5d713b769800f..5cdfcabadf612fa3604db877c186a8e33b8ccc63 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -51,6 +51,8 @@ #ifdef IVAS_FLOAT_FIXED Word16 slot_fx[4] = {32767, 16384, 10922 ,8192}; #endif + +#define IVAS_FLOAT_FIXED_TO_BE_REMOVED /*------------------------------------------------------------------------- * Local constants *------------------------------------------------------------------------*/ @@ -421,7 +423,7 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( if ( hDiracDecBin->hReverb != NULL && ( ( hDiracDecBin->hReverb->numBins != nBins ) || ( hDiracDecBin->hReverb->blockSize != CLDFB_SLOTS_PER_SUBFRAME ) ) ) { - ivas_binaural_reverb_close( &( hDiracDecBin->hReverb ) ); + ivas_binaural_reverb_close_fx( &( hDiracDecBin->hReverb ) ); } if ( hDiracDecBin->hReverb == NULL ) @@ -530,7 +532,10 @@ void ivas_dirac_dec_close_binaural_data( IF ((*hBinaural)->hReverb != NULL) { + ivas_binaural_reverb_close_fx(&((*hBinaural)->hReverb)); +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED ivas_binaural_reverb_close(&((*hBinaural)->hReverb)); +#endif } ivas_td_decorr_dec_close(&((*hBinaural)->hTdDecorr)); diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 30686c586fddd6ee891a8700d958e8d71d7c6b17..e551b22059ca123e57bcbe1c220788a06e2b7b1c 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -46,6 +46,7 @@ #include "ivas_prot_fx.h" #include "ivas_rom_binaural_crend_head.h" +#define IVAS_FLOAT_FIXED_TO_BE_REMOVED /*------------------------------------------------------------------------- * ivas_dirac_allocate_parameters() * @@ -857,18 +858,32 @@ void ivas_dirac_rend_close_fx( { FOR (j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++) { +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED IF (hDirACRend->buffer_intensity_real[i][j] != NULL) { free(hDirACRend->buffer_intensity_real[i][j]); hDirACRend->buffer_intensity_real[i][j] = NULL; } +#endif + IF (hDirACRend->buffer_intensity_real_fx[i][j] != NULL) + { + free(hDirACRend->buffer_intensity_real_fx[i][j]); + hDirACRend->buffer_intensity_real_fx[i][j] = NULL; + } } } +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED IF (hDirACRend->buffer_energy != NULL) { free(hDirACRend->buffer_energy); hDirACRend->buffer_energy = NULL; } +#endif + IF (hDirACRend->buffer_energy_fx != NULL) + { + free(hDirACRend->buffer_energy_fx); + hDirACRend->buffer_energy_fx = NULL; + } IF (hDirACRend->masa_stereo_type_detect != NULL) { @@ -1880,10 +1895,16 @@ void ivas_dirac_free_mem_fx( { free( hDirAC_mem->cy_auto_diff_smooth_fx ); } +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED IF (hDirAC_mem->direct_responses != NULL) { free(hDirAC_mem->direct_responses); } +#endif + if (hDirAC_mem->direct_responses_fx != NULL) + { + free(hDirAC_mem->direct_responses_fx); + } IF (hDirAC_mem->proto_direct_buffer_f != NULL) { free(hDirAC_mem->proto_direct_buffer_f); @@ -1950,12 +1971,6 @@ void ivas_dirac_free_mem( { free( hDirAC_mem->proto_power_smooth ); } -#ifdef IVAS_FLOAT_FIXED - if ( hDirAC_mem->proto_power_smooth_fx != NULL ) - { - free( hDirAC_mem->proto_power_smooth_fx ); - } -#endif if ( hDirAC_mem->proto_power_diff_smooth != NULL ) { free( hDirAC_mem->proto_power_diff_smooth ); @@ -1984,20 +1999,6 @@ void ivas_dirac_free_mem( { free( hDirAC_mem->proto_direct_buffer_f ); } -#ifdef IVAS_FLOAT_FIXED - if ( hDirAC_mem->proto_direct_buffer_f_fx != NULL ) - { - free( hDirAC_mem->proto_direct_buffer_f_fx ); - } - if ( hDirAC_mem->proto_diffuse_buffer_f_fx != NULL ) - { - free( hDirAC_mem->proto_diffuse_buffer_f_fx ); - } - if (hDirAC_mem->direct_responses_fx != NULL) - { - free(hDirAC_mem->direct_responses_fx); - } -#endif if ( hDirAC_mem->proto_diffuse_buffer_f != NULL ) { free( hDirAC_mem->proto_diffuse_buffer_f ); @@ -2018,16 +2019,6 @@ void ivas_dirac_free_mem( { free( hDirAC_mem->onset_filter ); } -#ifdef IVAS_FLOAT_FIXED - if ( hDirAC_mem->reference_power_fx != NULL ) - { - free( hDirAC_mem->reference_power_fx ); - } - if ( hDirAC_mem->onset_filter_fx != NULL ) - { - free( hDirAC_mem->onset_filter_fx ); - } -#endif return; } diff --git a/lib_rend/ivas_objectRenderer_hrFilt.c b/lib_rend/ivas_objectRenderer_hrFilt.c index 856a74a3b8070052d925ebe4777d924a5307bacb..3fdbe47f045a89dc898f4b8a31c9fc2cc36e80b2 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt.c +++ b/lib_rend/ivas_objectRenderer_hrFilt.c @@ -1133,19 +1133,6 @@ void BSplineModelEvalDealloc_fx( IF ( model->modelROM ) { -#if 1 //To be removed later :Floating point memory release - free( (void *) model->azimBsShape ); /* void* cast needed to please both gcc and Visual studio compilers. Deallocating const float** should be fine and gcc agrees, but Visual studio complains. */ - FOR ( i = 0; i < model->elevDim3; i++ ) - { - free( model->azimKSeq[i] ); - } - free( model->azimKSeq ); - IF ( modelEval != NULL ) - { - free( modelEval->hrfModL ); - free( modelEval->hrfModR ); - } -#endif free( (void *) model->azimBsShape_fx ); /* void* cast needed to please both gcc and Visual studio compilers. Deallocating const float** should be fine and gcc agrees, but Visual studio complains. */ FOR ( i = 0; i < model->elevDim3; i++ ) { @@ -1178,14 +1165,6 @@ void BSplineModelEvalDealloc( free( model->azimKSeq[i] ); } free( model->azimKSeq ); -#ifdef IVAS_FLOAT_FIXED - free( (void *) model->azimBsShape_fx ); /* void* cast needed to please both gcc and Visual studio compilers. Deallocating const float** should be fine and gcc agrees, but Visual studio complains. */ - FOR( i = 0; i < model->elevDim3; i++ ) - { - free( model->azimKSeq_fx[i] ); - } - free( model->azimKSeq_fx ); -#endif if ( modelEval != NULL ) { free( modelEval->hrfModL ); diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 5232930c9db9ea53df4e5037393b192afc311b76..bb95f0b387dae5d3590db1f076b22d4afcac42b4 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -1631,6 +1631,11 @@ ivas_error ivas_binaural_reverb_open_parambin( const HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : Parametric binauralizer HRTF handle */ ); +#ifdef IVAS_FLOAT_FIXED +void ivas_binaural_reverb_close_fx( + REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */ +); +#endif void ivas_binaural_reverb_close( REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */ ); diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 55375c9bde30944affffcc4544dba843982ac0b3..cbf9fe39038ba56d2906708199c28e2e1b0148df 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -981,9 +981,9 @@ static ivas_error compute_t60_coeffs_fx( Word16 bin_idx, loop_idx, tf_T60_len, len; ivas_error error; - Word16 loop_delay_sec_fx, inv_hfs_fx, norm_f_e, tmp; + Word16 loop_delay_sec_fx, norm_f_e, tmp; Word32 freq_Nyquist_fx = L_shr(output_Fs, 1); - Word16 target_gains_db_fx[RV_LENGTH_NR_FC], target_gains_exp; + Word16 target_gains_db_fx[RV_LENGTH_NR_FC]; Word16 norm_f_fx[RV_LENGTH_NR_FC]; Word32 *targetT60_fx, *pFc_fx; Word16 *pCoeffs_a_fx, *pCoeffs_b_fx, *targetT60_e; @@ -2287,7 +2287,6 @@ ivas_error ivas_reverb_open( REVERB_HANDLE pState = NULL; Word16 bin_idx, subframe_len, output_frame, predelay_bf_len, loop_idx; ivas_reverb_params_t params; - Word16 *pCoeffs_fx = params.pT60_filter_coeff_fx; Word32 pColor_target_l_fx[RV_LENGTH_NR_FC]; Word32 pColor_target_r_fx[RV_LENGTH_NR_FC]; Word32 pTime_window_fx[RV_FILTER_MAX_FFT_SIZE]; @@ -2399,7 +2398,9 @@ ivas_error ivas_reverb_open( /* Compute target levels (gains) for the coloration filters */ Word32 *pHrtf_avg_pwr_response_l_const = (Word32*)malloc(nr_fc_fft_filter * sizeof(Word32*)); Word32 *pHrtf_avg_pwr_response_r_const = (Word32*)malloc(nr_fc_fft_filter * sizeof(Word32*)); - Word32 *pT60_filter_coeff = (Word32*)malloc((params.nr_loops * 4 + 4) * sizeof(Word32*)); + Word16 lenT60_filter_coeff = add(params.t60_filter_order, 1); + lenT60_filter_coeff = add(i_mult(shl(lenT60_filter_coeff, 1), sub(params.nr_loops, 1)), add(lenT60_filter_coeff, 2)); + Word32 *pT60_filter_coeff = (Word32*)malloc((lenT60_filter_coeff) * sizeof(Word32*)); FOR (int i = 0; i < nr_fc_fft_filter; i++) @@ -2408,7 +2409,7 @@ ivas_error ivas_reverb_open( pHrtf_avg_pwr_response_l_const[i] = L_shl(params.pHrtf_avg_pwr_response_l_const_fx[i] ,5);/*Q23+5*/ pHrtf_avg_pwr_response_r_const[i] = L_shl(params.pHrtf_avg_pwr_response_r_const_fx[i] ,5);/*Q23+5*/ } - FOR (int i = 0; i < params.nr_loops * 4 + 4; i++) + FOR (int i = 0; i < lenT60_filter_coeff; i++) { pT60_filter_coeff[i] = L_shl_sat(params.pT60_filter_coeff_fx[i] ,17); } @@ -2486,6 +2487,7 @@ ivas_error ivas_reverb_open( } /* Computing coloration filters on the basis of target responses */ + ivas_reverb_calc_color_filters_fx(pColor_target_l_fx, pColor_target_r_fx, pTime_window_fx, pState->fft_size, 0, pFft_wf_filter_ch0_fx, pFft_wf_filter_ch1_fx, &q_pFft_wf_filter_ch0_fx, &q_pFft_wf_filter_ch1_fx); FOR ( int i = 0; i < nr_fc_fft_filter; i++ ) { @@ -2497,8 +2499,10 @@ ivas_error ivas_reverb_open( pFft_wf_filter_ch1_fx[i][0] = L_shl( pFft_wf_filter_ch1_fx[i][0], 31 - q_pFft_wf_filter_ch1_fx ); pFft_wf_filter_ch1_fx[i][1] = L_shl( pFft_wf_filter_ch1_fx[i][1], 31 - q_pFft_wf_filter_ch1_fx ); } + Scale_sig32( params.pHrtf_inter_aural_coherence_fx, nr_fc_fft_filter, 4 ); /*Scaling ( *hReverb )->fft_filter_color_0.fft_spectrum_fx to Q31*/ Scale_sig32( params.pFc_fx, nr_fc_fft_filter, 17 ); /*Scaling ( *hReverb )->fft_filter_color_1.fft_spectrum_fx to Q31*/ + /* Copying the computed FFT colorations filters to the fft_filter components */ IF ( ( error = set_color_fft_filter( pState, 0, pFft_wf_filter_ch0_fx ) ) != IVAS_ERR_OK ) { @@ -3891,7 +3895,7 @@ static ivas_error ivas_binaural_reverb_open( } ivas_binaural_reverb_setReverbTimes_fx( hReverb, sampling_rate, revTimes_fx, revEnes_fx ); - FOR(Word16 bin = 0; bin < hReverb->numBins; bin++) + FOR( bin = 0; bin < hReverb->numBins; bin++) { hReverb->binauralCoherenceDirectGains[bin] = (float)hReverb->binauralCoherenceDirectGains_fx[bin] / ONE_IN_Q31; hReverb->binauralCoherenceCrossmixGains[bin] = (float)hReverb->binauralCoherenceCrossmixGains_fx[bin] / ONE_IN_Q31; @@ -4013,7 +4017,7 @@ ivas_error ivas_binaural_reverb_open_parambin( *------------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED -void ivas_binaural_reverb_close( +void ivas_binaural_reverb_close_fx( REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */ ) { @@ -4044,7 +4048,7 @@ void ivas_binaural_reverb_close( return; } -#else +#endif void ivas_binaural_reverb_close( REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */ ) @@ -4061,8 +4065,10 @@ void ivas_binaural_reverb_close( FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { free( ( *hReverb )->tapPhaseShiftType[bin][chIdx] ); +#ifndef IVAS_FLOAT_FIXED free( ( *hReverb )->tapPointersReal[bin][chIdx] ); free( ( *hReverb )->tapPointersImag[bin][chIdx] ); +#endif free( ( *hReverb )->outputBufferReal[bin][chIdx] ); free( ( *hReverb )->outputBufferImag[bin][chIdx] ); } @@ -4075,4 +4081,3 @@ void ivas_binaural_reverb_close( return; } -#endif \ No newline at end of file diff --git a/lib_rend/ivas_vbap.c b/lib_rend/ivas_vbap.c index a579af75dd5eb479c0cb09d873f52d443bd5a878..3c3fd8023356d1fe9325e4941ec85b90070cbe46 100644 --- a/lib_rend/ivas_vbap.c +++ b/lib_rend/ivas_vbap.c @@ -310,13 +310,6 @@ ivas_error vbap_init_data_fx( set16_fx( vbap->top_virtual_speaker_node_division_gains_fx, 0, num_speaker_nodes ); is_success &= vbap->top_virtual_speaker_node_division_gains_fx != NULL; - IF( ( vbap->top_virtual_speaker_node_division_gains_fx = (Word16 *) malloc( num_speaker_nodes * sizeof( Word16 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for VBAP data\n" ) ); - } - set16_fx( vbap->top_virtual_speaker_node_division_gains_fx, 0, num_speaker_nodes ); - is_success &= vbap->top_virtual_speaker_node_division_gains_fx != NULL; - IF( EQ_16( ivas_format, MASA_ISM_FORMAT ) ) { IF( ( vbap->object_mode_top_virtual_speaker_node_division_gains_fx = (Word16 *) malloc( num_speaker_nodes * sizeof( Word16 ) ) ) == NULL ) @@ -767,6 +760,14 @@ void vbap_free_data_fx( { free( ( *hVBAPdata )->object_mode_back_virtual_speaker_node_division_gains_fx ); } + if ( ( *hVBAPdata )->search_struct[0].triplets != NULL ) + { + free( ( *hVBAPdata )->search_struct[0].triplets ); + } + if ( ( *hVBAPdata )->num_search_structs == 2 && ( *hVBAPdata )->search_struct[1].triplets != NULL ) + { + free( ( *hVBAPdata )->search_struct[1].triplets ); + } free( *hVBAPdata ); *hVBAPdata = NULL; @@ -1545,6 +1546,8 @@ static void determine_virtual_speaker_node_division_gains_fx( } } + free(exp_virtual_node_division_gains); + return; } #else