STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
GUI_JPEG_Private.h
Go to the documentation of this file.
1 /*********************************************************************
2 * SEGGER Microcontroller GmbH & Co. KG *
3 * Solutions for real time microcontroller applications *
4 **********************************************************************
5 * *
6 * (c) 1996 - 2015 SEGGER Microcontroller GmbH & Co. KG *
7 * *
8 * Internet: www.segger.com Support: support@segger.com *
9 * *
10 **********************************************************************
11 
12 ** emWin V5.28 - Graphical user interface for embedded applications **
13 All Intellectual Property rights in the Software belongs to SEGGER.
14 emWin is protected by international copyright laws. Knowledge of the
15 source code may not be used to write a similar product. This file may
16 only be used in accordance with the following terms:
17 
18 The software has been licensed to STMicroelectronics International
19 N.V. a Dutch company with a Swiss branch and its headquarters in Plan-
20 les-Ouates, Geneva, 39 Chemin du Champ des Filles, Switzerland for the
21 purposes of creating libraries for ARM Cortex-M-based 32-bit microcon_
22 troller products commercialized by Licensee only, sublicensed and dis_
23 tributed under the terms and conditions of the End User License Agree_
24 ment supplied by STMicroelectronics International N.V.
25 Full source code is available at: www.segger.com
26 
27 We appreciate your understanding and fairness.
28 ----------------------------------------------------------------------
29 File : GUI_JPEG_Private.h
30 Purpose : Private header
31 ----------------------------------------------------------------------
32 
33 Explanation of terms:
34 
35  Component - Color channel, e.g., Red or Luminance.
36  Sample - Single component value (i.e., one number in the image data).
37  Coefficient - Frequency coefficient (a DCT transform output number).
38  Block - 8x8 group of samples or coefficients.
39  MCU - (Minimum Coded Unit) is an interleaved set of blocks of size
40  determined by the sampling factors, or a single block in a
41  noninterleaved scan.
42 
43 ---------------------------END-OF-HEADER------------------------------
44 */
45 
46 #ifndef GUI_JPEG_PRIVATE_H
47 #define GUI_JPEG_PRIVATE_H
48 
49 /*********************************************************************
50 *
51 * Defines
52 *
53 **********************************************************************
54 */
55 #define JPEG_LOCK_H(h) (GUI_JPEG_DCONTEXT *)GUI_LOCK_H(h)
56 
57 /*********************************************************************
58 *
59 * Scan types
60 */
61 #define GRAYSCALE 0
62 #define YH1V1 1
63 #define YH2V1 2
64 #define YH1V2 3
65 #define YH2V2 4
66 
67 /*********************************************************************
68 *
69 * Maximum number of...
70 */
71 #define MAX_COMPONENTS 4
72 #define MAX_HUFFTABLES 8
73 #define MAX_QUANTTABLES 4
74 #define MAX_COMPSINSCAN 4
75 #define MAX_BLOCKSPERMCU 10
76 
77 /*********************************************************************
78 *
79 * Marker definitions
80 */
81 #define M_SOF0 0xc0 /* Start Of Frame */
82 #define M_SOF1 0xc1
83 #define M_SOF2 0xc2
84 #define M_SOF3 0xc3
85 
86 #define M_SOF5 0xc5
87 #define M_SOF6 0xc6
88 #define M_SOF7 0xc7
89 
90 #define M_JPG 0xc8
91 #define M_SOF9 0xc9
92 #define M_SOF10 0xca
93 #define M_SOF11 0xcb
94 
95 #define M_SOF13 0xcd
96 #define M_SOF14 0xce
97 #define M_SOF15 0xcf
98 
99 #define M_DHT 0xc4 /* Define Huffman Table */
100 
101 #define M_DAC 0xcc /* Define Arithmetic Coding Table */
102 
103 #define M_RST0 0xd0
104 #define M_RST1 0xd1
105 #define M_RST2 0xd2
106 #define M_RST3 0xd3
107 #define M_RST4 0xd4
108 #define M_RST5 0xd5
109 #define M_RST6 0xd6
110 #define M_RST7 0xd7
111 
112 #define M_SOI 0xd8 /* Start Of Image */
113 #define M_EOI 0xd9
114 #define M_SOS 0xda /* Start Of Scan */
115 #define M_DQT 0xdb /* Define Quantisation Table */
116 #define M_DRI 0xdd /* Define Restart Interval */
117 
118 #define M_APP0 0xe0 /* Application Usage */
119 #define M_APP14 0xee /* Adobe marker */
120 
121 #define M_TEM 0x01
122 
123 #define ADOBE_TRANSFORM_RGB 0
124 #define ADOBE_TRANSFORM_YCBCR 1
125 
126 /*********************************************************************
127 *
128 * Types
129 *
130 **********************************************************************
131 */
132 /* Default parameter structure for reading data from memory */
133 typedef struct {
134  const U8 * pFileData;
137 
138 /* Huffman table definition */
139 typedef struct {
140  unsigned aLookUp[256];
141  U8 aCodeSize[256];
142  unsigned aTree[512];
143 } HUFF_TABLE;
144 
145 /* Coefficient buffer used for progressive JPEGs */
146 typedef struct {
149  unsigned BlockSize;
151 } COEFF_BUFFER;
152 
154 
156  /* Function pointer for drawing one line of completely decoded pixels */
157  void (* pfWritePixels)(int x0, int y0, GUI_JPEG_DCONTEXT * pContext, GUI_COLOR (* pfGetColor)(const U8 ** ppData, unsigned SkipCnt), tLCDDEV_Color2Index * pfColor2Index);
158  /* Function pointer for reading one byte */
159  int (* pfGetU8)(GUI_JPEG_DCONTEXT * pContext, U8 * pByte);
160 
161  GUI_GET_DATA_FUNC * pfGetData; /* 'GetData' Function pointer */
162  void * pParam; /* Pointer passed to 'GetData' function */
163  U32 Off; /* Data pointer */
164  /* Image size */
167  /* Input buffer */
168  const U8 * pBuffer;
171  U8 aStuff[4]; /* Stuff back buffer */
172  U8 NumBytesStuffed; /* Number of stuffed bytes */
173  /* Bit buffer */
176  /* Huffman tables */
177  U8 aHuffNumTableAvail[MAX_HUFFTABLES];
178  U8 aaHuffNum[MAX_HUFFTABLES][17]; /* Pointer to number of Huffman codes per bit size */
179  U8 aaHuffVal[MAX_HUFFTABLES][256]; /* Pointer to Huffman codes */
183  /* Quantization tables */
184  U16 aaQuantTbl[MAX_QUANTTABLES][64];
185  U16 * apQuantTbl[MAX_QUANTTABLES];
186  /* Component information */
187  U8 NumCompsPerFrame; /* Number of components per frame */
188  U8 aCompHSamp[MAX_COMPONENTS]; /* Component's horizontal sampling factor */
189  U8 aCompVSamp[MAX_COMPONENTS]; /* Component's vertical sampling factor */
190  U8 aCompQuant[MAX_COMPONENTS]; /* Component's quantization table selector */
191  U8 aCompId [MAX_COMPONENTS]; /* Component's ID */
192  U8 NumCompsPerScan; /* Number of components per scan */
193  U8 aCompList[MAX_COMPSINSCAN]; /* Components in this scan */
194  U8 aCompDC_Tab[MAX_COMPONENTS]; /* Component's DC Huffman coding table selector */
195  U8 aCompAC_Tab[MAX_COMPONENTS]; /* Component's AC Huffman coding table selector */
196  unsigned * apComponent[MAX_BLOCKSPERMCU]; /* Points into the table aLastDC_Val[] */
197  unsigned aLastDC_Val[MAX_COMPONENTS]; /* Table of last DC values */
198  /* Data used for progressive scans */
199  U8 SpectralStart; /* Spectral selection start */
200  U8 SpectralEnd; /* Spectral selection end */
201  U8 SuccessiveLow; /* Successive approximation low */
202  U8 SuccessiveHigh; /* Successive approximation high */
203  COEFF_BUFFER aDC_Coeffs[MAX_COMPONENTS]; /* DC coefficient buffer for progressive scan */
204  COEFF_BUFFER aAC_Coeffs[MAX_COMPONENTS]; /* AC coefficient buffer for progressive scan */
205  int aBlockY_MCU[MAX_COMPONENTS]; /* */
207  /* Common */
209  U8 IsProgressive; /* Flag is set to 1 if JPEG is progressive */
210  U8 ScanType; /* Gray, Yh1v1, Yh1v2, Yh2v1, Yh2v2 */
211  int MaxMCUsPerRow; /* Maximum number of MCUs per row */
212  int MaxMCUsPerCol; /* Maximum number of MCUs per column */
213  int MaxBlocksPerMCU; /* Maximum number of blocks per MCU */
214  int MaxBlocksPerRow; /* Maximum number of blocks per row */
215  int MaxMCU_xSize; /* MCU's max. X size in pixels */
216  int MaxMCU_ySize; /* MCU's max. Y size in pixels */
217  int DestBytesPerPixel; /* 4 (RGB) or 1 (Y) */
218  int DestBytesPerScanline; /* Rounded up */
219  int RealDestBytesPerScanline; /* Actual bytes */
220  int EOB_Run; /* 'End Of Band' run */
227  int aMCU_Org[MAX_BLOCKSPERMCU];
228  /* Block buffer */
231  /* Sample buffer */
234  /* Status */
235  int TotalLinesLeft; /* Total number of lines left in image */
236  int MCULinesLeft; /* Total number of lines left in current MCU */
237  /* Output buffer(s) */
238  GUI_HMEM hScanLine0; /* Buffer 0 */
239  GUI_HMEM hScanLine1; /* Buffer 1, only used for V2 sampling factors */
241  /* Arrays used for converting YCbCr to RGB */
242  int aCRR[256];
243  int aCBB[256];
244  I32 aCRG[256];
245  I32 aCBG[256];
246  /* Banding */
247  U8 BandingRequired; /* Flag if banding is required */
248  unsigned NumBands; /* Number of required bands for drawing the complete frame */
249  int NumBlocksPerBand; /* Number of vertical blocks per band */
251  int aFirstBlockOfBand[MAX_COMPONENTS];
252  int bpp;
253 };
254 
255 /*********************************************************************
256 *
257 * Private interface
258 *
259 **********************************************************************
260 */
262 int GUI_JPEG__DecodeLine (GUI_JPEG_DCONTEXT * pContext);
264 void GUI_JPEG__Free (GUI_JPEG_DCONTEXT * pContext);
265 GUI_COLOR GUI_JPEG__GetColorGray (const U8 ** ppData, unsigned SkipCnt);
266 GUI_COLOR GUI_JPEG__GetColorRGB (const U8 ** ppData, unsigned SkipCnt);
267 int GUI_JPEG__GetData (void * p, const U8 ** ppData, unsigned NumBytesReq, U32 Off);
268 int GUI_JPEG__InitDraw (GUI_HMEM hContext);
269 int GUI_JPEG__ReadUntilSOF (GUI_HMEM hContext);
270 void GUI_JPEG__SetNextBand (GUI_JPEG_DCONTEXT * pContext);
271 int GUI_JPEG__SkipLine (GUI_JPEG_DCONTEXT * pContext);
272 int GUI_JPEG__GetInfoEx (GUI_HMEM hContext, GUI_JPEG_INFO * pInfo);
273 
274 #endif
GUI_COLOR GUI_JPEG__GetColorGray(const U8 **ppData, unsigned SkipCnt)
int GUI_JPEG__DecodeProgressiveBanding(GUI_JPEG_DCONTEXT *pContext)
int GUI_JPEG__DecodeLine(GUI_JPEG_DCONTEXT *pContext)
#define U32
Definition: Global.h:50
unsigned BlockSize
#define MAX_BLOCKSPERMCU
int GUI_JPEG__InitDraw(GUI_HMEM hContext)
void GUI_JPEG__Free(GUI_JPEG_DCONTEXT *pContext)
GUI_COLOR GUI_JPEG__GetColorRGB(const U8 **ppData, unsigned SkipCnt)
#define MAX_HUFFTABLES
#define MAX_COMPONENTS
LCD_COLOR GUI_COLOR
Definition: GUI_Type.h:50
GUI_GET_DATA_FUNC * pfGetData
int GUI_JPEG__AllocBandingCoeffBuffer(GUI_HMEM hContext)
int GUI_JPEG__GetInfoEx(GUI_HMEM hContext, GUI_JPEG_INFO *pInfo)
const U8 * pFileData
#define MAX_COMPSINSCAN
int GUI_GET_DATA_FUNC(void *p, const U8 **ppData, unsigned NumBytes, U32 Off)
Definition: GUI.h:497
#define GUI_HMEM
Definition: GUI_Type.h:565
int GUI_JPEG__SkipLine(GUI_JPEG_DCONTEXT *pContext)
#define MAX_QUANTTABLES
int GUI_JPEG__ReadUntilSOF(GUI_HMEM hContext)
void GUI_JPEG__SetNextBand(GUI_JPEG_DCONTEXT *pContext)
#define U16
Definition: Global.h:47
int GUI_JPEG__GetData(void *p, const U8 **ppData, unsigned NumBytesReq, U32 Off)
unsigned int tLCDDEV_Color2Index(LCD_COLOR Color)
Definition: LCD.h:126
#define I32
Definition: Global.h:59
#define U8
Definition: Global.h:44