Commit 2091dc8a authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Fixed changes corresponding to float updates provided

[x] Orient_track updates fixed implementation.
[x] Fixed implementation for read_surround_coherence_hr
parent 321539c2
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1187,6 +1187,10 @@ enum
#define MASA_MAXIMUM_DIRECTIONS                 2
#define MASA_MAX_TRANSPORT_CHANNELS             2

#ifdef  NON_BE_FIX_1048_THRESHOLD_COH_BASOP
#define MASA_SUR_COH_THRESHOLD                  1e-7f
#define MASA_SUR_COH_PRECISION                  1e7f
#endif

#define MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS   5

+4 −0
Original line number Diff line number Diff line
@@ -919,7 +919,11 @@ void deindex_lvq_SHB(

        /* find idx_leader */
        i = 1;
#ifdef NONBE_FIX_1054_NEGATIVE_LVQ_INDEX
        while ( index > table_no_cv[i] )
#else
        while ( index >= table_no_cv[i] )
#endif
        {
            i++;
        }
+7 −0
Original line number Diff line number Diff line
@@ -68,6 +68,12 @@

/* #################### End DEBUGGING switches ############################ */

/* ################### Start FIXES switches ########################### */

#define NON_BE_FIX_1048_THRESHOLD_COH_BASOP             /* Nokia: Fix 1048 replace comparison with 0 with comparison to threshold, to align with BASOP*/
#define NONBE_FIX_1054_NEGATIVE_LVQ_INDEX               /* Nokia: issue 1054: Input to decode_comb in deindex_lvq_SHB should be positive */

/* #################### End FIXES switches ############################ */

#define BASOP_NOGLOB                                    /* Disable global symbols in BASOPs, Overflow/Carry in BASOPs disabled, additional BASOPs in case of Overflow */

@@ -94,6 +100,7 @@
#define BE_FIX_832_ASAN_ERROR_EFAP_OSBA                       /* FhG: issue #832: fix ASAN error caused by re-allocating EFAP memories in OSBA*/
#define NONBE_FIX_819_DOUBLE_PREC_COMB_FORMATS                /* VA: issue 820: Double precision arithmetic in combined formats */
#define NONBE_FIX_849_OMASA_BFI_CRASH                         /* VA: issue 849: fix OMASA 2TC and FEC crashes */
#define NONBE_FIX_738_QUATERNION_SLERP_PRECISION              /* Quaternion slerp changes*/
#define IVAS_FLOAT_FIXED
#define ISM_DISABLE
#define FIX_TMP_714
+29 −60
Original line number Diff line number Diff line
@@ -7940,6 +7940,9 @@ static int16_t read_surround_coherence_hr(
    IVAS_QDIRECTION *q_direction;
    int16_t min_index;
    int16_t d, idx;
#ifdef NON_BE_FIX_1048_THRESHOLD_COH_BASOP
    int32_t int_error_ratio_surr;
#endif
    coding_subbands = hQMetaData->q_direction[0].cfg.nbands;
    q_direction = hQMetaData->q_direction;

@@ -7963,6 +7966,11 @@ static int16_t read_surround_coherence_hr(
                error_ratio_surr = 1.0f - q_direction[0].band_data[j].energy_ratio[sf];
            }

#ifdef NON_BE_FIX_1048_THRESHOLD_COH_BASOP
            int_error_ratio_surr = (int32_t)(MASA_SUR_COH_PRECISION * error_ratio_surr);
            error_ratio_surr = (float)(int_error_ratio_surr * MASA_SUR_COH_THRESHOLD);
#endif

            if ( error_ratio_surr <= 0 )
            {
                error_ratio_surr = 0;
@@ -8087,7 +8095,7 @@ static Word16 read_surround_coherence_hr_fx(
    Word16 coding_subbands;
    Word16 no_cv_vec[MASA_MAXIMUM_CODING_SUBBANDS];
    Word16 bit_pos;
    Word32 error_ratio_surr_fx;
    Word64 error_ratio_surr_fx;
    Word16 idx_ER[MASA_MAXIMUM_CODING_SUBBANDS];
    Word16 bits_sur_coherence, bits_GR;
    Word16 j, k, sf;
@@ -8096,6 +8104,7 @@ static Word16 read_surround_coherence_hr_fx(
    IVAS_QDIRECTION *q_direction;
    Word16 min_index;
    Word16 d, idx;
    Word32 int_error_ratio_surr;
    coding_subbands = hQMetaData->q_direction[0].cfg.nbands;
    q_direction = hQMetaData->q_direction;

@@ -8105,63 +8114,24 @@ static Word16 read_surround_coherence_hr_fx(
    FOR( sf = 0; sf < hQMetaData->q_direction[0].cfg.nblocks; sf++ )
    {
        d = 0;
#ifdef IVAS_FLOAT_FIXED_TBD
        FOR( j = 0; j < coding_subbands; j++ )
        {
            error_ratio_surr_fx = 1 << *q;
            if ( hQMetaData->no_directions == 2 )
            {
                d += hQMetaData->twoDirBands[j];
                idx = max( d - 1, 0 );
                error_ratio_surr_fx = L_sub(
                    L_sub( 1 << *q, q_direction[0].band_data[j].energy_ratio_fx[sf] ),
                    q_direction[1].band_data[idx].energy_ratio_fx[sf] * hQMetaData->twoDirBands[j] );
            }
            ELSE
            {
                error_ratio_surr_fx = L_sub( 1 << *q, q_direction[0].band_data[j].energy_ratio_fx[sf] );
            }

            if ( error_ratio_surr_fx <= 53667 ) // Assuming max error of 10^(-4) in q = 29 => 10^(-4) * 2^(29)
            {
                error_ratio_surr_fx = 0;
                no_cv_vec[j] = 1;
                idx_ER[j] = 0;
            }
            ELSE
            {
                idx_ER[j] = 7; // masa_sq( error_ratio_surr, diffuseness_thresholds, DIRAC_DIFFUSE_LEVELS );
                no_cv_vec[j] = idx_cb_sur_coh_masa[idx_ER[j]] + 2;
            }
        }
#else
        /* NOTE: This block gives incorrect output with fixed point resulting in failures in pytest */
        /* TODO: Remove the intermediate conversion from fixed to float below */
        float tmp;
        float energy_ratio_j_sf;
        float energy_ratio_idx_sf;
        FOR( j = 0; j < coding_subbands; j++ )
        {
            energy_ratio_j_sf = (float) energy_ratio[0][j][sf] / ( ONE_IN_Q62 );

            tmp = 1.0f;
            IF( hQMetaData->no_directions == 2 )
            error_ratio_surr_fx = ONE_IN_Q62;
            IF( EQ_32( hQMetaData->no_directions, 2 ) )
            {
                d += hQMetaData->twoDirBands[j];
                idx = max( d - 1, 0 );

                energy_ratio_idx_sf = (float) energy_ratio[1][idx][sf] / ( ONE_IN_Q62 );

                tmp = 1.0f - energy_ratio_j_sf - energy_ratio_idx_sf * hQMetaData->twoDirBands[j];
                d = add( d, hQMetaData->twoDirBands[j] );
                idx = s_max( sub( d, 1 ), 0 );
                error_ratio_surr_fx = W_sub(
                    W_sub( ONE_IN_Q62, energy_ratio[0][j][sf] ),
                    energy_ratio[1][idx][sf] * hQMetaData->twoDirBands[j] );
            }
            ELSE
            {
                tmp = 1.0f - energy_ratio_j_sf;
                error_ratio_surr_fx = W_sub( ONE_IN_Q62, energy_ratio[0][j][sf] );
            }

            error_ratio_surr_fx = (Word32) ( tmp * ONE_IN_Q30 );

            IF( error_ratio_surr_fx <= 0 )
            IF( LE_64( error_ratio_surr_fx, ( 461168601842 ) ) ) // 1e-7 in Q62
            {
                error_ratio_surr_fx = 0;
                no_cv_vec[j] = 1;
@@ -8173,9 +8143,8 @@ static Word16 read_surround_coherence_hr_fx(
                no_cv_vec[j] = idx_cb_sur_coh_masa[idx_ER[j]] + 2;
            }
        }
#endif // !IVAS_FLOAT_FIXED_TBD

        IF( sum_s( no_cv_vec, coding_subbands ) == coding_subbands )
        IF( EQ_16( sum_s( no_cv_vec, coding_subbands ), coding_subbands ) )
        {
            /* surround coherence is zero */
            FOR( j = 0; j < coding_subbands; j++ )
@@ -8193,29 +8162,29 @@ static Word16 read_surround_coherence_hr_fx(
        {
            /* read how the surround coherence is encoded */
            byteBuffer = bitstream[bit_pos--];
            bits_sur_coherence += 1;
            bits_sur_coherence = add( bits_sur_coherence, 1 );

            IF( byteBuffer & 1 )
            {
                /* GR decoding */
                /* read GR order */
                byteBuffer = bitstream[bit_pos--];
                bits_sur_coherence += 1;
                bits_sur_coherence = add( bits_sur_coherence, 1 );

                /* read min index */
                bits_GR = bit_pos;
                min_index = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, MASA_MAX_NO_CV_SUR_COH, 0 );
                bits_sur_coherence += bits_GR - bit_pos;
                bits_sur_coherence = add( bits_sur_coherence, sub( bits_GR, bit_pos ) );

                /* read GR data */
                FOR( j = 0; j < coding_subbands; j++ )
                {
                    bits_GR = bit_pos;
                    /* decoding for min removed */
                    IF( no_cv_vec[j] > 1 )
                    IF( GT_16( no_cv_vec[j], 1 ) )
                    {
                        idx_sur_coh[j] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, no_cv_vec[j] - min_index, ( byteBuffer & 1 ) );
                        bits_sur_coherence += bits_GR - bit_pos;
                        bits_sur_coherence = add( bits_sur_coherence, sub( bits_GR, bit_pos ) );
                    }
                    ELSE
                    {
@@ -8225,9 +8194,9 @@ static Word16 read_surround_coherence_hr_fx(

                FOR( j = 0; j < coding_subbands; j++ )
                {
                    IF( no_cv_vec[j] > 1 )
                    IF( GT_16( no_cv_vec[j], 1 ) )
                    {
                        hQMetaData->surcoh_band_data[j].sur_coherence_index = idx_sur_coh[j] + min_index;
                        hQMetaData->surcoh_band_data[j].sur_coherence_index = L_add( (Word32) idx_sur_coh[j], L_deposit_l( min_index ) );
                        hQMetaData->surcoh_band_data[j].surround_coherence[sf] = sur_coherence_cb_masa[idx_cb_sur_coh_masa[idx_ER[j]] * MASA_MAX_NO_CV_SUR_COH + hQMetaData->surcoh_band_data[j].sur_coherence_index];
                    }
                    ELSE
@@ -8253,7 +8222,7 @@ static Word16 read_surround_coherence_hr_fx(
                /* deindex surround coherence */
                FOR( j = 0; j < coding_subbands; j++ )
                {
                    IF( no_cv_vec[j] > 1 )
                    IF( GT_16( no_cv_vec[j], 1 ) )
                    {
                        hQMetaData->surcoh_band_data[j].surround_coherence[sf] = sur_coherence_cb_masa[idx_cb_sur_coh_masa[idx_ER[j]] * MASA_MAX_NO_CV_SUR_COH + hQMetaData->surcoh_band_data[j].sur_coherence_index];
                    }
@@ -8267,7 +8236,7 @@ static Word16 read_surround_coherence_hr_fx(
    }

    /* Replace return value with the actual read bits. bits_sur_coherence might show wrong count at this point. */
    bits_sur_coherence = *p_bit_pos - bit_pos;
    bits_sur_coherence = sub( *p_bit_pos, bit_pos );
    *p_bit_pos = bit_pos;

    return bits_sur_coherence;
+8 −0
Original line number Diff line number Diff line
@@ -3049,7 +3049,11 @@ void stereo_dft_dec_smooth_parameters(
        if ( hStereoDft->frame_sid_nodata )
        {
            /* set new xfade target if new itd received */
#ifdef NONBE_FIX_1010_STEREO_CNG_DIV_BY_ZERO
            if ( hStereoDft->ipd_xfade_counter < STEREO_DFT_ITD_CNG_XFADE )
#else
            if ( hStereoDft->gipd[k + k_offset] != hStereoDft->ipd_xfade_target )
#endif
            {
                if ( ( hStereoDft->gipd[k + k_offset] - hStereoDft->ipd_xfade_prev ) > EVS_PI )
                {
@@ -3095,7 +3099,11 @@ void stereo_dft_dec_smooth_parameters(
        if ( hStereoDft->frame_sid_nodata )
        {
            /* set new xfade target if new itd received */
#ifdef NONBE_FIX_1010_STEREO_CNG_DIV_BY_ZERO
            if ( hStereoDft->itd_xfade_counter < STEREO_DFT_ITD_CNG_XFADE )
#else
            if ( hStereoDft->itd[k + k_offset] != hStereoDft->itd_xfade_target )
#endif
            {
                hStereoDft->itd_xfade_target = hStereoDft->itd[k + k_offset];
                hStereoDft->itd_xfade_step = ( hStereoDft->itd_xfade_target - hStereoDft->itd_xfade_prev ) / ( STEREO_DFT_ITD_CNG_XFADE - hStereoDft->itd_xfade_counter );
Loading