From cf1db1c57390b424eb7c5e0e2f0dcde6892ca068 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 28 May 2025 13:53:18 +0530 Subject: [PATCH 1/2] Fix for 3GPP issue 1267: High MLD for ParamMC 5.1 at 80 kbps with +10dB Input gain Link #1267 --- lib_enc/ivas_core_enc_fx.c | 15 ++++++++++----- lib_enc/ivas_core_pre_proc_front_fx.c | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 6fcb8abd0..ad998beb3 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -113,7 +113,7 @@ ivas_error ivas_core_enc_fx( Word16 diff_nBits; ivas_error error; Word16 max_num_indices_BWE; - Word16 i; + Word16 i, shift, Q_min; set32_fx( new_swb_speech_buffer_fx, 0, L_FRAME48k + STEREO_DFT_OVL_MAX ); set16_fx( new_swb_speech_buffer_fx_16, 0, L_FRAME48k + STEREO_DFT_OVL_MAX ); @@ -531,11 +531,16 @@ ivas_error ivas_core_enc_fx( st->hTcxEnc->exp_buf_speech_ltp = st->exp_buf_speech_enc; move16(); } - Scale_sig( st->input_fx, input_frame, sub( -1, st->q_inp ) ); - Scale_sig( st->input_fx - input_frame, input_frame, sub( -1, st->q_old_inp ) ); - st->q_inp = -1; + shift = norm_arr( st->input_fx, input_frame ); + Q_min = s_max( -2, add( st->q_inp, shift ) ); + scale_sig( st->input_fx, input_frame, sub( Q_min, st->q_inp ) ); + st->q_inp = Q_min; move16(); - st->q_old_inp = -1; + + shift = norm_arr( st->input_fx - input_frame, input_frame ); + Q_min = s_max( -2, add( st->q_old_inp, shift ) ); + scale_sig( st->input_fx - input_frame, input_frame, sub( Q_min, st->q_old_inp ) ); + st->q_old_inp = Q_min; move16(); } diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 106d7c387..3e7bf2464 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -232,7 +232,7 @@ ivas_error pre_proc_front_ivas_fx( Word16 Q_min = add( sub( 15, st->exp_old_inp_12k8 ), norm_arr( st->old_inp_12k8_fx, L_INP_MEM ) ); Word16 input_frame_full = shl( input_frame, 1 ); //(old frame input length + new frame input length) Q_min = s_min( Q_min, sub( add( getScaleFactor32( st->input32_fx - input_frame, input_frame_full ), st->q_inp32 ), 16 ) ); - Q_min = s_max( -1, Q_min ); + Q_min = s_max( -2, Q_min ); Copy_Scale_sig_32_16( st->input32_fx - input_frame, st->input_fx - input_frame, input_frame_full, sub( Q_min, st->q_inp32 ) ); // Q_min st->q_inp = Q_min; move16(); @@ -682,7 +682,7 @@ ivas_error pre_proc_front_ivas_fx( } st->mem_preemph_fx = shl_sat( st->mem_preemph_fx_q_inp, sub( -1, st->q_inp ) ); /*Q(-1) saturation added as float value goes above 65536 for +10 dB test (ltv48_MC512.wav and ltv48_MC51.wav) */ move16(); - st->mem_preemph_DFT_fx = shl( st->mem_preemph_DFT_fx_q_inp, sub( -1, st->q_inp ) ); /*Q(-1)*/ + st->mem_preemph_DFT_fx = shl_sat( st->mem_preemph_DFT_fx_q_inp, sub( -1, st->q_inp ) ); /*Q(-1)*/ move16(); st->mem_preemph_q = st->q_inp; move16(); -- GitLab From 75dbe8183bd4e28198f366cf6635be3cba4572cb Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 28 May 2025 14:49:05 +0530 Subject: [PATCH 2/2] Warning fix --- lib_enc/ivas_core_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index ad998beb3..5737aad2f 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -712,7 +712,7 @@ ivas_error ivas_core_enc_fx( Word16 Q_shb_spch_16 = Q_shb_spch; move16(); - Word16 shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); + shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch Q_shb_spch = add( Q_shb_spch, shift ); -- GitLab