void idct_8(Int32 vec[])
{

    Int32 tmp0;
    Int32 tmp1;
    Int32 tmp2;
    Int32 tmp3;
    Int32 tmp4;
    Int32 tmp5;
    Int32 tmp6;
    Int32 tmp7;
    Int32 tmp8;


    tmp5 = fxp_mul32_by_16(vec[4] << 1, Qfmt15(0.70710678118655F));

    tmp1 =  vec[0] + tmp5;
    tmp5 =  vec[0] - tmp5;

    tmp3 = fxp_mul32_by_16(vec[2] << 1, Qfmt15(0.54119610014620F));		/* (1/(2*cos(2*phi)));*/
    tmp7 = fxp_mul32_Q29(vec[6], Qfmt(1.30656296487638F));		/* (1/(2*cos(6*phi)));*/

    tmp0  = fxp_mul32_by_16((tmp3 - tmp7) << 1, Qfmt15(0.70710678118655F));	/* (1/(2*cos(2*phi)));  */
    tmp7 = (tmp3 + tmp7) + tmp0;

    vec[0] = tmp1 + tmp7;
    tmp2 = fxp_mul32_by_16(vec[1] << 1, Qfmt15(0.50979557910416F));		/* (1/(2*cos(  phi)));*/
    vec[1] = tmp5 + tmp0;
    vec[2] = tmp5 - tmp0;
    tmp4 = fxp_mul32_by_16(vec[3] << 1, Qfmt15(0.60134488693505F));		/* (1/(2*cos(3*phi)));*/
    vec[3] = tmp1 - tmp7;

    tmp6 = fxp_mul32_by_16(vec[5] << 1, Qfmt15(0.89997622313642F));		/* (1/(2*cos(5*phi)));*/
    tmp8 = fxp_mul32_Q29(vec[7], Qfmt(2.56291544774151F));		/* (1/(2*cos(7*phi)));*/

    tmp7  =  tmp2 + tmp8;
    tmp5  = fxp_mul32_by_16((tmp2 - tmp8) << 1, Qfmt15(0.54119610014620F));
    tmp8  =  tmp4 + tmp6;
    tmp6  = fxp_mul32_Q29((tmp4 - tmp6), Qfmt(1.30656296487638F));

    tmp0 =  tmp7 + tmp8;
    tmp2 = fxp_mul32_by_16((tmp7 - tmp8) << 1, Qfmt15(0.70710678118655F));

    tmp3 = fxp_mul32_by_16((tmp5 - tmp6) << 1, Qfmt15(0.70710678118655F));
    tmp1 = (tmp5 + tmp6) + tmp3;

    tmp5 = tmp0 + tmp1;
    tmp6 = tmp1 + tmp2;
    tmp7 = tmp2 + tmp3;

    vec[7]  = vec[0] - tmp5;
    vec[0] +=          tmp5;
    vec[6]  = vec[1] - tmp6;
    vec[1] +=          tmp6;
    vec[5]  = vec[2] - tmp7;
    vec[2] +=          tmp7;
    vec[4]  = vec[3] - tmp3;
    vec[3] +=          tmp3;

}
void dct_16(Int32 vec[], Int flag)
{
    Int32 tmp0;
    Int32 tmp1;
    Int32 tmp2;
    Int32 tmp3;
    Int32 tmp4;
    Int32 tmp5;
    Int32 tmp6;
    Int32 tmp7;
    Int32 tmp_o0;
    Int32 tmp_o1;
    Int32 tmp_o2;
    Int32 tmp_o3;
    Int32 tmp_o4;
    Int32 tmp_o5;
    Int32 tmp_o6;
    Int32 tmp_o7;
    Int32 itmp_e0;
    Int32 itmp_e1;
    Int32 itmp_e2;

    /*  split input vector */


    tmp_o0 = fxp_mul32_by_16((vec[ 0] - vec[15]), Qfmt15(0.50241928618816F));
    tmp0   =  vec[ 0] + vec[15];

    tmp_o7 = fxp_mul32_Q31((vec[ 7] - vec[ 8]) << 3, Qfmt_31(0.63764357733614F));
    tmp7   =  vec[ 7] + vec[ 8];

    itmp_e0 = (tmp0 + tmp7);
    tmp7    = fxp_mul32_by_16((tmp0 - tmp7), Qfmt15(0.50979557910416F));

    tmp_o1 = fxp_mul32_by_16((vec[ 1] - vec[14]), Qfmt15(0.52249861493969F));
    tmp1   =  vec[ 1] + vec[14];
    tmp_o6 = fxp_mul32_by_16((vec[ 6] - vec[ 9]) << 1, Qfmt15(0.86122354911916F));
    tmp6   =  vec[ 6] + vec[ 9];

    itmp_e1 = (tmp1 + tmp6);
    tmp6    = fxp_mul32_by_16((tmp1 - tmp6), Qfmt15(0.60134488693505F));

    tmp_o2 = fxp_mul32_by_16((vec[ 2] - vec[13]), Qfmt15(0.56694403481636F));
    tmp2   =  vec[ 2] + vec[13];
    tmp_o5 = fxp_mul32_by_16((vec[ 5] - vec[10]) << 1, Qfmt15(0.53033884299517F));
    tmp5   =  vec[ 5] + vec[10];

    itmp_e2 = (tmp2 + tmp5);
    tmp5    = fxp_mul32_by_16((tmp2 - tmp5), Qfmt15(0.89997622313642F));

    tmp_o3 = fxp_mul32_by_16((vec[ 3] - vec[12]), Qfmt15(0.64682178335999F));
    tmp3   =  vec[ 3] + vec[12];
    tmp_o4 = fxp_mul32_by_16((vec[ 4] - vec[11]), Qfmt15(0.78815462345125F));
    tmp4   =  vec[ 4] + vec[11];

    tmp1   = (tmp3 + tmp4);
    tmp4   =  fxp_mul32_Q31((tmp3 - tmp4) << 2, Qfmt_31(0.64072886193538F));

    /*  split even part of tmp_e */

    tmp0 = (itmp_e0 + tmp1);
    tmp1 = fxp_mul32_by_16((itmp_e0 - tmp1), Qfmt15(0.54119610014620F));


    tmp3 = fxp_mul32_by_16((itmp_e1 - itmp_e2) << 1, Qfmt15(0.65328148243819F));
    tmp2 = (itmp_e1 + itmp_e2);

    vec[ 0]  = tmp0 >> 1;
    vec[ 0] += tmp2 >> 1;
    vec[ 8]  = fxp_mul32_by_16((tmp0 - tmp2), Qfmt15(0.70710678118655F));
    vec[12]  = fxp_mul32_by_16((tmp1 - tmp3) << 1, Qfmt15(0.70710678118655F));
    vec[ 4]  =  tmp1 + tmp3;
    vec[ 4] +=  vec[12];

    /*  split odd part of tmp_e */

    tmp1 = fxp_mul32_by_16((tmp7 - tmp4) << 1, Qfmt15(0.54119610014620F));
    tmp7 += tmp4;
    tmp3 = fxp_mul32_Q31((tmp6 - tmp5) << 2, Qfmt_31(0.65328148243819F));

    tmp6 += tmp5;

    vec[10]  = fxp_mul32_by_16((tmp7 - tmp6) << 1, Qfmt15(0.70710678118655F));
    vec[ 2]  =  tmp7 + tmp6;
    vec[14]  = fxp_mul32_by_16((tmp1 - tmp3) << 1, Qfmt15(0.70710678118655F));

    tmp1    +=  tmp3 + vec[14];
    vec[ 2] +=  tmp1;
    vec[ 6]  =  tmp1 + vec[10];

    vec[10] += vec[14];


    // dct8;

    tmp7 = tmp_o0 + tmp_o7;
    tmp_o7 = fxp_mul32_by_16((tmp_o0 - tmp_o7) << 1, Qfmt15(0.50979557910416F));

    tmp6 = tmp_o1 + tmp_o6;
    tmp_o1 = fxp_mul32_by_16((tmp_o1 - tmp_o6) << 1, Qfmt15(0.60134488693505F));

    tmp5 = tmp_o2 + tmp_o5;
    tmp_o5 = fxp_mul32_by_16((tmp_o2 - tmp_o5) << 1, Qfmt15(0.89997622313642F));

    tmp4 = tmp_o3 + tmp_o4;

    tmp_o3 = fxp_mul32_Q31((tmp_o3 - tmp_o4) << 3, Qfmt_31(0.6407288619354F));

    if (!flag)
    {
        tmp7   = -tmp7;
        tmp_o7 = -tmp_o7;
        tmp6   = -tmp6;
        tmp_o1 = -tmp_o1;
        tmp5   = -tmp5;
        tmp_o5 = -tmp_o5;
        tmp4   = -tmp4;
        tmp_o3 = -tmp_o3;
    }

    // even part

    tmp1 = fxp_mul32_by_16((tmp7 - tmp4) << 1, Qfmt15(0.54119610014620F));
    tmp0 =  tmp7 + tmp4;
    tmp3 = fxp_mul32_Q31((tmp6 - tmp5) << 2, Qfmt_31(0.65328148243819F));
    tmp2 =  tmp6 + tmp5;

    vec[ 9]  = fxp_mul32_Q31((tmp0 - tmp2) << 1, Qfmt_31(0.70710678118655F));
    vec[ 1]  =  tmp0 + tmp2;
    vec[13]  = fxp_mul32_Q31((tmp1 - tmp3) << 1, Qfmt_31(0.70710678118655F));

    vec[ 5]  =  tmp1 + tmp3 + vec[13];

    // odd part

    tmp0 =  tmp_o7 + tmp_o3;
    tmp1 = fxp_mul32_by_16((tmp_o7 - tmp_o3) << 1, Qfmt15(0.54119610014620F));
    tmp2 =  tmp_o1 + tmp_o5;
    tmp3 = fxp_mul32_Q31((tmp_o1 - tmp_o5) << 2, Qfmt_31(0.65328148243819F));

    vec[11]  = fxp_mul32_Q31((tmp0 - tmp2) << 1, Qfmt_31(0.70710678118655F));
    vec[ 3]  =  tmp0 + tmp2;
    vec[15]  = fxp_mul32_Q31((tmp1 - tmp3) << 1, Qfmt_31(0.70710678118655F));
    vec[ 7]  =  tmp1 + tmp3 + vec[15];


    vec[ 3] += vec[ 7];
    vec[ 7] += vec[11];
    vec[11] += vec[15];

    vec[ 1] += vec[ 3];
    vec[ 3] += vec[ 5];
    vec[ 5] += vec[ 7];
    vec[ 7] += vec[ 9];
    vec[ 9] += vec[11];
    vec[11] += vec[13];
    vec[13] += vec[15];


}
void ps_all_pass_fract_delay_filter_type_I(UInt32 *delayBufIndex,
        Int32 sb_delay,
        const Int32 *ppFractDelayPhaseFactorSer,
        Int32 ***pppRealDelayRBufferSer,
        Int32 ***pppImagDelayRBufferSer,
        Int32 *rIn,
        Int32 *iIn)
{

    Int32 cmplx;
    Int16 rTmp0;
    Int32 rTmp;
    Int32 iTmp;
    Int32 *pt_rTmp;
    Int32 *pt_iTmp;



    /*
     *  All pass filters
     *                         2
     *                        ___  Q_fract(k,m)*z^(-d(m))  -  a(m)*g_decay_slope(k)
     *   z^(-2)*phi_fract(k)* | |  ------------------------------------------------
     *                        m=0  1  - a(m)*g_decay_slope(k)*Q_fract(k,m)*z^(-d(m))
     *
     *
     *    Fractional delay matrix:
     *
     *    Q_fract(k,m) = exp(-j*pi*q(m)*f_center(k))       0<= k <= SUBQMF_GROUPS
     *
     *    Vectors: a(m), q(m), d(m) are constants
     *
     *    m                              m     0       1       2
     *                                 -------------------------------
     *    delay length                 d(m) == 3       4       5      (Fs > 32 KHz)
     *    fractional delay length      q(m) == 0.43    0.75    0.347
     *    filter coefficient           a(m) == 0.65144 0.56472 0.48954
     *
     *             g_decay_slope(k) is given
     */


    Int32 tmp_r;
    Int32 tmp_i;

    pt_rTmp = &pppRealDelayRBufferSer[0][*(delayBufIndex)][sb_delay];
    pt_iTmp = &pppImagDelayRBufferSer[0][*(delayBufIndex++)][sb_delay];

    cmplx  = *(ppFractDelayPhaseFactorSer++);        /* Q_fract(k,m)  */
    tmp_r = *pt_rTmp << 1;
    tmp_i = *pt_iTmp << 1;

    rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i,  cmplx);
    rTmp0  = Qfmt15(0.65143905753106f);
    iTmp = cmplx_mul32_by_16(tmp_i,  tmp_r,  cmplx);


    iTmp     =  fxp_mac32_by_16(-*iIn << 1, rTmp0, iTmp);  /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */
    *pt_iTmp =  fxp_mac32_by_16(iTmp << 1, rTmp0, *iIn);   /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */
    *iIn = iTmp;

    rTmp     =  fxp_mac32_by_16(-*rIn << 1, rTmp0, rTmp);
    *pt_rTmp =  fxp_mac32_by_16(rTmp << 1, rTmp0, *rIn);

    *rIn = rTmp;

    pt_rTmp = &pppRealDelayRBufferSer[1][*(delayBufIndex)][sb_delay];
    pt_iTmp = &pppImagDelayRBufferSer[1][*(delayBufIndex++)][sb_delay];



    cmplx  = *(ppFractDelayPhaseFactorSer++);        /* Q_fract(k,m)  */
    tmp_r = *pt_rTmp << 1;
    tmp_i = *pt_iTmp << 1;

    rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i,  cmplx);
    rTmp0  = Qfmt15(0.56471812200776f);
    iTmp = cmplx_mul32_by_16(tmp_i,  tmp_r,  cmplx);


    iTmp     =  fxp_mac32_by_16(-*iIn << 1, rTmp0, iTmp);  /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */
    *pt_iTmp =  fxp_mac32_by_16(iTmp << 1, rTmp0, *iIn);   /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */
    *iIn = iTmp;

    rTmp     =  fxp_mac32_by_16(-*rIn << 1, rTmp0, rTmp);
    *pt_rTmp =  fxp_mac32_by_16(rTmp << 1, rTmp0, *rIn);
    *rIn = rTmp;

    pt_rTmp = &pppRealDelayRBufferSer[2][*(delayBufIndex)][sb_delay];
    pt_iTmp = &pppImagDelayRBufferSer[2][*(delayBufIndex)][sb_delay];


    cmplx  = *(ppFractDelayPhaseFactorSer);        /* Q_fract(k,m)  */
    tmp_r = *pt_rTmp << 1;
    tmp_i = *pt_iTmp << 1;

    rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i,  cmplx);
    rTmp0  = Qfmt15(0.97908331911390f);
    iTmp = cmplx_mul32_by_16(tmp_i,  tmp_r,  cmplx);


    iTmp     =  fxp_mac32_by_16(-*iIn, rTmp0, iTmp);    /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */
    *pt_iTmp =  fxp_mac32_by_16(iTmp, rTmp0, *iIn);     /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */
    *iIn = iTmp << 2;

    rTmp     =  fxp_mac32_by_16(-*rIn, rTmp0, rTmp);
    *pt_rTmp =  fxp_mac32_by_16(rTmp, rTmp0, *rIn);
    *rIn = rTmp << 2;
}
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/


