From 1aa580448f497fd64e73f4a1ae04bb294ee864d8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 8 Aug 2025 18:07:06 +0200 Subject: [PATCH 1/3] remove duplicated parameters --- lib_enc/acelp_core_enc_fx.c | 6 +-- lib_enc/acelp_core_switch_enc_fx.c | 4 +- lib_enc/core_enc_init_fx.c | 5 -- lib_enc/dtx_fx.c | 10 ++-- lib_enc/init_enc_fx.c | 68 ++++++++++---------------- lib_enc/ivas_front_vad_fx.c | 2 +- lib_enc/ivas_sce_enc_fx.c | 60 +++-------------------- lib_enc/ivas_stereo_switching_enc_fx.c | 2 +- lib_enc/pre_proc_fx.c | 4 +- lib_enc/prot_fx_enc.h | 13 ++--- lib_enc/stat_enc.h | 12 +---- lib_enc/transition_enc_fx.c | 8 +-- lib_enc/vad_fx.c | 51 +++---------------- lib_enc/vad_proc_fx.c | 1 + 14 files changed, 68 insertions(+), 178 deletions(-) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index f942a19ff..d09596b60 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -393,7 +393,7 @@ ivas_error acelp_core_enc_fx( { config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag, - tc_subfr_fx, 0, &nb_bits, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx, + tc_subfr_fx, 0, &nb_bits, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); } @@ -459,7 +459,7 @@ ivas_error acelp_core_enc_fx( config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, tc_subfr_fx, 1, NULL, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, - tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); + tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); } /*---------------------------------------------------------------* @@ -513,7 +513,7 @@ ivas_error acelp_core_enc_fx( /* Configure ACELP bit allocation */ config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_fx, 0, &nb_bits, unbits_fx, 0, &uc_two_stage_flag, 0, 0, - st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); + st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); /* redo LSF quantization */ lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, st_fx->Nb_ACELP_frames, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, Q_new ); diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 8db68e089..c447cb040 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -134,7 +134,7 @@ void acelp_core_switch_enc_fx( *----------------------------------------------------------------*/ config_acelp1_fx( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, - GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); + GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_cnt, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); encod_gen_voic_core_switch_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new ); @@ -243,7 +243,7 @@ void acelp_core_switch_enc_ivas_fx( *----------------------------------------------------------------*/ config_acelp1_fx( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, - GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); + GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_cnt, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); encod_gen_voic_core_switch_ivas_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new ); diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index 2f7870ab6..b46e4cb71 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -207,11 +207,6 @@ void init_coder_ace_plus_fx( move16(); st->tfa_flag = 0; move16(); - /* Initialize DTX */ - IF( st->ini_frame == 0 ) - { - vad_init_fx( &st->vad_st ); - } st->glr = 0; move16(); diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index 247dcbda3..442c548e9 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -656,7 +656,7 @@ void dtx_fx( /* Initialization */ IF( st_fx->ini_frame == 0 ) { - st_fx->active_fr_cnt_fx = CNG_TYPE_HO; + st_fx->active_cnt = CNG_TYPE_HO; move16(); st_fx->cng_type = FD_CNG; @@ -756,7 +756,7 @@ void dtx_fx( st_fx->fd_cng_reset_flag == 0 ) { /* reset counter */ - st_fx->active_fr_cnt_fx = 0; + st_fx->active_cnt = 0; move16(); IF( st_fx->Opt_AMR_WB ) @@ -878,7 +878,7 @@ void dtx_fx( move16(); /* reset the counter of CNG frames for averaging */ } test(); - IF( GE_16( st_fx->active_fr_cnt_fx, CNG_TYPE_HO ) && st_fx->Opt_AMR_WB == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + IF( GE_16( st_fx->active_cnt, CNG_TYPE_HO ) && st_fx->Opt_AMR_WB == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { IF( EQ_16( st_fx->element_mode, IVAS_SCE ) ) { @@ -911,8 +911,8 @@ void dtx_fx( st_fx->cng_type = LP_CNG; move16(); } - st_fx->active_fr_cnt_fx = add( st_fx->active_fr_cnt_fx, 1 ); - st_fx->active_fr_cnt_fx = s_min( st_fx->active_fr_cnt_fx, 200 ); + st_fx->active_cnt = add( st_fx->active_cnt, 1 ); + st_fx->active_cnt = s_min( st_fx->active_cnt, 200 ); } /*------------------------------------------------------------------------* diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 69cee4255..14479702b 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -20,8 +20,11 @@ * * Initialization of state variables *-----------------------------------------------------------------------*/ + ivas_error init_encoder_fx( - Encoder_State *st_fx /* i/o: Encoder static variables structure */ + Encoder_State *st_fx, /* i/o: Encoder static variables structure */ + const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ + const int16_t interval_SID /* i : interval for SID update */ ) { Word16 i; @@ -350,35 +353,6 @@ ivas_error init_encoder_fx( } wb_vad_init_fx( st_fx->hVAD ); - st_fx->hVAD->prim_act_quick_fx = 0; - move16(); - st_fx->hVAD->prim_act_slow_fx = 0; - move16(); - st_fx->hVAD->prim_act_fx = 0; - move16(); - st_fx->hVAD->prim_act_quick_he_fx = 0; - move16(); - st_fx->hVAD->prim_act_slow_he_fx = 0; - move16(); - st_fx->hVAD->prim_act_he_fx = 0; - move16(); - st_fx->hVAD->hangover_terminate_flag = 0; - move16(); - - st_fx->hVAD->consec_inactive = 0; - move16(); - st_fx->hVAD->spectral_tilt_reset = 1; - move16(); - st_fx->hVAD->running_avg_fx = 0; - move16(); - st_fx->hVAD->ra_deltasum_fx = 0; - move16(); - st_fx->hVAD->trigger_SID = 0; - move16(); - st_fx->hVAD->L_snr_sum_vad_fx = 0; - move32(); - st_fx->hVAD->q_L_snr_sum_vad = Q31; - move16(); } ELSE { @@ -387,12 +361,22 @@ ivas_error init_encoder_fx( st_fx->Pos_relE_cnt = 5120; move16(); /*20.0f*/ - st_fx->nb_active_frames_HE_SAD_fx = 0; - move16(); - st_fx->lp_speech_fx = 11520; - move16(); /*Q8 (45.0) */ /* Initialize the long-term active speech level in dB */ - /* avoid uninitialized memory access */ + /* CLDFB-based VAD */ + IF( st_fx->element_mode == EVS_MONO ) + { + if ( ( st_fx->hVAD_CLDFB = (VAD_CLDFB_HANDLE) malloc( sizeof( T_CldfbVadState ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB VAD\n" ) ); + } + + vad_init_fx( st_fx->hVAD_CLDFB ); + } + ELSE + { + st_fx->hVAD_CLDFB = NULL; + } + /*-----------------------------------------------------------------* * Noise estimator @@ -504,7 +488,7 @@ ivas_error init_encoder_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX variables\n" ) ); } - dtx_enc_init_fx( st_fx, st_fx->var_SID_rate_flag_fx, st_fx->interval_SID_fx ); + dtx_enc_init_fx( st_fx, var_SID_rate_flag, interval_SID ); } ELSE { @@ -518,8 +502,7 @@ ivas_error init_encoder_fx( { move16(); } - st_fx->active_fr_cnt_fx = 0; - move16(); + st_fx->cng_type = -1; move16(); @@ -1494,7 +1477,7 @@ ivas_error init_encoder_ivas_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for VAD\n" ) ); } - wb_vad_init_ivas_fx( st->hVAD ); + wb_vad_init_fx( st->hVAD ); } ELSE { @@ -1506,8 +1489,11 @@ ivas_error init_encoder_ivas_fx( /* CLDFB-based VAD */ IF( st->element_mode == EVS_MONO ) { - /* This is done to as in EVS T_CldfbVadState structure is present in Encoder State */ - st->hVAD_CLDFB = &st->vad_st; + if ( ( st->hVAD_CLDFB = (VAD_CLDFB_HANDLE) malloc( sizeof( T_CldfbVadState ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB VAD\n" ) ); + } + vad_init_fx( st->hVAD_CLDFB ); } ELSE diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index 1f62b6854..ce09abdbc 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -385,7 +385,7 @@ ivas_error front_vad_create_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for VAD\n" ) ); } - wb_vad_init_ivas_fx( hFrontVad->hVAD ); + wb_vad_init_fx( hFrontVad->hVAD ); hFrontVad->lp_speech_fx = 11520; // 45.0f in Q8 /* Initialize the long-term active speech level in dB */ move16(); diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 5ff9878b2..0a01413c2 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -557,70 +557,23 @@ ivas_error create_evs_sce_enc_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CoreCoder structure\n" ) ); } memset( st_fx, 0, sizeof( Encoder_State ) ); - st_fx->input_Fs = 16000; - move32(); - st_fx->total_brate = ACELP_12k65; - move32(); - st_fx->Opt_AMR_WB = 0; - move16(); - st_fx->Opt_RF_ON = 0; - move16(); - st_fx->rf_fec_offset = 0; - move16(); - st_fx->rf_fec_indicator = 1; - move16(); - st_fx->max_bwidth = SWB; - move16(); - st_fx->interval_SID_fx = FIXED_SID_RATE; - move16(); - st_fx->var_SID_rate_flag_fx = 1; - move16(); - st_fx->Opt_HE_SAD_ON_fx = 0; - move16(); - st_fx->Opt_SC_VBR = 0; - move16(); - st_fx->last_Opt_SC_VBR = 0; - move16(); + copy_encoder_config_fx( st_ivas, st_fx, 1 ); + st_fx->bitstreamformat = G192; move16(); - // copy_encoder_config_fx( st_ivas, st_fx, 1 ); - st_fx->max_bwidth = st_ivas->hEncoderConfig->max_bwidth; - move16(); - st_fx->Opt_DTX_ON = st_ivas->hEncoderConfig->Opt_DTX_ON; - move16(); - st_fx->var_SID_rate_flag_fx = st_ivas->hEncoderConfig->var_SID_rate_flag; - move16(); - st_fx->interval_SID_fx = st_ivas->hEncoderConfig->interval_SID; - move16(); - st_fx->Opt_RF_ON = st_ivas->hEncoderConfig->Opt_RF_ON; - move16(); - st_fx->rf_fec_indicator = st_ivas->hEncoderConfig->rf_fec_indicator; - move16(); - st_fx->rf_fec_offset = st_ivas->hEncoderConfig->rf_fec_offset; - move16(); - // st_fx->bitstreamformat = st->bitstreamformat; st_fx->total_brate = st_ivas->hEncoderConfig->ivas_total_brate; move32(); - st_fx->Opt_SC_VBR = st_ivas->hEncoderConfig->Opt_SC_VBR; - move16(); - st_fx->last_Opt_SC_VBR = st_ivas->hEncoderConfig->last_Opt_SC_VBR; - move16(); - st_fx->Opt_AMR_WB = st_ivas->hEncoderConfig->Opt_AMR_WB; - move16(); - st_fx->input_Fs = st_ivas->hEncoderConfig->input_Fs; - move32(); - st_fx->codec_mode = st_ivas->codec_mode; - move16(); - st_fx->last_codec_mode = st_ivas->last_codec_mode; - move16(); + st_fx->input_frame_fx = extract_l( Mult_32_16( st_fx->input_Fs, 0x0290 ) ); move16(); - IF( NE_32( ( error = init_encoder_fx( st_fx ) ), IVAS_ERR_OK ) ) + + IF( NE_32( ( error = init_encoder_fx( st_fx, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID ) ), IVAS_ERR_OK ) ) { return error; } + /*-----------------------------------------------------------------* * Bitstream *-----------------------------------------------------------------*/ @@ -641,6 +594,7 @@ ivas_error create_evs_sce_enc_fx( return error; } + /*------------------------------------------------------------------------- * destroy_sce_enc_fx() * diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index a54e56fb9..6600faff3 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -85,7 +85,7 @@ static ivas_error allocate_CoreCoder_enc_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for VAD\n" ) ); } - wb_vad_init_ivas_fx( st->hVAD ); + wb_vad_init_fx( st->hVAD ); } IF( st->hSpMusClas == NULL ) diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 8a3cf1a00..b09917b5a 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -215,7 +215,7 @@ void pre_proc_fx( /*----------------------------------------------------------------* * Change the sampling frequency to 12.8 kHz *----------------------------------------------------------------*/ - modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, ( const Word16 )( EQ_16( st->max_bwidth, NB ) ) ); + modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, (const Word16) ( EQ_16( st->max_bwidth, NB ) ) ); Copy( new_inp_12k8, st->buf_speech_enc + L_FRAME32k, L_FRAME ); Scale_sig( st->buf_speech_enc + L_FRAME32k, L_FRAME, 1 ); /*------------------------------------------------------------------* @@ -270,7 +270,7 @@ void pre_proc_fx( st->vad_flag = wb_vad_fx( st, fr_bands, &noisy_speech_HO, &clean_speech_HO, &NB_speech_HO, &snr_sum_he, &localVAD_HE_SAD, &( st->flag_noisy_speech_snr ), *Q_new, hVAD, hNoiseEst, st->lp_speech_fx, st->lp_noise_fx ); - vad_flag_cldfb = vad_proc_fx( &( st->vad_st ), realBuffer, imagBuffer, cldfbScale->lb_scale, &cldfb_addition, + vad_flag_cldfb = vad_proc_fx( st->hVAD_CLDFB, realBuffer, imagBuffer, cldfbScale->lb_scale, &cldfb_addition, enerBuffer, enerBuffer_exp, st->cldfbAnaEnc->no_channels, st->vad_flag ); IF( LT_16( st->Pos_relE_cnt, 20 ) ) /* Ensure the level is high enough and cldfb decision is reliable */ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 48af49619..a4c439c1d 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2603,11 +2603,14 @@ void IGFEncSetMode_fx( const Word16 rf_mode /* i : flag to signal the RF mode */ ); -Word16 vad_init_fx( VAD_CLDFB_HANDLE vad_state ); +Word16 vad_init_fx( + VAD_CLDFB_HANDLE hVAD_CLDFB /* i/o: CLDFB VAD state */ +); void init_PLC_enc_fx( PLC_ENC_EVS_HANDLE hPlcExt, Word32 sampleRate ); + void core_coder_reconfig_fx( Encoder_State *st, const Word32 last_total_brate ); @@ -4390,10 +4393,6 @@ void wb_vad_init_fx( VAD_HANDLE hVAD /* i/o: VAD data handle */ ); -void wb_vad_init_ivas_fx( - VAD_HANDLE hVAD /* i/o: VAD data handle */ -); - void noise_est_init_fx( NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */ ); @@ -4780,7 +4779,9 @@ void index_lvq_ivas_fx( const Word16 prediction_flag ); ivas_error init_encoder_fx( - Encoder_State *st_fx /* i/o: Encoder static variables structure */ + Encoder_State *st_fx, /* i/o: Encoder static variables structure */ + const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ + const int16_t interval_SID /* i : interval for SID update */ ); void copy_encoder_config_fx( diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 3839e3ec5..c1e2924b3 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1324,7 +1324,6 @@ typedef struct enc_core_structure // Word16 Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ // Word16 Opt_DTX_ON_fx; /* flag indicating DTX operation */ // Word16 cng_type; /* flag indicating LP or CLDFB based SID/CNG */ - Word16 active_fr_cnt_fx; /* counter of active frames */ // Word16 Opt_SC_VBR_fx; /* flag indicating SC-VBR mode */ // Word16 last_Opt_SC_VBR_fx; /* flag indicating SC-VBR mode in the last frame */ @@ -1444,8 +1443,8 @@ typedef struct enc_core_structure Word32 diff_sm_fx; /* Q7 */ Word32 energy_sm_fx; /* Q7 */ + Word16 sharpFlag; - Word16 finalVAD; Word16 flag_noisy_speech_snr; /* encoder detector for noisy speech */ Word16 Pos_relE_cnt; /* Number of frames between relE */ @@ -1513,10 +1512,8 @@ typedef struct enc_core_structure VAD_HANDLE hVAD; VAD_CLDFB_HANDLE hVAD_CLDFB; - T_CldfbVadState vad_st; Word16 vad_flag; /* i : VAD flag */ - Word16 sharpFlag; Word16 localVAD; /* i : local VAD flag */ Word32 bckr_tilt_lt; /* Q16 */ @@ -1524,12 +1521,7 @@ typedef struct enc_core_structure Word16 lp_noise_fx; /* CNG and DTX - LP filtered total noise estimation Q24 */ Word32 lp_speech_32fx; /* Q24 */ Word32 lp_noise_32fx; /* CNG and DTX - LP filtered total noise estimation Q24 */ - Word16 Opt_HE_SAD_ON_fx; - Word16 nb_active_frames_HE_SAD_fx; - Word16 voicing_old_fx; - Word16 var_SID_rate_flag_fx; /* CNG and DTX - flag for variable SID rate */ - Word16 interval_SID_fx; - Word16 active_cnt; /* counter of active frames */ + Word16 active_cnt; /* counter of active frames */ TD_CNG_ENC_HANDLE hTdCngEnc; diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index c1c032e4e..50fb93bf6 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -214,7 +214,7 @@ void transition_enc_fx( /* this is called only to compute unused bits */ config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP, - st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); + st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_cnt, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); } *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, sub( shift_wsp, 1 ) ); @@ -326,7 +326,7 @@ void transition_enc_fx( { config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL, - unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); + unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_cnt, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); } /*-----------------------------------------------------------------* @@ -1034,7 +1034,7 @@ void transition_enc_ivas_fx( /* this is called only to compute unused bits */ config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP, - st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ + st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_cnt, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); } @@ -1147,7 +1147,7 @@ void transition_enc_ivas_fx( { config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL, - unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); + unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_cnt, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); } /*-----------------------------------------------------------------* diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 955c7c74d..09dead792 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -91,52 +91,13 @@ static Word16 vad_snr_log_fx( /* o: Q8 */ } -void wb_vad_init_fx( - VAD_HANDLE hVAD /* i/o: VAD data handle */ -) -{ - hVAD->hangover_cnt = 0; - move16(); /* Hangover counter initialized to 0 */ - hVAD->nb_active_frames = ACTIVE_FRAMES_FX; - move16(); /* The counter of SPEECH frames necessary to trigger HO */ - /* is set to max (-> start with hangover) */ - - hVAD->vad_flag_reg_H = L_deposit_l( 0 ); - move32(); - hVAD->vad_flag_reg_L = L_deposit_l( 0 ); - move32(); - hVAD->vad_prim_reg = L_deposit_l( 0 ); - move32(); - hVAD->vad_flag_cnt_50 = 0; - move16(); - hVAD->vad_prim_cnt_16 = 0; - move16(); - - hVAD->hangover_cnt_dtx = HANGOVER_LONG_FX; - move16(); /* hangover for DTX */ - hVAD->hangover_cnt_music = HANGOVER_LONG_MUSIC_FX; - move16(); /* hangover for MUSIC DTX */ - - hVAD->hangover_cnt_he = 0; - move16(); /* Hangover counter initialized to 0 */ - hVAD->nb_active_frames_he = ACTIVE_FRAMES_FX; - move16(); /* The counter of SPEECH frames necessary to trigger HO */ - hVAD->bcg_flux_fx = 1120; - move16(); /*70 in Q4 */ - hVAD->soft_hangover = 0; - move16(); - hVAD->voiced_burst = 0; - move16(); - hVAD->bcg_flux_init = 50; - move16(); - hVAD->nb_active_frames_he1 = ACTIVE_FRAMES_FX; - move16(); - hVAD->hangover_cnt_he1 = 0; - move16(); - return; -} +/*-----------------------------------------------------------------* + * wb_vad_init_fx() + * + * + *-----------------------------------------------------------------*/ -void wb_vad_init_ivas_fx( +void wb_vad_init_fx( VAD_HANDLE hVAD /* i/o: VAD data handle */ ) { diff --git a/lib_enc/vad_proc_fx.c b/lib_enc/vad_proc_fx.c index 2c9273ff5..16247be44 100644 --- a/lib_enc/vad_proc_fx.c +++ b/lib_enc/vad_proc_fx.c @@ -15,6 +15,7 @@ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ + /*-------------------------------------------------------------------* * vad_init_fx() * -- GitLab From 2ab6320f4f0c6ec716891f8f372dcac0a970c25f Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 8 Aug 2025 18:23:42 +0200 Subject: [PATCH 2/3] remove duplicated parameters --- lib_enc/init_enc_fx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 14479702b..0ee479a7c 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -476,7 +476,12 @@ ivas_error init_encoder_fx( st_fx->exc_pe_fx = 0; move16(); - /* CNG and DTX */ + /*-----------------------------------------------------------------* + * DTX + *-----------------------------------------------------------------*/ + + st_fx->lp_speech_fx = 11520; + move16(); /*Q8 (45.0) */ /* Initialize the long-term active speech level in dB */ st_fx->lp_noise_fx = 0; move16(); -- GitLab From 585f27f7162d01f43b5b0beb3ce3157ed94c2e5a Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 8 Aug 2025 19:41:13 +0200 Subject: [PATCH 3/3] clang-format --- lib_enc/pre_proc_fx.c | 2 +- lib_enc/vad_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index b09917b5a..0dc722acd 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -215,7 +215,7 @@ void pre_proc_fx( /*----------------------------------------------------------------* * Change the sampling frequency to 12.8 kHz *----------------------------------------------------------------*/ - modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, (const Word16) ( EQ_16( st->max_bwidth, NB ) ) ); + modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, ( const Word16 )( EQ_16( st->max_bwidth, NB ) ) ); Copy( new_inp_12k8, st->buf_speech_enc + L_FRAME32k, L_FRAME ); Scale_sig( st->buf_speech_enc + L_FRAME32k, L_FRAME, 1 ); /*------------------------------------------------------------------* diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 09dead792..9819285f0 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -94,7 +94,7 @@ static Word16 vad_snr_log_fx( /* o: Q8 */ /*-----------------------------------------------------------------* * wb_vad_init_fx() * - * + * *-----------------------------------------------------------------*/ void wb_vad_init_fx( -- GitLab