From 37dc401f05d3ce79b780aa1c6a7c373ac189fa25 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 12 Aug 2025 14:15:25 +0200 Subject: [PATCH 1/3] port MR --- lib_com/options.h | 1 + lib_dec/ivas_stereo_cng_dec_fx.c | 8 ++++++-- lib_dec/ivas_stereo_switching_dec_fx.c | 7 ++++++- lib_enc/ivas_stereo_switching_enc_fx.c | 6 ++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 62bccdca6..73e171fc8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -130,6 +130,7 @@ #define NONBE_FIX_981_PARAMBIN_DEFAULT_EARLY_PART /* Nokia: Set default early part energy correction to unity for BINAURAL_ROOM_REVERB */ #define NONBE_FIX_1174_MCMASA_LBR_LOOP_ERROR /* Nokia: Fix issue 1174 by removing the unnecessary inner loop causing problems. */ #define NONBE_FIX_1052_SBA_EXT_FIX /* VA: SBA external output support fix - do not overwrite "output_config" parameter */ +#define NONBE_FIX_1110_STEREO_DTX_BRATE_SWITCHING /* VA: issue 1110: fix encoder crash in the stereo DTX bitrate switching condition */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_stereo_cng_dec_fx.c b/lib_dec/ivas_stereo_cng_dec_fx.c index 463032467..c214b36fc 100644 --- a/lib_dec/ivas_stereo_cng_dec_fx.c +++ b/lib_dec/ivas_stereo_cng_dec_fx.c @@ -1373,6 +1373,7 @@ static void FindEmEs_fx( /* long-term estimate */ *lt_es_em_fx = L_add( Mpy_32_32( 858993459, *lt_es_em_fx ), Mpy_32_32( 1288490188, es_em_fx ) ); /* Q24 */ move32(); + return; } @@ -1422,13 +1423,17 @@ void stereo_cna_update_params_fx( { FindEmEs_fx( output_fx[0], output_fx[1], output_frame, &hCPE->lt_es_em_fx ); - hCPE->hStereoCng->first_SID_after_TD = 1; /* Q0 */ move16(); stereo_cng_compute_LRcorr_fx( hCPE, output_fx, output_frame, tdm_ratio_idx ); } ELSE { +#ifdef NONBE_FIX_1110_STEREO_DTX_BRATE_SWITCHING + hFdCngDec->first_cna_noise_updated = 0; + move16(); +#endif + return; } @@ -1568,7 +1573,6 @@ void stereo_cna_update_params_fx( set16_fx( hFdCngDec->cna_cm_fx, hFdCngDec->cna_LR_LT_fx, hFdCngDec->cna_nbands ); } - /* Soft VAD for stereo CNA */ test(); IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) || EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 57f631204..fe99711e2 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -1986,6 +1986,12 @@ void stereo_switching_dec( Copy( sts[0]->lsf_old_fx, sts[1]->lsf_old_fx, M ); /* Q2.56 */ Copy( sts[0]->lsp_old_fx, sts[1]->lsp_old_fx, M ); /* Q15 */ + +#ifdef NONBE_FIX_1110_STEREO_DTX_BRATE_SWITCHING + sts[1]->last_core_brate = sts[0]->last_core_brate; + move16(); +#endif + IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) { sts[1]->last_core = sts[0]->last_core; /* Q0 */ @@ -1993,7 +1999,6 @@ void stereo_switching_dec( sts[1]->last_coder_type = sts[0]->last_coder_type; /* Q0 */ move16(); - // 32bit buffer Copy32( sts[0]->hHQ_core->old_out_fx32, sts[1]->hHQ_core->old_out_fx32, L_FRAME48k ); /* exp(exp_old_out) */ Copy32( sts[0]->delay_buf_out32_fx, sts[1]->delay_buf_out32_fx, HQ_DELTA_MAX * HQ_DELAY_COMP ); /* Q11 */ diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index a54e56fb9..21f0bfeb1 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -906,8 +906,14 @@ void stereo_switching_enc_fx( Copy( sts[0]->lsf_old1_fx, sts[1]->lsf_old1_fx, M ); /* Qlog2(2.56) */ Copy( sts[0]->lsp_old1_fx, sts[1]->lsp_old1_fx, M ); /* Q15 */ +#ifdef NONBE_FIX_1110_STEREO_DTX_BRATE_SWITCHING + sts[1]->last_core_brate = sts[0]->last_core_brate; + move16(); +#endif + sts[1]->GSC_noisy_speech = 0; move16(); + IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) { /* cross-fade overlap region of DFT Stereo downmix and original stereo channels */ -- GitLab From 0d0dcc5157936ef56b0bb8d09b44d5a5ea486d55 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 12 Aug 2025 14:20:31 +0200 Subject: [PATCH 2/3] port MR --- lib_com/options.h | 1 + lib_dec/acelp_core_dec_fx.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 73e171fc8..76949eb5a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -131,6 +131,7 @@ #define NONBE_FIX_1174_MCMASA_LBR_LOOP_ERROR /* Nokia: Fix issue 1174 by removing the unnecessary inner loop causing problems. */ #define NONBE_FIX_1052_SBA_EXT_FIX /* VA: SBA external output support fix - do not overwrite "output_config" parameter */ #define NONBE_FIX_1110_STEREO_DTX_BRATE_SWITCHING /* VA: issue 1110: fix encoder crash in the stereo DTX bitrate switching condition */ +#define NONBE_1131_ACELP_OOB /* VA: issue 1131: fix division-by-zero in acelp gain decoding caused by wrong length of buffer update when switching from HQ core to ACELP core */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 260060522..298c4f1e3 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -992,7 +992,11 @@ ivas_error acelp_core_dec_fx( tmpF_fx = *old_exc_s_fx; st->mem_deemph_fx = shl_sat( old_exc_s_fx[st->L_frame - 1], st->Q_syn ); /* Q0 -> Q_syn */ move16(); +#ifdef NONBE_1131_ACELP_OOB + PREEMPH_FX( old_exc_s_fx, st->preemph_fac, st->L_frame, &tmpF_fx ); +#else PREEMPH_FX( old_exc_s_fx, st->preemph_fac, L_FRAME16k, &tmpF_fx ); +#endif Copy( old_exc_s_fx + sub( st->L_frame, M ), st->mem_syn2_fx, M ); Scale_sig( st->mem_syn2_fx, M, st->Q_syn ); /* Q0 -> Q_syn */ Residu3_fx( Aq_fx, old_exc_s_fx, old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, 0 ); -- GitLab From 0cd4a784cedd6972729410ef0c9df02f8a92f9b8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 12 Aug 2025 14:22:52 +0200 Subject: [PATCH 3/3] Revert "port MR" This reverts commit 0d0dcc5157936ef56b0bb8d09b44d5a5ea486d55. --- lib_com/options.h | 1 - lib_dec/acelp_core_dec_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 76949eb5a..73e171fc8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -131,7 +131,6 @@ #define NONBE_FIX_1174_MCMASA_LBR_LOOP_ERROR /* Nokia: Fix issue 1174 by removing the unnecessary inner loop causing problems. */ #define NONBE_FIX_1052_SBA_EXT_FIX /* VA: SBA external output support fix - do not overwrite "output_config" parameter */ #define NONBE_FIX_1110_STEREO_DTX_BRATE_SWITCHING /* VA: issue 1110: fix encoder crash in the stereo DTX bitrate switching condition */ -#define NONBE_1131_ACELP_OOB /* VA: issue 1131: fix division-by-zero in acelp gain decoding caused by wrong length of buffer update when switching from HQ core to ACELP core */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 298c4f1e3..260060522 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -992,11 +992,7 @@ ivas_error acelp_core_dec_fx( tmpF_fx = *old_exc_s_fx; st->mem_deemph_fx = shl_sat( old_exc_s_fx[st->L_frame - 1], st->Q_syn ); /* Q0 -> Q_syn */ move16(); -#ifdef NONBE_1131_ACELP_OOB - PREEMPH_FX( old_exc_s_fx, st->preemph_fac, st->L_frame, &tmpF_fx ); -#else PREEMPH_FX( old_exc_s_fx, st->preemph_fac, L_FRAME16k, &tmpF_fx ); -#endif Copy( old_exc_s_fx + sub( st->L_frame, M ), st->mem_syn2_fx, M ); Scale_sig( st->mem_syn2_fx, M, st->Q_syn ); /* Q0 -> Q_syn */ Residu3_fx( Aq_fx, old_exc_s_fx, old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, 0 ); -- GitLab