< prev index next >

modules/javafx.graphics/src/main/native-iio/libjpeg7/jpeglib.h

Print this page


   1 /*
   2  * jpeglib.h
   3  *
   4  * Copyright (C) 1991-1998, Thomas G. Lane.
   5  * Modified 2002-2009 by Guido Vollbeding.
   6  * This file is part of the Independent JPEG Group's software.
   7  * For conditions of distribution and use, see the accompanying README file.
   8  *
   9  * This file defines the application interface for the JPEG library.
  10  * Most applications using the library need only include this file,
  11  * and perhaps jerror.h if they want to know the exact error codes.
  12  */
  13 
  14 #ifndef JPEGLIB_H
  15 #define JPEGLIB_H
  16 
  17 /*
  18  * First we include the configuration files that record how this
  19  * installation of the JPEG library is set up.  jconfig.h can be
  20  * generated automatically for many systems.  jmorecfg.h contains
  21  * manual configuration options that most people need not worry about.
  22  */
  23 
  24 #ifndef JCONFIG_INCLUDED        /* in case jinclude.h already did */
  25 #include "jconfig.h"            /* widely used configuration options */
  26 #endif
  27 #include "jmorecfg.h"           /* seldom changed options */
  28 
  29 
  30 #ifdef __cplusplus
  31 #ifndef DONT_USE_EXTERN_C
  32 extern "C" {
  33 #endif
  34 #endif
  35 
  36 /* Version ID for the JPEG library.
  37  * Might be useful for tests like "#if JPEG_LIB_VERSION >= 70".
  38  */
  39 
  40 #define JPEG_LIB_VERSION  70    /* Version 7.0 */


  41 
  42 
  43 /* Various constants determining the sizes of things.
  44  * All of these are specified by the JPEG standard, so don't change them
  45  * if you want to be compatible.
  46  */
  47 
  48 #define DCTSIZE             8   /* The basic DCT block is 8x8 samples */
  49 #define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  50 #define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  51 #define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  52 #define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  53 #define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  54 #define MAX_SAMP_FACTOR     4   /* JPEG limit on sampling factors */
  55 /* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard;
  56  * the PostScript DCT filter can emit files with many more than 10 blocks/MCU.
  57  * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU
  58  * to handle it.  We even let you do this from the jconfig.h file.  However,
  59  * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe
  60  * sometimes emits noncompliant files doesn't mean you should too.
  61  */
  62 #define C_MAX_BLOCKS_IN_MCU   10 /* compressor's limit on blocks per MCU */
  63 #ifndef D_MAX_BLOCKS_IN_MCU
  64 #define D_MAX_BLOCKS_IN_MCU   10 /* decompressor's limit on blocks per MCU */
  65 #endif
  66 
  67 
  68 /* Data structures for images (arrays of samples and of DCT coefficients).


 138 
 139   /* Remaining fields should be treated as private by applications. */
 140 
 141   /* These values are computed during compression or decompression startup: */
 142   /* Component's size in DCT blocks.
 143    * Any dummy blocks added to complete an MCU are not counted; therefore
 144    * these values do not depend on whether a scan is interleaved or not.
 145    */
 146   JDIMENSION width_in_blocks;
 147   JDIMENSION height_in_blocks;
 148   /* Size of a DCT block in samples,
 149    * reflecting any scaling we choose to apply during the DCT step.
 150    * Values from 1 to 16 are supported.
 151    * Note that different components may receive different DCT scalings.
 152    */
 153   int DCT_h_scaled_size;
 154   int DCT_v_scaled_size;
 155   /* The downsampled dimensions are the component's actual, unpadded number
 156    * of samples at the main buffer (preprocessing/compression interface);
 157    * DCT scaling is included, so
 158    * downsampled_width = ceil(image_width * Hi/Hmax * DCT_h_scaled_size/DCTSIZE)

 159    * and similarly for height.
 160    */
 161   JDIMENSION downsampled_width;  /* actual width in samples */
 162   JDIMENSION downsampled_height; /* actual height in samples */
 163   /* This flag is used only for decompression.  In cases where some of the
 164    * components will be ignored (eg grayscale output from YCbCr image),
 165    * we can skip most computations for the unused components.




 166    */
 167   boolean component_needed;     /* do we need the value of this component? */
 168 
 169   /* These values are computed before starting a scan of the component. */
 170   /* The decompressor output side may not use these variables. */
 171   int MCU_width;                /* number of blocks per MCU, horizontally */
 172   int MCU_height;               /* number of blocks per MCU, vertically */
 173   int MCU_blocks;               /* MCU_width * MCU_height */
 174   int MCU_sample_width;         /* MCU width in samples, MCU_width*DCT_scaled_size */
 175   int last_col_width;           /* # of non-dummy blocks across in last MCU */
 176   int last_row_height;          /* # of non-dummy blocks down in last MCU */
 177 
 178   /* Saved quantization table for component; NULL if none yet saved.
 179    * See jdinput.c comments about the need for this information.
 180    * This field is currently used only for decompression.
 181    */
 182   JQUANT_TBL * quant_table;
 183 
 184   /* Private per-component storage for DCT or IDCT subsystem. */
 185   void * dct_table;
 186 } jpeg_component_info;
 187 
 188 
 189 /* The script for encoding a multiple-scan file is an array of these: */
 190 
 191 typedef struct {
 192   int comps_in_scan;            /* number of components encoded in this scan */
 193   int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */
 194   int Ss, Se;                   /* progressive JPEG spectral selection parms */


 196 } jpeg_scan_info;
 197 
 198 /* The decompressor can save APPn and COM markers in a list of these: */
 199 
 200 typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr;
 201 
 202 struct jpeg_marker_struct {
 203   jpeg_saved_marker_ptr next;   /* next in list, or NULL */
 204   UINT8 marker;                 /* marker code: JPEG_COM, or JPEG_APP0+n */
 205   unsigned int original_length; /* # bytes of data in the file */
 206   unsigned int data_length;     /* # bytes of data saved at data[] */
 207   JOCTET FAR * data;            /* the data contained in the marker */
 208   /* the marker length word is not counted in data_length or original_length */
 209 };
 210 
 211 /* Known color spaces. */
 212 
 213 typedef enum {
 214         JCS_UNKNOWN,            /* error/unspecified */
 215         JCS_GRAYSCALE,          /* monochrome */
 216         JCS_RGB,                /* red/green/blue */
 217         JCS_YCbCr,              /* Y/Cb/Cr (also known as YUV) */
 218         JCS_CMYK,               /* C/M/Y/K */
 219         JCS_YCCK                /* Y/Cb/Cr/K */


 220 } J_COLOR_SPACE;
 221 







 222 /* DCT/IDCT algorithm options. */
 223 
 224 typedef enum {
 225         JDCT_ISLOW,             /* slow but accurate integer algorithm */
 226         JDCT_IFAST,             /* faster, less accurate integer method */
 227         JDCT_FLOAT              /* floating-point: accurate, fast on fast HW */
 228 } J_DCT_METHOD;
 229 
 230 #ifndef JDCT_DEFAULT            /* may be overridden in jconfig.h */
 231 #define JDCT_DEFAULT  JDCT_ISLOW
 232 #endif
 233 #ifndef JDCT_FASTEST            /* may be overridden in jconfig.h */
 234 #define JDCT_FASTEST  JDCT_IFAST
 235 #endif
 236 
 237 /* Dithering options for decompression. */
 238 
 239 typedef enum {
 240         JDITHER_NONE,           /* no dithering */
 241         JDITHER_ORDERED,        /* simple ordered dither */


 351    * (in which case the correct restart_interval will be figured
 352    * for each scan).
 353    */
 354   unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */
 355   int restart_in_rows;          /* if > 0, MCU rows per restart interval */
 356 
 357   /* Parameters controlling emission of special markers. */
 358 
 359   boolean write_JFIF_header;    /* should a JFIF marker be written? */
 360   UINT8 JFIF_major_version;     /* What to write for the JFIF version number */
 361   UINT8 JFIF_minor_version;
 362   /* These three values are not used by the JPEG code, merely copied */
 363   /* into the JFIF APP0 marker.  density_unit can be 0 for unknown, */
 364   /* 1 for dots/inch, or 2 for dots/cm.  Note that the pixel aspect */
 365   /* ratio is defined by X_density/Y_density even when density_unit=0. */
 366   UINT8 density_unit;           /* JFIF code for pixel size units */
 367   UINT16 X_density;             /* Horizontal pixel density */
 368   UINT16 Y_density;             /* Vertical pixel density */
 369   boolean write_Adobe_marker;   /* should an Adobe marker be written? */
 370 



 371   /* State variable: index of next scanline to be written to
 372    * jpeg_write_scanlines().  Application may use this to control its
 373    * processing loop, e.g., "while (next_scanline < image_height)".
 374    */
 375 
 376   JDIMENSION next_scanline;     /* 0 .. image_height-1  */
 377 
 378   /* Remaining fields are known throughout compressor, but generally
 379    * should not be touched by a surrounding application.
 380    */
 381 
 382   /*
 383    * These fields are computed during compression startup
 384    */
 385   boolean progressive_mode;     /* TRUE if scan script uses progressive mode */
 386   int max_h_samp_factor;        /* largest h_samp_factor */
 387   int max_v_samp_factor;        /* largest v_samp_factor */
 388 
 389   int min_DCT_h_scaled_size;    /* smallest DCT_h_scaled_size of any component */
 390   int min_DCT_v_scaled_size;    /* smallest DCT_v_scaled_size of any component */
 391 
 392   JDIMENSION total_iMCU_rows;   /* # of iMCU rows to be input to coef ctlr */
 393   /* The coefficient controller receives data in units of MCU rows as defined
 394    * for fully interleaved scans (whether the JPEG file is interleaved or not).
 395    * There are v_samp_factor * DCTSIZE sample rows of each component in an
 396    * "iMCU" (interleaved MCU) row.
 397    */
 398 
 399   /*
 400    * These fields are valid during any one scan.
 401    * They describe the components and MCUs actually appearing in the scan.
 402    */
 403   int comps_in_scan;            /* # of JPEG components in this scan */
 404   jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
 405   /* *cur_comp_info[i] describes component that appears i'th in SOS */
 406 
 407   JDIMENSION MCUs_per_row;      /* # of MCUs across the image */
 408   JDIMENSION MCU_rows_in_scan;  /* # of MCU rows in the image */
 409 
 410   int blocks_in_MCU;            /* # of DCT blocks per MCU */
 411   int MCU_membership[C_MAX_BLOCKS_IN_MCU];
 412   /* MCU_membership[i] is index in cur_comp_info of component owning */
 413   /* i'th block in an MCU */
 414 
 415   int Ss, Se, Ah, Al;           /* progressive JPEG parameters for scan */
 416 




 417   /*
 418    * Links to compression subobjects (methods and private variables of modules)
 419    */
 420   struct jpeg_comp_master * master;
 421   struct jpeg_c_main_controller * main;
 422   struct jpeg_c_prep_controller * prep;
 423   struct jpeg_c_coef_controller * coef;
 424   struct jpeg_marker_writer * marker;
 425   struct jpeg_color_converter * cconvert;
 426   struct jpeg_downsampler * downsample;
 427   struct jpeg_forward_dct * fdct;
 428   struct jpeg_entropy_encoder * entropy;
 429   jpeg_scan_info * script_space; /* workspace for jpeg_simple_progression */
 430   int script_space_size;
 431 };
 432 
 433 
 434 /* Master record for a decompression instance */
 435 
 436 struct jpeg_decompress_struct {


 543   /* Quantization and Huffman tables are carried forward across input
 544    * datastreams when processing abbreviated JPEG datastreams.
 545    */
 546 
 547   JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS];
 548   /* ptrs to coefficient quantization tables, or NULL if not defined */
 549 
 550   JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
 551   JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
 552   /* ptrs to Huffman coding tables, or NULL if not defined */
 553 
 554   /* These parameters are never carried across datastreams, since they
 555    * are given in SOF/SOS markers or defined to be reset by SOI.
 556    */
 557 
 558   int data_precision;           /* bits of precision in image data */
 559 
 560   jpeg_component_info * comp_info;
 561   /* comp_info[i] describes component that appears i'th in SOF */
 562 

 563   boolean progressive_mode;     /* TRUE if SOFn specifies progressive mode */
 564   boolean arith_code;           /* TRUE=arithmetic coding, FALSE=Huffman */
 565 
 566   UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
 567   UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
 568   UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
 569 
 570   unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */
 571 
 572   /* These fields record data obtained from optional markers recognized by
 573    * the JPEG library.
 574    */
 575   boolean saw_JFIF_marker;      /* TRUE iff a JFIF APP0 marker was found */
 576   /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */
 577   UINT8 JFIF_major_version;     /* JFIF version number */
 578   UINT8 JFIF_minor_version;
 579   UINT8 density_unit;           /* JFIF code for pixel size units */
 580   UINT16 X_density;             /* Horizontal pixel density */
 581   UINT16 Y_density;             /* Vertical pixel density */
 582   boolean saw_Adobe_marker;     /* TRUE iff an Adobe APP14 marker was found */
 583   UINT8 Adobe_transform;        /* Color transform code from Adobe marker */
 584 



 585   boolean CCIR601_sampling;     /* TRUE=first samples are cosited */
 586 
 587   /* Aside from the specific data retained from APPn markers known to the
 588    * library, the uninterpreted contents of any or all APPn and COM markers
 589    * can be saved in a list for examination by the application.
 590    */
 591   jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */
 592 
 593   /* Remaining fields are known throughout decompressor, but generally
 594    * should not be touched by a surrounding application.
 595    */
 596 
 597   /*
 598    * These fields are computed during decompression startup
 599    */
 600   int max_h_samp_factor;        /* largest h_samp_factor */
 601   int max_v_samp_factor;        /* largest v_samp_factor */
 602 
 603   int min_DCT_h_scaled_size;    /* smallest DCT_h_scaled_size of any component */
 604   int min_DCT_v_scaled_size;    /* smallest DCT_v_scaled_size of any component */
 605 
 606   JDIMENSION total_iMCU_rows;   /* # of iMCU rows in image */
 607   /* The coefficient controller's input and output progress is measured in
 608    * units of "iMCU" (interleaved MCU) rows.  These are the same as MCU rows
 609    * in fully interleaved JPEG scans, but are used whether the scan is
 610    * interleaved or not.  We define an iMCU row as v_samp_factor DCT block
 611    * rows of each component.  Therefore, the IDCT output contains
 612    * v_samp_factor*DCT_v_scaled_size sample rows of a component per iMCU row.
 613    */
 614 
 615   JSAMPLE * sample_range_limit; /* table for fast range-limiting */
 616 
 617   /*
 618    * These fields are valid during any one scan.
 619    * They describe the components and MCUs actually appearing in the scan.
 620    * Note that the decompressor output side must not use these fields.
 621    */
 622   int comps_in_scan;            /* # of JPEG components in this scan */
 623   jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
 624   /* *cur_comp_info[i] describes component that appears i'th in SOS */
 625 
 626   JDIMENSION MCUs_per_row;      /* # of MCUs across the image */
 627   JDIMENSION MCU_rows_in_scan;  /* # of MCU rows in the image */
 628 
 629   int blocks_in_MCU;            /* # of DCT blocks per MCU */
 630   int MCU_membership[D_MAX_BLOCKS_IN_MCU];
 631   /* MCU_membership[i] is index in cur_comp_info of component owning */
 632   /* i'th block in an MCU */
 633 
 634   int Ss, Se, Ah, Al;           /* progressive JPEG parameters for scan */
 635 






 636   /* This field is shared between entropy decoder and marker parser.
 637    * It is either zero or the code of a JPEG marker that has been
 638    * read from the data source, but has not yet been processed.
 639    */
 640   int unread_marker;
 641 
 642   /*
 643    * Links to decompression subobjects (methods, private variables of modules)
 644    */
 645   struct jpeg_decomp_master * master;
 646   struct jpeg_d_main_controller * main;
 647   struct jpeg_d_coef_controller * coef;
 648   struct jpeg_d_post_controller * post;
 649   struct jpeg_input_controller * inputctl;
 650   struct jpeg_marker_reader * marker;
 651   struct jpeg_entropy_decoder * entropy;
 652   struct jpeg_inverse_dct * idct;
 653   struct jpeg_upsampler * upsample;
 654   struct jpeg_color_deconverter * cconvert;
 655   struct jpeg_color_quantizer * cquantize;
 656 };
 657 
 658 
 659 /* "Object" declarations for JPEG modules that may be supplied or called
 660  * directly by the surrounding application.
 661  * As with all objects in the JPEG library, these structs only define the
 662  * publicly visible methods and state variables of a module.  Additional
 663  * private fields may exist after the public ones.
 664  */
 665 
 666 
 667 /* Error handler object */
 668 
 669 struct jpeg_error_mgr {
 670   /* Error exit handler: does not return to caller */
 671   JMETHOD(void, error_exit, (j_common_ptr cinfo));
 672   /* Conditionally emit a trace or warning message */
 673   JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level));
 674   /* Routine that actually outputs a trace or error message */
 675   JMETHOD(void, output_message, (j_common_ptr cinfo));
 676   /* Format a message string for the most recent JPEG error or message */
 677   JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer));
 678 #define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
 679   /* Reset error state variables at start of a new image */
 680   JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo));
 681 
 682   /* The message ID code and any parameters are saved here.
 683    * A message can have one string parameter or up to 8 int parameters.
 684    */
 685   int msg_code;
 686 #define JMSG_STR_PARM_MAX  80
 687   union {
 688     int i[8];
 689     char s[JMSG_STR_PARM_MAX];
 690   } msg_parm;
 691 


 845 #else
 846 #define JPP(arglist)    ()
 847 #endif
 848 
 849 
 850 /* Short forms of external names for systems with brain-damaged linkers.
 851  * We shorten external names to be unique in the first six letters, which
 852  * is good enough for all known systems.
 853  * (If your compiler itself needs names to be unique in less than 15
 854  * characters, you are out of luck.  Get a better compiler.)
 855  */
 856 
 857 #ifdef NEED_SHORT_EXTERNAL_NAMES
 858 #define jpeg_std_error          jStdError
 859 #define jpeg_CreateCompress     jCreaCompress
 860 #define jpeg_CreateDecompress   jCreaDecompress
 861 #define jpeg_destroy_compress   jDestCompress
 862 #define jpeg_destroy_decompress jDestDecompress
 863 #define jpeg_stdio_dest         jStdDest
 864 #define jpeg_stdio_src          jStdSrc


 865 #define jpeg_set_defaults       jSetDefaults
 866 #define jpeg_set_colorspace     jSetColorspace
 867 #define jpeg_default_colorspace jDefColorspace
 868 #define jpeg_set_quality        jSetQuality
 869 #define jpeg_set_linear_quality jSetLQuality
 870 #define jpeg_default_qtables    jDefQTables
 871 #define jpeg_add_quant_table    jAddQuantTable
 872 #define jpeg_quality_scaling    jQualityScaling
 873 #define jpeg_simple_progression jSimProgress
 874 #define jpeg_suppress_tables    jSuppressTables
 875 #define jpeg_alloc_quant_table  jAlcQTable
 876 #define jpeg_alloc_huff_table   jAlcHTable
 877 #define jpeg_start_compress     jStrtCompress
 878 #define jpeg_write_scanlines    jWrtScanlines
 879 #define jpeg_finish_compress    jFinCompress
 880 #define jpeg_calc_jpeg_dimensions       jCjpegDimensions
 881 #define jpeg_write_raw_data     jWrtRawData
 882 #define jpeg_write_marker       jWrtMarker
 883 #define jpeg_write_m_header     jWrtMHeader
 884 #define jpeg_write_m_byte       jWrtMByte
 885 #define jpeg_write_tables       jWrtTables
 886 #define jpeg_read_header        jReadHeader
 887 #define jpeg_start_decompress   jStrtDecompress
 888 #define jpeg_read_scanlines     jReadScanlines
 889 #define jpeg_finish_decompress  jFinDecompress
 890 #define jpeg_read_raw_data      jReadRawData
 891 #define jpeg_has_multiple_scans jHasMultScn
 892 #define jpeg_start_output       jStrtOutput
 893 #define jpeg_finish_output      jFinOutput
 894 #define jpeg_input_complete     jInComplete
 895 #define jpeg_new_colormap       jNewCMap
 896 #define jpeg_consume_input      jConsumeInput

 897 #define jpeg_calc_output_dimensions     jCalcDimensions
 898 #define jpeg_save_markers       jSaveMarkers
 899 #define jpeg_set_marker_processor       jSetMarker
 900 #define jpeg_read_coefficients  jReadCoefs
 901 #define jpeg_write_coefficients jWrtCoefs
 902 #define jpeg_copy_critical_parameters   jCopyCrit
 903 #define jpeg_abort_compress     jAbrtCompress
 904 #define jpeg_abort_decompress   jAbrtDecompress
 905 #define jpeg_abort              jAbort
 906 #define jpeg_destroy            jDestroy
 907 #define jpeg_resync_to_restart  jResyncRestart
 908 #endif /* NEED_SHORT_EXTERNAL_NAMES */
 909 
 910 
 911 /* Default error-management setup */
 912 EXTERN(struct jpeg_error_mgr *) jpeg_std_error
 913         JPP((struct jpeg_error_mgr * err));
 914 
 915 /* Initialization of JPEG compression objects.
 916  * jpeg_create_compress() and jpeg_create_decompress() are the exported


 921  */
 922 #define jpeg_create_compress(cinfo) \
 923     jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \
 924                         (size_t) sizeof(struct jpeg_compress_struct))
 925 #define jpeg_create_decompress(cinfo) \
 926     jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \
 927                           (size_t) sizeof(struct jpeg_decompress_struct))
 928 EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo,
 929                                       int version, size_t structsize));
 930 EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo,
 931                                         int version, size_t structsize));
 932 /* Destruction of JPEG compression objects */
 933 EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo));
 934 EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo));
 935 
 936 /* Standard data source and destination managers: stdio streams. */
 937 /* Caller is responsible for opening the file before and closing after. */
 938 EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile));
 939 EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile));
 940 








 941 /* Default parameter setup for compression */
 942 EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo));
 943 /* Compression parameter setup aids */
 944 EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo,
 945                                       J_COLOR_SPACE colorspace));
 946 EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo));
 947 EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality,
 948                                    boolean force_baseline));
 949 EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo,
 950                                           int scale_factor,
 951                                           boolean force_baseline));
 952 EXTERN(void) jpeg_default_qtables JPP((j_compress_ptr cinfo,
 953                                        boolean force_baseline));
 954 EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl,
 955                                        const unsigned int *basic_table,
 956                                        int scale_factor,
 957                                        boolean force_baseline));
 958 EXTERN(int) jpeg_quality_scaling JPP((int quality));
 959 EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo));
 960 EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo,


