From fcbd610686c4bf349752f6e2b1e1aa3b02f8878b Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Tue, 29 Apr 2025 21:46:50 +0200 Subject: [PATCH] port to float ref --- 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 | 41 ++++++++++++++++++++++++++++---- 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index dee8963c7..118dd45a1 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5489,7 +5489,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 00612788b..41774e7af 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -189,6 +189,7 @@ #define NONBE_FIX_935_EARLY_REFLECTIONS_WRONG_ORDER /* Qualcomm: issue 953: fix order or ER channels in LC mode*/ #define FIX_956_DECODER_COMMAND_LINE_FIX /* VA: Output correct error message when the decoder command-line has too many mandatory arguments. */ #define FIX_955_FASTCONV_REND_IN_ISM /* VA: put FastConv rendering call under DEBUGGING */ +#define NONBE_FIX_967_ISM_MONO_DMX /* FhG: issue 967: accumulating energies in ISM mono DMX */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 40766887b..fb7a1f1ef 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 6610e4620..a5845d775 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -46,9 +46,11 @@ * Local constants *------------------------------------------------------------------------*/ -#define DOWNMIX_ALPHA 0.95f /* Smoothing coefficient */ -#define DOWNMIX_MAX_GAIN 4.0f /* Maximum allowed gain */ -#define MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS 4 +#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 /*------------------------------------------------------------------------- @@ -99,12 +101,15 @@ 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 +117,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 +142,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 +153,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 +177,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