Commit 59189eaf authored by Fabian Bauer's avatar Fabian Bauer
Browse files

use swb_bwe_enc[fx, hr]_fx from main

parent 770aec77
Loading
Loading
Loading
Loading
Loading
+12 −144
Original line number Diff line number Diff line
@@ -303,11 +303,9 @@ void swb_bwe_enc_ivas_fx(
    Word16 fb_ener_adjust_fx;
    Word16 ener_adjust_quan_fx = 0;
    move16();
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif
    Word16 fb_band_begin;
    Word16 q_new_input_hp;
@@ -410,11 +408,7 @@ void swb_bwe_enc_ivas_fx(
     *----------------------------------------------------------------------*/

    /* tilt returned in Q24 goto to Q11 */
#ifdef ISSUE_1867_replace_overflow_libenc
    tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); //??sat  //??sat
#else
    tilt_nb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3, &Overflow ), &Overflow );
#endif
    /*---------------------------------------------------------------------*
     * SWB BWE encoding
     * FB BWE encoding
@@ -549,11 +543,7 @@ void swb_bwe_enc_ivas_fx(
            L_tmp = L_shl( L_tmp, exp1 );
            exp = sub( sub( 31, exp1 ), sub( 30, exp ) );
            L_tmp = Isqrt_lc( L_tmp, &exp );                                               /*31-exp */
#ifdef ISSUE_1867_replace_overflow_libenc
            fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat  //??sat
#else
            fb_ener_adjust_fx = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */
#endif
        }
        ELSE
        {
@@ -633,11 +623,9 @@ void swb_bwe_enc_fx(
    Word16 fb_ener_adjust_fx;
    Word16 ener_adjust_quan_fx = 0;
    move16();
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif

    FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD;
@@ -695,11 +683,7 @@ void swb_bwe_enc_fx(
     *----------------------------------------------------------------------*/

    /* tilt returned in Q24 goto to Q11 */
#ifdef ISSUE_1867_replace_overflow_libenc
    tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); //??sat  //??sat
#else
    tilt_nb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3, &Overflow ), &Overflow );
#endif
    /*---------------------------------------------------------------------*
     * SWB BWE encoding
     * FB BWE encoding
@@ -822,11 +806,7 @@ void swb_bwe_enc_fx(
            // exp = 31 - exp1 - ( 30 - exp );
            exp = add( 31 - 30, sub( exp, exp1 ) );
            L_tmp = Isqrt_lc( L_tmp, &exp );                                               /*31-exp */
#ifdef ISSUE_1867_replace_overflow_libenc
            fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat  //??sat
#else
            fb_ener_adjust_fx = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */
