Fri, 11 Sep 2020 16:12:45 +0000
8253019: Enhanced JPEG decoding
Reviewed-by: rhalade, mschoene, serb, psadhukhan
duke@3 | 1 | /* |
duke@3 | 2 | * reserved comment block |
duke@3 | 3 | * DO NOT REMOVE OR ALTER! |
duke@3 | 4 | */ |
duke@3 | 5 | /* |
duke@3 | 6 | * jpeglib.h |
duke@3 | 7 | * |
duke@3 | 8 | * Copyright (C) 1991-1998, Thomas G. Lane. |
duke@3 | 9 | * This file is part of the Independent JPEG Group's software. |
duke@3 | 10 | * For conditions of distribution and use, see the accompanying README file. |
duke@3 | 11 | * |
duke@3 | 12 | * This file defines the application interface for the JPEG library. |
duke@3 | 13 | * Most applications using the library need only include this file, |
duke@3 | 14 | * and perhaps jerror.h if they want to know the exact error codes. |
duke@3 | 15 | */ |
duke@3 | 16 | |
duke@3 | 17 | #ifndef JPEGLIB_H |
duke@3 | 18 | #define JPEGLIB_H |
duke@3 | 19 | |
duke@3 | 20 | /* |
duke@3 | 21 | * First we include the configuration files that record how this |
duke@3 | 22 | * installation of the JPEG library is set up. jconfig.h can be |
duke@3 | 23 | * generated automatically for many systems. jmorecfg.h contains |
duke@3 | 24 | * manual configuration options that most people need not worry about. |
duke@3 | 25 | */ |
duke@3 | 26 | |
duke@3 | 27 | #ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */ |
duke@3 | 28 | #include "jconfig.h" /* widely used configuration options */ |
duke@3 | 29 | #endif |
duke@3 | 30 | #include "jmorecfg.h" /* seldom changed options */ |
duke@3 | 31 | |
duke@3 | 32 | |
duke@3 | 33 | /* Version ID for the JPEG library. |
duke@3 | 34 | * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". |
duke@3 | 35 | */ |
duke@3 | 36 | |
duke@3 | 37 | #define JPEG_LIB_VERSION 62 /* Version 6b */ |
duke@3 | 38 | |
duke@3 | 39 | |
duke@3 | 40 | /* Various constants determining the sizes of things. |
duke@3 | 41 | * All of these are specified by the JPEG standard, so don't change them |
duke@3 | 42 | * if you want to be compatible. |
duke@3 | 43 | */ |
duke@3 | 44 | |
duke@3 | 45 | #define DCTSIZE 8 /* The basic DCT block is 8x8 samples */ |
duke@3 | 46 | #define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */ |
duke@3 | 47 | #define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */ |
duke@3 | 48 | #define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */ |
duke@3 | 49 | #define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */ |
duke@3 | 50 | #define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */ |
duke@3 | 51 | #define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */ |
duke@3 | 52 | /* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard; |
duke@3 | 53 | * the PostScript DCT filter can emit files with many more than 10 blocks/MCU. |
duke@3 | 54 | * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU |
duke@3 | 55 | * to handle it. We even let you do this from the jconfig.h file. However, |
duke@3 | 56 | * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe |
duke@3 | 57 | * sometimes emits noncompliant files doesn't mean you should too. |
duke@3 | 58 | */ |
duke@3 | 59 | #define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */ |
duke@3 | 60 | #ifndef D_MAX_BLOCKS_IN_MCU |
duke@3 | 61 | #define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */ |
duke@3 | 62 | #endif |
duke@3 | 63 | |
duke@3 | 64 | |
duke@3 | 65 | /* Data structures for images (arrays of samples and of DCT coefficients). |
duke@3 | 66 | * On 80x86 machines, the image arrays are too big for near pointers, |
duke@3 | 67 | * but the pointer arrays can fit in near memory. |
duke@3 | 68 | */ |
duke@3 | 69 | |
duke@3 | 70 | typedef JSAMPLE FAR *JSAMPROW; /* ptr to one image row of pixel samples. */ |
duke@3 | 71 | typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */ |
duke@3 | 72 | typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */ |
duke@3 | 73 | |
duke@3 | 74 | typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */ |
duke@3 | 75 | typedef JBLOCK FAR *JBLOCKROW; /* pointer to one row of coefficient blocks */ |
duke@3 | 76 | typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */ |
duke@3 | 77 | typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */ |
duke@3 | 78 | |
duke@3 | 79 | typedef JCOEF FAR *JCOEFPTR; /* useful in a couple of places */ |
duke@3 | 80 | |
duke@3 | 81 | |
duke@3 | 82 | /* Types for JPEG compression parameters and working tables. */ |
duke@3 | 83 | |
duke@3 | 84 | |
duke@3 | 85 | /* DCT coefficient quantization tables. */ |
duke@3 | 86 | |
duke@3 | 87 | typedef struct { |
duke@3 | 88 | /* This array gives the coefficient quantizers in natural array order |
duke@3 | 89 | * (not the zigzag order in which they are stored in a JPEG DQT marker). |
duke@3 | 90 | * CAUTION: IJG versions prior to v6a kept this array in zigzag order. |
duke@3 | 91 | */ |
duke@3 | 92 | UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */ |
duke@3 | 93 | /* This field is used only during compression. It's initialized FALSE when |
duke@3 | 94 | * the table is created, and set TRUE when it's been output to the file. |
duke@3 | 95 | * You could suppress output of a table by setting this to TRUE. |
duke@3 | 96 | * (See jpeg_suppress_tables for an example.) |
duke@3 | 97 | */ |
duke@3 | 98 | boolean sent_table; /* TRUE when table has been output */ |
duke@3 | 99 | } JQUANT_TBL; |
duke@3 | 100 | |
duke@3 | 101 | |
duke@3 | 102 | /* Huffman coding tables. */ |
duke@3 | 103 | |
duke@3 | 104 | typedef struct { |
duke@3 | 105 | /* These two fields directly represent the contents of a JPEG DHT marker */ |
duke@3 | 106 | UINT8 bits[17]; /* bits[k] = # of symbols with codes of */ |
duke@3 | 107 | /* length k bits; bits[0] is unused */ |
duke@3 | 108 | UINT8 huffval[256]; /* The symbols, in order of incr code length */ |
duke@3 | 109 | /* This field is used only during compression. It's initialized FALSE when |
duke@3 | 110 | * the table is created, and set TRUE when it's been output to the file. |
duke@3 | 111 | * You could suppress output of a table by setting this to TRUE. |
duke@3 | 112 | * (See jpeg_suppress_tables for an example.) |
duke@3 | 113 | */ |
duke@3 | 114 | boolean sent_table; /* TRUE when table has been output */ |
duke@3 | 115 | } JHUFF_TBL; |
duke@3 | 116 | |
duke@3 | 117 | |
duke@3 | 118 | /* Basic info about one component (color channel). */ |
duke@3 | 119 | |
duke@3 | 120 | typedef struct { |
duke@3 | 121 | /* These values are fixed over the whole image. */ |
duke@3 | 122 | /* For compression, they must be supplied by parameter setup; */ |
duke@3 | 123 | /* for decompression, they are read from the SOF marker. */ |
duke@3 | 124 | int component_id; /* identifier for this component (0..255) */ |
duke@3 | 125 | int component_index; /* its index in SOF or cinfo->comp_info[] */ |
duke@3 | 126 | int h_samp_factor; /* horizontal sampling factor (1..4) */ |
duke@3 | 127 | int v_samp_factor; /* vertical sampling factor (1..4) */ |
duke@3 | 128 | int quant_tbl_no; /* quantization table selector (0..3) */ |
duke@3 | 129 | /* These values may vary between scans. */ |
duke@3 | 130 | /* For compression, they must be supplied by parameter setup; */ |
duke@3 | 131 | /* for decompression, they are read from the SOS marker. */ |
duke@3 | 132 | /* The decompressor output side may not use these variables. */ |
duke@3 | 133 | int dc_tbl_no; /* DC entropy table selector (0..3) */ |
duke@3 | 134 | int ac_tbl_no; /* AC entropy table selector (0..3) */ |
duke@3 | 135 | |
duke@3 | 136 | /* Remaining fields should be treated as private by applications. */ |
duke@3 | 137 | |
duke@3 | 138 | /* These values are computed during compression or decompression startup: */ |
duke@3 | 139 | /* Component's size in DCT blocks. |
duke@3 | 140 | * Any dummy blocks added to complete an MCU are not counted; therefore |
duke@3 | 141 | * these values do not depend on whether a scan is interleaved or not. |
duke@3 | 142 | */ |
duke@3 | 143 | JDIMENSION width_in_blocks; |
duke@3 | 144 | JDIMENSION height_in_blocks; |
duke@3 | 145 | /* Size of a DCT block in samples. Always DCTSIZE for compression. |
duke@3 | 146 | * For decompression this is the size of the output from one DCT block, |
duke@3 | 147 | * reflecting any scaling we choose to apply during the IDCT step. |
duke@3 | 148 | * Values of 1,2,4,8 are likely to be supported. Note that different |
duke@3 | 149 | * components may receive different IDCT scalings. |
duke@3 | 150 | */ |
duke@3 | 151 | int DCT_scaled_size; |
duke@3 | 152 | /* The downsampled dimensions are the component's actual, unpadded number |
duke@3 | 153 | * of samples at the main buffer (preprocessing/compression interface), thus |
duke@3 | 154 | * downsampled_width = ceil(image_width * Hi/Hmax) |
duke@3 | 155 | * and similarly for height. For decompression, IDCT scaling is included, so |
duke@3 | 156 | * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE) |
duke@3 | 157 | */ |
duke@3 | 158 | JDIMENSION downsampled_width; /* actual width in samples */ |
duke@3 | 159 | JDIMENSION downsampled_height; /* actual height in samples */ |
duke@3 | 160 | /* This flag is used only for decompression. In cases where some of the |
duke@3 | 161 | * components will be ignored (eg grayscale output from YCbCr image), |
duke@3 | 162 | * we can skip most computations for the unused components. |
duke@3 | 163 | */ |
duke@3 | 164 | boolean component_needed; /* do we need the value of this component? */ |
duke@3 | 165 | |
duke@3 | 166 | /* These values are computed before starting a scan of the component. */ |
duke@3 | 167 | /* The decompressor output side may not use these variables. */ |
duke@3 | 168 | int MCU_width; /* number of blocks per MCU, horizontally */ |
duke@3 | 169 | int MCU_height; /* number of blocks per MCU, vertically */ |
duke@3 | 170 | int MCU_blocks; /* MCU_width * MCU_height */ |
duke@3 | 171 | int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_scaled_size */ |
duke@3 | 172 | int last_col_width; /* # of non-dummy blocks across in last MCU */ |
duke@3 | 173 | int last_row_height; /* # of non-dummy blocks down in last MCU */ |
duke@3 | 174 | |
duke@3 | 175 | /* Saved quantization table for component; NULL if none yet saved. |
duke@3 | 176 | * See jdinput.c comments about the need for this information. |
duke@3 | 177 | * This field is currently used only for decompression. |
duke@3 | 178 | */ |
duke@3 | 179 | JQUANT_TBL * quant_table; |
duke@3 | 180 | |
duke@3 | 181 | /* Private per-component storage for DCT or IDCT subsystem. */ |
duke@3 | 182 | void * dct_table; |
duke@3 | 183 | } jpeg_component_info; |
duke@3 | 184 | |
duke@3 | 185 | |
duke@3 | 186 | /* The script for encoding a multiple-scan file is an array of these: */ |
duke@3 | 187 | |
duke@3 | 188 | typedef struct { |
duke@3 | 189 | int comps_in_scan; /* number of components encoded in this scan */ |
duke@3 | 190 | int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */ |
duke@3 | 191 | int Ss, Se; /* progressive JPEG spectral selection parms */ |
duke@3 | 192 | int Ah, Al; /* progressive JPEG successive approx. parms */ |
duke@3 | 193 | } jpeg_scan_info; |
duke@3 | 194 | |
duke@3 | 195 | /* The decompressor can save APPn and COM markers in a list of these: */ |
duke@3 | 196 | |
duke@3 | 197 | typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr; |
duke@3 | 198 | |
duke@3 | 199 | struct jpeg_marker_struct { |
duke@3 | 200 | jpeg_saved_marker_ptr next; /* next in list, or NULL */ |
duke@3 | 201 | UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */ |
duke@3 | 202 | unsigned int original_length; /* # bytes of data in the file */ |
duke@3 | 203 | unsigned int data_length; /* # bytes of data saved at data[] */ |
duke@3 | 204 | JOCTET FAR * data; /* the data contained in the marker */ |
duke@3 | 205 | /* the marker length word is not counted in data_length or original_length */ |
duke@3 | 206 | }; |
duke@3 | 207 | |
duke@3 | 208 | /* Known color spaces. */ |
duke@3 | 209 | |
duke@3 | 210 | typedef enum { |
duke@3 | 211 | JCS_UNKNOWN, /* error/unspecified */ |
duke@3 | 212 | JCS_GRAYSCALE, /* monochrome */ |
duke@3 | 213 | JCS_RGB, /* red/green/blue */ |
duke@3 | 214 | JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */ |
duke@3 | 215 | JCS_CMYK, /* C/M/Y/K */ |
duke@3 | 216 | JCS_YCCK /* Y/Cb/Cr/K */ |
duke@3 | 217 | } J_COLOR_SPACE; |
duke@3 | 218 | |
duke@3 | 219 | /* DCT/IDCT algorithm options. */ |
duke@3 | 220 | |
duke@3 | 221 | typedef enum { |
duke@3 | 222 | JDCT_ISLOW, /* slow but accurate integer algorithm */ |
duke@3 | 223 | JDCT_IFAST, /* faster, less accurate integer method */ |
duke@3 | 224 | JDCT_FLOAT /* floating-point: accurate, fast on fast HW */ |
duke@3 | 225 | } J_DCT_METHOD; |
duke@3 | 226 | |
duke@3 | 227 | #ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */ |
duke@3 | 228 | #define JDCT_DEFAULT JDCT_ISLOW |
duke@3 | 229 | #endif |
duke@3 | 230 | #ifndef JDCT_FASTEST /* may be overridden in jconfig.h */ |
duke@3 | 231 | #define JDCT_FASTEST JDCT_IFAST |
duke@3 | 232 | #endif |
duke@3 | 233 | |
duke@3 | 234 | /* Dithering options for decompression. */ |
duke@3 | 235 | |
duke@3 | 236 | typedef enum { |
duke@3 | 237 | JDITHER_NONE, /* no dithering */ |
duke@3 | 238 | JDITHER_ORDERED, /* simple ordered dither */ |
duke@3 | 239 | JDITHER_FS /* Floyd-Steinberg error diffusion dither */ |
duke@3 | 240 | } J_DITHER_MODE; |
duke@3 | 241 | |
duke@3 | 242 | |
duke@3 | 243 | /* Common fields between JPEG compression and decompression master structs. */ |
duke@3 | 244 | |
duke@3 | 245 | #define jpeg_common_fields \ |
duke@3 | 246 | struct jpeg_error_mgr * err; /* Error handler module */\ |
duke@3 | 247 | struct jpeg_memory_mgr * mem; /* Memory manager module */\ |
duke@3 | 248 | struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\ |
duke@3 | 249 | void * client_data; /* Available for use by application */\ |
duke@3 | 250 | boolean is_decompressor; /* So common code can tell which is which */\ |
duke@3 | 251 | int global_state /* For checking call sequence validity */ |
duke@3 | 252 | |
duke@3 | 253 | /* Routines that are to be used by both halves of the library are declared |
duke@3 | 254 | * to receive a pointer to this structure. There are no actual instances of |
duke@3 | 255 | * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct. |
duke@3 | 256 | */ |
duke@3 | 257 | struct jpeg_common_struct { |
duke@3 | 258 | jpeg_common_fields; /* Fields common to both master struct types */ |
duke@3 | 259 | /* Additional fields follow in an actual jpeg_compress_struct or |
duke@3 | 260 | * jpeg_decompress_struct. All three structs must agree on these |
duke@3 | 261 | * initial fields! (This would be a lot cleaner in C++.) |
duke@3 | 262 | */ |
duke@3 | 263 | }; |
duke@3 | 264 | |
duke@3 | 265 | typedef struct jpeg_common_struct * j_common_ptr; |
duke@3 | 266 | typedef struct jpeg_compress_struct * j_compress_ptr; |
duke@3 | 267 | typedef struct jpeg_decompress_struct * j_decompress_ptr; |
duke@3 | 268 | |
duke@3 | 269 | |
duke@3 | 270 | /* Master record for a compression instance */ |
duke@3 | 271 | |
duke@3 | 272 | struct jpeg_compress_struct { |
duke@3 | 273 | jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */ |
duke@3 | 274 | |
duke@3 | 275 | /* Destination for compressed data */ |
duke@3 | 276 | struct jpeg_destination_mgr * dest; |
duke@3 | 277 | |
duke@3 | 278 | /* Description of source image --- these fields must be filled in by |
duke@3 | 279 | * outer application before starting compression. in_color_space must |
duke@3 | 280 | * be correct before you can even call jpeg_set_defaults(). |
duke@3 | 281 | */ |
duke@3 | 282 | |
duke@3 | 283 | JDIMENSION image_width; /* input image width */ |
duke@3 | 284 | JDIMENSION image_height; /* input image height */ |
duke@3 | 285 | int input_components; /* # of color components in input image */ |
duke@3 | 286 | J_COLOR_SPACE in_color_space; /* colorspace of input image */ |
duke@3 | 287 | |
duke@3 | 288 | double input_gamma; /* image gamma of input image */ |
duke@3 | 289 | |
duke@3 | 290 | /* Compression parameters --- these fields must be set before calling |
duke@3 | 291 | * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to |
duke@3 | 292 | * initialize everything to reasonable defaults, then changing anything |
duke@3 | 293 | * the application specifically wants to change. That way you won't get |
duke@3 | 294 | * burnt when new parameters are added. Also note that there are several |
duke@3 | 295 | * helper routines to simplify changing parameters. |
duke@3 | 296 | */ |
duke@3 | 297 | |
duke@3 | 298 | int data_precision; /* bits of precision in image data */ |
duke@3 | 299 | |
duke@3 | 300 | int num_components; /* # of color components in JPEG image */ |
duke@3 | 301 | J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ |
duke@3 | 302 | |
duke@3 | 303 | jpeg_component_info * comp_info; |
duke@3 | 304 | /* comp_info[i] describes component that appears i'th in SOF */ |
duke@3 | 305 | |
duke@3 | 306 | JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; |
duke@3 | 307 | /* ptrs to coefficient quantization tables, or NULL if not defined */ |
duke@3 | 308 | |
duke@3 | 309 | JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; |
duke@3 | 310 | JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; |
duke@3 | 311 | /* ptrs to Huffman coding tables, or NULL if not defined */ |
duke@3 | 312 | |
duke@3 | 313 | UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ |
duke@3 | 314 | UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ |
duke@3 | 315 | UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ |
duke@3 | 316 | |
duke@3 | 317 | int num_scans; /* # of entries in scan_info array */ |
duke@3 | 318 | const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */ |
duke@3 | 319 | /* The default value of scan_info is NULL, which causes a single-scan |
duke@3 | 320 | * sequential JPEG file to be emitted. To create a multi-scan file, |
duke@3 | 321 | * set num_scans and scan_info to point to an array of scan definitions. |
duke@3 | 322 | */ |
duke@3 | 323 | |
duke@3 | 324 | boolean raw_data_in; /* TRUE=caller supplies downsampled data */ |
duke@3 | 325 | boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ |
duke@3 | 326 | boolean optimize_coding; /* TRUE=optimize entropy encoding parms */ |
duke@3 | 327 | boolean CCIR601_sampling; /* TRUE=first samples are cosited */ |
duke@3 | 328 | int smoothing_factor; /* 1..100, or 0 for no input smoothing */ |
duke@3 | 329 | J_DCT_METHOD dct_method; /* DCT algorithm selector */ |
duke@3 | 330 | |
duke@3 | 331 | /* The restart interval can be specified in absolute MCUs by setting |
duke@3 | 332 | * restart_interval, or in MCU rows by setting restart_in_rows |
duke@3 | 333 | * (in which case the correct restart_interval will be figured |
duke@3 | 334 | * for each scan). |
duke@3 | 335 | */ |
duke@3 | 336 | unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */ |
duke@3 | 337 | int restart_in_rows; /* if > 0, MCU rows per restart interval */ |
duke@3 | 338 | |
duke@3 | 339 | /* Parameters controlling emission of special markers. */ |
duke@3 | 340 | |
duke@3 | 341 | boolean write_JFIF_header; /* should a JFIF marker be written? */ |
duke@3 | 342 | UINT8 JFIF_major_version; /* What to write for the JFIF version number */ |
duke@3 | 343 | UINT8 JFIF_minor_version; |
duke@3 | 344 | /* These three values are not used by the JPEG code, merely copied */ |
duke@3 | 345 | /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */ |
duke@3 | 346 | /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */ |
duke@3 | 347 | /* ratio is defined by X_density/Y_density even when density_unit=0. */ |
duke@3 | 348 | UINT8 density_unit; /* JFIF code for pixel size units */ |
duke@3 | 349 | UINT16 X_density; /* Horizontal pixel density */ |
duke@3 | 350 | UINT16 Y_density; /* Vertical pixel density */ |
duke@3 | 351 | boolean write_Adobe_marker; /* should an Adobe marker be written? */ |
duke@3 | 352 | |
duke@3 | 353 | /* State variable: index of next scanline to be written to |
duke@3 | 354 | * jpeg_write_scanlines(). Application may use this to control its |
duke@3 | 355 | * processing loop, e.g., "while (next_scanline < image_height)". |
duke@3 | 356 | */ |
duke@3 | 357 | |
duke@3 | 358 | JDIMENSION next_scanline; /* 0 .. image_height-1 */ |
duke@3 | 359 | |
duke@3 | 360 | /* Remaining fields are known throughout compressor, but generally |
duke@3 | 361 | * should not be touched by a surrounding application. |
duke@3 | 362 | */ |
duke@3 | 363 | |
duke@3 | 364 | /* |
duke@3 | 365 | * These fields are computed during compression startup |
duke@3 | 366 | */ |
duke@3 | 367 | boolean progressive_mode; /* TRUE if scan script uses progressive mode */ |
duke@3 | 368 | int max_h_samp_factor; /* largest h_samp_factor */ |
duke@3 | 369 | int max_v_samp_factor; /* largest v_samp_factor */ |
duke@3 | 370 | |
duke@3 | 371 | JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */ |
duke@3 | 372 | /* The coefficient controller receives data in units of MCU rows as defined |
duke@3 | 373 | * for fully interleaved scans (whether the JPEG file is interleaved or not). |
duke@3 | 374 | * There are v_samp_factor * DCTSIZE sample rows of each component in an |
duke@3 | 375 | * "iMCU" (interleaved MCU) row. |
duke@3 | 376 | */ |
duke@3 | 377 | |
duke@3 | 378 | /* |
duke@3 | 379 | * These fields are valid during any one scan. |
duke@3 | 380 | * They describe the components and MCUs actually appearing in the scan. |
duke@3 | 381 | */ |
duke@3 | 382 | int comps_in_scan; /* # of JPEG components in this scan */ |
duke@3 | 383 | jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; |
duke@3 | 384 | /* *cur_comp_info[i] describes component that appears i'th in SOS */ |
duke@3 | 385 | |
duke@3 | 386 | JDIMENSION MCUs_per_row; /* # of MCUs across the image */ |
duke@3 | 387 | JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ |
duke@3 | 388 | |
duke@3 | 389 | int blocks_in_MCU; /* # of DCT blocks per MCU */ |
duke@3 | 390 | int MCU_membership[C_MAX_BLOCKS_IN_MCU]; |
duke@3 | 391 | /* MCU_membership[i] is index in cur_comp_info of component owning */ |
duke@3 | 392 | /* i'th block in an MCU */ |
duke@3 | 393 | |
duke@3 | 394 | int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ |
duke@3 | 395 | |
duke@3 | 396 | /* |
duke@3 | 397 | * Links to compression subobjects (methods and private variables of modules) |
duke@3 | 398 | */ |
duke@3 | 399 | struct jpeg_comp_master * master; |
duke@3 | 400 | struct jpeg_c_main_controller * main; |
duke@3 | 401 | struct jpeg_c_prep_controller * prep; |
duke@3 | 402 | struct jpeg_c_coef_controller * coef; |
duke@3 | 403 | struct jpeg_marker_writer * marker; |
duke@3 | 404 | struct jpeg_color_converter * cconvert; |
duke@3 | 405 | struct jpeg_downsampler * downsample; |
duke@3 | 406 | struct jpeg_forward_dct * fdct; |
duke@3 | 407 | struct jpeg_entropy_encoder * entropy; |
duke@3 | 408 | jpeg_scan_info * script_space; /* workspace for jpeg_simple_progression */ |
duke@3 | 409 | int script_space_size; |
duke@3 | 410 | }; |
duke@3 | 411 | |
duke@3 | 412 | |
duke@3 | 413 | /* Master record for a decompression instance */ |
duke@3 | 414 | |
duke@3 | 415 | struct jpeg_decompress_struct { |
duke@3 | 416 | jpeg_common_fields; /* Fields shared with jpeg_compress_struct */ |
duke@3 | 417 | |
duke@3 | 418 | /* Source of compressed data */ |
duke@3 | 419 | struct jpeg_source_mgr * src; |
duke@3 | 420 | |
duke@3 | 421 | /* Basic description of image --- filled in by jpeg_read_header(). */ |
duke@3 | 422 | /* Application may inspect these values to decide how to process image. */ |
duke@3 | 423 | |
duke@3 | 424 | JDIMENSION image_width; /* nominal image width (from SOF marker) */ |
duke@3 | 425 | JDIMENSION image_height; /* nominal image height */ |
duke@3 | 426 | int num_components; /* # of color components in JPEG image */ |
duke@3 | 427 | J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ |
duke@3 | 428 | |
duke@3 | 429 | /* Decompression processing parameters --- these fields must be set before |
duke@3 | 430 | * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes |
duke@3 | 431 | * them to default values. |
duke@3 | 432 | */ |
duke@3 | 433 | |
duke@3 | 434 | J_COLOR_SPACE out_color_space; /* colorspace for output */ |
duke@3 | 435 | |
duke@3 | 436 | unsigned int scale_num, scale_denom; /* fraction by which to scale image */ |
duke@3 | 437 | |
duke@3 | 438 | double output_gamma; /* image gamma wanted in output */ |
duke@3 | 439 | |
duke@3 | 440 | boolean buffered_image; /* TRUE=multiple output passes */ |
duke@3 | 441 | boolean raw_data_out; /* TRUE=downsampled data wanted */ |
duke@3 | 442 | |
duke@3 | 443 | J_DCT_METHOD dct_method; /* IDCT algorithm selector */ |
duke@3 | 444 | boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */ |
duke@3 | 445 | boolean do_block_smoothing; /* TRUE=apply interblock smoothing */ |
duke@3 | 446 | |
duke@3 | 447 | boolean quantize_colors; /* TRUE=colormapped output wanted */ |
duke@3 | 448 | /* the following are ignored if not quantize_colors: */ |
duke@3 | 449 | J_DITHER_MODE dither_mode; /* type of color dithering to use */ |
duke@3 | 450 | boolean two_pass_quantize; /* TRUE=use two-pass color quantization */ |
duke@3 | 451 | int desired_number_of_colors; /* max # colors to use in created colormap */ |
duke@3 | 452 | /* these are significant only in buffered-image mode: */ |
duke@3 | 453 | boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */ |
duke@3 | 454 | boolean enable_external_quant;/* enable future use of external colormap */ |
duke@3 | 455 | boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */ |
duke@3 | 456 | |
duke@3 | 457 | /* Description of actual output image that will be returned to application. |
duke@3 | 458 | * These fields are computed by jpeg_start_decompress(). |
duke@3 | 459 | * You can also use jpeg_calc_output_dimensions() to determine these values |
duke@3 | 460 | * in advance of calling jpeg_start_decompress(). |
duke@3 | 461 | */ |
duke@3 | 462 | |
duke@3 | 463 | JDIMENSION output_width; /* scaled image width */ |
duke@3 | 464 | JDIMENSION output_height; /* scaled image height */ |
duke@3 | 465 | int out_color_components; /* # of color components in out_color_space */ |
duke@3 | 466 | int output_components; /* # of color components returned */ |
duke@3 | 467 | /* output_components is 1 (a colormap index) when quantizing colors; |
duke@3 | 468 | * otherwise it equals out_color_components. |
duke@3 | 469 | */ |
duke@3 | 470 | int rec_outbuf_height; /* min recommended height of scanline buffer */ |
duke@3 | 471 | /* If the buffer passed to jpeg_read_scanlines() is less than this many rows |
duke@3 | 472 | * high, space and time will be wasted due to unnecessary data copying. |
duke@3 | 473 | * Usually rec_outbuf_height will be 1 or 2, at most 4. |
duke@3 | 474 | */ |
duke@3 | 475 | |
duke@3 | 476 | /* When quantizing colors, the output colormap is described by these fields. |
duke@3 | 477 | * The application can supply a colormap by setting colormap non-NULL before |
duke@3 | 478 | * calling jpeg_start_decompress; otherwise a colormap is created during |
duke@3 | 479 | * jpeg_start_decompress or jpeg_start_output. |
duke@3 | 480 | * The map has out_color_components rows and actual_number_of_colors columns. |
duke@3 | 481 | */ |
duke@3 | 482 | int actual_number_of_colors; /* number of entries in use */ |
duke@3 | 483 | JSAMPARRAY colormap; /* The color map as a 2-D pixel array */ |
duke@3 | 484 | |
duke@3 | 485 | /* State variables: these variables indicate the progress of decompression. |
duke@3 | 486 | * The application may examine these but must not modify them. |
duke@3 | 487 | */ |
duke@3 | 488 | |
duke@3 | 489 | /* Row index of next scanline to be read from jpeg_read_scanlines(). |
duke@3 | 490 | * Application may use this to control its processing loop, e.g., |
duke@3 | 491 | * "while (output_scanline < output_height)". |
duke@3 | 492 | */ |
duke@3 | 493 | JDIMENSION output_scanline; /* 0 .. output_height-1 */ |
duke@3 | 494 | |
duke@3 | 495 | /* Current input scan number and number of iMCU rows completed in scan. |
duke@3 | 496 | * These indicate the progress of the decompressor input side. |
duke@3 | 497 | */ |
duke@3 | 498 | int input_scan_number; /* Number of SOS markers seen so far */ |
duke@3 | 499 | JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */ |
duke@3 | 500 | |
duke@3 | 501 | /* The "output scan number" is the notional scan being displayed by the |
duke@3 | 502 | * output side. The decompressor will not allow output scan/row number |
duke@3 | 503 | * to get ahead of input scan/row, but it can fall arbitrarily far behind. |
duke@3 | 504 | */ |
duke@3 | 505 | int output_scan_number; /* Nominal scan number being displayed */ |
duke@3 | 506 | JDIMENSION output_iMCU_row; /* Number of iMCU rows read */ |
duke@3 | 507 | |
duke@3 | 508 | /* Current progression status. coef_bits[c][i] indicates the precision |
duke@3 | 509 | * with which component c's DCT coefficient i (in zigzag order) is known. |
duke@3 | 510 | * It is -1 when no data has yet been received, otherwise it is the point |
duke@3 | 511 | * transform (shift) value for the most recent scan of the coefficient |
duke@3 | 512 | * (thus, 0 at completion of the progression). |
duke@3 | 513 | * This pointer is NULL when reading a non-progressive file. |
duke@3 | 514 | */ |
duke@3 | 515 | int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */ |
duke@3 | 516 | |
duke@3 | 517 | /* Internal JPEG parameters --- the application usually need not look at |
duke@3 | 518 | * these fields. Note that the decompressor output side may not use |
duke@3 | 519 | * any parameters that can change between scans. |
duke@3 | 520 | */ |
duke@3 | 521 | |
duke@3 | 522 | /* Quantization and Huffman tables are carried forward across input |
duke@3 | 523 | * datastreams when processing abbreviated JPEG datastreams. |
duke@3 | 524 | */ |
duke@3 | 525 | |
duke@3 | 526 | JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; |
duke@3 | 527 | /* ptrs to coefficient quantization tables, or NULL if not defined */ |
duke@3 | 528 | |
duke@3 | 529 | JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; |
duke@3 | 530 | JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; |
duke@3 | 531 | /* ptrs to Huffman coding tables, or NULL if not defined */ |
duke@3 | 532 | |
duke@3 | 533 | /* These parameters are never carried across datastreams, since they |
duke@3 | 534 | * are given in SOF/SOS markers or defined to be reset by SOI. |
duke@3 | 535 | */ |
duke@3 | 536 | |
duke@3 | 537 | int data_precision; /* bits of precision in image data */ |
duke@3 | 538 | |
duke@3 | 539 | jpeg_component_info * comp_info; |
duke@3 | 540 | /* comp_info[i] describes component that appears i'th in SOF */ |
duke@3 | 541 | |
duke@3 | 542 | boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */ |
duke@3 | 543 | boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ |
duke@3 | 544 | |
duke@3 | 545 | UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ |
duke@3 | 546 | UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ |
duke@3 | 547 | UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ |
duke@3 | 548 | |
duke@3 | 549 | unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */ |
duke@3 | 550 | |
duke@3 | 551 | /* These fields record data obtained from optional markers recognized by |
duke@3 | 552 | * the JPEG library. |
duke@3 | 553 | */ |
duke@3 | 554 | boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */ |
duke@3 | 555 | /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */ |
duke@3 | 556 | UINT8 JFIF_major_version; /* JFIF version number */ |
duke@3 | 557 | UINT8 JFIF_minor_version; |
duke@3 | 558 | UINT8 density_unit; /* JFIF code for pixel size units */ |
duke@3 | 559 | UINT16 X_density; /* Horizontal pixel density */ |
duke@3 | 560 | UINT16 Y_density; /* Vertical pixel density */ |
duke@3 | 561 | boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */ |
duke@3 | 562 | UINT8 Adobe_transform; /* Color transform code from Adobe marker */ |
duke@3 | 563 | |
duke@3 | 564 | boolean CCIR601_sampling; /* TRUE=first samples are cosited */ |
duke@3 | 565 | |
duke@3 | 566 | /* Aside from the specific data retained from APPn markers known to the |
duke@3 | 567 | * library, the uninterpreted contents of any or all APPn and COM markers |
duke@3 | 568 | * can be saved in a list for examination by the application. |
duke@3 | 569 | */ |
duke@3 | 570 | jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */ |
duke@3 | 571 | |
duke@3 | 572 | /* Remaining fields are known throughout decompressor, but generally |
duke@3 | 573 | * should not be touched by a surrounding application. |
duke@3 | 574 | */ |
duke@3 | 575 | |
duke@3 | 576 | /* |
duke@3 | 577 | * These fields are computed during decompression startup |
duke@3 | 578 | */ |
duke@3 | 579 | int max_h_samp_factor; /* largest h_samp_factor */ |
duke@3 | 580 | int max_v_samp_factor; /* largest v_samp_factor */ |
duke@3 | 581 | |
duke@3 | 582 | int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */ |
duke@3 | 583 | |
duke@3 | 584 | JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */ |
duke@3 | 585 | /* The coefficient controller's input and output progress is measured in |
duke@3 | 586 | * units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows |
duke@3 | 587 | * in fully interleaved JPEG scans, but are used whether the scan is |
duke@3 | 588 | * interleaved or not. We define an iMCU row as v_samp_factor DCT block |
duke@3 | 589 | * rows of each component. Therefore, the IDCT output contains |
duke@3 | 590 | * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row. |
duke@3 | 591 | */ |
duke@3 | 592 | |
duke@3 | 593 | JSAMPLE * sample_range_limit; /* table for fast range-limiting */ |
duke@3 | 594 | |
duke@3 | 595 | /* |
duke@3 | 596 | * These fields are valid during any one scan. |
duke@3 | 597 | * They describe the components and MCUs actually appearing in the scan. |
duke@3 | 598 | * Note that the decompressor output side must not use these fields. |
duke@3 | 599 | */ |
duke@3 | 600 | int comps_in_scan; /* # of JPEG components in this scan */ |
duke@3 | 601 | jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; |
duke@3 | 602 | /* *cur_comp_info[i] describes component that appears i'th in SOS */ |
duke@3 | 603 | |
duke@3 | 604 | JDIMENSION MCUs_per_row; /* # of MCUs across the image */ |
duke@3 | 605 | JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ |
duke@3 | 606 | |
duke@3 | 607 | int blocks_in_MCU; /* # of DCT blocks per MCU */ |
duke@3 | 608 | int MCU_membership[D_MAX_BLOCKS_IN_MCU]; |
duke@3 | 609 | /* MCU_membership[i] is index in cur_comp_info of component owning */ |
duke@3 | 610 | /* i'th block in an MCU */ |
duke@3 | 611 | |
duke@3 | 612 | int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ |
duke@3 | 613 | |
duke@3 | 614 | /* This field is shared between entropy decoder and marker parser. |
duke@3 | 615 | * It is either zero or the code of a JPEG marker that has been |
duke@3 | 616 | * read from the data source, but has not yet been processed. |
duke@3 | 617 | */ |
duke@3 | 618 | int unread_marker; |
duke@3 | 619 | |
duke@3 | 620 | /* |
duke@3 | 621 | * Links to decompression subobjects (methods, private variables of modules) |
duke@3 | 622 | */ |
duke@3 | 623 | struct jpeg_decomp_master * master; |
duke@3 | 624 | struct jpeg_d_main_controller * main; |
duke@3 | 625 | struct jpeg_d_coef_controller * coef; |
duke@3 | 626 | struct jpeg_d_post_controller * post; |
duke@3 | 627 | struct jpeg_input_controller * inputctl; |
duke@3 | 628 | struct jpeg_marker_reader * marker; |
duke@3 | 629 | struct jpeg_entropy_decoder * entropy; |
duke@3 | 630 | struct jpeg_inverse_dct * idct; |
duke@3 | 631 | struct jpeg_upsampler * upsample; |
duke@3 | 632 | struct jpeg_color_deconverter * cconvert; |
duke@3 | 633 | struct jpeg_color_quantizer * cquantize; |
duke@3 | 634 | }; |
duke@3 | 635 | |
duke@3 | 636 | |
duke@3 | 637 | /* "Object" declarations for JPEG modules that may be supplied or called |
duke@3 | 638 | * directly by the surrounding application. |
duke@3 | 639 | * As with all objects in the JPEG library, these structs only define the |
duke@3 | 640 | * publicly visible methods and state variables of a module. Additional |
duke@3 | 641 | * private fields may exist after the public ones. |
duke@3 | 642 | */ |
duke@3 | 643 | |
duke@3 | 644 | |
duke@3 | 645 | /* Error handler object */ |
duke@3 | 646 | |
duke@3 | 647 | struct jpeg_error_mgr { |
duke@3 | 648 | /* Error exit handler: does not return to caller */ |
duke@3 | 649 | JMETHOD(void, error_exit, (j_common_ptr cinfo)); |
duke@3 | 650 | /* Conditionally emit a trace or warning message */ |
duke@3 | 651 | JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level)); |
duke@3 | 652 | /* Routine that actually outputs a trace or error message */ |
duke@3 | 653 | JMETHOD(void, output_message, (j_common_ptr cinfo)); |
duke@3 | 654 | /* Format a message string for the most recent JPEG error or message */ |
duke@3 | 655 | JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer)); |
duke@3 | 656 | #define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */ |
duke@3 | 657 | /* Reset error state variables at start of a new image */ |
duke@3 | 658 | JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo)); |
duke@3 | 659 | |
duke@3 | 660 | /* The message ID code and any parameters are saved here. |
duke@3 | 661 | * A message can have one string parameter or up to 8 int parameters. |
duke@3 | 662 | */ |
duke@3 | 663 | int msg_code; |
duke@3 | 664 | #define JMSG_STR_PARM_MAX 80 |
duke@3 | 665 | union { |
duke@3 | 666 | int i[8]; |
duke@3 | 667 | char s[JMSG_STR_PARM_MAX]; |
duke@3 | 668 | } msg_parm; |
duke@3 | 669 | |
duke@3 | 670 | /* Standard state variables for error facility */ |
duke@3 | 671 | |
duke@3 | 672 | int trace_level; /* max msg_level that will be displayed */ |
duke@3 | 673 | |
duke@3 | 674 | /* For recoverable corrupt-data errors, we emit a warning message, |
duke@3 | 675 | * but keep going unless emit_message chooses to abort. emit_message |
duke@3 | 676 | * should count warnings in num_warnings. The surrounding application |
duke@3 | 677 | * can check for bad data by seeing if num_warnings is nonzero at the |
duke@3 | 678 | * end of processing. |
duke@3 | 679 | */ |
duke@3 | 680 | long num_warnings; /* number of corrupt-data warnings */ |
duke@3 | 681 | |
duke@3 | 682 | /* These fields point to the table(s) of error message strings. |
duke@3 | 683 | * An application can change the table pointer to switch to a different |
duke@3 | 684 | * message list (typically, to change the language in which errors are |
duke@3 | 685 | * reported). Some applications may wish to add additional error codes |
duke@3 | 686 | * that will be handled by the JPEG library error mechanism; the second |
duke@3 | 687 | * table pointer is used for this purpose. |
duke@3 | 688 | * |
duke@3 | 689 | * First table includes all errors generated by JPEG library itself. |
duke@3 | 690 | * Error code 0 is reserved for a "no such error string" message. |
duke@3 | 691 | */ |
duke@3 | 692 | const char * const * jpeg_message_table; /* Library errors */ |
duke@3 | 693 | int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */ |
duke@3 | 694 | /* Second table can be added by application (see cjpeg/djpeg for example). |
duke@3 | 695 | * It contains strings numbered first_addon_message..last_addon_message. |
duke@3 | 696 | */ |
duke@3 | 697 | const char * const * addon_message_table; /* Non-library errors */ |
duke@3 | 698 | int first_addon_message; /* code for first string in addon table */ |
duke@3 | 699 | int last_addon_message; /* code for last string in addon table */ |
duke@3 | 700 | }; |
duke@3 | 701 | |
duke@3 | 702 | |
duke@3 | 703 | /* Progress monitor object */ |
duke@3 | 704 | |
duke@3 | 705 | struct jpeg_progress_mgr { |
duke@3 | 706 | JMETHOD(void, progress_monitor, (j_common_ptr cinfo)); |
duke@3 | 707 | |
duke@3 | 708 | long pass_counter; /* work units completed in this pass */ |
duke@3 | 709 | long pass_limit; /* total number of work units in this pass */ |
duke@3 | 710 | int completed_passes; /* passes completed so far */ |
duke@3 | 711 | int total_passes; /* total number of passes expected */ |
duke@3 | 712 | }; |
duke@3 | 713 | |
duke@3 | 714 | |
duke@3 | 715 | /* Data destination object for compression */ |
duke@3 | 716 | |
duke@3 | 717 | struct jpeg_destination_mgr { |
duke@3 | 718 | JOCTET * next_output_byte; /* => next byte to write in buffer */ |
duke@3 | 719 | size_t free_in_buffer; /* # of byte spaces remaining in buffer */ |
duke@3 | 720 | |
duke@3 | 721 | JMETHOD(void, init_destination, (j_compress_ptr cinfo)); |
duke@3 | 722 | JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo)); |
duke@3 | 723 | JMETHOD(void, term_destination, (j_compress_ptr cinfo)); |
duke@3 | 724 | }; |
duke@3 | 725 | |
duke@3 | 726 | |
duke@3 | 727 | /* Data source object for decompression */ |
duke@3 | 728 | |
duke@3 | 729 | struct jpeg_source_mgr { |
duke@3 | 730 | const JOCTET * next_input_byte; /* => next byte to read from buffer */ |
duke@3 | 731 | size_t bytes_in_buffer; /* # of bytes remaining in buffer */ |
duke@3 | 732 | |
duke@3 | 733 | JMETHOD(void, init_source, (j_decompress_ptr cinfo)); |
duke@3 | 734 | JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo)); |
duke@3 | 735 | JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes)); |
duke@3 | 736 | JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired)); |
duke@3 | 737 | JMETHOD(void, term_source, (j_decompress_ptr cinfo)); |
duke@3 | 738 | }; |
duke@3 | 739 | |
duke@3 | 740 | |
duke@3 | 741 | /* Memory manager object. |
duke@3 | 742 | * Allocates "small" objects (a few K total), "large" objects (tens of K), |
duke@3 | 743 | * and "really big" objects (virtual arrays with backing store if needed). |
duke@3 | 744 | * The memory manager does not allow individual objects to be freed; rather, |
duke@3 | 745 | * each created object is assigned to a pool, and whole pools can be freed |
duke@3 | 746 | * at once. This is faster and more convenient than remembering exactly what |
duke@3 | 747 | * to free, especially where malloc()/free() are not too speedy. |
duke@3 | 748 | * NB: alloc routines never return NULL. They exit to error_exit if not |
duke@3 | 749 | * successful. |
duke@3 | 750 | */ |
duke@3 | 751 | |
duke@3 | 752 | #define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */ |
duke@3 | 753 | #define JPOOL_IMAGE 1 /* lasts until done with image/datastream */ |
duke@3 | 754 | #define JPOOL_NUMPOOLS 2 |
duke@3 | 755 | |
duke@3 | 756 | typedef struct jvirt_sarray_control * jvirt_sarray_ptr; |
duke@3 | 757 | typedef struct jvirt_barray_control * jvirt_barray_ptr; |
duke@3 | 758 | |
duke@3 | 759 | |
duke@3 | 760 | struct jpeg_memory_mgr { |
duke@3 | 761 | /* Method pointers */ |
duke@3 | 762 | JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id, |
duke@3 | 763 | size_t sizeofobject)); |
duke@3 | 764 | JMETHOD(void FAR *, alloc_large, (j_common_ptr cinfo, int pool_id, |
duke@3 | 765 | size_t sizeofobject)); |
duke@3 | 766 | JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id, |
duke@3 | 767 | JDIMENSION samplesperrow, |
duke@3 | 768 | JDIMENSION numrows)); |
duke@3 | 769 | JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id, |
duke@3 | 770 | JDIMENSION blocksperrow, |
duke@3 | 771 | JDIMENSION numrows)); |
duke@3 | 772 | JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo, |
duke@3 | 773 | int pool_id, |
duke@3 | 774 | boolean pre_zero, |
duke@3 | 775 | JDIMENSION samplesperrow, |
duke@3 | 776 | JDIMENSION numrows, |
duke@3 | 777 | JDIMENSION maxaccess)); |
duke@3 | 778 | JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo, |
duke@3 | 779 | int pool_id, |
duke@3 | 780 | boolean pre_zero, |
duke@3 | 781 | JDIMENSION blocksperrow, |
duke@3 | 782 | JDIMENSION numrows, |
duke@3 | 783 | JDIMENSION maxaccess)); |
duke@3 | 784 | JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo)); |
duke@3 | 785 | JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo, |
duke@3 | 786 | jvirt_sarray_ptr ptr, |
duke@3 | 787 | JDIMENSION start_row, |
duke@3 | 788 | JDIMENSION num_rows, |
duke@3 | 789 | boolean writable)); |
duke@3 | 790 | JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo, |
duke@3 | 791 | jvirt_barray_ptr ptr, |
duke@3 | 792 | JDIMENSION start_row, |
duke@3 | 793 | JDIMENSION num_rows, |
duke@3 | 794 | boolean writable)); |
duke@3 | 795 | JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id)); |
duke@3 | 796 | JMETHOD(void, self_destruct, (j_common_ptr cinfo)); |
duke@3 | 797 | |
duke@3 | 798 | /* Limit on memory allocation for this JPEG object. (Note that this is |
duke@3 | 799 | * merely advisory, not a guaranteed maximum; it only affects the space |
duke@3 | 800 | * used for virtual-array buffers.) May be changed by outer application |
duke@3 | 801 | * after creating the JPEG object. |
duke@3 | 802 | */ |
bae@3541 | 803 | size_t max_memory_to_use; |
duke@3 | 804 | |
duke@3 | 805 | /* Maximum allocation request accepted by alloc_large. */ |
bae@3541 | 806 | size_t max_alloc_chunk; |
duke@3 | 807 | }; |
duke@3 | 808 | |
duke@3 | 809 | |
duke@3 | 810 | /* Routine signature for application-supplied marker processing methods. |
duke@3 | 811 | * Need not pass marker code since it is stored in cinfo->unread_marker. |
duke@3 | 812 | */ |
duke@3 | 813 | typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo)); |
duke@3 | 814 | |
duke@3 | 815 | |
duke@3 | 816 | /* Declarations for routines called by application. |
duke@3 | 817 | * The JPP macro hides prototype parameters from compilers that can't cope. |
duke@3 | 818 | * Note JPP requires double parentheses. |
duke@3 | 819 | */ |
duke@3 | 820 | |
duke@3 | 821 | #ifdef HAVE_PROTOTYPES |
duke@3 | 822 | #define JPP(arglist) arglist |
duke@3 | 823 | #else |
duke@3 | 824 | #define JPP(arglist) () |
duke@3 | 825 | #endif |
duke@3 | 826 | |
duke@3 | 827 | |
duke@3 | 828 | /* Short forms of external names for systems with brain-damaged linkers. |
duke@3 | 829 | * We shorten external names to be unique in the first six letters, which |
duke@3 | 830 | * is good enough for all known systems. |
duke@3 | 831 | * (If your compiler itself needs names to be unique in less than 15 |
duke@3 | 832 | * characters, you are out of luck. Get a better compiler.) |
duke@3 | 833 | */ |
duke@3 | 834 | |
duke@3 | 835 | #ifdef NEED_SHORT_EXTERNAL_NAMES |
duke@3 | 836 | #define jpeg_std_error jStdError |
duke@3 | 837 | #define jpeg_CreateCompress jCreaCompress |
duke@3 | 838 | #define jpeg_CreateDecompress jCreaDecompress |
duke@3 | 839 | #define jpeg_destroy_compress jDestCompress |
duke@3 | 840 | #define jpeg_destroy_decompress jDestDecompress |
duke@3 | 841 | #define jpeg_stdio_dest jStdDest |
duke@3 | 842 | #define jpeg_stdio_src jStdSrc |
duke@3 | 843 | #define jpeg_set_defaults jSetDefaults |
duke@3 | 844 | #define jpeg_set_colorspace jSetColorspace |
duke@3 | 845 | #define jpeg_default_colorspace jDefColorspace |
duke@3 | 846 | #define jpeg_set_quality jSetQuality |
duke@3 | 847 | #define jpeg_set_linear_quality jSetLQuality |
duke@3 | 848 | #define jpeg_add_quant_table jAddQuantTable |
duke@3 | 849 | #define jpeg_quality_scaling jQualityScaling |
duke@3 | 850 | #define jpeg_simple_progression jSimProgress |
duke@3 | 851 | #define jpeg_suppress_tables jSuppressTables |
duke@3 | 852 | #define jpeg_alloc_quant_table jAlcQTable |
duke@3 | 853 | #define jpeg_alloc_huff_table jAlcHTable |
duke@3 | 854 | #define jpeg_start_compress jStrtCompress |
duke@3 | 855 | #define jpeg_write_scanlines jWrtScanlines |
duke@3 | 856 | #define jpeg_finish_compress jFinCompress |
duke@3 | 857 | #define jpeg_write_raw_data jWrtRawData |
duke@3 | 858 | #define jpeg_write_marker jWrtMarker |
duke@3 | 859 | #define jpeg_write_m_header jWrtMHeader |
duke@3 | 860 | #define jpeg_write_m_byte jWrtMByte |
duke@3 | 861 | #define jpeg_write_tables jWrtTables |
duke@3 | 862 | #define jpeg_read_header jReadHeader |
duke@3 | 863 | #define jpeg_start_decompress jStrtDecompress |
duke@3 | 864 | #define jpeg_read_scanlines jReadScanlines |
duke@3 | 865 | #define jpeg_finish_decompress jFinDecompress |
duke@3 | 866 | #define jpeg_read_raw_data jReadRawData |
duke@3 | 867 | #define jpeg_has_multiple_scans jHasMultScn |
duke@3 | 868 | #define jpeg_start_output jStrtOutput |
duke@3 | 869 | #define jpeg_finish_output jFinOutput |
duke@3 | 870 | #define jpeg_input_complete jInComplete |
duke@3 | 871 | #define jpeg_new_colormap jNewCMap |
duke@3 | 872 | #define jpeg_consume_input jConsumeInput |
duke@3 | 873 | #define jpeg_calc_output_dimensions jCalcDimensions |
duke@3 | 874 | #define jpeg_save_markers jSaveMarkers |
duke@3 | 875 | #define jpeg_set_marker_processor jSetMarker |
duke@3 | 876 | #define jpeg_read_coefficients jReadCoefs |
duke@3 | 877 | #define jpeg_write_coefficients jWrtCoefs |
duke@3 | 878 | #define jpeg_copy_critical_parameters jCopyCrit |
duke@3 | 879 | #define jpeg_abort_compress jAbrtCompress |
duke@3 | 880 | #define jpeg_abort_decompress jAbrtDecompress |
duke@3 | 881 | #define jpeg_abort jAbort |
duke@3 | 882 | #define jpeg_destroy jDestroy |
duke@3 | 883 | #define jpeg_resync_to_restart jResyncRestart |
duke@3 | 884 | #endif /* NEED_SHORT_EXTERNAL_NAMES */ |
duke@3 | 885 | |
duke@3 | 886 | |
duke@3 | 887 | /* Default error-management setup */ |
duke@3 | 888 | EXTERN(struct jpeg_error_mgr *) jpeg_std_error |
duke@3 | 889 | JPP((struct jpeg_error_mgr * err)); |
duke@3 | 890 | |
duke@3 | 891 | /* Initialization of JPEG compression objects. |
duke@3 | 892 | * jpeg_create_compress() and jpeg_create_decompress() are the exported |
duke@3 | 893 | * names that applications should call. These expand to calls on |
duke@3 | 894 | * jpeg_CreateCompress and jpeg_CreateDecompress with additional information |
duke@3 | 895 | * passed for version mismatch checking. |
duke@3 | 896 | * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx. |
duke@3 | 897 | */ |
duke@3 | 898 | #define jpeg_create_compress(cinfo) \ |
duke@3 | 899 | jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \ |
duke@3 | 900 | (size_t) sizeof(struct jpeg_compress_struct)) |
duke@3 | 901 | #define jpeg_create_decompress(cinfo) \ |
duke@3 | 902 | jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \ |
duke@3 | 903 | (size_t) sizeof(struct jpeg_decompress_struct)) |
duke@3 | 904 | EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo, |
duke@3 | 905 | int version, size_t structsize)); |
duke@3 | 906 | EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo, |
duke@3 | 907 | int version, size_t structsize)); |
duke@3 | 908 | /* Destruction of JPEG compression objects */ |
duke@3 | 909 | EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo)); |
duke@3 | 910 | EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo)); |
duke@3 | 911 | |
duke@3 | 912 | /* Standard data source and destination managers: stdio streams. */ |
duke@3 | 913 | /* Caller is responsible for opening the file before and closing after. */ |
duke@3 | 914 | EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile)); |
duke@3 | 915 | EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile)); |
duke@3 | 916 | |
duke@3 | 917 | /* Default parameter setup for compression */ |
duke@3 | 918 | EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo)); |
duke@3 | 919 | /* Compression parameter setup aids */ |
duke@3 | 920 | EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo, |
duke@3 | 921 | J_COLOR_SPACE colorspace)); |
duke@3 | 922 | EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo)); |
duke@3 | 923 | EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality, |
duke@3 | 924 | boolean force_baseline)); |
duke@3 | 925 | EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo, |
duke@3 | 926 | int scale_factor, |
duke@3 | 927 | boolean force_baseline)); |
duke@3 | 928 | EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl, |
duke@3 | 929 | const unsigned int *basic_table, |
duke@3 | 930 | int scale_factor, |
duke@3 | 931 | boolean force_baseline)); |
duke@3 | 932 | EXTERN(int) jpeg_quality_scaling JPP((int quality)); |
duke@3 | 933 | EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo)); |
duke@3 | 934 | EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo, |
duke@3 | 935 | boolean suppress)); |
duke@3 | 936 | EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo)); |
duke@3 | 937 | EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo)); |
duke@3 | 938 | |
duke@3 | 939 | /* Main entry points for compression */ |
duke@3 | 940 | EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo, |
duke@3 | 941 | boolean write_all_tables)); |
duke@3 | 942 | EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo, |
duke@3 | 943 | JSAMPARRAY scanlines, |
duke@3 | 944 | JDIMENSION num_lines)); |
duke@3 | 945 | EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo)); |
duke@3 | 946 | |
duke@3 | 947 | /* Replaces jpeg_write_scanlines when writing raw downsampled data. */ |
duke@3 | 948 | EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo, |
duke@3 | 949 | JSAMPIMAGE data, |
duke@3 | 950 | JDIMENSION num_lines)); |
duke@3 | 951 | |
duke@3 | 952 | /* Write a special marker. See libjpeg.doc concerning safe usage. */ |
duke@3 | 953 | EXTERN(void) jpeg_write_marker |
duke@3 | 954 | JPP((j_compress_ptr cinfo, int marker, |
duke@3 | 955 | const JOCTET * dataptr, unsigned int datalen)); |
duke@3 | 956 | /* Same, but piecemeal. */ |
duke@3 | 957 | EXTERN(void) jpeg_write_m_header |
duke@3 | 958 | JPP((j_compress_ptr cinfo, int marker, unsigned int datalen)); |
duke@3 | 959 | EXTERN(void) jpeg_write_m_byte |
duke@3 | 960 | JPP((j_compress_ptr cinfo, int val)); |
duke@3 | 961 | |
duke@3 | 962 | /* Alternate compression function: just write an abbreviated table file */ |
duke@3 | 963 | EXTERN(void) jpeg_write_tables JPP((j_compress_ptr cinfo)); |
duke@3 | 964 | |
duke@3 | 965 | /* Decompression startup: read start of JPEG datastream to see what's there */ |
duke@3 | 966 | EXTERN(int) jpeg_read_header JPP((j_decompress_ptr cinfo, |
duke@3 | 967 | boolean require_image)); |
duke@3 | 968 | /* Return value is one of: */ |
duke@3 | 969 | #define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */ |
duke@3 | 970 | #define JPEG_HEADER_OK 1 /* Found valid image datastream */ |
duke@3 | 971 | #define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */ |
duke@3 | 972 | /* If you pass require_image = TRUE (normal case), you need not check for |
duke@3 | 973 | * a TABLES_ONLY return code; an abbreviated file will cause an error exit. |
duke@3 | 974 | * JPEG_SUSPENDED is only possible if you use a data source module that can |
duke@3 | 975 | * give a suspension return (the stdio source module doesn't). |
duke@3 | 976 | */ |
duke@3 | 977 | |
duke@3 | 978 | /* Main entry points for decompression */ |
duke@3 | 979 | EXTERN(boolean) jpeg_start_decompress JPP((j_decompress_ptr cinfo)); |
duke@3 | 980 | EXTERN(JDIMENSION) jpeg_read_scanlines JPP((j_decompress_ptr cinfo, |
duke@3 | 981 | JSAMPARRAY scanlines, |
duke@3 | 982 | JDIMENSION max_lines)); |
duke@3 | 983 | EXTERN(boolean) jpeg_finish_decompress JPP((j_decompress_ptr cinfo)); |
duke@3 | 984 | |
duke@3 | 985 | /* Replaces jpeg_read_scanlines when reading raw downsampled data. */ |
duke@3 | 986 | EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo, |
duke@3 | 987 | JSAMPIMAGE data, |
duke@3 | 988 | JDIMENSION max_lines)); |
duke@3 | 989 | |
duke@3 | 990 | /* Additional entry points for buffered-image mode. */ |
duke@3 | 991 | EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo)); |
duke@3 | 992 | EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo, |
duke@3 | 993 | int scan_number)); |
duke@3 | 994 | EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo)); |
duke@3 | 995 | EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo)); |
duke@3 | 996 | EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo)); |
duke@3 | 997 | EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo)); |
duke@3 | 998 | /* Return value is one of: */ |
duke@3 | 999 | /* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */ |
duke@3 | 1000 | #define JPEG_REACHED_SOS 1 /* Reached start of new scan */ |
duke@3 | 1001 | #define JPEG_REACHED_EOI 2 /* Reached end of image */ |
duke@3 | 1002 | #define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */ |
duke@3 | 1003 | #define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */ |
duke@3 | 1004 | |
duke@3 | 1005 | /* Precalculate output dimensions for current decompression parameters. */ |
duke@3 | 1006 | EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo)); |
duke@3 | 1007 | |
duke@3 | 1008 | /* Control saving of COM and APPn markers into marker_list. */ |
duke@3 | 1009 | EXTERN(void) jpeg_save_markers |
duke@3 | 1010 | JPP((j_decompress_ptr cinfo, int marker_code, |
duke@3 | 1011 | unsigned int length_limit)); |
duke@3 | 1012 | |
duke@3 | 1013 | /* Install a special processing method for COM or APPn markers. */ |
duke@3 | 1014 | EXTERN(void) jpeg_set_marker_processor |
duke@3 | 1015 | JPP((j_decompress_ptr cinfo, int marker_code, |
duke@3 | 1016 | jpeg_marker_parser_method routine)); |
duke@3 | 1017 | |
duke@3 | 1018 | /* Read or write raw DCT coefficients --- useful for lossless transcoding. */ |
duke@3 | 1019 | EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo)); |
duke@3 | 1020 | EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo, |
duke@3 | 1021 | jvirt_barray_ptr * coef_arrays)); |
duke@3 | 1022 | EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo, |
duke@3 | 1023 | j_compress_ptr dstinfo)); |
duke@3 | 1024 | |
duke@3 | 1025 | /* If you choose to abort compression or decompression before completing |
duke@3 | 1026 | * jpeg_finish_(de)compress, then you need to clean up to release memory, |
duke@3 | 1027 | * temporary files, etc. You can just call jpeg_destroy_(de)compress |
duke@3 | 1028 | * if you're done with the JPEG object, but if you want to clean it up and |
duke@3 | 1029 | * reuse it, call this: |
duke@3 | 1030 | */ |
duke@3 | 1031 | EXTERN(void) jpeg_abort_compress JPP((j_compress_ptr cinfo)); |
duke@3 | 1032 | EXTERN(void) jpeg_abort_decompress JPP((j_decompress_ptr cinfo)); |
duke@3 | 1033 | |
duke@3 | 1034 | /* Generic versions of jpeg_abort and jpeg_destroy that work on either |
duke@3 | 1035 | * flavor of JPEG object. These may be more convenient in some places. |
duke@3 | 1036 | */ |
duke@3 | 1037 | EXTERN(void) jpeg_abort JPP((j_common_ptr cinfo)); |
duke@3 | 1038 | EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo)); |
duke@3 | 1039 | |
duke@3 | 1040 | /* Default restart-marker-resync procedure for use by data source modules */ |
duke@3 | 1041 | EXTERN(boolean) jpeg_resync_to_restart JPP((j_decompress_ptr cinfo, |
duke@3 | 1042 | int desired)); |
duke@3 | 1043 | |
duke@3 | 1044 | |
duke@3 | 1045 | /* These marker codes are exported since applications and data source modules |
duke@3 | 1046 | * are likely to want to use them. |
duke@3 | 1047 | */ |
duke@3 | 1048 | |
duke@3 | 1049 | #define JPEG_RST0 0xD0 /* RST0 marker code */ |
duke@3 | 1050 | #define JPEG_EOI 0xD9 /* EOI marker code */ |
duke@3 | 1051 | #define JPEG_APP0 0xE0 /* APP0 marker code */ |
duke@3 | 1052 | #define JPEG_COM 0xFE /* COM marker code */ |
duke@3 | 1053 | |
duke@3 | 1054 | |
duke@3 | 1055 | /* If we have a brain-damaged compiler that emits warnings (or worse, errors) |
duke@3 | 1056 | * for structure definitions that are never filled in, keep it quiet by |
duke@3 | 1057 | * supplying dummy definitions for the various substructures. |
duke@3 | 1058 | */ |
duke@3 | 1059 | |
duke@3 | 1060 | #ifdef INCOMPLETE_TYPES_BROKEN |
duke@3 | 1061 | #ifndef JPEG_INTERNALS /* will be defined in jpegint.h */ |
duke@3 | 1062 | struct jvirt_sarray_control { long dummy; }; |
duke@3 | 1063 | struct jvirt_barray_control { long dummy; }; |
duke@3 | 1064 | struct jpeg_comp_master { long dummy; }; |
duke@3 | 1065 | struct jpeg_c_main_controller { long dummy; }; |
duke@3 | 1066 | struct jpeg_c_prep_controller { long dummy; }; |
duke@3 | 1067 | struct jpeg_c_coef_controller { long dummy; }; |
duke@3 | 1068 | struct jpeg_marker_writer { long dummy; }; |
duke@3 | 1069 | struct jpeg_color_converter { long dummy; }; |
duke@3 | 1070 | struct jpeg_downsampler { long dummy; }; |
duke@3 | 1071 | struct jpeg_forward_dct { long dummy; }; |
duke@3 | 1072 | struct jpeg_entropy_encoder { long dummy; }; |
duke@3 | 1073 | struct jpeg_decomp_master { long dummy; }; |
duke@3 | 1074 | struct jpeg_d_main_controller { long dummy; }; |
duke@3 | 1075 | struct jpeg_d_coef_controller { long dummy; }; |
duke@3 | 1076 | struct jpeg_d_post_controller { long dummy; }; |
duke@3 | 1077 | struct jpeg_input_controller { long dummy; }; |
duke@3 | 1078 | struct jpeg_marker_reader { long dummy; }; |
duke@3 | 1079 | struct jpeg_entropy_decoder { long dummy; }; |
duke@3 | 1080 | struct jpeg_inverse_dct { long dummy; }; |
duke@3 | 1081 | struct jpeg_upsampler { long dummy; }; |
duke@3 | 1082 | struct jpeg_color_deconverter { long dummy; }; |
duke@3 | 1083 | struct jpeg_color_quantizer { long dummy; }; |
duke@3 | 1084 | #endif /* JPEG_INTERNALS */ |
duke@3 | 1085 | #endif /* INCOMPLETE_TYPES_BROKEN */ |
duke@3 | 1086 | |
duke@3 | 1087 | |
duke@3 | 1088 | /* |
duke@3 | 1089 | * The JPEG library modules define JPEG_INTERNALS before including this file. |
duke@3 | 1090 | * The internal structure declarations are read only when that is true. |
duke@3 | 1091 | * Applications using the library should not include jpegint.h, but may wish |
duke@3 | 1092 | * to include jerror.h. |
duke@3 | 1093 | */ |
duke@3 | 1094 | |
duke@3 | 1095 | #ifdef JPEG_INTERNALS |
duke@3 | 1096 | #include "jpegint.h" /* fetch private declarations */ |
duke@3 | 1097 | #include "jerror.h" /* fetch error codes too */ |
duke@3 | 1098 | #endif |
duke@3 | 1099 | |
duke@3 | 1100 | #endif /* JPEGLIB_H */ |