working together with FATFileSystem

Fork of TinyJpgDec by Helmut Schmücker

Committer:
the_sz
Date:
Sat Nov 14 02:43:21 2015 +0000
Revision:
1:79e97662234d
Parent:
0:b6f284347a66
INT -> JPEG_INT

Who changed what in which revision?

UserRevisionLine numberNew contents of line
humlet 0:b6f284347a66 1 /*----------------------------------------------------------------------------/
humlet 0:b6f284347a66 2 / TJpgDec - Tiny JPEG Decompressor include file (C)ChaN, 2012
humlet 0:b6f284347a66 3 /----------------------------------------------------------------------------*/
humlet 0:b6f284347a66 4 #ifndef _TJPGDEC
humlet 0:b6f284347a66 5 #define _TJPGDEC
humlet 0:b6f284347a66 6 /*---------------------------------------------------------------------------*/
humlet 0:b6f284347a66 7 /* System Configurations */
humlet 0:b6f284347a66 8
humlet 0:b6f284347a66 9 #define JD_SZBUF 1024 /* Size of stream input buffer */
the_sz 1:79e97662234d 10 #define JD_FORMAT 0 /* Output pixel format 0:RGB888 (3 BYTE/pix), 1:RGB565 (1 WORD/pix) */
humlet 0:b6f284347a66 11 #define JD_USE_SCALE 1 /* Use descaling feature for output */
humlet 0:b6f284347a66 12 #define JD_TBLCLIP 1 /* Use table for saturation (might be a bit faster but increases 1K bytes of code size) */
humlet 0:b6f284347a66 13
humlet 0:b6f284347a66 14 /*---------------------------------------------------------------------------*/
humlet 0:b6f284347a66 15
humlet 0:b6f284347a66 16 #ifdef __cplusplus
humlet 0:b6f284347a66 17 extern "C" {
humlet 0:b6f284347a66 18 #endif
humlet 0:b6f284347a66 19
humlet 0:b6f284347a66 20 #include "integer.h"
humlet 0:b6f284347a66 21
humlet 0:b6f284347a66 22
humlet 0:b6f284347a66 23 /* Error code */
humlet 0:b6f284347a66 24 typedef enum {
humlet 0:b6f284347a66 25 JDR_OK = 0, /* 0: Succeeded */
humlet 0:b6f284347a66 26 JDR_INTR, /* 1: Interrupted by output function */
humlet 0:b6f284347a66 27 JDR_INP, /* 2: Device error or wrong termination of input stream */
humlet 0:b6f284347a66 28 JDR_MEM1, /* 3: Insufficient memory pool for the image */
humlet 0:b6f284347a66 29 JDR_MEM2, /* 4: Insufficient stream input buffer */
humlet 0:b6f284347a66 30 JDR_PAR, /* 5: Parameter error */
humlet 0:b6f284347a66 31 JDR_FMT1, /* 6: Data format error (may be damaged data) */
humlet 0:b6f284347a66 32 JDR_FMT2, /* 7: Right format but not supported */
humlet 0:b6f284347a66 33 JDR_FMT3 /* 8: Not supported JPEG standard */
humlet 0:b6f284347a66 34 }
humlet 0:b6f284347a66 35 JRESULT;
humlet 0:b6f284347a66 36
humlet 0:b6f284347a66 37
humlet 0:b6f284347a66 38
humlet 0:b6f284347a66 39 /* Rectangular structure */
humlet 0:b6f284347a66 40 typedef struct {
humlet 0:b6f284347a66 41 WORD left, right, top, bottom;
humlet 0:b6f284347a66 42 } JRECT;
humlet 0:b6f284347a66 43
humlet 0:b6f284347a66 44
humlet 0:b6f284347a66 45
humlet 0:b6f284347a66 46 /* Decompressor object structure */
humlet 0:b6f284347a66 47 typedef struct JDEC JDEC;
humlet 0:b6f284347a66 48 struct JDEC {
the_sz 1:79e97662234d 49 JPG_UINT dctr; /* Number of bytes available in the input buffer */
humlet 0:b6f284347a66 50 BYTE* dptr; /* Current data read ptr */
humlet 0:b6f284347a66 51 BYTE* inbuf; /* Bit stream input buffer */
humlet 0:b6f284347a66 52 BYTE dmsk; /* Current bit in the current read byte */
humlet 0:b6f284347a66 53 BYTE scale; /* Output scaling ratio */
humlet 0:b6f284347a66 54 BYTE msx, msy; /* MCU size in unit of block (width, height) */
humlet 0:b6f284347a66 55 BYTE qtid[3]; /* Quantization table ID of each component */
humlet 0:b6f284347a66 56 SHORT dcv[3]; /* Previous DC element of each component */
humlet 0:b6f284347a66 57 WORD nrst; /* Restart inverval */
the_sz 1:79e97662234d 58 JPG_UINT width, height; /* Size of the input image (pixel) */
humlet 0:b6f284347a66 59 BYTE* huffbits[2][2]; /* Huffman bit distribution tables [id][dcac] */
humlet 0:b6f284347a66 60 WORD* huffcode[2][2]; /* Huffman code word tables [id][dcac] */
humlet 0:b6f284347a66 61 BYTE* huffdata[2][2]; /* Huffman decoded data tables [id][dcac] */
humlet 0:b6f284347a66 62 LONG* qttbl[4]; /* Dequaitizer tables [id] */
humlet 0:b6f284347a66 63 void* workbuf; /* Working buffer for IDCT and RGB output */
humlet 0:b6f284347a66 64 BYTE* mcubuf; /* Working buffer for the MCU */
humlet 0:b6f284347a66 65 void* pool; /* Pointer to available memory pool */
the_sz 1:79e97662234d 66 JPG_UINT sz_pool; /* Size of momory pool (bytes available) */
the_sz 1:79e97662234d 67 JPG_UINT (*infunc)(JDEC*, BYTE*, JPG_UINT);/* Pointer to jpeg stream input function */
humlet 0:b6f284347a66 68 void* device; /* Pointer to I/O device identifiler for the session */
humlet 0:b6f284347a66 69 };
humlet 0:b6f284347a66 70
humlet 0:b6f284347a66 71
humlet 0:b6f284347a66 72
humlet 0:b6f284347a66 73 /* TJpgDec API functions */
the_sz 1:79e97662234d 74 JRESULT jd_prepare (JDEC*, JPG_UINT(*)(JDEC*,BYTE*,JPG_UINT), void*, JPG_UINT, void*);
the_sz 1:79e97662234d 75 JRESULT jd_decomp (JDEC*, JPG_UINT(*)(JDEC*,void*,JRECT*), BYTE);
humlet 0:b6f284347a66 76
humlet 0:b6f284347a66 77
humlet 0:b6f284347a66 78 #ifdef __cplusplus
humlet 0:b6f284347a66 79 }
humlet 0:b6f284347a66 80 #endif
humlet 0:b6f284347a66 81
humlet 0:b6f284347a66 82 #endif /* _TJPGDEC */