working together with FATFileSystem
Fork of TinyJpgDec by
Embed:
(wiki syntax)
Show/hide line numbers
TinyJpgDec.h
00001 /*----------------------------------------------------------------------------/ 00002 / TJpgDec - Tiny JPEG Decompressor include file (C)ChaN, 2012 00003 /----------------------------------------------------------------------------*/ 00004 #ifndef _TJPGDEC 00005 #define _TJPGDEC 00006 /*---------------------------------------------------------------------------*/ 00007 /* System Configurations */ 00008 00009 #define JD_SZBUF 1024 /* Size of stream input buffer */ 00010 #define JD_FORMAT 0 /* Output pixel format 0:RGB888 (3 BYTE/pix), 1:RGB565 (1 WORD/pix) */ 00011 #define JD_USE_SCALE 1 /* Use descaling feature for output */ 00012 #define JD_TBLCLIP 1 /* Use table for saturation (might be a bit faster but increases 1K bytes of code size) */ 00013 00014 /*---------------------------------------------------------------------------*/ 00015 00016 #ifdef __cplusplus 00017 extern "C" { 00018 #endif 00019 00020 #include "integer.h" 00021 00022 00023 /* Error code */ 00024 typedef enum { 00025 JDR_OK = 0, /* 0: Succeeded */ 00026 JDR_INTR, /* 1: Interrupted by output function */ 00027 JDR_INP, /* 2: Device error or wrong termination of input stream */ 00028 JDR_MEM1, /* 3: Insufficient memory pool for the image */ 00029 JDR_MEM2, /* 4: Insufficient stream input buffer */ 00030 JDR_PAR, /* 5: Parameter error */ 00031 JDR_FMT1, /* 6: Data format error (may be damaged data) */ 00032 JDR_FMT2, /* 7: Right format but not supported */ 00033 JDR_FMT3 /* 8: Not supported JPEG standard */ 00034 } 00035 JRESULT; 00036 00037 00038 00039 /* Rectangular structure */ 00040 typedef struct { 00041 WORD left, right, top, bottom; 00042 } JRECT; 00043 00044 00045 00046 /* Decompressor object structure */ 00047 typedef struct JDEC JDEC; 00048 struct JDEC { 00049 JPG_UINT dctr; /* Number of bytes available in the input buffer */ 00050 BYTE* dptr; /* Current data read ptr */ 00051 BYTE* inbuf; /* Bit stream input buffer */ 00052 BYTE dmsk; /* Current bit in the current read byte */ 00053 BYTE scale; /* Output scaling ratio */ 00054 BYTE msx, msy; /* MCU size in unit of block (width, height) */ 00055 BYTE qtid[3]; /* Quantization table ID of each component */ 00056 SHORT dcv[3]; /* Previous DC element of each component */ 00057 WORD nrst; /* Restart inverval */ 00058 JPG_UINT width, height; /* Size of the input image (pixel) */ 00059 BYTE* huffbits[2][2]; /* Huffman bit distribution tables [id][dcac] */ 00060 WORD* huffcode[2][2]; /* Huffman code word tables [id][dcac] */ 00061 BYTE* huffdata[2][2]; /* Huffman decoded data tables [id][dcac] */ 00062 LONG* qttbl[4]; /* Dequaitizer tables [id] */ 00063 void* workbuf; /* Working buffer for IDCT and RGB output */ 00064 BYTE* mcubuf; /* Working buffer for the MCU */ 00065 void* pool; /* Pointer to available memory pool */ 00066 JPG_UINT sz_pool; /* Size of momory pool (bytes available) */ 00067 JPG_UINT (*infunc)(JDEC*, BYTE*, JPG_UINT);/* Pointer to jpeg stream input function */ 00068 void* device; /* Pointer to I/O device identifiler for the session */ 00069 }; 00070 00071 00072 00073 /* TJpgDec API functions */ 00074 JRESULT jd_prepare (JDEC*, JPG_UINT(*)(JDEC*,BYTE*,JPG_UINT), void*, JPG_UINT, void*); 00075 JRESULT jd_decomp (JDEC*, JPG_UINT(*)(JDEC*,void*,JRECT*), BYTE); 00076 00077 00078 #ifdef __cplusplus 00079 } 00080 #endif 00081 00082 #endif /* _TJPGDEC */
Generated on Sun Jul 17 2022 04:52:20 by 1.7.2