#ifndef VLD_DATA_H
#define VLD_DATA_H

#include "jpeg.h"

/* VLD */
#define MAX_SIZE(classe)         ((classe)?162:14) /* Memory size of HTables */

#define HUFF_EOB                0x00
#define HUFF_ZRL                0xF0

typedef struct {
	unsigned char	CID;	/* component ID */
	char QT;	/* QTable index, 2bits 	*/
	char DC_HT;	/* DC table index, 1bit */
	char AC_HT;	/* AC table index, 1bit */
	int PRED;	/* DC predictor value */
} cd_t;

typedef struct {
    unsigned char *HTable[4];
    int MinCode[4][16];
    int MaxCode[4][16];
    int ValPtr[4][16];
    unsigned char DC_Table0[MAX_SIZE(DC_CLASS)];
    unsigned char DC_Table1[MAX_SIZE(DC_CLASS)];
    unsigned char AC_Table0[MAX_SIZE(AC_CLASS)];
    unsigned char AC_Table1[MAX_SIZE(AC_CLASS)];
} huff_context;

typedef struct {
    unsigned char current;
    unsigned char available;
} bitreader_context;

typedef struct {
	unsigned int lumHi;
	unsigned int lumVi;
	int mx_size;
	int my_size;
	huff_context huff;
	cd_t comp;
	cd_t compCr;
	cd_t compCb;
	int nb_consecutive_ff;
} vld_struct;

#endif
