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