From da23a911a3c2446b715e0d444b4d5fcfae9c6b12 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Tue, 15 Aug 2023 08:10:10 +0200 Subject: [PATCH 1/3] fix energy correction for ParamISM JBM rendering (#591) --- lib_com/options.h | 1 + lib_dec/ivas_ism_param_dec.c | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 9769123af1..b8d8140877 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -171,6 +171,7 @@ #define FIX_264_AUDIO_CHANNELS_TO_HEAP /* VA: issue 243: Move audio channels memory from stack to heap */ #define FIX_691_OSBA_CRASH /* FhG: Fix for issue 691: Crash for OSBA Stereo out */ #define FIX_694_OMASA_EXTREME /* Nokia: fix for crash in OMASA on extreme sample */ +#define FIX_591_PARAMISM_JBM_ENER_CORRECTION /* FhG: fix energy correction in ParamISM rendering */ /* ################## End BE DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index a30b25b532..3a6f6f8d58 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1124,6 +1124,9 @@ void ivas_param_ism_dec_digest_tc( float direct_response[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN]; DIRAC_DEC_HANDLE hDirAC; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; +#ifdef FIX_591_PARAMISM_JBM_ENER_CORRECTION + int16_t fade_len; +#endif /* Initialization */ hDirAC = st_ivas->hDirAC; @@ -1133,7 +1136,12 @@ void ivas_param_ism_dec_digest_tc( ene_tc = 0.0f; ene_sum = 0.0f; last_gain = st_ivas->hDirAC->hParamIsm->last_dmx_gain; +#ifdef FIX_591_PARAMISM_JBM_ENER_CORRECTION + fade_len = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( 2 * FRAMES_PER_SEC ) ); + output_frame = nCldfbSlots * hSpatParamRendCom->num_freq_bands; +#else output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); +#endif nchan_transport = st_ivas->nchan_transport; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; @@ -1238,9 +1246,13 @@ void ivas_param_ism_dec_digest_tc( { /* Smoothing */ gain = 0.75f * gain + 0.25f * last_gain; - /* 10ms ramp */ +#ifdef FIX_591_PARAMISM_JBM_ENER_CORRECTION + grad = ( gain - last_gain ) / (float) fade_len; /* slope between two consecutive gains, 480 samples length */ + for ( i = 0; i < fade_len; i++ ) +#else grad = ( gain - last_gain ) * 2.0f / (float) output_frame; /* slope between two consecutive gains, 480 samples length */ - for ( i = 0; i < ( output_frame / 2 ); i++ ) + for ( i = 0; i < output_frame / 2; i++ ) +#endif { transport_channels_f[0][i] *= ( last_gain + i * grad ); transport_channels_f[1][i] *= ( last_gain + i * grad ); -- GitLab From 3b89290ae363278ad4d13390a3bc4f049c3ca07a Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Tue, 15 Aug 2023 08:27:01 +0200 Subject: [PATCH 2/3] fix also binaural ener correction for ParamISM and JBM --- lib_dec/ivas_jbm_dec.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index ae3277fbc9..6542c8afff 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -207,6 +207,13 @@ ivas_error ivas_jbm_dec_tc( { ivas_mono_downmix_render_passive( st_ivas, output, output_frame ); } +#ifdef FIX_591_PARAMISM_JBM_ENER_CORRECTION + else if ( st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) + { + /* loudness correction */ + ivas_dirac_dec_binaural_sba_gain( output, st_ivas->nchan_transport, output_frame ); + } +#endif } else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { -- GitLab From 0b0773af0a8582f9e24c426918dfb3af979ad793 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Tue, 15 Aug 2023 10:10:26 +0200 Subject: [PATCH 3/3] uses half of real frame length in fade length for ParamISM energy correction --- lib_dec/ivas_ism_param_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 3a6f6f8d58..071513de38 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1137,8 +1137,8 @@ void ivas_param_ism_dec_digest_tc( ene_sum = 0.0f; last_gain = st_ivas->hDirAC->hParamIsm->last_dmx_gain; #ifdef FIX_591_PARAMISM_JBM_ENER_CORRECTION - fade_len = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( 2 * FRAMES_PER_SEC ) ); output_frame = nCldfbSlots * hSpatParamRendCom->num_freq_bands; + fade_len = output_frame / 2; #else output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); #endif -- GitLab