static void idct32(int *out, int *tab)

{

    int i, j;

    int *t, *t1, xr;

    const int *xp = costab32;



    for(j=31;j>=3;j-=2) tab[j] += tab[j - 2];



    t = tab + 30;

    t1 = tab + 2;

    do {

        t[0] += t[-4];

        t[1] += t[1 - 4];

        t -= 4;

    } while (t != t1);



    t = tab + 28;

    t1 = tab + 4;

    do {

        t[0] += t[-8];

        t[1] += t[1-8];

        t[2] += t[2-8];

        t[3] += t[3-8];

        t -= 8;

    } while (t != t1);



    t = tab;

    t1 = tab + 32;

    do {

        t[ 3] = -t[ 3];

        t[ 6] = -t[ 6];



        t[11] = -t[11];

        t[12] = -t[12];

        t[13] = -t[13];

        t[15] = -t[15];

        t += 16;

    } while (t != t1);





    t = tab;

    t1 = tab + 8;

    do {

        int x1, x2, x3, x4;



        x3 = MUL(t[16], FIX(SQRT2*0.5));

        x4 = t[0] - x3;

        x3 = t[0] + x3;



        x2 = MUL(-(t[24] + t[8]), FIX(SQRT2*0.5));

        x1 = MUL((t[8] - x2), xp[0]);

        x2 = MUL((t[8] + x2), xp[1]);



        t[ 0] = x3 + x1;

        t[ 8] = x4 - x2;

        t[16] = x4 + x2;

        t[24] = x3 - x1;

        t++;

    } while (t != t1);



    xp += 2;

    t = tab;

    t1 = tab + 4;

    do {

        xr = MUL(t[28],xp[0]);

        t[28] = (t[0] - xr);

        t[0] = (t[0] + xr);



        xr = MUL(t[4],xp[1]);

        t[ 4] = (t[24] - xr);

        t[24] = (t[24] + xr);



        xr = MUL(t[20],xp[2]);

        t[20] = (t[8] - xr);

        t[ 8] = (t[8] + xr);



        xr = MUL(t[12],xp[3]);

        t[12] = (t[16] - xr);

        t[16] = (t[16] + xr);

        t++;

    } while (t != t1);

    xp += 4;



    for (i = 0; i < 4; i++) {

        xr = MUL(tab[30-i*4],xp[0]);

        tab[30-i*4] = (tab[i*4] - xr);

        tab[   i*4] = (tab[i*4] + xr);



        xr = MUL(tab[ 2+i*4],xp[1]);

        tab[ 2+i*4] = (tab[28-i*4] - xr);

        tab[28-i*4] = (tab[28-i*4] + xr);



        xr = MUL(tab[31-i*4],xp[0]);

        tab[31-i*4] = (tab[1+i*4] - xr);

        tab[ 1+i*4] = (tab[1+i*4] + xr);



        xr = MUL(tab[ 3+i*4],xp[1]);

        tab[ 3+i*4] = (tab[29-i*4] - xr);

        tab[29-i*4] = (tab[29-i*4] + xr);



        xp += 2;

    }



    t = tab + 30;

    t1 = tab + 1;

    do {

        xr = MUL(t1[0], *xp);

        t1[0] = (t[0] - xr);

        t[0] = (t[0] + xr);

        t -= 2;

        t1 += 2;

        xp++;

    } while (t >= tab);



    for(i=0;i<32;i++) {

        out[i] = tab[bitinv32[i]];

    }

}
