From a7b2b13e8216bc85ed93f6bbc2e1847aab8a7da9 Mon Sep 17 00:00:00 2001 From: Andrea Eichenseer Date: Wed, 24 Jan 2024 16:09:10 +0100 Subject: [PATCH 1/3] Fix to issue 967. Adjusted the smoothing in the ISM mono DMX. Also changed the function name to ivas_ism_mono_dmx(). --- lib_com/ivas_prot.h | 4 ++++ lib_com/options.h | 1 + lib_dec/ivas_jbm_dec.c | 12 +++++++++++ lib_dec/ivas_mono_dmx_renderer.c | 36 ++++++++++++++++++++++++++++++-- 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 2eacf811b0..b27a002513 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5469,7 +5469,11 @@ void ivas_mono_dmx_renderer_close( MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/ i/o: Mono downmix structure */ ); +#ifdef NONBE_FIX_967_ISM_MONO_DMX +void ivas_ism_mono_dmx( +#else void ivas_mono_downmix_render_passive( +#endif Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output_f[], /* i/o: synthesized core-coder transport channels/mono output */ const int16_t output_frame /* i : output frame length */ diff --git a/lib_com/options.h b/lib_com/options.h index 8ff5ac6134..ae095a97b7 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -173,6 +173,7 @@ #define NONBE_FIX_935_EARLY_REFLECTIONS_WRONG_ORDER /* Qualcomm: issue 953: fix order or ER channels in LC mode*/ #define NONBE_FIX_949_MC_5MS_FRAMING /* Dlb: issue 949: fix for issue 949, distorted output in MC mode with 5ms framing*/ #define NONBE_FIX_952_MC_PARAMUPMIX_5MS /* Dlb : issue 952 : Differences between 5ms and 20ms rendering for ParamUpmix*/ +#define NONBE_FIX_967_ISM_MONO_DMX /* FhG: issue 967: accumulating energies in ISM mono DMX */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index b0199a301e..1b09291125 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -196,7 +196,11 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { +#ifdef NONBE_FIX_967_ISM_MONO_DMX + ivas_ism_mono_dmx( st_ivas, p_output, output_frame ); +#else ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); +#endif } 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 ) ) { @@ -388,7 +392,11 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { +#ifdef NONBE_FIX_967_ISM_MONO_DMX + ivas_ism_mono_dmx( st_ivas, p_output, output_frame ); +#else ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); +#endif } else if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { @@ -512,7 +520,11 @@ ivas_error ivas_jbm_dec_tc( } else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { +#ifdef NONBE_FIX_967_ISM_MONO_DMX + ivas_ism_mono_dmx( st_ivas, p_output, output_frame ); +#else ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); +#endif /* add W */ for ( n = 0; n < nchan_out; n++ ) diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 0936209639..3f42541d6b 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -48,7 +48,9 @@ #define DOWNMIX_ALPHA 0.95f /* Smoothing coefficient */ #define DOWNMIX_MAX_GAIN 4.0f /* Maximum allowed gain */ -#define MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS 4 +#ifndef NONBE_FIX_967_ISM_MONO_DMX +#define MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS 4 // FhG esr: this seems to be obsolete; not related to issue 967 +#endif /*------------------------------------------------------------------------- @@ -99,12 +101,16 @@ void ivas_mono_dmx_renderer_close( /*------------------------------------------------------------------------- - * ivas_mono_downmix_render_passive() + * ivas_ism_mono_dmx() * * Downmix process *------------------------------------------------------------------------*/ +#ifdef NONBE_FIX_967_ISM_MONO_DMX +void ivas_ism_mono_dmx( +#else void ivas_mono_downmix_render_passive( +#endif Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output_f[], /* i/o: synthesized core-coder transport channels/mono output */ const int16_t output_frame /* i : output frame length */ @@ -112,6 +118,9 @@ void ivas_mono_downmix_render_passive( { int16_t i, j, numInputChannels; float proto_signal[L_FRAME48k], eq; +#ifdef NONBE_FIX_967_ISM_MONO_DMX + float inputEnergy_local, protoEnergy_local; +#endif MONO_DOWNMIX_RENDERER_HANDLE hDownmix; numInputChannels = st_ivas->nSCE; @@ -134,6 +143,10 @@ void ivas_mono_downmix_render_passive( hDownmix = st_ivas->hMonoDmxRenderer; set_zero( proto_signal, output_frame ); +#ifdef NONBE_FIX_967_ISM_MONO_DMX + inputEnergy_local = 0; + protoEnergy_local = 0; +#endif /* Compute the Proto Signal */ for ( i = 0; i < numInputChannels; i++ ) @@ -141,6 +154,18 @@ void ivas_mono_downmix_render_passive( v_add( output_f[i], proto_signal, proto_signal, output_frame ); } +#ifdef NONBE_FIX_967_ISM_MONO_DMX + /* compute the input energy, proto energy */ + for ( i = 0; i < output_frame; i++ ) + { + protoEnergy_local += proto_signal[i] * proto_signal[i]; + + for ( j = 0; j < numInputChannels; j++ ) + { + inputEnergy_local += ( output_f[j][i] * output_f[j][i] ); + } + } +#else /* compute the input energy, proto energy after smoothing */ hDownmix->inputEnergy *= DOWNMIX_ALPHA; hDownmix->protoEnergy *= DOWNMIX_ALPHA; @@ -153,6 +178,13 @@ void ivas_mono_downmix_render_passive( hDownmix->inputEnergy += ( output_f[j][i] * output_f[j][i] ); } } +#endif +#ifdef NONBE_FIX_967_ISM_MONO_DMX + hDownmix->inputEnergy *= DOWNMIX_ALPHA; + hDownmix->protoEnergy *= DOWNMIX_ALPHA; + hDownmix->inputEnergy += ( 1.0f - DOWNMIX_ALPHA ) * inputEnergy_local; + hDownmix->protoEnergy += ( 1.0f - DOWNMIX_ALPHA ) * protoEnergy_local; +#endif /* compute the eq factor */ eq = min( DOWNMIX_MAX_GAIN, sqrtf( hDownmix->inputEnergy / ( EPSILON + hDownmix->protoEnergy ) ) ); -- GitLab From a4bd3ecc481e2148ab60bf4e9d035babe1e974dd Mon Sep 17 00:00:00 2001 From: Andrea Eichenseer Date: Wed, 24 Jan 2024 16:19:47 +0100 Subject: [PATCH 2/3] Clang format. --- lib_dec/ivas_mono_dmx_renderer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 3f42541d6b..1da119f000 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -46,8 +46,8 @@ * Local constants *------------------------------------------------------------------------*/ -#define DOWNMIX_ALPHA 0.95f /* Smoothing coefficient */ -#define DOWNMIX_MAX_GAIN 4.0f /* Maximum allowed gain */ +#define DOWNMIX_ALPHA 0.95f /* Smoothing coefficient */ +#define DOWNMIX_MAX_GAIN 4.0f /* Maximum allowed gain */ #ifndef NONBE_FIX_967_ISM_MONO_DMX #define MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS 4 // FhG esr: this seems to be obsolete; not related to issue 967 #endif @@ -162,7 +162,7 @@ void ivas_mono_downmix_render_passive( for ( j = 0; j < numInputChannels; j++ ) { - inputEnergy_local += ( output_f[j][i] * output_f[j][i] ); + inputEnergy_local += ( output_f[j][i] * output_f[j][i] ); } } #else -- GitLab From e4bf4e40824252651c673d7420f506d359045898 Mon Sep 17 00:00:00 2001 From: knj Date: Thu, 25 Jan 2024 16:04:24 +0100 Subject: [PATCH 3/3] fix output config in self_test[_ltv].prm files to be in line with tag --- scripts/config/self_test.prm | 2 +- scripts/config/self_test_ltv.prm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm index 203c8dfc4d..96cceba07c 100644 --- a/scripts/config/self_test.prm +++ b/scripts/config/self_test.prm @@ -402,7 +402,7 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 // 3 ISM with metadata at 48 kbps, 48 kHz in, 48 kHz out, EXT out ../IVAS_cod -ism 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv 48000 48 testv/stv3ISM48s.wav bit -../IVAS_dec MONO 48 bit testv/stv3ISM48s.48000_48-48_MONO.tst +../IVAS_dec EXT 48 bit testv/stv3ISM48s.48000_48-48_MONO.tst // 3 ISM with metadata at 64 kbps, 48 kHz in, 48 kHz out, EXT out ../IVAS_cod -ism 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv 64000 48 testv/stv3ISM48s.wav bit diff --git a/scripts/config/self_test_ltv.prm b/scripts/config/self_test_ltv.prm index 0aa3f764dc..971a577ed8 100644 --- a/scripts/config/self_test_ltv.prm +++ b/scripts/config/self_test_ltv.prm @@ -401,7 +401,7 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 // 3 ISM with metadata at 48 kbps, 48 kHz in, 48 kHz out, EXT out ../IVAS_cod -ism 3 testv/ltvISM1.csv testv/ltvISM2.csv testv/ltvISM3.csv 48000 48 testv/ltv48_3ISM.wav bit -../IVAS_dec MONO 48 bit testv/ltv48_3ISM.48000_48-48_MONO.tst +../IVAS_dec EXT 48 bit testv/ltv48_3ISM.48000_48-48_MONO.tst // 3 ISM with metadata at 64 kbps, 48 kHz in, 48 kHz out, EXT out ../IVAS_cod -ism 3 testv/ltvISM1.csv testv/ltvISM2.csv testv/ltvISM3.csv 64000 48 testv/ltv48_3ISM.wav bit -- GitLab