1 |
/***************************************************************************** |
/***************************************************************************** |
2 |
* |
* |
3 |
* XVID MPEG-4 VIDEO CODEC |
* XVID MPEG-4 VIDEO CODEC |
4 |
* - inverse fast disrete cosine transformation - integer C version |
* - Inverse DCT - |
5 |
* |
* |
6 |
* These routines are from Independent JPEG Group's free JPEG software |
* These routines are from Independent JPEG Group's free JPEG software |
7 |
* Copyright (C) 1991-1998, Thomas G. Lane (see the file README.IJG) |
* Copyright (C) 1991-1998, Thomas G. Lane (see the file README.IJG) |
8 |
* |
* |
9 |
* This file is part of XviD, a free MPEG-4 video encoder/decoder |
* 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 |
|
* XviD is free software; you can redistribute it and/or modify it |
|
|
* under the terms of the GNU General Public License as published by |
|
11 |
* the Free Software Foundation; either version 2 of the License, or |
* the Free Software Foundation; either version 2 of the License, or |
12 |
* (at your option) any later version. |
* (at your option) any later version. |
13 |
* |
* |
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 |
* Under section 8 of the GNU General Public License, the copyright |
* $Id: idct.c,v 1.7 2004-03-22 22:36:23 edgomez Exp $ |
24 |
* holders of XVID explicitly forbid distribution in the following |
* |
25 |
* countries: |
****************************************************************************/ |
26 |
* |
|
27 |
* - Japan |
/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */ |
28 |
* - United States of America |
|
29 |
* |
/* |
30 |
* Linking XviD statically or dynamically with other modules is making a |
* Disclaimer of Warranty |
|
* combined work based on XviD. Thus, the terms and conditions of the |
|
|
* GNU General Public License cover the whole combination. |
|
|
* |
|
|
* As a special exception, the copyright holders of XviD give you |
|
|
* permission to link XviD with independent modules that communicate with |
|
|
* XviD solely through the VFW1.1 and DShow interfaces, regardless of the |
|
|
* license terms of these independent modules, and to copy and distribute |
|
|
* the resulting combined work under terms of your choice, provided that |
|
|
* every copy of the combined work is accompanied by a complete copy of |
|
|
* the source code of XviD (the version of XviD used to produce the |
|
|
* combined work), being distributed under the terms of the GNU General |
|
|
* Public License plus this exception. An independent module is a module |
|
|
* which is not derived from or based on XviD. |
|
|
* |
|
|
* Note that people who make modified versions of XviD are not obligated |
|
|
* to grant this special exception for their modified versions; it is |
|
|
* their choice whether to do so. The GNU General Public License gives |
|
|
* permission to release a modified version without this exception; this |
|
|
* exception also makes it possible to release a modified version which |
|
|
* carries forward this exception. |
|
31 |
* |
* |
32 |
* $Id: idct.c,v 1.5 2002-11-26 23:44:10 edgomez Exp $ |
* 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 |
|
* The MPEG Software Simulation Group does not represent or warrant that the |
44 |
|
* programs furnished hereunder are free of infringement of any third-party |
45 |
|
* patents. |
46 |
|
* |
47 |
|
* Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, |
48 |
|
* are subject to royalty fees to patent holders. Many of these patents are |
49 |
|
* 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 */ |
/* inverse two dimensional DCT, Chen-Wang algorithm */ |
85 |
#define W6 1108 /* 2048*sqrt(2)*cos(6*pi/16) */ |
#define W6 1108 /* 2048*sqrt(2)*cos(6*pi/16) */ |
86 |
#define W7 565 /* 2048*sqrt(2)*cos(7*pi/16) */ |
#define W7 565 /* 2048*sqrt(2)*cos(7*pi/16) */ |
87 |
|
|
|
|
|
|
/* global declarations */ |
|
|
/*void init_idct_int32 (void); */ |
|
|
/*void idct_int32 (short *block); */ |
|
|
|
|
88 |
/* private data */ |
/* private data */ |
89 |
static short iclip[1024]; /* clipping table */ |
static short iclip[1024]; /* clipping table */ |
90 |
static short *iclp; |
static short *iclp; |
91 |
|
|
92 |
/* private prototypes */ |
/* private prototypes */ |
|
/*static void idctrow _ANSI_ARGS_((short *blk)); */ |
|
|
/*static void idctcol _ANSI_ARGS_((short *blk)); */ |
|
93 |
|
|
94 |
/* row (horizontal) IDCT |
/* row (horizontal) IDCT |
95 |
* |
* |
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 |
|
|
169 |
#if 0 |
#if 0 |
170 |
static void idctcol(blk) |
static void idctcol(blk) |
171 |
short *blk; |
short *blk; |
226 |
idctFuncPtr idct; |
idctFuncPtr idct; |
227 |
|
|
228 |
/* two dimensional inverse discrete cosine transform */ |
/* two dimensional inverse discrete cosine transform */ |
|
/*void j_rev_dct(block) */ |
|
|
/*short *block; */ |
|
229 |
void |
void |
230 |
idct_int32(short *const block) |
idct_int32(short *const block) |
231 |
{ |
{ |
232 |
|
|
233 |
/* idct_int32_init() must be called before the first call to this function! */ |
/* |
234 |
|
* idct_int32_init() must be called before the first call to this |
235 |
|
* function! |
236 |
|
*/ |
237 |
|
|
238 |
|
|
239 |
/*int i; |
#if 0 |
240 |
|
int i; |
241 |
long i; |
long i; |
242 |
|
|
243 |
for (i=0; i<8; i++) |
for (i=0; i<8; i++) |
244 |
idctrow(block+8*i); |
idctrow(block+8*i); |
245 |
|
|
246 |
for (i=0; i<8; i++) |
for (i=0; i<8; i++) |
247 |
idctcol(block+i); */ |
idctcol(block+i); |
248 |
|
#endif |
249 |
|
|
250 |
static short *blk; |
static short *blk; |
251 |
static long i; |
static long i; |
252 |
static long X0, X1, X2, X3, X4, X5, X6, X7, X8; |
static long X0, X1, X2, X3, X4, X5, X6, X7, X8; |
368 |
} /* end function idct_int32(block) */ |
} /* end function idct_int32(block) */ |
369 |
|
|
370 |
|
|
|
/*void */ |
|
|
/*idct_int32_init() */ |
|
371 |
void |
void |
372 |
idct_int32_init(void) |
idct_int32_init() |
373 |
{ |
{ |
374 |
int i; |
int i; |
375 |
|
|