--- xvid.h 2003/03/11 20:15:40 1.27.2.4 +++ xvid.h 2003/03/26 11:01:03 1.27.2.12 @@ -19,13 +19,14 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: xvid.h,v 1.27.2.4 2003/03/11 20:15:40 edgomez Exp $ + * $Id: xvid.h,v 1.27.2.12 2003/03/26 11:01:03 suxen_drol Exp $ * ****************************************************************************/ #ifndef _XVID_H_ #define _XVID_H_ + #ifdef __cplusplus extern "C" { #endif @@ -176,8 +177,8 @@ int version; xvid_image_t input; /* [in] input image & colorspace */ xvid_image_t output; /* [in] output image & colorspace */ - int width; /* [in] width */ - int height; /* [in] height */ + int width; /* [in] width */ + int height; /* [in] height */ int interlacing; /* [in] interlacing */ } xvid_gbl_convert_t; @@ -238,7 +239,7 @@ int time_increment; /* [out] time increment */ /* XXX: external deblocking stuff */ - unsigned char * qscale; /* [out] pointer to quantizer table */ + int * qscale; /* [out] pointer to quantizer table */ int qscale_stride; /* [out] quantizer scale stride */ } vop; @@ -254,6 +255,193 @@ } xvid_dec_stats_t; +/***************************************************************************** + xvid plugin system -- internals + + xvidcore will call XVID_PLG_INFO and XVID_PLG_CREATE during XVID_ENC_CREATE + before encoding each frame xvidcore will call XVID_PLG_BEFORE + after encoding each frame xvidcore will call XVID_PLG_AFTER + xvidcore will call XVID_PLG_DESTROY during XVID_ENC_DESTROY + ****************************************************************************/ + +#define XVID_PLG_CREATE 0 +#define XVID_PLG_DESTROY 1 +#define XVID_PLG_INFO 2 +#define XVID_PLG_BEFORE 3 +#define XVID_PLG_AFTER 4 + +/* xvid_plg_info_t.flags */ +#define XVID_REQORIGINAL 1 /* plugin requires a copy of the original (uncompressed) image */ +#define XVID_REQPSNR 2 /* plugin requires psnr between the uncompressed and compressed image*/ +#define XVID_REQDQUANTS 3 /* plugin requires access to the dquant table */ + + +typedef struct +{ + int version; + int flags; /* plugin flags */ +} xvid_plg_info_t; + + +typedef struct +{ + int version; + + int width; + int height; + int mb_width; + int mb_height; + int fincr; + int fbase; + + void * param; +} xvid_plg_create_t; + + +typedef struct +{ + int version; + + int num_frames; /* [out] totlal frame encoded */ +} xvid_plg_destroy_t; + + +typedef struct +{ + int version; + + int width; /* [out] */ + int height; /* [out] */ + int mb_width; /* [out] */ + int mb_height; /* [out] */ + int fincr; /* [out] */ + int fbase; /* [out] */ + + xvid_image_t reference; /* [out] -> [out] */ + xvid_image_t current; /* [out] -> [in,out] */ + xvid_image_t original; /* [out] after: points the original (uncompressed) copy of the current frame */ + int frame_num; /* [out] frame number */ + + int type; /* [in,out] */ + int quant; /* [in,out] */ + + int * dquant; /* [in,out] pointer to diff quantizer table */ + int dquant_stride; /* [in,out] diff quantizer stride */ + + int vop_flags; /* [in,out] */ + int vol_flags; /* [in,out] */ + int motion_flags; /* [in,out] */ + + int length; /* [out] after: length of encoded frame */ + int kblks, mblks, ublks; /* [out] after: */ + int sse_y, sse_u, sse_v; /* [out] */ +} xvid_plg_data_t; + + +/***************************************************************************** + xvid plugin system -- external + + the application passes xvid an array of "xvid_plugin_t" at XVID_ENC_CREATE. the array + indicates the plugin function pointer and plugin-specific data. + xvidcore handles the rest. example: + + xvid_enc_create_t create; + xvid_enc_plugin_t plugins[2]; + + plugins[0].func = xvid_psnr_func; + plugins[0].param = NULL; + plugins[1].func = xvid_cbr_func; + plugins[1].param = &cbr_data; + + create.num_plugins = 2; + create.plugins = plugins; + + ****************************************************************************/ + +typedef int (xvid_plugin_func)(void * handle, int opt, void * param1, void * param2); + +typedef struct +{ + xvid_plugin_func * func; + void * param; +} xvid_enc_plugin_t; + + + +xvid_plugin_func xvid_plugin_fixed; /* fixed quantizer control */ +xvid_plugin_func xvid_plugin_cbr; /* constant bitrate control */ +xvid_plugin_func xvid_plugin_2pass1; /* 2pass rate control: first pass */ +xvid_plugin_func xvid_plugin_2pass2; /* 2pass rate control: second pass */ + +xvid_plugin_func xvid_plugin_lumimasking; /* lumimasking */ + +xvid_plugin_func xvid_plugin_psnr; /* write psnr values to stdout */ +xvid_plugin_func xvid_plugin_dump; /* dump before and after yuvpgms */ + + +typedef struct +{ + int version; + int quant_increment; + int quant_base; +} xvid_plugin_fixed_t; + + +typedef struct +{ + int version; + int bitrate; + int max_quantizer; + int min_quantizer; + int reaction_delay_factor; + int averaging_period; + int buffer; +} xvid_plugin_cbr_t; + + +typedef struct { + int version; + char * filename; +} xvid_plugin_2pass1_t; + + +#define XVID_CURVE_COSINE 0 /* low aggressiveness */ +#define XVID_CURVE_LINEAR 1 /* medium aggressiveness */ +#define XVID_CURVE_SINE 2 /* high aggressiveness */ + +#define XVID_PAYBACK_BIAS 0 /* payback with bias */ +#define XVID_PAYBACK_PROP 1 /* payback proportionally */ + +typedef struct { + int version; + char * filename1; + char * filename2; + + int keyframe_boost; /* keyframe boost percentage: [0..100...]; */ + int payback_method; + int bitrate_payback_delay; + int curve_compression_high; + int curve_compression_low; + int max_overflow_improvement; + int max_overflow_degradation; + int min_quant[3]; + int max_quant[3]; + + int use_alt_curve; + int alt_curve_high_dist; + int alt_curve_low_dist; + int alt_curve_use_auto; + int alt_curve_auto_str; + int alt_curve_type; /* XVID_CURVE_ */ + int alt_curve_min_rel_qual; + int alt_curve_use_auto_bonus_bias; + int alt_curve_bonus_bias; + + int kftreshold; + int kfreduction; + int min_key_interval; +}xvid_plugin_2pass2_t; + /***************************************************************************** * xvid_encore() @@ -283,6 +471,7 @@ /* vol-based flags */ typedef enum { XVID_MPEGQUANT = 0x00000001, + XVID_EXTRASTATS = 0x00000002, XVID_QUARTERPEL = 0x00000004, /* enable quarterpel: frames will encoded as quarterpel */ XVID_GMC = 0x00000008, /* enable GMC; frames will be checked for gmc suitability */ XVID_REDUCED_ENABLE = 0x00000010, /* enable reduced resolution vops: frames will be checked for rrv suitability */ @@ -293,10 +482,9 @@ /* vop-based flags */ typedef enum { XVID_DEBUG = 0x00000001, - XVID_EXTRASTATS = 0x00000002, + XVID_HALFPEL = 0x00000004, /* use halfpel interpolation */ XVID_INTER4V = 0x00000008, - XVID_LUMIMASKING = 0x00000010, XVID_CHROMAOPT = 0x00000020, /* enable chroma optimization pre-filter */ XVID_GREYSCALE = 0x00000040, /* enable greyscale only mode (even for @@ -356,6 +544,9 @@ int width; /* [in] frame dimensions; width, pixel units */ int height; /* [in] frame dimensions; height, pixel units */ + int num_plugins; /* [in:opt] number of plugins */ + xvid_enc_plugin_t * plugins; /* ^^ plugin array */ + int num_threads; /* [in:opt] number of threads */ int max_bframes; /* [in:opt] max sequential bframes (0=disable bframes) */ @@ -384,33 +575,6 @@ xvid_enc_create_t; -typedef struct { - int version; - int type; /* [in] rate control type: XVID_RC_xxx */ - - /* common stuff */ - int min_iquant; /* [in:opt] ivop quantizer upper/lower limit */ - int max_iquant; /* [in:opt] */ - int min_pquant; /* [in:opt] psvop quantizer upper/lower limit */ - int max_pquant; /* [in:opt] */ - int min_bquant; /* [in:opt] bvop quantizer upper/lower limit */ - int max_bquant; /* [in:opt] */ - - union { - struct { /* XVID_RC_FQUANT */ - float quant; /* [in] quantizer */ - } fquant; - struct { /* XVID_RC_CBR */ - int bitrate; /* [in] the bitrate of the target encoded stream, in bits/second */ - int reaction_delay_factor; /* [in] how fast the rate control reacts - lower values are faster */ - int averaging_period; /* [in] */ - int buffer; /* [in] */ - } cbr; - } data; -} xvid_enc_rc_t; - - - #define XVID_KEYFRAME 0x00000001 typedef struct { @@ -429,6 +593,7 @@ int par_height; /* [in:opt] aspect ratio height */ /* ^^^----------------------------------------------------------------------------------*/ + int fincr; /* framerate increment, for variable framerate only */ xvid_vop_t vop_flags; /* [in] (general)vop-based flags */ xvid_motion_t motion; /* [in] ME options */ @@ -436,7 +601,6 @@ int type; /* [in:opt] coding type */ int quant; /* [in] frame quantizer; if <=0, automatatic (ratecontrol) */ - int bquant; /* [in:opt] bframe quantizer; if <=0, automatic*/ void *bitstream; /* [in:opt] bitstream ptr (written to)*/ int length; /* [in:opt] bitstream length (bytes) */ @@ -473,4 +637,5 @@ } #endif + #endif