3 |
* XVID MPEG-4 VIDEO CODEC |
* XVID MPEG-4 VIDEO CODEC |
4 |
* - XviD Main header file - |
* - XviD Main header file - |
5 |
* |
* |
6 |
* This program is free software ; you can redistribute it and/or modify |
* This file is part of XviD, a free MPEG-4 video encoder/decoder |
7 |
* it under the terms of the GNU General Public License as published by |
* |
8 |
|
* XviD is free software; you can redistribute it and/or modify it |
9 |
|
* 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 |
23 |
/***************************************************************************** |
* holders of XVID explicitly forbid distribution in the following |
24 |
|
* countries: |
25 |
|
* |
26 |
|
* - Japan |
27 |
|
* - United States of America |
28 |
* |
* |
29 |
* History |
* Linking XviD statically or dynamically with other modules is making a |
30 |
|
* combined work based on XviD. Thus, the terms and conditions of the |
31 |
|
* GNU General Public License cover the whole combination. |
32 |
* |
* |
33 |
* - 2002/06/13 Added legal header, ANSI C comment style (only for this header |
* As a special exception, the copyright holders of XviD give you |
34 |
* as it can be included in a ANSI C project). |
* permission to link XviD with independent modules that communicate with |
35 |
|
* XviD solely through the VFW1.1 and DShow interfaces, regardless of the |
36 |
|
* license terms of these independent modules, and to copy and distribute |
37 |
|
* the resulting combined work under terms of your choice, provided that |
38 |
|
* every copy of the combined work is accompanied by a complete copy of |
39 |
|
* the source code of XviD (the version of XviD used to produce the |
40 |
|
* combined work), being distributed under the terms of the GNU General |
41 |
|
* Public License plus this exception. An independent module is a module |
42 |
|
* which is not derived from or based on XviD. |
43 |
* |
* |
44 |
* ToDo ? : when BFRAMES is defined, the API_VERSION should not |
* Note that people who make modified versions of XviD are not obligated |
45 |
* be the same (3.0 ?) |
* to grant this special exception for their modified versions; it is |
46 |
|
* their choice whether to do so. The GNU General Public License gives |
47 |
|
* permission to release a modified version without this exception; this |
48 |
|
* exception also makes it possible to release a modified version which |
49 |
|
* carries forward this exception. |
50 |
* |
* |
51 |
* $Id$ |
* $Id$ |
52 |
* |
* |
53 |
*****************************************************************************/ |
*****************************************************************************/ |
54 |
|
|
|
|
|
55 |
#ifndef _XVID_H_ |
#ifndef _XVID_H_ |
56 |
#define _XVID_H_ |
#define _XVID_H_ |
57 |
|
|
58 |
#ifdef __cplusplus |
#ifdef __cplusplus |
59 |
* $Id$ |
extern "C" { |
60 |
#endif |
#endif |
61 |
|
|
62 |
|
|
63 |
|
/** |
64 |
|
* \defgroup global_grp Global constants used in both encoder and decoder. |
65 |
|
* |
66 |
|
* This module describe all constants used in both the encoder and the decoder. |
67 |
|
* @{ |
68 |
|
*/ |
69 |
|
|
70 |
|
/***************************************************************************** |
71 |
|
* API version number |
72 |
|
****************************************************************************/ |
73 |
|
|
74 |
|
/** |
75 |
|
* \defgroup api_grp API version |
76 |
|
* @{ |
77 |
|
*/ |
78 |
|
|
79 |
|
#define API_VERSION ((2 << 16) | (1))/**< This constant tells you what XviD's |
80 |
|
* version this header defines. |
81 |
|
* |
82 |
|
* You can use it to check if the host XviD library API is the same as the one |
83 |
|
* you used to build you client program. If versions mismatch, then it is |
84 |
|
* highly possible that your application will segfault because the host XviD |
85 |
|
* library and your application use different structures. |
86 |
|
* |
87 |
|
*/ |
88 |
|
|
89 |
|
/** @} */ |
90 |
|
|
91 |
|
|
92 |
/***************************************************************************** |
/***************************************************************************** |
93 |
* Global constants |
* Error codes |
94 |
****************************************************************************/ |
****************************************************************************/ |
95 |
|
|
|
/* API Version : 2.1 */ |
|
|
#define API_VERSION ((2 << 16) | (1)) |
|
96 |
|
|
97 |
|
/** |
98 |
|
* \defgroup error_grp Error codes returned by XviD API entry points. |
99 |
|
* @{ |
100 |
|
*/ |
101 |
|
|
102 |
/* Error codes */ |
#define XVID_ERR_FAIL -1 /**< Operation failed. |
103 |
#define XVID_ERR_FAIL -1 |
* |
104 |
#define XVID_ERR_OK 0 |
* The requested XviD operation failed. If this error code is returned from : |
105 |
#define XVID_ERR_MEMORY 1 |
* <ul> |
106 |
#define XVID_ERR_FORMAT 2 |
* <li>the xvid_init function : you must not try to use an XviD's instance from |
107 |
|
* this point of the code. Clean all instances you |
108 |
|
* already created and exit the program cleanly. |
109 |
|
* <li>xvid_encore or xvid_decore : something was wrong and en/decoding |
110 |
|
* operation was not completed sucessfully. |
111 |
|
* you can stop the en/decoding process or just |
112 |
|
* ignore and go on. |
113 |
|
* <li>xvid_stop : you can safely ignore it if you call this function at the |
114 |
|
* end of your program. |
115 |
|
* </ul> |
116 |
|
*/ |
117 |
|
|
118 |
|
#define XVID_ERR_OK 0 /**< Operation succeed. |
119 |
|
* |
120 |
|
* The requested XviD operation succeed, you can continue to use XviD's |
121 |
|
* functions. |
122 |
|
*/ |
123 |
|
|
124 |
|
#define XVID_ERR_MEMORY 1 /**< Operation failed. |
125 |
|
* |
126 |
|
* Insufficent memory was available on the host system. |
127 |
|
*/ |
128 |
|
|
129 |
/* Colorspaces */ |
#define XVID_ERR_FORMAT 2 /**< Operation failed. |
130 |
#define XVID_CSP_RGB24 0 |
* |
131 |
#define XVID_CSP_YV12 1 |
* The format of the parameters or input stream were incorrect. |
132 |
#define XVID_CSP_YUY2 2 |
*/ |
|
#define XVID_CSP_UYVY 3 |
|
|
#define XVID_CSP_I420 4 |
|
|
#define XVID_CSP_RGB555 10 |
|
|
#define XVID_CSP_RGB565 11 |
|
|
#define XVID_CSP_USER 12 |
|
|
#define XVID_CSP_EXTERN 1004 // per slice rendering |
|
|
#define XVID_CSP_YVYU 1002 |
|
|
#define XVID_CSP_RGB32 1000 |
|
|
#define XVID_CSP_NULL 9999 |
|
133 |
|
|
134 |
#define XVID_CSP_VFLIP 0x80000000 // flip mask |
/** @} */ |
135 |
|
|
136 |
|
|
137 |
/***************************************************************************** |
/***************************************************************************** |
138 |
* Initialization constants |
* Color space constants |
139 |
****************************************************************************/ |
****************************************************************************/ |
140 |
|
|
|
/* CPU flags for XVID_INIT_PARAM.cpu_flags */ |
|
141 |
|
|
142 |
#define XVID_CPU_MMX 0x00000001 |
/** |
143 |
#define XVID_CPU_MMXEXT 0x00000002 |
* \defgroup csp_grp Colorspaces constants. |
144 |
#define XVID_CPU_SSE 0x00000004 |
* @{ |
145 |
#define XVID_CPU_SSE2 0x00000008 |
*/ |
146 |
#define XVID_CPU_3DNOW 0x00000010 |
|
147 |
#define XVID_CPU_3DNOWEXT 0x00000020 |
#define XVID_CSP_RGB24 0 /**< 24-bit RGB colorspace (b,g,r packed) */ |
148 |
|
#define XVID_CSP_YV12 1 /**< YV12 colorspace (y,v,u planar) */ |
149 |
|
#define XVID_CSP_YUY2 2 /**< YUY2 colorspace (y,u,y,v packed) */ |
150 |
|
#define XVID_CSP_UYVY 3 /**< UYVY colorspace (u,y,v,y packed) */ |
151 |
|
#define XVID_CSP_I420 4 /**< I420 colorsapce (y,u,v planar) */ |
152 |
|
#define XVID_CSP_RGB555 10 /**< 16-bit RGB555 colorspace */ |
153 |
|
#define XVID_CSP_RGB565 11 /**< 16-bit RGB565 colorspace */ |
154 |
|
#define XVID_CSP_USER 12 /**< user colorspace format, where the image buffer points |
155 |
|
* to a DEC_PICTURE (y,u,v planar) structure. |
156 |
|
* |
157 |
|
* For encoding, image is read from the DEC_PICTURE |
158 |
|
* parameter values. For decoding, the DEC_PICTURE |
159 |
|
* parameters are set, pointing to the internal XviD |
160 |
|
* image buffer. */ |
161 |
|
#define XVID_CSP_EXTERN 1004 /**< Special colorspace used for slice rendering |
162 |
|
* |
163 |
|
* The application provides an external buffer to XviD. |
164 |
|
* This way, XviD works directly into the final rendering |
165 |
|
* buffer, no need to specify this is a speed boost feature. |
166 |
|
* This feature is only used by mplayer at the moment, refer |
167 |
|
* to mplayer code to see how it can be used. */ |
168 |
|
#define XVID_CSP_YVYU 1002 /**< YVYU colorspace (y,v,y,u packed) */ |
169 |
|
#define XVID_CSP_RGB32 1000 /**< 32-bit RGB colorspace (b,g,r,a packed) */ |
170 |
|
#define XVID_CSP_NULL 9999 /**< NULL colorspace; no conversion is performed */ |
171 |
|
|
172 |
|
#define XVID_CSP_VFLIP 0x80000000 /**< (flag) Flip frame vertically during conversion */ |
173 |
|
|
174 |
#define XVID_CPU_TSC 0x00000040 |
/** @} */ |
175 |
|
|
176 |
#define XVID_CPU_IA64 0x00000080 |
/** @} */ |
177 |
|
|
178 |
#define XVID_CPU_CHKONLY 0x40000000 /* check cpu only; dont init globals */ |
/** |
179 |
#define XVID_CPU_FORCE 0x80000000 |
* \defgroup init_grp Initialization constants, structures and functions. |
180 |
|
* |
181 |
|
* This section describes all the constants, structures and functions used to |
182 |
|
* initialize the XviD core library |
183 |
|
* |
184 |
|
* @{ |
185 |
|
*/ |
186 |
|
|
187 |
|
|
188 |
/***************************************************************************** |
/***************************************************************************** |
189 |
|
* CPU flags |
190 |
|
****************************************************************************/ |
191 |
|
|
192 |
|
|
193 |
|
/** |
194 |
|
* \defgroup cpu_grp Flags for XVID_INIT_PARAM.cpu_flags. |
195 |
|
* |
196 |
|
* This section describes all constants that show host cpu available features, |
197 |
|
* and allow a client application to force usage of some cpu instructions sets. |
198 |
|
* @{ |
199 |
|
*/ |
200 |
|
|
201 |
|
|
202 |
|
/** |
203 |
|
* \defgroup x86_grp x86 specific cpu flags |
204 |
|
* @{ |
205 |
|
*/ |
206 |
|
|
207 |
|
#define XVID_CPU_MMX 0x00000001 /**< use/has MMX instruction set */ |
208 |
|
#define XVID_CPU_MMXEXT 0x00000002 /**< use/has MMX-ext (pentium3) instruction set */ |
209 |
|
#define XVID_CPU_SSE 0x00000004 /**< use/has SSE (pentium3) instruction set */ |
210 |
|
#define XVID_CPU_SSE2 0x00000008 /**< use/has SSE2 (pentium4) instruction set */ |
211 |
|
#define XVID_CPU_3DNOW 0x00000010 /**< use/has 3dNOW (k6-2) instruction set */ |
212 |
|
#define XVID_CPU_3DNOWEXT 0x00000020 /**< use/has 3dNOW-ext (athlon) instruction set */ |
213 |
|
#define XVID_CPU_TSC 0x00000040 /**< has TimeStampCounter instruction */ |
214 |
|
|
215 |
|
/** @} */ |
216 |
|
|
217 |
|
/** |
218 |
|
* \defgroup ia64_grp ia64 specific cpu flags. |
219 |
|
* @{ |
220 |
|
*/ |
221 |
|
|
222 |
|
#define XVID_CPU_IA64 0x00000080 /**< Forces ia64 optimized code usage |
223 |
|
* |
224 |
|
* This flags allow client applications to force IA64 optimized functions. |
225 |
|
* This feature is considered exeperimental and should be treated as is. |
226 |
|
*/ |
227 |
|
|
228 |
|
/** @} */ |
229 |
|
|
230 |
|
/** |
231 |
|
* \defgroup iniflags_grp Initialization commands. |
232 |
|
* |
233 |
|
* @{ |
234 |
|
*/ |
235 |
|
|
236 |
|
#define XVID_CPU_CHKONLY 0x40000000 /**< Check cpu features |
237 |
|
* |
238 |
|
* When this flag is set, the xvid_init function performs just a cpu feature |
239 |
|
* checking and then fills the cpu field. This flag is usefull when client |
240 |
|
* applications want to know what instruction sets the host cpu supports. |
241 |
|
*/ |
242 |
|
|
243 |
|
#define XVID_CPU_FORCE 0x80000000 /**< Force input flags to be used |
244 |
|
* |
245 |
|
* When this flag is set, client application forces XviD to use other flags |
246 |
|
* set in cpu_flags. \b Use this at your own risk. |
247 |
|
*/ |
248 |
|
|
249 |
|
/** @} */ |
250 |
|
|
251 |
|
/** @} */ |
252 |
|
|
253 |
|
/***************************************************************************** |
254 |
* Initialization structures |
* Initialization structures |
255 |
****************************************************************************/ |
****************************************************************************/ |
256 |
|
|
257 |
|
/** Structure used in xvid_init function. */ |
258 |
typedef struct |
typedef struct |
259 |
{ |
{ |
260 |
int cpu_flags; |
int cpu_flags; /**< [in/out] |
261 |
int api_version; |
* |
262 |
int core_build; |
* Filled with desired[in] or available[out] |
263 |
|
* cpu instruction sets. |
264 |
|
*/ |
265 |
|
int api_version; /**< [out] |
266 |
|
* |
267 |
|
* xvid_init will initialize this field with |
268 |
|
* the API_VERSION used in this XviD core |
269 |
|
* library |
270 |
|
*/ |
271 |
|
int core_build; /**< [out] |
272 |
|
* \todo Unused. |
273 |
|
*/ |
274 |
} |
} |
275 |
XVID_INIT_PARAM; |
XVID_INIT_PARAM; |
276 |
|
|
278 |
* Initialization entry point |
* Initialization entry point |
279 |
****************************************************************************/ |
****************************************************************************/ |
280 |
|
|
281 |
|
/** |
282 |
|
* \defgroup inientry_grp Initialization entry point. |
283 |
|
* @{ |
284 |
|
*/ |
285 |
|
|
286 |
|
/** |
287 |
|
* \brief Initialization entry point. |
288 |
|
* |
289 |
|
* This is the XviD's initialization entry point, it is only used to initialize |
290 |
|
* the XviD internal data (function pointers, vector length code tables, |
291 |
|
* rgb2yuv lookup tables). |
292 |
|
* |
293 |
|
* \param handle Reserved for future use. |
294 |
|
* \param opt Reserved for future use (set it to 0). |
295 |
|
* \param param1 Used to pass an XVID_INIT_PARAM parameter. |
296 |
|
* \param param2 Reserved for future use. |
297 |
|
*/ |
298 |
int xvid_init(void *handle, |
int xvid_init(void *handle, |
299 |
int opt, |
int opt, |
300 |
void *param1, |
void *param1, |
301 |
void *param2); |
void *param2); |
302 |
|
|
303 |
|
/** @} */ |
304 |
|
|
305 |
|
/** @} */ |
306 |
|
|
307 |
/***************************************************************************** |
/***************************************************************************** |
308 |
* Decoder constants |
* Decoder constant |
309 |
****************************************************************************/ |
****************************************************************************/ |
310 |
|
|
311 |
/* Flags for XVID_DEC_FRAME.general */ |
/** |
312 |
|
* \defgroup decoder_grp Decoder related functions and structures. |
313 |
|
* |
314 |
|
* This part describes all the structures/functions from XviD's API needed for |
315 |
|
* decoding a MPEG4 compliant streams. |
316 |
|
* @{ |
317 |
|
*/ |
318 |
|
|
319 |
|
/** |
320 |
|
* \defgroup decframe_grp Flags for XVID_DEC_FRAME.general |
321 |
|
* |
322 |
|
* Flags' description for the XVID_DEC_FRAME.general member. |
323 |
|
* |
324 |
|
* @{ |
325 |
|
*/ |
326 |
|
|
327 |
|
/** Not used at the moment */ |
328 |
#define XVID_QUICK_DECODE 0x00000010 |
#define XVID_QUICK_DECODE 0x00000010 |
329 |
|
|
330 |
|
|
331 |
|
/** |
332 |
|
* @} |
333 |
|
*/ |
334 |
|
|
335 |
/***************************************************************************** |
/***************************************************************************** |
336 |
* Decoder structures |
* Decoder structures |
337 |
****************************************************************************/ |
****************************************************************************/ |
370 |
* Decoder entry point |
* Decoder entry point |
371 |
****************************************************************************/ |
****************************************************************************/ |
372 |
|
|
373 |
/* decoder options */ |
/** |
374 |
#define XVID_DEC_DECODE 0 |
* \defgroup decops_grp Decoder operations |
375 |
#define XVID_DEC_CREATE 1 |
* |
376 |
#define XVID_DEC_DESTROY 2 |
* These are all the operations XviD's decoder can perform. |
377 |
|
* |
378 |
|
* @{ |
379 |
|
*/ |
380 |
|
|
381 |
|
#define XVID_DEC_DECODE 0 /**< Decodes a frame |
382 |
|
* |
383 |
|
* This operation constant is used when client application wants to decode a |
384 |
|
* frame. Client application must also fill XVID_DEC_FRAME appropriately. |
385 |
|
*/ |
386 |
|
|
387 |
|
#define XVID_DEC_CREATE 1 /**< Creates a decoder instance |
388 |
|
* |
389 |
|
* This operation constant is used by a client application in order to create |
390 |
|
* a decoder instance. Decoder instances are independant from each other, and |
391 |
|
* can be safely threaded. |
392 |
|
*/ |
393 |
|
|
394 |
|
#define XVID_DEC_DESTROY 2 /**< Destroys a decoder instance |
395 |
|
* |
396 |
|
* This operation constant is used by the client application to destroy a |
397 |
|
* previously created decoder instance. |
398 |
|
*/ |
399 |
|
|
400 |
|
/** |
401 |
|
* @} |
402 |
|
*/ |
403 |
|
|
404 |
|
/** |
405 |
|
* \defgroup decentry_grp Decoder entry point |
406 |
|
* |
407 |
|
* @{ |
408 |
|
*/ |
409 |
|
|
410 |
|
/** |
411 |
|
* \brief Decoder entry point. |
412 |
|
* |
413 |
|
* This is the XviD's decoder entry point. The possible operations are |
414 |
|
* described in the \ref decops_grp section. |
415 |
|
* |
416 |
|
* \param handle Decoder instance handle. |
417 |
|
* \param opt Decoder option constant |
418 |
|
* \param param1 Used to pass a XVID_DEC_PARAM or XVID_DEC_FRAME structure |
419 |
|
* \param param2 Reserved for future use. |
420 |
|
*/ |
421 |
|
|
422 |
int xvid_decore(void *handle, |
int xvid_decore(void *handle, |
423 |
int opt, |
int opt, |
424 |
void *param1, |
void *param1, |
425 |
void *param2); |
void *param2); |
426 |
|
|
427 |
|
/** @} */ |
428 |
|
|
429 |
|
/** @} */ |
430 |
|
|
431 |
|
/** |
432 |
|
* \defgroup encoder_grp Encoder related functions and structures. |
433 |
|
* |
434 |
|
* @{ |
435 |
|
*/ |
436 |
|
|
437 |
/***************************************************************************** |
/***************************************************************************** |
438 |
* Encoder constants |
* Encoder constants |
439 |
****************************************************************************/ |
****************************************************************************/ |
440 |
|
|
441 |
/* Flags for XVID_ENC_PARAM.global */ |
/** |
442 |
#define XVID_GLOBAL_PACKED 0x00000001 /* packed bitstream */ |
* \defgroup encgenflags_grp Flags for XVID_ENC_FRAME.general |
443 |
#define XVID_GLOBAL_DX50BVOP 0x00000002 /* dx50 bvop compatibility */ |
* @{ |
444 |
#define XVID_GLOBAL_DEBUG 0x00000004 /* print debug info on each frame */ |
*/ |
445 |
|
|
446 |
/* Flags for XVID_ENC_FRAME.general */ |
#define XVID_VALID_FLAGS 0x80000000 /**< Reserved for future use */ |
447 |
#define XVID_VALID_FLAGS 0x80000000 |
|
448 |
|
#define XVID_CUSTOM_QMATRIX 0x00000004 /**< Use custom quantization matrices |
449 |
#define XVID_CUSTOM_QMATRIX 0x00000004 /* use custom quant matrix */ |
* |
450 |
#define XVID_H263QUANT 0x00000010 |
* This flag forces XviD to use custom matrices passed to encoder in |
451 |
#define XVID_MPEGQUANT 0x00000020 |
* XVID_ENC_FRAME structure (members quant_intra_matrix and quant_inter_matrix) */ |
452 |
#define XVID_HALFPEL 0x00000040 /* use halfpel interpolation */ |
#define XVID_H263QUANT 0x00000010 /**< Use H263 quantization |
453 |
#define XVID_ADAPTIVEQUANT 0x00000080 |
* |
454 |
#define XVID_LUMIMASKING 0x00000100 |
* This flag forces XviD to use H263 quantization type */ |
455 |
#define XVID_LATEINTRA 0x00000200 |
#define XVID_MPEGQUANT 0x00000020 /**< Use MPEG4 quantization. |
456 |
|
* |
457 |
#define XVID_INTERLACING 0x00000400 /* enable interlaced encoding */ |
* This flag forces XviD to use MPEG4 quantization type */ |
458 |
#define XVID_TOPFIELDFIRST 0x00000800 /* set top-field-first flag */ |
#define XVID_HALFPEL 0x00000040 /**< Halfpel motion estimation |
459 |
#define XVID_ALTERNATESCAN 0x00001000 /* set alternate vertical scan flag */ |
* |
460 |
|
* informs xvid to perform a half pixel motion estimation. */ |
461 |
#define XVID_HINTEDME_GET 0x00002000 /* receive mv hint data from core (1st pass) */ |
#define XVID_ADAPTIVEQUANT 0x00000080/**< Adaptive quantization |
462 |
#define XVID_HINTEDME_SET 0x00004000 /* send mv hint data to core (2nd pass) */ |
* |
463 |
|
* informs xvid to perform an adaptative quantization using a Luminance |
464 |
#define XVID_INTER4V 0x00008000 |
* masking algorithm */ |
465 |
|
#define XVID_LUMIMASKING 0x00000100/**< Lumimasking flag |
466 |
#define XVID_ME_ZERO 0x00010000 |
* |
467 |
#define XVID_ME_LOGARITHMIC 0x00020000 |
* \deprecated This flag is no longer used. */ |
468 |
#define XVID_ME_FULLSEARCH 0x00040000 |
#define XVID_LATEINTRA 0x00000200/**< Unknown |
469 |
#define XVID_ME_PMVFAST 0x00080000 |
* |
470 |
#define XVID_ME_EPZS 0x00100000 |
* \deprecated This flag is no longer used. */ |
471 |
|
#define XVID_INTERLACING 0x00000400/**< MPEG4 interlacing mode. |
472 |
|
* |
473 |
#define XVID_GREYSCALE 0x01000000 /* enable greyscale only mode (even for */ |
* Enables interlacing encoding mode */ |
474 |
#define XVID_GRAYSCALE 0x01000000 /* color input material chroma is ignored) */ |
#define XVID_TOPFIELDFIRST 0x00000800/**< Unknown |
475 |
|
* |
476 |
|
* \deprecated This flag is no longer used. */ |
477 |
/* Flags for XVID_ENC_FRAME.motion */ |
#define XVID_ALTERNATESCAN 0x00001000/**< |
478 |
#define PMV_ADVANCEDDIAMOND8 0x00004000 |
* |
479 |
#define PMV_ADVANCEDDIAMOND16 0x00008000 |
* \deprecated This flag is no longer used. */ |
480 |
#define PMV_EARLYSTOP16 0x00080000 |
#define XVID_HINTEDME_GET 0x00002000/**< Gets Motion vector data from ME system. |
481 |
#define PMV_QUICKSTOP16 0x00100000 /* like early, but without any more refinement */ |
* |
482 |
#define PMV_UNRESTRICTED16 0x00200000 /* unrestricted ME, not implemented */ |
* informs xvid to return Motion Estimation vectors from the ME encoder |
483 |
#define PMV_OVERLAPPING16 0x00400000 /* overlapping ME, not implemented */ |
* algorithm. Used during a first pass. */ |
484 |
#define PMV_USESQUARES16 0x00800000 |
#define XVID_HINTEDME_SET 0x00004000/**< Gives Motion vectors hint to ME system. |
485 |
|
* |
486 |
#define PMV_HALFPELDIAMOND8 0x01000000 |
* informs xvid to use the user given motion estimation vectors as hints |
487 |
#define PMV_HALFPELREFINE8 0x02000000 |
* for the encoder ME algorithms. Used during a 2nd pass. */ |
488 |
#define PMV_EXTSEARCH8 0x04000000 /* extend PMV by more searches */ |
#define XVID_INTER4V 0x00008000/**< Inter4V mode. |
489 |
#define PMV_EARLYSTOP8 0x08000000 |
* |
490 |
#define PMV_QUICKSTOP8 0x10000000 /* like early, but without any more refinement */ |
* forces XviD to search a vector for each 8x8 block within the 16x16 Macro |
491 |
#define PMV_UNRESTRICTED8 0x20000000 /* unrestricted ME, not implemented */ |
* Block. This mode should be used only if the XVID_HALFPEL mode is activated |
492 |
#define PMV_OVERLAPPING8 0x40000000 /* overlapping ME, not implemented */ |
* (this could change in the future). */ |
493 |
#define PMV_USESQUARES8 0x80000000 |
#define XVID_ME_ZERO 0x00010000/**< Unused |
494 |
|
* |
495 |
|
* Do not use this flag (reserved for future use) */ |
496 |
|
#define XVID_ME_LOGARITHMIC 0x00020000/**< Unused |
497 |
|
* |
498 |
|
* Do not use this flag (reserved for future use) */ |
499 |
|
#define XVID_ME_FULLSEARCH 0x00040000/**< Unused |
500 |
|
* |
501 |
|
* Do not use this flag (reserved for future use) */ |
502 |
|
#define XVID_ME_PMVFAST 0x00080000/**< Use PMVfast ME algorithm. |
503 |
|
* |
504 |
|
* Switches XviD ME algorithm to PMVfast */ |
505 |
|
#define XVID_ME_EPZS 0x00100000/**< Use EPZS ME algorithm. |
506 |
|
* |
507 |
|
* Switches XviD ME algorithm to EPZS */ |
508 |
|
#define XVID_GREYSCALE 0x01000000/**< Discard chroma data. |
509 |
|
* |
510 |
|
* This flags forces XviD to discard chroma data, this is not mpeg4 greyscale |
511 |
|
* mode, it simply drops chroma MBs using cbp == 0 for these blocks */ |
512 |
|
#define XVID_GRAYSCALE XVID_GREYSCALE /**< XVID_GREYSCALE alias |
513 |
|
* |
514 |
|
* United States locale support. */ |
515 |
|
|
516 |
|
/** @} */ |
517 |
|
|
518 |
|
/** |
519 |
|
* \defgroup encmotionflags_grp Flags for XVID_ENC_FRAME.motion |
520 |
|
* @{ |
521 |
|
*/ |
522 |
|
|
523 |
|
#define PMV_ADVANCEDDIAMOND8 0x00004000/**< Uses advanced diamonds for 8x8 blocks |
524 |
|
* |
525 |
|
* Same as its 16x16 companion option |
526 |
|
*/ |
527 |
|
#define PMV_ADVANCEDDIAMOND16 0x00008000/**< Uses advanced diamonds for 16x16 blocks |
528 |
|
* |
529 |
|
* */ |
530 |
|
#define PMV_HALFPELDIAMOND16 0x00010000/**< Turns on halfpel precision for 16x16 blocks |
531 |
|
* |
532 |
|
* switches the search algorithm from 1 or 2 full pixels precision to 1 or 2 half pixel precision. |
533 |
|
*/ |
534 |
|
#define PMV_HALFPELREFINE16 0x00020000/**< Turns on halfpel refinement step |
535 |
|
* |
536 |
|
* After normal diamond search, an extra halfpel refinement step is performed. Should always be used if |
537 |
|
* XVID_HALFPEL is on, because it gives a rather big increase in quality. |
538 |
|
*/ |
539 |
|
#define PMV_EXTSEARCH16 0x00040000/**< Extends search for 16x16 blocks |
540 |
|
* |
541 |
|
* Normal PMVfast predicts one start vector and does diamond search around this position. EXTSEARCH means that 2 |
542 |
|
* more start vectors are used: (0,0) and median predictor and diamond search is done for those, too. Makes |
543 |
|
* search slightly slower, but quality sometimes gets better. |
544 |
|
*/ |
545 |
|
#define PMV_EARLYSTOP16 0x00080000/**< Dynamic ME thresholding |
546 |
|
* |
547 |
|
* PMVfast and EPZS stop search if current best is below some dynamic threshhold. No diamond search is done, |
548 |
|
* only halfpel refinement (if active). Without EARLYSTOP diamond search is always done. That would be much slower, |
549 |
|
* but not really lead to better quality. |
550 |
|
*/ |
551 |
|
#define PMV_QUICKSTOP16 0x00100000/**< Dynamic ME thresholding |
552 |
|
* |
553 |
|
* like EARLYSTOP, but not even halfpel refinement is done. Normally worse quality, so it defaults to |
554 |
|
* off. Might be removed, too. |
555 |
|
*/ |
556 |
|
#define PMV_UNRESTRICTED16 0x00200000/**< Not implemented |
557 |
|
* |
558 |
|
* "unrestricted ME" is a feature of MPEG4. It's not implemented, so this flag is ignored (not even |
559 |
|
* checked). |
560 |
|
*/ |
561 |
|
#define PMV_OVERLAPPING16 0x00400000/**< Not implemented |
562 |
|
* |
563 |
|
* Same as above |
564 |
|
*/ |
565 |
|
#define PMV_USESQUARES16 0x00800000/**< Use square pattern |
566 |
|
* |
567 |
|
* Replace the diamond search with a square search. |
568 |
|
*/ |
569 |
|
#define PMV_HALFPELDIAMOND8 0x01000000/**< see 16x16 equivalent |
570 |
|
* |
571 |
|
* Same as its 16x16 companion option */ |
572 |
|
#define PMV_HALFPELREFINE8 0x02000000/**< see 16x16 equivalent |
573 |
|
* |
574 |
|
* Same as its 16x16 companion option */ |
575 |
|
#define PMV_EXTSEARCH8 0x04000000/**< see 16x16 equivalent |
576 |
|
* |
577 |
|
* Same as its 16x16 companion option */ |
578 |
|
#define PMV_EARLYSTOP8 0x08000000/**< see 16x16 equivalent |
579 |
|
* |
580 |
|
* Same as its 16x16 companion option */ |
581 |
|
#define PMV_QUICKSTOP8 0x10000000/**< see 16x16 equivalent |
582 |
|
* |
583 |
|
* Same as its 16x16 companion option */ |
584 |
|
#define PMV_UNRESTRICTED8 0x20000000/**< see 16x16 equivalent |
585 |
|
* |
586 |
|
* Same as its 16x16 companion option */ |
587 |
|
#define PMV_OVERLAPPING8 0x40000000/**< see 16x16 equivalent |
588 |
|
* |
589 |
|
* Same as its 16x16 companion option */ |
590 |
|
#define PMV_USESQUARES8 0x80000000/**< see 16x16 equivalent |
591 |
|
* |
592 |
|
* Same as its 16x16 companion option */ |
593 |
|
|
594 |
|
/** @} */ |
595 |
|
|
596 |
/***************************************************************************** |
/***************************************************************************** |
597 |
* Encoder structures |
* Encoder structures |
598 |
****************************************************************************/ |
****************************************************************************/ |
599 |
|
|
600 |
|
/** Structure used for encoder instance creation */ |
601 |
typedef struct |
typedef struct |
602 |
{ |
{ |
603 |
int width, height; |
int width; /**< [in] |
604 |
int fincr, fbase; /* frame increment, fbase. each frame = "fincr/fbase" seconds */ |
* |
605 |
int rc_bitrate; /* the bitrate of the target encoded stream, in bits/second */ |
* Input frame width. */ |
606 |
int rc_reaction_delay_factor; /* how fast the rate control reacts - lower values are faster */ |
int height; /**< [in] |
607 |
int rc_averaging_period; /* as above */ |
* |
608 |
int rc_buffer; /* as above */ |
* Input frame height. */ |
609 |
int max_quantizer; /* the upper limit of the quantizer */ |
int fincr; /**< [in] |
610 |
int min_quantizer; /* the lower limit of the quantizer */ |
* |
611 |
int max_key_interval; /* the maximum interval between key frames */ |
* Time increment (fps = increment/base). */ |
612 |
#ifdef _SMP |
int fbase; /**< [in] |
613 |
int num_threads; /* number of threads */ |
* |
614 |
#endif |
* Time base (fps = increment/base). */ |
615 |
#ifdef BFRAMES |
int rc_bitrate; /**< [in] |
616 |
int global; /* global/debug options */ |
* |
617 |
int max_bframes; /* max sequential bframes (0=disable bframes) */ |
* Sets the target bitrate of the encoded stream, in bits/second. **/ |
618 |
int bquant_ratio; /* bframe quantizer multipier (percentage). |
int rc_reaction_delay_factor; /**< [in] |
619 |
* used only when bquant < 1 |
* |
620 |
* eg. 200 = x2 multiplier |
* Tunes how fast the rate control reacts - lower values are faster. */ |
621 |
* quant = ((past_quant + future_quant) * bquant_ratio)/200 |
int rc_averaging_period; /**< [in] |
622 |
*/ |
* |
623 |
int frame_drop_ratio; /* frame dropping: 0=drop none... 100=drop all */ |
* Tunes how fast the rate control reacts - lower values are faster. */ |
624 |
#endif |
int rc_buffer; /**< [in] |
625 |
void *handle; /* [out] encoder instance handle */ |
* |
626 |
|
* Tunes how fast the rate control reacts - lower values are faster. */ |
627 |
|
int max_quantizer; /**< [in] |
628 |
|
* |
629 |
|
* Sets the upper limit of the quantizer. */ |
630 |
|
int min_quantizer; /**< [in] |
631 |
|
* |
632 |
|
* Sets the lower limit of the quantizer. */ |
633 |
|
int max_key_interval; /**< [in] |
634 |
|
* |
635 |
|
* Sets the maximum interval between key frames. */ |
636 |
|
void *handle; /**< [out] |
637 |
|
* |
638 |
|
* XviD core lib will set this with the creater encoder instance. */ |
639 |
} |
} |
640 |
XVID_ENC_PARAM; |
XVID_ENC_PARAM; |
641 |
|
|
642 |
typedef struct |
typedef struct |
643 |
{ |
{ |
644 |
int x; |
int x; |
645 |
|
int y; |
646 |
} |
} |
647 |
VECTOR; |
VECTOR; |
648 |
|
|
671 |
} |
} |
672 |
HINTINFO; |
HINTINFO; |
673 |
|
|
674 |
|
/** Structure used to pass a frame to the encoder */ |
675 |
typedef struct |
typedef struct |
676 |
{ |
{ |
677 |
int general; /* [in] general options */ |
int general; /**< [in] |
678 |
int motion; /* [in] ME options */ |
* |
679 |
void *bitstream; /* [in] bitstream ptr */ |
* Sets general options flag (See \ref encgenflags_grp) */ |
680 |
int length; /* [out] bitstream length (bytes) */ |
int motion; /**< [in] |
681 |
|
* |
682 |
void *image; /* [in] image ptr */ |
* Sets Motion Estimation options */ |
683 |
int colorspace; /* [in] source colorspace */ |
void *bitstream; /**< [out] |
684 |
|
* |
685 |
unsigned char *quant_intra_matrix; // [in] custom intra qmatrix */ |
* Output MPEG4 bitstream buffer pointer */ |
686 |
unsigned char *quant_inter_matrix; // [in] custom inter qmatrix */ |
int length; /**< [out] |
687 |
int quant; /* [in] frame quantizer (vbr) */ |
* |
688 |
int intra; /* [in] force intra frame (vbr only) |
* Output MPEG4 bitstream length (bytes) */ |
689 |
* [out] intra state |
void *image; /**< [in] |
690 |
|
* |
691 |
|
* Input frame */ |
692 |
|
int colorspace; /**< [in] |
693 |
|
* |
694 |
|
* input frame colorspace */ |
695 |
|
unsigned char *quant_intra_matrix; /**< [in] |
696 |
|
* |
697 |
|
* Custom intra quantization matrix */ |
698 |
|
unsigned char *quant_inter_matrix; /**< [in] |
699 |
|
* |
700 |
|
* Custom inter quantization matrix */ |
701 |
|
int quant; /**< [in] |
702 |
|
* |
703 |
|
* Frame quantizer : |
704 |
|
* <ul> |
705 |
|
* <li> 0 (zero) : Then the rate controler chooses the right quantizer |
706 |
|
* for you. Typically used in ABR encoding, or first pass of a VBR |
707 |
|
* encoding session. |
708 |
|
* <li> != 0 : Then you force the encoder to use this specific |
709 |
|
* quantizer value. It is clamped in the interval |
710 |
|
* [1..31]. Tipically used during the 2nd pass of a VBR encoding |
711 |
|
* session. |
712 |
|
* </ul> */ |
713 |
|
int intra; /**< [in/out] |
714 |
|
* |
715 |
|
* <ul> |
716 |
|
* <li> [in] : tells XviD if the frame must be encoded as an intra frame |
717 |
|
* <ul> |
718 |
|
* <li> 1: forces the encoder to create a keyframe. Mainly used during |
719 |
|
* a VBR 2nd pass. |
720 |
|
* <li> 0: forces the encoder not to create a keyframe. Minaly used |
721 |
|
* during a VBR second pass |
722 |
|
* <li> -1: let the encoder decide (based on contents and |
723 |
|
* max_key_interval). Mainly used in ABR mode and during a 1st |
724 |
|
* VBR pass. |
725 |
|
* </ul> |
726 |
|
* <li> [out] : When first set to -1, the encoder returns the effective keyframe state |
727 |
|
* of the frame. |
728 |
|
* </ul> |
729 |
*/ |
*/ |
730 |
HINTINFO hint; /* [in/out] mv hint information */ |
HINTINFO hint; /**< [in/out] |
731 |
|
* |
732 |
#ifdef BFRAMES |
* mv hint information */ |
|
int bquant; /* [in] bframe quantizer */ |
|
|
#endif |
|
733 |
|
|
734 |
} |
} |
735 |
XVID_ENC_FRAME; |
XVID_ENC_FRAME; |
736 |
|
|
737 |
|
|
738 |
|
/** Encoding statistics */ |
739 |
typedef struct |
typedef struct |
740 |
{ |
{ |
741 |
int quant; /* [out] frame quantizer */ |
int quant; /**< [out] |
742 |
int hlength; /* [out] header length (bytes) */ |
* |
743 |
int kblks, mblks, ublks; /* [out] */ |
* Frame quantizer used during encoding */ |
744 |
|
int hlength; /**< [out] |
745 |
|
* |
746 |
|
* Header bytes in the resulting MPEG4 stream */ |
747 |
|
int kblks; /**< [out] |
748 |
|
* |
749 |
|
* Number of intra macro blocks */ |
750 |
|
int mblks; /**< [out] |
751 |
|
* |
752 |
|
* Number of inter macro blocks */ |
753 |
|
int ublks; /**< [out] |
754 |
|
* |
755 |
|
* Number of skipped macro blocks */ |
756 |
} |
} |
757 |
XVID_ENC_STATS; |
XVID_ENC_STATS; |
758 |
|
|
761 |
* Encoder entry point |
* Encoder entry point |
762 |
****************************************************************************/ |
****************************************************************************/ |
763 |
|
|
764 |
/* Encoder options */ |
/** |
765 |
#define XVID_ENC_ENCODE 0 |
* \defgroup encops_grp Encoder operations |
766 |
#define XVID_ENC_CREATE 1 |
* |
767 |
#define XVID_ENC_DESTROY 2 |
* These are all the operations XviD's encoder can perform. |
768 |
|
* |
769 |
|
* @{ |
770 |
|
*/ |
771 |
|
|
772 |
|
#define XVID_ENC_ENCODE 0 /**< Encodes a frame |
773 |
|
* |
774 |
|
* This operation constant is used when client application wants to encode a |
775 |
|
* frame. Client application must also fill XVID_ENC_FRAME appropriately. |
776 |
|
*/ |
777 |
|
|
778 |
|
#define XVID_ENC_CREATE 1 /**< Creates a decoder instance |
779 |
|
* |
780 |
|
* This operation constant is used by a client application in order to create |
781 |
|
* an encoder instance. Encoder instances are independant from each other. |
782 |
|
*/ |
783 |
|
|
784 |
|
#define XVID_ENC_DESTROY 2 /**< Destroys a encoder instance |
785 |
|
* |
786 |
|
* This operation constant is used by the client application to destroy a |
787 |
|
* previously created encoder instance. |
788 |
|
*/ |
789 |
|
|
790 |
|
|
791 |
|
/** @} */ |
792 |
|
|
793 |
|
/** |
794 |
|
* \defgroup encentry_grp Encoder entry point |
795 |
|
* |
796 |
|
* @{ |
797 |
|
*/ |
798 |
|
|
799 |
|
/** |
800 |
|
* \brief Encoder entry point. |
801 |
|
* |
802 |
|
* This is the XviD's encoder entry point. The possible operations are |
803 |
|
* described in the \ref encops_grp section. |
804 |
|
* |
805 |
|
* \param handle Encoder instance handle |
806 |
|
* \param opt Encoder option constant |
807 |
|
* \param param1 Used to pass XVID_ENC_PARAM or XVID_ENC_FRAME structures. |
808 |
|
* \param param2 Optionally used to pass the XVID_ENC_STATS structure. |
809 |
|
*/ |
810 |
int xvid_encore(void *handle, |
int xvid_encore(void *handle, |
811 |
int opt, |
int opt, |
812 |
void *param1, |
void *param1, |
813 |
void *param2); |
void *param2); |
814 |
|
|
815 |
|
/** @} */ |
816 |
|
|
817 |
|
/** @} */ |
818 |
|
|
819 |
#ifdef __cplusplus |
#ifdef __cplusplus |
820 |
} |
} |