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