From c95fb11dfcb941159cd1f38c260e0d6c8e4d3a72 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 6 Mar 2026 07:32:02 +0100 Subject: [PATCH 01/15] Add BASOP/Float alignment under HQ_ALIGN_DUPLICATED_CODE --- lib_com/hq_tools_fx.c | 24 ++++++++++++++++++++++++ lib_com/options.h | 1 + lib_enc/hq_hr_enc_fx.c | 4 ++++ 3 files changed, 29 insertions(+) diff --git a/lib_com/hq_tools_fx.c b/lib_com/hq_tools_fx.c index c93c6a20e..f7f11cc7f 100644 --- a/lib_com/hq_tools_fx.c +++ b/lib_com/hq_tools_fx.c @@ -2640,7 +2640,22 @@ void enforce_zero_for_min_envelope_fx( return; } +#ifdef HQ_ALIGN_DUPLICATED_CODE +/*--------------------------------------------------------------------------* + * apply_envelope() + * + * Apply spectral envelope without envelope adjustments and noisefill + *--------------------------------------------------------------------------*/ +void apply_envelope_enc_fx( + const Word16 *coeff, /* i/o: Normalized/scaled normalized spectrum Q12 */ + const Word16 *norm, /* i : Envelope Q0 */ + const Word16 num_sfm, /* i : Total number of bands Q0 */ + const Word16 *sfm_start, /* i : Sub band start indices Q0 */ + const Word16 *sfm_end, /* i : Sub band end indices Q0 */ + Word32 *coeff_out /* o : scaled normalized spectrum Q12 */ +) +#else /*--------------------------------------------------------------------------* * apply_envelope() * @@ -2655,6 +2670,7 @@ void apply_envelope_enc_ivas_fx( const Word16 *sfm_end, /* i : Sub band end indices Q0 */ Word32 *coeff_out /* o : coded/noisefilled spectrum Q12 */ ) +#endif { Word16 i; Word16 sfm; @@ -2680,11 +2696,19 @@ void apply_envelope_enc_ivas_fx( } +#ifdef HQ_ALIGN_DUPLICATED_CODE +/*--------------------------------------------------------------------------* + * apply_envelope_fx() + * + * Apply spectral envelope with envelope adjustments + *--------------------------------------------------------------------------*/ +#else /*--------------------------------------------------------------------------* * apply_envelope() * * Apply spectral envelope with envelope adjustments *--------------------------------------------------------------------------*/ +#endif void apply_envelope_fx( const Word16 *coeff, /* i/o: Coded/noisefilled normalized spectrum Q12 */ diff --git a/lib_com/options.h b/lib_com/options.h index 23a5aa26c..6eda08e49 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -91,6 +91,7 @@ #define HARM_2456_APPLY_SCALE /* FhG basop issue 2456: Harmonize apply_scale_ind(), apply_scale_ivas_fx() */ #define HARM_2454_TCX_RES_Q_SPEC /* FhG: harmonization of tcx_res_Q_spec_fx() and tcx_res_Q_spec_ivas_fx() */ #define FIX_FLOAT_1535_ARI_RES_Q_CLEANUP /* FhG: remove dead code from tcx_ari_res_Q_spec() */ +#define HQ_ALIGN_DUPLICATED_CODE /* Eri: Align duplicated code */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/hq_hr_enc_fx.c b/lib_enc/hq_hr_enc_fx.c index 5c290fe7c..b2d7b4175 100644 --- a/lib_enc/hq_hr_enc_fx.c +++ b/lib_enc/hq_hr_enc_fx.c @@ -530,7 +530,11 @@ void hq_hr_enc_ivas_fx( { IF( NE_16( hqswb_clas, HQ_HVQ ) ) { +#ifdef HQ_ALIGN_DUPLICATED_CODE + apply_envelope_enc_fx( t_audio_q_norm, ynrm, num_sfm, sfm_start, sfm_end, t_audio_q_fx ); +#else apply_envelope_enc_ivas_fx( t_audio_q_norm, ynrm, num_sfm, sfm_start, sfm_end, t_audio_q_fx ); +#endif scale_sig32( t_audio_q_fx, length, sub( Q12, Q_audio ) ); // Q12 } -- GitLab From c3d6f9f64cd88117ffccd839e27ee1aa89eb681b Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 6 Mar 2026 08:35:45 +0100 Subject: [PATCH 02/15] Remove mdct_classifier_ivas_fx --- lib_com/hq_tools_fx.c | 4 ++-- lib_com/ivas_prot_fx.h | 4 ++-- lib_com/prot_fx.h | 11 +++++++++++ lib_enc/ivas_decision_matrix_enc_fx.c | 14 ++++++++++++-- lib_enc/mdct_classifier_fx.c | 14 ++++++++++---- lib_enc/prot_fx_enc.h | 9 +++++++-- 6 files changed, 44 insertions(+), 12 deletions(-) diff --git a/lib_com/hq_tools_fx.c b/lib_com/hq_tools_fx.c index f7f11cc7f..31ee54b86 100644 --- a/lib_com/hq_tools_fx.c +++ b/lib_com/hq_tools_fx.c @@ -2648,12 +2648,12 @@ void enforce_zero_for_min_envelope_fx( *--------------------------------------------------------------------------*/ void apply_envelope_enc_fx( - const Word16 *coeff, /* i/o: Normalized/scaled normalized spectrum Q12 */ + const Word16 *coeff, /* i : Normalized spectrum Q12 */ const Word16 *norm, /* i : Envelope Q0 */ const Word16 num_sfm, /* i : Total number of bands Q0 */ const Word16 *sfm_start, /* i : Sub band start indices Q0 */ const Word16 *sfm_end, /* i : Sub band end indices Q0 */ - Word32 *coeff_out /* o : scaled normalized spectrum Q12 */ + Word32 *coeff_out /* o : scaled spectrum Q12 */ ) #else /*--------------------------------------------------------------------------* diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 6fb6181ba..3a1717a77 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2720,7 +2720,7 @@ void ivas_param_mc_metadata_open_fx( const Word32 ivas_total_brate, /* i : IVAS total bitrate */ HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC /* o : handle for the Parametric MC parameter coding state */ ); - +#ifndef HQ_ALIGN_DUPLICATED_CODE Word16 mdct_classifier_ivas_fx( Encoder_State *st, /* i/o: Encoder state variable */ const Word16 *fft_buff, /* i : FFT spectrum from fft_rel */ @@ -2728,7 +2728,7 @@ Word16 mdct_classifier_ivas_fx( Word16 enerBuffer_exp, /* i: enenrgy buffer exponent */ const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ ); - +#endif /*----------------------------------------------------------------------------------* * Range Coder prototypes diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index f32d05534..ee87df03f 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -735,6 +735,16 @@ void enforce_zero_for_min_envelope_fx( const Word16 *sfm_end /* i : Sub band end indices Q0 */ ); +#ifdef HQ_ALIGN_DUPLICATED_CODE +void apply_envelope_enc_fx( + const Word16 *coeff, /* i : Normalized spectrum Q12 */ + const Word16 *norm, /* i : Envelope Q0 */ + const Word16 num_sfm, /* i : Total number of bands Q0 */ + const Word16 *sfm_start, /* i : Sub band start indices Q0 */ + const Word16 *sfm_end, /* i : Sub band end indices Q0 */ + Word32 *coeff_out /* o : scaled spectrum Q12 */ +); +#else void apply_envelope_enc_ivas_fx( const Word16 *coeff, /* i/o: Coded/noisefilled normalized spectrum Q12 */ const Word16 *norm, /* i : Envelope Q0 */ @@ -743,6 +753,7 @@ void apply_envelope_enc_ivas_fx( const Word16 *sfm_end, /* i : Sub band end indices Q0 */ Word32 *coeff_out /* o : coded/noisefilled spectrum Q12 */ ); +#endif void apply_envelope_fx( const Word16 *coeff, /* i : Coded/noisefilled normalized spectrum Q12 */ diff --git a/lib_enc/ivas_decision_matrix_enc_fx.c b/lib_enc/ivas_decision_matrix_enc_fx.c index 79448bd19..a6f5e7edb 100644 --- a/lib_enc/ivas_decision_matrix_enc_fx.c +++ b/lib_enc/ivas_decision_matrix_enc_fx.c @@ -36,7 +36,9 @@ #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" /* Function prototypes */ - +#ifdef HQ_ALIGN_DUPLICATED_CODE +#include "prot_fx_enc.h" +#endif /*-----------------------------------------------------------------* * ivas_decision_matrix_enc() @@ -188,8 +190,16 @@ void ivas_decision_matrix_enc_fx( } ELSE { - /* select TCX core or HQ core using bits_frame_nominal to match the TCX configuration bitrate */ +/* select TCX core or HQ core using bits_frame_nominal to match the TCX configuration bitrate */ +#ifdef HQ_ALIGN_DUPLICATED_CODE + st->core = mdct_classifier_fx( fft_buff, + st, + enerBuffer, + enerBuffer_exp, + L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ) ); /* Q0 */ +#else st->core = mdct_classifier_ivas_fx( st, fft_buff, enerBuffer, enerBuffer_exp, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ) ); /* Q0 */ +#endif move16(); } } diff --git a/lib_enc/mdct_classifier_fx.c b/lib_enc/mdct_classifier_fx.c index 11c4fcb4b..d0b39e7b5 100644 --- a/lib_enc/mdct_classifier_fx.c +++ b/lib_enc/mdct_classifier_fx.c @@ -91,10 +91,15 @@ static void dft_mag_square_fx( /* o: MDCT A/B decision */ Word16 mdct_classifier_fx( const Word16 *fft_buff, /* i : re[0], re[1], ..., re[n/2], im[n/2 - 1], im[n/2 - 2], ..., im[1] */ - Encoder_State *st_fx, /* i/o: Encoder state variable */ - Word32 *cldfbBuf_Ener, // enerBuffer_exp + Encoder_State *st_fx, /* i/o: Encoder state variable */ +#ifdef HQ_ALIGN_DUPLICATED_CODE + const Word32 *cldfbBuf_Ener, /* i : Sum array of energy values of CLDFB buffer */ + const Word16 enerBuffer_exp, /* i : Exponent of cldfbBuf_Ener */ +#else + Word32 *cldfbBuf_Ener, // enerBuffer_exp Word16 enerBuffer_exp, - const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ +#endif + const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ ) { Word16 c; @@ -504,7 +509,7 @@ Word16 mdct_classifier_fx( return clas_final; /* Q0 */ } - +#ifndef HQ_ALIGN_DUPLICATED_CODE Word16 mdct_classifier_ivas_fx( Encoder_State *st, /* i/o: Encoder state variable */ const Word16 *fft_buff, /* i : FFT spectrum from fft_rel */ @@ -1045,3 +1050,4 @@ Word16 mdct_classifier_ivas_fx( return clas_final; } +#endif diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index ab96335fc..cace60ece 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -247,10 +247,15 @@ void ivas_long_enr_fx( /* o: MDCT A/B decision */ Word16 mdct_classifier_fx( const Word16 *Y, /* i : re[0], re[1], ..., re[n/2], im[n/2 - 1], im[n/2 - 2], ..., im[1] */ - Encoder_State *st_fx, /* i/o: Encoder state variable */ + Encoder_State *st_fx, /* i/o: Encoder state variable */ +#ifdef HQ_ALIGN_DUPLICATED_CODE + const Word32 *cldfbBuf_Ener, /* i : Sum array of energy values of CLDFB buffer */ + const Word16 enerBuffer_exp, /* i : Exponent of cldfbBuf_Ener */ +#else Word32 *cldfbBuf_Ener, Word16 enerBuffer_exp, - const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ +#endif + const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ ); void noise_est_down_fx( -- GitLab From 3b259856f3294b219e49a63b748dffda11864e39 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 6 Mar 2026 09:56:52 +0100 Subject: [PATCH 03/15] Remove duplicate stat_noise_uv_mod_ivas_fx --- lib_com/prot_fx.h | 26 ++++ lib_com/stat_noise_uv_mod_fx.c | 167 +++++++++++++++++++++++--- lib_dec/acelp_core_dec_fx.c | 6 + lib_dec/stat_noise_uv_dec_fx.c | 8 ++ lib_enc/ivas_decision_matrix_enc_fx.c | 6 +- lib_enc/stat_noise_uv_enc_fx.c | 12 ++ 6 files changed, 201 insertions(+), 24 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index ee87df03f..345b4eae4 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7580,6 +7580,31 @@ void stat_noise_uv_dec_fx( const Word16 uc_two_stage_flag /* i : flag indicating two-stage UC */ ); +#ifdef HQ_ALIGN_DUPLICATED_CODE +void stat_noise_uv_mod_fx( + const Word16 element_mode, /* i : element mode */ + const Word16 coder_type, /* i : Coder type */ + Word16 noisiness, /* i : noisiness parameter Q=0 */ + const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q=15*/ + const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q=15*/ + const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/ + Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/ + Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/ + Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ + const Word16 bfi, /* i : Bad frame indicator */ + Word32 *ge_sm, /* i/o: smoothed excitation gain Q=Q_stat_noise_ge (6)*/ + Word16 *uv_count, /* i/o: unvoiced counter */ + Word16 *act_count, /* i/o: activation counter */ + Word16 lspold_s[], /* i/o: old LSP Q=15*/ + Word16 *noimix_seed, /* i/o: mixture seed Q0 */ + Word16 *st_min_alpha, /* i/o: minimum alpha Q=15*/ + Word16 *exc_pe, /* i/o: scale Q_stat_noise Q=Q_stat_noise*/ + const Word32 bitrate, /* i : core bitrate */ + const Word16 bwidth_fx, /* i : i bandwidth */ + Word16 *Q_stat_noise, /* i/o: noise scaling */ + Word16 *Q_stat_noise_ge /* i/o: noise scaling */ +); +#else void stat_noise_uv_mod_fx( const Word16 coder_type, /* i : Coder type */ Word16 noisiness, /* i : noisiness parameter Q0 */ @@ -7625,6 +7650,7 @@ void stat_noise_uv_mod_ivas_fx( Word16 *Q_stat_noise, /* i/o: noise scaling */ Word16 *Q_stat_noise_ge /* i/o: noise scaling */ ); +#endif Word16 FEC_SinOnset_fx( Word16 *exc, /* i/o : exc vector to modify */ diff --git a/lib_com/stat_noise_uv_mod_fx.c b/lib_com/stat_noise_uv_mod_fx.c index 33c5545ce..2ff84c948 100644 --- a/lib_com/stat_noise_uv_mod_fx.c +++ b/lib_com/stat_noise_uv_mod_fx.c @@ -28,13 +28,38 @@ Word32 L_Sqrt_Q0( const Word32 x ); * Modifies excitation signal in stationary noise segments *--------------------------------------------------------------------*/ +#ifdef HQ_ALIGN_DUPLICATED_CODE void stat_noise_uv_mod_fx( - const Word16 coder_type, /* i : Coder type */ + const Word16 element_mode, /* i : element mode */ + const Word16 coder_type, /* i : Coder type */ + Word16 noisiness, /* i : noisiness parameter Q=0 */ + const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q=15*/ + const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q=15*/ + const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/ + Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/ + Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/ + Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ + const Word16 bfi, /* i : Bad frame indicator */ + Word32 *ge_sm, /* i/o: smoothed excitation gain Q=Q_stat_noise_ge (6)*/ + Word16 *uv_count, /* i/o: unvoiced counter */ + Word16 *act_count, /* i/o: activation counter */ + Word16 lspold_s[], /* i/o: old LSP Q=15*/ + Word16 *noimix_seed, /* i/o: mixture seed Q0 */ + Word16 *st_min_alpha, /* i/o: minimum alpha Q=15*/ + Word16 *exc_pe, /* i/o: scale Q_stat_noise Q=Q_stat_noise*/ + const Word32 bitrate, /* i : core bitrate */ + const Word16 bwidth_fx, /* i : i bandwidth */ + Word16 *Q_stat_noise, /* i/o: noise scaling */ + Word16 *Q_stat_noise_ge /* i/o: noise scaling */ +) +#else +void stat_noise_uv_mod_fx( + const Word16 coder_type, /* i : Coder type */ Word16 noisiness, /* i : noisiness parameter Q0 */ - const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q15 */ - const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q15 */ - const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q15 */ - Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q12 */ + const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q15*/ + const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q15*/ + const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q15*/ + Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q12*/ Word16 *exc2, /* i/o: excitation buffer Q_exc */ Word16 Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ const Word16 bfi, /* i : Bad frame indicator */ @@ -50,6 +75,7 @@ void stat_noise_uv_mod_fx( Word16 *Q_stat_noise, /* i/o: noise scaling */ Word16 *Q_stat_noise_ge /* i/o: noise scaling */ ) +#endif { Word16 exctilt; /* Q15 */ Word32 vare; /* Q31 */ @@ -63,6 +89,9 @@ void stat_noise_uv_mod_fx( Word16 newlsp_mix[M]; Word16 beta; /* Q15 */ Word16 Noimix_fract; /* (noimix_fac - 1.0) in Q15 */ +#ifdef HQ_ALIGN_DUPLICATED_CODE + Word32 L_Noimix_fract; /* (noimix_fac - 1.0) in Q15 */ +#endif /* noimix_fax * x <-> x + Noimix_fract * x */ Word16 i_subfr; Word16 i, k; @@ -74,6 +103,9 @@ void stat_noise_uv_mod_fx( Word16 En_shift, Tmp; Word16 Exc2_local[L_FRAME]; /* local_copy in scaled Q_local*/ +#ifdef HQ_ALIGN_DUPLICATED_CODE + Word32 L_Exc2_local[L_FRAME]; /* local_copy in scaled Q_local*/ +#endif /*---------------------------------------------------------* * Init local variables @@ -82,6 +114,9 @@ void stat_noise_uv_mod_fx( move16(); min_alpha = 16384; move16(); +#ifdef HQ_ALIGN_DUPLICATED_CODE + L_Noimix_fract = 0; +#endif test(); test(); @@ -98,15 +133,23 @@ void stat_noise_uv_mod_fx( tmp_den = 31; move16(); tmp_shift = norm_s( tmp_den ); +#ifndef HQ_ALIGN_DUPLICATED_CODE move16(); +#endif L_tmp_res = L_deposit_h( noisiness ); L_tmp_res = L_shl( L_tmp_res, sub( tmp_shift, 1 ) ); tmp_den = shl( tmp_den, tmp_shift ); +#ifndef HQ_ALIGN_DUPLICATED_CODE move16(); +#endif tmp_res = div_l( L_tmp_res, tmp_den ); +#ifndef HQ_ALIGN_DUPLICATED_CODE move16(); +#endif min_alpha = add_sat( tmp_res, 16384 ); +#ifndef HQ_ALIGN_DUPLICATED_CODE move16(); +#endif /**st_min_alpha = sub(*st_min_alpha, 1638); move16();*/ min_alpha = s_max( min_alpha, sub( *st_min_alpha, 1638 ) ); @@ -128,9 +171,17 @@ void stat_noise_uv_mod_fx( Copy( exc2, Exc2_local, L_FRAME ); /* bound Q for internal use, optimization possible */ +#ifdef HQ_ALIGN_DUPLICATED_CODE + Q_local = s_min( 11, s_max( -1, *Q_exc ) ); +#else Q_local = s_min( 11, s_max( -1, Q_exc ) ); +#endif /* local excitation Q and incoming excitation Q*/ +#ifdef HQ_ALIGN_DUPLICATED_CODE + Qdiff = sub( Q_local, *Q_exc ); +#else Qdiff = sub( Q_local, Q_exc ); +#endif /* only shift if incoming Q is outside [11..-1] shift is done in energy calculations aswell */ Scale_sig( Exc2_local, L_FRAME, Qdiff ); /* current excitation Q and previous stat_noise states Q */ @@ -229,14 +280,30 @@ void stat_noise_uv_mod_fx( L_tmp_res = L_mac( 0, alpha, alpha ); L_tmp_res = L_mac( L_tmp_res, alpha_m1, alpha_m1 ); tmp_den = round_fx( L_Frac_sqrtQ31( L_tmp_res ) ); - +#ifdef HQ_ALIGN_DUPLICATED_CODE + IF( EQ_16( element_mode, EVS_MONO ) ) + { + tmp_nom = sub( 32767, tmp_den ); + tmp_shift = norm_s( tmp_den ); + tmp_den = shl( tmp_den, tmp_shift ); + tmp_res = div_s( tmp_nom, tmp_den ); + Noimix_fract = shr( tmp_res, tmp_shift ); /* float value is in range 0.0 to 0.42 */ + } + ELSE + { + Word16 exp_sqr = 0; + move16(); + tmp_res = BASOP_Util_Divide1616_Scale( 32767, tmp_den, &exp_sqr ); // 15-exp_sqr + Noimix_fract = tmp_res; // 15-exp_sqr + move16(); + } +#else tmp_nom = sub( 32767, tmp_den ); tmp_shift = norm_s( tmp_den ); tmp_den = shl( tmp_den, tmp_shift ); tmp_res = div_s( tmp_nom, tmp_den ); - - Noimix_fract = shr( tmp_res, tmp_shift ); /* float value is in range 0.0 to 0.42 */ - + Noimix_fract = shr( tmp_res, tmp_shift ); /* float value is in range 0.0 to 0.42 */ +#endif /* L_Ge might be 0 in unvoiced WB */ L_Ge = L_max( L_Ge, 1 ); tmp_shift = norm_l( L_Ge ); @@ -245,8 +312,20 @@ void stat_noise_uv_mod_fx( L_tmp_res = Mult_32_16( *ge_sm, tmp_res ); /* Q_stat_noise_ge+45-Q_local-Q_ge-tmp_shift-15 */ L_tmp_res = Mult_32_16( L_tmp_res, sub( 32767, beta ) ); /*30-Q_local-tmp_shift+15-15 */ L_tmp_res = L_add_sat( L_shl_sat( L_tmp_res, sub( add( Q_local, tmp_shift ), 15 ) ), beta ); /* Q15 */ - tmp_res = extract_h( L_shl_sat( L_tmp_res, 15 ) ); /* 15+15-16=14 */ - Noimix_fract = extract_l( Mult_32_16( L_tmp_res, Noimix_fract ) ); /*15+15-15 */ +#ifdef HQ_ALIGN_DUPLICATED_CODE + IF( EQ_16( element_mode, EVS_MONO ) ) + { + tmp_res = extract_h( L_shl_sat( L_tmp_res, 15 ) ); /* 15+15-16=14 */ + Noimix_fract = extract_l( Mult_32_16( L_tmp_res, Noimix_fract ) ); /*15+15-15 */ + } + ELSE + { + L_Noimix_fract = Mult_32_16( L_tmp_res, Noimix_fract ); /*15+15-exp_sqr-15 =15-exp_sqr */ + } +#else + tmp_res = extract_h( L_shl_sat( L_tmp_res, 15 ) ); /* 15+15-16=14 */ + Noimix_fract = extract_l( Mult_32_16( L_tmp_res, Noimix_fract ) ); /*15+15-15 */ +#endif FOR( i = 0; i < L_FRAME; i++ ) { @@ -258,23 +337,70 @@ void stat_noise_uv_mod_fx( *--------------------------------------------------------------------*/ /* (1-alpha)*(float)sqrt(12.0f) * ((float)own_random(&(st->noimix_seed))/65536.0f) */ - randval = Random( noimix_seed ); /* +/-32767 */ - randval = mult_r( 28378, randval ); /* Q downscaled by 2 bits ends up in Q14 */ /*sqrt(12.0f) in Q13*/ + randval = Random( noimix_seed ); /* +/-32767 */ + randval = mult_r( 28378, randval ); /* Q downscaled by 2 bits ends up in Q14 */ /*sqrt(12.0f) in Q13*/ +#ifdef HQ_ALIGN_DUPLICATED_CODE + randval = extract_l( L_shl( Mult_32_16( L_Ge, randval ), sub( 1, *Q_stat_noise_ge ) ) ); /*Q_local+Q_ge+14-15+1-Q_ge=Q_local */ +#else randval = extract_l( L_shl( Mult_32_16( L_Ge, randval ), 1 - *Q_stat_noise_ge ) ); /*Q_local+Q_ge+14-15+1-Q_ge=Q_local */ +#endif + L_tmp = L_mult( Exc2_local[i], alpha ); /* Q_local + 16 */ + L_tmp = L_mac( L_tmp, randval, alpha_m1 ); /* Q_local + 16 */ - L_tmp = L_mult( Exc2_local[i], alpha ); /* Q_local + 16 */ - L_tmp = L_mac( L_tmp, randval, alpha_m1 ); /* Q_local + 16 */ - L_tmp3 = Mult_32_16( L_tmp, Noimix_fract ); /* Q_local+16+15-15 */ - L_tmp = L_add_sat( L_tmp3, L_shl_sat( Mult_32_16( L_tmp, tmp_res ), 1 ) ); /* Q_local+16+14-15+1 */ - Exc2_local[i] = extract_h( L_tmp ); /*Q_local */ +#ifdef HQ_ALIGN_DUPLICATED_CODE + IF( EQ_16( element_mode, EVS_MONO ) ) + { + L_tmp3 = Mult_32_16( L_tmp, Noimix_fract ); /* Q_local+16+15-15 */ + L_tmp = L_add_sat( L_tmp3, L_shl_sat( Mult_32_16( L_tmp, tmp_res ), 1 ) ); /* Q_local+16+14-15+1 */ + Exc2_local[i] = extract_h( L_tmp ); /*Q_local */ + move16(); + } + ELSE + { + L_tmp3 = Mult_32_32( L_tmp, L_Noimix_fract ); /* Q_local+16+15-exp_sqr-15 =Q_local +1 */ + L_Exc2_local[i] = L_add( L_shr( L_tmp3, 1 ), Mpy_32_32( L_tmp, L_tmp_res ) ); // Q_local + 16 +15 -31 = Q_local + move32(); + } +#else + L_tmp3 = Mult_32_16( L_tmp, Noimix_fract ); /* Q_local+16+15-15 */ + L_tmp = L_add_sat( L_tmp3, L_shl_sat( Mult_32_16( L_tmp, tmp_res ), 1 ) ); /* Q_local+16+14-15+1 */ + Exc2_local[i] = extract_h( L_tmp ); /*Q_local */ + move16(); +#endif + } +#ifdef HQ_ALIGN_DUPLICATED_CODE + IF( EQ_16( element_mode, EVS_MONO ) ) + { + *Q_stat_noise = Q_local; /* update for next call, routine can only be called once every frame */ + move16(); + Qdiff = sub( *Q_exc, Q_local ); /* local excitation and incoming excitation */ + Scale_sig( Exc2_local, L_FRAME, Qdiff ); + Copy( Exc2_local, exc2, L_FRAME ); + } + ELSE + { + Word32 max_val; + maximum_abs_32_fx( L_Exc2_local, L_FRAME, &max_val ); + Word16 shift = 0; move16(); + IF( GT_32( max_val, ONE_IN_Q15 ) ) + { + shift = norm_l( max_val ); + shift = sub( Q31 - Q15, shift ); + *Q_exc = sub( Q_local, shift ); // Q_exc = Q_local -shift + move16(); + } + *Q_stat_noise = Q_local; /* update for next call, routine can only be called once every frame */ + move16(); + Copy_Scale_sig_32_16( L_Exc2_local, exc2, L_FRAME, negate( shift ) ); // Q_exc } +#else *Q_stat_noise = Q_local; /* update for next call, routine can only be called once every frame */ move16(); Qdiff = sub( Q_exc, Q_local ); /* local excitation and incoming excitation */ Scale_sig( Exc2_local, L_FRAME, Qdiff ); Copy( Exc2_local, exc2, L_FRAME ); - +#endif /*--------------------------------------------------------------------* * Generate low-pass filtered version of ISP coefficients *--------------------------------------------------------------------*/ @@ -324,6 +450,8 @@ void stat_noise_uv_mod_fx( } } } + +#ifndef HQ_ALIGN_DUPLICATED_CODE /*--------------------------------------------------------------------* * stat_noise_uv_mod() * @@ -629,6 +757,7 @@ void stat_noise_uv_mod_ivas_fx( } } } +#endif /*---------------------------------------------------------------------------* * calc_tilt() diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 73ff775af..508df7371 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1439,9 +1439,15 @@ ivas_error acelp_core_dec_fx( IF( NE_16( st->nelp_mode_dec, 1 ) ) { /* modify the excitation signal of stationary unvoiced frames */ +#ifdef HQ_ALIGN_DUPLICATED_CODE + stat_noise_uv_mod_fx( st->element_mode, st->coder_type, 0, st->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, &st->Q_exc, 1, &st->ge_sm_fx, + &st->uv_count, &st->act_count, st->lspold_s_fx, &st->noimix_seed, &st->min_alpha_fx, + &st->exc_pe_fx, st->core_brate, st->bwidth, &st->Q_stat_noise, &st->Q_stat_noise_ge ); +#else stat_noise_uv_mod_fx( st->coder_type, 0, st->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, st->Q_exc, 1, &st->ge_sm_fx, &st->uv_count, &st->act_count, st->lspold_s_fx, &st->noimix_seed, &st->min_alpha_fx, &st->exc_pe_fx, st->core_brate, st->bwidth, &st->Q_stat_noise, &st->Q_stat_noise_ge ); +#endif } } diff --git a/lib_dec/stat_noise_uv_dec_fx.c b/lib_dec/stat_noise_uv_dec_fx.c index 6972e4dd3..640624521 100644 --- a/lib_dec/stat_noise_uv_dec_fx.c +++ b/lib_dec/stat_noise_uv_dec_fx.c @@ -76,6 +76,13 @@ void stat_noise_uv_dec_fx( IF( !st_fx->Opt_AMR_WB ) { +#ifdef HQ_ALIGN_DUPLICATED_CODE + stat_noise_uv_mod_fx( st_fx->element_mode, coder_type, noisiness, st_fx->lsp_old_fx, lsp_new, lsp_mid, Aq, exc2, st_fx->Q_exc, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, + st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, + &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, + &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); + +#else IF( st_fx->element_mode > EVS_MONO ) { stat_noise_uv_mod_ivas_fx( coder_type, noisiness, st_fx->lsp_old_fx, lsp_new, lsp_mid, Aq, exc2, &st_fx->Q_exc, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, @@ -90,6 +97,7 @@ void stat_noise_uv_dec_fx( &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); } +#endif } diff --git a/lib_enc/ivas_decision_matrix_enc_fx.c b/lib_enc/ivas_decision_matrix_enc_fx.c index a6f5e7edb..4a3f9f54e 100644 --- a/lib_enc/ivas_decision_matrix_enc_fx.c +++ b/lib_enc/ivas_decision_matrix_enc_fx.c @@ -192,11 +192,7 @@ void ivas_decision_matrix_enc_fx( { /* select TCX core or HQ core using bits_frame_nominal to match the TCX configuration bitrate */ #ifdef HQ_ALIGN_DUPLICATED_CODE - st->core = mdct_classifier_fx( fft_buff, - st, - enerBuffer, - enerBuffer_exp, - L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ) ); /* Q0 */ + st->core = mdct_classifier_fx( fft_buff, st, enerBuffer, enerBuffer_exp, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ) ); /* Q0 */ #else st->core = mdct_classifier_ivas_fx( st, fft_buff, enerBuffer, enerBuffer_exp, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ) ); /* Q0 */ #endif diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c index 126e5cf8e..722e9b21f 100644 --- a/lib_enc/stat_noise_uv_enc_fx.c +++ b/lib_enc/stat_noise_uv_enc_fx.c @@ -97,9 +97,15 @@ void stat_noise_uv_enc_fx( * Modify the stationary noise excitation signal *-----------------------------------------------------------------*/ +#ifdef HQ_ALIGN_DUPLICATED_CODE + stat_noise_uv_mod_fx( st_fx->element_mode, st_fx->coder_type, noisiness, st_fx->lsp_old_fx, isp_new, isp_mid, Aq, exc2, &Q_new, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, + st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, &st_fx->exc_pe_fx, + st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); +#else stat_noise_uv_mod_fx( st_fx->coder_type, noisiness, st_fx->lsp_old_fx, isp_new, isp_mid, Aq, exc2, Q_new, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); +#endif return; @@ -167,9 +173,15 @@ void stat_noise_uv_enc_ivas_fx( * Modify the stationary noise excitation signal *-----------------------------------------------------------------*/ +#ifdef HQ_ALIGN_DUPLICATED_CODE + stat_noise_uv_mod_fx( st_fx->element_mode, st_fx->coder_type, noisiness, st_fx->lsp_old_fx, isp_new, isp_mid, Aq, exc2, Q_new, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, + st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, &st_fx->exc_pe_fx, + st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); +#else stat_noise_uv_mod_ivas_fx( st_fx->coder_type, noisiness, st_fx->lsp_old_fx, isp_new, isp_mid, Aq, exc2, Q_new, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); +#endif return; -- GitLab From 6df2d3a37388b3304a913923850189820298f8ba Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 6 Mar 2026 15:15:40 +0100 Subject: [PATCH 04/15] Update harmonization of mdct_classifier_fx --- lib_com/ivas_prot_fx.h | 3 +- lib_enc/ivas_decision_matrix_enc_fx.c | 10 +-- lib_enc/mdct_classifier_fx.c | 91 +++++++++++++++++++++++---- lib_enc/pre_proc_fx.c | 11 ++++ lib_enc/prot_fx_enc.h | 7 +-- 5 files changed, 94 insertions(+), 28 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 3a1717a77..1a7c6bf7a 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2720,7 +2720,7 @@ void ivas_param_mc_metadata_open_fx( const Word32 ivas_total_brate, /* i : IVAS total bitrate */ HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC /* o : handle for the Parametric MC parameter coding state */ ); -#ifndef HQ_ALIGN_DUPLICATED_CODE + Word16 mdct_classifier_ivas_fx( Encoder_State *st, /* i/o: Encoder state variable */ const Word16 *fft_buff, /* i : FFT spectrum from fft_rel */ @@ -2728,7 +2728,6 @@ Word16 mdct_classifier_ivas_fx( Word16 enerBuffer_exp, /* i: enenrgy buffer exponent */ const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ ); -#endif /*----------------------------------------------------------------------------------* * Range Coder prototypes diff --git a/lib_enc/ivas_decision_matrix_enc_fx.c b/lib_enc/ivas_decision_matrix_enc_fx.c index a6f5e7edb..6907c0e42 100644 --- a/lib_enc/ivas_decision_matrix_enc_fx.c +++ b/lib_enc/ivas_decision_matrix_enc_fx.c @@ -190,16 +190,8 @@ void ivas_decision_matrix_enc_fx( } ELSE { -/* select TCX core or HQ core using bits_frame_nominal to match the TCX configuration bitrate */ -#ifdef HQ_ALIGN_DUPLICATED_CODE - st->core = mdct_classifier_fx( fft_buff, - st, - enerBuffer, - enerBuffer_exp, - L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ) ); /* Q0 */ -#else + /* select TCX core or HQ core using bits_frame_nominal to match the TCX configuration bitrate */ st->core = mdct_classifier_ivas_fx( st, fft_buff, enerBuffer, enerBuffer_exp, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ) ); /* Q0 */ -#endif move16(); } } diff --git a/lib_enc/mdct_classifier_fx.c b/lib_enc/mdct_classifier_fx.c index d0b39e7b5..3d999538f 100644 --- a/lib_enc/mdct_classifier_fx.c +++ b/lib_enc/mdct_classifier_fx.c @@ -81,7 +81,7 @@ static void dft_mag_square_fx( return; } - +#ifndef HQ_ALIGN_DUPLICATED_CODE /*-------------------------------------------------------------------* * mdct_classifier() * @@ -91,15 +91,10 @@ static void dft_mag_square_fx( /* o: MDCT A/B decision */ Word16 mdct_classifier_fx( const Word16 *fft_buff, /* i : re[0], re[1], ..., re[n/2], im[n/2 - 1], im[n/2 - 2], ..., im[1] */ - Encoder_State *st_fx, /* i/o: Encoder state variable */ -#ifdef HQ_ALIGN_DUPLICATED_CODE - const Word32 *cldfbBuf_Ener, /* i : Sum array of energy values of CLDFB buffer */ - const Word16 enerBuffer_exp, /* i : Exponent of cldfbBuf_Ener */ -#else - Word32 *cldfbBuf_Ener, // enerBuffer_exp + Encoder_State *st_fx, /* i/o: Encoder state variable */ + Word32 *cldfbBuf_Ener, // enerBuffer_exp Word16 enerBuffer_exp, -#endif - const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ + const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ ) { Word16 c; @@ -509,7 +504,7 @@ Word16 mdct_classifier_fx( return clas_final; /* Q0 */ } -#ifndef HQ_ALIGN_DUPLICATED_CODE +#endif Word16 mdct_classifier_ivas_fx( Encoder_State *st, /* i/o: Encoder state variable */ const Word16 *fft_buff, /* i : FFT spectrum from fft_rel */ @@ -550,7 +545,11 @@ Word16 mdct_classifier_ivas_fx( move16(); test(); +#ifdef HQ_ALIGN_DUPLICATED_CODE + IF( EQ_32( st->input_Fs, 32000 ) || EQ_32( st->input_Fs, 48000 ) || EQ_16( st->element_mode, EVS_MONO ) ) +#else IF( EQ_32( st->input_Fs, 32000 ) || EQ_32( st->input_Fs, 48000 ) ) +#endif { gain2_start = GAIN2_START_SWB; gain3_start = GAIN3_START_SWB; @@ -764,6 +763,40 @@ Word16 mdct_classifier_ivas_fx( } } +#ifdef HQ_ALIGN_DUPLICATED_CODE + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + peak_H1 = L_add( enerBuffer[H1_start], 0 ); + Mpy_32_16_ss( enerBuffer[H1_start], 6554 /*0.4.Q15*/, &avrg_H1, &lsb16 ); + FOR( k = 1; k < 5; k++ ) + { + IF( GT_32( enerBuffer[H1_start + k], peak_H1 ) ) + { + peak_H1 = L_add( enerBuffer[H1_start + k], 0 ); + } + avrg_H1 = L_add( avrg_H1, Mult_32_16( enerBuffer[H1_start + k], 6554 /*0.4.Q15*/ ) ); + } + } + ELSE + { + // Todo (EN): This is introduced for IVAS, but looks strange + peak_H1 = enerBuffer[H1_start]; // enerBuffer_exp + move32(); + + avrg_H1 = enerBuffer[H1_start]; // enerBuffer_exp + move32(); + + FOR( i = 1; i < H_length; i++ ) + { + IF( GT_32( enerBuffer[H1_start + i], peak_H1 ) ) + { + peak_H1 = enerBuffer[H1_start + i]; // enerBuffer_exp + move32(); + } + avrg_H1 = L_add( avrg_H1, enerBuffer[H1_start + i] ); // enerBuffer_exp + } + } +#else peak_H1 = enerBuffer[H1_start]; // enerBuffer_exp move32(); @@ -779,7 +812,42 @@ Word16 mdct_classifier_ivas_fx( } avrg_H1 = L_add( avrg_H1, enerBuffer[H1_start + i] ); // enerBuffer_exp } +#endif +#ifdef HQ_ALIGN_DUPLICATED_CODE + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + peak_H2 = L_add( enerBuffer[H2_start], 0 ); + Mpy_32_16_ss( enerBuffer[H2_start], 6554 /*0.4.Q15*/, &avrg_H2, &lsb16 ); + FOR( i = 1; i < H_length; i++ ) + { + IF( GT_32( enerBuffer[H2_start + i], peak_H2 ) ) + { + peak_H2 = L_add( enerBuffer[H2_start + i], 0 ); + } + avrg_H2 = L_add( avrg_H2, Mult_32_16( enerBuffer[H2_start + i], 6554 /*0.4.Q15*/ ) ); + } + } + ELSE + { + // Todo (EN): This is introduced for IVAS, but looks strange + peak_H2 = enerBuffer[H2_start]; + move32(); + + avrg_H2 = enerBuffer[H2_start]; + move32(); + + FOR( i = 1; i < H_length; i++ ) + { + IF( GT_32( enerBuffer[H2_start + i], peak_H2 ) ) + { + peak_H2 = enerBuffer[H2_start + i]; + move32(); + } + avrg_H2 = L_add( avrg_H2, enerBuffer[H2_start + i] ); + } + } +#else peak_H2 = enerBuffer[H2_start]; move32(); @@ -795,7 +863,7 @@ Word16 mdct_classifier_ivas_fx( } avrg_H2 = L_add( avrg_H2, enerBuffer[H2_start + i] ); } - +#endif peak_l = L_deposit_l( 0 ); avrg_l = L_deposit_l( 0 ); peak_h = L_deposit_l( 0 ); @@ -1050,4 +1118,3 @@ Word16 mdct_classifier_ivas_fx( return clas_final; } -#endif diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 671fb4615..f4f3ffc0b 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -9,6 +9,9 @@ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ +#ifdef HQ_ALIGN_DUPLICATED_CODE +#include "ivas_prot_fx.h" +#endif /*-------------------------------------------------------------------* @@ -785,7 +788,11 @@ void pre_proc_fx( IF( ( EQ_16( st->bwidth, SWB ) || EQ_16( st->bwidth, FB ) ) && EQ_32( st->total_brate, ACELP_32k ) ) { /* Select MDCT Core */ +#ifdef HQ_ALIGN_DUPLICATED_CODE + st->core = mdct_classifier_ivas_fx( st, fft_buff, enerBuffer, sub( enerBuffer_exp, 31 ), st->total_brate ); +#else st->core = mdct_classifier_fx( fft_buff, st, enerBuffer, sub( enerBuffer_exp, 31 ), st->total_brate ); +#endif } test(); IF( ( EQ_32( st->total_brate, ACELP_13k20 ) ) && ( NE_16( st->bwidth, FB ) ) ) @@ -1226,7 +1233,11 @@ void pre_proc_fx( test(); IF( ( EQ_16( st->bwidth, SWB ) || EQ_16( st->bwidth, FB ) ) && EQ_32( st->total_brate, ACELP_24k40 ) ) { +#ifdef HQ_ALIGN_DUPLICATED_CODE + st->core = mdct_classifier_ivas_fx( st, fft_buff, enerBuffer, sub( enerBuffer_exp, 31 ), st->total_brate ); +#else st->core = mdct_classifier_fx( fft_buff, st, enerBuffer, sub( enerBuffer_exp, 31 ), st->total_brate ); +#endif } test(); IF( ( EQ_32( st->total_brate, ACELP_16k40 ) ) && ( NE_16( st->bwidth, FB ) ) ) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index cace60ece..5a2f0fabd 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -244,19 +244,16 @@ void ivas_long_enr_fx( const Word16 Etot_LR[] /* i : total channel energy LR channels Q=8*/ ); +#ifndef HQ_ALIGN_DUPLICATED_CODE /* o: MDCT A/B decision */ Word16 mdct_classifier_fx( const Word16 *Y, /* i : re[0], re[1], ..., re[n/2], im[n/2 - 1], im[n/2 - 2], ..., im[1] */ Encoder_State *st_fx, /* i/o: Encoder state variable */ -#ifdef HQ_ALIGN_DUPLICATED_CODE - const Word32 *cldfbBuf_Ener, /* i : Sum array of energy values of CLDFB buffer */ - const Word16 enerBuffer_exp, /* i : Exponent of cldfbBuf_Ener */ -#else Word32 *cldfbBuf_Ener, Word16 enerBuffer_exp, -#endif const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ ); +#endif void noise_est_down_fx( const Word32 fr_bands[], /* i : per band i energy (contains 2 vectors) */ -- GitLab From cf5fd923c7142c2188e1f94179b3ef8e160744ec Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 6 Mar 2026 17:08:16 +0100 Subject: [PATCH 05/15] Fix for mdct_classifier --- lib_enc/mdct_classifier_fx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib_enc/mdct_classifier_fx.c b/lib_enc/mdct_classifier_fx.c index 3d999538f..3efd19992 100644 --- a/lib_enc/mdct_classifier_fx.c +++ b/lib_enc/mdct_classifier_fx.c @@ -1084,7 +1084,12 @@ Word16 mdct_classifier_ivas_fx( test(); test(); test(); +#if 1 + test(); + if ( ( EQ_16( st->mdct_sw_enable, MODE2 ) || GT_16( st->element_mode, EVS_MONO ) ) && ( EQ_16( st->flag_noisy_speech_snr, 1 ) || st->vad_flag == 0 ) && EQ_16( clas_final, HQ_CORE ) ) +#else if ( EQ_16( st->mdct_sw_enable, MODE2 || st->element_mode > EVS_MONO ) && ( EQ_16( st->flag_noisy_speech_snr, 1 ) || st->vad_flag == 0 ) && EQ_16( clas_final, HQ_CORE ) ) +#endif { clas_final = TCX_20_CORE; move16(); -- GitLab From aaff1e7c11510fd4c5e9aa051bf5279a5e65bf8c Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 6 Mar 2026 18:06:48 +0100 Subject: [PATCH 06/15] Fix in mdct_classifier --- lib_enc/mdct_classifier_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/mdct_classifier_fx.c b/lib_enc/mdct_classifier_fx.c index 3efd19992..1c6ca77f8 100644 --- a/lib_enc/mdct_classifier_fx.c +++ b/lib_enc/mdct_classifier_fx.c @@ -1084,7 +1084,7 @@ Word16 mdct_classifier_ivas_fx( test(); test(); test(); -#if 1 +#ifdef HQ_ALIGN_DUPLICATED_CODE test(); if ( ( EQ_16( st->mdct_sw_enable, MODE2 ) || GT_16( st->element_mode, EVS_MONO ) ) && ( EQ_16( st->flag_noisy_speech_snr, 1 ) || st->vad_flag == 0 ) && EQ_16( clas_final, HQ_CORE ) ) #else -- GitLab From 2d356d9ca7ad8f3c96b8cbb6342374dd2178f556 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 6 Mar 2026 18:11:24 +0100 Subject: [PATCH 07/15] Fix call to stat_noise_uv_mod --- lib_dec/stat_noise_uv_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/stat_noise_uv_dec_fx.c b/lib_dec/stat_noise_uv_dec_fx.c index 640624521..ff8d8d1c1 100644 --- a/lib_dec/stat_noise_uv_dec_fx.c +++ b/lib_dec/stat_noise_uv_dec_fx.c @@ -77,7 +77,7 @@ void stat_noise_uv_dec_fx( IF( !st_fx->Opt_AMR_WB ) { #ifdef HQ_ALIGN_DUPLICATED_CODE - stat_noise_uv_mod_fx( st_fx->element_mode, coder_type, noisiness, st_fx->lsp_old_fx, lsp_new, lsp_mid, Aq, exc2, st_fx->Q_exc, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, + stat_noise_uv_mod_fx( st_fx->element_mode, coder_type, noisiness, st_fx->lsp_old_fx, lsp_new, lsp_mid, Aq, exc2, &st_fx->Q_exc, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); -- GitLab From ca1710e53c701840ae31a0a3b7b63f6ea5392dd8 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 6 Mar 2026 20:52:59 +0100 Subject: [PATCH 08/15] Clang format --- lib_com/stat_noise_uv_mod_fx.c | 12 ++++++------ lib_enc/mdct_classifier_fx.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_com/stat_noise_uv_mod_fx.c b/lib_com/stat_noise_uv_mod_fx.c index 2ff84c948..3c24980fa 100644 --- a/lib_com/stat_noise_uv_mod_fx.c +++ b/lib_com/stat_noise_uv_mod_fx.c @@ -302,7 +302,7 @@ void stat_noise_uv_mod_fx( tmp_shift = norm_s( tmp_den ); tmp_den = shl( tmp_den, tmp_shift ); tmp_res = div_s( tmp_nom, tmp_den ); - Noimix_fract = shr( tmp_res, tmp_shift ); /* float value is in range 0.0 to 0.42 */ + Noimix_fract = shr( tmp_res, tmp_shift ); /* float value is in range 0.0 to 0.42 */ #endif /* L_Ge might be 0 in unvoiced WB */ L_Ge = L_max( L_Ge, 1 ); @@ -323,8 +323,8 @@ void stat_noise_uv_mod_fx( L_Noimix_fract = Mult_32_16( L_tmp_res, Noimix_fract ); /*15+15-exp_sqr-15 =15-exp_sqr */ } #else - tmp_res = extract_h( L_shl_sat( L_tmp_res, 15 ) ); /* 15+15-16=14 */ - Noimix_fract = extract_l( Mult_32_16( L_tmp_res, Noimix_fract ) ); /*15+15-15 */ + tmp_res = extract_h( L_shl_sat( L_tmp_res, 15 ) ); /* 15+15-16=14 */ + Noimix_fract = extract_l( Mult_32_16( L_tmp_res, Noimix_fract ) ); /*15+15-15 */ #endif FOR( i = 0; i < L_FRAME; i++ ) @@ -362,9 +362,9 @@ void stat_noise_uv_mod_fx( move32(); } #else - L_tmp3 = Mult_32_16( L_tmp, Noimix_fract ); /* Q_local+16+15-15 */ - L_tmp = L_add_sat( L_tmp3, L_shl_sat( Mult_32_16( L_tmp, tmp_res ), 1 ) ); /* Q_local+16+14-15+1 */ - Exc2_local[i] = extract_h( L_tmp ); /*Q_local */ + L_tmp3 = Mult_32_16( L_tmp, Noimix_fract ); /* Q_local+16+15-15 */ + L_tmp = L_add_sat( L_tmp3, L_shl_sat( Mult_32_16( L_tmp, tmp_res ), 1 ) ); /* Q_local+16+14-15+1 */ + Exc2_local[i] = extract_h( L_tmp ); /*Q_local */ move16(); #endif } diff --git a/lib_enc/mdct_classifier_fx.c b/lib_enc/mdct_classifier_fx.c index 1c6ca77f8..ce3f60997 100644 --- a/lib_enc/mdct_classifier_fx.c +++ b/lib_enc/mdct_classifier_fx.c @@ -1087,7 +1087,7 @@ Word16 mdct_classifier_ivas_fx( #ifdef HQ_ALIGN_DUPLICATED_CODE test(); if ( ( EQ_16( st->mdct_sw_enable, MODE2 ) || GT_16( st->element_mode, EVS_MONO ) ) && ( EQ_16( st->flag_noisy_speech_snr, 1 ) || st->vad_flag == 0 ) && EQ_16( clas_final, HQ_CORE ) ) -#else +#else if ( EQ_16( st->mdct_sw_enable, MODE2 || st->element_mode > EVS_MONO ) && ( EQ_16( st->flag_noisy_speech_snr, 1 ) || st->vad_flag == 0 ) && EQ_16( clas_final, HQ_CORE ) ) #endif { -- GitLab From caaef3a77d3a7abb362a3a5fddbe498145e3d354 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 6 Mar 2026 22:59:54 +0100 Subject: [PATCH 09/15] Cleanup --- lib_com/ivas_prot_fx.h | 6 ++++-- lib_enc/ivas_decision_matrix_enc_fx.c | 4 ++++ lib_enc/mdct_classifier_fx.c | 11 +++++++---- lib_enc/pre_proc_fx.c | 4 ++-- lib_enc/prot_fx_enc.h | 10 +++++++++- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 1a7c6bf7a..0b5f2eb86 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2721,13 +2721,15 @@ void ivas_param_mc_metadata_open_fx( HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC /* o : handle for the Parametric MC parameter coding state */ ); +#ifndef HQ_ALIGN_DUPLICATED_CODE Word16 mdct_classifier_ivas_fx( Encoder_State *st, /* i/o: Encoder state variable */ const Word16 *fft_buff, /* i : FFT spectrum from fft_rel */ const Word32 enerBuffer[], /* i : energy buffer */ - Word16 enerBuffer_exp, /* i: enenrgy buffer exponent */ + Word16 enerBuffer_exp, /* i : energy buffer exponent */ const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ ); +#endif /*----------------------------------------------------------------------------------* * Range Coder prototypes @@ -6730,5 +6732,5 @@ ivas_error ivas_fb_set_cfg( const Word16 nachan_dirac_ana /* i : number of DirAR analysis channels */ ); -/* clang-format on */ + /* clang-format on */ #endif diff --git a/lib_enc/ivas_decision_matrix_enc_fx.c b/lib_enc/ivas_decision_matrix_enc_fx.c index 6907c0e42..adb69a988 100644 --- a/lib_enc/ivas_decision_matrix_enc_fx.c +++ b/lib_enc/ivas_decision_matrix_enc_fx.c @@ -191,7 +191,11 @@ void ivas_decision_matrix_enc_fx( ELSE { /* select TCX core or HQ core using bits_frame_nominal to match the TCX configuration bitrate */ +#ifdef HQ_ALIGN_DUPLICATED_CODE + st->core = mdct_classifier_fx( st, fft_buff, enerBuffer, enerBuffer_exp, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ) ); /* Q0 */ +#else st->core = mdct_classifier_ivas_fx( st, fft_buff, enerBuffer, enerBuffer_exp, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ) ); /* Q0 */ +#endif move16(); } } diff --git a/lib_enc/mdct_classifier_fx.c b/lib_enc/mdct_classifier_fx.c index ce3f60997..8c1f697bf 100644 --- a/lib_enc/mdct_classifier_fx.c +++ b/lib_enc/mdct_classifier_fx.c @@ -9,7 +9,6 @@ #include "rom_com.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ -#include "prot_fx_enc.h" /* Function prototypes */ #include "ivas_prot_fx.h" /* Function prototypes */ /*--------------------------------------------------------------------------* @@ -505,12 +504,16 @@ Word16 mdct_classifier_fx( return clas_final; /* Q0 */ } #endif +#ifdef HQ_ALIGN_DUPLICATED_CODE +Word16 mdct_classifier_fx( +#else Word16 mdct_classifier_ivas_fx( +#endif Encoder_State *st, /* i/o: Encoder state variable */ const Word16 *fft_buff, /* i : FFT spectrum from fft_rel */ - const Word32 enerBuffer[], /* i : energy buffer enerBuffer_exp*/ - Word16 enerBuffer_exp, - const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ + const Word32 enerBuffer[], /* i : energy buffer */ + Word16 enerBuffer_exp, /* i : energy buffer exponent */ + const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ ) { Word16 c; diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index f4f3ffc0b..868428e01 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -789,7 +789,7 @@ void pre_proc_fx( { /* Select MDCT Core */ #ifdef HQ_ALIGN_DUPLICATED_CODE - st->core = mdct_classifier_ivas_fx( st, fft_buff, enerBuffer, sub( enerBuffer_exp, 31 ), st->total_brate ); + st->core = mdct_classifier_fx( st, fft_buff, enerBuffer, sub( enerBuffer_exp, 31 ), st->total_brate ); #else st->core = mdct_classifier_fx( fft_buff, st, enerBuffer, sub( enerBuffer_exp, 31 ), st->total_brate ); #endif @@ -1234,7 +1234,7 @@ void pre_proc_fx( IF( ( EQ_16( st->bwidth, SWB ) || EQ_16( st->bwidth, FB ) ) && EQ_32( st->total_brate, ACELP_24k40 ) ) { #ifdef HQ_ALIGN_DUPLICATED_CODE - st->core = mdct_classifier_ivas_fx( st, fft_buff, enerBuffer, sub( enerBuffer_exp, 31 ), st->total_brate ); + st->core = mdct_classifier_fx( st, fft_buff, enerBuffer, sub( enerBuffer_exp, 31 ), st->total_brate ); #else st->core = mdct_classifier_fx( fft_buff, st, enerBuffer, sub( enerBuffer_exp, 31 ), st->total_brate ); #endif diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 5a2f0fabd..fd8469174 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -244,7 +244,15 @@ void ivas_long_enr_fx( const Word16 Etot_LR[] /* i : total channel energy LR channels Q=8*/ ); -#ifndef HQ_ALIGN_DUPLICATED_CODE +#ifdef HQ_ALIGN_DUPLICATED_CODE +Word16 mdct_classifier_fx( + Encoder_State *st, /* i/o: Encoder state variable */ + const Word16 *fft_buff, /* i : FFT spectrum from fft_rel */ + const Word32 enerBuffer[], /* i : energy buffer */ + Word16 enerBuffer_exp, /* i : energy buffer exponent */ + const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ +); +#else /* o: MDCT A/B decision */ Word16 mdct_classifier_fx( const Word16 *Y, /* i : re[0], re[1], ..., re[n/2], im[n/2 - 1], im[n/2 - 2], ..., im[1] */ -- GitLab From 3e649560a18dac5e0253bd9b9bd4253cd77d8af1 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 6 Mar 2026 23:01:30 +0100 Subject: [PATCH 10/15] Clang format --- lib_com/ivas_prot_fx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 0b5f2eb86..2befd8c8e 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -6732,5 +6732,5 @@ ivas_error ivas_fb_set_cfg( const Word16 nachan_dirac_ana /* i : number of DirAR analysis channels */ ); - /* clang-format on */ +/* clang-format on */ #endif -- GitLab From cd7b55e2cdca78e7c7e4aa9694adaf24855f6c9d Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 6 Mar 2026 23:12:27 +0100 Subject: [PATCH 11/15] Remove stat_noise_uv_enc_ivas_fx --- lib_enc/acelp_core_enc_fx.c | 4 ++++ lib_enc/prot_fx_enc.h | 3 ++- lib_enc/stat_noise_uv_enc_fx.c | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 2168e0e3a..42135df48 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -843,7 +843,11 @@ ivas_error acelp_core_enc_fx( Copy( exc_fx, exc2_fx, st->L_frame ); // Q_new Word16 q_exc2 = Q_new; move16(); +#ifdef HQ_ALIGN_DUPLICATED_CODE + stat_noise_uv_enc_fx( st, epsP, lsp_new, lsp_mid, Aq, exc2_fx, uc_two_stage_flag, &q_exc2 ); +#else stat_noise_uv_enc_ivas_fx( st, epsP, lsp_new, lsp_mid, Aq, exc2_fx, uc_two_stage_flag, &q_exc2 ); +#endif } } diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index fd8469174..25dc40ee3 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1838,7 +1838,7 @@ void stat_noise_uv_enc_fx( Word16 *exc2, /* i/o: excitation buffer */ const Word16 uc_two_stage_flag, /* o : flag undicating two-stage UC */ Word16 Q_new ); - +#ifndef HQ_ALIGN_DUPLICATED_CODE void stat_noise_uv_enc_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word32 *LepsP, /* i : LP prediction errors Q=Qx*/ @@ -1848,6 +1848,7 @@ void stat_noise_uv_enc_ivas_fx( Word16 *exc2, /* i/o: excitation buffer Q=Q_stat_noise */ const Word16 uc_two_stage_flag, /* o : flag undicating two-stage UC */ Word16 *Q_new ); +#endif void analy_sp_fx( const Word16 element_mode, /* i : element mode */ diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c index 722e9b21f..add17515d 100644 --- a/lib_enc/stat_noise_uv_enc_fx.c +++ b/lib_enc/stat_noise_uv_enc_fx.c @@ -111,7 +111,7 @@ void stat_noise_uv_enc_fx( return; } - +#ifndef HQ_ALIGN_DUPLICATED_CODE void stat_noise_uv_enc_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word32 *LepsP, /* i : LP prediction errors Q=Qx*/ @@ -186,3 +186,4 @@ void stat_noise_uv_enc_ivas_fx( return; } +#endif -- GitLab From e516d98965e69e8bb485e8cf4ef9607626466fb3 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Sat, 7 Mar 2026 10:37:19 +0100 Subject: [PATCH 12/15] Correction of call to stat_noise_uv_enc_fx --- lib_enc/acelp_core_enc_fx.c | 5 +++++ lib_enc/prot_fx_enc.h | 13 +++++++++++++ lib_enc/stat_noise_uv_enc_fx.c | 15 ++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 42135df48..992652603 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -829,7 +829,12 @@ ivas_error acelp_core_enc_fx( IF( NE_16( nelp_mode, 1 ) ) { Copy( exc_fx, exc2_fx, st->L_frame ); // Q_new +#ifdef HQ_ALIGN_DUPLICATED_CODE + Word16 q_exc2 = Q_new; + stat_noise_uv_enc_fx( st, epsP, lsp_new, lsp_mid, Aq, exc2_fx, uc_two_stage_flag, &q_exc2 ); +#else stat_noise_uv_enc_fx( st, epsP, lsp_new, lsp_mid, Aq, exc2_fx, uc_two_stage_flag, Q_new ); +#endif } } ELSE diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 25dc40ee3..c6e020c1b 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1829,6 +1829,18 @@ void encod_audio_fx( const Word16 shift /* i : Shift needed to obtain 12 bits vectors */ ); +#ifdef HQ_ALIGN_DUPLICATED_CODE +void stat_noise_uv_enc_fx( + Encoder_State *st_fx, /* i/o: state structure */ + const Word32 *LepsP, /* i : LP prediction errors */ + const Word16 *isp_new, /* i : immittance spectral pairs at 4th sfr */ + const Word16 *isp_mid, /* i : immittance spectral pairs at 2nd sfr */ + Word16 *Aq, /* i : A(z) quantized for the 4 subframes */ + Word16 *exc2, /* i/o: excitation buffer */ + const Word16 uc_two_stage_flag, /* o : flag indicating two-stage UC */ + Word16 *Q_new +); +#else void stat_noise_uv_enc_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word32 *LepsP, /* i : LP prediction errors */ @@ -1838,6 +1850,7 @@ void stat_noise_uv_enc_fx( Word16 *exc2, /* i/o: excitation buffer */ const Word16 uc_two_stage_flag, /* o : flag undicating two-stage UC */ Word16 Q_new ); +#endif #ifndef HQ_ALIGN_DUPLICATED_CODE void stat_noise_uv_enc_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c index add17515d..e013ef92b 100644 --- a/lib_enc/stat_noise_uv_enc_fx.c +++ b/lib_enc/stat_noise_uv_enc_fx.c @@ -36,6 +36,18 @@ /* _ None */ /*=======================================================================*/ +#ifdef HQ_ALIGN_DUPLICATED_CODE +void stat_noise_uv_enc_fx( + Encoder_State *st_fx, /* i/o: state structure */ + const Word32 *LepsP, /* i : LP prediction errors */ + const Word16 *isp_new, /* i : immittance spectral pairs at 4th sfr */ + const Word16 *isp_mid, /* i : immittance spectral pairs at 2nd sfr */ + Word16 *Aq, /* i : A(z) quantized for the 4 subframes */ + Word16 *exc2, /* i/o: excitation buffer */ + const Word16 uc_two_stage_flag, /* o : flag indicating two-stage UC */ + Word16 *Q_new +) +#else void stat_noise_uv_enc_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word32 *LepsP, /* i : LP prediction errors */ @@ -45,6 +57,7 @@ void stat_noise_uv_enc_fx( Word16 *exc2, /* i/o: excitation buffer */ const Word16 uc_two_stage_flag, /* o : flag undicating two-stage UC */ Word16 Q_new ) +#endif { Word16 noisiness = 0; move16(); @@ -98,7 +111,7 @@ void stat_noise_uv_enc_fx( *-----------------------------------------------------------------*/ #ifdef HQ_ALIGN_DUPLICATED_CODE - stat_noise_uv_mod_fx( st_fx->element_mode, st_fx->coder_type, noisiness, st_fx->lsp_old_fx, isp_new, isp_mid, Aq, exc2, &Q_new, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, + stat_noise_uv_mod_fx( st_fx->element_mode, st_fx->coder_type, noisiness, st_fx->lsp_old_fx, isp_new, isp_mid, Aq, exc2, Q_new, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); #else -- GitLab From 1cbf543634bf0ee3b2e9020f0079fb0973558c0c Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Sat, 7 Mar 2026 10:39:38 +0100 Subject: [PATCH 13/15] Clang format --- lib_enc/prot_fx_enc.h | 3 +-- lib_enc/stat_noise_uv_enc_fx.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index c6e020c1b..067a73282 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1838,8 +1838,7 @@ void stat_noise_uv_enc_fx( Word16 *Aq, /* i : A(z) quantized for the 4 subframes */ Word16 *exc2, /* i/o: excitation buffer */ const Word16 uc_two_stage_flag, /* o : flag indicating two-stage UC */ - Word16 *Q_new -); + Word16 *Q_new ); #else void stat_noise_uv_enc_fx( Encoder_State *st_fx, /* i/o: state structure */ diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c index e013ef92b..07d124ece 100644 --- a/lib_enc/stat_noise_uv_enc_fx.c +++ b/lib_enc/stat_noise_uv_enc_fx.c @@ -45,8 +45,7 @@ void stat_noise_uv_enc_fx( Word16 *Aq, /* i : A(z) quantized for the 4 subframes */ Word16 *exc2, /* i/o: excitation buffer */ const Word16 uc_two_stage_flag, /* o : flag indicating two-stage UC */ - Word16 *Q_new -) + Word16 *Q_new ) #else void stat_noise_uv_enc_fx( Encoder_State *st_fx, /* i/o: state structure */ -- GitLab From 9c1feeabc47974b73ad4f6f595082ba3cc3b5a2d Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 9 Mar 2026 06:56:39 +0100 Subject: [PATCH 14/15] Remove unused fft3_fx_ivas/ifft3_fx_ivas --- lib_com/fft_fx.c | 3 ++- lib_com/prot_fx.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c index 2cd92db53..97fef62e5 100644 --- a/lib_com/fft_fx.c +++ b/lib_com/fft_fx.c @@ -2791,6 +2791,7 @@ void DoRTFTn_fx_ivas( return; } +#ifndef HQ_ALIGN_DUPLICATED_CODE void fft3_fx_ivas( const Word32 X[], // Qx Word32 Y[], // Qx @@ -3287,7 +3288,7 @@ void ifft3_fx_ivas( return; } - +#endif static void rfft_post( const Word16 *sine_table, // Q15 diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 345b4eae4..225919397 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -4292,7 +4292,7 @@ void ifft3_fx( const Word16[], Word16[], const Word16 ); - +#ifndef HQ_ALIGN_DUPLICATED_CODE void fft3_fx_ivas( const Word32 X[], Word32 Y[], @@ -4301,6 +4301,7 @@ void ifft3_fx_ivas( const Word32 X[], Word32 Y[], const Word16 n ); +#endif void r_fft_fx_lc( const Word16 *phs_tbl, /* i : Table of phase */ -- GitLab From d0e2254840fff82436e8a6d0e48476e228d8a44e Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 9 Mar 2026 15:50:06 +0100 Subject: [PATCH 15/15] Address review comments --- lib_com/stat_noise_uv_mod_fx.c | 1 + lib_enc/pre_proc_fx.c | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib_com/stat_noise_uv_mod_fx.c b/lib_com/stat_noise_uv_mod_fx.c index 3c24980fa..7db32531a 100644 --- a/lib_com/stat_noise_uv_mod_fx.c +++ b/lib_com/stat_noise_uv_mod_fx.c @@ -116,6 +116,7 @@ void stat_noise_uv_mod_fx( move16(); #ifdef HQ_ALIGN_DUPLICATED_CODE L_Noimix_fract = 0; + move32(); #endif test(); diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 868428e01..1ffbd2561 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -9,9 +9,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ -#ifdef HQ_ALIGN_DUPLICATED_CODE -#include "ivas_prot_fx.h" -#endif /*-------------------------------------------------------------------* -- GitLab