#endif
        }
        ELSE
        {
@@ -1027,11 +1007,9 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class
    Word16 sharplimit;
    Word16 numsharp, num, den;
    Word16 numharmonic, tmp, expn, expd, scale;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move16();
#endif
#endif

    FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD;
@@ -1068,28 +1046,16 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class
        {
            IF( hBWE_FD->prev_global_gain_fx == 0 )
            {
#ifdef ISSUE_1867_replace_overflow_libenc
                gain_tmp = round_fx_sat( L_shl_sat( fGain, 30 ) ); /*Q14 */ //??sat  //??sat
#else
                gain_tmp = round_fx_o( L_shl_o( fGain, 30, &Overflow ), &Overflow ); /*Q14 */
#endif
            }
            ELSE
            {
                expn = norm_l( fGain );
#ifdef ISSUE_1867_replace_overflow_libenc
                num = extract_h( L_shl( fGain, expn ) );
#else
                num = extract_h( L_shl_o( fGain, expn, &Overflow ) );
#endif
                expn = sub( sub( 30, expn ), shl( Q_shb, 1 ) );

                expd = norm_l( hBWE_FD->prev_global_gain_fx );
#ifdef ISSUE_1867_replace_overflow_libenc
                den = extract_h( L_shl( hBWE_FD->prev_global_gain_fx, expd ) );
#else
                den = extract_h( L_shl_o( hBWE_FD->prev_global_gain_fx, expd, &Overflow ) );
#endif
                expd = sub( sub( 30, expd ), shl( st_fx->prev_Q_shb, 1 ) );

                scale = shr( sub( den, num ), 15 );
@@ -1197,11 +1163,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class
            expd = norm_s( den );
            tmp = div_s( shl( 1, sub( 14, expd ) ), den );                                /*Q(29-expd-Q_syn) */
            L_tmp = L_mult( tmp, peak );                                                  /*Q(30-expd) */
#ifdef ISSUE_1867_replace_overflow_libenc
            sharp = round_fx_sat( L_shl_sat( L_tmp, sub( expd, 4 ) ) ); /*Q10 */ //??sat  //??sat
#else
            sharp = round_fx_o( L_shl_o( L_tmp, sub( expd, 4 ), &Overflow ), &Overflow ); /*Q10 */
#endif
        }
        ELSE
        {
@@ -1401,11 +1363,9 @@ static void vqWithCand_w_fx(
    const Word16 *p_E_ROM_dico;
    Word16 dist, temp1;
    Word32 L_dist, L_tmp;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif
    IF( flag )
    {
@@ -1422,22 +1382,14 @@ static void vqWithCand_w_fx(

        FOR( i = 0; i < E_ROM_dico_size; i++ )
        {
#ifdef ISSUE_1867_replace_overflow_libenc
            dist = sub_sat( x[0], *p_E_ROM_dico++ ); /*Q8 */ //??sat
#else
            dist = sub_o( x[0], *p_E_ROM_dico++, &Overflow ); /*Q8 */
#endif
            L_dist = L_mult( dist, w[0] );                    /*Q22 */
            L_dist = Mult_32_16( L_dist, dist );              /*Q15 */
            L_dist = L_shr( L_dist, 10 );                     /*Q5 */

            FOR( j = 1; j < dim; j++ )
            {
#ifdef ISSUE_1867_replace_overflow_libenc
                temp1 = sub_sat( x[j], *p_E_ROM_dico++ ); //??sat
#else
                temp1 = sub_o( x[j], *p_E_ROM_dico++, &Overflow );
#endif
                L_tmp = L_mult( temp1, w[j] );                /*Q22 */
                L_tmp = Mult_32_16( L_tmp, temp1 );           /*Q15 */
                L_dist = L_add( L_dist, L_shr( L_tmp, 10 ) ); /*Q5 */
@@ -1712,11 +1664,9 @@ static void msvq_interpol_fx(
    Word16 quant_select[SWB_FENV], w_env11[SWB_FENV / 2], w_env12[SWB_FENV / 2], tmp;
    Word32 L_tmp, distCand[N_CAND], L_dist, L_minDist;
    Word16 synth_energy[SWB_FENV];
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif

    /* Extract target vector */
@@ -1757,21 +1707,13 @@ static void msvq_interpol_fx(
        /* Extract vector for odd position */
        FOR( n_band = 0; n_band < DIM11; n_band++ )
        {
#ifdef ISSUE_1867_replace_overflow_libenc
            quant_tmp[n_band] = add_sat( quant_tmp1[n_band], quant_tmp2[n_band] ); //??sat
#else
            quant_tmp[n_band] = add_o( quant_tmp1[n_band], quant_tmp2[n_band], &Overflow );
#endif
            move16();
        }

        FOR( n_band = 0; n_band < DIM12 - 1; n_band++ )
        {
#ifdef ISSUE_1867_replace_overflow_libenc
            tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); /*Q8 */ //??sat
#else
            tmp = add_o( quant_tmp[n_band], quant_tmp[n_band + 1], &Overflow ); /*Q8 */
#endif
            tmp = shr( tmp, 1 );
            quant_tmp2[n_band] = sub( env_temp12[n_band], tmp );
            move16(); /*Q8 */
@@ -1794,11 +1736,7 @@ static void msvq_interpol_fx(

        FOR( n_band = 0; n_band < DIM12 - 1; n_band++ )
        {
#ifdef ISSUE_1867_replace_overflow_libenc
            tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); //??sat
#else
            tmp = add_o( quant_tmp[n_band], quant_tmp[n_band + 1], &Overflow );
#endif
            tmp = shr( tmp, 1 );
            quant_select[( n_band << 1 ) + 1] = add( tmp, quant_tmp2[n_band] );
            move16(); /*Q8 */
@@ -1858,11 +1796,9 @@ static void msvq_interpol_2_fx(
    Word16 quant_select[SWB_FENV], w_env11[SWB_FENV / 2], w_env12[SWB_FENV / 2];
    Word32 L_tmp, distCand[N_CAND], L_dist, L_minDist;
    Word16 synth_energy[SWB_FENV];
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif
    /* Extract target vector */
    FOR( n_band = 0; n_band < DIM11 - 1; n_band++ )
@@ -1920,17 +1856,9 @@ static void msvq_interpol_2_fx(
        move16();
        FOR( n_band = 1; n_band < DIM12 - 1; n_band++ )
        {
#ifdef ISSUE_1867_replace_overflow_libenc
            tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); //??sat
#else
            tmp_q = add_o( quant_tmp[n_band - 1], quant_tmp[n_band], &Overflow );
#endif
            tmp_q = shr( tmp_q, 1 );
#ifdef ISSUE_1867_replace_overflow_libenc
            quant_tmp2[n_band] = sub_sat( env_temp12[n_band], tmp_q ); //??sat
#else
            quant_tmp2[n_band] = sub_o( env_temp12[n_band], tmp_q, &Overflow );
#endif
            move16();
        }

@@ -1951,17 +1879,9 @@ static void msvq_interpol_2_fx(
        move16(); /*Q8 */
        FOR( n_band = 1; n_band < DIM12 - 1; n_band++ )
        {
#ifdef ISSUE_1867_replace_overflow_libenc
            tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); //??sat
#else
            tmp_q = add_o( quant_tmp[n_band - 1], quant_tmp[n_band], &Overflow );
#endif
            tmp_q = shr( tmp_q, 1 );
#ifdef ISSUE_1867_replace_overflow_libenc
            quant_select[( n_band << 1 ) - 1] = add_sat( quant_tmp2[n_band], tmp_q ); //??sat
#else
            quant_select[( n_band << 1 ) - 1] = add_o( quant_tmp2[n_band], tmp_q, &Overflow );
#endif
        }

        L_dist = L_deposit_l( 0 );
@@ -2023,11 +1943,9 @@ static void calculate_Tonality_fx(
    Word16 org_spec[80], gen_spec[80];
    Word32 L_log_gm_org, L_log_gm_gen;
    Word16 l_shift;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif

    /* to reduce dynamic range of original spectrum */
@@ -2133,11 +2051,7 @@ static void calculate_Tonality_fx(
    L_tmp2 = Mpy_32_16_1( L_log_gm_org, inv_len ); /* Q14 */

    L_tmp = L_sub( L_tmp1, L_tmp2 );
#ifdef ISSUE_1867_replace_overflow_libenc
    *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat  //??sat
#else
    *SFM_org = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */
#endif
    move16();
    *SFM_org = s_max( 0, s_min( *SFM_org, 24547 ) );
    move16(); /*0.0001 and 5.993 in Q12 */
@@ -2158,11 +2072,7 @@ static void calculate_Tonality_fx(
    L_tmp2 = Mpy_32_16_1( L_log_gm_gen, inv_len ); /* Q14 */

    L_tmp = L_sub( L_tmp1, L_tmp2 );
#ifdef ISSUE_1867_replace_overflow_libenc
    *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat  //??sat
#else
    *SFM_gen = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */
#endif
    move16();
    *SFM_gen = s_max( 0, s_min( *SFM_gen, 24547 ) );
    move16(); /*0.0001 and 5.993 in Q12 */
@@ -2191,11 +2101,9 @@ static void calculate_Tonality_ivas_fx(
    Word16 org_spec[80], gen_spec[80];
    Word32 L_log_gm_org, L_log_gm_gen;
    Word16 l_shift;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif

    /* to reduce dynamic range of original spectrum */
@@ -2301,11 +2209,7 @@ static void calculate_Tonality_ivas_fx(
    L_tmp2 = Mpy_32_16_1( L_log_gm_org, inv_len ); /* Q14 */

    L_tmp = L_sub( L_tmp1, L_tmp2 );
#ifdef ISSUE_1867_replace_overflow_libenc
    *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat  //??sat
#else
    *SFM_org = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */
#endif
    move16();
    *SFM_org = s_max( 0, s_min( *SFM_org, 24547 ) );
    move16(); /*0.0001 and 5.993 in Q12 */
@@ -2326,11 +2230,7 @@ static void calculate_Tonality_ivas_fx(
    L_tmp2 = Mpy_32_16_1( L_log_gm_gen, inv_len ); /* Q14 */

    L_tmp = L_sub( L_tmp1, L_tmp2 );
#ifdef ISSUE_1867_replace_overflow_libenc
    *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat  //??sat
#else
    *SFM_gen = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */
#endif
    move16();
    *SFM_gen = s_max( 0, s_min( *SFM_gen, 24547 ) );
    move16(); /*0.0001 and 5.993 in Q12 */
@@ -2718,11 +2618,9 @@ static Word16 SWB_BWE_encoding_fx(
    Word16 SWB_tenv_tmp_fx[SWB_TENV];
    Word16 max_fx;
    Word16 energy_factor_fx[SWB_FENV], w_env_fx[SWB_FENV];
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move16();
#endif
#endif

    FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD;
@@ -2765,11 +2663,7 @@ static Word16 SWB_BWE_encoding_fx(
    }

    /* tilt returned in Q24 go to Q11 */
#ifdef ISSUE_1867_replace_overflow_libenc
    tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); //??sat  //??sat
#else
    tilt_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3, &Overflow ), &Overflow );
#endif
    test();
    test();
    IF( EQ_16( IsTransient, 1 ) && ( GT_16( tilt_fx, 16384 ) || GT_16( st_fx->clas, 1 ) ) )
@@ -2873,11 +2767,7 @@ static Word16 SWB_BWE_encoding_fx(
            L_tmp = L_deposit_h( tmp );
            L_tmp = Isqrt_lc( L_tmp, &expn ); /*31-expn */

#ifdef ISSUE_1867_replace_overflow_libenc
            Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ //??sat  //??sat
#else
            Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, sub( expn, 1 ), &Overflow ), &Overflow ); /*Q14 */
#endif
        }
        ELSE
        {
@@ -2889,11 +2779,7 @@ static Word16 SWB_BWE_encoding_fx(
        {
            L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */

#ifdef ISSUE_1867_replace_overflow_libenc
            Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat  //??sat
#else
            Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */
#endif
        }
        ELSE IF( GT_16( Rat_tenv_fx, 16384 ) )
        {
@@ -3177,11 +3063,9 @@ static Word16 SWB_BWE_encoding_ivas_fx(
    Word16 SWB_tenv_tmp_fx[SWB_TENV];
    Word16 max_fx;
    Word16 energy_factor_fx[SWB_FENV], w_env_fx[SWB_FENV];
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif
    Word16 inner_frame;
    Word16 q_shift;
@@ -3242,11 +3126,7 @@ static Word16 SWB_BWE_encoding_ivas_fx(
    }

    /* tilt returned in Q24 go to Q11 */
#ifdef ISSUE_1867_replace_overflow_libenc
    tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); //??sat  //??sat
#else
    tilt_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3, &Overflow ), &Overflow );
#endif
    test();
    test();
    IF( EQ_16( IsTransient, 1 ) && ( GT_16( tilt_fx, 16384 ) || GT_16( st_fx->clas, 1 ) ) )
@@ -3351,11 +3231,7 @@ static Word16 SWB_BWE_encoding_ivas_fx(
            expn = sub( sub( 30, expn ), sub( shl( Q_insig_lp, 1 ), 7 ) );

            expd = norm_l( WB_tenv_syn_fx );
#ifdef ISSUE_1867_replace_overflow_libenc
            den = round_fx_sat( L_shl( WB_tenv_syn_fx, expd ) ); //??sat
#else
            den = round_fx_o( L_shl( WB_tenv_syn_fx, expd ), &Overflow );
#endif
            expd = sub( sub( 30, expd ), sub( shl( Q_insig_lp, 1 ), 7 ) );

            scale = shr( sub( den, num ), 15 );
@@ -3368,11 +3244,7 @@ static Word16 SWB_BWE_encoding_ivas_fx(
            L_tmp = L_deposit_h( tmp );
            L_tmp = Isqrt_lc( L_tmp, &expn ); /*31-expn */

#ifdef ISSUE_1867_replace_overflow_libenc
            Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ //??sat  //??sat
#else
            Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, sub( expn, 1 ), &Overflow ), &Overflow ); /*Q14 */
#endif
        }
        ELSE
        {
@@ -3383,11 +3255,7 @@ static Word16 SWB_BWE_encoding_ivas_fx(
        IF( LT_16( Rat_tenv_fx, 8192 ) )
        {
            L_tmp = L_mult( Rat_tenv_fx, 19661 );                                  /*Q29 */
#ifdef ISSUE_1867_replace_overflow_libenc
            Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat  //??sat
#else
            Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */
#endif
        }
        ELSE IF( GT_16( Rat_tenv_fx, 16384 ) )
        {
+3 −5
Original line number Diff line number Diff line
@@ -117,11 +117,9 @@ void swb_bwe_enc_hr_fx(
#else
    Word32 L_t_audio_tmp_fx[L_FRAME48k];
#endif
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move16();
#endif
#endif
    FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD;
    BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
@@ -769,12 +767,12 @@ void swb_bwe_enc_hr_fx(
            FOR( i = 0; i < Nsv2 * WIDTH_BAND; i++ )
            {
                L_tmp = L_mult( temp, t_audio_fx[i] );
#ifdef ISSUE_1799_replace_L_shr_o
                L_tmp = L_shr_sat( L_tmp, temp2 );
#ifdef ISSUE_1867_replace_overflow_libenc
                t_audio_fx[i] = round_fx_sat( L_tmp ); //??sat
#else
                t_audio_fx[i] = round_fx_o( L_tmp, &Overflow );
                L_tmp = L_shr_o( L_tmp, temp2, &Overflow );
#endif
                t_audio_fx[i] = round_fx_o( L_tmp, &Overflow );
                move16();
            }