1015 EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo,
1016                                            JSAMPIMAGE data,
1017                                            JDIMENSION max_lines));
1018 
1019 /* Additional entry points for buffered-image mode. */
1020 EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo));
1021 EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo,
1022                                        int scan_number));
1023 EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo));
1024 EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo));
1025 EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo));
1026 EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo));
1027 /* Return value is one of: */
1028 /* #define JPEG_SUSPENDED       0    Suspended due to lack of input data */
1029 #define JPEG_REACHED_SOS        1 /* Reached start of new scan */
1030 #define JPEG_REACHED_EOI        2 /* Reached end of image */
1031 #define JPEG_ROW_COMPLETED      3 /* Completed one iMCU row */
1032 #define JPEG_SCAN_COMPLETED     4 /* Completed last iMCU row of a scan */
1033 
1034 /* Precalculate output dimensions for current decompression parameters. */

1035 EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo));
1036 
1037 /* Control saving of COM and APPn markers into marker_list. */
1038 EXTERN(void) jpeg_save_markers
1039         JPP((j_decompress_ptr cinfo, int marker_code,
1040              unsigned int length_limit));
1041 
1042 /* Install a special processing method for COM or APPn markers. */
1043 EXTERN(void) jpeg_set_marker_processor
1044         JPP((j_decompress_ptr cinfo, int marker_code,
1045              jpeg_marker_parser_method routine));
1046 
1047 /* Read or write raw DCT coefficients --- useful for lossless transcoding. */
1048 EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo));
1049 EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo,
1050                                           jvirt_barray_ptr * coef_arrays));
1051 EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo,
1052                                                 j_compress_ptr dstinfo));
1053 
1054 /* If you choose to abort compression or decompression before completing


   1 /*
   2  * jpeglib.h
   3  *
   4  * Copyright (C) 1991-1998, Thomas G. Lane.
   5  * Modified 2002-2017 by Guido Vollbeding.
   6  * This file is part of the Independent JPEG Group's software.
   7  * For conditions of distribution and use, see the accompanying README file.
   8  *
   9  * This file defines the application interface for the JPEG library.
  10  * Most applications using the library need only include this file,
  11  * and perhaps jerror.h if they want to know the exact error codes.
  12  */
  13 
  14 #ifndef JPEGLIB_H
  15 #define JPEGLIB_H
  16 
  17 /*
  18  * First we include the configuration files that record how this
  19  * installation of the JPEG library is set up.  jconfig.h can be
  20  * generated automatically for many systems.  jmorecfg.h contains
  21  * manual configuration options that most people need not worry about.
  22  */
  23 
  24 #ifndef JCONFIG_INCLUDED        /* in case jinclude.h already did */
  25 #include "jconfig.h"            /* widely used configuration options */
  26 #endif
  27 #include "jmorecfg.h"           /* seldom changed options */
  28 
  29 
  30 #ifdef __cplusplus
  31 #ifndef DONT_USE_EXTERN_C
  32 extern "C" {
  33 #endif
  34 #endif
  35 
  36 /* Version IDs for the JPEG library.
  37  * Might be useful for tests like "#if JPEG_LIB_VERSION >= 90".
  38  */
  39 
  40 #define JPEG_LIB_VERSION        90      /* Compatibility version 9.0 */
  41 #define JPEG_LIB_VERSION_MAJOR  9
  42 #define JPEG_LIB_VERSION_MINOR  3
  43 
  44 
  45 /* Various constants determining the sizes of things.
  46  * All of these are specified by the JPEG standard,
  47  * so don't change them if you want to be compatible.
  48  */
  49 
  50 #define DCTSIZE             8   /* The basic DCT block is 8x8 coefficients */
  51 #define DCTSIZE2            64  /* DCTSIZE squared; # of elements in a block */
  52 #define NUM_QUANT_TBLS      4   /* Quantization tables are numbered 0..3 */
  53 #define NUM_HUFF_TBLS       4   /* Huffman tables are numbered 0..3 */
  54 #define NUM_ARITH_TBLS      16  /* Arith-coding tables are numbered 0..15 */
  55 #define MAX_COMPS_IN_SCAN   4   /* JPEG limit on # of components in one scan */
  56 #define MAX_SAMP_FACTOR     4   /* JPEG limit on sampling factors */
  57 /* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard;
  58  * the PostScript DCT filter can emit files with many more than 10 blocks/MCU.
  59  * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU
  60  * to handle it.  We even let you do this from the jconfig.h file.  However,
  61  * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe
  62  * sometimes emits noncompliant files doesn't mean you should too.
  63  */
  64 #define C_MAX_BLOCKS_IN_MCU   10 /* compressor's limit on blocks per MCU */
  65 #ifndef D_MAX_BLOCKS_IN_MCU
  66 #define D_MAX_BLOCKS_IN_MCU   10 /* decompressor's limit on blocks per MCU */
  67 #endif
  68 
  69 
  70 /* Data structures for images (arrays of samples and of DCT coefficients).


 140 
 141   /* Remaining fields should be treated as private by applications. */
 142 
 143   /* These values are computed during compression or decompression startup: */
 144   /* Component's size in DCT blocks.
 145    * Any dummy blocks added to complete an MCU are not counted; therefore
 146    * these values do not depend on whether a scan is interleaved or not.
 147    */
 148   JDIMENSION width_in_blocks;
 149   JDIMENSION height_in_blocks;
 150   /* Size of a DCT block in samples,
 151    * reflecting any scaling we choose to apply during the DCT step.
 152    * Values from 1 to 16 are supported.
 153    * Note that different components may receive different DCT scalings.
 154    */
 155   int DCT_h_scaled_size;
 156   int DCT_v_scaled_size;
 157   /* The downsampled dimensions are the component's actual, unpadded number
 158    * of samples at the main buffer (preprocessing/compression interface);
 159    * DCT scaling is included, so
 160    * downsampled_width =
 161    *   ceil(image_width * Hi/Hmax * DCT_h_scaled_size/block_size)
 162    * and similarly for height.
 163    */
 164   JDIMENSION downsampled_width;  /* actual width in samples */
 165   JDIMENSION downsampled_height; /* actual height in samples */
 166   /* For decompression, in cases where some of the components will be
 167    * ignored (eg grayscale output from YCbCr image), we can skip most
 168    * computations for the unused components.
 169    * For compression, some of the components will need further quantization
 170    * scale by factor of 2 after DCT (eg BG_YCC output from normal RGB input).
 171    * The field is first set TRUE for decompression, FALSE for compression
 172    * in initial_setup, and then adapted in color conversion setup.
 173    */
 174   boolean component_needed;
 175 
 176   /* These values are computed before starting a scan of the component. */
 177   /* The decompressor output side may not use these variables. */
 178   int MCU_width;                /* number of blocks per MCU, horizontally */
 179   int MCU_height;               /* number of blocks per MCU, vertically */
 180   int MCU_blocks;               /* MCU_width * MCU_height */
 181   int MCU_sample_width; /* MCU width in samples: MCU_width * DCT_h_scaled_size */
 182   int last_col_width;           /* # of non-dummy blocks across in last MCU */
 183   int last_row_height;          /* # of non-dummy blocks down in last MCU */
 184 
 185   /* Saved quantization table for component; NULL if none yet saved.
 186    * See jdinput.c comments about the need for this information.
 187    * This field is currently used only for decompression.
 188    */
 189   JQUANT_TBL * quant_table;
 190 
 191   /* Private per-component storage for DCT or IDCT subsystem. */
 192   void * dct_table;
 193 } jpeg_component_info;
 194 
 195 
 196 /* The script for encoding a multiple-scan file is an array of these: */
 197 
 198 typedef struct {
 199   int comps_in_scan;            /* number of components encoded in this scan */
 200   int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */
 201   int Ss, Se;                   /* progressive JPEG spectral selection parms */


 203 } jpeg_scan_info;
 204 
 205 /* The decompressor can save APPn and COM markers in a list of these: */
 206 
 207 typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr;
 208 
 209 struct jpeg_marker_struct {
 210   jpeg_saved_marker_ptr next;   /* next in list, or NULL */
 211   UINT8 marker;                 /* marker code: JPEG_COM, or JPEG_APP0+n */
 212   unsigned int original_length; /* # bytes of data in the file */
 213   unsigned int data_length;     /* # bytes of data saved at data[] */
 214   JOCTET FAR * data;            /* the data contained in the marker */
 215   /* the marker length word is not counted in data_length or original_length */
 216 };
 217 
 218 /* Known color spaces. */
 219 
 220 typedef enum {
 221         JCS_UNKNOWN,            /* error/unspecified */
 222         JCS_GRAYSCALE,          /* monochrome */
 223         JCS_RGB,                /* red/green/blue, standard RGB (sRGB) */
 224         JCS_YCbCr,              /* Y/Cb/Cr (also known as YUV), standard YCC */
 225         JCS_CMYK,               /* C/M/Y/K */
 226         JCS_YCCK,               /* Y/Cb/Cr/K */
 227         JCS_BG_RGB,             /* big gamut red/green/blue, bg-sRGB */
 228         JCS_BG_YCC              /* big gamut Y/Cb/Cr, bg-sYCC */
 229 } J_COLOR_SPACE;
 230 
 231 /* Supported color transforms. */
 232 
 233 typedef enum {
 234         JCT_NONE           = 0,
 235         JCT_SUBTRACT_GREEN = 1
 236 } J_COLOR_TRANSFORM;
 237 
 238 /* DCT/IDCT algorithm options. */
 239 
 240 typedef enum {
 241         JDCT_ISLOW,             /* slow but accurate integer algorithm */
 242         JDCT_IFAST,             /* faster, less accurate integer method */
 243         JDCT_FLOAT              /* floating-point: accurate, fast on fast HW */
 244 } J_DCT_METHOD;
 245 
 246 #ifndef JDCT_DEFAULT            /* may be overridden in jconfig.h */
 247 #define JDCT_DEFAULT  JDCT_ISLOW
 248 #endif
 249 #ifndef JDCT_FASTEST            /* may be overridden in jconfig.h */
 250 #define JDCT_FASTEST  JDCT_IFAST
 251 #endif
 252 
 253 /* Dithering options for decompression. */
 254 
 255 typedef enum {
 256         JDITHER_NONE,           /* no dithering */
 257         JDITHER_ORDERED,        /* simple ordered dither */


 367    * (in which case the correct restart_interval will be figured
 368    * for each scan).
 369    */
 370   unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */
 371   int restart_in_rows;          /* if > 0, MCU rows per restart interval */
 372 
 373   /* Parameters controlling emission of special markers. */
 374 
 375   boolean write_JFIF_header;    /* should a JFIF marker be written? */
 376   UINT8 JFIF_major_version;     /* What to write for the JFIF version number */
 377   UINT8 JFIF_minor_version;
 378   /* These three values are not used by the JPEG code, merely copied */
 379   /* into the JFIF APP0 marker.  density_unit can be 0 for unknown, */
 380   /* 1 for dots/inch, or 2 for dots/cm.  Note that the pixel aspect */
 381   /* ratio is defined by X_density/Y_density even when density_unit=0. */
 382   UINT8 density_unit;           /* JFIF code for pixel size units */
 383   UINT16 X_density;             /* Horizontal pixel density */
 384   UINT16 Y_density;             /* Vertical pixel density */
 385   boolean write_Adobe_marker;   /* should an Adobe marker be written? */
 386 
 387   J_COLOR_TRANSFORM color_transform;
 388   /* Color transform identifier, writes LSE marker if nonzero */
 389 
 390   /* State variable: index of next scanline to be written to
 391    * jpeg_write_scanlines().  Application may use this to control its
 392    * processing loop, e.g., "while (next_scanline < image_height)".
 393    */
 394 
 395   JDIMENSION next_scanline;     /* 0 .. image_height-1  */
 396 
 397   /* Remaining fields are known throughout compressor, but generally
 398    * should not be touched by a surrounding application.
 399    */
 400 
 401   /*
 402    * These fields are computed during compression startup
 403    */
 404   boolean progressive_mode;     /* TRUE if scan script uses progressive mode */
 405   int max_h_samp_factor;        /* largest h_samp_factor */
 406   int max_v_samp_factor;        /* largest v_samp_factor */
 407 
 408   int min_DCT_h_scaled_size;    /* smallest DCT_h_scaled_size of any component */
 409   int min_DCT_v_scaled_size;    /* smallest DCT_v_scaled_size of any component */
 410 
 411   JDIMENSION total_iMCU_rows;   /* # of iMCU rows to be input to coef ctlr */
 412   /* The coefficient controller receives data in units of MCU rows as defined
 413    * for fully interleaved scans (whether the JPEG file is interleaved or not).
 414    * There are v_samp_factor * DCT_v_scaled_size sample rows of each component
 415    * in an "iMCU" (interleaved MCU) row.
 416    */
 417 
 418   /*
 419    * These fields are valid during any one scan.
 420    * They describe the components and MCUs actually appearing in the scan.
 421    */
 422   int comps_in_scan;            /* # of JPEG components in this scan */
 423   jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
 424   /* *cur_comp_info[i] describes component that appears i'th in SOS */
 425 
 426   JDIMENSION MCUs_per_row;      /* # of MCUs across the image */
 427   JDIMENSION MCU_rows_in_scan;  /* # of MCU rows in the image */
 428 
 429   int blocks_in_MCU;            /* # of DCT blocks per MCU */
 430   int MCU_membership[C_MAX_BLOCKS_IN_MCU];
 431   /* MCU_membership[i] is index in cur_comp_info of component owning */
 432   /* i'th block in an MCU */
 433 
 434   int Ss, Se, Ah, Al;           /* progressive JPEG parameters for scan */
 435 
 436   int block_size;               /* the basic DCT block size: 1..16 */
 437   const int * natural_order;    /* natural-order position array */
 438   int lim_Se;                   /* min( Se, DCTSIZE2-1 ) */
 439 
 440   /*
 441    * Links to compression subobjects (methods and private variables of modules)
 442    */
 443   struct jpeg_comp_master * master;
 444   struct jpeg_c_main_controller * main;
 445   struct jpeg_c_prep_controller * prep;
 446   struct jpeg_c_coef_controller * coef;
 447   struct jpeg_marker_writer * marker;
 448   struct jpeg_color_converter * cconvert;
 449   struct jpeg_downsampler * downsample;
 450   struct jpeg_forward_dct * fdct;
 451   struct jpeg_entropy_encoder * entropy;
 452   jpeg_scan_info * script_space; /* workspace for jpeg_simple_progression */
 453   int script_space_size;
 454 };
 455 
 456 
 457 /* Master record for a decompression instance */
 458 
 459 struct jpeg_decompress_struct {


 566   /* Quantization and Huffman tables are carried forward across input
 567    * datastreams when processing abbreviated JPEG datastreams.
 568    */
 569 
 570   JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS];
 571   /* ptrs to coefficient quantization tables, or NULL if not defined */
 572 
 573   JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
 574   JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
 575   /* ptrs to Huffman coding tables, or NULL if not defined */
 576 
 577   /* These parameters are never carried across datastreams, since they
 578    * are given in SOF/SOS markers or defined to be reset by SOI.
 579    */
 580 
 581   int data_precision;           /* bits of precision in image data */
 582 
 583   jpeg_component_info * comp_info;
 584   /* comp_info[i] describes component that appears i'th in SOF */
 585 
 586   boolean is_baseline;          /* TRUE if Baseline SOF0 encountered */
 587   boolean progressive_mode;     /* TRUE if SOFn specifies progressive mode */
 588   boolean arith_code;           /* TRUE=arithmetic coding, FALSE=Huffman */
 589 
 590   UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
 591   UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
 592   UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
 593 
 594   unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */
 595 
 596   /* These fields record data obtained from optional markers recognized by
 597    * the JPEG library.
 598    */
 599   boolean saw_JFIF_marker;      /* TRUE iff a JFIF APP0 marker was found */
 600   /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */
 601   UINT8 JFIF_major_version;     /* JFIF version number */
 602   UINT8 JFIF_minor_version;
 603   UINT8 density_unit;           /* JFIF code for pixel size units */
 604   UINT16 X_density;             /* Horizontal pixel density */
 605   UINT16 Y_density;             /* Vertical pixel density */
 606   boolean saw_Adobe_marker;     /* TRUE iff an Adobe APP14 marker was found */
 607   UINT8 Adobe_transform;        /* Color transform code from Adobe marker */
 608 
 609   J_COLOR_TRANSFORM color_transform;
 610   /* Color transform identifier derived from LSE marker, otherwise zero */
 611 
 612   boolean CCIR601_sampling;     /* TRUE=first samples are cosited */
 613 
 614   /* Aside from the specific data retained from APPn markers known to the
 615    * library, the uninterpreted contents of any or all APPn and COM markers
 616    * can be saved in a list for examination by the application.
 617    */
 618   jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */
 619 
 620   /* Remaining fields are known throughout decompressor, but generally
 621    * should not be touched by a surrounding application.
 622    */
 623 
 624   /*
 625    * These fields are computed during decompression startup
 626    */
 627   int max_h_samp_factor;        /* largest h_samp_factor */
 628   int max_v_samp_factor;        /* largest v_samp_factor */
 629 
 630   int min_DCT_h_scaled_size;    /* smallest DCT_h_scaled_size of any component */
 631   int min_DCT_v_scaled_size;    /* smallest DCT_v_scaled_size of any component */
 632 
 633   JDIMENSION total_iMCU_rows;   /* # of iMCU rows in image */
 634   /* The coefficient controller's input and output progress is measured in
 635    * units of "iMCU" (interleaved MCU) rows.  These are the same as MCU rows
 636    * in fully interleaved JPEG scans, but are used whether the scan is
 637    * interleaved or not.  We define an iMCU row as v_samp_factor DCT block
 638    * rows of each component.  Therefore, the IDCT output contains
 639    * v_samp_factor * DCT_v_scaled_size sample rows of a component per iMCU row.
 640    */
 641 
 642   JSAMPLE * sample_range_limit; /* table for fast range-limiting */
 643 
 644   /*
 645    * These fields are valid during any one scan.
 646    * They describe the components and MCUs actually appearing in the scan.
 647    * Note that the decompressor output side must not use these fields.
 648    */
 649   int comps_in_scan;            /* # of JPEG components in this scan */
 650   jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
 651   /* *cur_comp_info[i] describes component that appears i'th in SOS */
 652 
 653   JDIMENSION MCUs_per_row;      /* # of MCUs across the image */
 654   JDIMENSION MCU_rows_in_scan;  /* # of MCU rows in the image */
 655 
 656   int blocks_in_MCU;            /* # of DCT blocks per MCU */
 657   int MCU_membership[D_MAX_BLOCKS_IN_MCU];
 658   /* MCU_membership[i] is index in cur_comp_info of component owning */
 659   /* i'th block in an MCU */
 660 
 661   int Ss, Se, Ah, Al;           /* progressive JPEG parameters for scan */
 662 
 663   /* These fields are derived from Se of first SOS marker.
 664    */
 665   int block_size;               /* the basic DCT block size: 1..16 */
 666   const int * natural_order; /* natural-order position array for entropy decode */
 667   int lim_Se;                   /* min( Se, DCTSIZE2-1 ) for entropy decode */
 668 
 669   /* This field is shared between entropy decoder and marker parser.
 670    * It is either zero or the code of a JPEG marker that has been
 671    * read from the data source, but has not yet been processed.
 672    */
 673   int unread_marker;
 674 
 675   /*
 676    * Links to decompression subobjects (methods, private variables of modules)
 677    */
 678   struct jpeg_decomp_master * master;
 679   struct jpeg_d_main_controller * main;
 680   struct jpeg_d_coef_controller * coef;
 681   struct jpeg_d_post_controller * post;
 682   struct jpeg_input_controller * inputctl;
 683   struct jpeg_marker_reader * marker;
 684   struct jpeg_entropy_decoder * entropy;
 685   struct jpeg_inverse_dct * idct;
 686   struct jpeg_upsampler * upsample;
 687   struct jpeg_color_deconverter * cconvert;
 688   struct jpeg_color_quantizer * cquantize;
 689 };
 690 
 691 
 692 /* "Object" declarations for JPEG modules that may be supplied or called
 693  * directly by the surrounding application.
 694  * As with all objects in the JPEG library, these structs only define the
 695  * publicly visible methods and state variables of a module.  Additional
 696  * private fields may exist after the public ones.
 697  */
 698 
 699 
 700 /* Error handler object */
 701 
 702 struct jpeg_error_mgr {
 703   /* Error exit handler: does not return to caller */
 704   JMETHOD(noreturn_t, error_exit, (j_common_ptr cinfo));
 705   /* Conditionally emit a trace or warning message */
 706   JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level));
 707   /* Routine that actually outputs a trace or error message */
 708   JMETHOD(void, output_message, (j_common_ptr cinfo));
 709   /* Format a message string for the most recent JPEG error or message */
 710   JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer));
 711 #define JMSG_LENGTH_MAX  200    /* recommended size of format_message buffer */
 712   /* Reset error state variables at start of a new image */
 713   JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo));
 714 
 715   /* The message ID code and any parameters are saved here.
 716    * A message can have one string parameter or up to 8 int parameters.
 717    */
 718   int msg_code;
 719 #define JMSG_STR_PARM_MAX  80
 720   union {
 721     int i[8];
 722     char s[JMSG_STR_PARM_MAX];
 723   } msg_parm;
 724 


 878 #else
 879 #define JPP(arglist)    ()
 880 #endif
 881 
 882 
 883 /* Short forms of external names for systems with brain-damaged linkers.
 884  * We shorten external names to be unique in the first six letters, which
 885  * is good enough for all known systems.
 886  * (If your compiler itself needs names to be unique in less than 15 
 887  * characters, you are out of luck.  Get a better compiler.)
 888  */
 889 
 890 #ifdef NEED_SHORT_EXTERNAL_NAMES
 891 #define jpeg_std_error          jStdError
 892 #define jpeg_CreateCompress     jCreaCompress
 893 #define jpeg_CreateDecompress   jCreaDecompress
 894 #define jpeg_destroy_compress   jDestCompress
 895 #define jpeg_destroy_decompress jDestDecompress
 896 #define jpeg_stdio_dest         jStdDest
 897 #define jpeg_stdio_src          jStdSrc
 898 #define jpeg_mem_dest           jMemDest
 899 #define jpeg_mem_src            jMemSrc
 900 #define jpeg_set_defaults       jSetDefaults
 901 #define jpeg_set_colorspace     jSetColorspace
 902 #define jpeg_default_colorspace jDefColorspace
 903 #define jpeg_set_quality        jSetQuality
 904 #define jpeg_set_linear_quality jSetLQuality
 905 #define jpeg_default_qtables    jDefQTables
 906 #define jpeg_add_quant_table    jAddQuantTable
 907 #define jpeg_quality_scaling    jQualityScaling
 908 #define jpeg_simple_progression jSimProgress
 909 #define jpeg_suppress_tables    jSuppressTables
 910 #define jpeg_alloc_quant_table  jAlcQTable
 911 #define jpeg_alloc_huff_table   jAlcHTable
 912 #define jpeg_start_compress     jStrtCompress
 913 #define jpeg_write_scanlines    jWrtScanlines
 914 #define jpeg_finish_compress    jFinCompress
 915 #define jpeg_calc_jpeg_dimensions       jCjpegDimensions
 916 #define jpeg_write_raw_data     jWrtRawData
 917 #define jpeg_write_marker       jWrtMarker
 918 #define jpeg_write_m_header     jWrtMHeader
 919 #define jpeg_write_m_byte       jWrtMByte
 920 #define jpeg_write_tables       jWrtTables
 921 #define jpeg_read_header        jReadHeader
 922 #define jpeg_start_decompress   jStrtDecompress
 923 #define jpeg_read_scanlines     jReadScanlines
 924 #define jpeg_finish_decompress  jFinDecompress
 925 #define jpeg_read_raw_data      jReadRawData
 926 #define jpeg_has_multiple_scans jHasMultScn
 927 #define jpeg_start_output       jStrtOutput
 928 #define jpeg_finish_output      jFinOutput
 929 #define jpeg_input_complete     jInComplete
 930 #define jpeg_new_colormap       jNewCMap
 931 #define jpeg_consume_input      jConsumeInput
 932 #define jpeg_core_output_dimensions     jCoreDimensions
 933 #define jpeg_calc_output_dimensions     jCalcDimensions
 934 #define jpeg_save_markers       jSaveMarkers
 935 #define jpeg_set_marker_processor       jSetMarker
 936 #define jpeg_read_coefficients  jReadCoefs
 937 #define jpeg_write_coefficients jWrtCoefs
 938 #define jpeg_copy_critical_parameters   jCopyCrit
 939 #define jpeg_abort_compress     jAbrtCompress
 940 #define jpeg_abort_decompress   jAbrtDecompress
 941 #define jpeg_abort              jAbort
 942 #define jpeg_destroy            jDestroy
 943 #define jpeg_resync_to_restart  jResyncRestart
 944 #endif /* NEED_SHORT_EXTERNAL_NAMES */
 945 
 946 
 947 /* Default error-management setup */
 948 EXTERN(struct jpeg_error_mgr *) jpeg_std_error
 949         JPP((struct jpeg_error_mgr * err));
 950 
 951 /* Initialization of JPEG compression objects.
 952  * jpeg_create_compress() and jpeg_create_decompress() are the exported


 957  */
 958 #define jpeg_create_compress(cinfo) \
 959     jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \
 960                         (size_t) sizeof(struct jpeg_compress_struct))
 961 #define jpeg_create_decompress(cinfo) \
 962     jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \
 963                           (size_t) sizeof(struct jpeg_decompress_struct))
 964 EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo,
 965                                       int version, size_t structsize));
 966 EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo,
 967                                         int version, size_t structsize));
 968 /* Destruction of JPEG compression objects */
 969 EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo));
 970 EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo));
 971 
 972 /* Standard data source and destination managers: stdio streams. */
 973 /* Caller is responsible for opening the file before and closing after. */
 974 EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile));
 975 EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile));
 976 
 977 /* Data source and destination managers: memory buffers. */
 978 EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo,
 979                                unsigned char ** outbuffer,
 980                                unsigned long * outsize));
 981 EXTERN(void) jpeg_mem_src JPP((j_decompress_ptr cinfo,
 982                               const unsigned char * inbuffer,
 983                               unsigned long insize));
 984 
 985 /* Default parameter setup for compression */
 986 EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo));
 987 /* Compression parameter setup aids */
 988 EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo,
 989                                       J_COLOR_SPACE colorspace));
 990 EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo));
 991 EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality,
 992                                    boolean force_baseline));
 993 EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo,
 994                                           int scale_factor,
 995                                           boolean force_baseline));
 996 EXTERN(void) jpeg_default_qtables JPP((j_compress_ptr cinfo,
 997                                        boolean force_baseline));
 998 EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl,
 999                                        const unsigned int *basic_table,
