[svn] / branches / Isibaar / xvidcore / src / xvid.h Repository:
ViewVC logotype

Annotation of /branches/Isibaar/xvidcore/src/xvid.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1004 - (view) (download)

1 : edgomez 199 /*****************************************************************************
2 : edgomez 868 *
3 :     * XVID MPEG-4 VIDEO CODEC
4 :     * - XviD Main header file -
5 :     *
6 :     * This file is part of XviD, a free MPEG-4 video encoder/decoder
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 1004 * $Id: xvid.h,v 1.28.2.1 2003-05-03 23:23:49 Isibaar Exp $
23 : edgomez 868 *
24 :     ****************************************************************************/
25 : edgomez 199
26 :     #ifndef _XVID_H_
27 :     #define _XVID_H_
28 :    
29 :     #ifdef __cplusplus
30 : chl 352 extern "C" {
31 : edgomez 199 #endif
32 :    
33 :     /*****************************************************************************
34 : edgomez 851 * Global constants
35 : edgomez 199 ****************************************************************************/
36 :    
37 : edgomez 851 /* API Version : 2.1 */
38 :     #define API_VERSION ((2 << 16) | (1))
39 :     #define XVID_API_UNSTABLE
40 : edgomez 199
41 : edgomez 851 /* Bitstream Version
42 :     * this will be writen into the bitstream to allow easy detection of xvid
43 :     * encoder bugs in the decoder, without this it might not possible to
44 :     * automatically distinquish between a file which has been encoded with an
45 :     * old & buggy XVID from a file which has been encoded with a bugfree version
46 :     * see the infamous interlacing bug ...
47 :     *
48 :     * this MUST be increased if an encoder bug is fixed, increasing it too often
49 :     * doesnt hurt but not increasing it could cause difficulty for decoders in the
50 :     * future
51 : edgomez 608 */
52 : edgomez 851 #define XVID_BS_VERSION "0009"
53 : edgomez 199
54 :    
55 : edgomez 851 /* Error codes */
56 : edgomez 868 #define XVID_ERR_FAIL -1
57 :     #define XVID_ERR_OK 0
58 :     #define XVID_ERR_MEMORY 1
59 :     #define XVID_ERR_FORMAT 2
60 : edgomez 199
61 :    
62 : edgomez 851 /* Colorspaces */
63 : edgomez 868 #define XVID_CSP_RGB24 0 /* [b|g|r] */
64 :     #define XVID_CSP_YV12 1
65 :     #define XVID_CSP_YUY2 2
66 :     #define XVID_CSP_UYVY 3
67 :     #define XVID_CSP_I420 4
68 :     #define XVID_CSP_RGB555 10
69 :     #define XVID_CSP_RGB565 11
70 :     #define XVID_CSP_USER 12
71 :     #define XVID_CSP_EXTERN 1004 /* per slice rendering */
72 : edgomez 851 #define XVID_CSP_YVYU 1002
73 : edgomez 868 #define XVID_CSP_RGB32 1000 /* [b|g|r|a] */
74 :     #define XVID_CSP_ABGR 1006 /* [a|b|g|r] */
75 :     #define XVID_CSP_RGBA 1005 /* [r|g|b|a] */
76 : edgomez 199
77 :    
78 : edgomez 608
79 : edgomez 868 #define XVID_CSP_NULL 9999
80 : edgomez 608
81 : edgomez 868 #define XVID_CSP_VFLIP 0x80000000 /* flip mask */
82 : edgomez 608
83 :    
84 : edgomez 199 /*****************************************************************************
85 : edgomez 851 * Initialization constants
86 : edgomez 199 ****************************************************************************/
87 :    
88 : edgomez 851 /* CPU flags for XVID_INIT_PARAM.cpu_flags */
89 : edgomez 868 #define XVID_CPU_FORCE 0x80000000 /* force passed cpu flags */
90 :     #define XVID_CPU_CHKONLY 0x40000000 /* check cpu only; dont init globals */
91 :     #define XVID_CPU_ASM 0x00000080 /* native assembly */
92 : edgomez 199
93 : edgomez 851 /* ARCH_IS_IA32 */
94 : edgomez 868 #define XVID_CPU_MMX 0x00000001 /* mmx : pentiumMMX,k6 */
95 :     #define XVID_CPU_MMXEXT 0x00000002 /* mmx-ext : pentium2, athlon */
96 :     #define XVID_CPU_SSE 0x00000004 /* sse : pentium3, athlonXP */
97 :     #define XVID_CPU_SSE2 0x00000008 /* sse2 : pentium4, athlon64 */
98 :     #define XVID_CPU_3DNOW 0x00000010 /* 3dnow : k6-2 */
99 :     #define XVID_CPU_3DNOWEXT 0x00000020 /* 3dnow-ext: athlon */
100 :     #define XVID_CPU_TSC 0x00000040 /* timestamp counter */
101 :    
102 : edgomez 851 /* ARCH_IS_IA64 */
103 : edgomez 868 #define XVID_CPU_IA64 XVID_CPU_ASM /* defined for backward compatibility */
104 :    
105 : edgomez 851 /* ARCH_IS_PPC */
106 : edgomez 868 #define XVID_CPU_ALTIVEC 0x00000001 /* altivec */
107 : edgomez 199
108 : Isibaar 209
109 : edgomez 851 typedef struct
110 :     {
111 :     int colorspace;
112 :     void * y;
113 :     void * u;
114 :     void * v;
115 :     int y_stride;
116 :     int uv_stride;
117 : edgomez 868 } XVID_IMAGE; /* from yv12 */
118 : edgomez 199
119 : edgomez 868 #define XVID_INIT_INIT 0
120 :     #define XVID_INIT_CONVERT 1
121 :     #define XVID_INIT_TEST 2
122 : edgomez 199
123 : Isibaar 209 /*****************************************************************************
124 : edgomez 199 * Initialization structures
125 : Isibaar 209 ****************************************************************************/
126 :    
127 :     typedef struct
128 : suxen_drol 234 {
129 : edgomez 851 int cpu_flags;
130 :     int api_version;
131 :     int core_build;
132 : edgomez 868 } XVID_INIT_PARAM;
133 : edgomez 199
134 : edgomez 851 typedef struct
135 :     {
136 :     XVID_IMAGE input;
137 :     XVID_IMAGE output;
138 :     int width;
139 :     int height;
140 :     int interlacing;
141 :     } XVID_INIT_CONVERTINFO;
142 :    
143 : edgomez 199 /*****************************************************************************
144 :     * Initialization entry point
145 :     ****************************************************************************/
146 :    
147 :     int xvid_init(void *handle,
148 : edgomez 851 int opt,
149 :     void *param1,
150 :     void *param2);
151 : edgomez 199
152 :    
153 :     /*****************************************************************************
154 : edgomez 851 * Decoder constants
155 : edgomez 199 ****************************************************************************/
156 :    
157 : edgomez 851 /* Flags for XVID_DEC_FRAME.general */
158 : edgomez 868 #define XVID_DEC_LOWDELAY 0x00000001 /* decode lowdelay mode (ie. VFW) */
159 :     #define XVID_DEC_DEBLOCKY 0x00000002 /* luma deblocking */
160 :     #define XVID_DEC_DEBLOCKUV 0x00000008 /* chroma deblocking */
161 : Isibaar 1004 #define XVID_DEC_DERING 0x00000012 /* deringing */
162 : edgomez 868 #define XVID_DEC_DISCONTINUITY 0x00000004 /* indicates break in stream
163 :     instructs decoder to ignore any
164 :     previous reference frames */
165 :     #define XVID_QUICK_DECODE 0x00000010
166 : edgomez 199
167 :     /*****************************************************************************
168 :     * Decoder structures
169 :     ****************************************************************************/
170 :    
171 :     typedef struct
172 :     {
173 :     int width;
174 :     int height;
175 :     void *handle;
176 : edgomez 868 } XVID_DEC_PARAM;
177 : edgomez 199
178 :    
179 : edgomez 868 #define XVID_DEC_VOP 0
180 :     #define XVID_DEC_VOL 1
181 :     #define XVID_DEC_NOTHING 2 /* nothing was decoded */
182 : edgomez 851
183 : edgomez 199 typedef struct
184 :     {
185 : edgomez 868 int notify; /* [out] output 'mode' */
186 : edgomez 851 union
187 :     {
188 : edgomez 868 struct /* XVID_DEC_VOP */
189 : edgomez 851 {
190 : edgomez 868 int time_base; /* [out] time base */
191 :     int time_increment; /* [out] time increment */
192 : edgomez 851 } vop;
193 : edgomez 868 struct /* XVID_DEC_VOL */
194 : edgomez 851 {
195 : edgomez 868 int general; /* [out] flags: eg. frames are interlaced */
196 :     int width; /* [out] width */
197 :     int height; /* [out] height */
198 :     int aspect_ratio; /* [out] aspect ratio */
199 :     int par_width; /* [out] aspect ratio width */
200 :     int par_height; /* [out] aspect ratio height */
201 : edgomez 851 } vol;
202 :     } data;
203 :     } XVID_DEC_STATS;
204 :    
205 :    
206 :     typedef struct
207 :     {
208 : edgomez 199 int general;
209 :     void *bitstream;
210 :     int length;
211 :    
212 :     void *image;
213 :     int stride;
214 :     int colorspace;
215 : edgomez 868 } XVID_DEC_FRAME;
216 : edgomez 199
217 :    
218 : edgomez 868 /* This struct is used for per slice rendering */
219 : edgomez 199 typedef struct
220 :     {
221 :     void *y,*u,*v;
222 :     int stride_y, stride_u,stride_v;
223 :     } XVID_DEC_PICTURE;
224 :    
225 : albeu 315
226 :     /*****************************************************************************
227 :     * Decoder entry point
228 :     ****************************************************************************/
229 :    
230 : edgomez 851 /* decoder options */
231 : edgomez 868 #define XVID_DEC_DECODE 0
232 :     #define XVID_DEC_CREATE 1
233 :     #define XVID_DEC_DESTROY 2
234 : edgomez 199
235 : edgomez 851 int xvid_decore(void *handle,
236 :     int opt,
237 :     void *param1,
238 :     void *param2);
239 : edgomez 199
240 :    
241 : edgomez 851 /*****************************************************************************
242 :     * Encoder constants
243 :     ****************************************************************************/
244 : edgomez 199
245 : edgomez 851 /* Flags for XVID_ENC_PARAM.global */
246 : edgomez 868 #define XVID_GLOBAL_PACKED 0x00000001 /* packed bitstream */
247 :     #define XVID_GLOBAL_DX50BVOP 0x00000002 /* dx50 bvop compatibility */
248 :     #define XVID_GLOBAL_DEBUG 0x00000004 /* print debug info on each frame */
249 :     #define XVID_GLOBAL_REDUCED 0x04000000 /* reduced resolution vop enable */
250 : edgomez 199
251 : edgomez 868 #define XVID_GLOBAL_EXTRASTATS 0x00000200 /* generate extra statistics */
252 : edgomez 199
253 :    
254 : edgomez 851 /* Flags for XVID_ENC_FRAME.general */
255 : edgomez 868 #define XVID_VALID_FLAGS 0x80000000
256 : edgomez 199
257 : edgomez 868 #define XVID_CUSTOM_QMATRIX 0x00000004 /* use custom quant matrix */
258 : Isibaar 1004 #define XVID_CARTOON_MODE 0x00000008 /* use cartoon mode */
259 : edgomez 868 #define XVID_H263QUANT 0x00000010
260 :     #define XVID_MPEGQUANT 0x00000020
261 :     #define XVID_HALFPEL 0x00000040 /* use halfpel interpolation */
262 :     #define XVID_QUARTERPEL 0x02000000
263 :     #define XVID_ADAPTIVEQUANT 0x00000080
264 :     #define XVID_LUMIMASKING 0x00000100
265 : edgomez 199
266 : edgomez 868 #define XVID_INTERLACING 0x00000400 /* enable interlaced encoding */
267 :     #define XVID_TOPFIELDFIRST 0x00000800 /* set top-field-first flag */
268 :     #define XVID_ALTERNATESCAN 0x00001000 /* set alternate vertical scan flag */
269 : edgomez 199
270 : edgomez 868 #define XVID_HINTEDME_GET 0x00002000 /* receive mv hint data from core (1st pass) */
271 :     #define XVID_HINTEDME_SET 0x00004000 /* send mv hint data to core (2nd pass) */
272 : edgomez 199
273 : edgomez 868 #define XVID_INTER4V 0x00008000
274 : edgomez 199
275 : edgomez 868 #define XVID_ME_ZERO 0x00010000
276 :     #define XVID_ME_LOGARITHMIC 0x00020000
277 :     #define XVID_ME_FULLSEARCH 0x00040000
278 :     #define XVID_ME_PMVFAST 0x00080000
279 :     #define XVID_ME_EPZS 0x00100000
280 : edgomez 199
281 : edgomez 868 #define XVID_CHROMAOPT 0x00200000 /* enable chroma optimization pre-filter */
282 : edgomez 853
283 : edgomez 868 #define XVID_GREYSCALE 0x01000000 /* enable greyscale only mode (even for
284 :     color input material chroma is ignored) */
285 : edgomez 199
286 : edgomez 868 #define XVID_GMC 0x10000000
287 :     #define XVID_GMC_TRANSLATIONAL 0x20000000
288 : chl 352
289 : edgomez 868 #define XVID_REDUCED 0x04000000 /* reduced resolution vop */
290 :     #define XVID_HQACPRED 0x08000000 /* 20030209: high quality ac prediction */
291 : edgomez 199
292 : edgomez 868 #define XVID_EXTRASTATS 0x00000200 /* generate extra statistics */
293 : edgomez 199
294 : edgomez 868 #define XVID_MODEDECISION_BITS 0x00400000 /* enable DCT-ME and use it for mode decision */
295 : edgomez 199
296 : edgomez 608
297 : edgomez 851 /* Flags for XVID_ENC_FRAME.motion */
298 : edgomez 868 #define PMV_ADVANCEDDIAMOND16 0x00008000 /* use advdiamonds instead of diamonds as search pattern */
299 :     #define PMV_USESQUARES16 0x00800000 /* use squares instead of diamonds as search pattern */
300 : edgomez 851
301 : edgomez 868 #define PMV_HALFPELREFINE16 0x00020000
302 :     #define PMV_HALFPELREFINE8 0x02000000
303 : edgomez 851
304 : edgomez 868 #define PMV_QUARTERPELREFINE16 0x00040000
305 :     #define PMV_QUARTERPELREFINE8 0x04000000
306 : edgomez 851
307 : edgomez 868 #define PMV_EXTSEARCH16 0x00080000 /* extend PMV by more searches */
308 : edgomez 851
309 : edgomez 868 #define PMV_EXTSEARCH8 0x08000000 /* use diamond/square for extended 8x8 search */
310 :     #define PMV_ADVANCEDDIAMOND8 0x00004000 /* use advdiamond for PMV_EXTSEARCH8 */
311 :     #define PMV_USESQUARES8 0x80000000 /* use square for PMV_EXTSEARCH8 */
312 : edgomez 851
313 : edgomez 868 #define PMV_CHROMA16 0x00100000 /* also use chroma for P_VOP/S_VOP ME */
314 :     #define PMV_CHROMA8 0x10000000 /* also use chroma for B_VOP ME */
315 : edgomez 851
316 : edgomez 868 /* Motion search using DCT. use XVID_MODEDECISION_BITS to enable */
317 :     #define HALFPELREFINE16_BITS 0x00000100 /* perform DCT-based halfpel refinement */
318 :     #define HALFPELREFINE8_BITS 0x00000200 /* perform DCT-based halfpel refinement for 8x8 mode */
319 :     #define QUARTERPELREFINE16_BITS 0x00000400 /* perform DCT-based qpel refinement */
320 :     #define QUARTERPELREFINE8_BITS 0x00000800 /* perform DCT-based qpel refinement for 8x8 mode */
321 : edgomez 851
322 : edgomez 868 #define EXTSEARCH_BITS 0x00001000 /* perform DCT-based search using square pattern
323 :     enable PMV_EXTSEARCH8 to do this in 8x8 search as well */
324 :     #define CHECKPREDICTION_BITS 0x00002000 /* always check vector equal to prediction */
325 : edgomez 851
326 :    
327 :     /* note: old and deprecated - or never implemented */
328 :    
329 :     /* only for compatability with old encoders */
330 :    
331 : edgomez 868 #define PMV_EARLYSTOP16 0x00
332 :     #define PMV_EARLYSTOP8 0x00
333 :     #define PMV_QUICKSTOP16 0x00
334 :     #define PMV_QUICKSTOP8 0x00
335 : edgomez 851
336 : edgomez 868 #define PMV_HALFPELDIAMOND16 0x00
337 :     #define PMV_HALFPELDIAMOND8 0x00
338 : edgomez 851
339 : edgomez 868 #define PMV_UNRESTRICTED16 0x00200000 /* unrestricted ME, not implemented */
340 :     #define PMV_OVERLAPPING16 0x00400000 /* overlapping ME, not implemented */
341 :     #define PMV_UNRESTRICTED8 0x20000000 /* unrestricted ME, not implemented */
342 :     #define PMV_OVERLAPPING8 0x40000000 /* overlapping ME, not implemented */
343 : edgomez 851
344 : edgomez 868 #define XVID_ME_COLOUR 0x00 /* this has been converted to PMV_CHROMA[16/8] */
345 : edgomez 851
346 :    
347 : edgomez 199 /*****************************************************************************
348 :     * Encoder structures
349 :     ****************************************************************************/
350 :    
351 :     typedef struct
352 :     {
353 : edgomez 851 int width, height;
354 : edgomez 868 int fincr, fbase; /* [in] frame increment, fbase. each frame = "fincr/fbase" seconds */
355 :     int rc_bitrate; /* [in] the bitrate of the target encoded stream, in bits/second */
356 :     int rc_reaction_delay_factor; /* [in] how fast the rate control reacts - lower values are faster */
357 :     int rc_averaging_period; /* [in] as above */
358 :     int rc_buffer; /* [in] as above */
359 :     int max_quantizer; /* [in] the upper limit of the quantizer */
360 :     int min_quantizer; /* [in] the lower limit of the quantizer */
361 :     int max_key_interval; /* [in] the maximum interval between key frames */
362 : edgomez 851 #ifdef _SMP
363 : edgomez 868 int num_threads; /* [in] number of threads */
364 : edgomez 851 #endif
365 : edgomez 868 int global; /* [in] global/debug options */
366 :     int max_bframes; /* [in] max sequential bframes (0=disable bframes) */
367 :     int bquant_ratio; /* [in] bframe quantizer multipier (percentage).
368 :     used only when bquant < 1
369 :     eg. 200 = x2 multiplier
370 :     quant = ((past_quant + future_quant) * bquant_ratio)/200
371 :     */
372 :     int bquant_offset; /* [in] bquant += bquant_offset */
373 :     int frame_drop_ratio; /* [in] frame dropping: 0=drop none... 100=drop all */
374 :     void *handle; /* [out] encoder instance handle */
375 :     } XVID_ENC_PARAM;
376 : edgomez 199
377 :     typedef struct
378 :     {
379 :     int x;
380 : suxen_drol 324 int y;
381 : edgomez 868 } VECTOR;
382 : edgomez 199
383 :     typedef struct
384 :     {
385 : edgomez 868 int mode; /* macroblock mode */
386 : edgomez 199 VECTOR mvs[4];
387 : edgomez 868 } MVBLOCKHINT;
388 : edgomez 199
389 :     typedef struct
390 :     {
391 : edgomez 868 int intra; /* frame intra choice */
392 :     int fcode; /* frame fcode */
393 :     MVBLOCKHINT *block; /* caller-allocated array of block hints (mb_width * mb_height) */
394 :     } MVFRAMEHINT;
395 : edgomez 199
396 :     typedef struct
397 :     {
398 : edgomez 868 int rawhints; /* if set, use MVFRAMEHINT, else use compressed buffer */
399 : edgomez 199
400 :     MVFRAMEHINT mvhint;
401 : edgomez 868 void *hintstream; /* compressed hint buffer */
402 :     int hintlength; /* length of buffer (bytes) */
403 :     } HINTINFO;
404 : edgomez 199
405 :     typedef struct
406 :     {
407 : edgomez 868 int general; /* [in] general options */
408 :     int motion; /* [in] ME options */
409 :     void *bitstream; /* [in] bitstream ptr */
410 :     int length; /* [out] bitstream length (bytes) */
411 : edgomez 199
412 : edgomez 868 void *image; /* [in] image ptr */
413 :     int stride; /* [in] horizontal stride in bytes */
414 :     int colorspace; /* [in] source colorspace */
415 : edgomez 851
416 : edgomez 868 unsigned char *quant_intra_matrix; /* [in] custom intra qmatrix */
417 :     unsigned char *quant_inter_matrix; /* [in] custom inter qmatrix */
418 :     int quant; /* [in] frame quantizer (vbr) */
419 :     int intra; /* [in] force intra frame (vbr only)
420 :     [out] frame type (ugly atm)
421 :     */
422 :     HINTINFO hint; /* [in/out] mv hint information */
423 : edgomez 851
424 : edgomez 868 int bquant; /* [in] bframe quantizer */
425 : syskin 903 int bframe_threshold; /* [in] sensitivity of B-frame decision */
426 : edgomez 851
427 : edgomez 868 } XVID_ENC_FRAME;
428 : edgomez 199
429 :    
430 :     typedef struct
431 :     {
432 : edgomez 868 int quant; /* [out] frame quantizer */
433 :     int hlength; /* [out] header length (bytes) */
434 :     int kblks; /* [out] number of intra blocks */
435 :     int mblks; /* [out] number of inter blocks */
436 :     int ublks; /* [out] number of "not coded" blocks */
437 :     long sse_y; /* [out] SSE of Y */
438 :     long sse_u; /* [out] SSE of Cb */
439 :     long sse_v; /* [out] SSE of Cr */
440 : Isibaar 1004 int iblks;
441 :     int qblks;
442 : edgomez 868 } XVID_ENC_STATS;
443 : edgomez 199
444 :    
445 :     /*****************************************************************************
446 :     * Encoder entry point
447 :     ****************************************************************************/
448 :    
449 : edgomez 851 /* Encoder options */
450 : edgomez 868 #define XVID_ENC_ENCODE 0
451 :     #define XVID_ENC_CREATE 1
452 :     #define XVID_ENC_DESTROY 2
453 : edgomez 199
454 :     int xvid_encore(void *handle,
455 :     int opt,
456 :     void *param1,
457 :     void *param2);
458 :    
459 :    
460 :     #ifdef __cplusplus
461 :     }
462 :     #endif
463 :    
464 :     #endif

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