From b0b3dce18289e7e62a94a10d3d6b0a57893fdb1d Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 20 Mar 2026 09:38:13 +0100 Subject: [PATCH] Remove HARM_HQ_CORE_KEEP_BE in fine_gain_pred_fx --- lib_com/low_rate_band_att_fx.c | 38 +++++++++++++++++++++++----------- lib_com/options.h | 2 +- lib_com/prot_fx.h | 26 ++++++++++++----------- lib_dec/peak_vq_dec_fx.c | 5 +++++ lib_dec/pvq_core_dec_fx.c | 5 +++++ lib_enc/peak_vq_enc_fx.c | 5 +++++ lib_enc/pvq_core_enc_fx.c | 5 +++++ 7 files changed, 61 insertions(+), 25 deletions(-) diff --git a/lib_com/low_rate_band_att_fx.c b/lib_com/low_rate_band_att_fx.c index aeb46f87c..4319d51ee 100644 --- a/lib_com/low_rate_band_att_fx.c +++ b/lib_com/low_rate_band_att_fx.c @@ -16,19 +16,21 @@ *--------------------------------------------------------------------------*/ void fine_gain_pred_fx( - const Word16 *sfm_start, /* i : Sub band start indices */ - const Word16 *sfm_end, /* i : Sub band end indices */ - const Word16 *sfm_size, /* i : Sub band bandwidths */ - const Word16 *i_sort, /* i : Energy sorting indices */ - const Word16 *K, /* i : Number of pulses per band */ - const Word16 *maxpulse, /* i : Maximum pulse per band */ - const Word16 *R, /* i : Bits per sub band Q3 */ - const Word16 num_sfm, /* i : Number of sub bands */ - Word16 *xq, /* i/o: Quantized vector /quantized vector with finegain adj Q15*/ - Word16 *y, /* i/o: Quantized vector (int) Q0 */ - Word16 *fg_pred, /* o : Predicted fine gains Q12 */ + const Word16 *sfm_start, /* i : Sub band start indices */ + const Word16 *sfm_end, /* i : Sub band end indices */ + const Word16 *sfm_size, /* i : Sub band bandwidths */ + const Word16 *i_sort, /* i : Energy sorting indices */ + const Word16 *K, /* i : Number of pulses per band */ + const Word16 *maxpulse, /* i : Maximum pulse per band */ + const Word16 *R, /* i : Bits per sub band Q3 */ + const Word16 num_sfm, /* i : Number of sub bands */ + Word16 *xq, /* i/o: Quantized vector /quantized vector with finegain adj Q15*/ + Word16 *y, /* i/o: Quantized vector (int) Q0 */ + Word16 *fg_pred, /* o : Predicted fine gains Q12 */ +#ifndef FIX_BASOP_2486_HQ_FINE_GAIN_ALIGNMENT const Word16 element_mode, /* i : element mode */ - const Word16 core /* i : Core */ +#endif + const Word16 core /* i : Core */ ) { Word16 i, band; @@ -74,6 +76,17 @@ void fine_gain_pred_fx( exp = sub( 31, add( exp, sub( 30, shl( shift, 1 ) ) ) ); L_tmp = Isqrt_lc( L_tmp, &exp ); /*31 - exp */ +#ifdef FIX_BASOP_2486_HQ_FINE_GAIN_ALIGNMENT + IF( EQ_16( sfm_size[0], 10 ) ) /* If sfm_size[0] is 10, it means the extended ACELP->HQ transition frame is used. See hq_configure_fx(). */ + { + bw_idx = band_len_idx_ext[shr( bw, 3 )]; + tmp1 = fine_gain_pred_sqrt_bw_ext[bw_idx]; + } + ELSE + { + tmp1 = fine_gain_pred_sqrt_bw[bw_idx]; + } +#else IF( element_mode == EVS_MONO ) { tmp1 = fine_gain_pred_sqrt_bw[bw_idx]; @@ -96,6 +109,7 @@ void fine_gain_pred_fx( #endif } } +#endif Mpy_32_16_ss( L_tmp, tmp1, &L_tmp, &lsb ); /*31-exp+11-15=27-exp */ gp = round_fx_sat( L_shl_sat( L_tmp, add( 1, exp ) ) ); /*27-exp+1+exp-16=12 */ test(); diff --git a/lib_com/options.h b/lib_com/options.h index eb5d8a66e..2b7163773 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -98,7 +98,7 @@ #define FIX_BASOP_2451_HQ_FEC_SELECTOR /* Eri: Resolve basop issue 2451, wrong condition on env_stab_plc_fx */ #define FIX_2398_PRECISSION_ORIENTATION_TRACKING /* FhG: use refinement of Sqrt32 within certain functions*/ - +#define FIX_BASOP_2486_HQ_FINE_GAIN_ALIGNMENT /* Eri: Basop issue 2486: IVAS BASOP used calculations with truncation, EVS BASOP used rounding. This aligns the use of a table lookup. */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index de383d0a7..02cc7f06d 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -4409,19 +4409,21 @@ void longshr( Word16 len ); void fine_gain_pred_fx( - const Word16 *sfm_start, /* i : Sub band start indices */ - const Word16 *sfm_end, /* i : Sub band end indices */ - const Word16 *sfm_size, /* i : Sub band bandwidths */ - const Word16 *i_sort, /* i : Energy sorting indices */ - const Word16 *K, /* i : Number of pulses per band */ - const Word16 *maxpulse, /* i : Maximum pulse per band */ - const Word16 *R, /* i : Bits per sub band Q3 */ - const Word16 num_sfm, /* i : Number of sub bands */ - Word16 *xq, /* i/o: Quantized vector /quantized vector with finegain adj Q15*/ - Word16 *y, /* i/o: Quantized vector (int) */ - Word16 *fg_pred, /* o : Predicted fine gains Q12 */ + const Word16 *sfm_start, /* i : Sub band start indices */ + const Word16 *sfm_end, /* i : Sub band end indices */ + const Word16 *sfm_size, /* i : Sub band bandwidths */ + const Word16 *i_sort, /* i : Energy sorting indices */ + const Word16 *K, /* i : Number of pulses per band */ + const Word16 *maxpulse, /* i : Maximum pulse per band */ + const Word16 *R, /* i : Bits per sub band Q3 */ + const Word16 num_sfm, /* i : Number of sub bands */ + Word16 *xq, /* i/o: Quantized vector /quantized vector with finegain adj Q15*/ + Word16 *y, /* i/o: Quantized vector (int) */ + Word16 *fg_pred, /* o : Predicted fine gains Q12 */ +#ifndef FIX_BASOP_2486_HQ_FINE_GAIN_ALIGNMENT const Word16 element_mode, /* i : element mode */ - const Word16 core /* i : Core */ +#endif + const Word16 core /* i : Core */ ); void fine_gain_quant_fx( diff --git a/lib_dec/peak_vq_dec_fx.c b/lib_dec/peak_vq_dec_fx.c index e89f8db27..f345c61ee 100644 --- a/lib_dec/peak_vq_dec_fx.c +++ b/lib_dec/peak_vq_dec_fx.c @@ -321,8 +321,13 @@ static void peak_vq_dec_fx( pvq_decode_frame_fx( st_fx, pvq_vector, npulses, pvq_inp_vector, hvq_band_start, hvq_band_end, hvq_band_width, pvq_bands, Rk, pvq_bits, core ); +#ifdef FIX_BASOP_2486_HQ_FINE_GAIN_ALIGNMENT + fine_gain_pred_fx( hvq_band_start, hvq_band_end, hvq_band_width, k_sort, npulses, pvq_maxpulse, NULL, + pvq_bands, pvq_vector, pvq_inp_vector, fg_pred, core ); +#else fine_gain_pred_fx( hvq_band_start, hvq_band_end, hvq_band_width, k_sort, npulses, pvq_maxpulse, NULL, pvq_bands, pvq_vector, pvq_inp_vector, fg_pred, st_fx->element_mode, core ); +#endif fine_gain_dec_fx( st_fx, k_sort, pvq_bands, gain_bits_array, fg_pred ); diff --git a/lib_dec/pvq_core_dec_fx.c b/lib_dec/pvq_core_dec_fx.c index a787b376d..1d02cb818 100644 --- a/lib_dec/pvq_core_dec_fx.c +++ b/lib_dec/pvq_core_dec_fx.c @@ -277,8 +277,13 @@ Word16 pvq_core_dec_fx( get_max_pulses_fx( sfm_start, sfm_end, ord, npulses, nb_sfm, pulse_vector, maxpulse ); +#ifdef FIX_BASOP_2486_HQ_FINE_GAIN_ALIGNMENT + fine_gain_pred_fx( sfm_start, sfm_end, sfmsize, ord, npulses, maxpulse, R, + nb_sfm, coefs_quant, pulse_vector, fg_pred, core ); +#else fine_gain_pred_fx( sfm_start, sfm_end, sfmsize, ord, npulses, maxpulse, R, nb_sfm, coefs_quant, pulse_vector, fg_pred, st_fx->element_mode, core ); +#endif fine_gain_dec_fx( st_fx, ord, nb_sfm, gain_bits_array, fg_pred ); IF( st_fx->hHQ_core != NULL ) diff --git a/lib_enc/peak_vq_enc_fx.c b/lib_enc/peak_vq_enc_fx.c index 6e72486f1..6d7208bb8 100644 --- a/lib_enc/peak_vq_enc_fx.c +++ b/lib_enc/peak_vq_enc_fx.c @@ -402,8 +402,13 @@ Word16 peak_vq_enc_fx( move16(); } +#ifdef FIX_BASOP_2486_HQ_FINE_GAIN_ALIGNMENT + fine_gain_pred_fx( hvq_band_start, hvq_band_end, hvq_band_width, k_sort, npulses, NULL, NULL, pvq_bands, coefs_pvq, + pvq_inp_vector, fg_pred, HQ_CORE ); +#else fine_gain_pred_fx( hvq_band_start, hvq_band_end, hvq_band_width, k_sort, npulses, NULL, NULL, pvq_bands, coefs_pvq, pvq_inp_vector, fg_pred, element_mode, HQ_CORE ); +#endif pCoefsOut = &coefs_out[0]; pSelBnds = &sel_bnds[0]; diff --git a/lib_enc/pvq_core_enc_fx.c b/lib_enc/pvq_core_enc_fx.c index da8247321..23f3bcb58 100644 --- a/lib_enc/pvq_core_enc_fx.c +++ b/lib_enc/pvq_core_enc_fx.c @@ -323,8 +323,13 @@ Word16 pvq_core_enc_fx( get_max_pulses_fx( sfm_start, sfm_end, ord, npulses, nb_sfm, pulse_vector, maxpulse ); /* Fine gain prediction */ +#ifdef FIX_BASOP_2486_HQ_FINE_GAIN_ALIGNMENT + fine_gain_pred_fx( sfm_start, sfm_end, sfmsize, ord, npulses, maxpulse, R, nb_sfm, + coefs_quant, pulse_vector, fg_pred, core ); +#else fine_gain_pred_fx( sfm_start, sfm_end, sfmsize, ord, npulses, maxpulse, R, nb_sfm, coefs_quant, pulse_vector, fg_pred, element_mode, core ); +#endif fine_gain_quant_fx( hBstr, ord, nb_sfm, gain_bits_array, fg_pred, gopt ); -- GitLab