static int SpreSC[64]={ 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, 12873, 17855, 16819, 15137, 25746, 20228, 13933, 7103, 17734, 24598, 23170, 20853, 17734, 13933, 9597, 4892, 18081, 25080, 23624, 21261, 18081, 14206, 9785, 4988};
/* use this table to multiply the block[j] in the decode_macroblock stage; after multiply,shift to right 13 bits; (17-4)
*/
#define C2 30274 // 2 COS (PI/8) 1.84776#define C4 23171 // SQRT(2) 1.41421 #define C6 12540 // 2 SIN (PI/8) 0.76537#define C6pC2 42814 file://C6+C2 2.61313#define C6sC2 (-17734) // -1.08239#define RC0 14#define RC1 18#define ROUND (1<<(RC1-1))
// do 80 times of multiply; fastidct :176;
#define idct_unit(a,b) {x4 = x5 - x3; / t1 = x5 + x3; / x3 = (x2+x6)<<RC0; / x2 = (x2-x6)*C4-x3; / t0 = x1 + x7; / x6= x1 - x7; / x7= (t0 + t1)<<RC0; / x5 = (t0 - t1)*C4; / t0=C6*(x4+x6); / x4=C6sC2*x4-t0; / x6=C6pC2*x6-t0; / t0=x6-x7; / x1=(a-b)<<RC0; / t1=t0-x5; / x6=(a+b)<<RC0; / x0=x4-t1; / x4=x3+x6; / x6-=x3; / x3=x1+x2; / x5=x1-x2; }
static void IDCTaan_c(short* block){ int x0,x1,x2,x3,x4,x5,x6,x7; int t0,t1; short *blk;// Field one blk = block; for(int i=0; i<8; i++) { if (!( (x1 = blk[1]) | (x2 = blk[2]) | (x3 = blk[3]) | (x4 = blk[4]) | (x5 = blk[5]) | (x6 = blk[6]) | (x7 = blk[7]))) { // blk[0]= blk[1]=blk[2]=blk[3]=blk[4] =blk[5]=blk[6]=blk[7]=(blk[0]); } else {
idct_unit(blk[0],blk[4])
blk[0]=(x4+x7)>>RC0 ; blk[7]=(x4-x7)>>RC0 ; blk[1]=(x3+t0)>>RC0 ; blk[6]=(x3-t0)>>RC0 ; blk[2]=(x5-t1)>>RC0 ; blk[5]=(x5+t1)>>RC0 ; blk[3]=(x6-x0)>>RC0 ; blk[4]=(x6+x0)>>RC0 ; } blk+=8; }
file://field two blk=block; for ( i=0; i<8; i++) { if (!((x1 = blk[8]) | (x2 = blk[16]) | (x3 = blk[24]) | (x4 = blk[32]) | (x5 = blk[40]) | (x6 = blk[48]) | (x7 = blk[56]))) { blk[0]=blk[8]=blk[16]=blk[24] =blk[32]=blk[40]=blk[48]=blk[56]= iclp[blk[0]>>4]; } else { idct_unit(blk[0*8],blk[4*8])
blk[0*8]=iclp[(x4+x7+ROUND)>>RC1]; blk[7*8]=iclp[(x4-x7+ROUND)>>RC1]; blk[1*8]=iclp[(x3+t0+ROUND)>>RC1]; blk[6*8]=iclp[(x3-t0+ROUND)>>RC1]; blk[2*8]=iclp[(x5-t1+ROUND)>>RC1]; blk[5*8]=iclp[(x5+t1+ROUND)>>RC1]; blk[3*8]=iclp[(x6-x0+ROUND)>>RC1]; blk[4*8]=iclp[(x6+x0+ROUND)>>RC1]; } blk++; }}