Commit b40a7b3f authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

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.
parent f64098bc
Loading
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -3156,13 +3156,13 @@ static int16_t ivas_decode_masaism_metadata(


    /* Read MASA-to-total energy ratios */
    /* Read MASA-to-total energy ratios */
#ifdef IVAS_FLOAT_FIXED
#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 );
    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 );
            hMasaIsmData->masa_to_total_energy_ratio[k][j] = (float) hMasaIsmData->masa_to_total_energy_ratio_fx[k][j] / (float) ( 1 << q );
        }
        }
+6 −6
Original line number Original line Diff line number Diff line
@@ -7915,16 +7915,16 @@ static void read_stream_dct_coeffs_omasa_fx(
    }
    }


    /* deindex */
    /* 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++ )
    FOR( i = 1; i < len_stream; i++ )
    {
    {
        IF( ( q_idx[i] % 2 ) == 0 )
        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
        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 i, j, k;
    Word16 q_idx[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS];
    Word16 q_idx[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS];
    Word32 q_dct_data_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 = 18
        dct_data_tmp_fx[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS];  // q = 25
    Word16 n_streams, len_stream;
    Word16 n_streams, len_stream;


    /* Setup coding parameters */
    /* Setup coding parameters */
@@ -8101,7 +8101,7 @@ void ivas_omasa_decode_masa_to_total_fx(
    {
    {
        FOR( j = 0; j < nbands; j++ )
        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] );
            masa_to_total_energy_ratio_fx[i][j] = L_min( 1 << *q, masa_to_total_energy_ratio_fx[i][j] );
            k++;
            k++;
        }
        }