1 |
|
/***************************************************************************** |
2 |
|
* |
3 |
|
* XVID MPEG-4 VIDEO CODEC |
4 |
|
* - XviD Main header file - |
5 |
|
* |
6 |
|
* This program is an implementation of a part of one or more MPEG-4 |
7 |
|
* Video tools as specified in ISO/IEC 14496-2 standard. Those intending |
8 |
|
* to use this software module in hardware or software products are |
9 |
|
* advised that its use may infringe existing patents or copyrights, and |
10 |
|
* any such use would be at such party's own risk. The original |
11 |
|
* developer of this software module and his/her company, and subsequent |
12 |
|
* editors and their companies, will have no liability for use of this |
13 |
|
* software or modifications or derivatives thereof. |
14 |
|
* |
15 |
|
* This program is free software ; you can redistribute it and/or modify |
16 |
|
* it under the terms of the GNU General Public License as published by |
17 |
|
* the Free Software Foundation ; either version 2 of the License, or |
18 |
|
* (at your option) any later version. |
19 |
|
* |
20 |
|
* This program is distributed in the hope that it will be useful, |
21 |
|
* but WITHOUT ANY WARRANTY ; without even the implied warranty of |
22 |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23 |
|
* GNU General Public License for more details. |
24 |
|
* |
25 |
|
* You should have received a copy of the GNU General Public License |
26 |
|
* along with this program ; if not, write to the Free Software |
27 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
28 |
|
* |
29 |
|
*****************************************************************************/ |
30 |
|
/***************************************************************************** |
31 |
|
* |
32 |
|
* History |
33 |
|
* |
34 |
|
* - 2002/06/13 Added legal header, ANSI C comment style (only for this header |
35 |
|
* as it can be included in a ANSI C project). |
36 |
|
* |
37 |
|
* ToDo ? : when BFRAMES is defined, the API_VERSION should not |
38 |
|
* be the same (3.0 ?) |
39 |
|
* |
40 |
|
* $Id: xvid.h,v 1.4 2002-06-20 10:51:08 suxen_drol Exp $ |
41 |
|
* |
42 |
|
*****************************************************************************/ |
43 |
|
|
44 |
|
|
45 |
#ifndef _XVID_H_ |
#ifndef _XVID_H_ |
46 |
#define _XVID_H_ |
#define _XVID_H_ |
47 |
|
|
49 |
extern "C" { |
extern "C" { |
50 |
#endif |
#endif |
51 |
|
|
52 |
// ========================================== |
/***************************************************************************** |
53 |
// global |
* Global constants |
54 |
// ========================================== |
****************************************************************************/ |
55 |
|
|
56 |
// API Version: 2.0 |
/* API Version : 2.1 */ |
57 |
#define API_VERSION ((2 << 16) | (0)) |
#define API_VERSION ((2 << 16) | (1)) |
58 |
|
|
|
// cpu features |
|
|
#define XVID_CPU_MMX 0x00000001 |
|
|
#define XVID_CPU_MMXEXT 0x00000002 |
|
|
#define XVID_CPU_SSE 0x00000004 |
|
|
#define XVID_CPU_SSE2 0x00000008 |
|
|
#define XVID_CPU_3DNOW 0x00000010 |
|
|
#define XVID_CPU_3DNOWEXT 0x00000020 |
|
|
#define XVID_CPU_TSC 0x00000040 |
|
|
#define XVID_CPU_FORCE 0x80000000 |
|
59 |
|
|
60 |
// colorspaces |
/* Error codes */ |
61 |
|
#define XVID_ERR_FAIL -1 |
62 |
|
#define XVID_ERR_OK 0 |
63 |
|
#define XVID_ERR_MEMORY 1 |
64 |
|
#define XVID_ERR_FORMAT 2 |
65 |
|
|
66 |
|
|
67 |
|
/* Colorspaces */ |
68 |
#define XVID_CSP_RGB24 0 |
#define XVID_CSP_RGB24 0 |
69 |
#define XVID_CSP_YV12 1 |
#define XVID_CSP_YV12 1 |
70 |
#define XVID_CSP_YUY2 2 |
#define XVID_CSP_YUY2 2 |
79 |
|
|
80 |
#define XVID_CSP_VFLIP 0x80000000 // flip mask |
#define XVID_CSP_VFLIP 0x80000000 // flip mask |
81 |
|
|
82 |
// error |
|
83 |
#define XVID_ERR_FAIL -1 |
/***************************************************************************** |
84 |
#define XVID_ERR_OK 0 |
* Initialization constants |
85 |
#define XVID_ERR_MEMORY 1 |
****************************************************************************/ |
86 |
#define XVID_ERR_FORMAT 2 |
|
87 |
|
/* CPU flags for XVID_INIT_PARAM.cpu_flags */ |
88 |
|
|
89 |
|
#define XVID_CPU_MMX 0x00000001 |
90 |
|
#define XVID_CPU_MMXEXT 0x00000002 |
91 |
|
#define XVID_CPU_SSE 0x00000004 |
92 |
|
#define XVID_CPU_SSE2 0x00000008 |
93 |
|
#define XVID_CPU_3DNOW 0x00000010 |
94 |
|
#define XVID_CPU_3DNOWEXT 0x00000020 |
95 |
|
|
96 |
|
#define XVID_CPU_TSC 0x00000040 |
97 |
|
|
98 |
|
#define XVID_CPU_IA64 0x00000080 |
99 |
|
|
100 |
|
#define XVID_CPU_FORCE 0x80000000 |
101 |
|
|
102 |
|
|
103 |
|
/***************************************************************************** |
104 |
|
* Initialization structures |
105 |
|
****************************************************************************/ |
106 |
|
|
107 |
typedef struct |
typedef struct |
108 |
{ |
{ |
109 |
int cpu_flags; |
int cpu_flags; |
110 |
int api_version; |
int api_version; |
111 |
int core_build; |
int core_build; |
112 |
} XVID_INIT_PARAM; |
} |
113 |
|
XVID_INIT_PARAM; |
114 |
|
|
115 |
int xvid_init(void *handle, int opt, |
/***************************************************************************** |
116 |
void *param1, void *param2); |
* Initialization entry point |
117 |
|
****************************************************************************/ |
118 |
|
|
119 |
|
int xvid_init(void *handle, |
120 |
|
int opt, |
121 |
|
void *param1, |
122 |
|
void *param2); |
123 |
|
|
|
// ========================================== |
|
|
// decoder |
|
|
// ========================================== |
|
124 |
|
|
125 |
#define XVID_QUICK_DECODE 0x00000010 /* increases decoding speed but reduces quality */ |
/***************************************************************************** |
126 |
|
* Decoder constants |
127 |
|
****************************************************************************/ |
128 |
|
|
129 |
|
/* Flags for XVID_DEC_FRAME.general */ |
130 |
|
#define XVID_QUICK_DECODE 0x00000010 |
131 |
|
|
132 |
|
/***************************************************************************** |
133 |
|
* Decoder structures |
134 |
|
****************************************************************************/ |
135 |
|
|
136 |
typedef struct |
typedef struct |
137 |
{ |
{ |
138 |
int width; |
int width; |
139 |
int height; |
int height; |
140 |
void *handle; |
void *handle; |
141 |
} XVID_DEC_PARAM; |
} |
142 |
|
XVID_DEC_PARAM; |
143 |
|
|
144 |
|
|
145 |
typedef struct |
typedef struct |
151 |
void * image; |
void * image; |
152 |
int stride; |
int stride; |
153 |
int colorspace; |
int colorspace; |
154 |
} XVID_DEC_FRAME; |
} |
155 |
|
XVID_DEC_FRAME; |
156 |
|
|
157 |
|
|
158 |
// decoder options |
/***************************************************************************** |
159 |
|
* Decoder entry point |
160 |
|
****************************************************************************/ |
161 |
|
|
162 |
|
/* decoder options */ |
163 |
#define XVID_DEC_DECODE 0 |
#define XVID_DEC_DECODE 0 |
164 |
#define XVID_DEC_CREATE 1 |
#define XVID_DEC_CREATE 1 |
165 |
#define XVID_DEC_DESTROY 2 |
#define XVID_DEC_DESTROY 2 |
170 |
void * param2); |
void * param2); |
171 |
|
|
172 |
|
|
173 |
// ========================================== |
/***************************************************************************** |
174 |
// encoder |
* Encoder constants |
175 |
// ========================================== |
****************************************************************************/ |
176 |
|
|
177 |
/* Do not rely on the VALUES of these constants, they may be changed at any time */ |
/* Flags for XVID_ENC_FRAME.general */ |
178 |
#define XVID_VALID_FLAGS 0x80000000 |
#define XVID_VALID_FLAGS 0x80000000 |
179 |
|
|
180 |
#define XVID_CUSTOM_QMATRIX 0x00000004 /* use custom quant matrix */ |
#define XVID_CUSTOM_QMATRIX 0x00000004 /* use custom quant matrix */ |
186 |
#define XVID_LATEINTRA 0x00000200 |
#define XVID_LATEINTRA 0x00000200 |
187 |
|
|
188 |
#define XVID_INTERLACING 0x00000400 /* enable interlaced encoding */ |
#define XVID_INTERLACING 0x00000400 /* enable interlaced encoding */ |
189 |
#define XVID_TOPFIELDFIRST 0x00000800 /* set top-field-first flag (cosmetic only) */ |
#define XVID_TOPFIELDFIRST 0x00000800 /* set top-field-first flag */ |
190 |
#define XVID_ALTERNATESCAN 0x00001000 /* ?? sets alternate vertical scan flag */ |
#define XVID_ALTERNATESCAN 0x00001000 /* set alternate vertical scan flag */ |
191 |
|
|
192 |
#define XVID_HINTEDME_GET 0x00002000 /* receive mv hint data from core (1st pass) */ |
#define XVID_HINTEDME_GET 0x00002000 /* receive mv hint data from core (1st pass) */ |
193 |
#define XVID_HINTEDME_SET 0x00004000 /* send mv hint data to core (2nd pass) */ |
#define XVID_HINTEDME_SET 0x00004000 /* send mv hint data to core (2nd pass) */ |
200 |
#define XVID_ME_PMVFAST 0x00080000 |
#define XVID_ME_PMVFAST 0x00080000 |
201 |
#define XVID_ME_EPZS 0x00100000 |
#define XVID_ME_EPZS 0x00100000 |
202 |
|
|
203 |
|
|
204 |
|
/* Flags for XVID_ENC_FRAME.motion */ |
205 |
|
#define PMV_ADVANCEDDIAMOND8 0x00004000 |
206 |
|
#define PMV_ADVANCEDDIAMOND16 0x00008000 |
207 |
|
|
208 |
#define PMV_HALFPELDIAMOND16 0x00010000 |
#define PMV_HALFPELDIAMOND16 0x00010000 |
209 |
#define PMV_HALFPELREFINE16 0x00020000 |
#define PMV_HALFPELREFINE16 0x00020000 |
210 |
#define PMV_EXTSEARCH16 0x00040000 /* extend PMV by more searches */ |
#define PMV_EXTSEARCH16 0x00040000 /* extend PMV by more searches */ |
224 |
#define PMV_USESQUARES8 0x80000000 |
#define PMV_USESQUARES8 0x80000000 |
225 |
|
|
226 |
|
|
227 |
|
/***************************************************************************** |
228 |
|
* Encoder structures |
229 |
|
****************************************************************************/ |
230 |
|
|
231 |
typedef struct |
typedef struct |
232 |
{ |
{ |
233 |
int width, height; |
int width, height; |
234 |
int fincr, fbase; // frame increment, fbase. each frame = "fincr/fbase" seconds |
int fincr, fbase; /* frame increment, fbase. each frame = "fincr/fbase" seconds */ |
235 |
int rc_bitrate; // the bitrate of the target encoded stream, in bits/second |
int rc_bitrate; /* the bitrate of the target encoded stream, in bits/second */ |
236 |
int rc_reaction_delay_factor; // how fast the rate control reacts - lower values are faster |
int rc_reaction_delay_factor; /* how fast the rate control reacts - lower values are faster */ |
237 |
int rc_averaging_period; // as above |
int rc_averaging_period; /* as above */ |
238 |
int rc_buffer; // as above |
int rc_buffer; /* as above */ |
239 |
int max_quantizer; // the upper limit of the quantizer |
int max_quantizer; /* the upper limit of the quantizer */ |
240 |
int min_quantizer; // the lower limit of the quantizer |
int min_quantizer; /* the lower limit of the quantizer */ |
241 |
int max_key_interval; // the maximum interval between key frames |
int max_key_interval; /* the maximum interval between key frames */ |
242 |
|
#ifdef BFRAMES |
243 |
void * handle; // [out] encoder instance handle |
int packed; /* enable packed mode */ |
244 |
|
int max_bframes; /* max sequential bframes (0=disable bframes) */ |
245 |
} XVID_ENC_PARAM; |
int bquant_ratio; /* bframe quantizer multipier (percentage). |
246 |
|
* used only when bquant < 1 |
247 |
|
* eg. 200 = x2 multiplier |
248 |
|
* quant = ((past_quant + future_quant) * bquant_ratio)/200 |
249 |
|
*/ |
250 |
|
#endif |
251 |
|
void *handle; /* [out] encoder instance handle */ |
252 |
|
} |
253 |
|
XVID_ENC_PARAM; |
254 |
|
|
255 |
typedef struct |
typedef struct |
256 |
{ |
{ |
257 |
int x; |
int x; |
258 |
int y; |
int y; |
259 |
} VECTOR; |
} |
260 |
|
VECTOR; |
261 |
|
|
262 |
typedef struct |
typedef struct |
263 |
{ |
{ |
264 |
int mode; // macroblock mode |
int mode; /* macroblock mode */ |
265 |
VECTOR mvs[4]; |
VECTOR mvs[4]; |
266 |
} MVBLOCKHINT; |
} |
267 |
|
MVBLOCKHINT; |
268 |
|
|
269 |
typedef struct |
typedef struct |
270 |
{ |
{ |
271 |
int intra; // frame intra choice |
int intra; /* frame intra choice */ |
272 |
int fcode; // frame fcode |
int fcode; /* frame fcode */ |
273 |
MVBLOCKHINT * block; // caller-allocated array of block hints (mb_width * mb_height) |
MVBLOCKHINT *block; /* caller-allocated array of block hints (mb_width * mb_height) */ |
274 |
} MVFRAMEHINT; |
} |
275 |
|
MVFRAMEHINT; |
276 |
|
|
277 |
typedef struct |
typedef struct |
278 |
{ |
{ |
279 |
int rawhints; // if set, use MVFRAMEHINT, else use compressed buffer |
int rawhints; /* if set, use MVFRAMEHINT, else use compressed buffer */ |
280 |
|
|
281 |
MVFRAMEHINT mvhint; |
MVFRAMEHINT mvhint; |
282 |
void * hintstream; // compressed hint buffer |
void *hintstream; /* compressed hint buffer */ |
283 |
int hintlength; // length of buffer (bytes) |
int hintlength; /* length of buffer (bytes) */ |
284 |
} HINTINFO; |
} |
285 |
|
HINTINFO; |
286 |
|
|
287 |
typedef struct |
typedef struct |
288 |
{ |
{ |
289 |
int general; // [in] general options |
int general; /* [in] general options */ |
290 |
int motion; // [in] ME options |
int motion; /* [in] ME options */ |
291 |
void * bitstream; // [in] bitstream ptr |
void *bitstream; /* [in] bitstream ptr */ |
292 |
int length; // [out] bitstream length (bytes) |
int length; /* [out] bitstream length (bytes) */ |
293 |
|
|
294 |
|
void *image; /* [in] image ptr */ |
295 |
|
int colorspace; /* [in] source colorspace */ |
296 |
|
|
297 |
|
unsigned char *quant_intra_matrix; // [in] custom intra qmatrix */ |
298 |
|
unsigned char *quant_inter_matrix; // [in] custom inter qmatrix */ |
299 |
|
int quant; /* [in] frame quantizer (vbr) */ |
300 |
|
int intra; /* [in] force intra frame (vbr only) |
301 |
|
* [out] intra state |
302 |
|
*/ |
303 |
|
HINTINFO hint; /* [in/out] mv hint information */ |
304 |
|
|
305 |
void * image; // [in] image ptr |
#ifdef BFRAMES |
306 |
int colorspace; // [in] source colorspace |
int bquant; /* [in] bframe quantizer */ |
307 |
|
#endif |
308 |
|
|
309 |
unsigned char *quant_intra_matrix; // [in] custom intra qmatrix |
} |
310 |
unsigned char *quant_inter_matrix; // [in] custom inter qmatrix |
XVID_ENC_FRAME; |
|
int quant; // [in] frame quantizer (vbr) |
|
|
int intra; // [in] force intra frame (vbr only) |
|
|
// [out] intra state |
|
|
HINTINFO hint; // [in/out] mv hint information |
|
|
} XVID_ENC_FRAME; |
|
311 |
|
|
312 |
|
|
313 |
typedef struct |
typedef struct |
314 |
{ |
{ |
315 |
int quant; // [out] frame quantizer |
int quant; /* [out] frame quantizer */ |
316 |
int hlength; // [out] header length (bytes) |
int hlength; /* [out] header length (bytes) */ |
317 |
int kblks, mblks, ublks; // [out] |
int kblks, mblks, ublks; /* [out] */ |
318 |
|
|
319 |
|
} |
320 |
|
XVID_ENC_STATS; |
321 |
|
|
|
} XVID_ENC_STATS; |
|
322 |
|
|
323 |
|
/***************************************************************************** |
324 |
|
* Encoder entry point |
325 |
|
****************************************************************************/ |
326 |
|
|
327 |
|
/* Encoder options */ |
328 |
#define XVID_ENC_ENCODE 0 |
#define XVID_ENC_ENCODE 0 |
329 |
#define XVID_ENC_CREATE 1 |
#define XVID_ENC_CREATE 1 |
330 |
#define XVID_ENC_DESTROY 2 |
#define XVID_ENC_DESTROY 2 |
339 |
} |
} |
340 |
#endif |
#endif |
341 |
|
|
342 |
#endif /* _XVID_H_ */ |
#endif |