roo_display
API Documentation for roo_display
Loading...
Searching...
No Matches
tjpgd.h
Go to the documentation of this file.
1/*----------------------------------------------------------------------------/
2/ TJpgDec - Tiny JPEG Decompressor R0.03 include file (C)ChaN, 2021
3/----------------------------------------------------------------------------*/
4#ifndef DEF_TJPGDEC
5#define DEF_TJPGDEC
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11#include "tjpgdcnf.h"
12#include <string.h>
13
14#if defined(_WIN32) /* VC++ or some compiler without stdint.h */
15typedef unsigned char uint8_t;
16typedef unsigned short uint16_t;
17typedef short int16_t;
18typedef unsigned long uint32_t;
19typedef long int32_t;
20#else /* Embedded platform */
21#include <stdint.h>
22#endif
23
24#if JD_FASTDECODE >= 1
25typedef int16_t jd_yuv_t;
26#else
27typedef uint8_t jd_yuv_t;
28#endif
29
30
31/* Error code */
32typedef enum {
33 JDR_OK = 0, /* 0: Succeeded */
34 JDR_INTR, /* 1: Interrupted by output function */
35 JDR_INP, /* 2: Device error or wrong termination of input stream */
36 JDR_MEM1, /* 3: Insufficient memory pool for the image */
37 JDR_MEM2, /* 4: Insufficient stream input buffer */
38 JDR_PAR, /* 5: Parameter error */
39 JDR_FMT1, /* 6: Data format error (may be broken data) */
40 JDR_FMT2, /* 7: Right format but not supported */
41 JDR_FMT3 /* 8: Not supported JPEG standard */
43
44
45
46/* Rectangular region in the output image */
47typedef struct {
48 uint16_t left; /* Left end */
49 uint16_t right; /* Right end */
50 uint16_t top; /* Top end */
51 uint16_t bottom; /* Bottom end */
52} JRECT;
53
54
55
56/* Decompressor object structure */
57typedef struct JDEC JDEC;
58struct JDEC {
59 size_t dctr; /* Number of bytes available in the input buffer */
60 uint8_t* dptr; /* Current data read ptr */
61 uint8_t* inbuf; /* Bit stream input buffer */
62 uint8_t dbit; /* Number of bits availavble in wreg or reading bit mask */
63 uint8_t scale; /* Output scaling ratio */
64 uint8_t msx, msy; /* MCU size in unit of block (width, height) */
65 uint8_t qtid[3]; /* Quantization table ID of each component, Y, Cb, Cr */
66 uint8_t ncomp; /* Number of color components 1:grayscale, 3:color */
67 int16_t dcv[3]; /* Previous DC element of each component */
68 uint16_t nrst; /* Restart inverval */
69 uint16_t width, height; /* Size of the input image (pixel) */
70 uint8_t* huffbits[2][2]; /* Huffman bit distribution tables [id][dcac] */
71 uint16_t* huffcode[2][2]; /* Huffman code word tables [id][dcac] */
72 uint8_t* huffdata[2][2]; /* Huffman decoded data tables [id][dcac] */
73 int32_t* qttbl[4]; /* Dequantizer tables [id] */
74#if JD_FASTDECODE >= 1
75 uint32_t wreg; /* Working shift register */
76 uint8_t marker; /* Detected marker (0:None) */
77#if JD_FASTDECODE == 2
78 uint8_t longofs[2][2]; /* Table offset of long code [id][dcac] */
79 uint16_t* hufflut_ac[2]; /* Fast huffman decode tables for AC short code [id] */
80 uint8_t* hufflut_dc[2]; /* Fast huffman decode tables for DC short code [id] */
81#endif
82#endif
83 void* workbuf; /* Working buffer for IDCT and RGB output */
84 jd_yuv_t* mcubuf; /* Working buffer for the MCU */
85 void* pool; /* Pointer to available memory pool */
86 size_t sz_pool; /* Size of momory pool (bytes available) */
87 size_t (*infunc)(JDEC*, uint8_t*, size_t); /* Pointer to jpeg stream input function */
88 void* device; /* Pointer to I/O device identifiler for the session */
89};
90
91
92
93/* TJpgDec API functions */
94JRESULT jd_prepare (JDEC* jd, size_t (*infunc)(JDEC*,uint8_t*,size_t), void* pool, size_t sz_pool, void* dev);
95JRESULT jd_decomp (JDEC* jd, int (*outfunc)(JDEC*,void*,JRECT*), uint8_t scale);
96
97
98#ifdef __cplusplus
99}
100#endif
101
102#endif /* _TJPGDEC */
Definition tjpgd.h:58
uint8_t msx
Definition tjpgd.h:64
uint8_t * huffdata[2][2]
Definition tjpgd.h:72
size_t dctr
Definition tjpgd.h:59
size_t(* infunc)(JDEC *, uint8_t *, size_t)
Definition tjpgd.h:87
void * device
Definition tjpgd.h:88
uint16_t width
Definition tjpgd.h:69
uint16_t * huffcode[2][2]
Definition tjpgd.h:71
uint16_t * hufflut_ac[2]
Definition tjpgd.h:79
uint8_t msy
Definition tjpgd.h:64
uint16_t nrst
Definition tjpgd.h:68
uint8_t scale
Definition tjpgd.h:63
uint8_t * hufflut_dc[2]
Definition tjpgd.h:80
uint16_t height
Definition tjpgd.h:69
uint8_t * dptr
Definition tjpgd.h:60
jd_yuv_t * mcubuf
Definition tjpgd.h:84
int16_t dcv[3]
Definition tjpgd.h:67
uint8_t ncomp
Definition tjpgd.h:66
uint8_t * inbuf
Definition tjpgd.h:61
uint8_t qtid[3]
Definition tjpgd.h:65
uint8_t longofs[2][2]
Definition tjpgd.h:78
void * workbuf
Definition tjpgd.h:83
uint8_t marker
Definition tjpgd.h:76
uint32_t wreg
Definition tjpgd.h:75
size_t sz_pool
Definition tjpgd.h:86
uint8_t dbit
Definition tjpgd.h:62
int32_t * qttbl[4]
Definition tjpgd.h:73
void * pool
Definition tjpgd.h:85
uint8_t * huffbits[2][2]
Definition tjpgd.h:70
Definition tjpgd.h:47
uint16_t top
Definition tjpgd.h:50
uint16_t bottom
Definition tjpgd.h:51
uint16_t right
Definition tjpgd.h:49
uint16_t left
Definition tjpgd.h:48
int16_t jd_yuv_t
Definition tjpgd.h:25
JRESULT jd_prepare(JDEC *jd, size_t(*infunc)(JDEC *, uint8_t *, size_t), void *pool, size_t sz_pool, void *dev)
Definition tjpgd.c:962
JRESULT jd_decomp(JDEC *jd, int(*outfunc)(JDEC *, void *, JRECT *), uint8_t scale)
Definition tjpgd.c:1118
JRESULT
Definition tjpgd.h:32
@ JDR_INTR
Definition tjpgd.h:34
@ JDR_FMT3
Definition tjpgd.h:41
@ JDR_MEM2
Definition tjpgd.h:37
@ JDR_INP
Definition tjpgd.h:35
@ JDR_OK
Definition tjpgd.h:33
@ JDR_MEM1
Definition tjpgd.h:36
@ JDR_PAR
Definition tjpgd.h:38
@ JDR_FMT2
Definition tjpgd.h:40
@ JDR_FMT1
Definition tjpgd.h:39