From 584d51b1ad2c668f91969b05f0646acd2b310b4c Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 11:29:51 +0100 Subject: [PATCH 01/10] HARM_DTX, HARM_PREPROC --- lib_com/options.h | 2 + lib_enc/amr_wb_enc_fx.c | 4 + lib_enc/dtx_fx.c | 53 +++++-- lib_enc/init_enc_fx.c | 4 + lib_enc/ivas_core_pre_proc_front_fx.c | 209 +++++++++---------------- lib_enc/ivas_front_vad_fx.c | 4 + lib_enc/ivas_stereo_switching_enc_fx.c | 4 + lib_enc/pre_proc_fx.c | 13 +- lib_enc/prot_fx_enc.h | 5 +- 9 files changed, 147 insertions(+), 151 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4a272cf24..64addadef 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -124,6 +124,8 @@ #define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ #define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ #define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ +#define HARM_DTX /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ +#define HARM_PREPROC /* #################### End BE switches ################################## */ diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index 9b20100ba..e5da3ed7f 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -332,7 +332,11 @@ void amr_wb_enc_fx( move16(); } +#ifdef HARM_DTX + dtx_fx( st, -1, -1, vad_flag_dtx, inp, Q_new ); +#else dtx_fx( st, vad_flag_dtx, inp, Q_new ); +#endif /*----------------------------------------------------------------* * Noise energy down-ward update and total noise energy estimation diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index 483304cde..12c7fdbc6 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -43,7 +43,7 @@ static void update_SID_cnt_fx( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate, /*==================================================================================*/ -/* FUNCTION : dtx_ivas_fx() */ +/* FUNCTION : dtx_fx() */ /*----------------------------------------------------------------------------------*/ /* PURPOSE : Discontinuous transmission operation */ /*----------------------------------------------------------------------------------*/ @@ -58,25 +58,28 @@ static void update_SID_cnt_fx( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate, /* _ (Word16*) qener : frame_ener/lt_ener_voiced/lt_ener_noise buf qformat */ /* _ (Encoder_State_Fx) st_fx : encoder state structure */ /*----------------------------------------------------------------------------------*/ - /*----------------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ /* _ None */ /*==================================================================================*/ + +#ifdef HARM_DTX +void dtx_fx( +#else void dtx_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ const Word16 vad, /* i : vad flag for DTX Q0*/ const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ - Word16 Q_speech /* i : Q factor for speech */ + const Word16 Q_speech /* i : Q factor for speech */ ) { Word16 alpha, i, j, Q_speech2; Word32 L_tmp; DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc; TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; - Word16 last_br_cng_flag, last_br_flag, br_dtx_flag; Word32 total_brate_ref; @@ -100,7 +103,7 @@ void dtx_ivas_fx( test(); test(); test(); - + test(); last_br_flag = ( st_fx->element_mode == EVS_MONO && LE_32( st_fx->last_total_brate, MAX_BRATE_DTX_EVS ) ) || ( st_fx->element_mode != EVS_MONO && LE_32( last_ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 ); @@ -114,6 +117,7 @@ void dtx_ivas_fx( st_fx->cng_type = FD_CNG; move16(); + test(); test(); test(); @@ -123,6 +127,7 @@ void dtx_ivas_fx( move16(); } } + test(); test(); test(); @@ -142,12 +147,14 @@ void dtx_ivas_fx( { st_fx->total_brate = st_fx->last_total_brate_cng; move32(); + test(); if ( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) ) { st_fx->Opt_SC_VBR = 0; move16(); } + st_fx->rf_mode = st_fx->last_rf_mode_cng; move16(); st_fx->bwidth = st_fx->last_bwidth_cng; @@ -155,13 +162,14 @@ void dtx_ivas_fx( st_fx->codec_mode = st_fx->last_codec_mode_cng; move16(); } + test(); test(); IF( LE_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate, st_fx->total_brate ) && last_br_flag ) - { st_fx->total_brate = st_fx->last_total_brate; move32(); + test(); if ( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) ) { @@ -179,10 +187,12 @@ void dtx_ivas_fx( st_fx->Opt_RF_ON = 1; move16(); } + st_fx->rf_mode = st_fx->Opt_RF_ON; move16(); st_fx->bwidth = st_fx->last_bwidth; move32(); + IF( st_fx->element_mode > EVS_MONO ) { st_fx->codec_mode = MODE1; @@ -213,6 +223,7 @@ void dtx_ivas_fx( ( ( st_fx->element_mode != EVS_MONO ) && LE_32( ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || LT_16( extract_h( st_fx->lp_noise_32fx ), DTX_THR * 256 ); } + test(); test(); test(); @@ -272,12 +283,14 @@ void dtx_ivas_fx( st_fx->core_brate = SID_2k40; move32(); } + test(); test(); IF( ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->cng_type, FD_CNG ) ) && EQ_16( st_fx->dtx_sce_sba, 1 ) ) { st_fx->cng_type = FD_CNG; move16(); + test(); test(); test(); @@ -320,6 +333,7 @@ void dtx_ivas_fx( move16(); } } + /* reset the bitstream (IVAS format signalling was already written) */ test(); IF( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->hBstr != NULL ) @@ -337,7 +351,7 @@ void dtx_ivas_fx( /*------------------------------------------------------------------------* * Reset counters when in active frame (not in SID or FRAME_NO_DATA frame) *------------------------------------------------------------------------*/ - /* NB core bit rate can be "-1" at startup , so one can not use core_brate_fx <=2400 */ + test(); test(); IF( ( NE_32( st_fx->core_brate, SID_2k40 ) ) && ( NE_32( st_fx->core_brate, SID_1k75 ) ) && ( st_fx->core_brate != FRAME_NO_DATA ) ) @@ -428,6 +442,7 @@ void dtx_ivas_fx( move16(); } } + st_fx->last_total_brate_cng = -1; move16(); } @@ -436,6 +451,7 @@ void dtx_ivas_fx( st_fx->cng_type = LP_CNG; move16(); } + st_fx->active_cnt = add( st_fx->active_cnt, 1 ); move16(); st_fx->active_cnt = s_min( st_fx->active_cnt, 200 ); @@ -445,6 +461,7 @@ void dtx_ivas_fx( /*------------------------------------------------------------------------* * Update speech and background noise long-term energy *------------------------------------------------------------------------*/ + IF( hDtxEnc != NULL ) { hDtxEnc->frame_ener_fx = L_deposit_l( 0 ); @@ -467,7 +484,6 @@ void dtx_ivas_fx( } /* Active speech (voiced) */ - IF( EQ_16( st_fx->clas, VOICED_CLAS ) ) { alpha = ALPHA_ENER_SLOW_FX; /*Q15 */ @@ -524,7 +540,6 @@ void dtx_ivas_fx( test(); IF( st_fx->Opt_DTX_ON && ( EQ_32( st_fx->core_brate, SID_2k40 ) || ( st_fx->core_brate == FRAME_NO_DATA ) ) ) { - st_fx->bwidth = st_fx->last_bwidth; move16(); test(); @@ -561,7 +576,6 @@ void dtx_ivas_fx( IF( EQ_16( st_fx->codec_mode, MODE2 ) ) { Word16 n, bits_frame_nominal; - UWord16 lsb; Word16 tmpbandwidthMin; @@ -575,17 +589,20 @@ void dtx_ivas_fx( BREAK; } } - IF( EQ_16( n, FRAME_SIZE_NB ) ) + if ( n == FRAME_SIZE_NB ) { assert( !"Bitrate not supported: not part of EVS" ); } + tmpbandwidthMin = FrameSizeConfig[n].bandwidth_min; move16(); + if ( EQ_16( st_fx->rf_mode, 1 ) ) { tmpbandwidthMin = WB; move16(); } + st_fx->bwidth = s_max( s_min( st_fx->bwidth, FrameSizeConfig[n].bandwidth_max ), tmpbandwidthMin ); move16(); } @@ -594,6 +611,7 @@ void dtx_ivas_fx( return; } +#ifndef HARM_DTX /*==================================================================================*/ /* FUNCTION : dtx_fx() */ /*----------------------------------------------------------------------------------*/ @@ -1052,6 +1070,7 @@ void dtx_fx( return; } +#endif /*---------------------------------------------------------------------* * update_SID_cnt() @@ -1201,6 +1220,12 @@ static void update_SID_cnt_fx( } +/*-------------------------------------------------------------------* + * dtx_hangover_control() + * + * + *-------------------------------------------------------------------*/ + void dtx_hangover_control_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 lsp_new_fx[M] /* i : current frame LSPs Q15*/ @@ -1480,6 +1505,7 @@ void dtx_hangover_control_fx( return; } + /*-------------------------------------------------------------------* * td_cng_enc_init_fx() * @@ -1491,6 +1517,7 @@ void td_cng_enc_init_fx( const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/ const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ ) +#ifndef HARM_DTX { hTdCngEnc->cng_seed = RANDOM_INITSEED; @@ -1580,8 +1607,8 @@ void td_cng_enc_init_ivas_fx( const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/ const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ ) +#endif { - hTdCngEnc->cng_seed = RANDOM_INITSEED; move16(); hTdCngEnc->cng_ener_seed = RANDOM_INITSEED; @@ -1672,6 +1699,7 @@ void td_cng_enc_init_ivas_fx( return; } + /*-------------------------------------------------------------------* * dtx_enc_init_fx() * @@ -1734,5 +1762,6 @@ void dtx_enc_init_fx( move16(); } } + return; } diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 7c29b4e06..018efdedb 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -686,6 +686,9 @@ ivas_error init_encoder_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } +#ifdef HARM_DTX + td_cng_enc_init_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); +#else IF( st->element_mode == EVS_MONO ) { td_cng_enc_init_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); @@ -694,6 +697,7 @@ ivas_error init_encoder_fx( { td_cng_enc_init_ivas_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); } +#endif } ELSE { diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 38c5abd23..a80638b41 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -50,15 +50,13 @@ #define SCE_SMC_THR 16000 -static void calculate_energy_buffer_ivas_fx( CPE_ENC_HANDLE hCPE, Word32 enerBuffer_dft[], const Word16 no_channels, const Word32 input_Fs, Word16 enerBuffer_dft_e[] ); - /*-------------------------------------------------------------------* - * pre_proc_front_ivas() - * - * Front Pre-processing for IVAS - * (resampling, spectral analysis, LP analysis, VAD, OL pitch calculation, classification) + * Local function prototypes *--------------------------------------------------------------------*/ -static Word16 get_zero_flag( Word32 arr[], Word16 len ) + +static void calculate_energy_buffer_ivas_fx( CPE_ENC_HANDLE hCPE, Word32 enerBuffer_dft[], const Word16 no_channels, const Word32 input_Fs, Word16 enerBuffer_dft_e[] ); + +static Word16 get_zero_flag( const Word32 arr[], const Word16 len ) { FOR( Word16 j = 0; j < len; j++ ) { @@ -70,6 +68,14 @@ static Word16 get_zero_flag( Word32 arr[], Word16 len ) return 0; } + +/*-------------------------------------------------------------------* + * pre_proc_front_ivas() + * + * Front Pre-processing for IVAS + * (resampling, spectral analysis, LP analysis, VAD, OL pitch calculation, classification) + *--------------------------------------------------------------------*/ + ivas_error pre_proc_front_ivas_fx( SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ @@ -131,15 +137,6 @@ ivas_error pre_proc_front_ivas_fx( ) { Encoder_State *st; - IF( hSCE != NULL ) - { - st = hSCE->hCoreCoder[n]; - } - ELSE - { - st = hCPE->hCoreCoder[n]; - } - Word16 q_tmpN_LR[CPE_CHANNELS]; Word16 q_tmpE_LR[CPE_CHANNELS]; Word16 q_tmpN; @@ -165,22 +162,23 @@ ivas_error pre_proc_front_ivas_fx( Word16 old_pitch1; /* previous frame OL pitch[1] @12.8 kHz */ Word16 LR_localVAD; ivas_error error; - - push_wmops( "pre_proc_front" ); - Word16 *signal_in_fx; Word32 *signal32_in_fx; Word16 *inp_12k8_fx, *new_inp_12k8_fx; /* pointers to current frame and new data */ CLDFB_SCALE_FACTOR cldfbScale; +#ifdef HARM_PREPROC + Word16 temp1F_icatdmResampBuf_fx[L_FILT_MAX]; /* temp buffers for ICA TDM resamplers */ + Word16 mem_decim_dummy_fx[2 * L_FILT_MAX]; /* dummy decimation filter memory */ +#else Word16 *temp1F_icatdmResampBuf_fx; Word16 *mem_decim_dummy_fx; /* dummy decimation filter memory */ +#endif Word32 tmpF_fx[STEREO_DFT_BAND_MAX]; Word32 *res_cod_SNR_M_fx; Word16 snr_sum_he_fx; /* HE SAD parameters */ Word16 new_inp_out_size; Word16 Q_new_inp; Word16 mem_decim_size; - Word16 dummy_fx; Word16 ncharX_fx; Word16 ncharX_LR_fx; /* noise character for sp/mus classifier */ @@ -218,55 +216,21 @@ ivas_error pre_proc_front_ivas_fx( Word32 *in_buff_temp; Word16 in_q_temp; #endif - +#ifndef HARM_PREPROC mem_decim_dummy_fx = (Word16 *) malloc( 90 * sizeof( Word16 * ) ); temp1F_icatdmResampBuf_fx = (Word16 *) malloc( 45 * sizeof( Word16 * ) ); set16_fx( fft_buff_fx, 0, 512 ); - - Word16 Q_min = add( sub( 15, st->exp_old_inp_12k8 ), norm_arr( st->old_inp_12k8_fx, L_INP_MEM ) ); - Word16 input_frame_full = shl( input_frame, 1 ); //(old frame input length + new frame input length) - Q_min = s_min( Q_min, sub( add( getScaleFactor32( st->input32_fx - input_frame, input_frame_full ), st->q_inp32 ), 16 ) ); - Q_min = s_max( -2, Q_min ); - Copy_Scale_sig_32_16( st->input32_fx - input_frame, st->input_fx - input_frame, input_frame_full, sub( Q_min, st->q_inp32 ) ); // Q_min - st->q_inp = Q_min; - move16(); - st->q_old_inp = Q_min; - move16(); - -#ifdef DEBUG_MODE_INFO - IF( hSCE != NULL ) - { - in_buff_temp = hSCE->hCoreCoder[n]->input32_fx; - in_q_temp = hSCE->hCoreCoder[n]->q_inp32; - } - ELSE - { - in_buff_temp = hCPE->hCoreCoder[n]->input32_fx; - in_q_temp = hCPE->hCoreCoder[n]->q_inp32; - } -#endif - - -#ifdef DEBUG_MODE_INFO - if ( !( hCPE != NULL && hCPE->hStereoTD != NULL && ch_idx > 0 ) ) - { - /* for TD stereo only write out first channel. The existence of a second channel can vary, this is just easier to handle */ - int16_t tmpF[L_FRAME48k]; - for ( int16_t isample = 0; isample < input_frame; isample++ ) - { - tmpF[isample] = (int16_t) ( (float) in_buff_temp[isample - NS2SA( st->input_Fs, ACELP_LOOK_NS )] / ( (float) ( 1 << in_q_temp ) ) ); - } - dbgwrite( &tmpF, sizeof( int16_t ), input_frame, 1, strcat( fname( debug_dir, "ivas_input_dmx", 0, ch_idx + 1, ENC ), ".pcm" ) ); - } #endif - + Word16 Q_min; + Word16 input_frame_full; +#ifndef HARM_PREPROC FOR( Word16 k = 0; k < CLDFB_NO_COL_MAX; k++ ) { set32_fx( realBuffer_fx[k], 0, CLDFB_NO_CHANNELS_MAX ); set32_fx( imagBuffer_fx[k], 0, CLDFB_NO_CHANNELS_MAX ); } +#endif Word16 sf_energySum[CLDFB_NO_CHANNELS_MAX]; - Word16 Q_inp_const = -1; move16(); Word16 headroom = 0, preemp_len = 0, inp_max = 0; @@ -276,6 +240,7 @@ ivas_error pre_proc_front_ivas_fx( Word16 *preemp_start_idx = NULL; Word32 sig_out[960], max_32; + push_wmops( "pre_proc_front" ); /*------------------------------------------------------------------* * Initialization *------------------------------------------------------------------*/ @@ -283,8 +248,8 @@ ivas_error pre_proc_front_ivas_fx( error = IVAS_ERR_OK; move32(); - cldfbScale.lb_scale = 31; - cldfbScale.hb_scale = 31; + cldfbScale.lb_scale = Q31; + cldfbScale.hb_scale = Q31; move16(); move16(); @@ -297,12 +262,6 @@ ivas_error pre_proc_front_ivas_fx( LR_localVAD = 0; move16(); - IF( st->cldfbAnaEnc != NULL ) - { - scale_sig32( st->cldfbAnaEnc->cldfb_state_fx, sub( sub( st->cldfbAnaEnc->p_filter_length, st->cldfbAnaEnc->no_channels ), st->cldfbAnaEnc->zeros ), sub( Q11, st->cldfbAnaEnc->Q_cldfb_state ) ); /* Q11 */ - st->cldfbAnaEnc->Q_cldfb_state = Q11; - move16(); - } IF( hSCE != NULL ) { @@ -413,6 +372,16 @@ ivas_error pre_proc_front_ivas_fx( move16(); } + Q_min = add( sub( 15, st->exp_old_inp_12k8 ), norm_arr( st->old_inp_12k8_fx, L_INP_MEM ) ); + input_frame_full = shl( input_frame, 1 ); //(old frame input length + new frame input length) + Q_min = s_min( Q_min, sub( add( getScaleFactor32( st->input32_fx - input_frame, input_frame_full ), st->q_inp32 ), 16 ) ); + Q_min = s_max( -2, Q_min ); + Copy_Scale_sig_32_16( st->input32_fx - input_frame, st->input_fx - input_frame, input_frame_full, sub( Q_min, st->q_inp32 ) ); // Q_min + st->q_inp = Q_min; + move16(); + st->q_old_inp = Q_min; + move16(); + L_look = L_LOOK_12k8; /* lookahead at 12.8kHz */ move16(); @@ -448,6 +417,13 @@ ivas_error pre_proc_front_ivas_fx( last_core_orig = st->last_core; /* Q0 */ move16(); + IF( st->cldfbAnaEnc != NULL ) + { + scale_sig32( st->cldfbAnaEnc->cldfb_state_fx, sub( sub( st->cldfbAnaEnc->p_filter_length, st->cldfbAnaEnc->no_channels ), st->cldfbAnaEnc->zeros ), sub( Q11, st->cldfbAnaEnc->Q_cldfb_state ) ); /* Q11 */ + st->cldfbAnaEnc->Q_cldfb_state = Q11; + move16(); + } + /*--------------------------------------------------------------* * energy analysis *---------------------------------------------------------------*/ @@ -490,6 +466,7 @@ ivas_error pre_proc_front_ivas_fx( * Change the sampling frequency to 12.8 kHz * (if not available from downsampled DMX) *----------------------------------------------------------------*/ + Scale_sig( st->mem_decim_fx_q_inp, 2 * L_FILT_MAX, sub( st->q_inp, st->mem_q ) ); /* st->q_inp */ test(); @@ -501,7 +478,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); Copy( st->mem_decim_fx_q_inp, mem_decim_dummy_fx, 2 * L_FILT_MAX ); /* Q(-1) */ set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX ); - new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size ); /* st->q_inp */ + new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size ); /* st->q_inp */ Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ } ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_MDCT ) ) @@ -765,16 +742,6 @@ ivas_error pre_proc_front_ivas_fx( st->vad_flag = wb_vad_ivas_fx( st, fr_bands_fx, fr_bands_fx_q, &i, &i, &i, &snr_sum_he_fx, &localVAD_HE_SAD, &( st->flag_noisy_speech_snr ), NULL, NULL, -MAX_16, -MAX_16 ); //-100000f == max 16bit float move16(); -#ifdef DEBUG_FORCE_DIR - if ( st->force_dir[0] != '\0' ) - { - dbgread( &st->vad_flag, sizeof( int16_t ), 1, fname( st->force_dir, "force_vad_flag.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &st->vad_flag, sizeof( int16_t ), 1, 1, "res/force_vad_flag.enf" ); - } -#endif test(); IF( EQ_16( force_front_vad, 1 ) || EQ_16( front_vad_flag, 1 ) ) @@ -869,18 +836,6 @@ ivas_error pre_proc_front_ivas_fx( move16(); } -#ifdef DEBUG_FORCE_DIR - if ( st->force_dir[0] != '\0' ) - { - dbgread( &st->bwidth, sizeof( int16_t ), 1, fname( st->force_dir, "force_bwidth.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &st->bwidth, sizeof( int16_t ), 1, 1, "res/force_bwidth.enf" ); - } -#endif - - /*----------------------------------------------------------------* * Noise energy down-ward update and total noise energy estimation * Long-term energies and relative frame energy updates @@ -907,6 +862,7 @@ ivas_error pre_proc_front_ivas_fx( /*----------------------------------------------------------------* * FD-CNG Noise Estimator *----------------------------------------------------------------*/ + IF( st->hFdCngEnc != NULL ) { resetFdCngEnc_fx( st ); @@ -958,6 +914,7 @@ ivas_error pre_proc_front_ivas_fx( /*-----------------------------------------------------------------* * Select SID or FRAME_NO_DATA frame if DTX enabled *-----------------------------------------------------------------*/ + test(); test(); if ( hCPE != NULL && NE_16( element_mode, IVAS_CPE_DFT ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) @@ -976,7 +933,11 @@ ivas_error pre_proc_front_ivas_fx( move16(); } +#ifdef HARM_DTX + dtx_fx( st, last_ivas_total_brate, ivas_total_brate, *vad_flag_dtx, inp_12k8_fx, *Q_new ); +#else dtx_ivas_fx( st, last_ivas_total_brate, ivas_total_brate, *vad_flag_dtx, inp_12k8_fx, *Q_new ); +#endif test(); test(); @@ -990,6 +951,7 @@ ivas_error pre_proc_front_ivas_fx( /*----------------------------------------------------------------* * Adjust FD-CNG Noise Estimator *----------------------------------------------------------------*/ + test(); test(); test(); @@ -1006,7 +968,9 @@ ivas_error pre_proc_front_ivas_fx( { total_brate = imult3216( FRAMES_PER_SEC, st->bits_frame_nominal ); /* Q0 */ } + configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), total_brate ); + IF( hCPE != NULL ) { st->hFdCngEnc->hFdCngCom->CngBitrate = L_sub( hCPE->element_brate, 1 ); /* Q0 */ @@ -1063,6 +1027,7 @@ ivas_error pre_proc_front_ivas_fx( /*----------------------------------------------------------------* * LP analysis *----------------------------------------------------------------*/ + Word16 stab_fac_fx; Word16 Q_r[2]; set16_fx( Q_r, 0, 2 ); @@ -1111,6 +1076,7 @@ ivas_error pre_proc_front_ivas_fx( * Comparison of the LP coefficents to determine if it is possible * to reuse the primary channel LP coefficients in the secondary channel *----------------------------------------------------------------*/ + Word32 speech_buff[L_FRAME + M]; Copy_Scale_sig_16_32_DEPREC( inp_12k8_fx - M, speech_buff, L_FRAME + M, Q12 ); /* Q_new + 12 */ hCPE->hStereoTD->tdm_lp_reuse_flag = tdm_lp_comparison_fx( hCPE->hStereoTD, hCPE->hStereoClassif, st, &speech_buff[0], tdm_A_PCh_fx, A_fx, M, tdm_lsp_new_PCh_fx, lsp_new_fx, L_FRAME, L_sub( element_brate, imult3216( FRAMES_PER_SEC, nb_bits_metadata ) ), add( *Q_new, 12 ) ); /* Q0 */ @@ -1212,6 +1178,7 @@ ivas_error pre_proc_front_ivas_fx( /*------------------------------------------------------------------* * Update estimated noise energy and voicing cut-off frequency *-----------------------------------------------------------------*/ + Word16 scale = s_min( Q31, add( st->hNoiseEst->ave_enr_q, s_min( L_norm_arr( st->hNoiseEst->ave_enr_fx, NB_BANDS ), L_norm_arr( st->hNoiseEst->ave_enr2_fx, NB_BANDS ) ) ) ); scale = s_min( scale, add( q_tmpE, L_norm_arr( tmpE_fx, NB_BANDS ) ) ); scale = sub( scale, 1 ); // guard bits @@ -1281,6 +1248,7 @@ ivas_error pre_proc_front_ivas_fx( /*------------------------------------------------------------------* * Update parameters used in the VAD and DTX *-----------------------------------------------------------------*/ + vad_param_updt_fx( st, old_pitch1, corr_shift_fx, corr_shift_fx, A_fx, NULL, 1 ); test(); @@ -1288,6 +1256,7 @@ ivas_error pre_proc_front_ivas_fx( { vad_param_updt_fx( st, old_pitch1, corr_shiftL_fx, corr_shiftR_fx, A_fx, &hCPE->hFrontVad[0], CPE_CHANNELS ); } + /*-----------------------------------------------------------------* * Find spectral tilt * UC and VC frame selection @@ -1306,20 +1275,6 @@ ivas_error pre_proc_front_ivas_fx( &flag_spitch, last_core_orig, hStereoClassif, *Q_new /*q_inp_12k8*/, fr_bands_fx_q ); // Q0 Copy_Scale_sig_16_32_no_sat( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) ); -#ifdef DEBUG_FORCE_DIR - if ( st->force_dir[0] != '\0' ) - { - dbgread( &st->coder_type, sizeof( int16_t ), 1, fname( st->force_dir, "force_coder_type.enf", -1, -1, -1 ) ); - dbgread( &st->coder_type_raw, sizeof( int16_t ), 1, fname( st->force_dir, "force_coder_type_raw.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &st->coder_type, sizeof( int16_t ), 1, 1, "res/force_coder_type.enf" ); - dbgwrite( &st->coder_type_raw, sizeof( int16_t ), 1, 1, "res/force_coder_type_raw.enf" ); - } -#endif - - /*-----------------------------------------------------------------* * channel aware mode configuration * *-----------------------------------------------------------------*/ @@ -1348,6 +1303,7 @@ ivas_error pre_proc_front_ivas_fx( /*-----------------------------------------------------------------* * Collect stereo classifier features *-----------------------------------------------------------------*/ + IF( hStereoClassif != NULL ) { Word16 max_e_Etot; @@ -1362,6 +1318,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); move16(); move16(); + stereo_classifier_features_ivas_fx( hStereoClassif, st->idchan, element_mode, localVAD_HE_SAD, lsf_new_fx, epsP_fx, st->pitch, st->voicing_fx, *cor_map_sum_fx, non_staX_fx, sp_div_fx, st->clas, sub( 31, *epsP_fx_q ), ( 31 - Q8 ) /* exp of cor_map_sum */, ( 31 - Q20 ) /* exp of non_staX_fx */, sub( 15, q_sp_div ) ); @@ -1378,17 +1335,6 @@ ivas_error pre_proc_front_ivas_fx( smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, localVAD_HE_SAD, extract_h( Etot_fx ), lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, PS_fx, non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, *epsP_fx_q, hSpMusClas->past_PS_Q ); /* Q0 */ -#ifdef DEBUG_FORCE_DIR - if ( st->force_dir[0] != '\0' ) - { - dbgread( &smc_dec, sizeof( int16_t ), 1, fname( st->force_dir, "force_smc_dec_loc1.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/force_smc_dec_loc1.enf" ); - } -#endif - #ifdef DEBUGGING if ( st->idchan == 0 ) { @@ -1436,6 +1382,7 @@ ivas_error pre_proc_front_ivas_fx( st->GSC_IVAS_mode = 0; move16(); + test(); IF( EQ_16( st->idchan, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) { @@ -1492,6 +1439,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); st->hTcxEnc->spectrum_e[1] = 16; move16(); + IF( flag_16k_smc ) { Word16 Q_old_inp_16k = -1; @@ -1525,15 +1473,14 @@ ivas_error pre_proc_front_ivas_fx( Word16 Q_old_inp_12k8 = *Q_new; move16(); + /* Compute core-coder buffers at internal sampling rate */ - error = ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, - A_fx, Aw_fx, - epsP_fx, - lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new ); + error = ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new ); IF( NE_32( error, IVAS_ERR_OK ) ) { return error; } + *epsP_fx_q = add( Q_r[0], 1 ); move16(); @@ -1594,23 +1541,6 @@ ivas_error pre_proc_front_ivas_fx( ivas_smc_mode_selection_fx( st, element_brate, smc_dec, *relE_fx, extract_h( Etot_fx ), attack_flag, inp_12k8_fx, *Q_new, S_map_fx, flag_spitch ); } -#ifdef DEBUG_FORCE_DIR - if ( st->force_dir[0] != '\0' ) - { - dbgread( &smc_dec, sizeof( int16_t ), 1, fname( st->force_dir, "force_smc_dec_loc2.enf", -1, -1, -1 ) ); - dbgread( &st->sp_aud_decision0, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision0.enf", -1, -1, -1 ) ); - dbgread( &st->sp_aud_decision1, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision1.enf", -1, -1, -1 ) ); - dbgread( &st->sp_aud_decision2, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision2.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/force_smc_dec_loc2.enf" ); - dbgwrite( &st->sp_aud_decision0, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision0.enf" ); - dbgwrite( &st->sp_aud_decision1, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision1.enf" ); - dbgwrite( &st->sp_aud_decision2, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision2.enf" ); - } -#endif - /*----------------------------------------------------------------* * Final VAD correction (when HE-SAD is used instead of the normal VAD, * rewrite the VAD flag by VAD flag with DTX hangover for further processing) @@ -1626,26 +1556,30 @@ ivas_error pre_proc_front_ivas_fx( /*-----------------------------------------------------------------* * Update old input signal buffer *-----------------------------------------------------------------*/ + shift = getScaleFactor16( &old_inp_12k8_fx[L_FRAME], L_INP_MEM ); Copy_Scale_sig( &old_inp_12k8_fx[L_FRAME], st->old_inp_12k8_fx, L_INP_MEM, shift ); /* Q_new + shift */ st->exp_old_inp_12k8 = sub( Q15, add( *Q_new, shift ) ); move16(); - *Q_new = sub( *Q_new, Q_inp_const ); // ivas_core_enc will assume inp signal (12k8 and 16k) in Q_new - 1 move16(); +#ifndef HARM_PREPROC free( mem_decim_dummy_fx ); free( temp1F_icatdmResampBuf_fx ); +#endif pop_wmops(); return error; } + /*-------------------------------------------------------------------* * calculate_energy_buffer() * * calculate DFT-based energies *--------------------------------------------------------------------*/ + static void calculate_energy_buffer_ivas_fx( CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ Word32 enerBuffer_dft_fx[], /* o : energy buffer() exp(enerBuffer_dft_e)*/ @@ -1715,5 +1649,6 @@ static void calculate_energy_buffer_ivas_fx( enerBuffer_dft_e[i] = 0; move16(); } + return; } diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index f58f48e97..642e5c5f8 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -599,7 +599,11 @@ ivas_error front_vad_spar_fx( corr_shift_fx = correlation_shift_fx( extract_h( hFrontVad->hNoiseEst->totalNoise_32fx ) ); /* Q15 */ +#ifdef HARM_DTX + dtx_fx( st, hEncoderConfig->last_ivas_total_brate, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 ); +#else dtx_ivas_fx( st, hEncoderConfig->last_ivas_total_brate, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 ); +#endif /* linear prediction analysis */ alw_pitch_lag_12k8[0] = st->old_pitch_la; /* Q0 */ diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 107fb9681..2c8d21593 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -385,7 +385,11 @@ ivas_error stereo_memory_enc_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } +#ifdef HARM_DTX + td_cng_enc_init_fx( hCPE->hCoreCoder[0]->hTdCngEnc, hCPE->hCoreCoder[0]->Opt_DTX_ON, hCPE->hCoreCoder[0]->max_bwidth ); +#else td_cng_enc_init_ivas_fx( hCPE->hCoreCoder[0]->hTdCngEnc, hCPE->hCoreCoder[0]->Opt_DTX_ON, hCPE->hCoreCoder[0]->max_bwidth ); +#endif } /* allocate TCA data structure */ diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 3b5892975..eba46d645 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -325,17 +325,23 @@ void pre_proc_fx( *----------------------------------------------------------------*/ resetFdCngEnc_fx( st ); + perform_noise_estimation_enc_fx( st->band_energies, st->band_energies_exp, enerBuffer, enerBuffer_exp, st->hFdCngEnc ); /*-----------------------------------------------------------------* * Select SID or FRAME_NO_DATA frame if DTX enabled *-----------------------------------------------------------------*/ +#ifdef HARM_DTX + dtx_fx( st, -1, -1, vad_flag_dtx, inp_12k8, *Q_new ); +#else dtx_fx( st, vad_flag_dtx, inp_12k8, *Q_new ); +#endif /*----------------------------------------------------------------* * Adjust FD-CNG Noise Estimator *----------------------------------------------------------------*/ + test(); IF( ( NE_32( st->last_total_brate, st->total_brate ) ) || ( NE_16( st->last_bwidth, st->bwidth ) ) ) { @@ -349,6 +355,7 @@ void pre_proc_fx( } configureFdCngEnc_fx( st->hFdCngEnc, st->bwidth, L_tmp ); } + test(); IF( st->hFdCngEnc != NULL && st->Opt_DTX_ON ) { @@ -493,6 +500,7 @@ void pre_proc_fx( /*------------------------------------------------------------------* * Update parameters used in the VAD and DTX *-----------------------------------------------------------------*/ + vad_param_updt_fx( st, old_pitch1, corr_shift, corr_shift, A, NULL, 1 ); /*-----------------------------------------------------------------* @@ -506,9 +514,10 @@ void pre_proc_fx( st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, corr_shift, relE, *Etot, hp_E, *Q_new, &flag_spitch, *shift, last_core_orig ); - /*----------------------------------------------------------------* + /*-----------------------------------------------------------------* * channel aware mode configuration * *-----------------------------------------------------------------*/ + test(); test(); IF( !st->Opt_RF_ON ) @@ -562,6 +571,7 @@ void pre_proc_fx( hSC_VBR->Local_VAD = st->localVAD; move16(); } + /*----------------------------------------------------------------* * Speech/music classification * AC frame selection @@ -769,6 +779,7 @@ void pre_proc_fx( /*---------------------------------------------------------------------* * Decision matrix (selection of technologies) *---------------------------------------------------------------------*/ + IF( EQ_16( st->codec_mode, MODE1 ) ) { diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 06630ab57..727c60c73 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -138,6 +138,7 @@ Word16 correlation_shift_fx( ); void dtx_fx( +#ifndef HARM_DTX Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 vad, /* i : vad flag Q0*/ const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ @@ -145,6 +146,7 @@ void dtx_fx( ); void dtx_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ @@ -1175,12 +1177,13 @@ void td_cng_enc_init_fx( const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ ); +#ifndef HARM_DTX void td_cng_enc_init_ivas_fx( TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */ const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/ const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ ); - +#endif void dtx_enc_init_fx( Encoder_State *st, /* i : Encoder state handle */ const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate Q0*/ -- GitLab From 30fa8df764446e101539e555fa82479aad21b05a Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 11:43:17 +0100 Subject: [PATCH 02/10] step 2 (dtx_hangover_addition_fx) --- lib_enc/amr_wb_enc_fx.c | 4 ++++ lib_enc/ivas_core_pre_proc_front_fx.c | 9 +++++++-- lib_enc/ivas_front_vad_fx.c | 5 +++++ lib_enc/pre_proc_fx.c | 4 ++++ lib_enc/prot_fx_enc.h | 2 ++ lib_enc/vad_fx.c | 19 +++++++++++++++++-- 6 files changed, 39 insertions(+), 4 deletions(-) diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index e5da3ed7f..bd708c2c0 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -310,7 +310,11 @@ void amr_wb_enc_fx( } /* apply DTX hangover for CNG analysis */ +#ifdef HARM_PREPROC + vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), 0, &vad_hover_flag, NULL, NULL, NULL ); +#else vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), 0, &vad_hover_flag, NULL, NULL ); +#endif /*-----------------------------------------------------------------* * Select SID or FRAME_NO_DATA frame if DTX enabled diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index a80638b41..8fbe9512b 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -479,7 +479,7 @@ ivas_error pre_proc_front_ivas_fx( Copy( st->mem_decim_fx_q_inp, mem_decim_dummy_fx, 2 * L_FILT_MAX ); /* Q(-1) */ set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX ); new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size ); /* st->q_inp */ - Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ + Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ } ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_MDCT ) ) { @@ -563,6 +563,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); st->mem_preemph_DFT_fx_q_inp = shl_sat( st->mem_preemph_DFT_fx_q_inp, sub( st->q_inp, st->mem_preemph_q ) ); /*st->q_inp*/ move16(); + test(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { @@ -757,7 +758,11 @@ ivas_error pre_proc_front_ivas_fx( test(); IF( ( hCPE != NULL && !( lr_vad_enabled && st->idchan == 0 ) ) || hSCE != NULL ) { +#ifdef HARM_PREPROC + *vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, extract_h( L_sub( st->lp_speech_32fx, st->lp_noise_32fx ) ), 0, vad_hover_flag, NULL, NULL, NULL ); /* Q0 */ +#else *vad_flag_dtx = ivas_dtx_hangover_addition_fx( st, st->vad_flag, extract_h( L_sub( st->lp_speech_32fx, st->lp_noise_32fx ) ), 0, vad_hover_flag, NULL, NULL, NULL ); /* Q0 */ +#endif move16(); } ELSE @@ -1475,7 +1480,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); /* Compute core-coder buffers at internal sampling rate */ - error = ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new ); + error = ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new ); IF( NE_32( error, IVAS_ERR_OK ) ) { return error; diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index 642e5c5f8..f16881b2f 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -286,7 +286,12 @@ ivas_error front_vad_fx( sts[1]->last_coder_type = sts[0]->last_coder_type; /* Q0 */ move16(); } + +#ifdef HARM_PREPROC + vad_flag_dtx[n] = dtx_hangover_addition_fx( sts[n], hFrontVad->hVAD->vad_flag, sub( hFrontVad->lp_speech_fx, hFrontVad->lp_noise_fx ), 0 /* <- no cldfb addition */, &vad_hover_flag[n], hFrontVad->hVAD, hFrontVad->hNoiseEst, &hFrontVads[n]->rem_dtx_ho ); /* Q0 */ +#else vad_flag_dtx[n] = ivas_dtx_hangover_addition_fx( sts[n], hFrontVad->hVAD->vad_flag, sub( hFrontVad->lp_speech_fx, hFrontVad->lp_noise_fx ), 0 /* <- no cldfb addition */, &vad_hover_flag[n], hFrontVad->hVAD, hFrontVad->hNoiseEst, &hFrontVads[n]->rem_dtx_ho ); /* Q0 */ +#endif move16(); if ( EQ_16( n_chan, 1 ) ) diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index eba46d645..930f784d6 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -282,7 +282,11 @@ void pre_proc_fx( } /* apply DTX hangover for CNG analysis */ +#ifdef HARM_PREPROC + vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), cldfb_addition, vad_hover_flag, hVAD, hNoiseEst, NULL ); +#else vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), cldfb_addition, vad_hover_flag, hVAD, hNoiseEst ); +#endif /*----------------------------------------------------------------* * NB/WB/SWB/FB bandwidth detector diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 727c60c73..3042d2ee6 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -156,6 +156,7 @@ void dtx_ivas_fx( ); Word16 dtx_hangover_addition_fx( +#ifndef HARM_PREPROC Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 vad_flag, /* i Q0 */ const Word16 lp_snr, /* i Q8 */ @@ -166,6 +167,7 @@ Word16 dtx_hangover_addition_fx( ); Word16 ivas_dtx_hangover_addition_fx( +#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 vad_flag, /* i Q0 */ const Word16 lp_snr, /* i Q8 */ diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 4335225ca..5278a7b07 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -229,6 +229,7 @@ static void sign_thr_snr_acc_fx( *-----------------------------------------------------------------*/ Word16 dtx_hangover_addition_fx( +#ifndef HARM_PREPROC Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 vad_flag, /* i Q0 */ const Word16 lp_snr, /* i Q8 */ @@ -425,6 +426,7 @@ Word16 dtx_hangover_addition_fx( return flag_dtx; } Word16 ivas_dtx_hangover_addition_fx( +#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 vad_flag, /* i Q0 */ const Word16 lp_snr, /* i Q8 */ @@ -548,6 +550,18 @@ Word16 ivas_dtx_hangover_addition_fx( move16(); /* float fix FIX_HO_TERMINATE */ /* Music hangover when music detected */ +#ifdef HARM_DTX + IF( st_fx->element_mode == EVS_MONO ) + { + if ( ( GT_16( hVAD->prim_act_he_fx, 31129 ) ) && ( GT_16( hNoiseEst->Etot_lp_fx, 40 * 256 ) ) && ( GT_16( hVAD->vad_prim_cnt_16, 14 ) ) && ( GT_16( hVAD->vad_flag_cnt_50, 48 ) ) ) /* 45 requires roughly > 95% flag activity */ + { + hVAD->hangover_cnt_music = 0; + move16(); + } + } + ELSE +#endif + { test(); test(); test(); @@ -556,6 +570,7 @@ Word16 ivas_dtx_hangover_addition_fx( hVAD->hangover_cnt_music = 0; move16(); } +} /* inside Music HO period */ test(); @@ -609,9 +624,7 @@ Word16 ivas_dtx_hangover_addition_fx( } } - test(); - IF( flag_dtx != 0 && st_fx->localVAD == 0 ) { *vad_hover_flag_ptr = 1; @@ -625,6 +638,8 @@ Word16 ivas_dtx_hangover_addition_fx( return flag_dtx; } + + /*-----------------------------------------------------------------* * wb_vad() * -- GitLab From 5c654a7bdb8507f3afe04f1ed8ef43a3f52a3a4c Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 11:51:02 +0100 Subject: [PATCH 03/10] clang-format --- lib_enc/ivas_core_pre_proc_front_fx.c | 2 +- lib_enc/vad_fx.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 8fbe9512b..bb4ad3c84 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -171,7 +171,7 @@ ivas_error pre_proc_front_ivas_fx( Word16 mem_decim_dummy_fx[2 * L_FILT_MAX]; /* dummy decimation filter memory */ #else Word16 *temp1F_icatdmResampBuf_fx; - Word16 *mem_decim_dummy_fx; /* dummy decimation filter memory */ + Word16 *mem_decim_dummy_fx; /* dummy decimation filter memory */ #endif Word32 tmpF_fx[STEREO_DFT_BAND_MAX]; Word32 *res_cod_SNR_M_fx; diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 5278a7b07..11bc79ee0 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -562,15 +562,15 @@ Word16 ivas_dtx_hangover_addition_fx( ELSE #endif { - test(); - test(); - test(); - if ( ( GT_16( hVAD->prim_act_he_fx, 32113 ) ) && ( GT_16( hNoiseEst->Etot_lp_fx, 40 * 256 ) ) && ( GT_16( hVAD->vad_prim_cnt_16, 14 ) ) && ( GT_16( hVAD->vad_flag_cnt_50, 48 ) ) ) /* 45 requires roughly > 95% flag activity */ - { - hVAD->hangover_cnt_music = 0; - move16(); + test(); + test(); + test(); + if ( ( GT_16( hVAD->prim_act_he_fx, 32113 ) ) && ( GT_16( hNoiseEst->Etot_lp_fx, 40 * 256 ) ) && ( GT_16( hVAD->vad_prim_cnt_16, 14 ) ) && ( GT_16( hVAD->vad_flag_cnt_50, 48 ) ) ) /* 45 requires roughly > 95% flag activity */ + { + hVAD->hangover_cnt_music = 0; + move16(); + } } -} /* inside Music HO period */ test(); -- GitLab From e02584652cf818e088e4b3ad1b35e616e428bf39 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 12:45:42 +0100 Subject: [PATCH 04/10] step 3 (StableHighPitchDetect_fx) --- lib_com/options.h | 3 +- lib_enc/amr_wb_enc_fx.c | 2 +- lib_enc/dtx_fx.c | 6 +-- lib_enc/init_enc_fx.c | 2 +- lib_enc/ivas_core_pre_proc_front_fx.c | 10 ++-- lib_enc/ivas_front_vad_fx.c | 7 ++- lib_enc/ivas_stereo_switching_enc_fx.c | 2 +- lib_enc/pitch_ol2_fx.c | 70 +++++++++++++++++++------- lib_enc/pre_proc_fx.c | 7 ++- lib_enc/prot_fx_enc.h | 9 +++- lib_enc/vad_fx.c | 5 +- 11 files changed, 88 insertions(+), 35 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 64addadef..8907db790 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -124,8 +124,7 @@ #define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ #define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ #define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ -#define HARM_DTX /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ -#define HARM_PREPROC +#define HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index bd708c2c0..195b36dc4 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -336,7 +336,7 @@ void amr_wb_enc_fx( move16(); } -#ifdef HARM_DTX +#ifdef HARM_PREPROC dtx_fx( st, -1, -1, vad_flag_dtx, inp, Q_new ); #else dtx_fx( st, vad_flag_dtx, inp, Q_new ); diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index 12c7fdbc6..c9b2f5d0a 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -63,7 +63,7 @@ static void update_SID_cnt_fx( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate, /* _ None */ /*==================================================================================*/ -#ifdef HARM_DTX +#ifdef HARM_PREPROC void dtx_fx( #else void dtx_ivas_fx( @@ -611,7 +611,7 @@ void dtx_ivas_fx( return; } -#ifndef HARM_DTX +#ifndef HARM_PREPROC /*==================================================================================*/ /* FUNCTION : dtx_fx() */ /*----------------------------------------------------------------------------------*/ @@ -1517,7 +1517,7 @@ void td_cng_enc_init_fx( const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/ const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ ) -#ifndef HARM_DTX +#ifndef HARM_PREPROC { hTdCngEnc->cng_seed = RANDOM_INITSEED; diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 018efdedb..07ae94937 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -686,7 +686,7 @@ ivas_error init_encoder_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } -#ifdef HARM_DTX +#ifdef HARM_PREPROC td_cng_enc_init_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); #else IF( st->element_mode == EVS_MONO ) diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index bb4ad3c84..c6d9d1d0b 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -773,7 +773,6 @@ ivas_error pre_proc_front_ivas_fx( *vad_flag_dtx = *vad_flag_dtx || st->vad_flag; /* Q0 */ move16(); - /* Determine hangover flag status based on LR localVAD and downmix localVAD */ test(); test(); @@ -830,7 +829,6 @@ ivas_error pre_proc_front_ivas_fx( set_bw_fx( element_mode, element_brate, st, MODE1 ); } - /* set the BW of the TD secondary channel in LRTD mode same as BW of the primary channel (only at higher bitrates) */ test(); test(); @@ -938,7 +936,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); } -#ifdef HARM_DTX +#ifdef HARM_PREPROC dtx_fx( st, last_ivas_total_brate, ivas_total_brate, *vad_flag_dtx, inp_12k8_fx, *Q_new ); #else dtx_ivas_fx( st, last_ivas_total_brate, ivas_total_brate, *vad_flag_dtx, inp_12k8_fx, *Q_new ); @@ -1134,6 +1132,7 @@ ivas_error pre_proc_front_ivas_fx( pitch_ol_ivas_fx( st->pitch, st->voicing_fx, &st->old_pitch, &st->old_corr_fx, corr_shift_fx, &st->old_thres_fx, &st->delta_pit, st->old_wsp2_fx, wsp_fx, st->mem_decim2_fx, *relE_fx, st->clas, st->input_bwidth, st->Opt_SC_VBR, Q_wsp ); + /* Updates for adaptive lag window memory */ st->old_pitch_la = st->pitch[2]; /* Q0 */ move16(); @@ -1147,8 +1146,13 @@ ivas_error pre_proc_front_ivas_fx( move16(); Copy_Scale_sig_32_16( st->Bin_E_fx, st->lgBin_E_fx, L_FFT / 2, sub( Q7, st->q_Bin_E ) ); /* Q7 */ + /* Detection of very short stable pitch period */ +#ifdef HARM_PREPROC + StableHighPitchDetect_fx( element_mode, &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, *q_old_wsp, st->lgBin_E_fx ); +#else StableHighPitchDetect_ivas_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, *q_old_wsp, st->lgBin_E_fx ); +#endif /* 1/4 pitch precision improvement */ IF( LE_32( element_brate, IVAS_32k ) ) diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index f16881b2f..f6e9978ef 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -604,7 +604,7 @@ ivas_error front_vad_spar_fx( corr_shift_fx = correlation_shift_fx( extract_h( hFrontVad->hNoiseEst->totalNoise_32fx ) ); /* Q15 */ -#ifdef HARM_DTX +#ifdef HARM_PREPROC dtx_fx( st, hEncoderConfig->last_ivas_total_brate, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 ); #else dtx_ivas_fx( st, hEncoderConfig->last_ivas_total_brate, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 ); @@ -692,7 +692,12 @@ ivas_error front_vad_spar_fx( st->old_pitch_la = st->pitch[2]; /* Q0 */ move16(); +#ifdef HARM_PREPROC + StableHighPitchDetect_fx( IVAS_SCE /* needs to be other than EVS_MONO */, &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, Q_wsp, st->lgBin_E_fx ); +#else StableHighPitchDetect_ivas_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, Q_wsp, st->lgBin_E_fx ); +#endif + IF( st->hSpMusClas != NULL ) { Word16 dummy_int; diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 2c8d21593..8507bc58c 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -385,7 +385,7 @@ ivas_error stereo_memory_enc_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } -#ifdef HARM_DTX +#ifdef HARM_PREPROC td_cng_enc_init_fx( hCPE->hCoreCoder[0]->hTdCngEnc, hCPE->hCoreCoder[0]->Opt_DTX_ON, hCPE->hCoreCoder[0]->max_bwidth ); #else td_cng_enc_init_ivas_fx( hCPE->hCoreCoder[0]->hTdCngEnc, hCPE->hCoreCoder[0]->Opt_DTX_ON, hCPE->hCoreCoder[0]->max_bwidth ); diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index f50677cf0..af01e8dbf 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -26,6 +26,7 @@ * The pitch is searched in the interval pitch period (MODE1 bit-rates) */ +#ifdef HARM_PREPROC + StableHighPitchDetect_fx( EVS_MONO, &flag_spitch, st->pitch, st->voicing_fx, wsp, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, + &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, *Q_new, st->lgBin_E_fx ); +#else StableHighPitchDetect_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, *Q_new, st->lgBin_E_fx ); +#endif /* 1/4 pitch precision improvement */ IF( LE_32( st->total_brate, ACELP_24k40 ) ) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 3042d2ee6..eddda1a67 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -138,7 +138,7 @@ Word16 correlation_shift_fx( ); void dtx_fx( -#ifndef HARM_DTX +#ifndef HARM_PREPROC Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 vad, /* i : vad flag Q0*/ const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ @@ -575,6 +575,9 @@ void speech_music_classif_fx( ); void StableHighPitchDetect_fx( +#ifdef HARM_PREPROC + const Word16 element_mode, /* i : element mode */ +#endif Word16 *flag_spitch, /* o : flag to indicate very short stable pitch*/ Word16 pitch[], /* i/o: OL pitch buffer */ const Word16 voicing[], /* i : OL pitch gains */ @@ -588,6 +591,7 @@ void StableHighPitchDetect_fx( Word32 *energy_sm, /* i/o: smoothed energy around pitch frequency */ Word16 Q_new, Word16 EspecdB[] ); +#ifndef HARM_PREPROC void StableHighPitchDetect_ivas_fx( Word16 *flag_spitch, /* o : flag to indicate very short stable pitch */ @@ -604,6 +608,7 @@ void StableHighPitchDetect_ivas_fx( Word16 Q_new, Word16 EspecdB[] /* Q7 */ ); +#endif void swb_bwe_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ @@ -1179,7 +1184,7 @@ void td_cng_enc_init_fx( const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ ); -#ifndef HARM_DTX +#ifndef HARM_PREPROC void td_cng_enc_init_ivas_fx( TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */ const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/ diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 11bc79ee0..8a37d87ba 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -550,7 +550,10 @@ Word16 ivas_dtx_hangover_addition_fx( move16(); /* float fix FIX_HO_TERMINATE */ /* Music hangover when music detected */ -#ifdef HARM_DTX +#ifdef HARM_PREPROC + test(); + test(); + test(); IF( st_fx->element_mode == EVS_MONO ) { if ( ( GT_16( hVAD->prim_act_he_fx, 31129 ) ) && ( GT_16( hNoiseEst->Etot_lp_fx, 40 * 256 ) ) && ( GT_16( hVAD->vad_prim_cnt_16, 14 ) ) && ( GT_16( hVAD->vad_flag_cnt_50, 48 ) ) ) /* 45 requires roughly > 95% flag activity */ -- GitLab From ad92c9b318dbc9ea124eada32875b8e1796653cc Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 17:36:20 +0100 Subject: [PATCH 05/10] fix dtx_fx() --- lib_enc/dtx_fx.c | 25 +++++++++++++++++++++++++ lib_enc/prot_fx_enc.h | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index c9b2f5d0a..b80944b5f 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -82,6 +82,19 @@ void dtx_ivas_fx( TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; Word16 last_br_cng_flag, last_br_flag, br_dtx_flag; Word32 total_brate_ref; +#ifdef HARM_PREPROC + Word16 flag_lp_noise; + + IF( st_fx->element_mode == EVS_MONO ) + { + flag_lp_noise = LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ); + } + ELSE + { + flag_lp_noise = LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 ); + } + move16(); +#endif total_brate_ref = st_fx->total_brate; move32(); @@ -98,7 +111,11 @@ void dtx_ivas_fx( test(); test(); test(); +#ifdef HARM_PREPROC + last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_EVS ) || flag_lp_noise || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_IVAS ) ); +#else last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_EVS ) || LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_IVAS ) ); +#endif test(); test(); @@ -106,7 +123,11 @@ void dtx_ivas_fx( test(); last_br_flag = ( st_fx->element_mode == EVS_MONO && LE_32( st_fx->last_total_brate, MAX_BRATE_DTX_EVS ) ) || ( st_fx->element_mode != EVS_MONO && LE_32( last_ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || +#ifdef HARM_PREPROC + flag_lp_noise; +#else LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 ); +#endif } /* Initialization */ @@ -221,7 +242,11 @@ void dtx_ivas_fx( test(); br_dtx_flag = ( ( st_fx->element_mode == EVS_MONO ) && LE_32( st_fx->total_brate, MAX_BRATE_DTX_EVS ) ) || ( ( st_fx->element_mode != EVS_MONO ) && LE_32( ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || +#ifdef HARM_PREPROC + flag_lp_noise; +#else LT_16( extract_h( st_fx->lp_noise_32fx ), DTX_THR * 256 ); +#endif } test(); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index eddda1a67..9802f4f75 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -152,7 +152,7 @@ void dtx_ivas_fx( const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ const Word16 vad, /* i : vad flag for DTX Q0*/ const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ - Word16 Q_speech /* i : Q factor for speech */ + const Word16 Q_speech /* i : Q factor for speech */ ); Word16 dtx_hangover_addition_fx( -- GitLab From 5b7c2a8f80d52b61967d5b8d12e50b3298aa3f4f Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 19:10:50 +0100 Subject: [PATCH 06/10] fix EVS BE --- lib_enc/pitch_ol2_fx.c | 14 +++++++++++++- lib_enc/vad_fx.c | 7 +++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index af01e8dbf..b866091bc 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -489,7 +489,19 @@ void StableHighPitchDetect_ivas_fx( /* pitch_freq_point = (short)(L_FFT/(mult_fact*T_op[1])+0.5f);*/ Top = pitch[1]; move16(); - pitch_freq_point = idiv1616( L_FFT, Top ); /* Q0*/ +#ifdef HARM_PREPROC + IF( element_mode == EVS_MONO ) + { + exp = norm_s( Top ); + tmp = div_s( shl( 1, sub( 14, exp ) ), Top ); /*Q(29 - exp)*/ + L_tmp = L_mult0( tmp, L_FFT ); + pitch_freq_point = extract_h( L_add( L_shl( L_tmp, sub( exp, 13 ) ), 32768 ) ); /* Q0*/ + } + ELSE +#endif + { + pitch_freq_point = idiv1616( L_FFT, Top ); /* Q0*/ + } sum_energy = L_deposit_l( 0 ); FOR( i = 1; i < 2 * pitch_freq_point; i++ ) { diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 8a37d87ba..2e03bc59e 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -439,6 +439,7 @@ Word16 ivas_dtx_hangover_addition_fx( Word16 hangover_short_dtx; /* Q0 */ Word16 flag_dtx; /* Q0 */ Word16 tmp; /* Q0 */ + if ( hNoiseEst == NULL ) { hNoiseEst = st_fx->hNoiseEst; @@ -451,7 +452,6 @@ Word16 ivas_dtx_hangover_addition_fx( hVAD = st_fx->hVAD; } - flag_dtx = 0; move16(); @@ -486,7 +486,6 @@ Word16 ivas_dtx_hangover_addition_fx( } /* Only allow short HO if not sufficient active frames in clean speech*/ - tmp = 3; move16(); /* default for EVS*/ if ( EQ_16( st_fx->core, AMR_WB_CORE ) ) @@ -505,7 +504,7 @@ Word16 ivas_dtx_hangover_addition_fx( move16(); } - /* limit dtx hangover addition up to "tmp" frames in clean cond */ + /* limit dtx hangover addition up to "tmp" frames in clean cond */ IF( tmp != 0 ) { test(); @@ -519,13 +518,13 @@ Word16 ivas_dtx_hangover_addition_fx( } } - /* hangover adjustment from combined FFT+CLDFBVAD */ IF( NE_16( st_fx->core, AMR_WB_CORE ) ) { hangover_short_dtx = sub( hangover_short_dtx, cldfb_subtraction ); /*Q0*/ hangover_short_dtx = s_max( hangover_short_dtx, 0 ); } + IF( vad_flag != 0 ) /* Speech present */ { flag_dtx = 1; -- GitLab From 2a65dca10653a72092aa440590c804dc64c730a4 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 19:33:26 +0100 Subject: [PATCH 07/10] cleaning --- lib_enc/pitch_ol2_fx.c | 58 ++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index b866091bc..9a1a00ff0 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -519,7 +519,6 @@ void StableHighPitchDetect_ivas_fx( diff = L_mac0( L_negate( sum_energy ), EspecdB[pitch_freq_point], tmp ); /*sum_energy /= (2*pitch_freq_point-1);*/ - exp = norm_s( tmp ); tmp1 = div_s( shl( 1, sub( 14, exp ) ), tmp ); /*Q(29-exp)*/ L_tmp = Mult_32_16( sum_energy, tmp1 ); @@ -559,6 +558,7 @@ void StableHighPitchDetect_ivas_fx( { diff16 = round_fx_sat( L_shl_sat( diff, 25 ) ); } + test(); test(); IF( LT_32( *diff_sm, -1280 /*-10.0f Q7*/ ) && LT_32( *energy_sm, 4928 /*38.5f Q7*/ ) && LT_16( diff16, -26214 /*-.8f Q15*/ ) ) @@ -566,6 +566,7 @@ void StableHighPitchDetect_ivas_fx( *predecision_flag = 1; move16(); } + test(); test(); if ( GT_32( *diff_sm, 1280 /*10.0f Q7*/ ) && GT_32( *energy_sm, 10624 /*83.0f Q7*/ ) && GT_16( diff16, 16384 /*.5 Q15*/ ) ) @@ -595,6 +596,7 @@ void StableHighPitchDetect_ivas_fx( L_tmp = L_mac( L_tmp, *LF_EnergyRatio_sm, 30720 ); *LF_EnergyRatio_sm = round_fx( L_tmp ); move16(); + test(); if ( GT_16( *LF_EnergyRatio_sm, 4480 /*35.0f Q7*/ ) || GT_16( ratio, 6400 /*50.0f Q7*/ ) ) { @@ -649,43 +651,37 @@ void StableHighPitchDetect_ivas_fx( move16(); /* final short pitch detection */ +#ifdef HARM_PREPROC + *flag_spitch = 0; + move16(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( EQ_16( localVAD, 1 ) ) && ( EQ_16( *predecision_flag, 1 ) ) && + ( ( EQ_16( element_mode, EVS_MONO ) && GT_16( *voicing0_sm, 16384 ) && GT_16( *voicing0_sm, mult_r( *voicing_sm, 21299 ) ) ) || + ( NE_16( element_mode, EVS_MONO ) && GT_16( *voicing0_sm, 21299 /*.65f in Q15*/ ) && GT_16( *voicing0_sm, mult_r( *voicing_sm, 22938 /*.7f in Q15*/ ) ) ) ) ) +#else test(); test(); test(); *flag_spitch = 0; move16(); - -#ifdef HARM_PREPROC - IF( element_mode == EVS_MONO ) - { - IF( ( EQ_16( localVAD, 1 ) ) && ( EQ_16( *predecision_flag, 1 ) ) && - ( GT_16( *voicing0_sm, 16384 ) ) && ( GT_16( *voicing0_sm, mult_r( *voicing_sm, 21299 ) ) ) ) - { - *flag_spitch = 1; - move16(); - pitch[0] = Tp; - move16(); - pitch[1] = Tp; - move16(); - pitch[2] = Tp; - move16(); - } - } - ELSE + IF( ( EQ_16( localVAD, 1 ) ) && ( EQ_16( *predecision_flag, 1 ) ) && + ( GT_16( *voicing0_sm, 21299 /*.65f in Q15*/ ) ) && ( GT_16( *voicing0_sm, mult_r( *voicing_sm, 22938 /*.7f in Q15*/ ) ) ) ) #endif { - IF( ( EQ_16( localVAD, 1 ) ) && ( EQ_16( *predecision_flag, 1 ) ) && - ( GT_16( *voicing0_sm, 21299 /*.65f in Q15*/ ) ) && ( GT_16( *voicing0_sm, mult_r( *voicing_sm, 22938 /*.7f in Q15*/ ) ) ) ) - { - *flag_spitch = 1; - move16(); - pitch[0] = Tp; - move16(); - pitch[1] = Tp; - move16(); - pitch[2] = Tp; - move16(); - } + *flag_spitch = 1; + move16(); + pitch[0] = Tp; + move16(); + pitch[1] = Tp; + move16(); + pitch[2] = Tp; + move16(); } return; -- GitLab From a95a07684f16abbaaf104a3405a94b6ab4352ff2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 19:40:30 +0100 Subject: [PATCH 08/10] clang-format --- lib_enc/pitch_ol2_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index 9a1a00ff0..5b49c85b4 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -493,7 +493,7 @@ void StableHighPitchDetect_ivas_fx( IF( element_mode == EVS_MONO ) { exp = norm_s( Top ); - tmp = div_s( shl( 1, sub( 14, exp ) ), Top ); /*Q(29 - exp)*/ + tmp = div_s( shl( 1, sub( 14, exp ) ), Top ); /*Q(29 - exp)*/ L_tmp = L_mult0( tmp, L_FFT ); pitch_freq_point = extract_h( L_add( L_shl( L_tmp, sub( exp, 13 ) ), 32768 ) ); /* Q0*/ } -- GitLab From 7df0a90501e3be0d0477317b94999a98581cf4a8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 19:58:33 +0100 Subject: [PATCH 09/10] fix build --- lib_enc/dtx_fx.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index b80944b5f..b9ec0c872 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -85,15 +85,17 @@ void dtx_ivas_fx( #ifdef HARM_PREPROC Word16 flag_lp_noise; - IF( st_fx->element_mode == EVS_MONO ) - { - flag_lp_noise = LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ); - } - ELSE + flag_lp_noise = 0; + move16(); + test(); + test(); + test(); + IF( ( st_fx->element_mode == EVS_MONO && LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) ) || + ( st_fx->element_mode != EVS_MONO && LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 ) ) ) { - flag_lp_noise = LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 ); + flag_lp_noise = 1; + move16(); } - move16(); #endif total_brate_ref = st_fx->total_brate; -- GitLab From 9f78f55e851d83c17a0b72a41369f3d48a190c54 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jan 2026 09:39:44 +0100 Subject: [PATCH 10/10] fix build --- lib_com/ivas_prot_fx.h | 2 +- lib_enc/ivas_core_pre_proc_front_fx.c | 6 +----- lib_enc/ivas_cpe_enc_fx.c | 11 +++-------- lib_enc/ivas_ism_enc_fx.c | 11 +++-------- lib_enc/ivas_sce_enc_fx.c | 12 ++++-------- 5 files changed, 12 insertions(+), 30 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 7b1a94c61..ec26cdf06 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -6005,7 +6005,7 @@ ivas_error pre_proc_front_ivas_fx( const Word16 lf_E_LR_fx_q, /* i : Q factor of per bin spectrum energy in lf, LR channels */ const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/ Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN band_energies_LR_fx_q*/ - const Word16 band_energies_LR_fx_q, /* o : Q facttors of energy in critical bands without minimum noise floor */ + const Word16 band_energies_LR_fx_q, /* o : Q factors of energy in critical bands without minimum noise floor */ const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/ const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/ diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 88d57bdaa..d17b4d358 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -120,7 +120,7 @@ ivas_error pre_proc_front_ivas_fx( const Word16 lf_E_LR_fx_q, /* i : Q factor of per bin spectrum energy in lf, LR channels */ const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/ Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN band_energies_LR_fx_q*/ - const Word16 band_energies_LR_fx_q, /* o : Q facttors of energy in critical bands without minimum noise floor */ + const Word16 band_energies_LR_fx_q, /* o : Q factors of energy in critical bands without minimum noise floor */ const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/ const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/ @@ -208,10 +208,6 @@ ivas_error pre_proc_front_ivas_fx( Word16 Qfact_PS, q_lf_E_fx; Word16 enerBuffer_fx_exp_buf[CLDFB_NO_CHANNELS_MAX]; Word32 bckr_temp[NB_BANDS]; -#ifdef DEBUG_MODE_INFO - Word32 *in_buff_temp; - Word16 in_q_temp; -#endif #ifndef HARM_PREPROC mem_decim_dummy_fx = (Word16 *) malloc( 90 * sizeof( Word16 * ) ); temp1F_icatdmResampBuf_fx = (Word16 *) malloc( 45 * sizeof( Word16 * ) ); diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 813cae04b..f0ba8fc26 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -923,18 +923,13 @@ ivas_error ivas_cpe_enc_fx( &ener_fx[n], &relE_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], &vad_hover_flag[n], &attack_flag[n], realBuffer_fx[n], imagBuffer_fx[n], &q_re_im_buf[n], old_wsp_fx[n], &q_old_wsp, pitch_fr_fx[n], voicing_fr_fx[n], &loc_harm[n], &cor_map_sum_fx[n], &vad_flag_dtx[n], enerBuffer_fx[n], &enerBuffer_fx_exp[n], fft_buff_fx[n], &fft_buff_fx_q[n], A_fx[0], lsp_new_fx[0], currFlatness_fx[n], tdm_ratio_idx, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E[n], localVAD_HE_SAD, - band_energies_LR_fx, q_band_energies_LR, 0, front_vad_flag, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate, &Q_new[n] -#ifdef DEBUG_MODE_INFO - , - ( st_ivas->nSCE + ( cpe_id * CPE_CHANNELS ) + n ) -#endif - ); - e_old_wsp[n] = sub( Q15, q_old_wsp ); - move16(); + band_energies_LR_fx, q_band_energies_LR, 0, front_vad_flag, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate, &Q_new[n] ); IF( error != IVAS_ERR_OK ) { return error; } + e_old_wsp[n] = sub( Q15, q_old_wsp ); + move16(); } /*making Q common*/ diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index 6a1d1e676..be2e223f3 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -252,18 +252,13 @@ ivas_error ivas_ism_enc_fx( error = pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8_fx[sce_id][0], old_inp_16k_fx[sce_id][0], &ener_fx[sce_id][0], &relE_fx[sce_id][0], A_fx[sce_id][0], Aw_fx[sce_id][0], epsP_fx[sce_id][0], &epsP_fx_q[sce_id][0], lsp_new_fx[sce_id][0], lsp_mid_fx[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], realBuffer_fx[sce_id][0], imagBuffer_fx[sce_id][0], &q_re_im_buf[sce_id], old_wsp_fx[sce_id][0], &q_old_wsp, pitch_fr_fx[sce_id][0], voicing_fr_fx[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum_fx[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer_fx[sce_id][0], &enerBuffer_fx_exp[sce_id][0], - fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[sce_id][0] -#ifdef DEBUG_MODE_INFO - , - st->id_element -#endif - ); - e_old_wsp[sce_id][0] = sub( Q15, q_old_wsp ); - move16(); + fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[sce_id][0] ); IF( error != IVAS_ERR_OK ) { return error; } + e_old_wsp[sce_id][0] = sub( Q15, q_old_wsp ); + move16(); IF( st_ivas->hEncoderConfig->Opt_DTX_ON ) { diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 2457fef6e..144e86643 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -245,6 +245,7 @@ ivas_error ivas_sce_enc_fx( /*----------------------------------------------------------------* * Front Pre-processing *----------------------------------------------------------------*/ + set16_fx( old_wsp_fx[0], 0, L_WSP ); q_old_wsp = Q15; move16(); @@ -254,18 +255,13 @@ ivas_error ivas_sce_enc_fx( &ener_fx[0], &relE_fx[0], A_fx[0], Aw_fx[0], epsP_fx[0], &epsP_fx_q[0], lsp_new_fx[0], lsp_mid_fx[0], &vad_hover_flag[0], &attack_flag[0], realBuffer_fx[0], imagBuffer_fx[0], &q_re_im_buf, old_wsp_fx[0], &q_old_wsp, pitch_fr_fx[0], voicing_fr_fx[0], &loc_harm[0], &cor_map_sum_fx[0], &vad_flag_dtx[0], enerBuffer_fx[0], &enerBuffer_fx_exp[0], fft_buff_fx[0], &fft_buff_fx_q[0], A_fx[0], lsp_new_fx[0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, flag_16k_smc, - st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, ivas_format, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[0] -#ifdef DEBUG_MODE_INFO - , - st->id_element -#endif - ); - e_old_wsp[0] = sub( Q15, q_old_wsp ); - move16(); + st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, ivas_format, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[0] ); IF( NE_32( error, IVAS_ERR_OK ) ) { return error; } + e_old_wsp[0] = sub( Q15, q_old_wsp ); + move16(); /* sanity check -> DTX not supported for more than one SCEs/CPEs */ IF( sub( add( st_ivas->nSCE, st_ivas->nCPE ), 1 ) > 0 ) -- GitLab