[XviD-devel] pre0 milestone

suxen_drol xvid-devel@xvid.org
Wed, 18 Dec 2002 00:36:00 +1100


hi,

> * resolve the whole VOL/VOP issues (ie. frame-base qpel, etc..)
>     - i reckon, perform the qpel tests/analysis in the first pass, but
>       only enable qpel for ippp..ppp sequences in the second pass.
>     - koepi and/or syskin have suggested a nonspec xvid_enc_frame field,
>       which instructs the encoder to generate non standard streams.
>     - any other ideas


ive done some more work on api3. its 'almost' ready for integration.
to intergrate, i will rename all the api3 macros/structs/functions from XVID to xvi3, and
write a "api2 -> api3" wrapper to prevent breakage and assist testing.

by default vols are only written once, at the beginning of the stream. the XVID_VOL_AT_IVOP
flag enables vols to be generated for every keyframe.

vol-based flags are now defined seperatly from vol-based flags. by default, the encoder
will not react to vol-flag changes, until it encodes the next vol(keyframe).

i'd like to remove XVID_H263QUANT. gruel original asked for this in the event we'd implement
more quantization methods, but i think we cant easily that, without breaking the iso specification.

questions:
* i think we need min/max_i/p/b_quantizer vars for ratecontrol, and possible lumimasking
  where would these be best place? XVID_ENC_PARAM/xvid_enc_create_t, or FRAME, or the ratecontrol
  structs?
* in addition to bquant, should we consider a pquant?

in the xvid_enc_frame_t struct, there are four 'flag' member.
general: relate to the behaviour of the encoder
	#define XVID_DEBUG			0x00000001	/* print debug info on each frame */
	#define XVID_PACKED			0x00000002	/* packed bitstream */
	#define XVID_CLOSED_GOP			0x00000004	/* closed_gop	(was dx50 bvop compatibility) */
	#define XVID_VOL_AT_IVOP		0x00000008	/* write vol at every ivop: WIN32/divx compatibility */

vol_flags: vol specific stuff
	#define XVID_GMC			0x00000001	/* enable GMC; frames will be checked for gmc suitability */
	#define XVID_REDUCED			0x00000002	/* enable reduced resolution vops: frames will be checked for rrv suitability */
	#define XVID_QUARTERPEL			0x00000004	/* enable quarterpel: frames will encoded as quarterpel */

??	#define XVID_H263QUANT			0x00000000	/* XXX: why do we need a macros for this??! */
	#define XVID_MPEGQUANT			0x00000008	/* mpeg quant type */
	#define XVID_CUSTOM_QMATRIX		0x00000010	/* use custom quant matrix */

	#define XVID_INTERLACING		0x00000400	/* enable interlaced encoding */

vop_flags: frame/vop specific stuff
	#define XVID_TOPFIELDFIRST		0x00000800	/* set top-field-first flag  */
	#define XVID_ALTERNATESCAN		0x00001000	/* set alternate vertical scan flag */
	#define XVID_HALFPEL			0x00000040	/* use halfpel interpolation 
							when enabled, xvidcore will interpolate the y-plane reference image 
							must be enabled to use halfpel refinement */
	#define XVID_LUMIMASKING		0x00000100	/* adaptive quantization */
	#define XVID_INTER4V			0x00008000	/* enable inter4v search */
	#define XVID_ME_COLOUR			0x40000000	/* enable chroma to be considered in motion search */

	/* preprocessing flags */
	#define XVID_GREYSCALE			0x00000001	/* enable greyscale only mode (even for */
	#define XVID_GRAYSCALE			0x00000001  /* color input material chroma is ignored) */
	#define XVID_CHROMAOPT			0x00000002	/* chroma optimzer */


motion: ...all our existing PMV_xxx flags


typedef struct {
	int version;
	int general;			/* [in] general options */

/* --- VOL related stuff ---- the encoder will not react to any changes here until the next VOL (keyframe) ---- */
	int vol_flags;			/* [in]	vop flags */
	unsigned char *
		quant_intra_matrix;	/* [in] custom intra qmatrix */
	unsigned char *
		quant_inter_matrix;	/* [in] custom inter qmatrix */

	int fincr;			/* [in:opt] frame duration increment
					optional when fincr in nonzero in xvid_enc_create_t */

	int par;			/* [in:opt] picture aspect ratio (refer to XVID_PAR_xxx above) */
	int par_width;			/* [in:opt] aspect ratio width */
	int par_height;			/* [in:opt] aspect ratio height */
/* ^^^----------------------------------------------------------------------------------*/

	int vop_flags			/* [in] vop-based flags */
	int motion;			/* [in] ME options */

	xvid_image_t input;		/* [in] input image */
	
	int coding_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 */
	int length;			/* [in:opt] bitstream length (bytes) */

	int intra;			/* [out] intra state */
}
xvid_enc_frame_t;


typedef struct {
	int version;
	int coding_type;		/* [out] coding type */
	int quant;			/* [out] frame quantizer */
	int length			/* [out] frame length */

	int hlength;			/* [out] header length (bytes) */
	int kblks, mblks, ublks;	/* [out] */
}
xvid_enc_stats_t;



-- pete; in light of the new 3ivx codec and the completion of api3, i
propose we rename XviD to Xvi3. </joke>