From b40a7b3fa104e607acd8ef6b006a84ec5e46cc0d Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 23 Jan 2024 20:20:23 +0530 Subject: [PATCH] Fix for one crash issue observed with LTV [x] Reason of crash: Precision loss in masa_to_total_energy_ratio array causing invalid reading of bitstream. [x] Fix: Changed the q factor of masa_to_total_energy_ratio array from 18 to 25 and some minor related adjustments. --- lib_dec/ivas_masa_dec.c | 6 +++--- lib_dec/ivas_qmetadata_dec.c | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 8870a16a3..3a37fc231 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -3156,13 +3156,13 @@ static int16_t ivas_decode_masaism_metadata( /* Read MASA-to-total energy ratios */ #ifdef IVAS_FLOAT_FIXED - Word16 q = 18; + Word16 q = 25; ivas_omasa_decode_masa_to_total_fx( bit_stream, next_bit_pos, hMasaIsmData->masa_to_total_energy_ratio_fx, nbands, nblocks, &q ); - FOR( int k = 0; k < nblocks; k++ ) + FOR( int k = 0; k < (nblocks != 1 ? nblocks : MAX_PARAM_SPATIAL_SUBFRAMES); k++ ) { - FOR( int j = 0; j < nbands; j++ ) + FOR( int j = 0; j < (nbands != 1 ? nbands : MASA_FREQUENCY_BANDS); j++ ) { hMasaIsmData->masa_to_total_energy_ratio[k][j] = (float) hMasaIsmData->masa_to_total_energy_ratio_fx[k][j] / (float) ( 1 << q ); } diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index 23c701e6a..dc627ef74 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -7915,16 +7915,16 @@ static void read_stream_dct_coeffs_omasa_fx( } /* deindex */ - q_dct_data_fx[0] = L_shl( Mpy_32_16_1( step, q_idx[0] ), 2 ); // q = 18 + q_dct_data_fx[0] = L_shl( Mpy_32_16_1( step, shl( q_idx[0], 7) ), 2 ); // q = 25 FOR( i = 1; i < len_stream; i++ ) { IF( ( q_idx[i] % 2 ) == 0 ) { - q_dct_data_fx[i] = L_shl( Mpy_32_16_1( step, negate( shr( q_idx[i], 1 ) ) ), 2 ); + q_dct_data_fx[i] = L_shl( Mpy_32_16_1( step, negate( shl( q_idx[i], 6 ) ) ), 2 ); } ELSE { - q_dct_data_fx[i] = L_shl( Mpy_32_16_1( step, shr( q_idx[i] + 1, 1 ) ), 2 ); + q_dct_data_fx[i] = L_shl( Mpy_32_16_1( step, shl( q_idx[i] + 1, 6 ) ), 2 ); } } @@ -8046,8 +8046,8 @@ void ivas_omasa_decode_masa_to_total_fx( { Word16 i, j, k; Word16 q_idx[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS]; - Word32 q_dct_data_fx[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS], // q = 18 - dct_data_tmp_fx[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS]; // q = 18 + Word32 q_dct_data_fx[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS], // q = 25 + dct_data_tmp_fx[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS]; // q = 25 Word16 n_streams, len_stream; /* Setup coding parameters */ @@ -8101,7 +8101,7 @@ void ivas_omasa_decode_masa_to_total_fx( { FOR( j = 0; j < nbands; j++ ) { - masa_to_total_energy_ratio_fx[i][j] = L_max( 0, L_shl( q_dct_data_fx[k], *q - 18 ) ); + masa_to_total_energy_ratio_fx[i][j] = L_max( 0, L_shl( q_dct_data_fx[k], *q - 25 ) ); masa_to_total_energy_ratio_fx[i][j] = L_min( 1 << *q, masa_to_total_energy_ratio_fx[i][j] ); k++; } -- GitLab