[svn] / branches / release-1_3-branch / xvidcore / src / dct / idct.c Repository:
ViewVC logotype

Diff of /branches/release-1_3-branch/xvidcore/src/dct/idct.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1984, Wed May 18 08:51:47 2011 UTC revision 1985, Wed May 18 09:02:35 2011 UTC
# Line 3  Line 3 
3   *  XVID MPEG-4 VIDEO CODEC   *  XVID MPEG-4 VIDEO CODEC
4   *  - Inverse DCT  -   *  - Inverse DCT  -
5   *   *
6   *  Copyright (C) 2006-2011 Xvid Solutions GmbH   *  These routines are from Independent JPEG Group's free JPEG software
7     *  Copyright (C) 1991-1998, Thomas G. Lane (see the file README.IJG)
8   *   *
9   *  This program is free software ; you can redistribute it and/or modify   *  This program is free software ; you can redistribute it and/or modify
10   *  it under the terms of the GNU General Public License as published by   *  it under the terms of the GNU General Public License as published by
# Line 19  Line 20 
20   *  along with this program ; if not, write to the Free Software   *  along with this program ; if not, write to the Free Software
21   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22   *   *
23   * $Id: idct.c,v 1.9 2005-11-22 10:23:01 suxen_drol Exp $   * $Id$
24   *   *
25   ****************************************************************************/   ****************************************************************************/
26    
27    /* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */
28    
29  /*  /*
30   *  Authors: Skal   * Disclaimer of Warranty
31     *
32     * These software programs are available to the user without any license fee or
33     * royalty on an "as is" basis.  The MPEG Software Simulation Group disclaims
34     * any and all warranties, whether express, implied, or statuary, including any
35     * implied warranties or merchantability or of fitness for a particular
36     * purpose.  In no event shall the copyright-holder be liable for any
37     * incidental, punitive, or consequential damages of any kind whatsoever
38     * arising from the use of these programs.
39     *
40     * This disclaimer of warranty extends to the user of these programs and user's
41     * customers, employees, agents, transferees, successors, and assigns.
42   *   *
43   *  Walken IDCT   * The MPEG Software Simulation Group does not represent or warrant that the
44   *  Alternative idct implementations for decoding compatibility   * programs furnished hereunder are free of infringement of any third-party
45     * patents.
46   *   *
47   *  NOTE: this "C" version is not the original one,   * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware,
48   *  but is modified to yield the same error profile   * are subject to royalty fees to patent holders.  Many of these patents are
49   *  than the MMX version.   * general enough such that they are unavoidable regardless of implementation
50     * design.
51   *   *
52   ************************************************************************/   * MPEG2AVI
53     * --------
54     * v0.16B33 renamed the initialization function to init_idct_int32()
55     * v0.16B32 removed the unused idct_row() and idct_col() functions
56     * v0.16B3  changed var declarations to static, to enforce data align
57     * v0.16B22  idct_FAST() renamed to idct_int32()
58     *        also merged idct_FAST() into a single function, to help VC++
59     *        optimize it.
60     *
61     * v0.14  changed int to long, to avoid confusion when compiling on x86
62     *        platform ( in VC++ "int" -> 32bits )
63     */
64    
65    /**********************************************************/
66    /* inverse two dimensional DCT, Chen-Wang algorithm       */
67    /* (cf. IEEE ASSP-32, pp. 803-816, Aug. 1984)             */
68    /* 32-bit integer arithmetic (8 bit coefficients)         */
69    /* 11 mults, 29 adds per DCT                              */
70    /*                                      sE, 18.8.91       */
71    /**********************************************************/
72    /* coefficients extended to 12 bit for IEEE1180-1990      */
73    /* compliance                           sE,  2.1.94       */
74    /**********************************************************/
75    
76  #include "idct.h"  /* this code assumes >> to be a two's-complement arithmetic */
77    /* right shift: (-2)>>1 == -1 , (-3)>>1 == -2               */
78    
79  /* function pointer */  #include "idct.h"
 idctFuncPtr idct;  
   
 #define XVID_DSP_CLIP_255(x)   ( ((x)&~255) ? ((-(x)) >> (8*sizeof((x))-1))&0xff : (x) )  
