/* Decompressor object structure */ typedef struct JDEC JDEC; struct JDEC { UINT dctr; /* Number of bytes available in the input buffer */ BYTE* dptr; /* Current data read ptr */ BYTE* inbuf; /* Bit stream input buffer */ BYTE dmsk; /* Current bit in the current read byte */ BYTE scale; /* Output scaling ratio */ BYTE msx, msy; /* MCU size in unit of block (width, height) */ BYTE qtid[3]; /* Quantization table ID of each component */ SHORT dcv[3]; /* Previous DC element of each component */ WORD nrst; /* Restart inverval */ UINT width, height; /* Size of the input image (pixel) */ BYTE* huffbits[2][2]; /* Huffman bit distribution tables [id][dcac] */ WORD* huffcode[2][2]; /* Huffman code word tables [id][dcac] */ BYTE* huffdata[2][2]; /* Huffman decoded data tables [id][dcac] */ LONG* qttbl[4]; /* Dequaitizer tables [id] */ void* workbuf; /* Working buffer for IDCT and RGB output */ BYTE* mcubuf; /* Working buffer for the MCU */ void* pool; /* Pointer to available memory pool */ UINT sz_pool; /* Size of momory pool (bytes available) */ UINT (*infunc)(JDEC*, BYTE*, UINT);/* Pointer to jpeg stream input function */ void* device; /* Pointer to I/O device identifiler for the session */ }; 之外,還需要自己寫兩個函數(shù).
先來看下其中一個庫函數(shù)的聲明:
JRESULT jd_prepare (
JDEC* jd,/* Blank decompressor object */
UINT (*infunc)(JDEC*, BYTE*, UINT),/* JPEG strem input function */
void* pool,/* Working buffer for the decompression session */
UINT sz_pool,/* Size of working buffer */
void* dev/* I/O device identifier for the session */
)