Repo for the search and displace ingest module that takes odf, docx and pdf and transforms it into .md to be used with search and displace operations
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1300 lines
56 KiB

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