From d4d62a3967e8a274451ca9fe66f373b1af65acdf Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 29 Apr 2026 13:12:48 +0200 Subject: [PATCH 1/3] [fix] float issue 1521: SBA loudness for binaural and stereo --- lib_com/options.h | 2 ++ lib_dec/ivas_dec_render.c | 11 +++++++++++ lib_dec/ivas_sba_dirac_stereo_dec.c | 5 +++++ lib_rend/ivas_allrad_dec.c | 7 +++++++ lib_rend/ivas_crend.c | 14 +++++++++++++- 5 files changed, 38 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 6abf37fd8..71897e39e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -172,6 +172,8 @@ /* any switch which is non-be wrt. TS 26.258 V3.0 */ #define USE_RTPDUMP /* FhG: RTPDUMP format (rtptools standard) instead of custom format */ +#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 */ #define FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API /* Expose Payload Type setting in RTP Header */ #define FIX_BASOP_2023_TDREND_DISTATT_PRECISION /* Eri: Basop issue 2023: Distance attenuation scaling, synch with BASOP updates and adding clamping of distance att input and listener position */ #define FIX_1574_EFAP_CODE_LINT /* FhG: issue 1574: Code quality fixes in ivas_efap.c */ diff --git a/lib_dec/ivas_dec_render.c b/lib_dec/ivas_dec_render.c index cfef84e48..df35c3b01 100644 --- a/lib_dec/ivas_dec_render.c +++ b/lib_dec/ivas_dec_render.c @@ -341,6 +341,17 @@ ivas_error ivas_dec_render( return error; } } +#ifdef FIX_1521_SBA_LOUDNESS_BINAURAL + if ( st_ivas->ivas_format == SBA_FORMAT && + ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) ) + { + /* loudness correction for SBA binaural rendering */ + for ( n = 0; n < BINAURAL_CHANNELS; n++ ) + { + v_multc( p_output[n], INV_SQRT2, p_output[n], *nSamplesRendered ); + } + } +#endif } else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index e074d13f7..18754dbd1 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -912,8 +912,13 @@ void ivas_sba_dirac_stereo_dec( /* output scaling */ if ( !sba_mono_flag && !( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_NONE ) ) { +#ifdef FIX_1521_SBA_LOUDNESS_STEREO + v_multc( output[0], INV_SQRT2, output[0], output_frame ); + v_multc( output[1], INV_SQRT2, output[1], output_frame ); +#else v_multc( output[0], 0.5f, output[0], output_frame ); v_multc( output[1], 0.5f, output[1], output_frame ); +#endif } /* delay HB synth */ diff --git a/lib_rend/ivas_allrad_dec.c b/lib_rend/ivas_allrad_dec.c index 141e53881..5b27c04cb 100644 --- a/lib_rend/ivas_allrad_dec.c +++ b/lib_rend/ivas_allrad_dec.c @@ -129,10 +129,17 @@ ivas_error ivas_sba_get_hoa_dec_matrix( } else if ( hOutSetup.output_config == IVAS_AUDIO_CONFIG_STEREO ) { +#ifdef FIX_1521_SBA_LOUDNESS_STEREO + ( *hoa_dec_mtx )[0] = INV_SQRT2; + ( *hoa_dec_mtx )[1] = INV_SQRT2; + ( *hoa_dec_mtx )[SBA_NHARM_HOA3] = INV_SQRT2; + ( *hoa_dec_mtx )[SBA_NHARM_HOA3 + 1] = -INV_SQRT2; +#else ( *hoa_dec_mtx )[0] = 0.5f; ( *hoa_dec_mtx )[1] = 0.5f; ( *hoa_dec_mtx )[SBA_NHARM_HOA3] = 0.5f; ( *hoa_dec_mtx )[SBA_NHARM_HOA3 + 1] = -0.5f; +#endif } else if ( hOutSetup.is_loudspeaker_setup ) { diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 6befa436a..e2abbd341 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1854,7 +1854,19 @@ ivas_error ivas_rend_crendProcessSubframe( for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { /* move to output */ - mvr2r( pcm_tmp[ch], p_output[ch], subframe_len ); +#ifdef FIX_1521_SBA_LOUDNESS_BINAURAL + if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) + { + /* loudness correction for SBA binaural rendering */ + v_multc( pcm_tmp[ch], INV_SQRT2, p_output[ch], subframe_len ); + } + else + { +#endif + mvr2r( pcm_tmp[ch], p_output[ch], subframe_len ); +#ifdef FIX_1521_SBA_LOUDNESS_BINAURAL + } +#endif p_output[ch] += subframe_len; } -- GitLab From d9f51f44c0baca6e96a0e4c12a81a981560f70c0 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 30 Apr 2026 10:47:48 +0200 Subject: [PATCH 2/3] [fix] gain application for OSBA and lower bitrate SBA BINAURAL_ROOM_REVERB rendering --- lib_dec/ivas_dec_render.c | 7 +++++-- lib_dec/ivas_sba_dirac_stereo_dec.c | 18 ++++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_dec_render.c b/lib_dec/ivas_dec_render.c index df35c3b01..531c38ff0 100644 --- a/lib_dec/ivas_dec_render.c +++ b/lib_dec/ivas_dec_render.c @@ -343,10 +343,13 @@ ivas_error ivas_dec_render( } #ifdef FIX_1521_SBA_LOUDNESS_BINAURAL if ( st_ivas->ivas_format == SBA_FORMAT && - ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) ) + ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || + 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; + for ( n = 0; n < nchan_out_syn_output; n++ ) { v_multc( p_output[n], INV_SQRT2, p_output[n], *nSamplesRendered ); } diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index 18754dbd1..fcc4f9412 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -910,11 +910,25 @@ void ivas_sba_dirac_stereo_dec( synchro_synthesis( st_ivas->hDecoderConfig->ivas_total_brate, hCPE, output, output_frame, 1 /*st_ivas->sba_dirac_stereo_flag*/ ); /* output scaling */ +#ifdef FIX_1521_SBA_LOUDNESS_STEREO + if ( !sba_mono_flag ) +#else if ( !sba_mono_flag && !( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_NONE ) ) +#endif { #ifdef FIX_1521_SBA_LOUDNESS_STEREO - v_multc( output[0], INV_SQRT2, output[0], output_frame ); - v_multc( output[1], INV_SQRT2, output[1], output_frame ); + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && 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( output[0], SQRT2, output[0], output_frame ); + v_multc( output[1], SQRT2, output[1], output_frame ); + } + else + { + v_multc( output[0], INV_SQRT2, output[0], output_frame ); + v_multc( output[1], INV_SQRT2, output[1], output_frame ); + } #else v_multc( output[0], 0.5f, output[0], output_frame ); v_multc( output[1], 0.5f, output[1], output_frame ); -- GitLab From 02d8eb0b7f44531d2cbc2fd2afa103e8ff6a7bcb Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 30 Apr 2026 13:38:29 +0200 Subject: [PATCH 3/3] [fix] BINAURAL_SPLIT_PCM uses a temporary buffer where scaling isn't applied --- lib_dec/ivas_dec_render.c | 4 +++- lib_dec/lib_dec.c | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_dec_render.c b/lib_dec/ivas_dec_render.c index 531c38ff0..278bb18ac 100644 --- a/lib_dec/ivas_dec_render.c +++ b/lib_dec/ivas_dec_render.c @@ -345,7 +345,9 @@ ivas_error ivas_dec_render( if ( st_ivas->ivas_format == SBA_FORMAT && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) ) + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) && + output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && + output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { /* loudness correction for SBA binaural rendering */ nchan_out_syn_output = ( st_ivas->hSplitBinRend != NULL ) ? st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS : BINAURAL_CHANNELS; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 63f78a949..7430e9e6f 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2250,6 +2250,19 @@ static ivas_error isar_generate_metadata_and_bitstream( return error; } +#ifdef FIX_1521_SBA_LOUDNESS_BINAURAL + if ( pcm_out_flag && st_ivas->ivas_format == SBA_FORMAT && + ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) ) + { + for ( i = 0; i < st_ivas->hDecoderConfig->nchan_out; ++i ) + { + v_multc( p_head_pose_buf[i], INV_SQRT2, p_head_pose_buf[i], nSamples ); + } + } +#endif + return IVAS_ERR_OK; } -- GitLab