mpeg_tok.h 1.45 KB

#define TOK_PTYPE_INTRA	(1)
#define TOK_PTYPE_PRED	(2)
#define TOK_PTYPE_BIDIR	(3)

#define TOK_BEGIN_BLOCK	(0)
#define TOK_NEXT_MB	(16)
#define TOK_NEXT_PIC	(17)
#define TOK_NEXT_SEQ	(18)
#define TOK_END_PAGE	(29)
#define TOK_END_PIC	(30)
#define TOK_END_SEQ	(31)


#define TOK_MBTYPE_INTRA	(1<<15)
#define TOK_MBTYPE_ERRS	(1<<14)
#define TOK_MBTYPE_FOR	(1<<13)
#define TOK_MBTYPE_BAK	(1<<12)
#define TOK_MBTYPE_BCNTS	(1<<11)

/*
	Macroblock type encoding bitfields:

15	Intra
14	Errs
13	For
12	Back
11	Bcnts
10	------

 9	FhighY
 8	FhighX
 7	FhighX
 6	FhighX
 5	FhighX

 4	BhighY
 3	BhighX
 2	BhighX
 1	BhighX
 0	BhighX

*/

/*
    Motion vector encoding:

	MPEG-2 Main Profile, Main Level says x in [-1024,+1023.5]  (12 bits)
					and  y in [ -128, +127.5]  ( 9 bits)
	
	These can be stored in (1+4)(high bits in MBtype) + (8+8)(low bits)

	So, only one extra 16-bit word is needed per macroblock per MV.
*/

#define TOK_MVY_HIGH_BITS		(1)
#define TOK_MVX_HIGH_BITS		(4)

#define TOK_MVY_LOW_BITS		(8)
#define TOK_MVX_LOW_BITS		(8)

#define TOK_MVY_HIGH_MASK		((1<<TOK_MVY_HIGH_BITS)-1)
#define TOK_MVX_HIGH_MASK		((1<<TOK_MVX_HIGH_BITS)-1)

#define TOK_MVY_LOW_MASK		((1<<TOK_MVY_LOW_BITS)-1)
#define TOK_MVX_LOW_MASK		((1<<TOK_MVX_LOW_BITS)-1)

#define TOK_FMVY_HIGH_SHIFT		(9)
#define TOK_FMVX_HIGH_SHIFT		(5)

#define TOK_BMVY_HIGH_SHIFT		(4)
#define TOK_BMVX_HIGH_SHIFT		(0)

#define TOK_MVY_LOW_SHIFT		(8)
#define TOK_MVX_LOW_SHIFT		(0)

#define TOK_PRED_SKIP		(TOK_MBTYPE_FOR)