Просмотр исходного кода

Merge pull request #3 from mysterywolf/master

从R0.01c升级到R0.01d
朱天龙 (Armink) 5 лет назад
Родитель
Сommit
0597cd2f2a
2 измененных файлов с 589 добавлено и 586 удалено
  1. 541 538
      tjpgd.c
  2. 48 48
      tjpgd.h

Разница между файлами не показана из-за своего большого размера
+ 541 - 538
tjpgd.c


+ 48 - 48
tjpgd.h

@@ -1,32 +1,32 @@
-#include <rtthread.h>
-
 /*----------------------------------------------------------------------------/
-/ TJpgDec - Tiny JPEG Decompressor include file               (C)ChaN, 2019
+/ TJpgDec - Tiny JPEG Decompressor include file               (C)ChaN, 2020
 /----------------------------------------------------------------------------*/
 #ifndef DEF_TJPGDEC
 #define DEF_TJPGDEC
 /*---------------------------------------------------------------------------*/
 /* System Configurations */
 
+#include <rtthread.h>
+
 #ifdef TJPGD_USING_FORMAT_RGB888
-#define JD_FORMAT		0   /* Output pixel format 0:RGB888 (3 BYTE/pix) 1:RGB565 (1 WORD/pix)*/
+#define JD_FORMAT       0   /* Output pixel format 0:RGB888 (3 BYTE/pix) 1:RGB565 (1 WORD/pix)*/
 #elif defined TJPGD_USING_FORMAT_RGB565
-#define JD_FORMAT		1   /* Output pixel format 1:RGB565 (1 WORD/pix) */
+#define JD_FORMAT       1   /* Output pixel format 1:RGB565 (1 WORD/pix) */
 #endif
 
 #ifdef TJPGD_USING_SCALE
-#define	JD_USE_SCALE	1	/* Use descaling feature for output */
+#define JD_USE_SCALE    1   /* Use descaling feature for output */
 #else
-#define	JD_USE_SCALE	0	
+#define JD_USE_SCALE    0
 #endif
 
 #ifdef TJPGD_USING_TBLCLIP
-#define JD_TBLCLIP		1	/* Use table for saturation (might be a bit faster but increases 1K bytes of code size) */
+#define JD_TBLCLIP      1   /* Use table for saturation (might be a bit faster but increases 1K bytes of code size) */
 #else
-#define	JD_TBLCLIP		0	
+#define JD_TBLCLIP      0
 #endif
 
-#define	JD_SZBUF		TJPGD_INPUT_BUFFER_SIZE	/* Size of stream input buffer */
+#define JD_SZBUF        TJPGD_INPUT_BUFFER_SIZE /* Size of stream input buffer */
 
 /*---------------------------------------------------------------------------*/
 
