diff --git a/lib_com/options.h b/lib_com/options.h index eae06258d74b4e8173a5b49373fc0658332e07fb..8098b3e2c5587e5b9fda17475e3399589b3540ce 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -160,6 +160,7 @@ #define NONBE_1244_FIX_SWB_BWE_MEMORY /* VA: issue 1244: fix to SWB BWE memory in case of switching from FB coding - pending a review by Huawei */ #define FIX_1113_CLDFB_REND_IN_ISAR /* issue 1113: fix the use of CLDFB renderer in split-rendering at the external renderer */ #define NONBE_1328_FIX_NON_LINEARITY /* VA: Fix possible issue when computing bwe_exc_extended and previous frame were almost 0 */ +#define SIMPLIFY_IVAS_CORE /* VA: simplify ivas core coder functions */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_com/prot.h b/lib_com/prot.h index b917d41dc2d26fe910df2f495e97bc7436babc9a..c15608e730795b3490affbc3e4db8f4ff1aed62a 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -5863,7 +5863,6 @@ ivas_error core_switching_post_dec( float *synth, /* i/o: output synthesis */ float *output, /* i/o: LB synth/upsampled LB synth */ float output_mem[], /* i : OLA memory from last TCX/HQ frame */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ const int16_t output_frame, /* i : frame length */ const int16_t core_switching_flag, /* i : ACELP->HQ switching frame flag */ diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index c6e7fe24c316a7c97d29fd9cada922049aedae6a..1f340121f6759c01874d77bc21a26a098dcb3e85 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -557,7 +557,6 @@ ivas_error core_switching_post_dec( float *synth, /* i/o: output synthesis */ float *output, /* i/o: LB synth/upsampled LB synth */ float output_mem[], /* i : OLA memory from last TCX/HQ frame */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ const int16_t output_frame, /* i : frame length */ const int16_t core_switching_flag, /* i : ACELP->HQ switching flag */ @@ -679,7 +678,11 @@ ivas_error core_switching_post_dec( synth[i + delay_comp] = ( synth[i + delay_comp] * i + ( tmpDelta - i ) * st->previoussynth[i + delay_comp] ) / tmpDelta; } +#ifdef SIMPLIFY_IVAS_CORE + if ( ( st->element_mode == IVAS_CPE_MDCT || ( st->is_ism_format && st->core == TCX_20_CORE /* <- means TCX in general, TCX10 is forbidden after ACELP */ ) ) && st->last_core_brate <= SID_2k40 && st->core_brate > SID_2k40 ) +#else if ( ( st->element_mode == IVAS_CPE_MDCT || ( ivas_format == ISM_FORMAT && st->core == TCX_20_CORE /* <- means TCX in general, TCX10 is forbidden after ACELP */ ) ) && st->last_core_brate <= SID_2k40 && st->core_brate > SID_2k40 ) +#endif { /* smooth transitions to avoid pops in car noise items */ smoothTransitionDtxToTcx( synth, output_frame, delay_comp ); diff --git a/lib_dec/evs_dec.c b/lib_dec/evs_dec.c index 464437d75cd72b244721ab935900bb932250242f..14df97361e34d3d14bfc1a8660a033b0f8a9ee6b 100644 --- a/lib_dec/evs_dec.c +++ b/lib_dec/evs_dec.c @@ -274,7 +274,7 @@ ivas_error evs_dec( * Postprocessing for ACELP/MDCT core switching *---------------------------------------------------------------------*/ - if ( ( error = core_switching_post_dec( st, synth, NULL, NULL, 0, MONO_FORMAT, output_frame, core_switching_flag, 0, -1, EVS_MONO ) ) != IVAS_ERR_OK ) + if ( ( error = core_switching_post_dec( st, synth, NULL, NULL, 0, output_frame, core_switching_flag, 0, -1, EVS_MONO ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 9c146d5a5d49ad8e7f5cfddfcbbce572218a564a..093f163f564a6c358cfd2b5a9b39337e03f37eba 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -70,6 +70,7 @@ ivas_error ivas_core_dec( Decoder_State **sts, *st; STEREO_ICBWE_DEC_HANDLE hStereoICBWE; STEREO_TD_DEC_DATA_HANDLE hStereoTD; + STEREO_CNG_DEC_HANDLE hStereoCng; int16_t sharpFlag[CPE_CHANNELS]; float synth[CPE_CHANNELS][L_FRAME48k]; float tmp_buffer[L_FRAME48k]; @@ -116,6 +117,7 @@ ivas_error ivas_core_dec( last_element_mode = IVAS_SCE; hStereoTD = NULL; p_output_mem = NULL; + hStereoCng = NULL; nchan_out = 1; if ( st_ivas != NULL && st_ivas->ivas_format == ISM_FORMAT ) { @@ -133,6 +135,7 @@ ivas_error ivas_core_dec( last_element_mode = hCPE->last_element_mode; hStereoICBWE = hCPE->hStereoICBWE; hStereoTD = hCPE->hStereoTD; + hStereoCng = hCPE->hStereoCng; p_output_mem = hCPE->output_mem[1]; nchan_out = hCPE->nchan_out; @@ -243,19 +246,16 @@ ivas_error ivas_core_dec( } } - if ( hCPE != NULL && hCPE->hStereoCng != NULL ) + if ( hStereoCng != NULL ) { - hCPE->hStereoCng->flag_cna_fade = 0; + hStereoCng->flag_cna_fade = 0; } + save_hb_synth = NULL; 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; } - else - { - save_hb_synth = NULL; - } /*------------------------------------------------------------------* * Decode SID for MDCT-Stereo DTX mode @@ -279,7 +279,7 @@ ivas_error ivas_core_dec( if ( hCPE != NULL && hCPE->element_mode == IVAS_CPE_DFT && hCPE->brate_surplus > 0 ) { - ivas_combined_format_brate_sanity( hCPE->element_brate, sts[0]->core, sts[0]->total_brate, &( sts[0]->core_brate ), &( sts[0]->inactive_coder_type_flag ), &tmps ); + ivas_combined_format_brate_sanity( element_brate, sts[0]->core, sts[0]->total_brate, &( sts[0]->core_brate ), &( sts[0]->inactive_coder_type_flag ), &tmps ); } /*------------------------------------------------------------------* @@ -348,7 +348,7 @@ ivas_error ivas_core_dec( if ( st->core == ACELP_CORE ) { /* ACELP core decoder */ - if ( ( error = acelp_core_dec( st, output[n], synth[n], save_hb_synth, bwe_exc_extended[n], voice_factors[n], old_syn_12k8_16k[n], sharpFlag[n], pitch_buf[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hCPE == NULL ? NULL : hCPE->hStereoCng, read_sid_info ) ) != IVAS_ERR_OK ) + if ( ( error = acelp_core_dec( st, output[n], synth[n], save_hb_synth, bwe_exc_extended[n], voice_factors[n], old_syn_12k8_16k[n], sharpFlag[n], pitch_buf[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ) != IVAS_ERR_OK ) { return error; } @@ -357,7 +357,7 @@ ivas_error ivas_core_dec( if ( ( st->core == TCX_20_CORE || st->core == TCX_10_CORE ) && st->element_mode != IVAS_CPE_MDCT ) { /* TCX decoder */ - stereo_tcx_core_dec( st, frameMode[n], output[n], synth[n], pitch_buf[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hCPE == NULL ? NULL : hCPE->hStereoCng, nchan_out, st_ivas == NULL ? 0 : st_ivas->ivas_format ); + stereo_tcx_core_dec( st, frameMode[n], output[n], synth[n], pitch_buf[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hStereoCng, nchan_out, st_ivas == NULL ? 0 : st_ivas->ivas_format ); } if ( st->core == HQ_CORE ) @@ -420,9 +420,9 @@ ivas_error ivas_core_dec( * Stereo CNG updates *---------------------------------------------------------------------*/ - if ( sts[0]->element_mode == IVAS_CPE_TD && hCPE->hStereoCng != NULL ) + if ( sts[0]->element_mode == IVAS_CPE_TD && hStereoCng != NULL ) { - stereo_cng_compute_PScorr( output, &hCPE->hStereoCng->c_PS_LT, sts[0]->L_frame, sts[1]->L_frame ); + stereo_cng_compute_PScorr( output, &hStereoCng->c_PS_LT, sts[0]->L_frame, sts[1]->L_frame ); } /*---------------------------------------------------------------------* @@ -462,7 +462,7 @@ ivas_error ivas_core_dec( mvr2r( synth[n], hSCE->save_synth, output_frame ); } - if ( ( error = core_switching_post_dec( st, synth[n], output[n], p_output_mem, ( st_ivas != NULL ) ? st_ivas->ivas_format : UNDEFINED_FORMAT, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, ( hCPE != NULL ) ? hCPE->last_element_mode : IVAS_SCE ) ) != IVAS_ERR_OK ) + if ( ( error = core_switching_post_dec( st, synth[n], output[n], p_output_mem, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, ( hCPE != NULL ) ? hCPE->last_element_mode : IVAS_SCE ) ) != IVAS_ERR_OK ) { return error; } @@ -474,7 +474,7 @@ ivas_error ivas_core_dec( } /* if we transition from inactive to active coding in MDCT-Stereo DTX and the output format is mono DMX, we need to sync the upsampled buffer between channels here */ - if ( n == 0 && st->element_mode == IVAS_CPE_MDCT && st->last_core == ACELP_CORE && st->core != ACELP_CORE && ( nchan_out == 1 || ( hCPE != NULL && hCPE->last_element_mode == IVAS_CPE_DFT ) ) ) + if ( n == 0 && st->element_mode == IVAS_CPE_MDCT && st->last_core == ACELP_CORE && st->core != ACELP_CORE && ( nchan_out == 1 || last_element_mode == IVAS_CPE_DFT ) ) { mvr2r( sts[0]->previoussynth, sts[1]->previoussynth, st->hTcxDec->L_frameTCX ); } @@ -649,7 +649,7 @@ ivas_error ivas_core_dec( mvr2r( tmp_buffer, st->hb_prev_synth_buffer, tmps ); } - if ( ( st->element_mode != IVAS_CPE_TD && !use_cldfb_for_dft ) || ( hCPE->element_mode == IVAS_CPE_TD && tdm_LRTD_flag ) ) + if ( ( st->element_mode != IVAS_CPE_TD && !use_cldfb_for_dft ) || ( st->element_mode == IVAS_CPE_TD && tdm_LRTD_flag ) ) { /* Delay hb_synth */ delay_signal( hb_synth[n], output_frame, st->hb_prev_synth_buffer, tmps ); @@ -702,7 +702,7 @@ ivas_error ivas_core_dec( } else /* IVAS_CPE_DFT */ { - if ( hCPE->last_element_mode == IVAS_CPE_MDCT ) + if ( last_element_mode == IVAS_CPE_MDCT ) { stereo_mdct2dft_update( hCPE, output[0], synth[0] ); } diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index ebc295cb7204209d9107844c96af15cb35ef611b..3077282c7e5f6914872ed8e54714ea49986685da 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -76,6 +76,7 @@ ivas_error ivas_cpe_dec( float outputHB[CPE_CHANNELS][L_FRAME48k]; /* 'float' buffer for output HB synthesis, both channels */ float res_buf[STEREO_DFT_N_8k]; CPE_DEC_HANDLE hCPE; + STEREO_DFT_CONFIG_DATA_HANDLE hConfigDft; Decoder_State **sts; int32_t ivas_total_brate; ivas_error error; @@ -116,6 +117,12 @@ ivas_error ivas_cpe_dec( return error; } + hConfigDft = NULL; + if ( hCPE->hStereoDft != NULL ) + { + hConfigDft = hCPE->hStereoDft->hConfig; + } + /*------------------------------------------------------------------* * Initialization *-----------------------------------------------------------------*/ @@ -172,11 +179,11 @@ ivas_error ivas_cpe_dec( { if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { - stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, (int32_t) ( 0.7f * st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); + stereo_dft_config( hConfigDft, (int32_t) ( 0.7f * st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); } else { - stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); + stereo_dft_config( hConfigDft, st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); } } else @@ -184,11 +191,11 @@ ivas_error ivas_cpe_dec( /* Note: This only works for stereo operation. If DTX would be applied for multiple CPEs a different bitrate signaling is needed */ if ( ivas_total_brate <= IVAS_SID_5k2 ) { - stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, ivas_total_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); + stereo_dft_config( hConfigDft, ivas_total_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); } else { - stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); + stereo_dft_config( hConfigDft, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); } } } @@ -419,7 +426,7 @@ ivas_error ivas_cpe_dec( * Core Decoder *----------------------------------------------------------------*/ - if ( hCPE->element_mode != IVAS_CPE_DFT || ( hCPE->nchan_out == 1 && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF ) ) + if ( hCPE->element_mode != IVAS_CPE_DFT || ( hCPE->nchan_out == 1 && hConfigDft->res_cod_mode == STEREO_DFT_RES_COD_OFF ) ) { if ( ( error = ivas_core_dec( st_ivas, NULL, hCPE, st_ivas->hMCT, n_channels, output, outputHB, NULL, st_ivas->sba_dirac_stereo_flag ) ) != IVAS_ERR_OK ) { @@ -438,7 +445,7 @@ ivas_error ivas_cpe_dec( * Stereo decoder & upmixing *----------------------------------------------------------------*/ - if ( hCPE->element_mode == IVAS_CPE_DFT && !( hCPE->nchan_out == 1 && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF ) ) + if ( hCPE->element_mode == IVAS_CPE_DFT && !( hCPE->nchan_out == 1 && hConfigDft->res_cod_mode == STEREO_DFT_RES_COD_OFF ) ) { float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX]; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 4e8031e140dfad7d7eded1fda4de97ba7a586baf..291032941438eafac4ce0ec886435c739e453001 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -260,7 +260,7 @@ ivas_error ivas_mct_dec( } /* Postprocessing for ACELP/MDCT core switching and synchronization */ - if ( ( error = core_switching_post_dec( sts[n], synth[n], output[cpe_id * CPE_CHANNELS + n], hCPE->output_mem[1], st_ivas->ivas_format, 0, output_frame, 0 /*core_switching_flag*/, ( st_ivas->ivas_format != SBA_ISM_FORMAT || cpe_id >= nCPE - 2 ) ? st_ivas->sba_dirac_stereo_flag : 0, -1, hCPE->last_element_mode ) ) != IVAS_ERR_OK ) + if ( ( error = core_switching_post_dec( sts[n], synth[n], output[cpe_id * CPE_CHANNELS + n], hCPE->output_mem[1], 0, output_frame, 0 /*core_switching_flag*/, ( st_ivas->ivas_format != SBA_ISM_FORMAT || cpe_id >= nCPE - 2 ) ? st_ivas->sba_dirac_stereo_flag : 0, -1, hCPE->last_element_mode ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index b3e8addc7d6c8b96961c200ddcf734b8f7142665..cdf012b3f6740ab5eebb87cccf036d44ca340b23 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -194,7 +194,7 @@ ivas_error ivas_core_enc( diff_nBits = 0; if ( hCPE != NULL && hCPE->element_mode == IVAS_CPE_DFT && hCPE->brate_surplus > 0 ) { - ivas_combined_format_brate_sanity( hCPE->element_brate, sts[0]->core, sts[0]->total_brate, &( sts[0]->core_brate ), &( sts[0]->inactive_coder_type_flag ), &diff_nBits ); + ivas_combined_format_brate_sanity( element_brate, sts[0]->core, sts[0]->total_brate, &( sts[0]->core_brate ), &( sts[0]->inactive_coder_type_flag ), &diff_nBits ); } /*---------------------------------------------------------------------* diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 8f1e419d5d227abed2613fdcf2103e3c17d004fb..42ec9f84292033cf00f69dd9b2ea6792b539f70d 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -68,6 +68,7 @@ ivas_error ivas_cpe_enc( ) { CPE_ENC_HANDLE hCPE; + STEREO_DFT_CONFIG_DATA_HANDLE hConfigDft; Encoder_State **sts; int16_t n, n_CoreChannels; float old_inp_12k8[CPE_CHANNELS][L_INP_12k8]; /* buffer of input signal @ 12k8 */ @@ -222,6 +223,11 @@ ivas_error ivas_cpe_enc( return error; } + hConfigDft = NULL; + if ( hCPE->hStereoDft != NULL ) + { + hConfigDft = hCPE->hStereoDft->hConfig; + } /*----------------------------------------------------------------* * Set TD stereo parameters @@ -295,25 +301,24 @@ ivas_error ivas_cpe_enc( sts[n]->element_mode = hCPE->element_mode; } - if ( hCPE->element_mode != IVAS_CPE_MDCT && ( hCPE->element_brate != hCPE->last_element_brate || hCPE->last_element_mode != hCPE->element_mode || sts[0]->ini_frame == 0 || - ( ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate ) || sts[0]->last_core_brate <= SID_2k40 ) ) /* If the last frame was SID or NO_DATA, we need to run stereo_dft_config here since VAD decision is not known yet */ + ( ivas_total_brate != hEncoderConfig->last_ivas_total_brate ) || sts[0]->last_core_brate <= SID_2k40 ) ) /* If the last frame was SID or NO_DATA, we need to run stereo_dft_config here since VAD decision is not known yet */ { if ( st_ivas->hQMetaData != NULL ) { if ( ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode != ISM_MODE_NONE ) { - stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, (int32_t) ( 0.70f * st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); + stereo_dft_config( hConfigDft, (int32_t) ( 0.70f * st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); } else { - stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); + stereo_dft_config( hConfigDft, st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); } } else { /* note; "bits_frame_nominal" needed in TD stereo as well */ - stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); + stereo_dft_config( hConfigDft, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); } } @@ -399,13 +404,13 @@ ivas_error ivas_cpe_enc( if ( hCPE->element_mode == IVAS_CPE_DFT ) { - stereo_dft_hybrid_ITD_flag( hCPE->hStereoDft->hConfig, input_Fs, hCPE->hStereoDft->hItd->hybrid_itd_max ); + stereo_dft_hybrid_ITD_flag( hConfigDft, input_Fs, hCPE->hStereoDft->hItd->hybrid_itd_max ); /* Time Domain ITD compensation using extrapolation */ #ifdef DEBUG_MODE_DFT - stereo_td_itd( hCPE->hStereoDft->hItd, hCPE->hStereoDft->input_mem_itd, hCPE->hStereoDft->hConfig->hybrid_itd_flag, hCPE->hStereoDft->hConfig->itd_mode, hCPE->hStereoDft->dft_ovl, sts, input_frame, hCPE->input_mem ); + stereo_td_itd( hCPE->hStereoDft->hItd, hCPE->hStereoDft->input_mem_itd, hConfigDft->hybrid_itd_flag, hConfigDft->itd_mode, hCPE->hStereoDft->dft_ovl, sts, input_frame, hCPE->input_mem ); #else - stereo_td_itd( hCPE->hStereoDft->hItd, hCPE->hStereoDft->input_mem_itd, hCPE->hStereoDft->hConfig->hybrid_itd_flag, hCPE->hStereoDft->dft_ovl, sts, input_frame, hCPE->input_mem ); + stereo_td_itd( hCPE->hStereoDft->hItd, hCPE->hStereoDft->input_mem_itd, hConfigDft->hybrid_itd_flag, hCPE->hStereoDft->dft_ovl, sts, input_frame, hCPE->input_mem ); #endif /* DFT on right and left input channels */ @@ -416,7 +421,7 @@ ivas_error ivas_cpe_enc( hCPE->hStereoDft->res_cod_bits = (int16_t) ( ( hCPE->element_brate ) / FRAMES_PER_SEC - 0.8f * sts[0]->bits_frame_nominal ); #endif /* Update DFT Stereo memories */ - stereo_dft_enc_update( hCPE->hStereoDft, sts[0]->max_bwidth ); + stereo_dft_enc_update( hCPE->hStereoDft, max_bwidth ); /* DFT stereo processing */ stereo_dft_enc_process( hCPE, vad_flag_dtx, vad_hover_flag, input_frame ); @@ -424,9 +429,7 @@ ivas_error ivas_cpe_enc( else if ( hCPE->element_mode == IVAS_CPE_TD ) { /* Determine the energy ratio between the 2 channels */ - tdm_ratio_idx = stereo_tdm_ener_analysis( - ivas_format, - hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM ); + tdm_ratio_idx = stereo_tdm_ener_analysis( ivas_format, hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM ); /* Compute the downmix signal based on the ratio index */ stereo_tdm_downmix( hCPE->hStereoTD, sts[0]->input, sts[1]->input, input_frame, tdm_ratio_idx, ( ( hCPE->hStereoTD->tdm_LRTD_flag == 0 ) ? tdm_SM_or_LRTD_Pri : 0 ), tdm_ratio_idx_SM ); @@ -501,7 +504,7 @@ ivas_error ivas_cpe_enc( error = pre_proc_front_ivas( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8[n], old_inp_16k[n], &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], &vad_hover_flag[n], &attack_flag[n], realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n], - fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate + fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_format, st_ivas->hMCT != NULL, hEncoderConfig->last_ivas_total_brate, ivas_total_brate #ifdef DEBUG_MODE_INFO , ( st_ivas->nSCE + ( cpe_id * CPE_CHANNELS ) + n ) @@ -557,7 +560,7 @@ ivas_error ivas_cpe_enc( set_bw_stereo( hCPE ); /* reconfiguration of MDCT stereo */ - if ( sts[0]->bwidth != sts[0]->last_bwidth || ( ( hCPE->last_element_brate != hCPE->element_brate || hCPE->last_element_mode != hCPE->element_mode ) && sts[0]->bwidth != sts[0]->max_bwidth ) ) + if ( sts[0]->bwidth != sts[0]->last_bwidth || ( ( hCPE->last_element_brate != hCPE->element_brate || hCPE->last_element_mode != hCPE->element_mode ) && sts[0]->bwidth != max_bwidth ) ) { initMdctStereoEncData( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, sts[0]->bwidth, 0, NULL, 0 ); hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) ); @@ -578,12 +581,11 @@ ivas_error ivas_cpe_enc( if ( ( hCPE->last_element_brate != hCPE->element_brate || hCPE->element_mode != hCPE->last_element_mode || ( hCPE->element_mode == IVAS_CPE_TD && sts[0]->bits_frame_nominal != last_bits_frame_nominal ) || sts[n]->last_bwidth != sts[n]->bwidth ) && ( n == 0 || hCPE->element_mode == IVAS_CPE_MDCT ) ) { int16_t igf; - int16_t bw; - bw = ( hCPE->element_mode == IVAS_CPE_MDCT ) ? sts[n]->bwidth : sts[n]->max_bwidth; + bw = ( hCPE->element_mode == IVAS_CPE_MDCT ) ? sts[n]->bwidth : max_bwidth; igf = getIgfPresent( sts[n]->element_mode, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, bw, sts[n]->rf_mode ); - if ( ( error = IGF_Reconfig( &sts[n]->hIGFEnc, igf, 0, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, sts[n]->max_bwidth, sts[n]->element_mode, sts[n]->rf_mode ) ) != IVAS_ERR_OK ) + if ( ( error = IGF_Reconfig( &sts[n]->hIGFEnc, igf, 0, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, max_bwidth, sts[n]->element_mode, sts[n]->rf_mode ) ) != IVAS_ERR_OK ) { return error; } @@ -650,11 +652,11 @@ ivas_error ivas_cpe_enc( /* Reconfigure DFT Stereo for inactive frames */ if ( sts[0]->core_brate == SID_2k40 ) { - stereo_dft_config( hCPE->hStereoDft->hConfig, IVAS_SID_5k2, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); + stereo_dft_config( hConfigDft, IVAS_SID_5k2, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); } else { - stereo_dft_config( hCPE->hStereoDft->hConfig, FRAME_NO_DATA, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); + stereo_dft_config( hConfigDft, FRAME_NO_DATA, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); } stereo_dft_cng_side_gain( hCPE->hStereoDft, hCPE->hStereoCng, sts[0]->core_brate, sts[0]->last_core_brate, sts[0]->bwidth ); diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index bac7ee783dea66853962d32673358dc1feaf6654..5fcc1980ea8bca141e2868f4c5bb5e92cf7c6f7e 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -169,7 +169,7 @@ ivas_error ivas_sce_enc( /* set flag for sampling rate of OL S/M classifier */ flag_16k_smc = 0; - if ( st_ivas->hEncoderConfig->ivas_format == SBA_FORMAT && ( st_ivas->hEncoderConfig->ivas_total_brate == IVAS_24k4 || st_ivas->hEncoderConfig->ivas_total_brate == IVAS_32k ) && hSCE->element_brate == hSCE->last_element_brate ) + if ( ivas_format == SBA_FORMAT && ( st_ivas->hEncoderConfig->ivas_total_brate == IVAS_24k4 || st_ivas->hEncoderConfig->ivas_total_brate == IVAS_32k ) && hSCE->element_brate == hSCE->last_element_brate ) { flag_16k_smc = 1; }