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