DEADSOFTWARE

new code for blood particles (other particles are turned off temporarily): almost...
[d2df-sdl.git] / src / lib / vampimg / JpegLib / imjpeglib.pas
1 unit imjpeglib;
3 { This file defines the application interface for the JPEG library.
4 Most applications using the library need only include this file,
5 and perhaps jerror.h if they want to know the exact error codes. }
7 { Source:jpeglib.h+jpegint.h; Copyright (C) 1991-1998, Thomas G. Lane. }
10 interface
12 {$I imjconfig.inc}
14 { First we include the configuration files that record how this
15 installation of the JPEG library is set up. jconfig.h can be
16 generated automatically for many systems. jmorecfg.h contains
17 manual configuration options that most people need not worry about. }
19 uses
20 imjdeferr,
21 imjmorecfg; { seldom changed options }
23 { Version ID for the JPEG library.
24 Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". }
27 Const
28 JPEG_LIB_VERSION = 62; { Version 6b }
31 { These marker codes are exported since applications and data source modules
32 are likely to want to use them. }
34 const
35 JPEG_RST0 = $D0; { RST0 marker code }
36 JPEG_EOI = $D9; { EOI marker code }
37 JPEG_APP0 = $E0; { APP0 marker code }
38 JPEG_COM = $FE; { COM marker code }
41 { Various constants determining the sizes of things.
42 All of these are specified by the JPEG standard, so don't change them
43 if you want to be compatible. }
45 const
46 DCTSIZE = 8; { The basic DCT block is 8x8 samples }
47 DCTSIZE2 = 64; { DCTSIZE squared; # of elements in a block }
48 NUM_QUANT_TBLS = 4; { Quantization tables are numbered 0..3 }
49 NUM_HUFF_TBLS = 4; { Huffman tables are numbered 0..3 }
50 NUM_ARITH_TBLS = 16; { Arith-coding tables are numbered 0..15 }
51 MAX_COMPS_IN_SCAN = 4; { JPEG limit on # of components in one scan }
52 MAX_SAMP_FACTOR = 4; { JPEG limit on sampling factors }
53 { Unfortunately, some bozo at Adobe saw no reason to be bound by the standard;
54 the PostScript DCT filter can emit files with many more than 10 blocks/MCU.
55 If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU
56 to handle it. We even let you do this from the jconfig.h file. However,
57 we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe
58 sometimes emits noncompliant files doesn't mean you should too. }
59 C_MAX_BLOCKS_IN_MCU = 10; { compressor's limit on blocks per MCU }
60 D_MAX_BLOCKS_IN_MCU = 10; { decompressor's limit on blocks per MCU }
63 { Data structures for images (arrays of samples and of DCT coefficients).
64 On 80x86 machines, the image arrays are too big for near pointers,
65 but the pointer arrays can fit in near memory. }
67 type
68 { for typecasting }
69 JSAMPLE_PTR = ^JSAMPLE;
70 JSAMPROW_PTR = ^JSAMPROW;
71 JBLOCKROW_PTR = ^JBLOCKROW;
73 jTSample = 0..(MaxInt div SIZEOF(JSAMPLE))-1;
74 JSAMPLE_ARRAY = Array[jTSample] of JSAMPLE; {far}
75 JSAMPROW = ^JSAMPLE_ARRAY; { ptr to one image row of pixel samples. }
77 jTRow = 0..(MaxInt div SIZEOF(JSAMPROW))-1;
78 JSAMPROW_ARRAY = Array[jTRow] of JSAMPROW;
79 JSAMPARRAY = ^JSAMPROW_ARRAY; { ptr to some rows (a 2-D sample array) }
81 jTArray = 0..(MaxInt div SIZEOF(JSAMPARRAY))-1;
82 JSAMP_ARRAY = Array[jTArray] of JSAMPARRAY;
83 JSAMPIMAGE = ^JSAMP_ARRAY; { a 3-D sample array: top index is color }
85 JBLOCK = Array[0..DCTSIZE2-1] of JCOEF; { one block of coefficients }
86 JBLOCK_PTR = ^JBLOCK;
88 jTBlockRow = 0..(MaxInt div SIZEOF(JBLOCK))-1;
89 JBLOCK_ROWS = Array[jTBlockRow] of JBLOCK;
90 JBLOCKROW = ^JBLOCK_ROWS; {far} { pointer to one row of coefficient blocks }
93 jTBlockArray = 0..(MaxInt div SIZEOF(JBLOCKROW))-1;
94 JBLOCK_ARRAY = Array[jTBlockArray] of JBLOCKROW;
95 JBLOCKARRAY = ^JBLOCK_ARRAY; { a 2-D array of coefficient blocks }
97 jTBlockImage = 0..(MaxInt div SIZEOF(JBLOCKARRAY))-1;
98 JBLOCK_IMAGE = Array[jTBlockImage] of JBLOCKARRAY;
99 JBLOCKIMAGE = ^JBLOCK_IMAGE; { a 3-D array of coefficient blocks }
101 jTCoef = 0..(MaxInt div SIZEOF(JCOEF))-1;
102 JCOEF_ROW = Array[jTCoef] of JCOEF;
103 JCOEFPTR = ^JCOEF_ROW; {far} { useful in a couple of places }
106 type
107 jTByte = 0..(MaxInt div SIZEOF(byte))-1;
108 JByteArray = Array[jTByte] of byte;
109 JBytePtr = ^JByteArray;
110 type
111 byteptr = ^byte;
113 { Types for JPEG compression parameters and working tables. }
116 { DCT coefficient quantization tables. }
118 type
119 JQUANT_TBL_PTR = ^JQUANT_TBL;
120 JQUANT_TBL = record
121 { This array gives the coefficient quantizers in natural array order
122 (not the zigzag order in which they are stored in a JPEG DQT marker).
123 CAUTION: IJG versions prior to v6a kept this array in zigzag order. }
124 quantval : Array[0..DCTSIZE2-1] of UINT16;
125 { quantization step for each coefficient }
126 { This field is used only during compression. It's initialized FALSE when
127 the table is created, and set TRUE when it's been output to the file.
128 You could suppress output of a table by setting this to TRUE.
129 (See jpeg_suppress_tables for an example.) }
130 sent_table : boolean; { TRUE when table has been output }
131 end;
132 JQUANT_TBL_FIELD = Array[0..(MaxInt div SizeOf(JQUANT_TBL))-1] of JQUANT_TBL;
134 { Huffman coding tables. }
136 type
137 JHUFF_TBL_PTR = ^JHUFF_TBL;
138 JHUFF_TBL = record
139 { These two fields directly represent the contents of a JPEG DHT marker }
140 bits : Array[0..17-1] of UINT8; { bits[k] = # of symbols with codes of }
141 { length k bits; bits[0] is unused }
142 huffval : Array[0..256-1] of UINT8;
143 { The symbols, in order of incr code length }
144 { This field is used only during compression. It's initialized FALSE when
145 the table is created, and set TRUE when it's been output to the file.
146 You could suppress output of a table by setting this to TRUE.
147 (See jpeg_suppress_tables for an example.) }
148 sent_table : boolean; { TRUE when table has been output }
149 end;
150 JHUFF_TBL_FIELD = Array[0..(MaxInt div SizeOf(JHUFF_TBL))-1] of JHUFF_TBL;
152 { Declarations for both compression & decompression }
154 type
155 J_BUF_MODE = ( { Operating modes for buffer controllers }
156 JBUF_PASS_THRU, { Plain stripwise operation }
157 { Remaining modes require a full-image buffer to have been created }
158 JBUF_SAVE_SOURCE, { Run source subobject only, save output }
159 JBUF_CRANK_DEST, { Run dest subobject only, using saved data }
160 JBUF_SAVE_AND_PASS { Run both subobjects, save output }
161 );
163 { Values of global_state field (jdapi.c has some dependencies on ordering!) }
164 const
165 CSTATE_START = 100; { after create_compress }
166 CSTATE_SCANNING = 101; { start_compress done, write_scanlines OK }
167 CSTATE_RAW_OK = 102; { start_compress done, write_raw_data OK }
168 CSTATE_WRCOEFS = 103; { jpeg_write_coefficients done }
169 DSTATE_START = 200; { after create_decompress }
170 DSTATE_INHEADER = 201; { reading header markers, no SOS yet }
171 DSTATE_READY = 202; { found SOS, ready for start_decompress }
172 DSTATE_PRELOAD = 203; { reading multiscan file in start_decompress}
173 DSTATE_PRESCAN = 204; { performing dummy pass for 2-pass quant }
174 DSTATE_SCANNING = 205; { start_decompress done, read_scanlines OK }
175 DSTATE_RAW_OK = 206; { start_decompress done, read_raw_data OK }
176 DSTATE_BUFIMAGE = 207; { expecting jpeg_start_output }
177 DSTATE_BUFPOST = 208; { looking for SOS/EOI in jpeg_finish_output }
178 DSTATE_RDCOEFS = 209; { reading file in jpeg_read_coefficients }
179 DSTATE_STOPPING = 210; { looking for EOI in jpeg_finish_decompress }
183 { Basic info about one component (color channel). }
185 type
186 jpeg_component_info_ptr = ^jpeg_component_info;
187 jpeg_component_info = record
188 { These values are fixed over the whole image. }
189 { For compression, they must be supplied by parameter setup; }
190 { for decompression, they are read from the SOF marker. }
191 component_id : int; { identifier for this component (0..255) }
192 component_index : int; { its index in SOF or cinfo^.comp_info[] }
193 h_samp_factor : int; { horizontal sampling factor (1..4) }
194 v_samp_factor : int; { vertical sampling factor (1..4) }
195 quant_tbl_no : int; { quantization table selector (0..3) }
196 { These values may vary between scans. }
197 { For compression, they must be supplied by parameter setup; }
198 { for decompression, they are read from the SOS marker. }
199 { The decompressor output side may not use these variables. }
200 dc_tbl_no : int; { DC entropy table selector (0..3) }
201 ac_tbl_no : int; { AC entropy table selector (0..3) }
203 { Remaining fields should be treated as private by applications. }
205 { These values are computed during compression or decompression startup: }
206 { Component's size in DCT blocks.
207 Any dummy blocks added to complete an MCU are not counted; therefore
208 these values do not depend on whether a scan is interleaved or not. }
209 width_in_blocks : JDIMENSION;
210 height_in_blocks : JDIMENSION;
211 { Size of a DCT block in samples. Always DCTSIZE for compression.
212 For decompression this is the size of the output from one DCT block,
213 reflecting any scaling we choose to apply during the IDCT step.
214 Values of 1,2,4,8 are likely to be supported. Note that different
215 components may receive different IDCT scalings. }
217 DCT_scaled_size : int;
218 { The downsampled dimensions are the component's actual, unpadded number
219 of samples at the main buffer (preprocessing/compression interface), thus
220 downsampled_width = ceil(image_width * Hi/Hmax)
221 and similarly for height. For decompression, IDCT scaling is included, so
222 downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE)}
224 downsampled_width : JDIMENSION; { actual width in samples }
225 downsampled_height : JDIMENSION; { actual height in samples }
226 { This flag is used only for decompression. In cases where some of the
227 components will be ignored (eg grayscale output from YCbCr image),
228 we can skip most computations for the unused components. }
230 component_needed : boolean; { do we need the value of this component? }
232 { These values are computed before starting a scan of the component. }
233 { The decompressor output side may not use these variables. }
234 MCU_width : int; { number of blocks per MCU, horizontally }
235 MCU_height : int; { number of blocks per MCU, vertically }
236 MCU_blocks : int; { MCU_width * MCU_height }
237 MCU_sample_width : int; { MCU width in samples, MCU_width*DCT_scaled_size }
238 last_col_width : int; { # of non-dummy blocks across in last MCU }
239 last_row_height : int; { # of non-dummy blocks down in last MCU }
241 { Saved quantization table for component; NIL if none yet saved.
242 See jdinput.c comments about the need for this information.
243 This field is currently used only for decompression. }
245 quant_table : JQUANT_TBL_PTR;
247 { Private per-component storage for DCT or IDCT subsystem. }
248 dct_table : pointer;
249 end; { record jpeg_component_info }
251 jTCinfo = 0..(MaxInt div SizeOf(jpeg_component_info))-1;
252 jpeg_component_info_array = array[jTCinfo] of jpeg_component_info;
253 jpeg_component_info_list_ptr = ^jpeg_component_info_array;
256 { The script for encoding a multiple-scan file is an array of these: }
258 type
259 jpeg_scan_info_ptr = ^jpeg_scan_info;
260 jpeg_scan_info = record
261 comps_in_scan : int; { number of components encoded in this scan }
262 component_index : Array[0..MAX_COMPS_IN_SCAN-1] of int;
263 { their SOF/comp_info[] indexes }
264 Ss, Se : int; { progressive JPEG spectral selection parms }
265 Ah, Al : int; { progressive JPEG successive approx. parms }
266 end;
268 { The decompressor can save APPn and COM markers in a list of these: }
270 type
271 jpeg_saved_marker_ptr = ^jpeg_marker_struct;
272 jpeg_marker_struct = record
273 next : jpeg_saved_marker_ptr; { next in list, or NULL }
274 marker : UINT8; { marker code: JPEG_COM, or JPEG_APP0+n }
275 original_length : uint; { # bytes of data in the file }
276 data_length : uint; { # bytes of data saved at data[] }
277 data : JOCTET_FIELD_PTR; { the data contained in the marker }
278 { the marker length word is not counted in data_length or original_length }
279 end;
281 { Known color spaces. }
283 type
284 J_COLOR_SPACE = (
285 JCS_UNKNOWN, { error/unspecified }
286 JCS_GRAYSCALE, { monochrome }
287 JCS_RGB, { red/green/blue }
288 JCS_YCbCr, { Y/Cb/Cr (also known as YUV) }
289 JCS_CMYK, { C/M/Y/K }
290 JCS_YCCK { Y/Cb/Cr/K }
291 );
293 { DCT/IDCT algorithm options. }
295 type
296 J_DCT_METHOD = (
297 JDCT_ISLOW, { slow but accurate integer algorithm }
298 JDCT_IFAST, { faster, less accurate integer method }
299 JDCT_FLOAT { floating-point: accurate, fast on fast HW }
300 );
302 const
303 JDCT_DEFAULT = JDCT_ISLOW;
304 JDCT_FASTEST = JDCT_IFAST;
306 { Dithering options for decompression. }
308 type
309 J_DITHER_MODE = (
310 JDITHER_NONE, { no dithering }
311 JDITHER_ORDERED, { simple ordered dither }
312 JDITHER_FS { Floyd-Steinberg error diffusion dither }
313 );
316 const
317 JPOOL_PERMANENT = 0; { lasts until master record is destroyed }
318 JPOOL_IMAGE = 1; { lasts until done with image/datastream }
319 JPOOL_NUMPOOLS = 2;
322 { "Object" declarations for JPEG modules that may be supplied or called
323 directly by the surrounding application.
324 As with all objects in the JPEG library, these structs only define the
325 publicly visible methods and state variables of a module. Additional
326 private fields may exist after the public ones. }
329 { Error handler object }
331 const
332 JMSG_LENGTH_MAX = 200; { recommended size of format_message buffer }
333 JMSG_STR_PARM_MAX = 80;
335 const
336 TEMP_NAME_LENGTH = 64; { max length of a temporary file's name }
337 type
338 TEMP_STRING = string[TEMP_NAME_LENGTH];
340 {$ifdef USE_MSDOS_MEMMGR} { DOS-specific junk }
341 type
342 XMSH = ushort; { type of extended-memory handles }
343 EMSH = ushort; { type of expanded-memory handles }
345 handle_union = record
346 case byte of
347 0:(file_handle : short); { DOS file handle if it's a temp file }
348 1:(xms_handle : XMSH); { handle if it's a chunk of XMS }
349 2:(ems_handle : EMSH); { handle if it's a chunk of EMS }
350 end;
351 {$endif} { USE_MSDOS_MEMMGR }
353 type
354 jpeg_error_mgr_ptr = ^jpeg_error_mgr;
355 jpeg_memory_mgr_ptr = ^jpeg_memory_mgr;
356 jpeg_progress_mgr_ptr = ^jpeg_progress_mgr;
359 {$ifdef common}
360 { Common fields between JPEG compression and decompression master structs. }
361 err : jpeg_error_mgr_ptr; { Error handler module }
362 mem : jpeg_memory_mgr_ptr; { Memory manager module }
363 progress : jpeg_progress_mgr_ptr; { Progress monitor, or NIL if none }
364 client_data : voidp; { Available for use by application }
365 is_decompressor : boolean; { so common code can tell which is which }
366 global_state : int; { for checking call sequence validity }
367 {$endif}
369 j_common_ptr = ^jpeg_common_struct;
370 j_compress_ptr = ^jpeg_compress_struct;
371 j_decompress_ptr = ^jpeg_decompress_struct;
373 {$ifdef AM_MEMORY_MANAGER} { only jmemmgr.c defines these }
375 { This structure holds whatever state is needed to access a single
376 backing-store object. The read/write/close method pointers are called
377 by jmemmgr.c to manipulate the backing-store object; all other fields
378 are private to the system-dependent backing store routines. }
381 backing_store_ptr = ^backing_store_info;
382 backing_store_info = record
383 { Methods for reading/writing/closing this backing-store object }
384 read_backing_store : procedure (cinfo : j_common_ptr;
385 info : backing_store_ptr;
386 buffer_address : pointer; {far}
387 file_offset : long;
388 byte_count : long);
389 write_backing_store : procedure (cinfo : j_common_ptr;
390 info : backing_store_ptr;
391 buffer_address : pointer; {far}
392 file_offset : long;
393 byte_count : long);
395 close_backing_store : procedure (cinfo : j_common_ptr;
396 info : backing_store_ptr);
398 { Private fields for system-dependent backing-store management }
399 {$ifdef USE_MSDOS_MEMMGR}
400 { For the MS-DOS manager (jmemdos.c), we need: }
401 handle : handle_union; { reference to backing-store storage object }
402 temp_name : TEMP_STRING; { name if it's a file }
403 {$else}
404 { For a typical implementation with temp files, we need: }
405 temp_file : file; { stdio reference to temp file }
406 temp_name : TEMP_STRING; { name of temp file }
407 {$endif}
408 end;
411 { The control blocks for virtual arrays.
412 Note that these blocks are allocated in the "small" pool area.
413 System-dependent info for the associated backing store (if any) is hidden
414 inside the backing_store_info struct. }
416 jvirt_sarray_ptr = ^jvirt_sarray_control;
417 jvirt_sarray_control = record
418 mem_buffer : JSAMPARRAY; { => the in-memory buffer }
419 rows_in_array : JDIMENSION; { total virtual array height }
420 samplesperrow : JDIMENSION; { width of array (and of memory buffer) }
421 maxaccess : JDIMENSION; { max rows accessed by access_virt_sarray }
422 rows_in_mem : JDIMENSION; { height of memory buffer }
423 rowsperchunk : JDIMENSION; { allocation chunk size in mem_buffer }
424 cur_start_row : JDIMENSION; { first logical row # in the buffer }
425 first_undef_row : JDIMENSION; { row # of first uninitialized row }
426 pre_zero : boolean; { pre-zero mode requested? }
427 dirty : boolean; { do current buffer contents need written? }
428 b_s_open : boolean; { is backing-store data valid? }
429 next : jvirt_sarray_ptr; { link to next virtual sarray control block }
430 b_s_info : backing_store_info; { System-dependent control info }
431 end;
433 jvirt_barray_ptr = ^jvirt_barray_control;
434 jvirt_barray_control = record
435 mem_buffer : JBLOCKARRAY; { => the in-memory buffer }
436 rows_in_array : JDIMENSION; { total virtual array height }
437 blocksperrow : JDIMENSION; { width of array (and of memory buffer) }
438 maxaccess : JDIMENSION; { max rows accessed by access_virt_barray }
439 rows_in_mem : JDIMENSION; { height of memory buffer }
440 rowsperchunk : JDIMENSION; { allocation chunk size in mem_buffer }
441 cur_start_row : JDIMENSION; { first logical row # in the buffer }
442 first_undef_row : JDIMENSION; { row # of first uninitialized row }
443 pre_zero : boolean; { pre-zero mode requested? }
444 dirty : boolean; { do current buffer contents need written? }
445 b_s_open : boolean; { is backing-store data valid? }
446 next : jvirt_barray_ptr; { link to next virtual barray control block }
447 b_s_info : backing_store_info; { System-dependent control info }
448 end;
450 {$endif} { AM_MEMORY_MANAGER }
452 { Declarations for compression modules }
454 { Master control module }
455 jpeg_comp_master_ptr = ^jpeg_comp_master;
456 jpeg_comp_master = record
457 prepare_for_pass : procedure(cinfo : j_compress_ptr);
458 pass_startup : procedure(cinfo : j_compress_ptr);
459 finish_pass : procedure(cinfo : j_compress_ptr);
461 { State variables made visible to other modules }
462 call_pass_startup : Boolean; { True if pass_startup must be called }
463 is_last_pass : Boolean; { True during last pass }
464 end;
466 { Main buffer control (downsampled-data buffer) }
467 jpeg_c_main_controller_ptr = ^jpeg_c_main_controller;
468 jpeg_c_main_controller = record
469 start_pass : procedure(cinfo : j_compress_ptr; pass_mode : J_BUF_MODE);
470 process_data : procedure(cinfo : j_compress_ptr;
471 input_buf : JSAMPARRAY;
472 var in_row_ctr : JDIMENSION;
473 in_rows_avail : JDIMENSION);
474 end;
476 { Compression preprocessing (downsampling input buffer control) }
477 jpeg_c_prep_controller_ptr = ^jpeg_c_prep_controller;
478 jpeg_c_prep_controller = record
479 start_pass : procedure(cinfo : j_compress_ptr; pass_mode : J_BUF_MODE);
480 pre_process_data : procedure(cinfo : j_compress_ptr;
481 input_buf : JSAMPARRAY;
482 var in_row_ctr : JDIMENSION;
483 in_rows_avail : JDIMENSION;
484 output_buf : JSAMPIMAGE;
485 var out_row_group_ctr : JDIMENSION;
486 out_row_groups_avail : JDIMENSION);
487 end;
489 { Coefficient buffer control }
490 jpeg_c_coef_controller_ptr = ^jpeg_c_coef_controller;
491 jpeg_c_coef_controller = record
492 start_pass : procedure(cinfo : j_compress_ptr; pass_mode : J_BUF_MODE);
493 compress_data : function(cinfo : j_compress_ptr;
494 input_buf : JSAMPIMAGE) : boolean;
495 end;
497 { Colorspace conversion }
498 jpeg_color_converter_ptr = ^jpeg_color_converter;
499 jpeg_color_converter = record
500 start_pass : procedure(cinfo : j_compress_ptr);
501 color_convert : procedure(cinfo : j_compress_ptr;
502 input_buf : JSAMPARRAY;
503 output_buf : JSAMPIMAGE;
504 output_row : JDIMENSION;
505 num_rows : int);
506 end;
508 { Downsampling }
509 jpeg_downsampler_ptr = ^jpeg_downsampler;
510 jpeg_downsampler = record
511 start_pass : procedure(cinfo : j_compress_ptr);
512 downsample : procedure(cinfo : j_compress_ptr;
513 input_buf : JSAMPIMAGE;
514 in_row_index : JDIMENSION;
515 output_buf : JSAMPIMAGE;
516 out_row_group_index: JDIMENSION);
517 need_context_rows : Boolean; { TRUE if need rows above & below }
518 end;
520 { Forward DCT (also controls coefficient quantization) }
521 jpeg_forward_dct_ptr = ^jpeg_forward_dct;
522 jpeg_forward_dct = record
523 start_pass : procedure(cinfo : j_compress_ptr);
524 { perhaps this should be an array??? }
525 forward_DCT : procedure(cinfo : j_compress_ptr;
526 compptr : jpeg_component_info_ptr;
527 sample_data : JSAMPARRAY;
528 coef_blocks : JBLOCKROW;
529 start_row : JDIMENSION;
530 start_col : JDIMENSION;
531 num_blocks : JDIMENSION);
532 end;
534 { Entropy encoding }
536 jpeg_entropy_encoder_ptr = ^jpeg_entropy_encoder;
537 jpeg_entropy_encoder = record
538 start_pass : procedure(cinfo : j_compress_ptr; gather_statistics : boolean);
539 encode_mcu : function(cinfo : j_compress_ptr;
540 const MCU_data: array of JBLOCKROW) : boolean;
541 finish_pass : procedure(cinfo : j_compress_ptr);
542 end;
544 { Marker writing }
545 jpeg_marker_writer_ptr = ^jpeg_marker_writer;
546 jpeg_marker_writer = record
547 write_file_header : procedure(cinfo : j_compress_ptr);
548 write_frame_header : procedure(cinfo : j_compress_ptr);
549 write_scan_header : procedure(cinfo : j_compress_ptr);
550 write_file_trailer : procedure(cinfo : j_compress_ptr);
551 write_tables_only : procedure(cinfo : j_compress_ptr);
552 { These routines are exported to allow insertion of extra markers }
553 { Probably only COM and APPn markers should be written this way }
554 write_marker_header : procedure (cinfo : j_compress_ptr;
555 marker : int;
556 datalen : uint);
557 write_marker_byte : procedure (cinfo : j_compress_ptr; val : int);
558 end;
560 { Declarations for decompression modules }
562 { Master control module }
563 jpeg_decomp_master_ptr = ^jpeg_decomp_master;
564 jpeg_decomp_master = record
565 prepare_for_output_pass : procedure( cinfo : j_decompress_ptr);
566 finish_output_pass : procedure(cinfo : j_decompress_ptr);
568 { State variables made visible to other modules }
569 is_dummy_pass : Boolean; { True during 1st pass for 2-pass quant }
570 end;
572 { Input control module }
573 jpeg_input_controller_ptr = ^jpeg_input_controller;
574 jpeg_input_controller = record
575 consume_input : function (cinfo : j_decompress_ptr) : int;
576 reset_input_controller : procedure(cinfo : j_decompress_ptr);
577 start_input_pass : procedure(cinfo : j_decompress_ptr);
578 finish_input_pass : procedure(cinfo : j_decompress_ptr);
580 { State variables made visible to other modules }
581 has_multiple_scans : Boolean; { True if file has multiple scans }
582 eoi_reached : Boolean; { True when EOI has been consumed }
583 end;
585 { Main buffer control (downsampled-data buffer) }
587 jpeg_d_main_controller_ptr = ^jpeg_d_main_controller;
588 jpeg_d_main_controller = record
589 start_pass : procedure(cinfo : j_decompress_ptr; pass_mode : J_BUF_MODE);
590 process_data : procedure(cinfo : j_decompress_ptr;
591 output_buf : JSAMPARRAY;
592 var out_row_ctr : JDIMENSION;
593 out_rows_avail : JDIMENSION);
594 end;
596 { Coefficient buffer control }
597 jvirt_barray_tbl = array[0..MAX_COMPONENTS-1] of jvirt_barray_ptr;
598 jvirt_barray_tbl_ptr = ^jvirt_barray_tbl;
599 jpeg_d_coef_controller_ptr = ^jpeg_d_coef_controller;
600 jpeg_d_coef_controller = record
601 start_input_pass : procedure(cinfo : j_decompress_ptr);
602 consume_data : function (cinfo : j_decompress_ptr) : int;
603 start_output_pass : procedure(cinfo : j_decompress_ptr);
604 decompress_data : function (cinfo : j_decompress_ptr;
605 output_buf : JSAMPIMAGE) : int;
606 { Pointer to array of coefficient virtual arrays, or NIL if none }
607 coef_arrays : jvirt_barray_tbl_ptr;
608 end;
610 { Decompression postprocessing (color quantization buffer control) }
611 jpeg_d_post_controller_ptr = ^jpeg_d_post_controller;
612 jpeg_d_post_controller = record
613 start_pass : procedure(cinfo : j_decompress_ptr;
614 pass_mode : J_BUF_MODE);
615 post_process_data : procedure(cinfo : j_decompress_ptr;
616 input_buf : JSAMPIMAGE;
617 var in_row_group_ctr : JDIMENSION;
618 in_row_groups_avail : JDIMENSION;
619 output_buf : JSAMPARRAY;
620 var out_row_ctr : JDIMENSION;
621 out_rows_avail : JDIMENSION);
622 end;
625 { Routine signature for application-supplied marker processing methods.
626 Need not pass marker code since it is stored in cinfo^.unread_marker. }
628 jpeg_marker_parser_method = function(cinfo : j_decompress_ptr) : boolean;
630 { Marker reading & parsing }
631 jpeg_marker_reader_ptr = ^jpeg_marker_reader;
632 jpeg_marker_reader = record
633 reset_marker_reader : procedure(cinfo : j_decompress_ptr);
634 { Read markers until SOS or EOI.
635 Returns same codes as are defined for jpeg_consume_input:
636 JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. }
638 read_markers : function (cinfo : j_decompress_ptr) : int;
639 { Read a restart marker --- exported for use by entropy decoder only }
640 read_restart_marker : jpeg_marker_parser_method;
642 { State of marker reader --- nominally internal, but applications
643 supplying COM or APPn handlers might like to know the state. }
645 saw_SOI : boolean; { found SOI? }
646 saw_SOF : boolean; { found SOF? }
647 next_restart_num : int; { next restart number expected (0-7) }
648 discarded_bytes : uint; { # of bytes skipped looking for a marker }
649 end;
651 { Entropy decoding }
652 jpeg_entropy_decoder_ptr = ^jpeg_entropy_decoder;
653 jpeg_entropy_decoder = record
654 start_pass : procedure(cinfo : j_decompress_ptr);
655 decode_mcu : function(cinfo : j_decompress_ptr;
656 var MCU_data : array of JBLOCKROW) : boolean;
657 { This is here to share code between baseline and progressive decoders; }
658 { other modules probably should not use it }
659 insufficient_data : BOOLEAN; { set TRUE after emitting warning }
660 end;
662 { Inverse DCT (also performs dequantization) }
663 inverse_DCT_method_ptr = procedure(cinfo : j_decompress_ptr;
664 compptr : jpeg_component_info_ptr;
665 coef_block : JCOEFPTR;
666 output_buf : JSAMPARRAY; output_col : JDIMENSION);
668 jpeg_inverse_dct_ptr = ^jpeg_inverse_dct;
669 jpeg_inverse_dct = record
670 start_pass : procedure(cinfo : j_decompress_ptr);
671 { It is useful to allow each component to have a separate IDCT method. }
672 inverse_DCT : Array[0..MAX_COMPONENTS-1] of inverse_DCT_method_ptr;
673 end;
675 { Upsampling (note that upsampler must also call color converter) }
676 jpeg_upsampler_ptr = ^jpeg_upsampler;
677 jpeg_upsampler = record
678 start_pass : procedure(cinfo : j_decompress_ptr);
679 upsample : procedure(cinfo : j_decompress_ptr;
680 input_buf : JSAMPIMAGE;
681 var in_row_group_ctr : JDIMENSION; { array of }
682 in_row_groups_avail : JDIMENSION;
683 output_buf : JSAMPARRAY;
684 var out_row_ctr : JDIMENSION;
685 out_rows_avail : JDIMENSION);
687 need_context_rows : boolean; { TRUE if need rows above & below }
688 end;
690 { Colorspace conversion }
691 jpeg_color_deconverter_ptr = ^jpeg_color_deconverter;
692 jpeg_color_deconverter = record
693 start_pass : procedure(cinfo: j_decompress_ptr);
694 color_convert : procedure(cinfo : j_decompress_ptr;
695 input_buf : JSAMPIMAGE;
696 input_row : JDIMENSION;
697 output_buf : JSAMPARRAY;
698 num_rows : int);
699 end;
701 { Color quantization or color precision reduction }
702 jpeg_color_quantizer_ptr = ^jpeg_color_quantizer;
703 jpeg_color_quantizer = record
704 start_pass : procedure(cinfo : j_decompress_ptr; is_pre_scan : boolean);
705 color_quantize : procedure(cinfo : j_decompress_ptr;
706 input_buf : JSAMPARRAY;
707 output_buf : JSAMPARRAY;
708 num_rows : int);
710 finish_pass : procedure(cinfo : j_decompress_ptr);
711 new_color_map : procedure(cinfo : j_decompress_ptr);
712 end;
714 {int8array = Array[0..8-1] of int;}
715 int8array = Array[0..8-1] of longint; { for TP FormatStr }
717 jpeg_error_mgr = record
718 { Error exit handler: does not return to caller }
719 error_exit : procedure (cinfo : j_common_ptr);
720 { Conditionally emit a trace or warning message }
721 emit_message : procedure (cinfo : j_common_ptr; msg_level : int);
722 { Routine that actually outputs a trace or error message }
723 output_message : procedure (cinfo : j_common_ptr);
724 { Format a message string for the most recent JPEG error or message }
725 format_message : procedure (cinfo : j_common_ptr; var buffer : AnsiString);
727 { Reset error state variables at start of a new image }
728 reset_error_mgr : procedure (cinfo : j_common_ptr);
730 { The message ID code and any parameters are saved here.
731 A message can have one string parameter or up to 8 int parameters. }
733 msg_code : int;
735 msg_parm : record
736 case byte of
737 0:(i : int8array);
738 1:(s : string[JMSG_STR_PARM_MAX]);
739 end;
741 { Standard state variables for error facility }
743 trace_level : int; { max msg_level that will be displayed }
745 { For recoverable corrupt-data errors, we emit a warning message,
746 but keep going unless emit_message chooses to abort. emit_message
747 should count warnings in num_warnings. The surrounding application
748 can check for bad data by seeing if num_warnings is nonzero at the
749 end of processing. }
751 num_warnings : long; { number of corrupt-data warnings }
753 { These fields point to the table(s) of error message strings.
754 An application can change the table pointer to switch to a different
755 message list (typically, to change the language in which errors are
756 reported). Some applications may wish to add additional error codes
757 that will be handled by the JPEG library error mechanism; the second
758 table pointer is used for this purpose.
760 First table includes all errors generated by JPEG library itself.
761 Error code 0 is reserved for a "no such error string" message. }
763 {const char * const * jpeg_message_table; }
764 jpeg_message_table : ^msg_table; { Library errors }
766 last_jpeg_message : J_MESSAGE_CODE;
767 { Table contains strings 0..last_jpeg_message }
768 { Second table can be added by application (see cjpeg/djpeg for example).
769 It contains strings numbered first_addon_message..last_addon_message. }
771 {const char * const * addon_message_table; }
772 addon_message_table : ^msg_table; { Non-library errors }
774 first_addon_message : J_MESSAGE_CODE; { code for first string in addon table }
775 last_addon_message : J_MESSAGE_CODE; { code for last string in addon table }
776 end;
779 { Progress monitor object }
781 jpeg_progress_mgr = record
782 progress_monitor : procedure(cinfo : j_common_ptr);
784 pass_counter : long; { work units completed in this pass }
785 pass_limit : long; { total number of work units in this pass }
786 completed_passes : int; { passes completed so far }
787 total_passes : int; { total number of passes expected }
788 end;
791 { Data destination object for compression }
792 jpeg_destination_mgr_ptr = ^jpeg_destination_mgr;
793 jpeg_destination_mgr = record
794 next_output_byte : JOCTETptr; { => next byte to write in buffer }
795 free_in_buffer : size_t; { # of byte spaces remaining in buffer }
797 init_destination : procedure (cinfo : j_compress_ptr);
798 empty_output_buffer : function (cinfo : j_compress_ptr) : boolean;
799 term_destination : procedure (cinfo : j_compress_ptr);
800 end;
803 { Data source object for decompression }
805 jpeg_source_mgr_ptr = ^jpeg_source_mgr;
806 jpeg_source_mgr = record
807 {const JOCTET * next_input_byte;}
808 next_input_byte : JOCTETptr; { => next byte to read from buffer }
809 bytes_in_buffer : size_t; { # of bytes remaining in buffer }
811 init_source : procedure (cinfo : j_decompress_ptr);
812 fill_input_buffer : function (cinfo : j_decompress_ptr) : boolean;
813 skip_input_data : procedure (cinfo : j_decompress_ptr; num_bytes : long);
814 resync_to_restart : function (cinfo : j_decompress_ptr;
815 desired : int) : boolean;
816 term_source : procedure (cinfo : j_decompress_ptr);
817 end;
820 { Memory manager object.
821 Allocates "small" objects (a few K total), "large" objects (tens of K),
822 and "really big" objects (virtual arrays with backing store if needed).
823 The memory manager does not allow individual objects to be freed; rather,
824 each created object is assigned to a pool, and whole pools can be freed
825 at once. This is faster and more convenient than remembering exactly what
826 to free, especially where malloc()/free() are not too speedy.
827 NB: alloc routines never return NIL. They exit to error_exit if not
828 successful. }
831 jpeg_memory_mgr = record
832 { Method pointers }
833 alloc_small : function (cinfo : j_common_ptr; pool_id : int;
834 sizeofobject : size_t) : pointer;
835 alloc_large : function (cinfo : j_common_ptr; pool_id : int;
836 sizeofobject : size_t) : pointer; {far}
837 alloc_sarray : function (cinfo : j_common_ptr; pool_id : int;
838 samplesperrow : JDIMENSION;
839 numrows : JDIMENSION) : JSAMPARRAY;
841 alloc_barray : function (cinfo : j_common_ptr; pool_id : int;
842 blocksperrow : JDIMENSION;
843 numrows : JDIMENSION) : JBLOCKARRAY;
845 request_virt_sarray : function(cinfo : j_common_ptr;
846 pool_id : int;
847 pre_zero : boolean;
848 samplesperrow : JDIMENSION;
849 numrows : JDIMENSION;
850 maxaccess : JDIMENSION) : jvirt_sarray_ptr;
852 request_virt_barray : function(cinfo : j_common_ptr;
853 pool_id : int;
854 pre_zero : boolean;
855 blocksperrow : JDIMENSION;
856 numrows : JDIMENSION;
857 maxaccess : JDIMENSION) : jvirt_barray_ptr;
859 realize_virt_arrays : procedure (cinfo : j_common_ptr);
861 access_virt_sarray : function (cinfo : j_common_ptr;
862 ptr : jvirt_sarray_ptr;
863 start_row : JDIMENSION;
864 num_rows : JDIMENSION;
865 writable : boolean) : JSAMPARRAY;
867 access_virt_barray : function (cinfo : j_common_ptr;
868 ptr : jvirt_barray_ptr;
869 start_row : JDIMENSION;
870 num_rows : JDIMENSION;
871 writable : boolean) : JBLOCKARRAY;
873 free_pool : procedure (cinfo : j_common_ptr; pool_id : int);
874 self_destruct : procedure (cinfo : j_common_ptr);
876 { Limit on memory allocation for this JPEG object. (Note that this is
877 merely advisory, not a guaranteed maximum; it only affects the space
878 used for virtual-array buffers.) May be changed by outer application
879 after creating the JPEG object. }
880 max_memory_to_use : long;
882 { Maximum allocation request accepted by alloc_large. }
883 max_alloc_chunk : long;
884 end;
886 { Routines that are to be used by both halves of the library are declared
887 to receive a pointer to this structure. There are no actual instances of
888 jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct.}
889 jpeg_common_struct = record
890 { Fields common to both master struct types }
891 err : jpeg_error_mgr_ptr; { Error handler module }
892 mem : jpeg_memory_mgr_ptr; { Memory manager module }
893 progress : jpeg_progress_mgr_ptr; { Progress monitor, or NIL if none }
894 client_data : voidp; { Available for use by application }
895 is_decompressor : boolean; { so common code can tell which is which }
896 global_state : int; { for checking call sequence validity }
898 { Additional fields follow in an actual jpeg_compress_struct or
899 jpeg_decompress_struct. All three structs must agree on these
900 initial fields! (This would be a lot cleaner in C++.) }
901 end;
904 { Master record for a compression instance }
906 jpeg_compress_struct = record
907 { Fields shared with jpeg_decompress_struct }
908 err : jpeg_error_mgr_ptr; { Error handler module }
909 mem : jpeg_memory_mgr_ptr; { Memory manager module }
910 progress : jpeg_progress_mgr_ptr; { Progress monitor, or NIL if none }
911 client_data : voidp; { Available for use by application }
912 is_decompressor : boolean; { so common code can tell which is which }
913 global_state : int; { for checking call sequence validity }
915 { Destination for compressed data }
916 dest : jpeg_destination_mgr_ptr;
918 { Description of source image --- these fields must be filled in by
919 outer application before starting compression. in_color_space must
920 be correct before you can even call jpeg_set_defaults(). }
923 image_width : JDIMENSION; { input image width }
924 image_height : JDIMENSION; { input image height }
925 input_components : int; { # of color components in input image }
926 in_color_space : J_COLOR_SPACE; { colorspace of input image }
928 input_gamma : double; { image gamma of input image }
930 { Compression parameters --- these fields must be set before calling
931 jpeg_start_compress(). We recommend calling jpeg_set_defaults() to
932 initialize everything to reasonable defaults, then changing anything
933 the application specifically wants to change. That way you won't get
934 burnt when new parameters are added. Also note that there are several
935 helper routines to simplify changing parameters. }
937 data_precision : int; { bits of precision in image data }
939 num_components : int; { # of color components in JPEG image }
940 jpeg_color_space : J_COLOR_SPACE; { colorspace of JPEG image }
942 comp_info : jpeg_component_info_list_ptr;
943 { comp_info^[i] describes component that appears i'th in SOF }
945 quant_tbl_ptrs: Array[0..NUM_QUANT_TBLS-1] of JQUANT_TBL_PTR;
946 { ptrs to coefficient quantization tables, or NIL if not defined }
948 dc_huff_tbl_ptrs : Array[0..NUM_HUFF_TBLS-1] of JHUFF_TBL_PTR;
949 ac_huff_tbl_ptrs : Array[0..NUM_HUFF_TBLS-1] of JHUFF_TBL_PTR;
950 { ptrs to Huffman coding tables, or NIL if not defined }
952 arith_dc_L : Array[0..NUM_ARITH_TBLS-1] of UINT8; { L values for DC arith-coding tables }
953 arith_dc_U : Array[0..NUM_ARITH_TBLS-1] of UINT8; { U values for DC arith-coding tables }
954 arith_ac_K : Array[0..NUM_ARITH_TBLS-1] of UINT8; { Kx values for AC arith-coding tables }
956 num_scans : int; { # of entries in scan_info array }
957 scan_info : jpeg_scan_info_ptr; { script for multi-scan file, or NIL }
958 { The default value of scan_info is NIL, which causes a single-scan
959 sequential JPEG file to be emitted. To create a multi-scan file,
960 set num_scans and scan_info to point to an array of scan definitions. }
962 raw_data_in : boolean; { TRUE=caller supplies downsampled data }
963 arith_code : boolean; { TRUE=arithmetic coding, FALSE=Huffman }
964 optimize_coding : boolean; { TRUE=optimize entropy encoding parms }
965 CCIR601_sampling : boolean; { TRUE=first samples are cosited }
966 smoothing_factor : int; { 1..100, or 0 for no input smoothing }
967 dct_method : J_DCT_METHOD; { DCT algorithm selector }
969 { The restart interval can be specified in absolute MCUs by setting
970 restart_interval, or in MCU rows by setting restart_in_rows
971 (in which case the correct restart_interval will be figured
972 for each scan). }
974 restart_interval : uint; { MCUs per restart, or 0 for no restart }
975 restart_in_rows : int; { if > 0, MCU rows per restart interval }
977 { Parameters controlling emission of special markers. }
979 write_JFIF_header : boolean; { should a JFIF marker be written? }
980 JFIF_major_version : UINT8; { What to write for the JFIF version number }
981 JFIF_minor_version : UINT8;
982 { These three values are not used by the JPEG code, merely copied }
983 { into the JFIF APP0 marker. density_unit can be 0 for unknown, }
984 { 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect }
985 { ratio is defined by X_density/Y_density even when density_unit=0. }
986 density_unit : UINT8; { JFIF code for pixel size units }
987 X_density : UINT16; { Horizontal pixel density }
988 Y_density : UINT16; { Vertical pixel density }
989 write_Adobe_marker : boolean; { should an Adobe marker be written? }
991 { State variable: index of next scanline to be written to
992 jpeg_write_scanlines(). Application may use this to control its
993 processing loop, e.g., "while (next_scanline < image_height)". }
995 next_scanline : JDIMENSION; { 0 .. image_height-1 }
997 { Remaining fields are known throughout compressor, but generally
998 should not be touched by a surrounding application. }
1000 { These fields are computed during compression startup }
1001 progressive_mode : boolean; { TRUE if scan script uses progressive mode }
1002 max_h_samp_factor : int; { largest h_samp_factor }
1003 max_v_samp_factor : int; { largest v_samp_factor }
1005 total_iMCU_rows : JDIMENSION; { # of iMCU rows to be input to coef ctlr }
1006 { The coefficient controller receives data in units of MCU rows as defined
1007 for fully interleaved scans (whether the JPEG file is interleaved or not).
1008 There are v_samp_factor * DCTSIZE sample rows of each component in an
1009 "iMCU" (interleaved MCU) row. }
1011 { These fields are valid during any one scan.
1012 They describe the components and MCUs actually appearing in the scan. }
1014 comps_in_scan : int; { # of JPEG components in this scan }
1015 cur_comp_info : Array[0..MAX_COMPS_IN_SCAN-1] of jpeg_component_info_ptr;
1016 { cur_comp_info[i]^ describes component that appears i'th in SOS }
1018 MCUs_per_row : JDIMENSION; { # of MCUs across the image }
1019 MCU_rows_in_scan : JDIMENSION;{ # of MCU rows in the image }
1021 blocks_in_MCU : int; { # of DCT blocks per MCU }
1022 MCU_membership : Array[0..C_MAX_BLOCKS_IN_MCU-1] of int;
1023 { MCU_membership[i] is index in cur_comp_info of component owning }
1024 { i'th block in an MCU }
1026 Ss, Se, Ah, Al : int; { progressive JPEG parameters for scan }
1028 { Links to compression subobjects (methods and private variables of modules) }
1029 master : jpeg_comp_master_ptr;
1030 main : jpeg_c_main_controller_ptr;
1031 prep : jpeg_c_prep_controller_ptr;
1032 coef : jpeg_c_coef_controller_ptr;
1033 marker : jpeg_marker_writer_ptr;
1034 cconvert : jpeg_color_converter_ptr;
1035 downsample : jpeg_downsampler_ptr;
1036 fdct : jpeg_forward_dct_ptr;
1037 entropy : jpeg_entropy_encoder_ptr;
1038 script_space : jpeg_scan_info_ptr; { workspace for jpeg_simple_progression }
1039 script_space_size : int;
1040 end;
1043 { Master record for a decompression instance }
1045 coef_bits_field = Array[0..DCTSIZE2-1] of int;
1046 coef_bits_ptr = ^coef_bits_field;
1047 coef_bits_ptrfield = Array[0..MAX_COMPS_IN_SCAN-1] of coef_bits_field;
1048 coef_bits_ptrrow = ^coef_bits_ptrfield;
1050 range_limit_table = array[-(MAXJSAMPLE+1)..4*(MAXJSAMPLE+1)
1051 + CENTERJSAMPLE -1] of JSAMPLE;
1052 range_limit_table_ptr = ^range_limit_table;
1054 jpeg_decompress_struct = record
1055 { Fields shared with jpeg_compress_struct }
1056 err : jpeg_error_mgr_ptr; { Error handler module }
1057 mem : jpeg_memory_mgr_ptr; { Memory manager module }
1058 progress : jpeg_progress_mgr_ptr; { Progress monitor, or NIL if none }
1059 client_data : voidp; { Available for use by application }
1060 is_decompressor : boolean; { so common code can tell which is which }
1061 global_state : int; { for checking call sequence validity }
1063 { Source of compressed data }
1064 src : jpeg_source_mgr_ptr;
1066 { Basic description of image --- filled in by jpeg_read_header(). }
1067 { Application may inspect these values to decide how to process image. }
1069 image_width : JDIMENSION; { nominal image width (from SOF marker) }
1070 image_height : JDIMENSION; { nominal image height }
1071 num_components : int; { # of color components in JPEG image }
1072 jpeg_color_space : J_COLOR_SPACE; { colorspace of JPEG image }
1074 { Decompression processing parameters --- these fields must be set before
1075 calling jpeg_start_decompress(). Note that jpeg_read_header()
1076 initializes them to default values. }
1078 out_color_space : J_COLOR_SPACE; { colorspace for output }
1080 scale_num, scale_denom : uint ; { fraction by which to scale image }
1082 output_gamma : double; { image gamma wanted in output }
1084 buffered_image : boolean; { TRUE=multiple output passes }
1085 raw_data_out : boolean; { TRUE=downsampled data wanted }
1087 dct_method : J_DCT_METHOD; { IDCT algorithm selector }
1088 do_fancy_upsampling : boolean; { TRUE=apply fancy upsampling }
1089 do_block_smoothing : boolean; { TRUE=apply interblock smoothing }
1091 quantize_colors : boolean; { TRUE=colormapped output wanted }
1092 { the following are ignored if not quantize_colors: }
1093 dither_mode : J_DITHER_MODE; { type of color dithering to use }
1094 two_pass_quantize : boolean; { TRUE=use two-pass color quantization }
1095 desired_number_of_colors : int; { max # colors to use in created colormap }
1096 { these are significant only in buffered-image mode: }
1097 enable_1pass_quant : boolean; { enable future use of 1-pass quantizer }
1098 enable_external_quant : boolean; { enable future use of external colormap }
1099 enable_2pass_quant : boolean; { enable future use of 2-pass quantizer }
1101 { Description of actual output image that will be returned to application.
1102 These fields are computed by jpeg_start_decompress().
1103 You can also use jpeg_calc_output_dimensions() to determine these values
1104 in advance of calling jpeg_start_decompress(). }
1106 output_width : JDIMENSION; { scaled image width }
1107 output_height: JDIMENSION; { scaled image height }
1108 out_color_components : int; { # of color components in out_color_space }
1109 output_components : int; { # of color components returned }
1110 { output_components is 1 (a colormap index) when quantizing colors;
1111 otherwise it equals out_color_components. }
1113 rec_outbuf_height : int; { min recommended height of scanline buffer }
1114 { If the buffer passed to jpeg_read_scanlines() is less than this many
1115 rows high, space and time will be wasted due to unnecessary data
1116 copying. Usually rec_outbuf_height will be 1 or 2, at most 4. }
1118 { When quantizing colors, the output colormap is described by these
1119 fields. The application can supply a colormap by setting colormap
1120 non-NIL before calling jpeg_start_decompress; otherwise a colormap
1121 is created during jpeg_start_decompress or jpeg_start_output. The map
1122 has out_color_components rows and actual_number_of_colors columns. }
1124 actual_number_of_colors : int; { number of entries in use }
1125 colormap : JSAMPARRAY; { The color map as a 2-D pixel array }
1127 { State variables: these variables indicate the progress of decompression.
1128 The application may examine these but must not modify them. }
1130 { Row index of next scanline to be read from jpeg_read_scanlines().
1131 Application may use this to control its processing loop, e.g.,
1132 "while (output_scanline < output_height)". }
1134 output_scanline : JDIMENSION; { 0 .. output_height-1 }
1136 { Current input scan number and number of iMCU rows completed in scan.
1137 These indicate the progress of the decompressor input side. }
1139 input_scan_number : int; { Number of SOS markers seen so far }
1140 input_iMCU_row : JDIMENSION; { Number of iMCU rows completed }
1142 { The "output scan number" is the notional scan being displayed by the
1143 output side. The decompressor will not allow output scan/row number
1144 to get ahead of input scan/row, but it can fall arbitrarily far behind.}
1146 output_scan_number : int; { Nominal scan number being displayed }
1147 output_iMCU_row : int; { Number of iMCU rows read }
1149 { Current progression status. coef_bits[c][i] indicates the precision
1150 with which component c's DCT coefficient i (in zigzag order) is known.
1151 It is -1 when no data has yet been received, otherwise it is the point
1152 transform (shift) value for the most recent scan of the coefficient
1153 (thus, 0 at completion of the progression).
1154 This pointer is NIL when reading a non-progressive file. }
1156 coef_bits : coef_bits_ptrrow;
1157 { -1 or current Al value for each coef }
1159 { Internal JPEG parameters --- the application usually need not look at
1160 these fields. Note that the decompressor output side may not use
1161 any parameters that can change between scans. }
1163 { Quantization and Huffman tables are carried forward across input
1164 datastreams when processing abbreviated JPEG datastreams. }
1166 quant_tbl_ptrs : Array[0..NUM_QUANT_TBLS-1] of JQUANT_TBL_PTR;
1167 { ptrs to coefficient quantization tables, or NIL if not defined }
1169 dc_huff_tbl_ptrs : Array[0..NUM_HUFF_TBLS-1] of JHUFF_TBL_PTR;
1170 ac_huff_tbl_ptrs : Array[0..NUM_HUFF_TBLS-1] of JHUFF_TBL_PTR;
1171 { ptrs to Huffman coding tables, or NIL if not defined }
1173 { These parameters are never carried across datastreams, since they
1174 are given in SOF/SOS markers or defined to be reset by SOI. }
1176 data_precision : int; { bits of precision in image data }
1178 comp_info : jpeg_component_info_list_ptr;
1179 { comp_info^[i] describes component that appears i'th in SOF }
1181 progressive_mode : boolean; { TRUE if SOFn specifies progressive mode }
1182 arith_code : boolean; { TRUE=arithmetic coding, FALSE=Huffman }
1184 arith_dc_L : Array[0..NUM_ARITH_TBLS-1] of UINT8; { L values for DC arith-coding tables }
1185 arith_dc_U : Array[0..NUM_ARITH_TBLS-1] of UINT8; { U values for DC arith-coding tables }
1186 arith_ac_K : Array[0..NUM_ARITH_TBLS-1] of UINT8; { Kx values for AC arith-coding tables }
1188 restart_interval : uint; { MCUs per restart interval, or 0 for no restart }
1190 { These fields record data obtained from optional markers recognized by
1191 the JPEG library. }
1193 saw_JFIF_marker : boolean; { TRUE iff a JFIF APP0 marker was found }
1194 { Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: }
1195 JFIF_major_version : UINT8; { JFIF version number }
1196 JFIF_minor_version : UINT8;
1197 density_unit : UINT8; { JFIF code for pixel size units }
1198 X_density : UINT16; { Horizontal pixel density }
1199 Y_density : UINT16; { Vertical pixel density }
1200 saw_Adobe_marker : boolean; { TRUE iff an Adobe APP14 marker was found }
1201 Adobe_transform : UINT8; { Color transform code from Adobe marker }
1203 CCIR601_sampling : boolean; { TRUE=first samples are cosited }
1205 { Aside from the specific data retained from APPn markers known to the
1206 library, the uninterpreted contents of any or all APPn and COM markers
1207 can be saved in a list for examination by the application. }
1209 marker_list : jpeg_saved_marker_ptr; { Head of list of saved markers }
1211 { Remaining fields are known throughout decompressor, but generally
1212 should not be touched by a surrounding application. }
1215 { These fields are computed during decompression startup }
1217 max_h_samp_factor : int; { largest h_samp_factor }
1218 max_v_samp_factor : int; { largest v_samp_factor }
1220 min_DCT_scaled_size : int; { smallest DCT_scaled_size of any component }
1222 total_iMCU_rows : JDIMENSION; { # of iMCU rows in image }
1223 { The coefficient controller's input and output progress is measured in
1224 units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows
1225 in fully interleaved JPEG scans, but are used whether the scan is
1226 interleaved or not. We define an iMCU row as v_samp_factor DCT block
1227 rows of each component. Therefore, the IDCT output contains
1228 v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row.}
1230 sample_range_limit : range_limit_table_ptr; { table for fast range-limiting }
1233 { These fields are valid during any one scan.
1234 They describe the components and MCUs actually appearing in the scan.
1235 Note that the decompressor output side must not use these fields. }
1237 comps_in_scan : int; { # of JPEG components in this scan }
1238 cur_comp_info : Array[0..MAX_COMPS_IN_SCAN-1] of jpeg_component_info_ptr;
1239 { cur_comp_info[i]^ describes component that appears i'th in SOS }
1241 MCUs_per_row : JDIMENSION; { # of MCUs across the image }
1242 MCU_rows_in_scan : JDIMENSION; { # of MCU rows in the image }
1244 blocks_in_MCU : JDIMENSION; { # of DCT blocks per MCU }
1245 MCU_membership : Array[0..D_MAX_BLOCKS_IN_MCU-1] of int;
1246 { MCU_membership[i] is index in cur_comp_info of component owning }
1247 { i'th block in an MCU }
1249 Ss, Se, Ah, Al : int; { progressive JPEG parameters for scan }
1251 { This field is shared between entropy decoder and marker parser.
1252 It is either zero or the code of a JPEG marker that has been
1253 read from the data source, but has not yet been processed. }
1255 unread_marker : int;
1257 { Links to decompression subobjects
1258 (methods, private variables of modules) }
1260 master : jpeg_decomp_master_ptr;
1261 main : jpeg_d_main_controller_ptr;
1262 coef : jpeg_d_coef_controller_ptr;
1263 post : jpeg_d_post_controller_ptr;
1264 inputctl : jpeg_input_controller_ptr;
1265 marker : jpeg_marker_reader_ptr;
1266 entropy : jpeg_entropy_decoder_ptr;
1267 idct : jpeg_inverse_dct_ptr;
1268 upsample : jpeg_upsampler_ptr;
1269 cconvert : jpeg_color_deconverter_ptr;
1270 cquantize : jpeg_color_quantizer_ptr;
1271 end;
1273 { Decompression startup: read start of JPEG datastream to see what's there
1274 function jpeg_read_header (cinfo : j_decompress_ptr;
1275 require_image : boolean) : int;
1276 Return value is one of: }
1277 const
1278 JPEG_SUSPENDED = 0; { Suspended due to lack of input data }
1279 JPEG_HEADER_OK = 1; { Found valid image datastream }
1280 JPEG_HEADER_TABLES_ONLY = 2; { Found valid table-specs-only datastream }
1281 { If you pass require_image = TRUE (normal case), you need not check for
1282 a TABLES_ONLY return code; an abbreviated file will cause an error exit.
1283 JPEG_SUSPENDED is only possible if you use a data source module that can
1284 give a suspension return (the stdio source module doesn't). }
1287 { function jpeg_consume_input (cinfo : j_decompress_ptr) : int;
1288 Return value is one of: }
1290 JPEG_REACHED_SOS = 1; { Reached start of new scan }
1291 JPEG_REACHED_EOI = 2; { Reached end of image }
1292 JPEG_ROW_COMPLETED = 3; { Completed one iMCU row }
1293 JPEG_SCAN_COMPLETED = 4; { Completed last iMCU row of a scan }
1298 implementation
1300 end.