80    
81  #define ROW_SHIFT 11  #define W1 2841                                 /* 2048*sqrt(2)*cos(1*pi/16) */
82  #define COL_SHIFT 6  #define W2 2676                                 /* 2048*sqrt(2)*cos(2*pi/16) */
83    #define W3 2408                                 /* 2048*sqrt(2)*cos(3*pi/16) */
84    #define W5 1609                                 /* 2048*sqrt(2)*cos(5*pi/16) */
85    #define W6 1108                                 /* 2048*sqrt(2)*cos(6*pi/16) */
86    #define W7 565                                  /* 2048*sqrt(2)*cos(7*pi/16) */
87    
88    /* private data
89     * Initialized by idct_int32_init so it's mostly RO data,
90     * doesn't hurt thread safety */
91    static short iclip[1024];               /* clipping table */
92    static short *iclp;
93    
94  // #define FIX(x)   (int)((x) * (1<<ROW_SHIFT))  /* private prototypes */
 #define Rnd0 65536 // 1<<(COL_SHIFT+ROW_SHIFT-1);  
 #define Rnd1 3597  // FIX (1.75683487303);  
 #define Rnd2 2260  // FIX (1.10355339059);  
 #define Rnd3 1203  // FIX (0.587788325588);  
 #define Rnd4 0  
 #define Rnd5 120   // FIX (0.058658283817);  
 #define Rnd6 512   // FIX (0.25);  
 #define Rnd7 512   // FIX (0.25);  
 #undef FIX  
   
 static const int Tab04[] = { 22725, 21407, 19266, 16384, 12873,  8867, 4520 };  
 static const int Tab17[] = { 31521, 29692, 26722, 22725, 17855, 12299, 6270 };  
 static const int Tab26[] = { 29692, 27969, 25172, 21407, 16819, 11585, 5906 };  
 static const int Tab35[] = { 26722, 25172, 22654, 19266, 15137, 10426, 5315 };  