1000                                        int scale_factor,
1001                                        boolean force_baseline));
1002 EXTERN(int) jpeg_quality_scaling JPP((int quality));
1003 EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo));
1004 EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo,


1059 EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo,
1060                                            JSAMPIMAGE data,
1061                                            JDIMENSION max_lines));
1062 
1063 /* Additional entry points for buffered-image mode. */
1064 EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo));
1065 EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo,
1066                                        int scan_number));
1067 EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo));
1068 EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo));
1069 EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo));
1070 EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo));
1071 /* Return value is one of: */
1072 /* #define JPEG_SUSPENDED       0    Suspended due to lack of input data */
1073 #define JPEG_REACHED_SOS        1 /* Reached start of new scan */
1074 #define JPEG_REACHED_EOI        2 /* Reached end of image */
1075 #define JPEG_ROW_COMPLETED      3 /* Completed one iMCU row */
1076 #define JPEG_SCAN_COMPLETED     4 /* Completed last iMCU row of a scan */
1077 
1078 /* Precalculate output dimensions for current decompression parameters. */
1079 EXTERN(void) jpeg_core_output_dimensions JPP((j_decompress_ptr cinfo));
1080 EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo));
1081 
1082 /* Control saving of COM and APPn markers into marker_list. */
1083 EXTERN(void) jpeg_save_markers
1084         JPP((j_decompress_ptr cinfo, int marker_code,
1085              unsigned int length_limit));
1086 
1087 /* Install a special processing method for COM or APPn markers. */
1088 EXTERN(void) jpeg_set_marker_processor
1089         JPP((j_decompress_ptr cinfo, int marker_code,
1090              jpeg_marker_parser_method routine));
1091 
1092 /* Read or write raw DCT coefficients --- useful for lossless transcoding. */
1093 EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo));
1094 EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo,
1095                                           jvirt_barray_ptr * coef_arrays));
1096 EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo,
1097                                                 j_compress_ptr dstinfo));
1098 
1099 /* If you choose to abort compression or decompression before completing


< prev index next >