Parent Directory | Revision Log
Revision 1077 - (view) (download)
1 : | edgomez | 1054 | /***************************************************************************** |
2 : | * | ||
3 : | * XVID MPEG-4 VIDEO CODEC | ||
4 : | * - Global definitions - | ||
5 : | * | ||
6 : | * Copyright(C) 2002 Michael Militzer <isibaar@xvid.org> | ||
7 : | * | ||
8 : | * 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 | ||
10 : | * the Free Software Foundation ; either version 2 of the License, or | ||
11 : | * (at your option) any later version. | ||
12 : | * | ||
13 : | * This program is distributed in the hope that it will be useful, | ||
14 : | * but WITHOUT ANY WARRANTY ; without even the implied warranty of | ||
15 : | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 : | * GNU General Public License for more details. | ||
17 : | * | ||
18 : | * You should have received a copy of the GNU General Public License | ||
19 : | * along with this program ; if not, write to the Free Software | ||
20 : | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 : | * | ||
22 : | chl | 1077 | * $Id: global.h,v 1.21.2.7 2003-06-28 15:50:55 chl Exp $ |
23 : | edgomez | 1054 | * |
24 : | ****************************************************************************/ | ||
25 : | |||
26 : | Isibaar | 3 | #ifndef _GLOBAL_H_ |
27 : | #define _GLOBAL_H_ | ||
28 : | |||
29 : | h | 101 | #include "xvid.h" |
30 : | Isibaar | 3 | #include "portab.h" |
31 : | |||
32 : | suxen_drol | 118 | /* --- macroblock modes --- */ |
33 : | Isibaar | 3 | |
34 : | #define MODE_INTER 0 | ||
35 : | #define MODE_INTER_Q 1 | ||
36 : | #define MODE_INTER4V 2 | ||
37 : | #define MODE_INTRA 3 | ||
38 : | #define MODE_INTRA_Q 4 | ||
39 : | #define MODE_NOT_CODED 16 | ||
40 : | edgomez | 851 | #define MODE_NOT_CODED_GMC 17 |
41 : | Isibaar | 3 | |
42 : | suxen_drol | 118 | /* --- bframe specific --- */ |
43 : | |||
44 : | #define MODE_DIRECT 0 | ||
45 : | #define MODE_INTERPOLATE 1 | ||
46 : | #define MODE_BACKWARD 2 | ||
47 : | #define MODE_FORWARD 3 | ||
48 : | chenm001 | 156 | #define MODE_DIRECT_NONE_MV 4 |
49 : | edgomez | 851 | #define MODE_DIRECT_NO4V 5 |
50 : | suxen_drol | 118 | |
51 : | suxen_drol | 890 | |
52 : | edgomez | 1053 | /* |
53 : | * vop coding types | ||
54 : | * intra, prediction, backward, sprite, not_coded | ||
55 : | */ | ||
56 : | suxen_drol | 890 | #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 : | edgomez | 851 | typedef struct |
87 : | { | ||
88 : | VECTOR duv[3]; | ||
89 : | } | ||
90 : | WARPPOINTS; | ||
91 : | suxen_drol | 118 | |
92 : | edgomez | 851 | /* 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 : | edgomez | 1053 | 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 : | edgomez | 851 | |
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 : | chl | 1077 | typedef struct NEW_GMC_DATA NEW_GMC_DATA; |
139 : | struct NEW_GMC_DATA | ||
140 : | { | ||
141 : | int num_wp; // 0=none, 1=translation, 2,3 = warping | ||
142 : | // a value of -1 means: "structure not initialized!" | ||
143 : | int accuracy; // {0,1,2,3} => {1/2,1/4,1/8,1/16} pel | ||
144 : | edgomez | 851 | |
145 : | chl | 1077 | int sW, sH; // sprite size * 16 |
146 : | int dU[2], dV[2], Uo, Vo, Uco, Vco; // gradient, calculated from warp points | ||
147 : | |||
148 : | void (*predict_16x16)(const NEW_GMC_DATA * const This, | ||
149 : | uint8_t *dst, const uint8_t *src, | ||
150 : | int dststride, int srcstride, int x, int y, int rounding); | ||
151 : | void (*predict_8x8) (const NEW_GMC_DATA * const This, | ||
152 : | uint8_t *uDst, const uint8_t *uSrc, | ||
153 : | uint8_t *vDst, const uint8_t *vSrc, | ||
154 : | int dststride, int srcstride, int x, int y, int rounding); | ||
155 : | void (*get_average_mv)(NEW_GMC_DATA *Dsp, VECTOR * const mv, | ||
156 : | int x, int y, int qpel); | ||
157 : | }; | ||
158 : | |||
159 : | Isibaar | 3 | typedef struct |
160 : | { | ||
161 : | edgomez | 851 | uint8_t *y; |
162 : | uint8_t *u; | ||
163 : | uint8_t *v; | ||
164 : | } | ||
165 : | IMAGE; | ||
166 : | |||
167 : | |||
168 : | typedef struct | ||
169 : | { | ||
170 : | h | 101 | uint32_t bufa; |
171 : | uint32_t bufb; | ||
172 : | uint32_t buf; | ||
173 : | uint32_t pos; | ||
174 : | uint32_t *tail; | ||
175 : | uint32_t *start; | ||
176 : | uint32_t length; | ||
177 : | edgomez | 972 | uint32_t initpos; |
178 : | edgomez | 195 | } |
179 : | h | 101 | Bitstream; |
180 : | Isibaar | 3 | |
181 : | |||
182 : | #define MBPRED_SIZE 15 | ||
183 : | |||
184 : | |||
185 : | typedef struct | ||
186 : | { | ||
187 : | edgomez | 1053 | /* decoder/encoder */ |
188 : | Isibaar | 3 | VECTOR mvs[4]; |
189 : | |||
190 : | chl | 172 | short int pred_values[6][MBPRED_SIZE]; |
191 : | int acpred_directions[6]; | ||
192 : | edgomez | 195 | |
193 : | Isibaar | 3 | int mode; |
194 : | edgomez | 1053 | int quant; /* absolute quant */ |
195 : | Isibaar | 3 | |
196 : | h | 69 | int field_dct; |
197 : | int field_pred; | ||
198 : | int field_for_top; | ||
199 : | int field_for_bot; | ||
200 : | |||
201 : | edgomez | 1053 | /* encoder specific */ |
202 : | Isibaar | 3 | |
203 : | chl | 172 | VECTOR mv16; |
204 : | Isibaar | 3 | VECTOR pmvs[4]; |
205 : | edgomez | 1053 | VECTOR qmvs[4]; /* mvs in quarter pixel resolution */ |
206 : | chl | 172 | |
207 : | edgomez | 1053 | int32_t sad8[4]; /* SAD values for inter4v-VECTORs */ |
208 : | int32_t sad16; /* SAD value for inter-VECTOR */ | ||
209 : | chl | 172 | |
210 : | Isibaar | 3 | int dquant; |
211 : | int cbp; | ||
212 : | |||
213 : | edgomez | 1053 | /* bframe stuff */ |
214 : | suxen_drol | 118 | |
215 : | VECTOR b_mvs[4]; | ||
216 : | edgomez | 851 | VECTOR b_qmvs[4]; |
217 : | suxen_drol | 118 | |
218 : | chenm001 | 156 | int mb_type; |
219 : | |||
220 : | edgomez | 1053 | /* |
221 : | * stuff for block based ME (needed for Qpel ME) | ||
222 : | * backup of last integer ME vectors/sad | ||
223 : | */ | ||
224 : | edgomez | 851 | |
225 : | edgomez | 1053 | VECTOR amv; /* average motion vectors from GMC */ |
226 : | edgomez | 851 | int32_t mcsel; |
227 : | |||
228 : | /* This structure has become way to big! What to do? Split it up? */ | ||
229 : | |||
230 : | edgomez | 195 | } |
231 : | MACROBLOCK; | ||
232 : | Isibaar | 3 | |
233 : | edgomez | 851 | static __inline uint32_t |
234 : | edgomez | 195 | get_dc_scaler(uint32_t quant, |
235 : | uint32_t lum) | ||
236 : | Isibaar | 3 | { |
237 : | edgomez | 195 | if (quant < 5) |
238 : | return 8; | ||
239 : | Isibaar | 3 | |
240 : | edgomez | 195 | if (quant < 25 && !lum) |
241 : | edgomez | 851 | return (quant + 13) / 2; |
242 : | Isibaar | 3 | |
243 : | edgomez | 195 | if (quant < 9) |
244 : | edgomez | 851 | return 2 * quant; |
245 : | Isibaar | 3 | |
246 : | edgomez | 195 | if (quant < 25) |
247 : | edgomez | 851 | return quant + 8; |
248 : | Isibaar | 3 | |
249 : | edgomez | 195 | if (lum) |
250 : | edgomez | 851 | return 2 * quant - 16; |
251 : | Isibaar | 3 | else |
252 : | edgomez | 851 | return quant - 6; |
253 : | Isibaar | 3 | } |
254 : | |||
255 : | edgomez | 1053 | /* useful macros */ |
256 : | suxen_drol | 118 | |
257 : | #define MIN(X, Y) ((X)<(Y)?(X):(Y)) | ||
258 : | #define MAX(X, Y) ((X)>(Y)?(X):(Y)) | ||
259 : | edgomez | 982 | /* #define ABS(X) (((X)>0)?(X):-(X)) */ |
260 : | suxen_drol | 118 | #define SIGN(X) (((X)>0)?1:-1) |
261 : | edgomez | 851 | #define CLIP(X,AMIN,AMAX) (((X)<(AMIN)) ? (AMIN) : ((X)>(AMAX)) ? (AMAX) : (X)) |
262 : | #define DIV_DIV(a,b) (((a)>0) ? ((a)+((b)>>1))/(b) : ((a)-((b)>>1))/(b)) | ||
263 : | suxen_drol | 926 | #define SWAP(_T_,A,B) { _T_ tmp = A; A = B; B = tmp; } |
264 : | suxen_drol | 118 | |
265 : | |||
266 : | edgomez | 851 | #endif /* _GLOBAL_H_ */ |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |