jpeglib.h
上传用户:center1979
上传日期:2022-07-26
资源大小:50633k
文件大小:46k
源码类别:

OpenGL

开发平台:

Visual C++

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