huf.h 1.57 KB

typedef struct huf_struct {
	
    unsigned int
		end:1,
		sign:1,
		stop:1,	    /* don't consume bits unless "sign" is set also */
		nbits:2,
		value:11;
} HufControl;

typedef HufControl HufTable[16];

typedef unsigned int BIT_BUFTYPE;


extern FILE *huf_file;
extern char *huf_filename;
extern BIT_BUFTYPE *in_bit_buf;
extern int in_buf_len;
extern int in_cur_bits;
extern int in_cur_used;
extern int in_cur_word;


#define AC_ERROR        (0x100)
#define AC_EOB          (AC_ERROR+1)
#define AC_ESCAPE       (AC_ERROR+2)
#define AC_START_CODE   (AC_ERROR+3)


#define AC_FIRST        (0)
#define AC_START        (1)

extern HufControl *(huf_mpeg1_ac_tabs[32]);


#define HUF_LEVEL_SHIFT (5)
#define LR(level,run)   ((level<<HUF_LEVEL_SHIFT)+run)
#define RL(run,level)   ((level<<HUF_LEVEL_SHIFT)+run)

#define MBH_ZEROS       LR(1,0)
#define MBH_ERRORS      LR(2,0)

#define MBH_FIRST       (0)

#define MBA_START       (MBH_FIRST)
#define MBT_INTRA       (MBH_FIRST+7)
#define MBT_PRED        (MBH_FIRST+8)
#define MBT_BIDIR       (MBH_FIRST+11)
#define CBP_START       (MBH_FIRST+14)
#define MV_START        (MBH_FIRST+28)
#define DCL_START       (MBH_FIRST+33)
#define DCC_START       (MBH_FIRST+35)


#define MBA_ZEROS       (MBH_ZEROS + 1)
#define MBA_ERROR       (MBH_ERRORS + 1)

#define MBA_ESCAPE      (33)
#define MBA_STUFF       (0)

#define MBT_ERROR       (MBH_ERRORS + 2)

#define CBP_ZEROS       (MBH_ZEROS + 4)
#define CBP_ERROR       (MBH_ERRORS + 4)

#define DCL_ERROR       (MBH_ERRORS + 6)
#define DCC_ERROR       (MBH_ERRORS + 7)

extern HufControl *(huf_mpeg1_mbh_tabs[40]);