95    
96  static int Idct_Row(short * In, const int * const Tab, int Rnd)  /* row (horizontal) IDCT
97  {   *
98    const int C1 = Tab[0];   *           7                       pi         1
99    const int C2 = Tab[1];   * dst[k] = sum c[l] * src[l] * cos( -- * ( k + - ) * l )
100    const int C3 = Tab[2];   *          l=0                      8          2
101    const int C4 = Tab[3];   *
102    const int C5 = Tab[4];   * where: c[0]    = 128
103    const int C6 = Tab[5];   *        c[1..7] = 128*sqrt(2)
104    const int C7 = Tab[6];   */
105    
106    const int Right = In[5]|In[6]|In[7];  #if 0
107    const int Left  = In[1]|In[2]|In[3];  static void idctrow(blk)
108    if (!(Right | In[4]))  short *blk;
   {  
     const int K = C4*In[0] + Rnd;  
     if (Left)  
109      {      {
110        const int a0 = K + C2*In[2];    int X0, X1, X2, X3, X4, X5, X6, X7, X8;
111        const int a1 = K + C6*In[2];  
112        const int a2 = K - C6*In[2];    /* shortcut  */
113        const int a3 = K - C2*In[2];    if (!((X1 = blk[4]<<11) | (X2 = blk[6]) | (X3 = blk[2]) |
114            (X4 = blk[1]) | (X5 = blk[7]) | (X6 = blk[5]) | (X7 = blk[3])))
       const int b0 = C1*In[1] + C3*In[3];  
       const int b1 = C3*In[1] - C7*In[3];  
       const int b2 = C5*In[1] - C1*In[3];  
       const int b3 = C7*In[1] - C5*In[3];  
   
       In[0] = (a0 + b0) >> ROW_SHIFT;  
       In[1] = (a1 + b1) >> ROW_SHIFT;  
       In[2] = (a2 + b2) >> ROW_SHIFT;  
       In[3] = (a3 + b3) >> ROW_SHIFT;  
       In[4] = (a3 - b3) >> ROW_SHIFT;  
       In[5] = (a2 - b2) >> ROW_SHIFT;  
       In[6] = (a1 - b1) >> ROW_SHIFT;  
       In[7] = (a0 - b0) >> ROW_SHIFT;  
     }  
     else  
115      {      {
116        const int a0 = K >> ROW_SHIFT;      blk[0]=blk[1]=blk[2]=blk[3]=blk[4]=blk[5]=blk[6]=blk[7]=blk[0]<<3;
117        if (a0) {      return;
         In[0] = In[1] = In[2] = In[3] =  
         In[4] = In[5] = In[6] = In[7] = a0;  
       }  
       else return 0;  
118      }      }
119    
120      X0 = (blk[0]<<11) + 128; /* for proper rounding in the fourth stage  */
121    
122      /* first stage  */
123      X8 = W7*(X4+X5);
124      X4 = X8 + (W1-W7)*X4;
125      X5 = X8 - (W1+W7)*X5;
126      X8 = W3*(X6+X7);
127      X6 = X8 - (W3-W5)*X6;
128      X7 = X8 - (W3+W5)*X7;
129    
130      /* second stage  */
131      X8 = X0 + X1;
132      X0 -= X1;
133      X1 = W6*(X3+X2);
134      X2 = X1 - (W2+W6)*X2;
135      X3 = X1 + (W2-W6)*X3;
136      X1 = X4 + X6;
137      X4 -= X6;
138      X6 = X5 + X7;
139      X5 -= X7;
140    
141      /* third stage  */
142      X7 = X8 + X3;
143      X8 -= X3;
144      X3 = X0 + X2;
145      X0 -= X2;
146      X2 = (181*(X4+X5)+128)>>8;
147      X4 = (181*(X4-X5)+128)>>8;
148    
149      /* fourth stage  */
150      blk[0] = (X7+X1)>>8;
151      blk[1] = (X3+X2)>>8;
152      blk[2] = (X0+X4)>>8;
153      blk[3] = (X8+X6)>>8;
154      blk[4] = (X8-X6)>>8;
155      blk[5] = (X0-X4)>>8;
156      blk[6] = (X3-X2)>>8;
157      blk[7] = (X7-X1)>>8;
158    }    }
159    else if (!(Left|Right))  #endif
160    
161    /* column (vertical) IDCT
162     *
163     *             7                         pi         1
164     * dst[8*k] = sum c[l] * src[8*l] * cos( -- * ( k + - ) * l )
165     *            l=0                        8          2
166     *
167     * where: c[0]    = 1/1024
168     *        c[1..7] = (1/1024)*sqrt(2)
169     */
170    
171    #if 0
172    static void idctcol(blk)
173    short *blk;
174    {    {
175      const int a0 = (Rnd + C4*(In[0]+In[4])) >> ROW_SHIFT;    int X0, X1, X2, X3, X4, X5, X6, X7, X8;
     const int a1 = (Rnd + C4*(In[0]-In[4])) >> ROW_SHIFT;  
176    
177      In[0] = a0;    /* shortcut  */
178      In[3] = a0;    if (!((X1 = (blk[8*4]<<8)) | (X2 = blk[8*6]) | (X3 = blk[8*2]) |
179      In[4] = a0;          (X4 = blk[8*1]) | (X5 = blk[8*7]) | (X6 = blk[8*5]) | (X7 = blk[8*3])))
     In[7] = a0;  
     In[1] = a1;  
     In[2] = a1;  
     In[5] = a1;  
     In[6] = a1;  
   }  
   else  
180    {    {
181      const int K = C4*In[0] + Rnd;      blk[8*0]=blk[8*1]=blk[8*2]=blk[8*3]=blk[8*4]=blk[8*5]=blk[8*6]=blk[8*7]=
182      const int a0 = K + C2*In[2] + C4*In[4] + C6*In[6];        iclp[(blk[8*0]+32)>>6];
183      const int a1 = K + C6*In[2] - C4*In[4] - C2*In[6];      return;
184      const int a2 = K - C6*In[2] - C4*In[4] + C2*In[6];    }
185      const int a3 = K - C2*In[2] + C4*In[4] - C6*In[6];  
186      X0 = (blk[8*0]<<8) + 8192;
187      const int b0 = C1*In[1] + C3*In[3] + C5*In[5] + C7*In[7];  
188      const int b1 = C3*In[1] - C7*In[3] - C1*In[5] - C5*In[7];    /* first stage  */
189      const int b2 = C5*In[1] - C1*In[3] + C7*In[5] + C3*In[7];    X8 = W7*(X4+X5) + 4;
190      const int b3 = C7*In[1] - C5*In[3] + C3*In[5] - C1*In[7];    X4 = (X8+(W1-W7)*X4)>>3;
191      X5 = (X8-(W1+W7)*X5)>>3;
192      In[0] = (a0 + b0) >> ROW_SHIFT;    X8 = W3*(X6+X7) + 4;
193      In[1] = (a1 + b1) >> ROW_SHIFT;    X6 = (X8-(W3-W5)*X6)>>3;
194      In[2] = (a2 + b2) >> ROW_SHIFT;    X7 = (X8-(W3+W5)*X7)>>3;
195      In[3] = (a3 + b3) >> ROW_SHIFT;  
196      In[4] = (a3 - b3) >> ROW_SHIFT;    /* second stage */
197      In[5] = (a2 - b2) >> ROW_SHIFT;    X8 = X0 + X1;
198      In[6] = (a1 - b1) >> ROW_SHIFT;    X0 -= X1;
199      In[7] = (a0 - b0) >> ROW_SHIFT;    X1 = W6*(X3+X2) + 4;
200    }    X2 = (X1-(W2+W6)*X2)>>3;
201    return 1;    X3 = (X1+(W2-W6)*X3)>>3;
202      X1 = X4 + X6;
203      X4 -= X6;
204      X6 = X5 + X7;
205      X5 -= X7;
206    
207      /* third stage  */
208      X7 = X8 + X3;
209      X8 -= X3;
210      X3 = X0 + X2;
211      X0 -= X2;
212      X2 = (181*(X4+X5)+128)>>8;
213      X4 = (181*(X4-X5)+128)>>8;
214    
215      /* fourth stage */
216      blk[8*0] = iclp[(X7+X1)>>14];
217      blk[8*1] = iclp[(X3+X2)>>14];
218      blk[8*2] = iclp[(X0+X4)>>14];
219      blk[8*3] = iclp[(X8+X6)>>14];
220      blk[8*4] = iclp[(X8-X6)>>14];
221      blk[8*5] = iclp[(X0-X4)>>14];
222      blk[8*6] = iclp[(X3-X2)>>14];
223      blk[8*7] = iclp[(X7-X1)>>14];
224  }  }
225    #endif
226    
227  #define Tan1  0x32ec  /* function pointer */
228  #define Tan2  0x6a0a  idctFuncPtr idct;
 #define Tan3  0xab0e  
 #define Sqrt2 0x5a82  
   
 #define MULT(c,x, n)  ( ((c) * (x)) >> (n) )  
 // 12b version => #define MULT(c,x, n)  ( (((c)>>3) * (x)) >> ((n)-3) )  
 // 12b zero-testing version:  
   
 #define BUTF(a, b, tmp) \  
   (tmp) = (a)+(b);      \  
   (b)   = (a)-(b);      \  
   (a)   = (tmp)  
   
 #define LOAD_BUTF(m1, m2, a, b, tmp, S) \  
   (m1) = (S)[(a)] + (S)[(b)];           \  
   (m2) = (S)[(a)] - (S)[(b)]  
