From 4b4561acd02dc7efc3fcef968b876ccb7ba1aadc Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 12 Aug 2025 14:06:30 +0200 Subject: [PATCH 1/3] port MR --- lib_com/options.h | 1 + lib_dec/ivas_stereo_cng_dec_fx.c | 6 +++++- lib_dec/ivas_stereo_switching_dec_fx.c | 21 +++++++++++++++------ lib_enc/ivas_stereo_switching_enc_fx.c | 6 ++++++ 4 files changed, 27 insertions(+), 7 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..32c1b04e4 100644 --- a/lib_dec/ivas_stereo_cng_dec_fx.c +++ b/lib_dec/ivas_stereo_cng_dec_fx.c @@ -1422,13 +1422,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; } diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 57f631204..f2362f68c 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -1689,12 +1689,15 @@ void synchro_synthesis_fx( * Handling of memories in case of CPE modes switching *-------------------------------------------------------------------*/ -Word32 side_gain_table[32 + 1] = { -ONE_IN_Q31, -2040109440, -1932735232, -1825361152, -1717986944, - -1610612736, -1503238528, -1395864320, -1288490240, -1181115904, -1073741824, - -966367616, -858993408, -751619200, -644245120, -536870912, -429496704, - -322122496, -214748288, -107374208, 0, 107374336, 214748416, - 322122496, 429496832, 536870912, 644245248, 751619328, 858993408, - 966367744, 1073741824, 1181116160, 1288490240 }; +static const Word32 side_gain_table[32 + 1] = { + -ONE_IN_Q31, -2040109440, -1932735232, -1825361152, -1717986944, + -1610612736, -1503238528, -1395864320, -1288490240, -1181115904, -1073741824, + -966367616, -858993408, -751619200, -644245120, -536870912, -429496704, + -322122496, -214748288, -107374208, 0, 107374336, 214748416, + 322122496, 429496832, 536870912, 644245248, 751619328, 858993408, + 966367744, 1073741824, 1181116160, 1288490240 +}; + void stereo_switching_dec( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/ @@ -1986,6 +1989,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 */ 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 8eb844e9c19038176673dbdeb3dbca0469560f99 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 12 Aug 2025 14:12:05 +0200 Subject: [PATCH 2/3] Revert "port MR" This reverts commit 4b4561acd02dc7efc3fcef968b876ccb7ba1aadc. --- lib_com/options.h | 1 - lib_dec/ivas_stereo_cng_dec_fx.c | 6 +----- lib_dec/ivas_stereo_switching_dec_fx.c | 21 ++++++--------------- lib_enc/ivas_stereo_switching_enc_fx.c | 6 ------ 4 files changed, 7 insertions(+), 27 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 73e171fc8..62bccdca6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -130,7 +130,6 @@ #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 32c1b04e4..463032467 100644 --- a/lib_dec/ivas_stereo_cng_dec_fx.c +++ b/lib_dec/ivas_stereo_cng_dec_fx.c @@ -1422,17 +1422,13 @@ 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; } diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index f2362f68c..57f631204 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -1689,15 +1689,12 @@ void synchro_synthesis_fx( * Handling of memories in case of CPE modes switching *-------------------------------------------------------------------*/ -static const Word32 side_gain_table[32 + 1] = { - -ONE_IN_Q31, -2040109440, -1932735232, -1825361152, -1717986944, - -1610612736, -1503238528, -1395864320, -1288490240, -1181115904, -1073741824, - -966367616, -858993408, -751619200, -644245120, -536870912, -429496704, - -322122496, -214748288, -107374208, 0, 107374336, 214748416, - 322122496, 429496832, 536870912, 644245248, 751619328, 858993408, - 966367744, 1073741824, 1181116160, 1288490240 -}; - +Word32 side_gain_table[32 + 1] = { -ONE_IN_Q31, -2040109440, -1932735232, -1825361152, -1717986944, + -1610612736, -1503238528, -1395864320, -1288490240, -1181115904, -1073741824, + -966367616, -858993408, -751619200, -644245120, -536870912, -429496704, + -322122496, -214748288, -107374208, 0, 107374336, 214748416, + 322122496, 429496832, 536870912, 644245248, 751619328, 858993408, + 966367744, 1073741824, 1181116160, 1288490240 }; void stereo_switching_dec( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/ @@ -1989,12 +1986,6 @@ 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 */ diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 21f0bfeb1..a54e56fb9 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -906,14 +906,8 @@ 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 0919c13299c9abf4213dcb07bab0f5992d5dfa5c Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 12 Aug 2025 14:26:08 +0200 Subject: [PATCH 3/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 62bccdca6..fc09f927d 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_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