KSM edits to RA8875

Dependents:   Liz_Test_Code

Committer:
kerrysmartin
Date:
Thu Jul 11 14:02:46 2019 +0000
Revision:
177:8620cdfcdbf2
Parent:
167:8aa3fb2a5a31
Initial check in

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WiredHome 167:8aa3fb2a5a31 1 /// @page TinyJPEGDecompressor_Copyright Tiny JPEG Decompressor
WiredHome 167:8aa3fb2a5a31 2 ///
WiredHome 167:8aa3fb2a5a31 3 /// TJpgDec - Tiny JPEG Decompressor R0.01b (C)ChaN, 2012
WiredHome 167:8aa3fb2a5a31 4 ///-----------------------------------------------------------------------------/
WiredHome 167:8aa3fb2a5a31 5 /// The TJpgDec is a generic JPEG decompressor module for tiny embedded systems.
WiredHome 167:8aa3fb2a5a31 6 /// This is a free software that opened for education, research and commercial
WiredHome 167:8aa3fb2a5a31 7 /// developments under license policy of following terms.
WiredHome 167:8aa3fb2a5a31 8 ///
WiredHome 167:8aa3fb2a5a31 9 /// @copyright © 2012, ChaN, all right reserved.
WiredHome 115:c9862fd0c689 10 ///
WiredHome 167:8aa3fb2a5a31 11 /// * The TJpgDec module is a free software and there is NO WARRANTY.
WiredHome 167:8aa3fb2a5a31 12 /// * No restriction on use. You can use, modify and redistribute it for
WiredHome 167:8aa3fb2a5a31 13 /// personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
WiredHome 167:8aa3fb2a5a31 14 /// * Redistributions of source code must retain the above copyright notice.
WiredHome 167:8aa3fb2a5a31 15 ///
WiredHome 167:8aa3fb2a5a31 16 ///-----------------------------------------------------------------------------/
WiredHome 167:8aa3fb2a5a31 17 /// Oct 04,'11 R0.01 First release.
WiredHome 167:8aa3fb2a5a31 18 /// Feb 19,'12 R0.01a Fixed decompression fails when scan starts with an escape seq.
WiredHome 167:8aa3fb2a5a31 19 /// Sep 03,'12 R0.01b Added JD_TBLCLIP option.
WiredHome 167:8aa3fb2a5a31 20 ///----------------------------------------------------------------------------*/
WiredHome 115:c9862fd0c689 21
WiredHome 115:c9862fd0c689 22 #ifndef GraphicsDisplayJPEG_H
WiredHome 115:c9862fd0c689 23 #define GraphicsDisplayJPEG_H
WiredHome 115:c9862fd0c689 24
WiredHome 115:c9862fd0c689 25 /*----------------------------------------------------------------------------/
WiredHome 115:c9862fd0c689 26 / TJpgDec - Tiny JPEG Decompressor include file (C)ChaN, 2012
WiredHome 115:c9862fd0c689 27 /----------------------------------------------------------------------------*/
WiredHome 115:c9862fd0c689 28 #ifndef _TJPGDEC
WiredHome 115:c9862fd0c689 29 #define _TJPGDEC
WiredHome 115:c9862fd0c689 30
WiredHome 115:c9862fd0c689 31 /*---------------------------------------------------------------------------*/
WiredHome 115:c9862fd0c689 32 /* System Configurations */
WiredHome 115:c9862fd0c689 33
WiredHome 115:c9862fd0c689 34 #define JD_SZBUF 512 /* Size of stream input buffer */
WiredHome 115:c9862fd0c689 35 #define JD_FORMAT 1 /* Output pixel format 0:RGB888 (3 BYTE/pix), 1:RGB565 (1 WORD/pix) */
WiredHome 115:c9862fd0c689 36 #define JD_USE_SCALE 1 /* Use descaling feature for output */
WiredHome 115:c9862fd0c689 37 #define JD_TBLCLIP 1 /* Use table for saturation (might be a bit faster but increases 1K bytes of code size) */
WiredHome 115:c9862fd0c689 38
WiredHome 115:c9862fd0c689 39 /*---------------------------------------------------------------------------*/
WiredHome 115:c9862fd0c689 40
WiredHome 115:c9862fd0c689 41 #include "DisplayDefs.h"
WiredHome 115:c9862fd0c689 42
WiredHome 125:7a0b70f56550 43 /// Error code results for the jpeg engine
WiredHome 115:c9862fd0c689 44 typedef enum {
WiredHome 125:7a0b70f56550 45 JDR_OK = noerror, ///< 0: Succeeded
WiredHome 125:7a0b70f56550 46 JDR_INTR = external_abort, ///< 1: Interrupted by output function
WiredHome 125:7a0b70f56550 47 JDR_INP = bad_parameter, ///< 2: Device error or wrong termination of input stream
WiredHome 125:7a0b70f56550 48 JDR_MEM1 = not_enough_ram, ///< 3: Insufficient memory pool for the image
WiredHome 125:7a0b70f56550 49 JDR_MEM2 = not_enough_ram, ///< 4: Insufficient stream input buffer
WiredHome 125:7a0b70f56550 50 JDR_PAR = bad_parameter, ///< 5: Parameter error
WiredHome 125:7a0b70f56550 51 JDR_FMT1 = not_supported_format, ///< 6: Data format error (may be damaged data)
WiredHome 125:7a0b70f56550 52 JDR_FMT2 = not_supported_format, ///< 7: Right format but not supported
WiredHome 125:7a0b70f56550 53 JDR_FMT3 = not_supported_format ///< 8: Not supported JPEG standard
WiredHome 115:c9862fd0c689 54 } JRESULT;
WiredHome 115:c9862fd0c689 55
WiredHome 115:c9862fd0c689 56
WiredHome 115:c9862fd0c689 57
WiredHome 125:7a0b70f56550 58 /// Rectangular structure definition for the jpeg engine
WiredHome 115:c9862fd0c689 59 typedef struct {
WiredHome 125:7a0b70f56550 60 loc_t left; ///< left coord
WiredHome 125:7a0b70f56550 61 loc_t right; ///< right coord
WiredHome 125:7a0b70f56550 62 loc_t top; ///< top coord
WiredHome 125:7a0b70f56550 63 loc_t bottom; ///< bottom coord
WiredHome 115:c9862fd0c689 64 } JRECT;
WiredHome 115:c9862fd0c689 65
WiredHome 115:c9862fd0c689 66
WiredHome 125:7a0b70f56550 67 /// Decompressor object structure for the jpeg engine
WiredHome 125:7a0b70f56550 68 typedef struct JDEC JDEC;
WiredHome 115:c9862fd0c689 69
WiredHome 125:7a0b70f56550 70 /// Internal structure for the jpeg engine
WiredHome 115:c9862fd0c689 71 struct JDEC {
WiredHome 125:7a0b70f56550 72 uint16_t dctr; ///< Number of bytes available in the input buffer
WiredHome 125:7a0b70f56550 73 uint8_t * dptr; ///< Current data read ptr
WiredHome 125:7a0b70f56550 74 uint8_t * inbuf; ///< Bit stream input buffer
WiredHome 125:7a0b70f56550 75 uint8_t dmsk; ///< Current bit in the current read byte
WiredHome 125:7a0b70f56550 76 uint8_t scale; ///< Output scaling ratio
WiredHome 125:7a0b70f56550 77 uint8_t msx; ///< MCU size in unit of block (width, ...)
WiredHome 125:7a0b70f56550 78 uint8_t msy; ///< MCU size in unit of block (..., height)
WiredHome 125:7a0b70f56550 79 uint8_t qtid[3]; ///< Quantization table ID of each component
WiredHome 125:7a0b70f56550 80 int16_t dcv[3]; ///< Previous DC element of each component
WiredHome 125:7a0b70f56550 81 uint16_t nrst; ///< Restart inverval
WiredHome 125:7a0b70f56550 82 uint16_t width; ///< Size of the input image (pixel width, ...)
WiredHome 125:7a0b70f56550 83 uint16_t height; ///< Size of the input image (..., pixel height)
WiredHome 125:7a0b70f56550 84 uint8_t * huffbits[2][2]; ///< Huffman bit distribution tables [id][dcac]
WiredHome 125:7a0b70f56550 85 uint16_t * huffcode[2][2]; ///< Huffman code word tables [id][dcac]
WiredHome 125:7a0b70f56550 86 uint8_t * huffdata[2][2]; ///< Huffman decoded data tables [id][dcac]
WiredHome 125:7a0b70f56550 87 int32_t * qttbl[4]; ///< Dequaitizer tables [id]
WiredHome 125:7a0b70f56550 88 void * workbuf; ///< Working buffer for IDCT and RGB output
WiredHome 125:7a0b70f56550 89 uint8_t * mcubuf; ///< Working buffer for the MCU
WiredHome 125:7a0b70f56550 90 void * pool; ///< Pointer to available memory pool
WiredHome 125:7a0b70f56550 91 uint16_t sz_pool; ///< Size of momory pool (bytes available)
WiredHome 125:7a0b70f56550 92 uint16_t (*infunc)(JDEC * jd, uint8_t * buffer, uint16_t bufsize); ///< Pointer to jpeg stream input function
WiredHome 125:7a0b70f56550 93 void * device; ///< Pointer to I/O device identifiler for the session
WiredHome 115:c9862fd0c689 94 };
WiredHome 115:c9862fd0c689 95
WiredHome 115:c9862fd0c689 96
WiredHome 115:c9862fd0c689 97 #endif /* _TJPGDEC */
WiredHome 115:c9862fd0c689 98
WiredHome 115:c9862fd0c689 99 #endif // GraphicsDisplayJPEG_H