From 3013c508e7785252d2ecee37cfcba918c8fa7277 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 3 Jul 2025 16:14:17 +0530 Subject: [PATCH] Fix for 3GPP issue 1797: Decoder crash for MC 7.1+4 at 128kbps decoding to mono/stereo in ivas_ls_setup_conversion_process_mdct_param_mc_fx() Link #1797 --- lib_dec/ivas_out_setup_conversion_fx.c | 38 ++++++++++++++++++++------ 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/lib_dec/ivas_out_setup_conversion_fx.c b/lib_dec/ivas_out_setup_conversion_fx.c index 93a7c204e..2135cd6d6 100644 --- a/lib_dec/ivas_out_setup_conversion_fx.c +++ b/lib_dec/ivas_out_setup_conversion_fx.c @@ -1028,6 +1028,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( Word16 start, stop, start_tcx5, stop_tcx5; Word16 mct_chan_mode[MAX_CICP_CHANNELS]; + Word16 all_ch_ignored; // Flag for checking if all channels are ignored /* Declare all handles */ LSSETUP_CONVERSION_HANDLE hLsSetUpConversion; @@ -1130,13 +1131,22 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( set_zero_fx( target_ch_ener_fx, MAX_OUTPUT_CHANNELS ); Word16 max_e = 0; move16(); + all_ch_ignored = 1; + move16(); FOR( idx = 0; idx < nchan_transport; idx++ ) { IF( NE_16( mct_chan_mode[idx], MCT_CHAN_MODE_IGNORE ) ) { max_e = s_max( max_e, x_e[idx][0] ); + all_ch_ignored = 0; + move16(); } } + if ( all_ch_ignored ) + { + max_e = 31; + move16(); + } FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ ) { set_zero_fx( real_in_buffer_fx, PARAM_MC_MAX_BANDS_IN_PARAMETER_BAND * PARAM_MC_BAND_TO_MDCT_BAND_RATIO * MAX_TRANSPORT_CHANNELS ); @@ -1164,22 +1174,32 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( } } } - Word16 shift = 1; + input_exp = max_e; move16(); - FOR( i = 0; i < num_bands * nchan_transport; ++i ) + IF( all_ch_ignored == 0 ) { - real_in_buffer_fx[i] = L_shr( real_in_buffer_fx[i], shift ); - move32(); - imag_in_buffer_fx[i] = L_shr( imag_in_buffer_fx[i], shift ); - move32(); + Word16 shift = 1; + move16(); + FOR( i = 0; i < num_bands * nchan_transport; ++i ) + { + real_in_buffer_fx[i] = L_shr( real_in_buffer_fx[i], shift ); + move32(); + imag_in_buffer_fx[i] = L_shr( imag_in_buffer_fx[i], shift ); + move32(); + } + input_exp = add( input_exp, shift ); } - input_exp = max_e; - move16(); - input_exp = add( input_exp, shift ); + cmplx_matrix_square_fx( real_in_buffer_fx, imag_in_buffer_fx, num_bands, nchan_transport, real_buffer_fx, imag_buffer_fx, input_exp, &output_exp ); v_add_32( cx_fx[bandIdx], real_buffer_fx, cx_fx[bandIdx], i_mult( nchan_transport, nchan_transport ) ); /*Q=Q_real_buffer=Q_imag_buffer=output_exp*/ v_add_32( cx_imag_fx[bandIdx], imag_buffer_fx, cx_imag_fx[bandIdx], i_mult( nchan_transport, nchan_transport ) ); /*Q=Q_real_buffer=Q_imag_buffer=output_exp*/ } + if ( all_ch_ignored ) + { + output_exp = 29; + move16(); + } + Word16 exp_in = 10, exp_out = 0; move16(); move16(); -- GitLab