4 * Basic jpeg data structure definitions.
7 * $Id: jpeg.h,v 1.3 2004/01/07 10:07:28 regrain Exp $
14 /* a function referenced thru EXTERNs: */
16 #define GLOBAL(type) __declspec( dllexport ) type
18 #define GLOBAL(type) type
21 typedef unsigned char Uchar;
22 typedef unsigned short Ushort;
23 typedef unsigned int Uint;
24 typedef FILE * StreamIN ;
28 * The following structure stores basic information about one component.
30 typedef struct JpegComponentInfo
33 * These values are fixed over the whole image.
34 * They are read from the SOF marker.
36 short componentId; /* identifier for this component (0..255) */
37 short componentIndex; /* its index in SOF or cPtr->compInfo[] */
40 * Downsampling is not normally used in lossless JPEG, although
41 * it is permitted by the JPEG standard (DIS). We set all sampling
42 * factors to 1 in this program.
44 short hSampFactor; /* horizontal sampling factor */
45 short vSampFactor; /* vertical sampling factor */
48 * Huffman table selector (0..3). The value may vary
49 * between scans. It is read from the SOS marker.
56 * One of the following structures is created for each huffman coding
57 * table. We use the same structure for encoding and decoding, so there
58 * may be some extra fields for encoding that aren't used in the decoding
61 typedef struct HuffmanTable
64 * These two fields directly represent the contents of a JPEG DHT
71 * This field is used only during compression. It's initialized
72 * FALSE when the table is created, and set TRUE when it's been
78 * The remaining fields are computed from the above to allow more
79 * efficient coding and decoding. These fields should be considered
80 * private to the Huffman compression & decompression modules.
93 * One of the following structures is used to pass around the
94 * compression information.
100 * One of the following structures is used to pass around the
101 * decompression information.
103 typedef struct DecompressInfo
106 * Image width, height, and image data precision (bits/sample)
107 * These fields are set by ReadFileHeader or ReadScanHeader
114 * compInfo[i] describes component that appears i'th in SOF
115 * numComponents is the # of color components in JPEG image.
117 JpegComponentInfo compInfo[4];
121 * *curCompInfo[i] describes component that appears i'th in SOS.
122 * compsInScan is the # of color components in current scan.
124 JpegComponentInfo *curCompInfo[4];
128 * MCUmembership[i] indexes the i'th component of MCU into the
131 short MCUmembership[10];
134 * ptrs to Huffman coding tables, or NULL if not defined
136 HuffmanTable *dcHuffTblPtrs[4];
139 * prediction seletion value (PSV) and point transform parameter (Pt)
145 * In lossless JPEG, restart interval shall be an integer
146 * multiple of the number of MCU in a MCU row.
148 int restartInterval;/* MCUs per restart interval, 0 = no restart */
149 int restartInRows; /*if > 0, MCU rows per restart interval; 0 = no restart*/
152 * these fields are private data for the entropy decoder
154 int restartRowsToGo; /* MCUs rows left in this restart interval */
155 short nextRestartNum; /* # of next RSTn marker (0..7) */
157 int error; /* an ERROR flag */
163 *--------------------------------------------------------------
167 * Swap the contents stored in a and b.
168 * "type" is the variable type of a and b.
171 * The values in a and b are swapped.
176 *--------------------------------------------------------------
178 #define gdcmSWAP(type,a,b) {type c; c=(a); (a)=(b); (b)=c;}
180 #define MEMSET(s,c,n) memset((void *)(s),(int)(c),(int)(n))
181 #define MEMCPY(s1,s2,n) memcpy((void *)(s1),(void *)(s2),(int)(n))
184 * Lossless JPEG specifies data precision to be from 2 to 16 bits/sample.
186 #define MinPrecisionBits 2
187 #define MaxPrecisionBits 16
188 #define MinPrecisionValue 2
189 #define MaxPrecisionValue 65535