void interpolate_isp(
    int16 isp_old[],       /* input : isps from past frame              */
    int16 isp_new[],       /* input : isps from present frame           */
    const int16 frac[],    /* input : fraction for 3 first subfr (Q15)  */
    int16 Az[]             /* output: LP coefficients in 4 subframes    */
)
{
    int16 i, k, fac_old, fac_new;
    int16 isp[M];
    int32 L_tmp;

    for (k = 0; k < 3; k++)
    {
        fac_new = frac[k];
        fac_old = add_int16(sub_int16(32767, fac_new), 1);  /* 1.0 - fac_new */

        for (i = 0; i < M; i++)
        {
            L_tmp = mul_16by16_to_int32(isp_old[i], fac_old);
            L_tmp = mac_16by16_to_int32(L_tmp, isp_new[i], fac_new);
            isp[i] = amr_wb_round(L_tmp);
        }
        Isp_Az(isp, Az, M, 0);
        Az += MP1;
    }

    /* 4th subframe: isp_new (frac=1.0) */

    Isp_Az(isp_new, Az, M, 0);

    return;
}
Beispiel #2
0
void deemphasis_32(
    int16 x_hi[],                        /* (i)     : input signal (bit31..16) */
    int16 x_lo[],                        /* (i)     : input signal (bit15..4)  */
    int16 y[],                           /* (o)     : output signal (x16)      */
    int16 mu,                            /* (i) Q15 : deemphasis factor        */
    int16 L,                             /* (i)     : vector size              */
    int16 * mem                          /* (i/o)   : memory (y[-1])           */
)
{
    int16 i;
    int32 L_tmp;
    int16 lo, hi;

    L_tmp  = ((int32)x_hi[0]) << 16;
    L_tmp += ((int32)x_lo[0]) << 4;
    L_tmp  = shl_int32(L_tmp, 3);

    L_tmp = fxp_mac_16by16(*mem, mu, L_tmp),

    L_tmp = shl_int32(L_tmp, 1);               /* saturation can occur here */
    y[0] = amr_wb_round(L_tmp);

    lo = x_lo[1];
    hi = x_hi[1];
    for (i = 1; i < L - 1; i++)
    {
        L_tmp  = ((int32)hi) << 16;
        L_tmp += ((int32)lo) << 4;
        L_tmp  = shl_int32(L_tmp, 3);
        L_tmp  = fxp_mac_16by16(y[i - 1], mu, L_tmp),
        L_tmp  = shl_int32(L_tmp, 1);           /* saturation can occur here */
        y[i]   = amr_wb_round(L_tmp);
        lo     = x_lo[i+1];
        hi     = x_hi[i+1];
    }
    L_tmp  = ((int32)hi) << 16;
    L_tmp += ((int32)lo) << 4;
    L_tmp  = shl_int32(L_tmp, 3);
    L_tmp  = fxp_mac_16by16(y[i - 1], mu, L_tmp),
    L_tmp  = shl_int32(L_tmp, 1);           /* saturation can occur here */
    y[i]   = amr_wb_round(L_tmp);

    *mem = y[L - 1];

    return;
}
Beispiel #3
0
void preemph_amrwb_dec(
    int16 x[],         /* (i/o)   : input signal overwritten by the output */
    int16 mu,          /* (i) Q15 : preemphasis coefficient                */
    int16 lg           /* (i)     : lenght of filtering                    */
)
{
    int16 i;
    int32 L_tmp;

    for (i = lg - 1; i != 0; i--)
    {
        L_tmp = msu_16by16_from_int32((int32)x[i] << 16, x[i - 1], mu);
        x[i] = amr_wb_round(L_tmp);
    }

}
Beispiel #4
0
void agc2_amr_wb(
    int16 * sig_in,          /* (i)     : postfilter input signal  */
    int16 * sig_out,         /* (i/o)   : postfilter output signal */
    int16 l_trm              /* (i)     : subframe size            */
)
{

    int16 i, exp;
    int16 gain_in, gain_out, g0;
    int32 s;

    int16 temp;

    /* calculate gain_out with exponent */

    temp = sig_out[0] >> 2;
    s = fxp_mul_16by16(temp, temp) << 1;
    for (i = 1; i < l_trm; i++)
    {
        temp = sig_out[i] >> 2;
        s = mac_16by16_to_int32(s, temp, temp);
    }


    if (s == 0)
    {
        return;
    }
    exp = normalize_amr_wb(s) - 1;
    gain_out = amr_wb_round(s << exp);

    /* calculate gain_in with exponent */

    temp = sig_in[0] >> 2;
    s = mul_16by16_to_int32(temp, temp);
    for (i = 1; i < l_trm; i++)
    {
        temp = sig_in[i] >> 2;
        s = mac_16by16_to_int32(s, temp, temp);
    }


    if (s == 0)
    {
        g0 = 0;
    }
    else
    {
        i = normalize_amr_wb(s);
        gain_in = amr_wb_round(s << i);
        exp -= i;

        /*
         *  g0 = sqrt(gain_in/gain_out)
         */

        s = div_16by16(gain_out, gain_in);
        s = shl_int32(s, 7);                   /* s = gain_out / gain_in */
        s = shr_int32(s, exp);                 /* add exponent */

        s = one_ov_sqrt(s);
        g0 = amr_wb_round(shl_int32(s, 9));
    }
    /* sig_out(n) = gain(n) sig_out(n) */

    for (i = 0; i < l_trm; i++)
    {
        sig_out[i] = extract_h(shl_int32(fxp_mul_16by16(sig_out[i], g0), 3));

    }

    return;
}