From 24a16072958365c020eeb1e1b010ee3a8a1717c1 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 15 Jul 2025 14:55:18 +0530 Subject: [PATCH] Fix for 3GPP issue 1778: Different codebook precision at encoder and decoder for McMASA and MASA Link #1778 Combined McMASA_LFEGain_vectors_fx_q13 and McMASA_LFEGain_vectors_fx_q25 into McMASA_LFEGain_vectors_fx maintained in Q25. --- lib_com/ivas_rom_com_fx.c | 14 +------------- lib_com/ivas_rom_com_fx.h | 3 +-- lib_dec/ivas_masa_dec_fx.c | 10 +++++----- lib_enc/ivas_masa_enc_fx.c | 2 +- 4 files changed, 8 insertions(+), 21 deletions(-) diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c index 1cfe1ff6c..b64ac5635 100644 --- a/lib_com/ivas_rom_com_fx.c +++ b/lib_com/ivas_rom_com_fx.c @@ -483,20 +483,8 @@ const Word32 dft_res_gains_q_fx[][2] = { }; -// Q13 -const Word16 McMASA_LFEGain_vectors_fx_q13[64] = { - 3113, 2703, 1556, 1638, -1311, -1802, -2867, -2785, - 4096, 4096, 4096, 4096, -6554, -3277, 8356, 819, - -4096, -4096, -4096, -4096, -4588, -983, -6390, 11141, - -8356, 9667, -4669, 2703, 5898, -9257, 7946, -5079, - -7455, 7619, 8192, -9011, 14172, -1884, -6390, -6881, - 7782, -13107, -2785, 7619, 7127, 3850, -15565, 4260, - 5489, 11633, -7946, -10158, 6799, 4751, 4997, -16712, - -6554, -12943, 6717, 11633, -17531, 2130, 6881, 8356 -}; - // Q25 -const Word32 McMASA_LFEGain_vectors_fx_q25[64] = { +const Word32 McMASA_LFEGain_vectors_fx[64] = { 12750684, 11072963, 6375342, 6710886, /* 1st bit */ -5368709, -7381975, -11744051, -11408507, 16777216, 16777216, 16777216, 16777216, /* 2nd bit*/ diff --git a/lib_com/ivas_rom_com_fx.h b/lib_com/ivas_rom_com_fx.h index 3344a35d2..2619a3f26 100644 --- a/lib_com/ivas_rom_com_fx.h +++ b/lib_com/ivas_rom_com_fx.h @@ -56,8 +56,7 @@ extern const Word16 dft_trigo_12k8_fx[STEREO_DFT_N_12k8_ENC / 4 + 1]; extern const Word16 dft_trigo_32k_fx[STEREO_DFT_N_32k_ENC / 4 + 1]; extern const Word16 dft_trigo_48k_fx[STEREO_DFT_N_MAX_ENC / 4 + 1]; extern const Word16 gridEq_Table[NO_THETA16_MAX]; -extern const Word16 McMASA_LFEGain_vectors_fx_q13[64]; -extern const Word32 McMASA_LFEGain_vectors_fx_q25[64]; +extern const Word32 McMASA_LFEGain_vectors_fx[64]; /* Q25 */ extern const Word16 ivas_divde_255[256]; diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 457c040c3..6363bdf74 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -1533,11 +1533,11 @@ static Word16 decode_lfe_to_total_energy_ratio_fx( } ELSE { - tmp16 = shr( McMASA_LFEGain_vectors_fx_q13[4 * lfeToTotalEnergyRatioIndices[2] + i], 1 ); /* Q12 */ - tmp16 = add( log2LFEaverage_fx, tmp16 ); /* Q12 */ - tmp32 = BASOP_util_Pow2( L_deposit_h( tmp16 ), 15 - Q12, &exp ); /* Q(31 - exp) */ - tmp16 = round_fx( tmp32 ); /* Q(31-exp) -> Q(15 - exp) */ - hMasaLfeSynth->lfeToTotalEnergyRatio_fx[i] = shr_sat( tmp16, sub( 1, exp ) ); /* should saturate. Q(15 - exp) - (1 - exp) -> Q14 */ + tmp16 = shr( extract_l( L_shr_r( McMASA_LFEGain_vectors_fx[4 * lfeToTotalEnergyRatioIndices[2] + i], Q12 ) ), 1 ); /* Q12 */ + tmp16 = add( log2LFEaverage_fx, tmp16 ); /* Q12 */ + tmp32 = BASOP_util_Pow2( L_deposit_h( tmp16 ), 15 - Q12, &exp ); /* Q(31 - exp) */ + tmp16 = round_fx( tmp32 ); /* Q(31-exp) -> Q(15 - exp) */ + hMasaLfeSynth->lfeToTotalEnergyRatio_fx[i] = shr_sat( tmp16, sub( 1, exp ) ); /* should saturate. Q(15 - exp) - (1 - exp) -> Q14 */ move16(); } diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 35c57c42b..b87bcf88b 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -2842,7 +2842,7 @@ static Word16 encode_lfe_to_total_energy_ratio_fx( IF( VQLevels > 0 ) { - lfeToTotalEnergyRatioIndices[2] = vquant_ivas_fx( log2LFEratio, 0, xqv, McMASA_LFEGain_vectors_fx_q25, 4, VQLevels ); + lfeToTotalEnergyRatioIndices[2] = vquant_ivas_fx( log2LFEratio, 0, xqv, McMASA_LFEGain_vectors_fx, 4, VQLevels ); move16(); } } -- GitLab