From 60930d82c600d56d2703b1576f1dd809ba834986 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 7 Feb 2025 16:06:53 +0530 Subject: [PATCH 1/2] Bug fixes for MC and SBA formats [x] Remove wrong q-updation for bin_e in stereo_tcx_core_enc [x] Few corrections for SBA format files --- lib_enc/core_enc_init.c | 4 ++-- lib_enc/ivas_core_pre_proc.c | 2 ++ lib_enc/ivas_core_pre_proc_front.c | 7 ++++++- lib_enc/ivas_tcx_core_enc.c | 6 +----- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c index d82d1b7ff..43e93f27c 100644 --- a/lib_enc/core_enc_init.c +++ b/lib_enc/core_enc_init.c @@ -528,8 +528,8 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol Copy( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); // Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); - - /*Resamp buffers needed only for ACELP*/ + st->exp_buf_wspeech_enc = st->exp_old_wsp; + move16(); /*Resamp buffers needed only for ACELP*/ IF( EQ_16( st->L_frame, L_FRAME16k ) ) { lerp( st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, st->buf_wspeech_enc + st->L_frame + L_SUBFR - 310, 310, L_WSP_MEM ); diff --git a/lib_enc/ivas_core_pre_proc.c b/lib_enc/ivas_core_pre_proc.c index 848e26ce3..3444ca091 100644 --- a/lib_enc/ivas_core_pre_proc.c +++ b/lib_enc/ivas_core_pre_proc.c @@ -571,6 +571,8 @@ ivas_error pre_proc_ivas_fx( st->q_inp = -1; move16(); Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); /* Q15 - Q_old_inp_16k */ + st->mem_wsp_enc = shl( st->mem_wsp_enc,sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); // Q_old_inp_16k + move16(); st->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k ); move16(); Word16 Q_old_inp_128k = *Q_new; diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 9e09f93f6..57a6222c1 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -1643,6 +1643,8 @@ ivas_error pre_proc_front_ivas_fx( st->exp_mem_preemph_enc = sub( Q15, Q_old_inp_16k ); move16(); Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); /* Q15 - Q_old_inp_16k */ + st->mem_wsp_enc = shl( st->mem_wsp_enc,sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); //Q_old_inp_16k + move16(); st->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k ); move16(); Scale_sig( st->buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_speech_enc_pe ) ) ); /* Q15 - Q_old_inp_16k */ @@ -1666,7 +1668,7 @@ ivas_error pre_proc_front_ivas_fx( *epsP_fx_q = add( Q_r[0], 1 ); move16(); - st->mem_wsp_enc = shr_r( st->mem_wsp_enc, *Q_new ); // Q_new - 1 -> Q-1 + st->mem_wsp_enc = shl( st->mem_wsp_enc,sub( 0, sub( Q15, st->exp_buf_wspeech_enc ) ) ); //Q0 move16(); *Q_new = add( *Q_new, Q_to_be_looked_into ); // actual Q_new @@ -1676,6 +1678,9 @@ ivas_error pre_proc_front_ivas_fx( Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( 0, sub( Q15, st->exp_buf_speech_enc ) ) ); /* Q0 */ st->exp_buf_speech_enc = Q15; move16(); + Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( 0, sub( Q15, st->exp_buf_wspeech_enc ) ) ); /* Q0 */ + st->exp_buf_wspeech_enc = Q15; + move16(); smc_dec = ivas_acelp_tcx20_switching_fx( st, st->speech_enc, 0, st->wspeech_enc, non_staX_fx, pitch_fr_fx, voicing_fr_fx, currFlatness_fx, lsp_mid_fx, stab_fac_fx, res_cod_SNR_M_fx, res_cod_SNR_M_fx_e, flag_16k_smc ); /* Q0 */ } ELSE diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index f993c8e28..0680fc795 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -727,10 +727,6 @@ void stereo_tcx_core_enc( move16(); } } - st->q_Bin_E = Q_new + Q_SCALE - 2; - move16(); - st->q_Bin_E_old = Q_new + Q_SCALE - 2; - move16(); Scale_sig( st->synth, st->L_frame, -Q_new ); IF( st->tcxonly == 0 ) { @@ -875,7 +871,7 @@ Word16 ivas_acelp_tcx20_switching_fx( #ifdef MSAN_FIX FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_length / 2; i++ ) { - window_fx[st->hTcxCfg->tcx_mdct_window_length / 2 - 1 - i] = st->hTcxCfg->tcx_mdct_window[i].v.re; // Q15 + window_fx[st->hTcxCfg->tcx_mdct_window_length - 1 - i] = st->hTcxCfg->tcx_mdct_window[i].v.re; // Q15 move16(); window_fx[i] = st->hTcxCfg->tcx_mdct_window[i].v.im; // Q15 move16(); -- GitLab From 64a68a5359ee8cd84ea264f54a4452ad2fcef734 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 7 Feb 2025 16:21:42 +0530 Subject: [PATCH 2/2] Clang formatting changes --- lib_enc/ivas_core_pre_proc.c | 2 +- lib_enc/ivas_core_pre_proc_front.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_enc/ivas_core_pre_proc.c b/lib_enc/ivas_core_pre_proc.c index 3444ca091..541cc620c 100644 --- a/lib_enc/ivas_core_pre_proc.c +++ b/lib_enc/ivas_core_pre_proc.c @@ -571,7 +571,7 @@ ivas_error pre_proc_ivas_fx( st->q_inp = -1; move16(); Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); /* Q15 - Q_old_inp_16k */ - st->mem_wsp_enc = shl( st->mem_wsp_enc,sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); // Q_old_inp_16k + st->mem_wsp_enc = shl( st->mem_wsp_enc, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); // Q_old_inp_16k move16(); st->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k ); move16(); diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 57a6222c1..fd9b79617 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -1643,7 +1643,7 @@ ivas_error pre_proc_front_ivas_fx( st->exp_mem_preemph_enc = sub( Q15, Q_old_inp_16k ); move16(); Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); /* Q15 - Q_old_inp_16k */ - st->mem_wsp_enc = shl( st->mem_wsp_enc,sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); //Q_old_inp_16k + st->mem_wsp_enc = shl( st->mem_wsp_enc, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); // Q_old_inp_16k move16(); st->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k ); move16(); @@ -1668,7 +1668,7 @@ ivas_error pre_proc_front_ivas_fx( *epsP_fx_q = add( Q_r[0], 1 ); move16(); - st->mem_wsp_enc = shl( st->mem_wsp_enc,sub( 0, sub( Q15, st->exp_buf_wspeech_enc ) ) ); //Q0 + st->mem_wsp_enc = shl( st->mem_wsp_enc, sub( 0, sub( Q15, st->exp_buf_wspeech_enc ) ) ); // Q0 move16(); *Q_new = add( *Q_new, Q_to_be_looked_into ); // actual Q_new -- GitLab