From 1db0efae17f8bb71d2796afc71914fb89451e978 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 29 Oct 2025 12:55:52 +0100 Subject: [PATCH 1/3] basop operators; align with float --- lib_dec/ivas_jbm_dec_fx.c | 8 ++++---- lib_dec/lib_dec_fx.c | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index efd212eda..db23b9673 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2549,7 +2549,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( { /* move it at the beginning of the TC buffer with zero padding */ Copy32( hTcBuffer->tc_buffer_old_fx[ch_idx], hTcBuffer->tc_fx[ch_idx], n_samples_to_render ); - set_zero_fx( hTcBuffer->tc_fx[ch_idx] + n_samples_to_render, hTcBuffer->n_samples_granularity - n_samples_to_render ); + set_zero_fx( hTcBuffer->tc_fx[ch_idx] + n_samples_to_render, sub( hTcBuffer->n_samples_granularity, n_samples_to_render ) ); } #else /* render what is still there with zero padding */ @@ -3369,7 +3369,7 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( move16(); } - nsamp_to_allocate = s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ) * n_samp_full; + nsamp_to_allocate = imult1616( s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ), n_samp_full ); IF( Opt_tsm ) { @@ -3382,7 +3382,7 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( offset = 0; move16(); - FOR( ch_idx = 0; ch_idx < max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ ) + FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ ) { hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset]; offset = add( offset, n_samp_full ); @@ -3462,6 +3462,7 @@ static void ivas_jbm_dec_tc_audio_deallocate_fx( return; } + #endif /*--------------------------------------------------------------------------* @@ -3470,7 +3471,6 @@ static void ivas_jbm_dec_tc_audio_deallocate_fx( * open and initialize JBM transport channel buffer *--------------------------------------------------------------------------*/ - ivas_error ivas_jbm_dec_tc_buffer_open_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 248b8846b..28417c137 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1217,7 +1217,11 @@ ivas_error IVAS_DEC_GetSamplesRenderer( hIvasDec->hasBeenFedFrame = false; /* check for possible flushed samples from a rate switch */ +#ifdef NONBE_1324_TC_BUFFER_MEMOERY_KEEP + IF( GT_16( hIvasDec->nSamplesFlushed, 0 ) ) +#else IF( GE_16( hIvasDec->nSamplesFlushed, 0 ) ) +#endif { /* note: offset (rendered samples) is always 0 */ Copy( hIvasDec->flushbuffer, pcmBuf, imult1616( hIvasDec->nSamplesFlushed, nOutChannels ) ); -- GitLab From b853be0b10bc7bdf4ac989e3263020f0f2390fc3 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 30 Oct 2025 11:13:48 +0200 Subject: [PATCH 2/3] Add switches --- lib_com/options.h | 2 ++ lib_dec/ivas_jbm_dec_fx.c | 13 ++++++++++++- lib_dec/lib_dec_fx.c | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 885e75e65..755af8894 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,6 +86,8 @@ #define FIX_2166_ASSERT_OSBA_PLC_STEREO_OUT /* FhG: fix for issue 2166 - add missing averaging factor 0.5 in for the sum of energies in function stereo_dft_dmx_swb_nrg_fx()*/ #define FIX_1793_DEC_MC_TO_MONO_SCALING_ISSUE /* FhG: Use dynamic Q factor for synth_fx and synthFB_fx to prevent overflow */ +#define FIX_2174_JBM_BASOP_ALIGNMENT /* VoiceAge, Nokia: Fixes to JBM BASOP implementation and alignment to float */ + /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index db23b9673..fa893c549 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2549,7 +2549,11 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( { /* move it at the beginning of the TC buffer with zero padding */ Copy32( hTcBuffer->tc_buffer_old_fx[ch_idx], hTcBuffer->tc_fx[ch_idx], n_samples_to_render ); +#ifdef FIX_2174_JBM_BASOP_ALIGNMENT set_zero_fx( hTcBuffer->tc_fx[ch_idx] + n_samples_to_render, sub( hTcBuffer->n_samples_granularity, n_samples_to_render ) ); +#else + set_zero_fx( hTcBuffer->tc_fx[ch_idx] + n_samples_to_render, hTcBuffer->n_samples_granularity - n_samples_to_render ); +#endif } #else /* render what is still there with zero padding */ @@ -3369,7 +3373,11 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( move16(); } +#ifdef FIX_2174_JBM_BASOP_ALIGNMENT nsamp_to_allocate = imult1616( s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ), n_samp_full ); +#else + nsamp_to_allocate = s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ) * n_samp_full; +#endif IF( Opt_tsm ) { @@ -3382,7 +3390,11 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( offset = 0; move16(); +#ifdef FIX_2174_JBM_BASOP_ALIGNMENT FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ ) +#else + FOR( ch_idx = 0; ch_idx < max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ ) +#endif { hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset]; offset = add( offset, n_samp_full ); @@ -3462,7 +3474,6 @@ static void ivas_jbm_dec_tc_audio_deallocate_fx( return; } - #endif /*--------------------------------------------------------------------------* diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 28417c137..176d3427a 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1217,7 +1217,7 @@ ivas_error IVAS_DEC_GetSamplesRenderer( hIvasDec->hasBeenFedFrame = false; /* check for possible flushed samples from a rate switch */ -#ifdef NONBE_1324_TC_BUFFER_MEMOERY_KEEP +#ifdef FIX_2174_JBM_BASOP_ALIGNMENT IF( GT_16( hIvasDec->nSamplesFlushed, 0 ) ) #else IF( GE_16( hIvasDec->nSamplesFlushed, 0 ) ) -- GitLab From b2e65be4de6f12fc46d46c8380c13354822e5099 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 30 Oct 2025 13:32:41 +0100 Subject: [PATCH 3/3] one more fix under FIX_2174_JBM_BASOP_ALIGNMENT --- lib_dec/ivas_jbm_dec_fx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index fa893c549..76f77b353 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -3364,7 +3364,11 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( IF( Opt_tsm ) { n_samp_full = NS2SA_FX2( output_Fs, MAX_JBM_L_FRAME_NS ); +#ifdef FIX_2174_JBM_BASOP_ALIGNMENT + n_samp_residual = sub( hTcBuffer->n_samples_granularity, 1 ); +#else n_samp_residual = add( hTcBuffer->n_samples_granularity, 1 ); +#endif } ELSE { -- GitLab