4 * Basic jpeg data structure definitions.
7 * $Id: jpeg.h,v 1.2 2003/10/29 18:24:40 malaterre Exp $
12 /* a function referenced thru EXTERNs: */
14 #define GLOBAL(type) __declspec( dllexport ) type
16 #define GLOBAL(type) type
19 typedef unsigned char Uchar;
20 typedef unsigned short Ushort;
21 typedef unsigned int Uint;
22 typedef FILE * StreamIN ;
26 * The following structure stores basic information about one component.
28 typedef struct JpegComponentInfo
31 * These values are fixed over the whole image.
32 * They are read from the SOF marker.
34 short componentId; /* identifier for this component (0..255) */
35 short componentIndex; /* its index in SOF or cPtr->compInfo[] */
38 * Downsampling is not normally used in lossless JPEG, although
39 * it is permitted by the JPEG standard (DIS). We set all sampling
40 * factors to 1 in this program.
42 short hSampFactor; /* horizontal sampling factor */
43 short vSampFactor; /* vertical sampling factor */
46 * Huffman table selector (0..3). The value may vary
47 * between scans. It is read from the SOS marker.
54 * One of the following structures is created for each huffman coding
55 * table. We use the same structure for encoding and decoding, so there
56 * may be some extra fields for encoding that aren't used in the decoding
59 typedef struct HuffmanTable
62 * These two fields directly represent the contents of a JPEG DHT
69 * This field is used only during compression. It's initialized
70 * FALSE when the table is created, and set TRUE when it's been
76 * The remaining fields are computed from the above to allow more
77 * efficient coding and decoding. These fields should be considered
78 * private to the Huffman compression & decompression modules.
91 * One of the following structures is used to pass around the
92 * compression information.
98 * One of the following structures is used to pass around the
99 * decompression information.
101 typedef struct DecompressInfo
104 * Image width, height, and image data precision (bits/sample)
105 * These fields are set by ReadFileHeader or ReadScanHeader
112 * compInfo[i] describes component that appears i'th in SOF
113 * numComponents is the # of color components in JPEG image.
115 JpegComponentInfo compInfo[4];
119 * *curCompInfo[i] describes component that appears i'th in SOS.
120 * compsInScan is the # of color components in current scan.
122 JpegComponentInfo *curCompInfo[4];
126 * MCUmembership[i] indexes the i'th component of MCU into the
129 short MCUmembership[10];
132 * ptrs to Huffman coding tables, or NULL if not defined
134 HuffmanTable *dcHuffTblPtrs[4];
137 * prediction seletion value (PSV) and point transform parameter (Pt)
143 * In lossless JPEG, restart interval shall be an integer
144 * multiple of the number of MCU in a MCU row.
146 int restartInterval;/* MCUs per restart interval, 0 = no restart */
147 int restartInRows; /*if > 0, MCU rows per restart interval; 0 = no restart*/
150 * these fields are private data for the entropy decoder
152 int restartRowsToGo; /* MCUs rows left in this restart interval */
153 short nextRestartNum; /* # of next RSTn marker (0..7) */
155 int error; /* an ERROR flag */
161 *--------------------------------------------------------------
165 * Swap the contents stored in a and b.
166 * "type" is the variable type of a and b.
169 * The values in a and b are swapped.
174 *--------------------------------------------------------------
176 #define swap(type,a,b) {type c; c=(a); (a)=(b); (b)=c;}
178 #define MEMSET(s,c,n) memset((void *)(s),(int)(c),(int)(n))
179 #define MEMCPY(s1,s2,n) memcpy((void *)(s1),(void *)(s2),(int)(n))
182 * Lossless JPEG specifies data precision to be from 2 to 16 bits/sample.
184 #define MinPrecisionBits 2
185 #define MaxPrecisionBits 16
186 #define MinPrecisionValue 2
187 #define MaxPrecisionValue 65535