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

Annotation of /xvidcore/src/global.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.26 - (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 : Isibaar 1.26 * $Id: global.h,v 1.25 2005/12/09 04:45:35 syskin Exp $
23 : edgomez 1.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 :     * vop coding types
53 :     * intra, prediction, backward, sprite, not_coded
54 :     */
55 :     #define I_VOP 0
56 :     #define P_VOP 1
57 :     #define B_VOP 2
58 :     #define S_VOP 3
59 :     #define N_VOP 4
60 :    
61 :     /* convert mpeg-4 coding type i/p/b/s_VOP to XVID_TYPE_xxx */
62 :     static __inline int
63 :     coding2type(int coding_type)
64 :     {
65 :     return coding_type + 1;
66 :     }
67 :    
68 :     /* convert XVID_TYPE_xxx to bitstream coding type i/p/b/s_VOP */
69 :     static __inline int
70 :     type2coding(int xvid_type)
71 :     {
72 :     return xvid_type - 1;
73 :     }
74 :    
75 :     typedef struct
76 :     {
77 :     int x;
78 :     int y;
79 :     }
80 :     VECTOR;
81 :    
82 :     typedef struct
83 : edgomez 1.19 {
84 :     VECTOR duv[3];
85 :     }
86 :     WARPPOINTS;
87 :    
88 : edgomez 1.23 /* save all warping parameters for GMC once and for all, instead of
89 : edgomez 1.19 recalculating for every block. This is needed for encoding&decoding
90 : edgomez 1.23 When switching to incremental calculations, this will get much shorter
91 : edgomez 1.19 */
92 :    
93 :     /* we don't include WARPPOINTS wp here, but in FRAMEINFO itself */
94 :    
95 : edgomez 1.23 typedef struct
96 : edgomez 1.19 {
97 : edgomez 1.23 int num_wp; /* [input]: 0=none, 1=translation, 2,3 = warping */
98 :     /* a value of -1 means: "structure not initialized!" */
99 :     int s; /* [input]: calc is done with 1/s pel resolution */
100 : edgomez 1.19
101 :     int W;
102 :     int H;
103 : edgomez 1.23
104 :     int ss;
105 :     int smask;
106 :     int sigma;
107 :    
108 :     int r;
109 :     int rho;
110 : edgomez 1.19
111 :     int i0s;
112 :     int j0s;
113 :     int i1s;
114 :     int j1s;
115 :     int i2s;
116 :     int j2s;
117 : edgomez 1.23
118 :     int i1ss;
119 :     int j1ss;
120 :     int i2ss;
121 :     int j2ss;
122 : edgomez 1.19
123 :     int alpha;
124 :     int beta;
125 : edgomez 1.23 int Ws;
126 :     int Hs;
127 :    
128 :     int dxF, dyF, dxG, dyG;
129 : edgomez 1.19 int Fo, Go;
130 :     int cFo, cGo;
131 : edgomez 1.23 } GMC_DATA;
132 : edgomez 1.19
133 : edgomez 1.23 typedef struct _NEW_GMC_DATA
134 :     {
135 :     /* 0=none, 1=translation, 2,3 = warping
136 :     * a value of -1 means: "structure not initialized!" */
137 :     int num_wp;
138 :    
139 :     /* {0,1,2,3} => {1/2,1/4,1/8,1/16} pel */
140 :     int accuracy;
141 :    
142 :     /* sprite size * 16 */
143 :     int sW, sH;
144 :    
145 :     /* gradient, calculated from warp points */
146 :     int dU[2], dV[2], Uo, Vo, Uco, Vco;
147 :    
148 :     void (*predict_16x16)(const struct _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 struct _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)(const struct _NEW_GMC_DATA * const Dsp, VECTOR * const mv,
156 :     int x, int y, int qpel);
157 :     } NEW_GMC_DATA;
158 : edgomez 1.19
159 :     typedef struct
160 :     {
161 :     uint8_t *y;
162 :     uint8_t *u;
163 :     uint8_t *v;
164 :     }
165 :     IMAGE;
166 : suxen_drol 1.5
167 : Isibaar 1.1 typedef struct
168 :     {
169 : h 1.4 uint32_t bufa;
170 :     uint32_t bufb;
171 :     uint32_t buf;
172 :     uint32_t pos;
173 :     uint32_t *tail;
174 :     uint32_t *start;
175 :     uint32_t length;
176 : edgomez 1.22 uint32_t initpos;
177 : edgomez 1.10 }
178 : h 1.4 Bitstream;
179 : Isibaar 1.1
180 :     #define MBPRED_SIZE 15
181 :    
182 :     typedef struct
183 :     {
184 : edgomez 1.23 /* decoder/encoder */
185 : Isibaar 1.1 VECTOR mvs[4];
186 :    
187 : chl 1.9 short int pred_values[6][MBPRED_SIZE];
188 :     int acpred_directions[6];
189 : edgomez 1.10
190 : Isibaar 1.1 int mode;
191 : edgomez 1.23 int quant; /* absolute quant */
192 : Isibaar 1.1
193 : h 1.2 int field_dct;
194 :     int field_pred;
195 :     int field_for_top;
196 :     int field_for_bot;
197 :    
198 : edgomez 1.23 /* encoder specific */
199 : Isibaar 1.1
200 :     VECTOR pmvs[4];
201 : edgomez 1.23 VECTOR qmvs[4]; /* mvs in quarter pixel resolution */
202 : chl 1.9
203 : edgomez 1.23 int32_t sad8[4]; /* SAD values for inter4v-VECTORs */
204 :     int32_t sad16; /* SAD value for inter-VECTOR */
205 : chl 1.9
206 : Isibaar 1.1 int dquant;
207 :     int cbp;
208 :    
209 : syskin 1.25 /* lambda for these blocks */
210 :     int lambda[6];
211 :    
212 : edgomez 1.23 /* bframe stuff */
213 : suxen_drol 1.5
214 :     VECTOR b_mvs[4];
215 : edgomez 1.19 VECTOR b_qmvs[4];
216 : chl 1.13
217 : edgomez 1.23 VECTOR amv; /* average motion vectors from GMC */
218 : edgomez 1.19 int32_t mcsel;
219 : suxen_drol 1.24
220 :     VECTOR mvs_avg; //CK average of field motion vectors
221 : edgomez 1.19
222 : edgomez 1.23 /* This structure has become way to big! What to do? Split it up? */
223 : chl 1.11
224 : edgomez 1.10 }
225 :     MACROBLOCK;
226 : Isibaar 1.1
227 : edgomez 1.19 static __inline uint32_t
228 : edgomez 1.10 get_dc_scaler(uint32_t quant,
229 :     uint32_t lum)
230 : Isibaar 1.1 {
231 : edgomez 1.10 if (quant < 5)
232 :     return 8;
233 : Isibaar 1.1
234 : edgomez 1.10 if (quant < 25 && !lum)
235 : edgomez 1.19 return (quant + 13) / 2;
236 : Isibaar 1.1
237 : edgomez 1.10 if (quant < 9)
238 : edgomez 1.19 return 2 * quant;
239 : Isibaar 1.1
240 : edgomez 1.10 if (quant < 25)
241 : edgomez 1.19 return quant + 8;
242 : Isibaar 1.1
243 : edgomez 1.10 if (lum)
244 : edgomez 1.19 return 2 * quant - 16;
245 : Isibaar 1.1 else
246 : edgomez 1.19 return quant - 6;
247 : Isibaar 1.1 }
248 : suxen_drol 1.5
249 : edgomez 1.23 /* useful macros */
250 : suxen_drol 1.5
251 :     #define MIN(X, Y) ((X)<(Y)?(X):(Y))
252 :     #define MAX(X, Y) ((X)>(Y)?(X):(Y))
253 : edgomez 1.23 /* #define ABS(X) (((X)>0)?(X):-(X)) */
254 : suxen_drol 1.5 #define SIGN(X) (((X)>0)?1:-1)
255 : edgomez 1.19 #define CLIP(X,AMIN,AMAX) (((X)<(AMIN)) ? (AMIN) : ((X)>(AMAX)) ? (AMAX) : (X))
256 :     #define DIV_DIV(a,b) (((a)>0) ? ((a)+((b)>>1))/(b) : ((a)-((b)>>1))/(b))
257 : edgomez 1.23 #define SWAP(_T_,A,B) { _T_ tmp = A; A = B; B = tmp; }
258 : suxen_drol 1.5
259 : Isibaar 1.1
260 : edgomez 1.19 #endif /* _GLOBAL_H_ */

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