diff options
author | Joshua Bakita <bakitajoshua@gmail.com> | 2019-10-07 19:13:39 -0400 |
---|---|---|
committer | Joshua Bakita <bakitajoshua@gmail.com> | 2019-10-07 19:13:39 -0400 |
commit | 386b7d3366f1359a265da207a9cafa3edf553b64 (patch) | |
tree | c76120c2c138faed822e4ae386be6ef22a738a78 /baseline/source/cjpeg_transupp/jpeglib.h | |
parent | 54a3f7091a2146b29c73a6fdc4b62a5c4ad7a3d8 (diff) |
Reorganize and commit all the modified TACLeBench code and run scripts
Diffstat (limited to 'baseline/source/cjpeg_transupp/jpeglib.h')
-rw-r--r-- | baseline/source/cjpeg_transupp/jpeglib.h | 757 |
1 files changed, 757 insertions, 0 deletions
diff --git a/baseline/source/cjpeg_transupp/jpeglib.h b/baseline/source/cjpeg_transupp/jpeglib.h new file mode 100644 index 0000000..bb4c940 --- /dev/null +++ b/baseline/source/cjpeg_transupp/jpeglib.h | |||
@@ -0,0 +1,757 @@ | |||
1 | /* | ||
2 | |||
3 | This program is part of the TACLeBench benchmark suite. | ||
4 | Version V 2.0 | ||
5 | |||
6 | Name: jpeglib | ||
7 | |||
8 | Author: Thomas G. Lane | ||
9 | |||
10 | Function: This file defines the application interface for the JPEG library. | ||
11 | Most applications using the library need only include this file, and perhaps | ||
12 | jerror.h if they want to know the exact error codes. | ||
13 | |||
14 | Source: MediaBench II | ||
15 | http://euler.slu.edu/~fritts/mediabench (mirror) | ||
16 | |||
17 | Original name: cjpeg | ||
18 | |||
19 | Changes: No major functional changes. | ||
20 | |||
21 | License: See the accompanying README file. | ||
22 | |||
23 | */ | ||
24 | |||
25 | |||
26 | #ifndef JPEGLIB_H | ||
27 | #define JPEGLIB_H | ||
28 | |||
29 | /* | ||
30 | Various constants determining the sizes of things. | ||
31 | All of these are specified by the JPEG standard, so don't change them if you | ||
32 | want to be compatible. | ||
33 | */ | ||
34 | |||
35 | /* The basic DCT block is 8x8 samples */ | ||
36 | #define DCTSIZE 8 | ||
37 | |||
38 | /* DCTSIZE squared; # of elements in a block */ | ||
39 | #define DCTSIZE2 64 | ||
40 | |||
41 | |||
42 | /* | ||
43 | Data structures for images (arrays of samples and of DCT coefficients). | ||
44 | On 80x86 machines, the image arrays are too big for near pointers, but the | ||
45 | pointer arrays can fit in near memory. | ||
46 | */ | ||
47 | |||
48 | /* ptr to one image row of pixel samples. */ | ||
49 | typedef unsigned char *JSAMPROW; | ||
50 | |||
51 | /* ptr to some rows (a 2-D sample array) */ | ||
52 | typedef JSAMPROW *JSAMPARRAY; | ||
53 | |||
54 | /* one block of coefficients */ | ||
55 | typedef signed char JBLOCK[DCTSIZE2]; | ||
56 | |||
57 | /* pointer to one row of coefficient blocks */ | ||
58 | typedef JBLOCK *JBLOCKROW; | ||
59 | |||
60 | /* a 2-D array of coefficient blocks */ | ||
61 | typedef JBLOCKROW *JBLOCKARRAY; | ||
62 | |||
63 | /* useful in a couple of places */ | ||
64 | typedef signed char *JCOEFPTR; | ||
65 | |||
66 | |||
67 | /* | ||
68 | DCT coefficient quantization tables. | ||
69 | */ | ||
70 | |||
71 | typedef struct { | ||
72 | /* quantization step for each coefficient */ | ||
73 | /* | ||
74 | This array gives the coefficient quantizers in natural array order (not the | ||
75 | zigzag order in which they are stored in a JPEG DQT marker). | ||
76 | CAUTION: IJG versions prior to v6a kept this array in zigzag order. | ||
77 | */ | ||
78 | unsigned short quantval[ DCTSIZE2 ]; | ||
79 | |||
80 | /* 1 when table has been output */ | ||
81 | /* | ||
82 | This field is used only during compression. It's initialized 0 when the | ||
83 | table is created, and set 1 when it's been output to the file. You could | ||
84 | suppress output of a table by setting this to 1. (See jpeg_suppress_tables | ||
85 | for an example.) | ||
86 | */ | ||
87 | int sent_table; | ||
88 | } JQUANT_TBL; | ||
89 | |||
90 | |||
91 | /* | ||
92 | Huffman coding tables. | ||
93 | */ | ||
94 | |||
95 | typedef struct { | ||
96 | /* These two fields directly represent the contents of a JPEG DHT marker */ | ||
97 | |||
98 | /* bits[k] = # of symbols with codes of */ | ||
99 | /* length k bits; bits[0] is unused */ | ||
100 | unsigned char bits[ 17 ]; | ||
101 | |||
102 | /* The symbols, in order of incr code length */ | ||
103 | /* | ||
104 | This field is used only during compression. It's initialized 0 when the | ||
105 | table is created, and set 1 when it's been output to the file. You could | ||
106 | suppress output of a table by setting this to 1. (See jpeg_suppress_tables | ||
107 | for an example.) | ||
108 | */ | ||
109 | unsigned char huffval[ 256 ]; | ||
110 | |||
111 | /* 1 when table has been output */ | ||
112 | int sent_table; | ||
113 | } JHUFF_TBL; | ||
114 | |||
115 | |||
116 | /* | ||
117 | Basic info about one component (color channel). | ||
118 | */ | ||
119 | |||
120 | typedef struct { | ||
121 | /* | ||
122 | These values are fixed over the whole image. For compression, they must be | ||
123 | supplied by parameter setup; for decompression, they are read from the SOF | ||
124 | marker. | ||
125 | */ | ||
126 | |||
127 | /* identifier for this component (0..255) */ | ||
128 | int component_id; | ||
129 | |||
130 | /* its index in SOF or cinfo->comp_info[] */ | ||
131 | int component_index; | ||
132 | |||
133 | /* horizontal sampling factor (1..4) */ | ||
134 | int h_samp_factor; | ||
135 | |||
136 | /* vertical sampling factor (1..4) */ | ||
137 | int v_samp_factor; | ||
138 | |||
139 | /* quantization table selector (0..3) */ | ||
140 | int quant_tbl_no; | ||
141 | |||
142 | /* | ||
143 | These values may vary between scans. For compression, they must be supplied | ||
144 | by parameter setup; for decompression, they are read from the SOS marker. | ||
145 | The decompressor output side may not use these variables. | ||
146 | */ | ||
147 | |||
148 | /* DC entropy table selector (0..3) */ | ||
149 | int dc_tbl_no; | ||
150 | |||
151 | /* AC entropy table selector (0..3) */ | ||
152 | int ac_tbl_no; | ||
153 | |||
154 | /* Remaining fields should be treated as private by applications. */ | ||
155 | |||
156 | /* | ||
157 | These values are computed during compression or decompression startup: | ||
158 | Component's size in DCT blocks. Any dummy blocks added to complete an MCU | ||
159 | are not counted; therefore these values do not depend on whether a scan is | ||
160 | interleaved or not. | ||
161 | */ | ||
162 | unsigned int width_in_blocks; | ||
163 | unsigned int height_in_blocks; | ||
164 | |||
165 | /* | ||
166 | Size of a DCT block in samples. Always DCTSIZE for compression. For | ||
167 | decompression this is the size of the output from one DCT block, reflecting | ||
168 | any scaling we choose to apply during the IDCT step. Values of 1,2,4,8 are | ||
169 | likely to be supported. Note that different components may receive different | ||
170 | IDCT scalings. | ||
171 | */ | ||
172 | int DCT_scaled_size; | ||
173 | |||
174 | /* | ||
175 | The downsampled dimensions are the component's actual, unpadded number of | ||
176 | samples at the main buffer (preprocessing/compression interface), thus | ||
177 | downsampled_width = ceil(image_width * Hi/Hmax) and similarly for height. | ||
178 | For decompression, IDCT scaling is included, so | ||
179 | downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE) | ||
180 | */ | ||
181 | |||
182 | /* actual width in samples */ | ||
183 | unsigned int downsampled_width; | ||
184 | |||
185 | /* actual height in samples */ | ||
186 | unsigned int downsampled_height; | ||
187 | |||
188 | /* | ||
189 | This flag is used only for decompression. In cases where some of the | ||
190 | components will be ignored (eg grayscale output from YCbCr image), we can | ||
191 | skip most computations for the unused components. | ||
192 | */ | ||
193 | |||
194 | /* do we need the value of this component? */ | ||
195 | int component_needed; | ||
196 | |||
197 | /* | ||
198 | These values are computed before starting a scan of the component. The | ||
199 | decompressor output side may not use these variables. | ||
200 | */ | ||
201 | |||
202 | /* number of blocks per MCU, horizontally */ | ||
203 | int MCU_width; | ||
204 | |||
205 | /* number of blocks per MCU, vertically */ | ||
206 | int MCU_height; | ||
207 | |||
208 | /* MCU_width * MCU_height */ | ||
209 | int MCU_blocks; | ||
210 | |||
211 | /* MCU width in samples, MCU_width*DCT_scaled_size */ | ||
212 | int MCU_sample_width; | ||
213 | |||
214 | /* # of non-dummy blocks across in last MCU */ | ||
215 | int last_col_width; | ||
216 | |||
217 | /* # of non-dummy blocks down in last MCU */ | ||
218 | int last_row_height; | ||
219 | |||
220 | /* | ||
221 | Saved quantization table for component; (void*)0 if none yet saved. See | ||
222 | jdinput.c comments about the need for this information. This field is | ||
223 | currently used only for decompression. | ||
224 | */ | ||
225 | JQUANT_TBL *quant_table; | ||
226 | |||
227 | /* Private per-component storage for DCT or IDCT subsystem. */ | ||
228 | void *dct_table; | ||
229 | } jpeg_component_info; | ||
230 | |||
231 | |||
232 | /* | ||
233 | The script for encoding a multiple-scan file is an array of these: | ||
234 | */ | ||
235 | |||
236 | typedef struct { | ||
237 | /* number of components encoded in this scan */ | ||
238 | int comps_in_scan; | ||
239 | |||
240 | /* their SOF/comp_info[] indexes */ | ||
241 | int component_index[ 4 ]; | ||
242 | |||
243 | /* progressive JPEG spectral selection parms */ | ||
244 | int Ss, Se; | ||
245 | |||
246 | /* progressive JPEG successive approx. parms */ | ||
247 | int Ah, Al; | ||
248 | } jpeg_scan_info; | ||
249 | |||
250 | |||
251 | /* | ||
252 | Known color spaces. | ||
253 | */ | ||
254 | |||
255 | typedef enum { | ||
256 | /* error/unspecified */ | ||
257 | JCS_UNKNOWN, | ||
258 | |||
259 | /* monochrome */ | ||
260 | JCS_GRAYSCALE, | ||
261 | |||
262 | /* red/green/blue */ | ||
263 | JCS_RGB, | ||
264 | |||
265 | /* Y/Cb/Cr (also known as YUV) */ | ||
266 | JCS_YCbCr, | ||
267 | |||
268 | /* C/M/Y/K */ | ||
269 | JCS_CMYK, | ||
270 | |||
271 | /* Y/Cb/Cr/K */ | ||
272 | JCS_YCCK | ||
273 | } J_COLOR_SPACE; | ||
274 | |||
275 | |||
276 | /* | ||
277 | DCT/IDCT algorithm options. | ||
278 | */ | ||
279 | |||
280 | typedef enum { | ||
281 | /* slow but accurate integer algorithm */ | ||
282 | JDCT_ISLOW, | ||
283 | |||
284 | /* faster, less accurate integer method */ | ||
285 | JDCT_IFAST, | ||
286 | |||
287 | /* floating-point: accurate, fast on fast HW */ | ||
288 | JDCT_FLOAT | ||
289 | } J_DCT_METHOD; | ||
290 | |||
291 | |||
292 | /* | ||
293 | Common fields between JPEG compression and decompression master structs. | ||
294 | */ | ||
295 | |||
296 | #define jpeg_common_fields \ | ||
297 | /* Error handler module */\ | ||
298 | struct jpeg_error_mgr *err; \ | ||
299 | /* Memory manager module */\ | ||
300 | struct jpeg_memory_mgr *mem; \ | ||
301 | /* Progress monitor, or (void*)0 if none */\ | ||
302 | struct jpeg_progress_mgr *progress; \ | ||
303 | /* Available for use by application */\ | ||
304 | void *client_data; \ | ||
305 | /* So common code can tell which is which */\ | ||
306 | int is_decompressor; \ | ||
307 | /* For checking call sequence validity */\ | ||
308 | int global_state | ||
309 | |||
310 | |||
311 | /* | ||
312 | Routines that are to be used by both halves of the library are declared to | ||
313 | receive a pointer to this structure. There are no actual instances of | ||
314 | jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct. | ||
315 | */ | ||
316 | |||
317 | struct jpeg_common_struct { | ||
318 | /* Fields common to both master struct types */ | ||
319 | jpeg_common_fields; | ||
320 | |||
321 | /* | ||
322 | Additional fields follow in an actual jpeg_compress_struct or | ||
323 | jpeg_decompress_struct. All three structs must agree on these initial | ||
324 | fields! (This would be a lot cleaner in C++.) | ||
325 | */ | ||
326 | }; | ||
327 | |||
328 | typedef struct jpeg_common_struct *j_common_ptr; | ||
329 | typedef struct jpeg_compress_struct *j_compress_ptr; | ||
330 | typedef struct jpeg_decompress_struct *j_decompress_ptr; | ||
331 | |||
332 | |||
333 | /* | ||
334 | Master record for a compression instance | ||
335 | */ | ||
336 | |||
337 | struct jpeg_compress_struct { | ||
338 | /* Fields shared with jpeg_decompress_struct */ | ||
339 | jpeg_common_fields; | ||
340 | |||
341 | /* Destination for compressed data */ | ||
342 | struct jpeg_destination_mgr *dest; | ||
343 | |||
344 | /* | ||
345 | Description of source image --- these fields must be filled in by outer | ||
346 | application before starting compression. in_color_space must be correct | ||
347 | before you can even call jpeg_set_defaults(). | ||
348 | */ | ||
349 | |||
350 | /* input image width */ | ||
351 | unsigned int image_width; | ||
352 | |||
353 | /* input image height */ | ||
354 | unsigned int image_height; | ||
355 | |||
356 | /* # of color components in input image */ | ||
357 | int input_components; | ||
358 | |||
359 | /* colorspace of input image */ | ||
360 | J_COLOR_SPACE in_color_space; | ||
361 | |||
362 | /* image gamma of input image */ | ||
363 | double input_gamma; | ||
364 | |||
365 | /* | ||
366 | Compression parameters --- these fields must be set before calling | ||
367 | jpeg_start_compress(). We recommend calling jpeg_set_defaults() to | ||
368 | initialize everything to reasonable defaults, then changing anything the | ||
369 | application specifically wants to change. That way you won't get burnt when | ||
370 | new parameters are added. Also note that there are several helper routines | ||
371 | to simplify changing parameters. | ||
372 | */ | ||
373 | |||
374 | /* bits of precision in image data */ | ||
375 | int data_precision; | ||
376 | |||
377 | /* # of color components in JPEG image */ | ||
378 | int num_components; | ||
379 | |||
380 | /* colorspace of JPEG image */ | ||
381 | J_COLOR_SPACE jpeg_color_space; | ||
382 | |||
383 | /* comp_info[i] describes component that appears i'th in SOF */ | ||
384 | jpeg_component_info *comp_info; | ||
385 | |||
386 | /* ptrs to coefficient quantization tables, or (void*)0 if not defined */ | ||
387 | JQUANT_TBL *quant_tbl_ptrs[ 4 ]; | ||
388 | |||
389 | /* ptrs to Huffman coding tables, or (void*)0 if not defined */ | ||
390 | JHUFF_TBL *dc_huff_tbl_ptrs[ 4 ]; | ||
391 | JHUFF_TBL *ac_huff_tbl_ptrs[ 4 ]; | ||
392 | |||
393 | /* L values for DC arith-coding tables */ | ||
394 | unsigned char arith_dc_L[ 16 ]; | ||
395 | |||
396 | /* U values for DC arith-coding tables */ | ||
397 | unsigned char arith_dc_U[ 16 ]; | ||
398 | |||
399 | /* Kx values for AC arith-coding tables */ | ||
400 | unsigned char arith_ac_K[ 16 ]; | ||
401 | |||
402 | /* # of entries in scan_info array */ | ||
403 | int num_scans; | ||
404 | |||
405 | /* | ||
406 | script for multi-scan file, or (void*)0 | ||
407 | The default value of scan_info is (void*)0, which causes a single-scan | ||
408 | sequential JPEG file to be emitted. To create a multi-scan file, set | ||
409 | num_scans and scan_info to point to an array of scan definitions. | ||
410 | */ | ||
411 | const jpeg_scan_info *scan_info; | ||
412 | |||
413 | /* 1=caller supplies downsampled data */ | ||
414 | int raw_data_in; | ||
415 | |||
416 | /* 1=arithmetic coding, 0=Huffman */ | ||
417 | int arith_code; | ||
418 | |||
419 | /* 1=optimize entropy encoding parms */ | ||
420 | int optimize_coding; | ||
421 | |||
422 | /* 1=first samples are cosited */ | ||
423 | int CCIR601_sampling; | ||
424 | |||
425 | /* 1..100, or 0 for no input smoothing */ | ||
426 | int smoothing_factor; | ||
427 | |||
428 | /* DCT algorithm selector */ | ||
429 | J_DCT_METHOD dct_method; | ||
430 | |||
431 | |||
432 | /* | ||
433 | The restart interval can be specified in absolute MCUs by setting | ||
434 | restart_interval, or in MCU rows by setting restart_in_rows (in which case | ||
435 | the correct restart_interval will be figured for each scan). | ||
436 | */ | ||
437 | |||
438 | /* MCUs per restart, or 0 for no restart */ | ||
439 | unsigned int restart_interval; | ||
440 | |||
441 | /* if > 0, MCU rows per restart interval */ | ||
442 | int restart_in_rows; | ||
443 | |||
444 | |||
445 | /* | ||
446 | Parameters controlling emission of special markers. | ||
447 | */ | ||
448 | |||
449 | /* should a JFIF marker be written? */ | ||
450 | int write_JFIF_header; | ||
451 | |||
452 | /* What to write for the JFIF version number */ | ||
453 | unsigned char JFIF_major_version; | ||
454 | unsigned char JFIF_minor_version; | ||
455 | |||
456 | /* | ||
457 | These three values are not used by the JPEG code, merely copied into the | ||
458 | JFIF APP0 marker. density_unit can be 0 for unknown, 1 for dots/inch, or 2 | ||
459 | for dots/cm. Note that the pixel aspect ratio is defined by | ||
460 | X_density/Y_density even when density_unit=0. | ||
461 | */ | ||
462 | |||
463 | /* JFIF code for pixel size units */ | ||
464 | unsigned char density_unit; | ||
465 | |||
466 | /* Horizontal pixel density */ | ||
467 | unsigned short X_density; | ||
468 | |||
469 | /* Vertical pixel density */ | ||
470 | unsigned short Y_density; | ||
471 | |||
472 | /* should an Adobe marker be written? */ | ||
473 | int write_Adobe_marker; | ||
474 | |||
475 | /* | ||
476 | State variable: index of next scanline to be written to | ||
477 | jpeg_write_scanlines(). Application may use this to control its processing | ||
478 | loop, e.g., "while (next_scanline < image_height)". | ||
479 | */ | ||
480 | |||
481 | /* 0 .. image_height-1 */ | ||
482 | unsigned int next_scanline; | ||
483 | |||
484 | |||
485 | /* | ||
486 | Remaining fields are known throughout compressor, but generally should not | ||
487 | be touched by a surrounding application. | ||
488 | */ | ||
489 | |||
490 | /* | ||
491 | These fields are computed during compression startup | ||
492 | */ | ||
493 | |||
494 | /* 1 if scan script uses progressive mode */ | ||
495 | int progressive_mode; | ||
496 | |||
497 | /* largest h_samp_factor */ | ||
498 | int max_h_samp_factor; | ||
499 | |||
500 | /* largest v_samp_factor */ | ||
501 | int max_v_samp_factor; | ||
502 | |||
503 | /* | ||
504 | # of iMCU rows to be input to coef ctlr | ||
505 | The coefficient controller receives data in units of MCU rows as defined for | ||
506 | fully interleaved scans (whether the JPEG file is interleaved or not). There | ||
507 | are v_samp_factor * DCTSIZE sample rows of each component in an "iMCU" | ||
508 | (interleaved MCU) row. | ||
509 | */ | ||
510 | unsigned int total_iMCU_rows; | ||
511 | |||
512 | /* | ||
513 | These fields are valid during any one scan. They describe the components | ||
514 | and MCUs actually appearing in the scan. | ||
515 | */ | ||
516 | |||
517 | /* # of JPEG components in this scan */ | ||
518 | int comps_in_scan; | ||
519 | |||
520 | /* *cur_comp_info[i] describes component that appears i'th in SOS */ | ||
521 | jpeg_component_info *cur_comp_info[ 4 ]; | ||
522 | |||
523 | /* # of MCUs across the image */ | ||
524 | unsigned int MCUs_per_row; | ||
525 | |||
526 | /* # of MCU rows in the image */ | ||
527 | unsigned int MCU_rows_in_scan; | ||
528 | |||
529 | /* # of DCT blocks per MCU */ | ||
530 | int blocks_in_MCU; | ||
531 | |||
532 | /* | ||
533 | MCU_membership[i] is index in cur_comp_info of component owning i'th block | ||
534 | in an MCU | ||
535 | */ | ||
536 | int MCU_membership[ 10 ]; | ||
537 | |||
538 | /* progressive JPEG parameters for scan */ | ||
539 | int Ss, Se, Ah, Al; | ||
540 | |||
541 | /* | ||
542 | Links to compression subobjects (methods and private variables of modules) | ||
543 | */ | ||
544 | |||
545 | struct jpeg_comp_master *master; | ||
546 | struct jpeg_c_main_controller *main; | ||
547 | struct jpeg_c_prep_controller *prep; | ||
548 | struct jpeg_c_coef_controller *coef; | ||
549 | struct jpeg_marker_writer *marker; | ||
550 | struct jpeg_color_converter *cconvert; | ||
551 | struct jpeg_downsampler *downsample; | ||
552 | struct jpeg_forward_dct *fdct; | ||
553 | struct jpeg_entropy_encoder *entropy; | ||
554 | |||
555 | /* workspace for jpeg_simple_progression */ | ||
556 | jpeg_scan_info *script_space; | ||
557 | |||
558 | int script_space_size; | ||
559 | }; | ||
560 | |||
561 | |||
562 | /* | ||
563 | "Object" declarations for JPEG modules that may be supplied or called directly | ||
564 | by the surrounding application. As with all objects in the JPEG library, these | ||
565 | structs only define the publicly visible methods and state variables of a | ||
566 | module. Additional private fields may exist after the public ones. | ||
567 | */ | ||
568 | |||
569 | /* | ||
570 | Error handler object | ||
571 | */ | ||
572 | |||
573 | struct jpeg_error_mgr { | ||
574 | /* Error exit handler: does not return to caller */ | ||
575 | void ( *error_exit ) ( j_common_ptr cinfo ); | ||
576 | |||
577 | /* Conditionally emit a trace or warning message */ | ||
578 | void ( *emit_message ) ( j_common_ptr cinfo, int msg_level ); | ||
579 | |||
580 | /* Routine that actually outputs a trace or error message */ | ||
581 | void ( *output_message ) ( j_common_ptr cinfo ); | ||
582 | |||
583 | /* Format a message string for the most recent JPEG error or message */ | ||
584 | void ( *format_message ) ( j_common_ptr cinfo, char *buffer ); | ||
585 | |||
586 | /* Reset error state variables at start of a new image */ | ||
587 | void ( *reset_error_mgr ) ( j_common_ptr cinfo ); | ||
588 | |||
589 | /* | ||
590 | The message ID code and any parameters are saved here. A message can have | ||
591 | one string parameter or up to 8 int parameters. | ||
592 | */ | ||
593 | int msg_code; | ||
594 | |||
595 | union { | ||
596 | int i[ 8 ]; | ||
597 | char s[ 80 ]; | ||
598 | } msg_parm; | ||
599 | |||
600 | |||
601 | /* | ||
602 | Standard state variables for error facility | ||
603 | */ | ||
604 | |||
605 | /* max msg_level that will be displayed */ | ||
606 | int trace_level; | ||
607 | |||
608 | /* | ||
609 | For recoverable corrupt-data errors, we emit a warning message, but keep | ||
610 | going unless emit_message chooses to abort. emit_message should count | ||
611 | warnings in num_warnings. The surrounding application can check for bad data | ||
612 | by seeing if num_warnings is nonzero at the end of processing. | ||
613 | */ | ||
614 | |||
615 | /* number of corrupt-data warnings */ | ||
616 | long num_warnings; | ||
617 | |||
618 | /* | ||
619 | These fields point to the table(s) of error message strings. An application | ||
620 | can change the table pointer to switch to a different message list | ||
621 | (typically, to change the language in which errors are reported). Some | ||
622 | applications may wish to add additional error codes that will be handled by | ||
623 | the JPEG library error mechanism; the second table pointer is used for this | ||
624 | purpose. | ||
625 | |||
626 | First table includes all errors generated by JPEG library itself. Error | ||
627 | code 0 is reserved for a "no such error string" message. | ||
628 | */ | ||
629 | |||
630 | /* Library errors */ | ||
631 | const char *const *jpeg_message_table; | ||
632 | |||
633 | /* Table contains strings 0..last_jpeg_message */ | ||
634 | int last_jpeg_message; | ||
635 | |||
636 | /* | ||
637 | Second table can be added by application (see cjpeg/djpeg for example). It | ||
638 | contains strings numbered first_addon_message..last_addon_message. | ||
639 | */ | ||
640 | |||
641 | /* Non-library errors */ | ||
642 | const char *const *addon_message_table; | ||
643 | |||
644 | /* code for first string in addon table */ | ||
645 | int first_addon_message; | ||
646 | |||
647 | /* code for last string in addon table */ | ||
648 | int last_addon_message; | ||
649 | }; | ||
650 | |||
651 | |||
652 | /* | ||
653 | Progress monitor object | ||
654 | */ | ||
655 | |||
656 | struct jpeg_progress_mgr { | ||
657 | void ( *progress_monitor ) ( j_common_ptr cinfo ); | ||
658 | |||
659 | /* work units completed in this pass */ | ||
660 | long pass_counter; | ||
661 | |||
662 | /* total number of work units in this pass */ | ||
663 | long pass_limit; | ||
664 | |||
665 | /* passes completed so far */ | ||
666 | int completed_passes; | ||
667 | |||
668 | /* total number of passes expected */ | ||
669 | int total_passes; | ||
670 | }; | ||
671 | |||
672 | |||
673 | /* | ||
674 | Data destination object for compression | ||
675 | */ | ||
676 | |||
677 | struct jpeg_destination_mgr { | ||
678 | /* => next byte to write in buffer */ | ||
679 | unsigned char *next_output_byte; | ||
680 | |||
681 | /* # of byte spaces remaining in buffer */ | ||
682 | long unsigned int free_in_buffer; | ||
683 | |||
684 | void ( *init_destination ) ( j_compress_ptr cinfo ); | ||
685 | int ( *empty_output_buffer ) ( j_compress_ptr cinfo ); | ||
686 | void ( *term_destination ) ( j_compress_ptr cinfo ); | ||
687 | }; | ||
688 | |||
689 | |||
690 | /* | ||
691 | Memory manager object. | ||
692 | Allocates "small" objects (a few K total), "large" objects (tens of K), and | ||
693 | "really big" objects (virtual arrays with backing store if needed). The memory | ||
694 | manager does not allow individual objects to be freed; rather, each created | ||
695 | object is assigned to a pool, and whole pools can be freed at once. This is | ||
696 | faster and more convenient than remembering exactly what to free, especially | ||
697 | where malloc()/free() are not too speedy. | ||
698 | NB: alloc routines never return (void*)0. They exit to error_exit if not | ||
699 | successful. | ||
700 | */ | ||
701 | |||
702 | typedef struct jvirt_sarray_control *jvirt_sarray_ptr; | ||
703 | typedef struct jvirt_barray_control *jvirt_barray_ptr; | ||
704 | |||
705 | struct jpeg_memory_mgr { | ||
706 | /* | ||
707 | Method pointers | ||
708 | */ | ||
709 | void *( *alloc_small ) ( | ||
710 | j_common_ptr cinfo, int pool_id, long unsigned int sizeofobject ); | ||
711 | |||
712 | void *( *alloc_large ) ( | ||
713 | j_common_ptr cinfo, int pool_id, long unsigned int sizeofobject ); | ||
714 | |||
715 | JSAMPARRAY ( *alloc_sarray ) ( | ||
716 | j_common_ptr cinfo, int pool_id, unsigned int samplesperrow, | ||
717 | unsigned int numrows ); | ||
718 | |||
719 | JBLOCKARRAY ( *alloc_barray )( | ||
720 | j_common_ptr cinfo, int pool_id, unsigned int blocksperrow, | ||
721 | unsigned int numrows ); | ||
722 | |||
723 | jvirt_sarray_ptr ( *request_virt_sarray ) ( | ||
724 | j_common_ptr cinfo, int pool_id, int pre_zero, unsigned int samplesperrow, | ||
725 | unsigned int numrows, unsigned int maxaccess ); | ||
726 | |||
727 | jvirt_barray_ptr ( *request_virt_barray ) ( | ||
728 | j_common_ptr cinfo, int pool_id, int pre_zero, unsigned int blocksperrow, | ||
729 | unsigned int numrows, unsigned int maxaccess ); | ||
730 | |||
731 | void ( *realize_virt_arrays ) ( j_common_ptr cinfo ); | ||
732 | |||
733 | JSAMPARRAY ( *access_virt_sarray ) ( | ||
734 | j_common_ptr cinfo, jvirt_sarray_ptr ptr, unsigned int start_row, | ||
735 | unsigned int num_rows, int writable ); | ||
736 | |||
737 | JBLOCKARRAY ( *access_virt_barray ) ( | ||
738 | j_common_ptr cinfo, jvirt_barray_ptr ptr, unsigned int start_row, | ||
739 | unsigned int num_rows, int writable ); | ||
740 | |||
741 | void ( *free_pool ) ( j_common_ptr cinfo, int pool_id ); | ||
742 | |||
743 | void ( *self_destruct ) ( j_common_ptr cinfo ); | ||
744 | |||
745 | /* | ||
746 | Limit on memory allocation for this JPEG object. (Note that this is merely | ||
747 | advisory, not a guaranteed maximum; it only affects the space used for | ||
748 | virtual-array buffers.) May be changed by outer application after creating | ||
749 | the JPEG object. | ||
750 | */ | ||
751 | long max_memory_to_use; | ||
752 | |||
753 | /* Maximum allocation request accepted by alloc_large. */ | ||
754 | long max_alloc_chunk; | ||
755 | }; | ||
756 | |||
757 | #endif /* JPEGLIB_H */ | ||