Commit 5f94be93 authored by vaillancour's avatar vaillancour
Browse files

First fixes for SWB encoder

parent fd794046
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -1259,7 +1259,9 @@ GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) | p
    Word32 energyValues[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
    Word16 energyValuesSumE[CLDFB_NO_CHANNELS_MAX];
    Word16 freqTable[2] = {20, 40};

#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif

    FOR (k=0; k<numberCols; k++)
    {
@@ -1344,7 +1346,11 @@ GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) | p
        {
            FOR (j=20; j < numberBandsM; j++)
            {
#ifdef BASOP_NOGLOB
                nrg = L_add_o(nrg, L_shr_o(energyValues[k][j], s, &Overflow), &Overflow);
#else
                nrg = L_add(nrg, L_shr(energyValues[k][j], s));
#endif
            }
        }

+7 −1
Original line number Diff line number Diff line
@@ -60,7 +60,9 @@ void tcxFormantEnhancement(
    Word16 i, j, k, l, n;
    Word16 fac, fac0, fac1, fac_e, d, tmp;
    Word16 xn_buf_e, xn_one, m, e;

#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif

    k = shr(L_frame, 6); /* FDNS_NPTS = 64 */
    l = 0;
@@ -133,7 +135,11 @@ void tcxFormantEnhancement(
            {
                fac = add(fac0, mult(d, extract_l(L_mult0(j, inv_int[n]))));
                BASOP_SATURATE_WARNING_OFF;
#ifdef BASOP_NOGLOB
                xn_buf[l+j] = s_min(xn_one, shl_o(mult(xn_buf[l+j], fac), fac_e, &Overflow));
#else
                xn_buf[l+j] = s_min(xn_one, shl(mult(xn_buf[l+j], fac), fac_e));
#endif
                move16();
                BASOP_SATURATE_WARNING_ON;
            }
+15 −0
Original line number Diff line number Diff line
@@ -1550,6 +1550,9 @@ void a2rc_fx( const Word16* a, /* i: can be any Q */
    Word16 m, j, n;
    Word16 q, q_a, q_a2, One_Qx;
    Word32 One_Qx2;
#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif
    q = add( norm_s(a[-1]), 1 );
    q_a = sub(15, q);
    q_a2 = add(shl(q_a,1),1);
@@ -1610,13 +1613,25 @@ void a2rc_fx( const Word16* a, /* i: can be any Q */
        {
            n = sub( sub( m, ( Word16 )1 ), j );
            L_tmp1 = L_mult( denom_mant, f_fx[j] ); /* denom*f[j]. Q15*Q12 = Q28 (floating with exp) */
#ifdef BASOP_NOGLOB
            L_tmp1 = L_mac_o( L_tmp1, tmp, f_fx[n], &Overflow ); /* denom*f[j]+km*denom*f[n] in Q28 (floating with exp) */
#else
            L_tmp1 = L_mac( L_tmp1, tmp, f_fx[n] ); /* denom*f[j]+km*denom*f[n] in Q28 (floating with exp) */
#endif
            L_tmp2 = L_mult( denom_mant,f_fx[n] ); /* denom*f[n]. Q15*Q12 = Q28 (floating with exp) */
#ifdef BASOP_NOGLOB
            L_tmp2 = L_mac_o( L_tmp2, tmp,f_fx[j], &Overflow); /* denom*f[n]+km*denom*f[j] in Q28 (floating with exp) */
            L_tmp1 = L_shr_o( L_tmp1, exp, &Overflow); /* bringing to true Q28 */
            L_tmp2 = L_shr_o( L_tmp2, exp, &Overflow); /* bringing to true Q28 */
            f_fx[j] = round_fx_o( L_tmp1, &Overflow); /* extracting in q_a */
            f_fx[n] = round_fx_o( L_tmp2, &Overflow); /* extracting in q_a */
#else
            L_tmp2 = L_mac( L_tmp2, tmp,f_fx[j] ); /* denom*f[n]+km*denom*f[j] in Q28 (floating with exp) */
            L_tmp1 = L_shr( L_tmp1, exp ); /* bringing to true Q28 */
            L_tmp2 = L_shr( L_tmp2, exp ); /* bringing to true Q28 */
            f_fx[j] = round_fx( L_tmp1 ); /* extracting in q_a */
            f_fx[n] = round_fx( L_tmp2 ); /* extracting in q_a */
#endif
        }

        IF ( m & 1 )
+39 −3
Original line number Diff line number Diff line
@@ -68,7 +68,9 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
    Word32 LepsP[M+1];
    Word16 flag_low_order = 0;
    Word16 filt_len_tmp;

#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif 
    const Resampling_cfg_fx *cfg_ptr_fx;

    /*-------------------------------------------------------------------*
@@ -264,7 +266,11 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
                test();
                if( GT_32(fin, 16000)&&(EQ_16(lg_out,L_FRAME)||EQ_16(lg_out,L_FRAME16k)||EQ_16(lg_out,512)))
                {
#ifdef BASOP_NOGLOB
                    num_den = shl_o(num_den, 1, &Overflow);
#else
                    num_den = shl(num_den, 1);
#endif
                }
                FOR( i=0; i<lg_out; i++ )
                {
@@ -651,8 +657,11 @@ void Decimate_allpass_steep_fx(
#endif
        Lacc1 = L_deposit_h( in_fx[2*k] );                      /* Q16+Qx    */
        temp1 = extract_h( Lacc );                              /* Qx        */
#ifdef BASOP_NOGLOB
        Lacc1 = L_msu_o( Lacc1, AP1_STEEP_FX[0], temp1, &Overflow );         /* Q16+Qx    */
#else
        Lacc1 = L_msu( Lacc1, AP1_STEEP_FX[0], temp1 );         /* Q16+Qx    */

#endif
        mem[0] = extract_h( Lacc1 );                       /* Qx        */
        temp[0] = temp1;
        move16();
@@ -665,7 +674,11 @@ void Decimate_allpass_steep_fx(
#endif

        temp2 = extract_h( Lacc1 );                             /* Qx        */
#ifdef BASOP_NOGLOB
        Lacc = L_msu_o( Lacc, AP1_STEEP_FX[1], temp2 , &Overflow);           /* Q16+Qx    */
#else
        Lacc = L_msu( Lacc, AP1_STEEP_FX[1], temp2 );           /* Q16+Qx    */
#endif
        mem[1] = extract_h(Lacc);                          /* Qx        */
        temp[1] = temp2;
        move16();
@@ -691,8 +704,11 @@ void Decimate_allpass_steep_fx(
#endif
    Lacc1 = L_deposit_h( mem[2*ALLPASSSECTIONS_STEEP] );               /*  Q(16+x)     */
    temp1 = extract_h( Lacc );                                              /*  Qx          */
#ifdef BASOP_NOGLOB
    Lacc1 = L_msu_o( Lacc1, AP2_STEEP_FX[0], temp1, &Overflow );                         /*  Q(16+x)     */
#else
    Lacc1 = L_msu( Lacc1, AP2_STEEP_FX[0], temp1 );                         /*  Q(16+x)     */

#endif
    mem[ ALLPASSSECTIONS_STEEP ] = extract_h( Lacc1 );
    temp[0] = temp1;
    move16();
@@ -706,7 +722,11 @@ void Decimate_allpass_steep_fx(
    temp2 = extract_h( Lacc1 );                                             /*  Qx      */
    temp[1] = temp2;
    move16();
#ifdef BASOP_NOGLOB
    Lacc = L_msu_o( Lacc, AP2_STEEP_FX[1], temp2, &Overflow );                           /*  Q(16+x) */
#else
    Lacc = L_msu( Lacc, AP2_STEEP_FX[1], temp2 );                           /*  Q(16+x) */
#endif
    mem[ALLPASSSECTIONS_STEEP+1] = extract_h( Lacc );                  /*  Qx      */


@@ -717,7 +737,11 @@ void Decimate_allpass_steep_fx(
    Lacc = L_mac( Lacc, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP-1], temp2 );      /* Q(16+x) temp[ALLPASSSECTIONS_STEEP-1] */
#endif
    temp[2] = extract_h( Lacc );                                             /* temp[2] in Qx  */
#ifdef BASOP_NOGLOB
    Lacc1 = L_msu_o( Lacc1, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP-1], temp[2], &Overflow );    /*   Q(16+x) */
#else
    Lacc1 = L_msu( Lacc1, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP-1], temp[2] );    /*   Q(16+x) */
#endif
    mem[ 2*ALLPASSSECTIONS_STEEP-1 ] = extract_h( Lacc1 );                  /*   Qx      */

    sum = mult_r( out_fx[0], 16384 ); /* Qx */
@@ -736,7 +760,11 @@ void Decimate_allpass_steep_fx(
#endif
        Lacc1 = L_deposit_h( in_fx[ 2*k-1 ] );                                  /* Q(16+x)           */
        temp1 = extract_h( Lacc );                                              /* Qx                */
#ifdef BASOP_NOGLOB
        Lacc1 = L_msu_o( Lacc1, AP2_STEEP_FX[0], temp1, &Overflow );                         /* Q(16+x)           */
#else
        Lacc1 = L_msu( Lacc1, AP2_STEEP_FX[0], temp1 );                         /* Q(16+x)           */
#endif

        mem[ALLPASSSECTIONS_STEEP] = extract_h( Lacc1 );                   /* Qx */
        temp[0] = temp1;
@@ -752,7 +780,11 @@ void Decimate_allpass_steep_fx(
        temp2 = extract_h( Lacc1 );                                             /* Qx       */
        temp[1] = temp2;
        move16();
#ifdef BASOP_NOGLOB
        Lacc = L_msu_o(Lacc,AP2_STEEP_FX[1],temp2, &Overflow);                               /* Q(16+x)  */
#else                                                       
        Lacc = L_msu(Lacc,AP2_STEEP_FX[1],temp2);                               /* Q(16+x)  */
#endif
        mem[ALLPASSSECTIONS_STEEP+1]= extract_h(Lacc);                     /* Qx       */


@@ -763,7 +795,11 @@ void Decimate_allpass_steep_fx(
        Lacc = L_mac( Lacc, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP-1], temp[1] );       /* Q(16+x) temp[ALLPASSSECTIONS_STEEP-1] */
#endif
        temp[2] = extract_h( Lacc );    /*temp[2] in Qx  */
#ifdef BASOP_NOGLOB
        Lacc1 = L_msu_o( Lacc1, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP-1], temp[2], &Overflow );     /* Q(16+x) */
#else
        Lacc1 = L_msu( Lacc1, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP-1], temp[2] );     /* Q(16+x) */
#endif
        mem[2*ALLPASSSECTIONS_STEEP-1] = extract_h( Lacc1 );                   /* Qx  */


+14 −1
Original line number Diff line number Diff line
@@ -3623,6 +3623,9 @@ void Estimate_mix_factors_fx(
    Word16 exp1,exp2, expa, expb, fraca, fracb, scale, num_flag, den_flag;
    Word16 tmp, tmp1, sc1, sc2;
    Word32 L_tmp1, L_tmp2;
#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif

    Copy(shb_res, shb_res_local, L_FRAME16k);
    Copy(White_exc16k_frac, WN_exc_local, L_FRAME16k);
@@ -3679,7 +3682,11 @@ void Estimate_mix_factors_fx(
        expa = sub(30,expa);

        expb = norm_l(temp_p1_p2);
#ifdef BASOP_NOGLOB
        fracb = round_fx_o(L_shl_o(temp_p1_p2,expb, &Overflow), &Overflow);
#else
        fracb = round_fx(L_shl(temp_p1_p2,expb));
#endif
        expb =  sub(30,expb);

        num_flag = 0;
@@ -4002,6 +4009,9 @@ Word16 swb_formant_fac_fx( /* o : Formant filter strength [0,1] */
{
    Word16 formant_fac;
    Word16 tmp;
#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif

    /* Smoothen tilt value */
    /* tmp = 0.5f * (float)fabs(lpc_shb2) + 0.5f * *tilt_mem; */
@@ -4029,8 +4039,11 @@ Word16 swb_formant_fac_fx( /* o : Formant filter strength [0,1] */

    /* formant_fac = 1.0f - 0.5f*formant_fac */
    tmp = mult_r(16384, formant_fac); /* 0.5 in Q12 */
#ifdef BASOP_NOGLOB
    formant_fac = shl_o(sub(4096,tmp),3, &Overflow);
#else
    formant_fac = shl(sub(4096,tmp),3);

#endif
    return formant_fac; /*Q15 */
}

Loading