From e0d2ebe1640492ea5322ee5f68f5685380db2d73 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 11 Apr 2025 17:00:53 +0530 Subject: [PATCH] Fix for 3GPP issue 1458: Crash with new testcase in pytest suite - ISM with DTX, bitrate switching + JBM to BINAURAL_ROOM_IR Link #1458 --- lib_dec/ivas_jbm_dec_fx.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 8c5a9e9af..74af57bd5 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2550,7 +2550,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( DECODER_TC_BUFFER_HANDLE hTcBuffer; Word32 output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; - Word16 nchan_in, nchan_out; + Word16 nchan_in, nchan_out, gd_bits, n_chan_inp, i, shift; IF( !st_ivas->hDecoderConfig->Opt_tsm ) { return IVAS_ERR_OK; @@ -2637,17 +2637,44 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ set16_fx( st_ivas->hIsmRendererData->interpolator_fx, 32767, hTcBuffer->n_samples_granularity ); // 32767=1.0f in Q15 - ivas_ism_render_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ); + ivas_ism_render_sf_fx( st_ivas, p_output_fx, hTcBuffer->n_samples_granularity ); st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; *st_ivas->hCrendWrapper->p_io_qfactor = 11; move16(); + + shift = MAX_16; + move16(); + n_chan_inp = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ); + + FOR( i = 0; i < n_chan_inp; i++ ) + { + shift = s_min( shift, L_norm_arr( p_output_fx[i], hTcBuffer->n_samples_granularity ) ); + } + + gd_bits = sub( find_guarded_bits_fx( imult1616( hTcBuffer->subframe_nbslots[0], hTcBuffer->n_samples_granularity ) ), shift ); + + *st_ivas->hCrendWrapper->p_io_qfactor = sub( *st_ivas->hCrendWrapper->p_io_qfactor, gd_bits ); + move16(); + + FOR( i = 0; i < n_chan_inp; i++ ) + { + scale_sig32( p_output_fx[i], hTcBuffer->n_samples_granularity, sub( *st_ivas->hCrendWrapper->p_io_qfactor, Q11 ) ); // Q(*st_ivas->hCrendWrapper->p_io_qfactor) + } + IF( NE_32( ( error = ivas_rend_crendProcessSubframe( 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 ) ), IVAS_ERR_OK ) ) { return error; } + + FOR( i = 0; i < n_chan_inp; i++ ) + { + scale_sig32( p_output_fx[i], hTcBuffer->n_samples_granularity, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q(11) + } + *st_ivas->hCrendWrapper->p_io_qfactor = Q11; + move16(); } } ELSE -- GitLab