From 68155186dfb00efd927818f808970b3ea6f65fb8 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 29 Apr 2026 13:16:09 +0200 Subject: [PATCH 1/7] [fix] float issue: 1521: SBA loudness for binaural and stereo --- lib_com/options.h | 2 ++ lib_dec/ivas_dec_render_fx.c | 13 +++++++++++++ lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 5 +++++ lib_rend/ivas_allrad_dec_fx.c | 7 +++++++ lib_rend/ivas_crend_fx.c | 15 ++++++++++++++- 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 53bfa8a2e..3b1dcc546 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -148,6 +148,8 @@ #define FIX_BASOP_2517_CLICK_IN_OMASA_LTV /* FhG: BASOP #2517: preserve precision by removing one-bit headroom from Q_min and allowing saturation during buffer scaling */ #define FIX_BASOP_2559_Q_SYNTH_HISTORY_RESET /* FhG: BASOP issue 2559: reset hTcxDec->q_synth_history_fx in allocate_CoreCoder_TCX_fx() */ #define FIX_FLOAT_1578_OMASA_REND_SPIKES /* Nokia: Float issue 1578: Fix spikes and collapsed perception in OMASA/MASA rendering to FOA/HOA */ +#define FIX_1521_SBA_LOUDNESS_STEREO /* FhG: issue 1521: Fix loudness for SBA to stereo rendering */ +#define FIX_1521_SBA_LOUDNESS_BINAURAL /* FhG: issue 1521: Fix loudness for SBA to binaural rendering */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_dec_render_fx.c b/lib_dec/ivas_dec_render_fx.c index ee5105fde..15cb13136 100644 --- a/lib_dec/ivas_dec_render_fx.c +++ b/lib_dec/ivas_dec_render_fx.c @@ -440,6 +440,19 @@ ivas_error ivas_dec_render_fx( return error; } } +#ifdef FIX_1521_SBA_LOUDNESS_BINAURAL + test(); + test(); + IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) && + ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) ) + { + /* loudness correction for SBA binaural rendering */ + FOR( n = 0; n < BINAURAL_CHANNELS; n++ ) + { + v_multc_fx( p_output_fx[n], INV_SQRT2_FX, p_output_fx[n], *nSamplesRendered ); + } + } +#endif } ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 905d62d3c..d553b8ca8 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1569,8 +1569,13 @@ void ivas_sba_dirac_stereo_dec_fx( test(); IF( !sba_mono_flag && !( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MODE_NONE ) ) ) { +#ifdef FIX_1521_SBA_LOUDNESS_STEREO + v_multc_fx( output[0], INV_SQRT2_FX, output[0], output_frame ); + v_multc_fx( output[1], INV_SQRT2_FX, output[1], output_frame ); +#else v_shr( output[0], 1, output[0], output_frame ); /*0.5f*/ v_shr( output[1], 1, output[1], output_frame ); /*0.5f*/ +#endif } /* delay HB synth */ diff --git a/lib_rend/ivas_allrad_dec_fx.c b/lib_rend/ivas_allrad_dec_fx.c index 2c5c40b9c..18793c211 100644 --- a/lib_rend/ivas_allrad_dec_fx.c +++ b/lib_rend/ivas_allrad_dec_fx.c @@ -98,10 +98,17 @@ ivas_error ivas_sba_get_hoa_dec_matrix_fx( } ELSE IF( EQ_32( hOutSetup.output_config, IVAS_AUDIO_CONFIG_STEREO ) ) { +#ifdef FIX_1521_SBA_LOUDNESS_STEREO + ( *hoa_dec_mtx )[0] = INV_SQRT2_FX >> 2; + ( *hoa_dec_mtx )[1] = INV_SQRT2_FX >> 2; + ( *hoa_dec_mtx )[SBA_NHARM_HOA3] = INV_SQRT2_FX >> 2; + ( *hoa_dec_mtx )[SBA_NHARM_HOA3 + 1] = -( INV_SQRT2_FX >> 2 ); +#else ( *hoa_dec_mtx )[0] = ONE_IN_Q28; // 0.5f in Q29 ( *hoa_dec_mtx )[1] = ONE_IN_Q28; // 0.5f in Q29 ( *hoa_dec_mtx )[SBA_NHARM_HOA3] = ONE_IN_Q28; // 0.5f in Q29 ( *hoa_dec_mtx )[SBA_NHARM_HOA3 + 1] = -ONE_IN_Q28; // 0.5f in Q29 +#endif move32(); move32(); move32(); diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 5e4192891..e1981b91f 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -2230,7 +2230,20 @@ ivas_error ivas_rend_crendProcessSubframe_fx( FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { /* move to output */ - Copy32( pcm_tmp_fx[ch], p_output_fx[ch], subframe_len ); +#ifdef FIX_1521_SBA_LOUDNESS_BINAURAL + test(); + IF( EQ_32( inConfigType, IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) && NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) + { + /* loudness correction for SBA binaural rendering */ + v_multc_fx( pcm_tmp_fx[ch], INV_SQRT2_FX, p_output_fx[ch], subframe_len ); + } + ELSE + { +#endif + Copy32( pcm_tmp_fx[ch], p_output_fx[ch], subframe_len ); +#ifdef FIX_1521_SBA_LOUDNESS_BINAURAL + } +#endif p_output_fx[ch] += subframe_len; } -- GitLab From 7d0d247884a43253d1e1b9829638451d055b9cd4 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 29 Apr 2026 15:42:48 +0200 Subject: [PATCH 2/7] temporarily swap v_add_fx with v_add_fx_no_hdrm to test overflow --- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index d553b8ca8..0b0c805e3 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1600,10 +1600,10 @@ void ivas_sba_dirac_stereo_dec_fx( ivas_sba_dirac_stereo_upmix_hb( hb_synth_stereo, hSCE->save_hb_synth_fx, hb_gain, output_frame, ( ( NE_16( st_ivas->ivas_format, SBA_FORMAT ) && NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) || mcmasa ), sba_mono_flag, hSCE->hCoreCoder[0]->bwidth, hStereoDft ); /* add HB to ACELP core */ - v_add_fx( output[0], hb_synth_stereo[0], output[0], output_frame ); /*q*/ + v_add_fx_no_hdrm( output[0], hb_synth_stereo[0], output[0], output_frame ); /*q*/ IF( !sba_mono_flag ) { - v_add_fx( output[1], hb_synth_stereo[1], output[1], output_frame ); /*q*/ + v_add_fx_no_hdrm( output[1], hb_synth_stereo[1], output[1], output_frame ); /*q*/ /* apply TD Stereo Filling as is done in ICBWE */ test(); -- GitLab From c6acb610a20c25a466c0aa6874c0b72ece249b68 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 29 Apr 2026 16:28:57 +0200 Subject: [PATCH 3/7] Revert "temporarily swap v_add_fx with v_add_fx_no_hdrm to test overflow" This reverts commit 7d0d247884a43253d1e1b9829638451d055b9cd4. --- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 0b0c805e3..d553b8ca8 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1600,10 +1600,10 @@ void ivas_sba_dirac_stereo_dec_fx( ivas_sba_dirac_stereo_upmix_hb( hb_synth_stereo, hSCE->save_hb_synth_fx, hb_gain, output_frame, ( ( NE_16( st_ivas->ivas_format, SBA_FORMAT ) && NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) || mcmasa ), sba_mono_flag, hSCE->hCoreCoder[0]->bwidth, hStereoDft ); /* add HB to ACELP core */ - v_add_fx_no_hdrm( output[0], hb_synth_stereo[0], output[0], output_frame ); /*q*/ + v_add_fx( output[0], hb_synth_stereo[0], output[0], output_frame ); /*q*/ IF( !sba_mono_flag ) { - v_add_fx_no_hdrm( output[1], hb_synth_stereo[1], output[1], output_frame ); /*q*/ + v_add_fx( output[1], hb_synth_stereo[1], output[1], output_frame ); /*q*/ /* apply TD Stereo Filling as is done in ICBWE */ test(); -- GitLab From 6d98546125b2f157f8b4fe50006b98f762cfc280 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 30 Apr 2026 11:17:06 +0200 Subject: [PATCH 4/7] [fix] gain application for OSBA and lower bitrate SBA BINAURAL_ROOM_REVERB rendering --- lib_dec/ivas_dec_render_fx.c | 9 +++++++-- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_dec_render_fx.c b/lib_dec/ivas_dec_render_fx.c index 15cb13136..71dec5629 100644 --- a/lib_dec/ivas_dec_render_fx.c +++ b/lib_dec/ivas_dec_render_fx.c @@ -441,13 +441,18 @@ ivas_error ivas_dec_render_fx( } } #ifdef FIX_1521_SBA_LOUDNESS_BINAURAL + test(); test(); test(); IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) && - ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) ) + ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || + EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || + EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) ) { /* loudness correction for SBA binaural rendering */ - FOR( n = 0; n < BINAURAL_CHANNELS; n++ ) + nchan_out_syn_output = ( st_ivas->hSplitBinRend != NULL ) ? st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS : BINAURAL_CHANNELS; + move16(); + FOR( n = 0; n < nchan_out_syn_output; n++ ) { v_multc_fx( p_output_fx[n], INV_SQRT2_FX, p_output_fx[n], *nSamplesRendered ); } diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index d553b8ca8..c2798a55d 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1566,12 +1566,27 @@ void ivas_sba_dirac_stereo_dec_fx( synchro_synthesis_fx( st_ivas->hDecoderConfig->ivas_total_brate, hCPE, output, output_frame, 1 /*st_ivas->sba_dirac_stereo_flag*/, q_dft[0] ); /* output scaling */ +#ifdef FIX_1521_SBA_LOUDNESS_STEREO + IF( !sba_mono_flag ) +#else test(); IF( !sba_mono_flag && !( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MODE_NONE ) ) ) +#endif { #ifdef FIX_1521_SBA_LOUDNESS_STEREO - v_multc_fx( output[0], INV_SQRT2_FX, output[0], output_frame ); - v_multc_fx( output[1], INV_SQRT2_FX, output[1], output_frame ); + test(); + IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MODE_NONE ) ) + { + /* low bitrate OSBA needs a makeup gain of 2.f to compensate for the encoder side + INV_SQRT2 * 2 = SQRT2 */ + v_multc_fx( output[0], SQRT2_FX, output[0], output_frame ); + v_multc_fx( output[1], SQRT2_FX, output[1], output_frame ); + } + ELSE + { + v_multc_fx( output[0], INV_SQRT2_FX, output[0], output_frame ); + v_multc_fx( output[1], INV_SQRT2_FX, output[1], output_frame ); + } #else v_shr( output[0], 1, output[0], output_frame ); /*0.5f*/ v_shr( output[1], 1, output[1], output_frame ); /*0.5f*/ -- GitLab From 29f960b01ff5666f84a18f90572077fb0b2555e4 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 30 Apr 2026 11:31:09 +0200 Subject: [PATCH 5/7] [revertme] test overflow --- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index c2798a55d..65031a32a 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1615,10 +1615,10 @@ void ivas_sba_dirac_stereo_dec_fx( ivas_sba_dirac_stereo_upmix_hb( hb_synth_stereo, hSCE->save_hb_synth_fx, hb_gain, output_frame, ( ( NE_16( st_ivas->ivas_format, SBA_FORMAT ) && NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) || mcmasa ), sba_mono_flag, hSCE->hCoreCoder[0]->bwidth, hStereoDft ); /* add HB to ACELP core */ - v_add_fx( output[0], hb_synth_stereo[0], output[0], output_frame ); /*q*/ + v_add_fx_no_hdrm( output[0], hb_synth_stereo[0], output[0], output_frame ); /*q*/ IF( !sba_mono_flag ) { - v_add_fx( output[1], hb_synth_stereo[1], output[1], output_frame ); /*q*/ + v_add_fx_no_hdrm( output[1], hb_synth_stereo[1], output[1], output_frame ); /*q*/ /* apply TD Stereo Filling as is done in ICBWE */ test(); -- GitLab From a9848a5f83e38995a0cbc50b81c68586a672fff0 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 30 Apr 2026 12:05:53 +0200 Subject: [PATCH 6/7] Revert "[revertme] test overflow" This reverts commit 29f960b01ff5666f84a18f90572077fb0b2555e4. --- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 65031a32a..c2798a55d 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1615,10 +1615,10 @@ void ivas_sba_dirac_stereo_dec_fx( ivas_sba_dirac_stereo_upmix_hb( hb_synth_stereo, hSCE->save_hb_synth_fx, hb_gain, output_frame, ( ( NE_16( st_ivas->ivas_format, SBA_FORMAT ) && NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) || mcmasa ), sba_mono_flag, hSCE->hCoreCoder[0]->bwidth, hStereoDft ); /* add HB to ACELP core */ - v_add_fx_no_hdrm( output[0], hb_synth_stereo[0], output[0], output_frame ); /*q*/ + v_add_fx( output[0], hb_synth_stereo[0], output[0], output_frame ); /*q*/ IF( !sba_mono_flag ) { - v_add_fx_no_hdrm( output[1], hb_synth_stereo[1], output[1], output_frame ); /*q*/ + v_add_fx( output[1], hb_synth_stereo[1], output[1], output_frame ); /*q*/ /* apply TD Stereo Filling as is done in ICBWE */ test(); -- GitLab From 152503bbdc35a20a66d315e8f1842bfd57e8e033 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 30 Apr 2026 14:57:40 +0200 Subject: [PATCH 7/7] [fix] Q factor for low bitrate OSBA branch --- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index c2798a55d..1d15b3d29 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1581,6 +1581,8 @@ void ivas_sba_dirac_stereo_dec_fx( INV_SQRT2 * 2 = SQRT2 */ v_multc_fx( output[0], SQRT2_FX, output[0], output_frame ); v_multc_fx( output[1], SQRT2_FX, output[1], output_frame ); + v_shr( output[0], -1, output[0], output_frame ); /* q_dft */ + v_shr( output[1], -1, output[1], output_frame ); /* q_dft */ } ELSE { -- GitLab