/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/


const Int16 aRevLinkDecaySerCoeff[NO_ALLPASS_CHANNELS][NO_SERIAL_ALLPASS_LINKS] =
{


    { Qfmt15(0.74915491616071f),  Qfmt15(0.64942584030892f),  Qfmt15(0.56297290849050f) },
    { Qfmt15(0.71658296328416f),  Qfmt15(0.62118993420853f),  Qfmt15(0.53849582551265f) },
    { Qfmt15(0.68401101040761f),  Qfmt15(0.59295402810815f),  Qfmt15(0.51401874253480f) },
    { Qfmt15(0.65143905753106f),  Qfmt15(0.56471812200776f),  Qfmt15(0.97908331911390f) },      /*  3  */
    { Qfmt15(0.61886710465450f),  Qfmt15(0.53648221590737f),  Qfmt15(0.93012915315822f) },
    { Qfmt15(0.58629515177795f),  Qfmt15(0.50824630980698f),  Qfmt15(0.88117498720252f) },
    { Qfmt15(0.55372319890140f),  Qfmt15(0.48001040370660f),  Qfmt15(0.83222082124682f) },
    { Qfmt15(0.52115124602484f),  Qfmt15(0.45177449760621f),  Qfmt15(0.78326665529112f) },
    { Qfmt15(0.48857929314829f),  Qfmt15(0.42353859150582f),  Qfmt15(0.73431248933542f) },
    { Qfmt15(0.45600734027174f),  Qfmt15(0.39530268540543f),  Qfmt15(0.68535832337974f) },
    { Qfmt15(0.42343538739519f),  Qfmt15(0.36706677930504f),  Qfmt15(0.63640415742404f) },
    { Qfmt15(0.39086343451863f),  Qfmt15(0.33883087320466f),  Qfmt15(0.58744999146834f) },
    { Qfmt15(0.35829148164208f),  Qfmt15(0.31059496710427f),  Qfmt15(0.53849582551265f) },
    { Qfmt15(0.32571952876553f),  Qfmt15(0.28235906100388f),  Qfmt15(0.48954165955695f) },
    { Qfmt15(0.29314757588898f),  Qfmt15(0.25412315490349f),  Qfmt15(0.44058749360126f) },
    { Qfmt15(0.26057562301242f),  Qfmt15(0.22588724880310f),  Qfmt15(0.39163332764556f) },
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
#define Q30_fmt(x)   (Int32)(x*((Int32)1<<30) + (x>=0?0.5F:-0.5F))
#define Qfmt15(x)    (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F))


const Int32 limGains[5] = { Q30_fmt(0.70795f), Q30_fmt(1.0f),
                            Q30_fmt(1.41254f), Q30_fmt(1.16415321826935f), 33
                          };

const Int32 smoothLengths[2] = { 4, 0 };

const Int16 rP_LCx[512] =
{
    Qfmt15(-0.99948153278296f), Qfmt15(0.97113454393991f), Qfmt15(0.14130051758487f), Qfmt15(-0.47005496701697f),
    Qfmt15(0.80705063769351f), Qfmt15(-0.38981478896926f), Qfmt15(-0.01053049862020f), Qfmt15(-0.91266367957293f),
    Qfmt15(0.54840422910309f), Qfmt15(0.40009252867955f), Qfmt15(-0.99867974711855f), Qfmt15(-0.95531076805040f),
    Qfmt15(-0.45725933317144f), Qfmt15(-0.72929675029275f), Qfmt15(0.75622801399036f), Qfmt15(0.07069442601050f),
    Qfmt15(0.74496252926055f), Qfmt15(-0.96440182703856f), Qfmt15(0.30424629369539f), Qfmt15(0.66565033746925f),
    Qfmt15(0.91697008020594f), Qfmt15(-0.70774918760427f), Qfmt15(-0.70051415345560f), Qfmt15(-0.99496513054797f),
    Qfmt15(0.98164490790123f), Qfmt15(-0.54671580548181f), Qfmt15(-0.01689629065389f), Qfmt15(-0.86110349531986f),
    Qfmt15(-0.98892980586032f), Qfmt15(0.51756627678691f), Qfmt15(-0.99635026409640f), Qfmt15(-0.99969370862163f),
    Qfmt15(0.55266258627194f), Qfmt15(0.34581177741673f), Qfmt15(0.62664209577999f), Qfmt15(-0.77149701404973f),
    Qfmt15(-0.91592244254432f), Qfmt15(-0.76285492357887f), Qfmt15(0.79788337195331f), Qfmt15(0.54473080610200f),
    Qfmt15(-0.85639281671058f), Qfmt15(-0.92882402971423f), Qfmt15(-0.11708371046774f), Qfmt15(0.21356749817493f),
    Qfmt15(-0.76191692573909f), Qfmt15(0.98111043100884f), Qfmt15(-0.85913269895572f), Qfmt15(-0.93307242253692f),
    Qfmt15(0.30485754879632f), Qfmt15(0.85289650925190f), Qfmt15(0.91328082618125f), Qfmt15(-0.05890199924154f),
    Qfmt15(0.28398686150148f), Qfmt15(0.95258164539612f), Qfmt15(-0.78566324168507f), Qfmt15(-0.95789495447877f),
    Qfmt15(0.82411158711197f), Qfmt15(-0.65185446735885f), Qfmt15(-0.93643603134666f), Qfmt15(0.91427159529618f),
    Qfmt15(-0.70395684036886f), Qfmt15(0.00563771969365f), Qfmt15(0.89065051931895f), Qfmt15(-0.68683707712762f),