1 |
/***************************************************************************** |
/***************************************************************************** |
2 |
* |
* |
3 |
* XVID MPEG-4 VIDEO CODEC |
* XVID MPEG-4 VIDEO CODEC |
4 |
* - XviD Main header file - |
* - Xvid Main header file - |
5 |
* |
* |
6 |
* Copyright(C) 2001-2004 Peter Ross <pross@xvid.org> |
* Copyright(C) 2001-2011 Peter Ross <pross@xvid.org> |
7 |
* |
* |
8 |
* This program is free software ; you can redistribute it and/or modify |
* 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 |
* it under the terms of the GNU General Public License as published by |
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 |
* $Id: xvid.h,v 1.36 2004-04-15 12:05:19 suxen_drol Exp $ |
* $Id$ |
23 |
* |
* |
24 |
****************************************************************************/ |
****************************************************************************/ |
25 |
|
|
26 |
#ifndef _XVID_H_ |
#ifndef _XVID_H_ |
27 |
#define _XVID_H_ |
#define _XVID_H_ |
28 |
|
|
|
|
|
29 |
#ifdef __cplusplus |
#ifdef __cplusplus |
30 |
extern "C" { |
extern "C" { |
31 |
#endif |
#endif |
32 |
|
|
33 |
/***************************************************************************** |
/***************************************************************************** |
34 |
|
* function export defines |
35 |
|
****************************************************************************/ |
36 |
|
|
37 |
|
#ifndef XVID_IMPEXP |
38 |
|
#define XVID_IMPEXP extern |
39 |
|
#endif |
40 |
|
|
41 |
|
#ifndef XVID_CALL |
42 |
|
#define XVID_CALL |
43 |
|
#endif |
44 |
|
|
45 |
|
/***************************************************************************** |
46 |
* versioning |
* versioning |
47 |
****************************************************************************/ |
****************************************************************************/ |
48 |
|
|
68 |
#define XVID_API_MAJOR(a) (((a)>>16) & 0xff) |
#define XVID_API_MAJOR(a) (((a)>>16) & 0xff) |
69 |
#define XVID_API_MINOR(a) (((a)>> 0) & 0xff) |
#define XVID_API_MINOR(a) (((a)>> 0) & 0xff) |
70 |
|
|
71 |
#define XVID_VERSION XVID_MAKE_VERSION(1,1,-127) |
#define XVID_VERSION XVID_MAKE_VERSION(1,4,-127) |
72 |
#define XVID_API XVID_MAKE_API(4, 0) |
#define XVID_API XVID_MAKE_API(4, 4) |
73 |
|
|
74 |
#define XVID_UNSTABLE |
#define XVID_UNSTABLE |
75 |
|
|
84 |
* doesnt hurt but not increasing it could cause difficulty for decoders in the |
* doesnt hurt but not increasing it could cause difficulty for decoders in the |
85 |
* future |
* future |
86 |
*/ |
*/ |
87 |
#define XVID_BS_VERSION "0030" |
#define XVID_BS_VERSION 73 |
|
|
|
88 |
|
|
89 |
/***************************************************************************** |
/***************************************************************************** |
90 |
* error codes |
* error codes |
113 |
#define XVID_CSP_YUY2 (1<< 3) /* 4:2:2 packed */ |
#define XVID_CSP_YUY2 (1<< 3) /* 4:2:2 packed */ |
114 |
#define XVID_CSP_UYVY (1<< 4) /* 4:2:2 packed */ |
#define XVID_CSP_UYVY (1<< 4) /* 4:2:2 packed */ |
115 |
#define XVID_CSP_YVYU (1<< 5) /* 4:2:2 packed */ |
#define XVID_CSP_YVYU (1<< 5) /* 4:2:2 packed */ |
116 |
|
#define XVID_CSP_RGB (1<<16) /* 24-bit rgb packed */ |
117 |
#define XVID_CSP_BGRA (1<< 6) /* 32-bit bgra packed */ |
#define XVID_CSP_BGRA (1<< 6) /* 32-bit bgra packed */ |
118 |
#define XVID_CSP_ABGR (1<< 7) /* 32-bit abgr packed */ |
#define XVID_CSP_ABGR (1<< 7) /* 32-bit abgr packed */ |
119 |
#define XVID_CSP_RGBA (1<< 8) /* 32-bit rgba packed */ |
#define XVID_CSP_RGBA (1<< 8) /* 32-bit rgba packed */ |
140 |
#define XVID_PROFILE_S_L1 0x01 |
#define XVID_PROFILE_S_L1 0x01 |
141 |
#define XVID_PROFILE_S_L2 0x02 |
#define XVID_PROFILE_S_L2 0x02 |
142 |
#define XVID_PROFILE_S_L3 0x03 |
#define XVID_PROFILE_S_L3 0x03 |
143 |
|
#define XVID_PROFILE_S_L4a 0x04 |
144 |
|
#define XVID_PROFILE_S_L5 0x05 |
145 |
|
#define XVID_PROFILE_S_L6 0x06 |
146 |
#define XVID_PROFILE_ARTS_L1 0x91 /* advanced realtime simple */ |
#define XVID_PROFILE_ARTS_L1 0x91 /* advanced realtime simple */ |
147 |
#define XVID_PROFILE_ARTS_L2 0x92 |
#define XVID_PROFILE_ARTS_L2 0x92 |
148 |
#define XVID_PROFILE_ARTS_L3 0x93 |
#define XVID_PROFILE_ARTS_L3 0x93 |
184 |
#define XVID_CPU_MMXEXT (1<< 1) /* mmx-ext : pentium2, athlon */ |
#define XVID_CPU_MMXEXT (1<< 1) /* mmx-ext : pentium2, athlon */ |
185 |
#define XVID_CPU_SSE (1<< 2) /* sse : pentium3, athlonXP */ |
#define XVID_CPU_SSE (1<< 2) /* sse : pentium3, athlonXP */ |
186 |
#define XVID_CPU_SSE2 (1<< 3) /* sse2 : pentium4, athlon64 */ |
#define XVID_CPU_SSE2 (1<< 3) /* sse2 : pentium4, athlon64 */ |
187 |
|
#define XVID_CPU_SSE3 (1<< 8) /* sse3 : pentium4, athlon64 */ |
188 |
|
#define XVID_CPU_SSE41 (1<< 9) /* sse41: penryn */ |
189 |
#define XVID_CPU_3DNOW (1<< 4) /* 3dnow : k6-2 */ |
#define XVID_CPU_3DNOW (1<< 4) /* 3dnow : k6-2 */ |
190 |
#define XVID_CPU_3DNOWEXT (1<< 5) /* 3dnow-ext : athlon */ |
#define XVID_CPU_3DNOWEXT (1<< 5) /* 3dnow-ext : athlon */ |
191 |
#define XVID_CPU_TSC (1<< 6) /* tsc : Pentium */ |
#define XVID_CPU_TSC (1<< 6) /* tsc : Pentium */ |
236 |
#define XVID_GBL_INFO 1 /* return some info about xvidcore, and the host computer */ |
#define XVID_GBL_INFO 1 /* return some info about xvidcore, and the host computer */ |
237 |
#define XVID_GBL_CONVERT 2 /* colorspace conversion utility */ |
#define XVID_GBL_CONVERT 2 /* colorspace conversion utility */ |
238 |
|
|
239 |
extern int xvid_global(void *handle, int opt, void *param1, void *param2); |
XVID_IMPEXP int XVID_CALL xvid_global(void *handle, int opt, void *param1, void *param2); |
240 |
|
|
241 |
|
|
242 |
/***************************************************************************** |
/***************************************************************************** |
247 |
#define XVID_DEC_DESTROY 1 /* destroy decore instance: return 0 on success */ |
#define XVID_DEC_DESTROY 1 /* destroy decore instance: return 0 on success */ |
248 |
#define XVID_DEC_DECODE 2 /* decode a frame: returns number of bytes consumed >= 0 */ |
#define XVID_DEC_DECODE 2 /* decode a frame: returns number of bytes consumed >= 0 */ |
249 |
|
|
250 |
extern int xvid_decore(void *handle, int opt, void *param1, void *param2); |
XVID_IMPEXP int XVID_CALL xvid_decore(void *handle, int opt, void *param1, void *param2); |
251 |
|
|
252 |
/* XVID_DEC_CREATE param 1 |
/* XVID_DEC_CREATE param 1 |
253 |
image width & height may be specified here when the dimensions are |
image width & height as well as FourCC code may be specified |
254 |
known in advance. */ |
here when known in advance (e.g. being read from container) */ |
255 |
typedef struct { |
typedef struct { |
256 |
int version; |
int version; |
257 |
int width; /* [in:opt] image width */ |
int width; /* [in:opt] image width */ |
258 |
int height; /* [in:opt] image width */ |
int height; /* [in:opt] image width */ |
259 |
void * handle; /* [out] decore context handle */ |
void * handle; /* [out] decore context handle */ |
260 |
|
/* ------- v1.3.x ------- */ |
261 |
|
int fourcc; /* [in:opt] fourcc of the input video */ |
262 |
|
int num_threads;/* [in:opt] number of threads to use in decoder */ |
263 |
} xvid_dec_create_t; |
} xvid_dec_create_t; |
264 |
|
|
265 |
|
|
270 |
#define XVID_DEBLOCKY (1<<2) /* perform luma deblocking */ |
#define XVID_DEBLOCKY (1<<2) /* perform luma deblocking */ |
271 |
#define XVID_DEBLOCKUV (1<<3) /* perform chroma deblocking */ |
#define XVID_DEBLOCKUV (1<<3) /* perform chroma deblocking */ |
272 |
#define XVID_FILMEFFECT (1<<4) /* adds film grain */ |
#define XVID_FILMEFFECT (1<<4) /* adds film grain */ |
273 |
|
#define XVID_DERINGUV (1<<5) /* perform chroma deringing, requires deblocking to work */ |
274 |
|
#define XVID_DERINGY (1<<6) /* perform luma deringing, requires deblocking to work */ |
275 |
|
|
276 |
|
#define XVID_DEC_FAST (1<<29) /* disable postprocessing to decrease cpu usage *todo* */ |
277 |
|
#define XVID_DEC_DROP (1<<30) /* drop bframes to decrease cpu usage *todo* */ |
278 |
|
#define XVID_DEC_PREROLL (1<<31) /* decode as fast as you can, don't even show output *todo* */ |
279 |
|
|
280 |
typedef struct { |
typedef struct { |
281 |
int version; |
int version; |
283 |
void *bitstream; /* [in] bitstream (read from)*/ |
void *bitstream; /* [in] bitstream (read from)*/ |
284 |
int length; /* [in] bitstream length */ |
int length; /* [in] bitstream length */ |
285 |
xvid_image_t output; /* [in] output image (written to) */ |
xvid_image_t output; /* [in] output image (written to) */ |
286 |
/* ------- v1.1.0 ------- */ |
/* ------- v1.1.x ------- */ |
287 |
int brightness; /* [in] brightness offset (0=none) */ |
int brightness; /* [in] brightness offset (0=none) */ |
288 |
} xvid_dec_frame_t; |
} xvid_dec_frame_t; |
289 |
|
|
381 |
#define XVID_REQORIGINAL (1<<0) /* plugin requires a copy of the original (uncompressed) image */ |
#define XVID_REQORIGINAL (1<<0) /* plugin requires a copy of the original (uncompressed) image */ |
382 |
#define XVID_REQPSNR (1<<1) /* plugin requires psnr between the uncompressed and compressed image*/ |
#define XVID_REQPSNR (1<<1) /* plugin requires psnr between the uncompressed and compressed image*/ |
383 |
#define XVID_REQDQUANTS (1<<2) /* plugin requires access to the dquant table */ |
#define XVID_REQDQUANTS (1<<2) /* plugin requires access to the dquant table */ |
384 |
|
#define XVID_REQLAMBDA (1<<3) /* plugin requires access to the lambda table */ |
385 |
|
|
386 |
typedef struct |
typedef struct |
387 |
{ |
{ |
446 |
int vol_flags; /* [in,out] */ |
int vol_flags; /* [in,out] */ |
447 |
int motion_flags; /* [in,out] */ |
int motion_flags; /* [in,out] */ |
448 |
|
|
449 |
|
/* Lambda table for HVSPlugins */ |
450 |
|
float * lambda; /* [in,out] six floats for each macroblock. read, multiply, write back */ |
451 |
|
|
452 |
/* Deprecated, use the stats field instead. |
/* Deprecated, use the stats field instead. |
453 |
* Will disapear before 1.0 */ |
* Will disapear before 1.0 */ |
454 |
int length; /* [out] after: length of encoded frame */ |
int length; /* [out] after: length of encoded frame */ |
486 |
|
|
487 |
****************************************************************************/ |
****************************************************************************/ |
488 |
|
|
489 |
typedef int (xvid_plugin_func)(void * handle, int opt, void * param1, void * param2); |
typedef int (XVID_CALL xvid_plugin_func)(void * handle, int opt, void * param1, void * param2); |
490 |
|
|
491 |
typedef struct |
typedef struct |
492 |
{ |
{ |
494 |
void * param; |
void * param; |
495 |
} xvid_enc_plugin_t; |
} xvid_enc_plugin_t; |
496 |
|
|
497 |
|
XVID_IMPEXP xvid_plugin_func xvid_plugin_single; /* single-pass rate control */ |
498 |
|
XVID_IMPEXP xvid_plugin_func xvid_plugin_2pass1; /* two-pass rate control: first pass */ |
499 |
|
XVID_IMPEXP xvid_plugin_func xvid_plugin_2pass2; /* two-pass rate control: second pass */ |
500 |
|
|
501 |
extern xvid_plugin_func xvid_plugin_single; /* single-pass rate control */ |
XVID_IMPEXP xvid_plugin_func xvid_plugin_lumimasking; /* lumimasking */ |
|
extern xvid_plugin_func xvid_plugin_2pass1; /* two-pass rate control: first pass */ |
|
|
extern xvid_plugin_func xvid_plugin_2pass2; /* two-pass rate control: second pass */ |
|
502 |
|
|
503 |
extern xvid_plugin_func xvid_plugin_lumimasking; /* lumimasking */ |
XVID_IMPEXP xvid_plugin_func xvid_plugin_psnr; /* write psnr values to stdout */ |
504 |
|
XVID_IMPEXP xvid_plugin_func xvid_plugin_dump; /* dump before and after yuvpgms */ |
505 |
|
|
506 |
extern xvid_plugin_func xvid_plugin_psnr; /* write psnr values to stdout */ |
XVID_IMPEXP xvid_plugin_func xvid_plugin_ssim; /*write ssim values to stdout*/ |
507 |
extern xvid_plugin_func xvid_plugin_dump; /* dump before and after yuvpgms */ |
XVID_IMPEXP xvid_plugin_func xvid_plugin_psnrhvsm; /*write psnrhvsm values to stdout*/ |
508 |
|
|
509 |
|
|
510 |
/* single pass rate control |
/* single pass rate control |
533 |
typedef struct { |
typedef struct { |
534 |
int version; |
int version; |
535 |
|
|
536 |
int bitrate; /* [in] bits per second */ |
int bitrate; /* [in] target bitrate (bits per second) */ |
537 |
char * filename; /* [in] first pass stats filename */ |
char * filename; /* [in] first pass stats filename */ |
538 |
|
|
539 |
int keyframe_boost; /* [in] keyframe boost percentage: [0..100] */ |
int keyframe_boost; /* [in] keyframe boost percentage: [0..100] */ |
550 |
* 0 for 1<distance<kfthreshold */ |
* 0 for 1<distance<kfthreshold */ |
551 |
|
|
552 |
int container_frame_overhead; /* [in] How many bytes the controller has to compensate per frame due to container format overhead */ |
int container_frame_overhead; /* [in] How many bytes the controller has to compensate per frame due to container format overhead */ |
553 |
|
|
554 |
|
/* ------- v1.1.x ------- */ |
555 |
|
int vbv_size; /* [in] buffer size (bits) If this is zero, VBV check is disabled.*/ |
556 |
|
int vbv_initial; /* [in] initial buffer occupancy (bits) */ |
557 |
|
int vbv_maxrate; /* [in] max processing bitrate (bits per second) */ |
558 |
|
int vbv_peakrate; /* [in:opt] max average bitrate over 1 second (bits per second). |
559 |
|
* This is used for diagnostics only and won't affect the actual peak bitrate. |
560 |
|
* This is not a problem as long as vbv_peakrate > vbv_size + vbv_maxrate which |
561 |
|
* guarantees that vbv_peakrate won't be exceeded. */ |
562 |
}xvid_plugin_2pass2_t; |
}xvid_plugin_2pass2_t; |
563 |
|
|
564 |
|
|
565 |
|
typedef struct{ |
566 |
|
/*stat output*/ |
567 |
|
int b_printstat; |
568 |
|
char* stat_path; |
569 |
|
|
570 |
|
/*visualize*/ |
571 |
|
int b_visualize; |
572 |
|
|
573 |
|
/*accuracy 0 very accurate 4 very fast*/ |
574 |
|
int acc; |
575 |
|
|
576 |
|
int cpu_flags; /* XVID_CPU_XXX flags */ |
577 |
|
|
578 |
|
} xvid_plugin_ssim_t; |
579 |
|
|
580 |
|
typedef struct { |
581 |
|
int version; |
582 |
|
|
583 |
|
int method; /* [in] masking method to apply. 0 for luminance masking, 1 for variance masking */ |
584 |
|
} xvid_plugin_lumimasking_t; |
585 |
|
|
586 |
/***************************************************************************** |
/***************************************************************************** |
587 |
* ENCODER API |
* ENCODER API |
588 |
****************************************************************************/ |
****************************************************************************/ |
601 |
* Encoder entry point |
* Encoder entry point |
602 |
*--------------------------------------------------------------------------*/ |
*--------------------------------------------------------------------------*/ |
603 |
|
|
604 |
extern int xvid_encore(void *handle, int opt, void *param1, void *param2); |
XVID_IMPEXP int XVID_CALL xvid_encore(void *handle, int opt, void *param1, void *param2); |
605 |
|
|
606 |
/* Quick API reference |
/* Quick API reference |
607 |
* |
* |
642 |
#define XVID_GLOBAL_VOL_AT_IVOP (1<<3) /* write vol at every ivop: WIN32/divx compatibility */ |
#define XVID_GLOBAL_VOL_AT_IVOP (1<<3) /* write vol at every ivop: WIN32/divx compatibility */ |
643 |
#define XVID_GLOBAL_FORCE_VOL (1<<4) /* when vol-based parameters are changed, insert an ivop NOT recommended */ |
#define XVID_GLOBAL_FORCE_VOL (1<<4) /* when vol-based parameters are changed, insert an ivop NOT recommended */ |
644 |
#endif |
#endif |
645 |
|
#define XVID_GLOBAL_DIVX5_USERDATA (1<<5) /* write divx5 userdata string |
646 |
|
this is implied if XVID_GLOBAL_PACKED is set */ |
647 |
|
|
648 |
/*---------------------------------------------------------------------------- |
/*---------------------------------------------------------------------------- |
649 |
* "VOL" flags |
* "VOL" flags |
657 |
#define XVID_VOL_QUARTERPEL (1<<2) /* enable quarterpel: frames will encoded as quarterpel */ |
#define XVID_VOL_QUARTERPEL (1<<2) /* enable quarterpel: frames will encoded as quarterpel */ |
658 |
#define XVID_VOL_GMC (1<<3) /* enable GMC; frames will be checked for gmc suitability */ |
#define XVID_VOL_GMC (1<<3) /* enable GMC; frames will be checked for gmc suitability */ |
659 |
#define XVID_VOL_REDUCED_ENABLE (1<<4) /* enable reduced resolution vops: frames will be checked for rrv suitability */ |
#define XVID_VOL_REDUCED_ENABLE (1<<4) /* enable reduced resolution vops: frames will be checked for rrv suitability */ |
660 |
|
/* NOTE: the reduced resolution feature is not supported anymore. This flag will have no effect! */ |
661 |
#define XVID_VOL_INTERLACING (1<<5) /* enable interlaced encoding */ |
#define XVID_VOL_INTERLACING (1<<5) /* enable interlaced encoding */ |
662 |
|
|
663 |
|
|
679 |
#define XVID_VOP_HQACPRED (1<< 7) /* high quality ac prediction */ |
#define XVID_VOP_HQACPRED (1<< 7) /* high quality ac prediction */ |
680 |
#define XVID_VOP_MODEDECISION_RD (1<< 8) /* enable DCT-ME and use it for mode decision */ |
#define XVID_VOP_MODEDECISION_RD (1<< 8) /* enable DCT-ME and use it for mode decision */ |
681 |
#define XVID_VOP_FAST_MODEDECISION_RD (1<<12) /* use simplified R-D mode decision */ |
#define XVID_VOP_FAST_MODEDECISION_RD (1<<12) /* use simplified R-D mode decision */ |
682 |
|
#define XVID_VOP_RD_BVOP (1<<13) /* enable rate-distortion mode decision in b-frames */ |
683 |
|
#define XVID_VOP_RD_PSNRHVSM (1<<14) /* use PSNR-HVS-M as metric for rate-distortion optimizations */ |
684 |
|
|
685 |
/* Only valid for vol_flags|=XVID_VOL_INTERLACING */ |
/* Only valid for vol_flags|=XVID_VOL_INTERLACING */ |
686 |
#define XVID_VOP_TOPFIELDFIRST (1<< 9) /* set top-field-first flag */ |
#define XVID_VOP_TOPFIELDFIRST (1<< 9) /* set top-field-first flag */ |
688 |
|
|
689 |
/* only valid for vol_flags|=XVID_VOL_REDUCED_ENABLED */ |
/* only valid for vol_flags|=XVID_VOL_REDUCED_ENABLED */ |
690 |
#define XVID_VOP_REDUCED (1<<11) /* reduced resolution vop */ |
#define XVID_VOP_REDUCED (1<<11) /* reduced resolution vop */ |
691 |
|
/* NOTE: reduced resolution feature is not supported anymore. This flag will have no effect! */ |
692 |
|
|
693 |
/*---------------------------------------------------------------------------- |
/*---------------------------------------------------------------------------- |
694 |
* "Motion" flags |
* "Motion" flags |
758 |
int num_plugins; /* [in:opt] number of plugins */ |
int num_plugins; /* [in:opt] number of plugins */ |
759 |
xvid_enc_plugin_t * plugins; /* ^^ plugin array */ |
xvid_enc_plugin_t * plugins; /* ^^ plugin array */ |
760 |
|
|
761 |
int num_threads; /* [in:opt] number of threads */ |
int num_threads; /* [in:opt] number of threads to use in encoder */ |
762 |
int max_bframes; /* [in:opt] max sequential bframes (0=disable bframes) */ |
int max_bframes; /* [in:opt] max sequential bframes (0=disable bframes) */ |
763 |
|
|
764 |
int global; /* [in:opt] global flags; controls encoding behavior */ |
int global; /* [in:opt] global flags; controls encoding behavior */ |
781 |
/* ---------------------------------------------- */ |
/* ---------------------------------------------- */ |
782 |
|
|
783 |
void *handle; /* [out] encoder instance handle */ |
void *handle; /* [out] encoder instance handle */ |
784 |
|
|
785 |
|
/* ------- v1.3.x ------- */ |
786 |
|
int start_frame_num; /* [in:opt] frame number of start frame relative to zones definitions. allows to encode sub-sequences */ |
787 |
|
int num_slices; /* [in:opt] number of slices to code for each frame */ |
788 |
} xvid_enc_create_t; |
} xvid_enc_create_t; |
789 |
|
|
790 |
|
|