Commit b93d1532 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh Committed by Manuel Jander
Browse files

Fix for 3GPP issue 1140: Missing conversion of some flt. pt. functions in the BASOP code

Link #1140
parent e0b75f08
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -183,14 +183,14 @@ Word16 Q_factor( float x )
{
    Word16 Q = 15;
    if ( x >= 1 || x <= -1 )
        Q = norm_s( (Word16) abs( (Word32) x ) );
        Q = norm_s( (Word16) L_abs( (Word32) x ) );
    return Q;
}
Word16 Q_factor_L( float x )
{
    Word16 Q = 31;
    if ( x >= 1 || x <= -1 )
        Q = norm_l( abs( (Word32) x ) );
        Q = norm_l( L_abs( (Word32) x ) );
    return Q;
}
Word16 Q_factor_L_32( Word32 x )
@@ -206,7 +206,7 @@ Word16 Q_factor_arr( float *x, Word16 l )
    for ( int i = 0; i < l; i++ )
    {
        if ( x[i] >= 1 || x[i] <= -1 )
            Q = s_min( Q, norm_s( (Word16) abs( (Word32) x[i] ) ) );
            Q = s_min( Q, norm_s( (Word16) L_abs( (Word32) x[i] ) ) );
    }
    return Q;
}
@@ -216,7 +216,7 @@ Word16 Q_factor_arrL( float *x, Word16 l )
    for ( int i = 0; i < l; i++ )
    {
        if ( x[i] >= 1 || x[i] <= -1 )
            Q = s_min( Q, norm_l( (Word32) abs( (Word32) x[i] ) ) );
            Q = s_min( Q, norm_l( (Word32) L_abs( (Word32) x[i] ) ) );
    }
    return Q;
}
+25 −14
Original line number Diff line number Diff line
@@ -4004,7 +4004,8 @@ void ivas_get_spar_md_from_dirac_enc_fx(
        move16();
        P_norm_fx[0] = 0;
        move32();
        FOR( i = 0; i < max( 0, sub( foa_ch, ndm ) ); i++ )
        Word16 len = s_max( 0, sub( foa_ch, ndm ) );
        FOR( i = 0; i < len; i++ )
        {
            P_norm_fx[0] = L_add( P_norm_fx[0], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31
            move32();
@@ -4014,7 +4015,8 @@ void ivas_get_spar_md_from_dirac_enc_fx(

        P_norm_fx[1] = 0;
        move32();
        FOR( ; i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ); i++ )
        len = s_max( 0, sub( s_min( num_ch, hoa2_ch ), ndm ) );
        FOR( ; i < len; i++ ) // max( 0, ( min( num_ch, hoa2_ch ) - ndm ) )
        {
            P_norm_fx[1] = L_add( P_norm_fx[1], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31
            move32();
@@ -4031,8 +4033,8 @@ void ivas_get_spar_md_from_dirac_enc_fx(
        }
        P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[min( diff_norm_order3_fx, max( 0, ( num_ch - ndm ) ) )] ); // 2*q_P_re - 31
        move32();

        FOR( i = 0; i < max( 0, ( foa_ch - ndm ) ); i++ )
        len = s_max( 0, sub( foa_ch, ndm ) );
        FOR( i = 0; i < len; i++ ) // i < max( 0, ( foa_ch - ndm ) )
        {
            idx = sub( remix_order[i + ndm], ndm );
            P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ); // 2*q_P_re - 31
@@ -4045,7 +4047,8 @@ void ivas_get_spar_md_from_dirac_enc_fx(
                move32();
            }
        }
        FOR( ; i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ); i++ )
        len = s_max( 0, sub( s_min( num_ch, hoa2_ch ), ndm ) );
        FOR( ; i < len; i++ ) // i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) )
        {
            idx = sub( remix_order[i + ndm], ndm );
            P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ); // 2*q_P_re - 31
@@ -4057,6 +4060,7 @@ void ivas_get_spar_md_from_dirac_enc_fx(
                move32();
            }
        }

        FOR( ; i < ( num_ch - ndm ); i++ )
        {
            idx = sub( remix_order[i + ndm], ndm );
@@ -4222,7 +4226,8 @@ void ivas_get_spar_md_from_dirac_enc_fx(
                    /*normalize 2nd order*/
                    norm_fx = 0;
                    move32();
                    FOR( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ )
                    Word16 min_ch_order = s_min( hoa2_ch_order, num_ch_order );
                    FOR( ch = foa_ch; ch < min_ch_order; ch++ )
                    {
                        norm_fx = L_add( norm_fx, Mpy_32_32( response_avg_fx[ch], response_avg_fx[ch] ) ); // q29
                    }
@@ -4243,7 +4248,8 @@ void ivas_get_spar_md_from_dirac_enc_fx(
                        move16();
                    }
                    norm_fx = L_shr( norm_fx, sub( 1, norm_q ) ); // q30
                    FOR( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ )
                    min_ch_order = s_min( hoa2_ch_order, num_ch_order );
                    FOR( ch = foa_ch; ch < min_ch_order; ch++ )
                    {
                        IF( LT_32( norm_fx, EPSILON_FX_THR ) )
                        {
@@ -4557,7 +4563,8 @@ void ivas_get_spar_md_from_dirac_fx(
        move16();
        P_norm_fx[0] = 0;
        move32();
        FOR( i = 0; i < max( 0, sub( foa_ch, ndm ) ); i++ )
        Word16 len = s_max( 0, sub( foa_ch, ndm ) );
        FOR( i = 0; i < len; i++ ) // i < max( 0, sub( foa_ch, ndm ) )
        {
            P_norm_fx[0] = L_add( P_norm_fx[0], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31
            move32();
@@ -4567,7 +4574,8 @@ void ivas_get_spar_md_from_dirac_fx(

        P_norm_fx[1] = 0;
        move32();
        FOR( ; i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ); i++ )
        len = s_max( 0, sub( s_min( num_ch, hoa2_ch ), ndm ) );
        FOR( ; i < len; i++ ) // i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) )
        {
            P_norm_fx[1] = L_add( P_norm_fx[1], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31
            move32();
@@ -4584,8 +4592,8 @@ void ivas_get_spar_md_from_dirac_fx(
        }
        P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[min( diff_norm_order3_fx, max( 0, ( num_ch - ndm ) ) )] ); // 2*q_P_re - 31
        move32();

        FOR( i = 0; i < max( 0, ( foa_ch - ndm ) ); i++ )
        len = s_max( 0, sub( foa_ch, ndm ) );
        FOR( i = 0; i < len; i++ ) // i < max( 0, ( foa_ch - ndm ) )
        {
            idx = sub( remix_order[i + ndm], ndm );
            P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ); // 2*q_P_re - 31
@@ -4598,7 +4606,8 @@ void ivas_get_spar_md_from_dirac_fx(
                move32();
            }
        }
        FOR( ; i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ); i++ )
        len = s_max( 0, sub( s_min( num_ch, hoa2_ch ), ndm ) );
        FOR( ; i < len; i++ ) // i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) )
        {
            idx = sub( remix_order[i + ndm], ndm );
            P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ); // 2*q_P_re - 31
@@ -4775,7 +4784,8 @@ void ivas_get_spar_md_from_dirac_fx(
                    /*normalize 2nd order*/
                    norm_fx = 0;
                    move32();
                    FOR( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ )
                    Word16 min_ch_order = s_min( hoa2_ch_order, num_ch_order );
                    FOR( ch = foa_ch; ch < min_ch_order; ch++ )
                    {
                        norm_fx = L_add( norm_fx, Mpy_32_32( response_avg_fx[ch], response_avg_fx[ch] ) ); // q29
                    }
@@ -4796,7 +4806,8 @@ void ivas_get_spar_md_from_dirac_fx(
                        move16();
                    }
                    norm_fx = L_shr( norm_fx, sub( 1, norm_q ) ); // q30
                    FOR( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ )
                    min_ch_order = s_min( hoa2_ch_order, num_ch_order );
                    FOR( ch = foa_ch; ch < min_ch_order; ch++ )
                    {
                        IF( LT_32( norm_fx, EPSILON_FX_THR ) )
                        {
+10 −9
Original line number Diff line number Diff line
@@ -3807,7 +3807,7 @@ void decoder_tcx_invQ_fx(
                FOR( i = 0; i < noiseFillingSize; ++i )
                {
                    tmp32 = L_shr( x[i], sub( 31, *x_e ) );
                    *nf_seed = add_o( *nf_seed, (Word16) abs( tmp32 ) * i * 2, &Overflow );
                    *nf_seed = add_o( *nf_seed, shl( i_mult( (Word16) L_abs( tmp32 ), i ), 1 ), &Overflow ); // abs( tmp32 ) * i * 2
                    move16();
                }
            }
@@ -3875,7 +3875,8 @@ void decoder_tcx_invQ_fx(
        test();
        IF( !st->tcxonly || ( hTcxCfg->resq && hTcxDec->tcx_lpc_shaped_ari ) )
        {
            FOR( i = 0; i < max( L_spec, L_frameTCX ); i++ )
            Word16 len = s_max( L_spec, L_frameTCX );
            FOR( i = 0; i < len; i++ )
            {
                xn_buf[i] = ONE_IN_Q14;
                move16();
@@ -4891,11 +4892,11 @@ void decoder_tcx_tns_fx(
    move16();

    test();
    IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) )
    IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly != 0 )
    {
        test();
        test();
        IF( NE_16( frame_cnt, 0 ) && EQ_16( bfi, 0 ) && NE_16( st->last_core, ACELP_CORE ) )
        IF( frame_cnt != 0 && bfi == 0 && st->last_core != ACELP_CORE )
        {
            /* fix sub-window overlap */
            hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode;
@@ -4940,14 +4941,14 @@ void decoder_tcx_tns_fx(
    test();
    test();
    test();
    IF( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) && EQ_16( tnsData->tnsOnWhitenedSpectra, whitenedDomain ) )
    IF( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && fUseTns != 0 && NE_16( bfi, 1 ) && EQ_16( tnsData->tnsOnWhitenedSpectra, whitenedDomain ) )
    {
        /* Apply TNS to get the reconstructed signal */
        SetTnsConfig( hTcxCfg, L_frame_glob == st->L_frame, ( st->last_core == ACELP_CORE ) && ( frame_cnt == 0 ) );

        test();
        test();
        IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( isTCX5, 0 ) )
        IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly != 0 && isTCX5 != 0 )
        {
            tcx5TnsGrouping_fx( shr( L, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx );
        }
@@ -4956,10 +4957,10 @@ void decoder_tcx_tns_fx(

        test();
        test();
        IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( isTCX5, 0 ) )
        IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly != 0 && isTCX5 != 0 )
        {
            test();
            IF( EQ_16( st->element_mode, EVS_MONO ) || LT_16( L_spec, L_frameTCX ) ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */
            IF( st->element_mode == EVS_MONO || LT_16( L_spec, L_frameTCX ) ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */
            {
                tcx5TnsUngrouping_fx( shr( L_frameTCX, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx, DEC );
                tmp = L_frameTCX;
@@ -5232,7 +5233,7 @@ void decoder_tcx_imdct_fx(
    {
        IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB,
                       hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index,
                       kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win );
                       kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win );
    }
    ELSE
    {
+6 −6
Original line number Diff line number Diff line
@@ -396,7 +396,7 @@ static Word16 lfeplc_lev_dur_fx(
        IF( LT_16( rc_q_fx[i - 1], 31 ) )
        {

            IF( GT_32( abs( rc_fx[i - 1] ), L_shr( 2146302532, sub( 31, rc_q_fx[i - 1] ) ) ) ) // 2146302532 = 0.99945f in Q31
            IF( GT_32( L_abs( rc_fx[i - 1] ), L_shr( 2146302532, sub( 31, rc_q_fx[i - 1] ) ) ) ) // 2146302532 = 0.99945f in Q31
            {
                return 1;
            }
@@ -413,7 +413,7 @@ static Word16 lfeplc_lev_dur_fx(
        }
        ELSE
        {
            IF( GT_32( abs( L_shr( rc_fx[i - 1], sub( rc_q_fx[i - 1], 31 ) ) ), 2146302532 ) ) // 2146302532 = 0.00045f in Q31
            IF( GT_32( L_abs( L_shr( rc_fx[i - 1], sub( rc_q_fx[i - 1], 31 ) ) ), 2146302532 ) ) // 2146302532 = 0.00045f in Q31
            {
                return 1;
            }
@@ -465,7 +465,7 @@ static Word16 d_a2rc_fx(
        move32();
        km_q_fx = ff_q_fx[m];
        move16();
        IF( GE_64( W_shr( abs( km_fx ), sub( ff_q_fx[m], Q30 ) ), W_deposit32_l( ONE_IN_Q30 ) ) )
        IF( GE_64( W_shr( L_abs( km_fx ), sub( ff_q_fx[m], Q30 ) ), W_deposit32_l( ONE_IN_Q30 ) ) )
        {
            FOR( j = 0; j < lpcorder; j++ )
            {
@@ -826,7 +826,7 @@ static Word32 find_max_delta_fx(

        IF( !stable )
        {
            temp = abs( eps_fx );
            temp = L_abs( eps_fx );
            IF( GT_32( L_shr( temp, sub( eps_q_fx, 31 ) ), EPS_STOP_Q31 ) )
            {
                exp1 = norm_l( -temp );
@@ -836,12 +836,12 @@ static Word32 find_max_delta_fx(
            }
            ELSE
            {
                eps_fx = L_negate( abs( eps_fx ) );
                eps_fx = L_negate( L_abs( eps_fx ) );
            }
        }
        ELSE
        {
            temp = abs( eps_fx );
            temp = L_abs( eps_fx );
            if ( LT_32( L_shr( temp, sub( eps_q_fx, 31 ) ), EPS_STOP_Q31 ) )
            {
                BREAK;
+4 −2
Original line number Diff line number Diff line
@@ -132,7 +132,8 @@ void ivas_mc_paramupmix_dec_read_BS(
        nb_bits_read_orig = 0;
        move16();
        last_bit_pos = sub( last_bit_pos, nb_bits_read_orig ); /* reverse the bitstream for easier reading of indices */
        FOR( i = 0; i < min( MAX_BITS_METADATA, last_bit_pos ); i++ )
        Word16 len = s_min( MAX_BITS_METADATA, last_bit_pos );
        FOR( i = 0; i < len; i++ )
        {
            bstr_meta[i] = st_ivas->bit_stream[last_bit_pos - i];
            move16();
@@ -269,7 +270,8 @@ void ivas_mc_paramupmix_dec_render(

            ivas_mc_paramupmix_dec_sf( st_ivas, output_local_fx );

            FOR( ch = 0; ch < min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ) ); ch++ )
            Word16 num_ch = s_min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ) );
            FOR( ch = 0; ch < num_ch; ch++ )
            {
                output_local_fx[ch] += n_samples_sf;
            }
Loading