@@ -34,34 +34,34 @@
 extern "C" {
 #endif
 
-#if defined(_WIN32)	/* Main development platform */
-typedef unsigned char	uint8_t;
-typedef unsigned short	uint16_t;
-typedef short			int16_t;
-typedef unsigned long	uint32_t;
-typedef long			int32_t;
+#if defined(_WIN32) /* Main development platform */
+typedef unsigned char   uint8_t;
+typedef unsigned short  uint16_t;
+typedef short           int16_t;
+typedef unsigned long   uint32_t;
+typedef long            int32_t;
 #else
 #include "stdint.h"
 #endif
 
 /* Error code */
 typedef enum {
-	JDR_OK = 0,	/* 0: Succeeded */
-	JDR_INTR,	/* 1: Interrupted by output function */	
-	JDR_INP,	/* 2: Device error or wrong termination of input stream */
-	JDR_MEM1,	/* 3: Insufficient memory pool for the image */
-	JDR_MEM2,	/* 4: Insufficient stream input buffer */
-	JDR_PAR,	/* 5: Parameter error */
-	JDR_FMT1,	/* 6: Data format error (may be damaged data) */
-	JDR_FMT2,	/* 7: Right format but not supported */
-	JDR_FMT3	/* 8: Not supported JPEG standard */
+    JDR_OK = 0, /* 0: Succeeded */
+    JDR_INTR,   /* 1: Interrupted by output function */
+    JDR_INP,    /* 2: Device error or wrong termination of input stream */
+    JDR_MEM1,   /* 3: Insufficient memory pool for the image */
+    JDR_MEM2,   /* 4: Insufficient stream input buffer */
+    JDR_PAR,    /* 5: Parameter error */
+    JDR_FMT1,   /* 6: Data format error (may be damaged data) */
+    JDR_FMT2,   /* 7: Right format but not supported */
+    JDR_FMT3    /* 8: Not supported JPEG standard */
 } JRESULT;
 
 
 
 /* Rectangular structure */
 typedef struct {
-	uint16_t left, right, top, bottom;
+    uint16_t left, right, top, bottom;
 } JRECT;
 
 
@@ -69,33 +69,33 @@ typedef struct {
 /* Decompressor object structure */
 typedef struct JDEC JDEC;
 struct JDEC {
-	uint16_t dctr;				/* Number of bytes available in the input buffer */
-	uint8_t* dptr;				/* Current data read ptr */
-	uint8_t* inbuf;				/* Bit stream input buffer */
-	uint8_t dmsk;				/* Current bit in the current read byte */
-	uint8_t scale;				/* Output scaling ratio */
-	uint8_t msx, msy;			/* MCU size in unit of block (width, height) */
-	uint8_t qtid[3];			/* Quantization table ID of each component */
-	int16_t dcv[3];				/* Previous DC element of each component */
-	uint16_t nrst;				/* Restart inverval */
-	uint16_t width, height;		/* Size of the input image (pixel) */
-	uint8_t* huffbits[2][2];	/* Huffman bit distribution tables [id][dcac] */
-	uint16_t* huffcode[2][2];	/* Huffman code word tables [id][dcac] */
-	uint8_t* huffdata[2][2];	/* Huffman decoded data tables [id][dcac] */
-	int32_t* qttbl[4];			/* Dequantizer tables [id] */
-	void* workbuf;				/* Working buffer for IDCT and RGB output */
-	uint8_t* mcubuf;			/* Working buffer for the MCU */
-	void* pool;					/* Pointer to available memory pool */
-	uint16_t sz_pool;			/* Size of momory pool (bytes available) */
-	uint16_t (*infunc)(JDEC*, uint8_t*, uint16_t);/* Pointer to jpeg stream input function */
-	void* device;				/* Pointer to I/O device identifiler for the session */
+    unsigned int dctr;          /* Number of bytes available in the input buffer */
+    uint8_t* dptr;              /* Current data read ptr */
+    uint8_t* inbuf;             /* Bit stream input buffer */
+    uint8_t dmsk;               /* Current bit in the current read byte */
+    uint8_t scale;              /* Output scaling ratio */
+    uint8_t msx, msy;           /* MCU size in unit of block (width, height) */
+    uint8_t qtid[3];            /* Quantization table ID of each component */
+    int16_t dcv[3];             /* Previous DC element of each component */
+    uint16_t nrst;              /* Restart inverval */
+    uint16_t width, height;     /* Size of the input image (pixel) */
+    uint8_t* huffbits[2][2];    /* Huffman bit distribution tables [id][dcac] */
+    uint16_t* huffcode[2][2];   /* Huffman code word tables [id][dcac] */
+    uint8_t* huffdata[2][2];    /* Huffman decoded data tables [id][dcac] */
+    int32_t* qttbl[4];          /* Dequantizer tables [id] */
+    void* workbuf;              /* Working buffer for IDCT and RGB output */
+    uint8_t* mcubuf;            /* Working buffer for the MCU */
+    void* pool;                 /* Pointer to available memory pool */
+    unsigned int sz_pool;       /* Size of momory pool (bytes available) */
+    unsigned int (*infunc)(JDEC*, uint8_t*, unsigned int);  /* Pointer to jpeg stream input function */
+    void* device;               /* Pointer to I/O device identifiler for the session */
 };
 
 
 
 /* TJpgDec API functions */
-JRESULT jd_prepare (JDEC*, uint16_t(*)(JDEC*,uint8_t*,uint16_t), void*, uint16_t, void*);
-JRESULT jd_decomp (JDEC*, uint16_t(*)(JDEC*,void*,JRECT*), uint8_t);
+JRESULT jd_prepare (JDEC* jd, unsigned int (*infunc)(JDEC*,uint8_t*,unsigned int), void* pool, unsigned int sz_pool, void* dev);
+JRESULT jd_decomp (JDEC* jd, int (*outfunc)(JDEC*,void*,JRECT*), uint8_t scale);
 
 
 #ifdef __cplusplus

Некоторые файлы не были показаны из-за большого количества измененных файлов