229    
230  static void Idct_Col_8(short * const In)  /* two dimensional inverse discrete cosine transform */
231    void
232    idct_int32(short *const block)
233  {  {
   int mm0, mm1, mm2, mm3, mm4, mm5, mm6, mm7, Spill;  
234    
235      // odd          /*
236             * idct_int32_init() must be called before the first call to this
237             * function!
238             */
239    
   mm4 = (int)In[7*8];  
   mm5 = (int)In[5*8];  
   mm6 = (int)In[3*8];  
   mm7 = (int)In[1*8];  
   
   mm0 = MULT(Tan1, mm4, 16) + mm7;  
   mm1 = MULT(Tan1, mm7, 16) - mm4;  
   mm2 = MULT(Tan3, mm5, 16) + mm6;  
   mm3 = MULT(Tan3, mm6, 16) - mm5;  
   
   mm7 = mm0 + mm2;  
   mm4 = mm1 - mm3;  
   mm0 = mm0 - mm2;  
   mm1 = mm1 + mm3;  
   mm6 = mm0 + mm1;  
   mm5 = mm0 - mm1;  
   mm5 = 2*MULT(Sqrt2, mm5, 16);  // 2*sqrt2  
   mm6 = 2*MULT(Sqrt2, mm6, 16);  // Watch out: precision loss but done to match  
                                  // the pmulhw used in mmx/sse versions  
   
     // even  
   
   mm1 = (int)In[2*8];  
   mm2 = (int)In[6*8];  
   mm3 = MULT(Tan2,mm2, 16) + mm1;  
   mm2 = MULT(Tan2,mm1, 16) - mm2;  
   
   LOAD_BUTF(mm0, mm1, 0*8, 4*8, Spill, In);  
   
   BUTF(mm0, mm3, Spill);  
   BUTF(mm0, mm7, Spill);  
   In[8*0] = (int16_t) (mm0 >> COL_SHIFT);  
   In[8*7] = (int16_t) (mm7 >> COL_SHIFT);  
   BUTF(mm3, mm4, mm0);  
   In[8*3] = (int16_t) (mm3 >> COL_SHIFT);  
   In[8*4] = (int16_t) (mm4 >> COL_SHIFT);  
   
   BUTF(mm1, mm2, mm0);  
   BUTF(mm1, mm6, mm0);  
   In[8*1] = (int16_t) (mm1 >> COL_SHIFT);  
   In[8*6] = (int16_t) (mm6 >> COL_SHIFT);  
   BUTF(mm2, mm5, mm0);  
   In[8*2] = (int16_t) (mm2 >> COL_SHIFT);  
   In[8*5] = (int16_t) (mm5 >> COL_SHIFT);  
 }  
240    
241  static void Idct_Col_4(short * const In)  #if 0
242  {          int i;
243    int mm0, mm1, mm2, mm3, mm4, mm5, mm6, mm7, Spill;          long i;
244    
245      // odd          for (i=0; i<8; i++)
246                    idctrow(block+8*i);
247    
248    mm0 = (int)In[1*8];          for (i=0; i<8; i++)
249    mm2 = (int)In[3*8];                  idctcol(block+i);
250    #endif
251    
252            short *blk;
253            long i;
254            long X0, X1, X2, X3, X4, X5, X6, X7, X8;
255    
   mm1 = MULT(Tan1, mm0, 16);  
   mm3 = MULT(Tan3, mm2, 16);  
   
   mm7 = mm0 + mm2;  
   mm4 = mm1 - mm3;  
   mm0 = mm0 - mm2;  
   mm1 = mm1 + mm3;  
   mm6 = mm0 + mm1;  
   mm5 = mm0 - mm1;  
   mm6 = 2*MULT(Sqrt2, mm6, 16);  // 2*sqrt2  
   mm5 = 2*MULT(Sqrt2, mm5, 16);  
   
     // even  
   
   mm0 = mm1 = (int)In[0*8];  
   mm3 = (int)In[2*8];  
   mm2 = MULT(Tan2,mm3, 16);  
   
   BUTF(mm0, mm3, Spill);  
   BUTF(mm0, mm7, Spill);  
   In[8*0] = (int16_t) (mm0 >> COL_SHIFT);  
   In[8*7] = (int16_t) (mm7 >> COL_SHIFT);  
   BUTF(mm3, mm4, mm0);  
   In[8*3] = (int16_t) (mm3 >> COL_SHIFT);  
   In[8*4] = (int16_t) (mm4 >> COL_SHIFT);  
   
   BUTF(mm1, mm2, mm0);  
   BUTF(mm1, mm6, mm0);  
   In[8*1] = (int16_t) (mm1 >> COL_SHIFT);  
   In[8*6] = (int16_t) (mm6 >> COL_SHIFT);  
   BUTF(mm2, mm5, mm0);  
   In[8*2] = (int16_t) (mm2 >> COL_SHIFT);  
   In[8*5] = (int16_t) (mm5 >> COL_SHIFT);  
 }  
256    
257  static void Idct_Col_3(short * const In)          for (i = 0; i < 8; i++)         /* idct rows */
258  {  {
259    int mm0, mm1, mm2, mm3, mm4, mm5, mm6, mm7, Spill;                  blk = block + (i << 3);
260                    if (!
261                            ((X1 = blk[4] << 11) | (X2 = blk[6]) | (X3 = blk[2]) | (X4 =
262                                                                                                                                            blk[1]) |
263                             (X5 = blk[7]) | (X6 = blk[5]) | (X7 = blk[3]))) {
264                            blk[0] = blk[1] = blk[2] = blk[3] = blk[4] = blk[5] = blk[6] =
265                                    blk[7] = blk[0] << 3;
266                            continue;
267                    }
268    
269                    X0 = (blk[0] << 11) + 128;      /* for proper rounding in the fourth stage  */
270    
271                    /* first stage  */
272                    X8 = W7 * (X4 + X5);
273                    X4 = X8 + (W1 - W7) * X4;
274                    X5 = X8 - (W1 + W7) * X5;
275                    X8 = W3 * (X6 + X7);
276                    X6 = X8 - (W3 - W5) * X6;
277                    X7 = X8 - (W3 + W5) * X7;
278    
279                    /* second stage  */
280                    X8 = X0 + X1;
281                    X0 -= X1;
282                    X1 = W6 * (X3 + X2);
283                    X2 = X1 - (W2 + W6) * X2;
284                    X3 = X1 + (W2 - W6) * X3;
285                    X1 = X4 + X6;
286                    X4 -= X6;
287                    X6 = X5 + X7;
288                    X5 -= X7;
289    
290                    /* third stage  */
291                    X7 = X8 + X3;
292                    X8 -= X3;
293                    X3 = X0 + X2;
294                    X0 -= X2;
295                    X2 = (181 * (X4 + X5) + 128) >> 8;
296                    X4 = (181 * (X4 - X5) + 128) >> 8;
297    
298                    /* fourth stage  */
299    
300                    blk[0] = (short) ((X7 + X1) >> 8);
301                    blk[1] = (short) ((X3 + X2) >> 8);
302                    blk[2] = (short) ((X0 + X4) >> 8);
303                    blk[3] = (short) ((X8 + X6) >> 8);
304                    blk[4] = (short) ((X8 - X6) >> 8);
305                    blk[5] = (short) ((X0 - X4) >> 8);
306                    blk[6] = (short) ((X3 - X2) >> 8);
307                    blk[7] = (short) ((X7 - X1) >> 8);
308    
309      // odd          }                                                       /* end for ( i = 0; i < 8; ++i ) IDCT-rows */
310    
   mm7 = (int)In[1*8];  
   mm4 = MULT(Tan1, mm7, 16);  
311    
   mm6 = mm7 + mm4;  
   mm5 = mm7 - mm4;  
   mm6 = 2*MULT(Sqrt2, mm6, 16);  // 2*sqrt2  
   mm5 = 2*MULT(Sqrt2, mm5, 16);  
   
     // even  
   
   mm0 = mm1 = (int)In[0*8];  
   mm3 = (int)In[2*8];  
   mm2 = MULT(Tan2,mm3, 16);  
   
   BUTF(mm0, mm3, Spill);  
   BUTF(mm0, mm7, Spill);  
   In[8*0] = (int16_t) (mm0 >> COL_SHIFT);  
   In[8*7] = (int16_t) (mm7 >> COL_SHIFT);  
   BUTF(mm3, mm4, mm0);  
   In[8*3] = (int16_t) (mm3 >> COL_SHIFT);  
   In[8*4] = (int16_t) (mm4 >> COL_SHIFT);  
   
   BUTF(mm1, mm2, mm0);  
   BUTF(mm1, mm6, mm0);  
   In[8*1] = (int16_t) (mm1 >> COL_SHIFT);  
   In[8*6] = (int16_t) (mm6 >> COL_SHIFT);  
   BUTF(mm2, mm5, mm0);  
   In[8*2] = (int16_t) (mm2 >> COL_SHIFT);  
   In[8*5] = (int16_t) (mm5 >> COL_SHIFT);  
 }  
312    
313  #undef Tan1          for (i = 0; i < 8; i++)         /* idct columns */
314  #undef Tan2          {
315  #undef Tan3                  blk = block + i;
316  #undef Sqrt2                  /* shortcut  */
317                    if (!
318                            ((X1 = (blk[8 * 4] << 8)) | (X2 = blk[8 * 6]) | (X3 =
319                                                                                                                             blk[8 *
320                                                                                                                                     2]) | (X4 =
321                                                                                                                                                    blk[8 *
322                                                                                                                                                            1])
323                             | (X5 = blk[8 * 7]) | (X6 = blk[8 * 5]) | (X7 = blk[8 * 3]))) {
324                            blk[8 * 0] = blk[8 * 1] = blk[8 * 2] = blk[8 * 3] = blk[8 * 4] =
325                                    blk[8 * 5] = blk[8 * 6] = blk[8 * 7] =
326                                    iclp[(blk[8 * 0] + 32) >> 6];
327                            continue;
328                    }
329    
330                    X0 = (blk[8 * 0] << 8) + 8192;
331    
332                    /* first stage  */
333                    X8 = W7 * (X4 + X5) + 4;
334                    X4 = (X8 + (W1 - W7) * X4) >> 3;
335                    X5 = (X8 - (W1 + W7) * X5) >> 3;
336                    X8 = W3 * (X6 + X7) + 4;
337                    X6 = (X8 - (W3 - W5) * X6) >> 3;
338                    X7 = (X8 - (W3 + W5) * X7) >> 3;
339    
340                    /* second stage  */
341                    X8 = X0 + X1;
342                    X0 -= X1;
343                    X1 = W6 * (X3 + X2) + 4;
344                    X2 = (X1 - (W2 + W6) * X2) >> 3;
345                    X3 = (X1 + (W2 - W6) * X3) >> 3;
346                    X1 = X4 + X6;
347                    X4 -= X6;
348                    X6 = X5 + X7;
349                    X5 -= X7;
350    
351                    /* third stage  */
352                    X7 = X8 + X3;
353                    X8 -= X3;
354                    X3 = X0 + X2;
355                    X0 -= X2;
356                    X2 = (181 * (X4 + X5) + 128) >> 8;
357                    X4 = (181 * (X4 - X5) + 128) >> 8;
358    
359                    /* fourth stage  */
360                    blk[8 * 0] = iclp[(X7 + X1) >> 14];
361                    blk[8 * 1] = iclp[(X3 + X2) >> 14];
362                    blk[8 * 2] = iclp[(X0 + X4) >> 14];
363                    blk[8 * 3] = iclp[(X8 + X6) >> 14];
364                    blk[8 * 4] = iclp[(X8 - X6) >> 14];
365                    blk[8 * 5] = iclp[(X0 - X4) >> 14];
366                    blk[8 * 6] = iclp[(X3 - X2) >> 14];
367                    blk[8 * 7] = iclp[(X7 - X1) >> 14];
368            }
369    
370  #undef ROW_SHIFT  }                                                               /* end function idct_int32(block) */
 #undef COL_SHIFT  
371    
 //////////////////////////////////////////////////////////  
372    
373  void idct_int32(short *const In)  void
374    idct_int32_init(void)
375  {  {
376    int i, Rows = 0x07;          int i;
377    
378    Idct_Row(In + 0*8, Tab04, Rnd0);          iclp = iclip + 512;
379    Idct_Row(In + 1*8, Tab17, Rnd1);          for (i = -512; i < 512; i++)
380    Idct_Row(In + 2*8, Tab26, Rnd2);                  iclp[i] = (i < -256) ? -256 : ((i > 255) ? 255 : i);
   if (Idct_Row(In + 3*8, Tab35, Rnd3)) Rows |= 0x08;  
   if (Idct_Row(In + 4*8, Tab04, Rnd4)) Rows |= 0x10;  
   if (Idct_Row(In + 5*8, Tab35, Rnd5)) Rows |= 0x20;  
   if (Idct_Row(In + 6*8, Tab26, Rnd6)) Rows |= 0x40;  
   if (Idct_Row(In + 7*8, Tab17, Rnd7)) Rows |= 0x80;  
   
   if (Rows&0xf0) {  
     for(i=0; i<8; i++)  
       Idct_Col_8(In + i);  
   }  
   else if (Rows&0x08) {  
     for(i=0; i<8; i++)  
       Idct_Col_4(In + i);  
   }  
   else {  
     for(i=0; i<8; i++)  
       Idct_Col_3(In + i);  
   }  
381  }  }

Legend:
Removed from v.1984  
changed lines
  Added in v.1985

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4