[cvs] / xvidcore / src / global.h Repository:
ViewVC logotype

Annotation of /xvidcore/src/global.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.23 - (view) (download)

1 : edgomez 1.23 /*****************************************************************************
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 :     * $Id$
23 :     *
24 :     ****************************************************************************/
25 :    
26 : Isibaar 1.1 #ifndef _GLOBAL_H_
27 :     #define _GLOBAL_H_
28 :    
29 : h 1.4 #include "xvid.h"
30 : Isibaar 1.1 #include "portab.h"
31 :    
32 : suxen_drol 1.5 /* --- macroblock modes --- */
33 : Isibaar 1.1
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 1.19 #define MODE_NOT_CODED_GMC 17
41 : Isibaar 1.1
42 : suxen_drol 1.5 /* --- 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 1.6 #define MODE_DIRECT_NONE_MV 4
49 : edgomez 1.19 #define MODE_DIRECT_NO4V 5
50 :    
51 : edgomez 1.23
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 : edgomez 1.19 {
88 :     VECTOR duv[3];
89 :     }
90 :     WARPPOINTS;
91 :    
92 : edgomez 1.23 /* save all warping parameters for GMC once and for all, instead of
93 : edgomez 1.19 recalculating for every block. This is needed for encoding&decoding
94 : edgomez 1.23 When switching to incremental calculations, this will get much shorter
95 : edgomez 1.19 */
96 :    
97 :     /* we don't include WARPPOINTS wp here, but in FRAMEINFO itself */
98 :    
99 : edgomez 1.23 typedef struct
100 : edgomez 1.19 {
101 : edgomez 1.23 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 1.19
105 :     int W;
106 :     int H;
107 : edgomez 1.23
108 :     int ss;
109 :     int smask;
110 :     int sigma;
111 :    
112 :     int r;
113 :     int rho;
114 : edgomez 1.19
115 :     int i0s;
116 :     int j0s;
117 :     int i1s;
118 :     int j1s;
119 :     int i2s;
120 :     int j2s;
121 : edgomez 1.23
122 :     int i1ss;
123 :     int j1ss;
124 :     int i2ss;
125 :     int j2ss;
126 : edgomez 1.19
127 :     int alpha;
128 :     int beta;
129 : edgomez 1.23 int Ws;
130 :     int Hs;
131 :    
132 :     int dxF, dyF, dxG, dyG;
133 : edgomez 1.19 int Fo, Go;
134 :     int cFo, cGo;
135 : edgomez 1.23 } GMC_DATA;
136 : edgomez 1.19
137 : edgomez 1.23 typedef struct _NEW_GMC_DATA
138 :     {
139 :     /* 0=none, 1=translation, 2,3 = warping
140 :     * a value of -1 means: "structure not initialized!" */
141 :     int num_wp;
142 :    
143 :     /* {0,1,2,3} => {1/2,1/4,1/8,1/16} pel */
144 :     int accuracy;
145 :    
146 :     /* sprite size * 16 */
147 :     int sW, sH;
148 :    
149 :     /* gradient, calculated from warp points */
150 :     int dU[2], dV[2], Uo, Vo, Uco, Vco;
151 :    
152 :     void (*predict_16x16)(const struct _NEW_GMC_DATA * const This,
153 :     uint8_t *dst, const uint8_t *src,
154 :     int dststride, int srcstride, int x, int y, int rounding);
155 :     void (*predict_8x8) (const struct _NEW_GMC_DATA * const This,
156 :     uint8_t *uDst, const uint8_t *uSrc,
157 :     uint8_t *vDst, const uint8_t *vSrc,
158 :     int dststride, int srcstride, int x, int y, int rounding);
159 :     void (*get_average_mv)(const struct _NEW_GMC_DATA * const Dsp, VECTOR * const mv,
160 :     int x, int y, int qpel);
161 :     } NEW_GMC_DATA;
162 : edgomez 1.19
163 :     typedef struct
164 :     {
165 :     uint8_t *y;
166 :     uint8_t *u;
167 :     uint8_t *v;
168 :     }
169 :     IMAGE;
170 : suxen_drol 1.5
171 :    
172 : Isibaar 1.1 typedef struct
173 :     {
174 : h 1.4 uint32_t bufa;
175 :     uint32_t bufb;
176 :     uint32_t buf;
177 :     uint32_t pos;
178 :     uint32_t *tail;
179 :     uint32_t *start;
180 :     uint32_t length;
181 : edgomez 1.22 uint32_t initpos;
182 : edgomez 1.10 }
183 : h 1.4 Bitstream;
184 : Isibaar 1.1
185 :    
186 :     #define MBPRED_SIZE 15
187 :    
188 :    
189 :     typedef struct
190 :     {
191 : edgomez 1.23 /* decoder/encoder */
192 : Isibaar 1.1 VECTOR mvs[4];
193 :    
194 : chl 1.9 short int pred_values[6][MBPRED_SIZE];
195 :     int acpred_directions[6];
196 : edgomez 1.10
197 : Isibaar 1.1 int mode;
198 : edgomez 1.23 int quant; /* absolute quant */
199 : Isibaar 1.1
200 : h 1.2 int field_dct;
201 :     int field_pred;
202 :     int field_for_top;
203 :     int field_for_bot;
204 :    
205 : edgomez 1.23 /* encoder specific */
206 : Isibaar 1.1
207 :     VECTOR pmvs[4];
208 : edgomez 1.23 VECTOR qmvs[4]; /* mvs in quarter pixel resolution */
209 : chl 1.9
210 : edgomez 1.23 int32_t sad8[4]; /* SAD values for inter4v-VECTORs */
211 :     int32_t sad16; /* SAD value for inter-VECTOR */
212 : chl 1.9
213 : Isibaar 1.1 int dquant;
214 :     int cbp;
215 :    
216 : edgomez 1.23 /* bframe stuff */
217 : suxen_drol 1.5
218 :     VECTOR b_mvs[4];
219 : edgomez 1.19 VECTOR b_qmvs[4];
220 : chl 1.13
221 : edgomez 1.23 VECTOR amv; /* average motion vectors from GMC */
222 : edgomez 1.19 int32_t mcsel;
223 :    
224 : edgomez 1.23 /* This structure has become way to big! What to do? Split it up? */
225 : chl 1.11
226 : edgomez 1.10 }
227 :     MACROBLOCK;
228 : Isibaar 1.1
229 : edgomez 1.19 static __inline uint32_t
230 : edgomez 1.10 get_dc_scaler(uint32_t quant,
231 :     uint32_t lum)
232 : Isibaar 1.1 {
233 : edgomez 1.10 if (quant < 5)
234 :     return 8;
235 : Isibaar 1.1
236 : edgomez 1.10 if (quant < 25 && !lum)
237 : edgomez 1.19 return (quant + 13) / 2;
238 : Isibaar 1.1
239 : edgomez 1.10 if (quant < 9)
240 : edgomez 1.19 return 2 * quant;
241 : Isibaar 1.1
242 : edgomez 1.10 if (quant < 25)
243 : edgomez 1.19 return quant + 8;
244 : Isibaar 1.1
245 : edgomez 1.10 if (lum)
246 : edgomez 1.19 return 2 * quant - 16;
247 : Isibaar 1.1 else
248 : edgomez 1.19 return quant - 6;
249 : Isibaar 1.1 }
250 : suxen_drol 1.5
251 : edgomez 1.23 /* useful macros */
252 : suxen_drol 1.5
253 :     #define MIN(X, Y) ((X)<(Y)?(X):(Y))
254 :     #define MAX(X, Y) ((X)>(Y)?(X):(Y))
255 : edgomez 1.23 /* #define ABS(X) (((X)>0)?(X):-(X)) */
256 : suxen_drol 1.5 #define SIGN(X) (((X)>0)?1:-1)
257 : edgomez 1.19 #define CLIP(X,AMIN,AMAX) (((X)<(AMIN)) ? (AMIN) : ((X)>(AMAX)) ? (AMAX) : (X))
258 :     #define DIV_DIV(a,b) (((a)>0) ? ((a)+((b)>>1))/(b) : ((a)-((b)>>1))/(b))
259 : edgomez 1.23 #define SWAP(_T_,A,B) { _T_ tmp = A; A = B; B = tmp; }
260 : suxen_drol 1.5
261 : Isibaar 1.1
262 : edgomez 1.19 #endif /* _GLOBAL_H_ */

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