From 1d31791c7b1879ec4b59d1d92c0d6696c6b45dec Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 9 Apr 2026 17:14:21 +0200 Subject: [PATCH 1/2] Add headroom to input of ivas_rend_crendProcessSubframe_fx() for ivas_mdft_fx() calculation --- lib_com/options.h | 1 + lib_dec/ivas_dec_render_fx.c | 33 +++++++++++++++++++++++++++++++++ lib_rend/ivas_crend_fx.c | 5 ++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index eead3c8ca..26177cbb4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -123,6 +123,7 @@ #define FIX_BASOP_2497_MCMASA_LFE_WRONG_SF_INDEX /* Nokia: BASOP 2497: Fix wrong subframe index in McMASA LFE synth. */ #define FIX_BASOP_2496_OMASA_OBJ_EDIT_WRONG_ASSIGN /* Nokia: BASOP 2496: Fix wrong assignment in OMASA object edit code */ #define FIX_2495_Q_ALIGN_OSBA_RENDERER /* FhG: Basop issue #2495: Corrected exponent scaling of outAudio.data_fx before buffer accumulation in renderSbaToBinaural(). */ +#define FIX_2505_IVAS_DEC_SEGFAULT /* FhG: BASOP #2505: Add headroom to input of ivas_rend_crendProcessSubframe_fx() for ivas_mdft_fx() calculation */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_dec_render_fx.c b/lib_dec/ivas_dec_render_fx.c index ec74f595e..73edbeb33 100644 --- a/lib_dec/ivas_dec_render_fx.c +++ b/lib_dec/ivas_dec_render_fx.c @@ -1083,15 +1083,48 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( ivas_ism_render_sf_fx( st_ivas, renderer_type_old, p_output_fx, n_samples_granularity ); st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; +#ifdef FIX_2505_IVAS_DEC_SEGFAULT + Word16 subframe_len, guard_bits, q_shift_min; + + IF( NE_32( ( error = getAudioConfigNumChannels( IVAS_AUDIO_CONFIG_7_1_4, &nchan_in ) ), IVAS_ERR_OK ) ) + { + return error; + } + + subframe_len = imult1616( st_ivas->hTcBuffer->subframe_nbslots[0], n_samples_granularity ); + guard_bits = find_guarded_bits_fx( subframe_len ); + + q_shift_min = L_norm_arr( p_output_fx[0], subframe_len ); + FOR( Word16 i = 1; i < nchan_in; i++ ) + { + q_shift_min = s_min( q_shift_min, L_norm_arr( p_output_fx[i], subframe_len ) ); + } + q_shift_min = sub( q_shift_min, guard_bits ); + + FOR( Word16 i = 0; i < nchan_in; i++ ) + { + scale_sig32( p_output_fx[i], *nSamplesRendered, q_shift_min ); + } + *st_ivas->hCrendWrapper->p_io_qfactor = add( Q11, q_shift_min ); +#else *st_ivas->hCrendWrapper->p_io_qfactor = 11; move16(); +#endif IF( NE_32( ( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ), IVAS_ERR_OK ) ) { return error; } +#ifdef FIX_2505_IVAS_DEC_SEGFAULT + FOR( Word16 i = 0; i < nchan_in; i++ ) + { + scale_sig32( p_output_fx[i], *nSamplesRendered, negate( q_shift_min ) ); // Q11 + } + *st_ivas->hCrendWrapper->p_io_qfactor = Q11; + move16(); +#endif } } ELSE diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 989215e4f..5e4192891 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1923,8 +1923,11 @@ static ivas_error ivas_rend_crendConvolver_fx( } } } - +#ifdef FIX_2505_IVAS_DEC_SEGFAULT + ivas_mdft_fx( pIn, pFreq_buf_re, pFreq_buf_im, subframe_length, subframe_length ); // Input guard bits are added two functions up the call chain before ivas_rend_crendProcessSubframe_fx() is called +#else ivas_mdft_fx( pIn, pFreq_buf_re, pFreq_buf_im, subframe_length, subframe_length ); +#endif i = add( i, 1 ); } } -- GitLab From bd1a6bc95010dd51413221b6e063213f3e1ab14d Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 10 Apr 2026 15:23:12 +0200 Subject: [PATCH 2/2] refacturing --- lib_dec/ivas_dec_render_fx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_dec_render_fx.c b/lib_dec/ivas_dec_render_fx.c index 73edbeb33..ee5105fde 100644 --- a/lib_dec/ivas_dec_render_fx.c +++ b/lib_dec/ivas_dec_render_fx.c @@ -1077,6 +1077,10 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( } ELSE IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { +#ifdef FIX_2505_IVAS_DEC_SEGFAULT + Word16 subframe_len, guard_bits, q_shift_min; + +#endif /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ set16_fx( st_ivas->hIsmRendererData->interpolator_fx, 32767, n_samples_granularity ); // 32767=1.0f in Q15 @@ -1084,7 +1088,6 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; #ifdef FIX_2505_IVAS_DEC_SEGFAULT - Word16 subframe_len, guard_bits, q_shift_min; IF( NE_32( ( error = getAudioConfigNumChannels( IVAS_AUDIO_CONFIG_7_1_4, &nchan_in ) ), IVAS_ERR_OK ) ) { -- GitLab