[svn] / trunk / xvidcore / src / dct / idct.c Repository:
ViewVC logotype

Diff of /trunk/xvidcore/src/dct/idct.c

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

revision 649, Sat Nov 16 23:51:58 2002 UTC revision 677, Tue Nov 26 23:44:11 2002 UTC
# Line 51  Line 51 
51   *  exception also makes it possible to release a modified version which   *  exception also makes it possible to release a modified version which
52   *  carries forward this exception.   *  carries forward this exception.
53   *   *
54   * $Id: idct.c,v 1.4 2002-11-16 23:51:58 edgomez Exp $   * $Id: idct.c,v 1.5 2002-11-26 23:44:10 edgomez Exp $
55   *   *
56   *************************************************************************/   *************************************************************************/
57    
# Line 80  Line 80 
80    
81    
82  /* global declarations */  /* global declarations */
83  //void init_idct_int32 (void);  /*void init_idct_int32 (void); */
84  //void idct_int32 (short *block);  /*void idct_int32 (short *block); */
85    
86  /* private data */  /* private data */
87  static short iclip[1024];               /* clipping table */  static short iclip[1024];               /* clipping table */
88  static short *iclp;  static short *iclp;
89    
90  /* private prototypes */  /* private prototypes */
91  //static void idctrow _ANSI_ARGS_((short *blk));  /*static void idctrow _ANSI_ARGS_((short *blk)); */
92  //static void idctcol _ANSI_ARGS_((short *blk));  /*static void idctcol _ANSI_ARGS_((short *blk)); */
93    
94  /* row (horizontal) IDCT  /* row (horizontal) IDCT
95   *   *
# Line 101  Line 101 
101   *        c[1..7] = 128*sqrt(2)   *        c[1..7] = 128*sqrt(2)
102   */   */
103    
104  /*  #if 0
105  static void idctrow(blk)  static void idctrow(blk)
106  short *blk;  short *blk;
107  {  {
108    int X0, X1, X2, X3, X4, X5, X6, X7, X8;    int X0, X1, X2, X3, X4, X5, X6, X7, X8;
109    
110    // shortcut    /* shortcut  */
111    if (!((X1 = blk[4]<<11) | (X2 = blk[6]) | (X3 = blk[2]) |    if (!((X1 = blk[4]<<11) | (X2 = blk[6]) | (X3 = blk[2]) |
112          (X4 = blk[1]) | (X5 = blk[7]) | (X6 = blk[5]) | (X7 = blk[3])))          (X4 = blk[1]) | (X5 = blk[7]) | (X6 = blk[5]) | (X7 = blk[3])))
113    {    {
# Line 115  Line 115 
115      return;      return;
116    }    }
117    
118    X0 = (blk[0]<<11) + 128; // for proper rounding in the fourth stage    X0 = (blk[0]<<11) + 128; /* for proper rounding in the fourth stage  */
119    
120    // first stage    /* first stage  */
121    X8 = W7*(X4+X5);    X8 = W7*(X4+X5);
122    X4 = X8 + (W1-W7)*X4;    X4 = X8 + (W1-W7)*X4;
123    X5 = X8 - (W1+W7)*X5;    X5 = X8 - (W1+W7)*X5;
# Line 125  Line 125 
125    X6 = X8 - (W3-W5)*X6;    X6 = X8 - (W3-W5)*X6;
126    X7 = X8 - (W3+W5)*X7;    X7 = X8 - (W3+W5)*X7;
127    
128    // second stage    /* second stage  */
129    X8 = X0 + X1;    X8 = X0 + X1;
130    X0 -= X1;    X0 -= X1;
131    X1 = W6*(X3+X2);    X1 = W6*(X3+X2);
# Line 136  Line 136 
136    X6 = X5 + X7;    X6 = X5 + X7;
137    X5 -= X7;    X5 -= X7;
138    
139    // third stage    /* third stage  */
140    X7 = X8 + X3;    X7 = X8 + X3;
141    X8 -= X3;    X8 -= X3;
142    X3 = X0 + X2;    X3 = X0 + X2;
# Line 144  Line 144 
144    X2 = (181*(X4+X5)+128)>>8;    X2 = (181*(X4+X5)+128)>>8;
145    X4 = (181*(X4-X5)+128)>>8;    X4 = (181*(X4-X5)+128)>>8;
146    
147    // fourth stage    /* fourth stage  */
148    blk[0] = (X7+X1)>>8;    blk[0] = (X7+X1)>>8;
149    blk[1] = (X3+X2)>>8;    blk[1] = (X3+X2)>>8;
150    blk[2] = (X0+X4)>>8;    blk[2] = (X0+X4)>>8;
# Line 153  Line 153 
153    blk[5] = (X0-X4)>>8;    blk[5] = (X0-X4)>>8;
154    blk[6] = (X3-X2)>>8;    blk[6] = (X3-X2)>>8;
155    blk[7] = (X7-X1)>>8;    blk[7] = (X7-X1)>>8;
156  }*/  }
157    #endif
158    
159  /* column (vertical) IDCT  /* column (vertical) IDCT
160   *   *
# Line 164  Line 165 
165   * where: c[0]    = 1/1024   * where: c[0]    = 1/1024
166   *        c[1..7] = (1/1024)*sqrt(2)   *        c[1..7] = (1/1024)*sqrt(2)
167   */   */
168  /*  #if     0
169  static void idctcol(blk)  static void idctcol(blk)
170  short *blk;  short *blk;
171  {  {
172    int X0, X1, X2, X3, X4, X5, X6, X7, X8;    int X0, X1, X2, X3, X4, X5, X6, X7, X8;
173    
174    // shortcut    /* shortcut  */
175    if (!((X1 = (blk[8*4]<<8)) | (X2 = blk[8*6]) | (X3 = blk[8*2]) |    if (!((X1 = (blk[8*4]<<8)) | (X2 = blk[8*6]) | (X3 = blk[8*2]) |
176          (X4 = blk[8*1]) | (X5 = blk[8*7]) | (X6 = blk[8*5]) | (X7 = blk[8*3])))          (X4 = blk[8*1]) | (X5 = blk[8*7]) | (X6 = blk[8*5]) | (X7 = blk[8*3])))
177    {    {
# Line 181  Line 182 
182    
183    X0 = (blk[8*0]<<8) + 8192;    X0 = (blk[8*0]<<8) + 8192;
184    
185    // first stage    /* first stage  */
186    X8 = W7*(X4+X5) + 4;    X8 = W7*(X4+X5) + 4;
187    X4 = (X8+(W1-W7)*X4)>>3;    X4 = (X8+(W1-W7)*X4)>>3;
188    X5 = (X8-(W1+W7)*X5)>>3;    X5 = (X8-(W1+W7)*X5)>>3;
# Line 189  Line 190 
190    X6 = (X8-(W3-W5)*X6)>>3;    X6 = (X8-(W3-W5)*X6)>>3;
191    X7 = (X8-(W3+W5)*X7)>>3;    X7 = (X8-(W3+W5)*X7)>>3;
192    
193    // second stage    /* second stage */
194    X8 = X0 + X1;    X8 = X0 + X1;
195    X0 -= X1;    X0 -= X1;
196    X1 = W6*(X3+X2) + 4;    X1 = W6*(X3+X2) + 4;
# Line 200  Line 201 
201    X6 = X5 + X7;    X6 = X5 + X7;
202    X5 -= X7;    X5 -= X7;
203    
204    // third stage    /* third stage  */
205    X7 = X8 + X3;    X7 = X8 + X3;
206    X8 -= X3;    X8 -= X3;
207    X3 = X0 + X2;    X3 = X0 + X2;
# Line 208  Line 209 
209    X2 = (181*(X4+X5)+128)>>8;    X2 = (181*(X4+X5)+128)>>8;
210    X4 = (181*(X4-X5)+128)>>8;    X4 = (181*(X4-X5)+128)>>8;
211    
212    // fourth stage    /* fourth stage */
213    blk[8*0] = iclp[(X7+X1)>>14];    blk[8*0] = iclp[(X7+X1)>>14];
214    blk[8*1] = iclp[(X3+X2)>>14];    blk[8*1] = iclp[(X3+X2)>>14];
215    blk[8*2] = iclp[(X0+X4)>>14];    blk[8*2] = iclp[(X0+X4)>>14];
# Line 217  Line 218 
218    blk[8*5] = iclp[(X0-X4)>>14];    blk[8*5] = iclp[(X0-X4)>>14];
219    blk[8*6] = iclp[(X3-X2)>>14];    blk[8*6] = iclp[(X3-X2)>>14];
220    blk[8*7] = iclp[(X7-X1)>>14];    blk[8*7] = iclp[(X7-X1)>>14];
221  }*/  }
222    #endif
223    
224  // function pointer  /* function pointer */
225  idctFuncPtr idct;  idctFuncPtr idct;
226    
227  /* two dimensional inverse discrete cosine transform */  /* two dimensional inverse discrete cosine transform */
228  //void j_rev_dct(block)  /*void j_rev_dct(block) */
229  //short *block;  /*short *block; */
230  void  void
231  idct_int32(short *const block)  idct_int32(short *const block)
232  {  {
233    
234          // idct_int32_init() must be called before the first call to this function!          /* idct_int32_init() must be called before the first call to this function! */
235    
236    
237          /*int i;          /*int i;
# Line 245  Line 247 
247          static long X0, X1, X2, X3, X4, X5, X6, X7, X8;          static long X0, X1, X2, X3, X4, X5, X6, X7, X8;
248    
249    
250          for (i = 0; i < 8; i++)         // idct rows          for (i = 0; i < 8; i++)         /* idct rows */
251          {          {
252                  blk = block + (i << 3);                  blk = block + (i << 3);
253                  if (!                  if (!
# Line 257  Line 259 
259                          continue;                          continue;
260                  }                  }
261    
262                  X0 = (blk[0] << 11) + 128;      // for proper rounding in the fourth stage                  X0 = (blk[0] << 11) + 128;      /* for proper rounding in the fourth stage  */
263    
264                  // first stage                  /* first stage  */
265                  X8 = W7 * (X4 + X5);                  X8 = W7 * (X4 + X5);
266                  X4 = X8 + (W1 - W7) * X4;                  X4 = X8 + (W1 - W7) * X4;
267                  X5 = X8 - (W1 + W7) * X5;                  X5 = X8 - (W1 + W7) * X5;
# Line 267  Line 269 
269                  X6 = X8 - (W3 - W5) * X6;                  X6 = X8 - (W3 - W5) * X6;
270                  X7 = X8 - (W3 + W5) * X7;                  X7 = X8 - (W3 + W5) * X7;
271    
272                  // second stage                  /* second stage  */
273                  X8 = X0 + X1;                  X8 = X0 + X1;
274                  X0 -= X1;                  X0 -= X1;
275                  X1 = W6 * (X3 + X2);                  X1 = W6 * (X3 + X2);
# Line 278  Line 280 
280                  X6 = X5 + X7;                  X6 = X5 + X7;
281                  X5 -= X7;                  X5 -= X7;
282    
283                  // third stage                  /* third stage  */
284                  X7 = X8 + X3;                  X7 = X8 + X3;
285                  X8 -= X3;                  X8 -= X3;
286                  X3 = X0 + X2;                  X3 = X0 + X2;
# Line 286  Line 288 
288                  X2 = (181 * (X4 + X5) + 128) >> 8;                  X2 = (181 * (X4 + X5) + 128) >> 8;
289                  X4 = (181 * (X4 - X5) + 128) >> 8;                  X4 = (181 * (X4 - X5) + 128) >> 8;
290    
291                  // fourth stage                  /* fourth stage  */
292    
293                  blk[0] = (short) ((X7 + X1) >> 8);                  blk[0] = (short) ((X7 + X1) >> 8);
294                  blk[1] = (short) ((X3 + X2) >> 8);                  blk[1] = (short) ((X3 + X2) >> 8);
# Line 297  Line 299 
299                  blk[6] = (short) ((X3 - X2) >> 8);                  blk[6] = (short) ((X3 - X2) >> 8);
300                  blk[7] = (short) ((X7 - X1) >> 8);                  blk[7] = (short) ((X7 - X1) >> 8);
301    
302          }                                                       // end for ( i = 0; i < 8; ++i ) IDCT-rows          }                                                       /* end for ( i = 0; i < 8; ++i ) IDCT-rows */
303    
304    
305    
306          for (i = 0; i < 8; i++)         // idct columns          for (i = 0; i < 8; i++)         /* idct columns */
307          {          {
308                  blk = block + i;                  blk = block + i;
309                  // shortcut                  /* shortcut  */
310                  if (!                  if (!
311                          ((X1 = (blk[8 * 4] << 8)) | (X2 = blk[8 * 6]) | (X3 =                          ((X1 = (blk[8 * 4] << 8)) | (X2 = blk[8 * 6]) | (X3 =
312                                                                                                                           blk[8 *                                                                                                                           blk[8 *
# Line 320  Line 322 
322    
323                  X0 = (blk[8 * 0] << 8) + 8192;                  X0 = (blk[8 * 0] << 8) + 8192;
324    
325                  // first stage                  /* first stage  */
326                  X8 = W7 * (X4 + X5) + 4;                  X8 = W7 * (X4 + X5) + 4;
327                  X4 = (X8 + (W1 - W7) * X4) >> 3;                  X4 = (X8 + (W1 - W7) * X4) >> 3;
328                  X5 = (X8 - (W1 + W7) * X5) >> 3;                  X5 = (X8 - (W1 + W7) * X5) >> 3;
# Line 328  Line 330 
330                  X6 = (X8 - (W3 - W5) * X6) >> 3;                  X6 = (X8 - (W3 - W5) * X6) >> 3;
331                  X7 = (X8 - (W3 + W5) * X7) >> 3;                  X7 = (X8 - (W3 + W5) * X7) >> 3;
332    
333                  // second stage                  /* second stage  */
334                  X8 = X0 + X1;                  X8 = X0 + X1;
335                  X0 -= X1;                  X0 -= X1;
336                  X1 = W6 * (X3 + X2) + 4;                  X1 = W6 * (X3 + X2) + 4;
# Line 339  Line 341 
341                  X6 = X5 + X7;                  X6 = X5 + X7;
342                  X5 -= X7;                  X5 -= X7;
343    
344                  // third stage                  /* third stage  */
345                  X7 = X8 + X3;                  X7 = X8 + X3;
346                  X8 -= X3;                  X8 -= X3;
347                  X3 = X0 + X2;                  X3 = X0 + X2;
# Line 347  Line 349 
349                  X2 = (181 * (X4 + X5) + 128) >> 8;                  X2 = (181 * (X4 + X5) + 128) >> 8;
350                  X4 = (181 * (X4 - X5) + 128) >> 8;                  X4 = (181 * (X4 - X5) + 128) >> 8;
351    
352                  // fourth stage                  /* fourth stage  */
353                  blk[8 * 0] = iclp[(X7 + X1) >> 14];                  blk[8 * 0] = iclp[(X7 + X1) >> 14];
354                  blk[8 * 1] = iclp[(X3 + X2) >> 14];                  blk[8 * 1] = iclp[(X3 + X2) >> 14];
355                  blk[8 * 2] = iclp[(X0 + X4) >> 14];                  blk[8 * 2] = iclp[(X0 + X4) >> 14];
# Line 358  Line 360 
360                  blk[8 * 7] = iclp[(X7 - X1) >> 14];                  blk[8 * 7] = iclp[(X7 - X1) >> 14];
361          }          }
362    
363  }                                                               // end function idct_int32(block)  }                                                               /* end function idct_int32(block) */
364    
365    
366  //void  /*void */
367  //idct_int32_init()  /*idct_int32_init() */
368  void  void
369  idct_int32_init()  idct_int32_init(void)
370  {  {
371          int i;          int i;
372    

Legend:
Removed from v.649  
changed lines
  Added in v.677

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