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

Fix for 3GPP issue 1731: OMASA BASOP bitstream crashing float decoder (ivas_mdct_core_invQ)

Link #1731
parent 1dc85670
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -383,7 +383,7 @@ typedef enum
#define PARAM_ISM_MAX_CHAN                      16
#define PARAM_ISM_HYS_BUF_SIZE                  10

#define STEP_PARAM_ISM_POW_RATIO_NBITS_Q15      (4681)  /* 1.0f / (float)((1 << PARAM_ISM_POW_RATIO_NBITS) - 1) */
#define STEP_PARAM_ISM_POW_RATIO_NBITS_Q31      (306783378)  /* 1.0f / (float)((1 << PARAM_ISM_POW_RATIO_NBITS) - 1) */

/* ISM DTX */
#define ISM_Q_STEP_FX                           ( 10485760 )  // Q22
+3 −3
Original line number Diff line number Diff line
@@ -1308,7 +1308,7 @@ Word16 valid_ratio_index_fx(
void reconstruct_ism_ratios_fx(
    Word16 *ratio_ism_idx,     /* i  : index vector                 Q0  */
    const Word16 nchan_ism,    /* i  : number of components/objects Q0  */
    const Word16 step,         /* i  : quantization step            Q15 */
    const Word32 step,         /* i  : quantization step            Q31 */
    Word32 *q_energy_ratio_ism /* o  : reconstructed ISM values     Q30 */
)
{
@@ -1320,7 +1320,7 @@ void reconstruct_ism_ratios_fx(
    
    FOR( i = 0; i < nchan_ism - 1; i++ )
    {
        q_energy_ratio_ism[i] = L_shl( L_mult( ratio_ism_idx[i], step ), 14 ); // q0 + q15 + 1 + 14 = q30;
        q_energy_ratio_ism[i] = W_extract_l(W_shr( W_mult_32_16( step, ratio_ism_idx[i] ), 2 )); // q0 + q31 + 1 - 2 = q30;
        move32();

        sum = L_add( sum, q_energy_ratio_ism[i] ); // Q30
+1 −1
Original line number Diff line number Diff line
@@ -115,7 +115,7 @@ ivas_error ivas_masa_dec_reconfigure_fx(
void reconstruct_ism_ratios_fx(
    Word16 *ratio_ism_idx,     /* i  : index vector                 Q0  */
    const Word16 nchan_ism,    /* i  : number of components/objects Q0  */
    const Word16 step,         /* i  : quantization step            Q15 */
    const Word32 step,         /* i  : quantization step            Q31 */
    Word32 *q_energy_ratio_ism /* o  : reconstructed ISM values     Q30 */
);

+1 −1
Original line number Diff line number Diff line
@@ -3097,7 +3097,7 @@ static void decode_ism_ratios_fx(
        /* reconstructed values */
        FOR( band = 0; band < nbands; band++ )
        {
            reconstruct_ism_ratios_fx( ratio_ism_idx[band], n_ism, STEP_PARAM_ISM_POW_RATIO_NBITS_Q15, ratio_ism[sf][band] );
            reconstruct_ism_ratios_fx( ratio_ism_idx[band], n_ism, STEP_PARAM_ISM_POW_RATIO_NBITS_Q31, ratio_ism[sf][band] );
        }

        test();
+1 −7
Original line number Diff line number Diff line
@@ -4666,7 +4666,6 @@ static void ivas_encode_masaism_metadata_fx(
    UWord16 index_theta, index_phi;
    Word16 ratio_ism_fx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS];
    Word16 ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], ratio_ism_idx_prev_sf[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS];
    Word16 step;
    Word32 energy_ism, energy_ism_ind[MAX_NUM_OBJECTS];
    Word16 tmp, rotate, energy_ism_e, energy_ism_ind_e[MAX_NUM_OBJECTS];
    Word16 n_ism_tmp, i;
@@ -4919,11 +4918,6 @@ static void ivas_encode_masaism_metadata_fx(
    /* quantize ism_ratios */
    IF( GT_16( nchan_ism, 1 ) )
    {
        /* inv_step = ( ( 1 << PARAM_ISM_POW_RATIO_NBITS ) - 1 ); *
         * step = 1.0f / inv_step;                                */
        step = 4681; // 1.f / ( ( 1 << PARAM_ISM_POW_RATIO_NBITS ) - 1 ) => 1.f / 7 in Q15
        move16();

        rotate = 0;
        n_ism_tmp = 0;
        move16();
@@ -4968,7 +4962,7 @@ static void ivas_encode_masaism_metadata_fx(
                }

                /* reconstructed values */
                reconstruct_ism_ratios_fx( ratio_ism_idx[band], nchan_ism, step, hMasa->data.hOmasaData->q_energy_ratio_ism_fx[sf][band] );
                reconstruct_ism_ratios_fx( ratio_ism_idx[band], nchan_ism, STEP_PARAM_ISM_POW_RATIO_NBITS_Q31, hMasa->data.hOmasaData->q_energy_ratio_ism_fx[sf][band] );
            }
            test();
            IF( GT_16( nchan_ism, 2 ) && EQ_16( idx_separated_object, sub( nchan_ism, 1 ) ) )