1 |
/***************************************************************************** |
/***************************************************************************** |
2 |
* |
* |
3 |
* XVID MPEG-4 VIDEO CODEC |
* XVID MPEG-4 VIDEO CODEC |
4 |
* - Global structures, constants - |
* - Global definitions - |
5 |
* |
* |
6 |
* Copyright(C) 2002 Michael Militzer <isibaar@xvid.org> |
* Copyright(C) 2002 Michael Militzer <isibaar@xvid.org> |
7 |
* |
* |
8 |
* 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 |
9 |
* |
* 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 |
|
10 |
* the Free Software Foundation; either version 2 of the License, or |
* the Free Software Foundation; either version 2 of the License, or |
11 |
* (at your option) any later version. |
* (at your option) any later version. |
12 |
* |
* |
19 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
* |
* |
22 |
* Under section 8 of the GNU General Public License, the copyright |
* $Id: global.h,v 1.21.2.6 2003-06-09 13:50:57 edgomez Exp $ |
|
* holders of XVID explicitly forbid distribution in the following |
|
|
* countries: |
|
|
* |
|
|
* - Japan |
|
|
* - United States of America |
|
|
* |
|
|
* Linking XviD statically or dynamically with other modules is making a |
|
|
* 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. |
|
|
* |
|
|
* $Id: global.h,v 1.17 2002-11-26 23:44:10 edgomez Exp $ |
|
23 |
* |
* |
24 |
****************************************************************************/ |
****************************************************************************/ |
25 |
|
|
36 |
#define MODE_INTER4V 2 |
#define MODE_INTER4V 2 |
37 |
#define MODE_INTRA 3 |
#define MODE_INTRA 3 |
38 |
#define MODE_INTRA_Q 4 |
#define MODE_INTRA_Q 4 |
|
#define MODE_STUFFING 7 |
|
39 |
#define MODE_NOT_CODED 16 |
#define MODE_NOT_CODED 16 |
40 |
|
#define MODE_NOT_CODED_GMC 17 |
41 |
|
|
42 |
/* --- bframe specific --- */ |
/* --- bframe specific --- */ |
43 |
|
|
46 |
#define MODE_BACKWARD 2 |
#define MODE_BACKWARD 2 |
47 |
#define MODE_FORWARD 3 |
#define MODE_FORWARD 3 |
48 |
#define MODE_DIRECT_NONE_MV 4 |
#define MODE_DIRECT_NONE_MV 4 |
49 |
|
#define MODE_DIRECT_NO4V 5 |
50 |
|
|
51 |
|
|
52 |
|
/* |
53 |
|
* vop coding types |
54 |
|
* intra, prediction, backward, sprite, not_coded |
55 |
|
*/ |
56 |
|
#define I_VOP 0 |
57 |
|
#define P_VOP 1 |
58 |
|
#define B_VOP 2 |
59 |
|
#define S_VOP 3 |
60 |
|
#define N_VOP 4 |
61 |
|
|
62 |
|
/* convert mpeg-4 coding type i/p/b/s_VOP to XVID_TYPE_xxx */ |
63 |
|
static __inline int |
64 |
|
coding2type(int coding_type) |
65 |
|
{ |
66 |
|
return coding_type + 1; |
67 |
|
} |
68 |
|
|
69 |
|
/* convert XVID_TYPE_xxx to bitstream coding type i/p/b/s_VOP */ |
70 |
|
static __inline int |
71 |
|
type2coding(int xvid_type) |
72 |
|
{ |
73 |
|
return xvid_type - 1; |
74 |
|
} |
75 |
|
|
76 |
|
|
77 |
|
typedef struct |
78 |
|
{ |
79 |
|
int x; |
80 |
|
int y; |
81 |
|
} |
82 |
|
VECTOR; |
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
typedef struct |
87 |
|
{ |
88 |
|
VECTOR duv[3]; |
89 |
|
} |
90 |
|
WARPPOINTS; |
91 |
|
|
92 |
|
/* save all warping parameters for GMC once and for all, instead of |
93 |
|
recalculating for every block. This is needed for encoding&decoding |
94 |
|
When switching to incremental calculations, this will get much shorter |
95 |
|
*/ |
96 |
|
|
97 |
|
/* we don't include WARPPOINTS wp here, but in FRAMEINFO itself */ |
98 |
|
|
99 |
|
typedef struct |
100 |
|
{ |
101 |
|
int num_wp; /* [input]: 0=none, 1=translation, 2,3 = warping */ |
102 |
|
/* a value of -1 means: "structure not initialized!" */ |
103 |
|
int s; /* [input]: calc is done with 1/s pel resolution */ |
104 |
|
|
105 |
|
int W; |
106 |
|
int H; |
107 |
|
|
108 |
|
int ss; |
109 |
|
int smask; |
110 |
|
int sigma; |
111 |
|
|
112 |
|
int r; |
113 |
|
int rho; |
114 |
|
|
115 |
|
int i0s; |
116 |
|
int j0s; |
117 |
|
int i1s; |
118 |
|
int j1s; |
119 |
|
int i2s; |
120 |
|
int j2s; |
121 |
|
|
122 |
|
int i1ss; |
123 |
|
int j1ss; |
124 |
|
int i2ss; |
125 |
|
int j2ss; |
126 |
|
|
127 |
|
int alpha; |
128 |
|
int beta; |
129 |
|
int Ws; |
130 |
|
int Hs; |
131 |
|
|
132 |
|
int dxF, dyF, dxG, dyG; |
133 |
|
int Fo, Go; |
134 |
|
int cFo, cGo; |
135 |
|
} |
136 |
|
GMC_DATA; |
137 |
|
|
138 |
|
|
139 |
|
typedef struct |
140 |
|
{ |
141 |
|
uint8_t *y; |
142 |
|
uint8_t *u; |
143 |
|
uint8_t *v; |
144 |
|
} |
145 |
|
IMAGE; |
146 |
|
|
147 |
|
|
148 |
typedef struct |
typedef struct |
154 |
uint32_t *tail; |
uint32_t *tail; |
155 |
uint32_t *start; |
uint32_t *start; |
156 |
uint32_t length; |
uint32_t length; |
157 |
|
uint32_t initpos; |
158 |
} |
} |
159 |
Bitstream; |
Bitstream; |
160 |
|
|
182 |
|
|
183 |
VECTOR mv16; |
VECTOR mv16; |
184 |
VECTOR pmvs[4]; |
VECTOR pmvs[4]; |
185 |
|
VECTOR qmvs[4]; /* mvs in quarter pixel resolution */ |
186 |
|
|
187 |
int32_t sad8[4]; /* SAD values for inter4v-VECTORs */ |
int32_t sad8[4]; /* SAD values for inter4v-VECTORs */ |
188 |
int32_t sad16; /* SAD value for inter-VECTOR */ |
int32_t sad16; /* SAD value for inter-VECTOR */ |
193 |
/* bframe stuff */ |
/* bframe stuff */ |
194 |
|
|
195 |
VECTOR b_mvs[4]; |
VECTOR b_mvs[4]; |
196 |
VECTOR b_pmvs[4]; |
VECTOR b_qmvs[4]; |
|
|
|
|
/* bframe direct mode */ |
|
|
|
|
|
VECTOR directmv[4]; |
|
|
VECTOR deltamv; |
|
197 |
|
|
198 |
int mb_type; |
int mb_type; |
|
int dbquant; |
|
199 |
|
|
200 |
/* stuff for block based ME (needed for Qpel ME) */ |
/* |
201 |
/* backup of last integer ME vectors/sad */ |
* stuff for block based ME (needed for Qpel ME) |
202 |
|
* backup of last integer ME vectors/sad |
203 |
|
*/ |
204 |
|
|
205 |
VECTOR i_mv16; |
VECTOR amv; /* average motion vectors from GMC */ |
206 |
VECTOR i_mvs[4]; |
int32_t mcsel; |
207 |
|
|
208 |
int32_t i_sad8[4]; /* SAD values for inter4v-VECTORs */ |
/* This structure has become way to big! What to do? Split it up? */ |
|
int32_t i_sad16; /* SAD value for inter-VECTOR */ |
|
209 |
|
|
210 |
} |
} |
211 |
MACROBLOCK; |
MACROBLOCK; |
212 |
|
|
213 |
static __inline int8_t |
static __inline uint32_t |
214 |
get_dc_scaler(uint32_t quant, |
get_dc_scaler(uint32_t quant, |
215 |
uint32_t lum) |
uint32_t lum) |
216 |
{ |
{ |
236 |
|
|
237 |
#define MIN(X, Y) ((X)<(Y)?(X):(Y)) |
#define MIN(X, Y) ((X)<(Y)?(X):(Y)) |
238 |
#define MAX(X, Y) ((X)>(Y)?(X):(Y)) |
#define MAX(X, Y) ((X)>(Y)?(X):(Y)) |
239 |
#define ABS(X) (((X)>0)?(X):-(X)) |
/* #define ABS(X) (((X)>0)?(X):-(X)) */ |
240 |
#define SIGN(X) (((X)>0)?1:-1) |
#define SIGN(X) (((X)>0)?1:-1) |
241 |
|
#define CLIP(X,AMIN,AMAX) (((X)<(AMIN)) ? (AMIN) : ((X)>(AMAX)) ? (AMAX) : (X)) |
242 |
|
#define DIV_DIV(a,b) (((a)>0) ? ((a)+((b)>>1))/(b) : ((a)-((b)>>1))/(b)) |
243 |
|
#define SWAP(_T_,A,B) { _T_ tmp = A; A = B; B = tmp; } |
244 |
|
|
245 |
|
|
246 |
#endif /* _GLOBAL_H_ */ |
#endif /* _GLOBAL_H_ */ |