4 * Basic jpeg data structure definitions.
7 * $Id: jpeg.h,v 1.1 2003/10/21 12:08:54 jpr Exp $
12 typedef unsigned char Uchar;
13 typedef unsigned short Ushort;
14 typedef unsigned int Uint;
15 typedef FILE * StreamIN ;
19 * The following structure stores basic information about one component.
21 typedef struct JpegComponentInfo
24 * These values are fixed over the whole image.
25 * They are read from the SOF marker.
27 short componentId; /* identifier for this component (0..255) */
28 short componentIndex; /* its index in SOF or cPtr->compInfo[] */
31 * Downsampling is not normally used in lossless JPEG, although
32 * it is permitted by the JPEG standard (DIS). We set all sampling
33 * factors to 1 in this program.
35 short hSampFactor; /* horizontal sampling factor */
36 short vSampFactor; /* vertical sampling factor */
39 * Huffman table selector (0..3). The value may vary
40 * between scans. It is read from the SOS marker.
47 * One of the following structures is created for each huffman coding
48 * table. We use the same structure for encoding and decoding, so there
49 * may be some extra fields for encoding that aren't used in the decoding
52 typedef struct HuffmanTable
55 * These two fields directly represent the contents of a JPEG DHT
62 * This field is used only during compression. It's initialized
63 * FALSE when the table is created, and set TRUE when it's been
69 * The remaining fields are computed from the above to allow more
70 * efficient coding and decoding. These fields should be considered
71 * private to the Huffman compression & decompression modules.
84 * One of the following structures is used to pass around the
85 * compression information.
91 * One of the following structures is used to pass around the
92 * decompression information.
94 typedef struct DecompressInfo
97 * Image width, height, and image data precision (bits/sample)
98 * These fields are set by ReadFileHeader or ReadScanHeader
105 * compInfo[i] describes component that appears i'th in SOF
106 * numComponents is the # of color components in JPEG image.
108 JpegComponentInfo compInfo[4];
112 * *curCompInfo[i] describes component that appears i'th in SOS.
113 * compsInScan is the # of color components in current scan.
115 JpegComponentInfo *curCompInfo[4];
119 * MCUmembership[i] indexes the i'th component of MCU into the
122 short MCUmembership[10];
125 * ptrs to Huffman coding tables, or NULL if not defined
127 HuffmanTable *dcHuffTblPtrs[4];
130 * prediction seletion value (PSV) and point transform parameter (Pt)
136 * In lossless JPEG, restart interval shall be an integer
137 * multiple of the number of MCU in a MCU row.
139 int restartInterval;/* MCUs per restart interval, 0 = no restart */
140 int restartInRows; /*if > 0, MCU rows per restart interval; 0 = no restart*/
143 * these fields are private data for the entropy decoder
145 int restartRowsToGo; /* MCUs rows left in this restart interval */
146 short nextRestartNum; /* # of next RSTn marker (0..7) */
148 int error; /* an ERROR flag */
154 *--------------------------------------------------------------
158 * Swap the contents stored in a and b.
159 * "type" is the variable type of a and b.
162 * The values in a and b are swapped.
167 *--------------------------------------------------------------
169 #define swap(type,a,b) {type c; c=(a); (a)=(b); (b)=c;}
171 #define MEMSET(s,c,n) memset((void *)(s),(int)(c),(int)(n))
172 #define MEMCPY(s1,s2,n) memcpy((void *)(s1),(void *)(s2),(int)(n))
175 * Lossless JPEG specifies data precision to be from 2 to 16 bits/sample.
177 #define MinPrecisionBits 2
178 #define MaxPrecisionBits 16
179 #define MinPrecisionValue 2
180 #define MaxPrecisionValue 65535