00001 /* 00002 * jpeglib.h 00003 * 00004 * Copyright (C) 1991-1998, Thomas G. Lane. 00005 * This file is part of the Independent JPEG Group's software. 00006 * For conditions of distribution and use, see the accompanying README file. 00007 * Visit the website at: http://www.ijg.org/ 00008 * 00009 * This file defines the application interface for the JPEG library. 00010 * Most applications using the library need only include this file, 00011 * and perhaps jerror.h if they want to know the exact error codes. 00012 */ 00013 00014 #ifndef JPEGLIB_H 00015 #define JPEGLIB_H 00016 00017 00018 /* 00019 * First we include the configuration files that record how this 00020 * installation of the JPEG library is set up. jconfig.h can be 00021 * generated automatically for many systems. jmorecfg.h contains 00022 * manual configuration options that most people need not worry about. 00023 */ 00024 00025 #ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */ 00026 00027 #include <stdio.h> 00028 #include <stdlib.h> 00029 #include <iostream.h> 00030 #include <string.h> 00031 #include <stdarg.h> 00032 #include <math.h> 00033 #include <malloc.h> 00034 #include <string.h> 00035 #include <tchar.h> 00036 #include <windows.h> 00037 /* 00038 * jconfig.doc 00039 * 00040 * Copyright (C) 1991-1994, Thomas G. Lane. 00041 * This file is part of the Independent JPEG Group's software. 00042 * For conditions of distribution and use, see the accompanying README file. 00043 * 00044 * This file documents the configuration options that are required to 00045 * customize the JPEG software for a particular system. 00046 * 00047 * The actual configuration options for a particular installation are stored 00048 * in jconfig.h. On many machines, jconfig.h can be generated automatically 00049 * or copied from one of the "canned" jconfig files that we supply. But if 00050 * you need to generate a jconfig.h file by hand, this file tells you how. 00051 * 00052 * DO NOT EDIT THIS FILE --- IT WON'T ACCOMPLISH ANYTHING. 00053 * EDIT A COPY NAMED JCONFIG.H. 00054 */ 00055 00056 00057 /* 00058 * These symbols indicate the properties of your machine or compiler. 00059 * #define the symbol if yes, #undef it if no. 00060 */ 00061 00062 /* Does your compiler support function prototypes? 00063 * (If not, you also need to use ansi2knr, see install.doc) 00064 */ 00065 #define HAVE_PROTOTYPES 00066 00067 /* Does your compiler support the declaration "unsigned char" ? 00068 * How about "unsigned short" ? 00069 */ 00070 #define HAVE_UNSIGNED_CHAR 00071 #define HAVE_UNSIGNED_SHORT 00072 00073 /* Define "void" as "char" if your compiler doesn't know about type void. 00074 * NOTE: be sure to define void such that "void *" represents the most general 00075 * pointer type, e.g., that returned by malloc(). 00076 */ 00077 /* #define void char */ 00078 00079 /* Define "const" as empty if your compiler doesn't know the "const" keyword. 00080 */ 00081 /* #define const */ 00082 00083 /* Define this if an ordinary "char" type is unsigned. 00084 * If you're not sure, leaving it undefined will work at some cost in speed. 00085 * If you defined HAVE_UNSIGNED_CHAR then the speed difference is minimal. 00086 */ 00087 #undef CHAR_IS_UNSIGNED 00088 00089 /* Define this if your system has an ANSI-conforming <stddef.h> file. 00090 */ 00091 #define HAVE_STDDEF_H 00092 00093 /* Define this if your system has an ANSI-conforming <stdlib.h> file. 00094 */ 00095 #define HAVE_STDLIB_H 00096 00097 /* Define this if your system does not have an ANSI/SysV <string.h>, 00098 * but does have a BSD-style <strings.h>. 00099 */ 00100 #undef NEED_BSD_STRINGS 00101 00102 /* Define this if your system does not provide typedef size_t in any of the 00103 * ANSI-standard places (stddef.h, stdlib.h, or stdio.h), but places it in 00104 * <sys/types.h> instead. 00105 */ 00106 #undef NEED_SYS_TYPES_H 00107 00108 /* For 80x86 machines, you need to define NEED_FAR_POINTERS, 00109 * unless you are using a large-data memory model or 80386 flat-memory mode. 00110 * On less brain-damaged CPUs this symbol must not be defined. 00111 * (Defining this symbol causes large data structures to be referenced through 00112 * "far" pointers and to be allocated with a special version of malloc.) 00113 */ 00114 #undef NEED_FAR_POINTERS 00115 00116 /* Define this if your linker needs global names to be unique in less 00117 * than the first 15 characters. 00118 */ 00119 #undef NEED_SHORT_EXTERNAL_NAMES 00120 00121 /* Although a real ANSI C compiler can deal perfectly well with pointers to 00122 * unspecified structures (see "incomplete types" in the spec), a few pre-ANSI 00123 * and pseudo-ANSI compilers get confused. To keep one of these bozos happy, 00124 * define INCOMPLETE_TYPES_BROKEN. This is not recommended unless you 00125 * actually get "missing structure definition" warnings or errors while 00126 * compiling the JPEG code. 00127 */ 00128 #undef INCOMPLETE_TYPES_BROKEN 00129 00130 00131 /* 00132 * The following options affect code selection within the JPEG library, 00133 * but they don't need to be visible to applications using the library. 00134 * To minimize application namespace pollution, the symbols won't be 00135 * defined unless JPEG_INTERNALS has been defined. 00136 */ 00137 00138 #ifdef JPEG_INTERNALS 00139 00140 /* Define this if your compiler implements ">>" on signed values as a logical 00141 * (unsigned) shift; leave it undefined if ">>" is a signed (arithmetic) shift, 00142 * which is the normal and rational definition. 00143 */ 00144 #undef RIGHT_SHIFT_IS_UNSIGNED 00145 00146 00147 #endif /* JPEG_INTERNALS */ 00148 00149 00150 /* 00151 * The remaining options do not affect the JPEG library proper, 00152 * but only the sample applications cjpeg/djpeg (see cjpeg.c, djpeg.c). 00153 * Other applications can ignore these. 00154 */ 00155 00156 #ifdef JPEG_CJPEG_DJPEG 00157 00158 /* These defines indicate which image (non-JPEG) file formats are allowed. */ 00159 00160 #define BMP_SUPPORTED /* BMP image file format */ 00161 #define GIF_SUPPORTED /* GIF image file format */ 00162 #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ 00163 #undef RLE_SUPPORTED /* Utah RLE image file format */ 00164 #define TARGA_SUPPORTED /* Targa image file format */ 00165 00166 /* Define this if you want to name both input and output files on the command 00167 * line, rather than using stdout and optionally stdin. You MUST do this if 00168 * your system can't cope with binary I/O to stdin/stdout. See comments at 00169 * head of cjpeg.c or djpeg.c. 00170 */ 00171 #undef TWO_FILE_COMMANDLINE 00172 00173 /* Define this if your system needs explicit cleanup of temporary files. 00174 * This is crucial under MS-DOS, where the temporary "files" may be areas 00175 * of extended memory; on most other systems it's not as important. 00176 */ 00177 #undef NEED_SIGNAL_CATCHER 00178 00179 /* By default, we open image files with fopen(...,"rb") or fopen(...,"wb"). 00180 * This is necessary on systems that distinguish text files from binary files, 00181 * and is harmless on most systems that don't. If you have one of the rare 00182 * systems that complains about the "b" spec, define this symbol. 00183 */ 00184 #undef DONT_USE_B_MODE 00185 00186 /* Define this if you want percent-done progress reports from cjpeg/djpeg. 00187 */ 00188 #undef PROGRESS_REPORT 00189 00190 #define HAVE_BOOLEAN 00191 00192 #endif /* JPEG_CJPEG_DJPEG */ 00193 00194 #endif /* ifndef JCONFIG_INCLUDED */ 00195 00196 /* 00197 * Define BITS_IN_JSAMPLE as either 00198 * 8 for 8-bit sample values (the usual setting) 00199 * 12 for 12-bit sample values 00200 * Only 8 and 12 are legal data precisions for lossy JPEG according to the 00201 * JPEG standard, and the IJG code does not support anything else! 00202 * We do not support run-time selection of data precision, sorry. 00203 */ 00204 00205 #define BITS_IN_JSAMPLE 8 /* use 8 or 12 */ 00206 00207 00208 /* 00209 * Maximum number of components (color channels) allowed in JPEG image. 00210 * To meet the letter of the JPEG spec, set this to 255. However, darn 00211 * few applications need more than 4 channels (maybe 5 for CMYK + alpha 00212 * mask). We recommend 10 as a reasonable compromise; use 4 if you are 00213 * really short on memory. (Each allowed component costs a hundred or so 00214 * bytes of storage, whether actually used in an image or not.) 00215 */ 00216 00217 #define MAX_COMPONENTS 10 /* maximum number of image components */ 00218 00219 00220 /* 00221 * Basic data types. 00222 * You may need to change these if you have a machine with unusual data 00223 * type sizes; for example, "char" not 8 bits, "short" not 16 bits, 00224 * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, 00225 * but it had better be at least 16. 00226 */ 00227 00228 /* Representation of a single sample (pixel element value). 00229 * We frequently allocate large arrays of these, so it's important to keep 00230 * them small. But if you have memory to burn and access to char or short 00231 * arrays is very slow on your hardware, you might want to change these. 00232 */ 00233 00234 #if BITS_IN_JSAMPLE == 8 00235 /* JSAMPLE should be the smallest type that will hold the values 0..255. 00236 * You can use a signed char by having GETJSAMPLE mask it with 0xFF. 00237 */ 00238 00239 #ifdef HAVE_UNSIGNED_CHAR 00240 00241 typedef unsigned char JSAMPLE; 00242 #define GETJSAMPLE(value) ((int) (value)) 00243 00244 #else /* not HAVE_UNSIGNED_CHAR */ 00245 00246 typedef char JSAMPLE; 00247 #ifdef CHAR_IS_UNSIGNED 00248 #define GETJSAMPLE(value) ((int) (value)) 00249 #else 00250 #define GETJSAMPLE(value) ((int) (value) & 0xFF) 00251 #endif /* CHAR_IS_UNSIGNED */ 00252 00253 #endif /* HAVE_UNSIGNED_CHAR */ 00254 00255 #define MAXJSAMPLE 255 00256 #define CENTERJSAMPLE 128 00257 00258 #endif /* BITS_IN_JSAMPLE == 8 */ 00259 00260 00261 #if BITS_IN_JSAMPLE == 12 00262 /* JSAMPLE should be the smallest type that will hold the values 0..4095. 00263 * On nearly all machines "short" will do nicely. 00264 */ 00265 00266 typedef short JSAMPLE; 00267 #define GETJSAMPLE(value) ((int) (value)) 00268 00269 #define MAXJSAMPLE 4095 00270 #define CENTERJSAMPLE 2048 00271 00272 #endif /* BITS_IN_JSAMPLE == 12 */ 00273 00274 00275 /* Representation of a DCT frequency coefficient. 00276 * This should be a signed value of at least 16 bits; "short" is usually OK. 00277 * Again, we allocate large arrays of these, but you can change to int 00278 * if you have memory to burn and "short" is really slow. 00279 */ 00280 00281 typedef short JCOEF; 00282 00283 00284 /* Compressed datastreams are represented as arrays of JOCTET. 00285 * These must be EXACTLY 8 bits wide, at least once they are written to 00286 * external storage. Note that when using the stdio data source/destination 00287 * managers, this is also the data type passed to fread/fwrite. 00288 */ 00289 00290 #ifdef HAVE_UNSIGNED_CHAR 00291 00292 typedef unsigned char JOCTET; 00293 #define GETJOCTET(value) (value) 00294 00295 #else /* not HAVE_UNSIGNED_CHAR */ 00296 00297 typedef char JOCTET; 00298 #ifdef CHAR_IS_UNSIGNED 00299 #define GETJOCTET(value) (value) 00300 #else 00301 #define GETJOCTET(value) ((value) & 0xFF) 00302 #endif /* CHAR_IS_UNSIGNED */ 00303 00304 #endif /* HAVE_UNSIGNED_CHAR */ 00305 00306 00307 /* These typedefs are used for various table entries and so forth. 00308 * They must be at least as wide as specified; but making them too big 00309 * won't cost a huge amount of memory, so we don't provide special 00310 * extraction code like we did for JSAMPLE. (In other words, these 00311 * typedefs live at a different point on the speed/space tradeoff curve.) 00312 */ 00313 00314 /* UINT8 must hold at least the values 0..255. */ 00315 00316 #ifdef HAVE_UNSIGNED_CHAR 00317 typedef unsigned char UINT8; 00318 #else /* not HAVE_UNSIGNED_CHAR */ 00319 #ifdef CHAR_IS_UNSIGNED 00320 typedef char UINT8; 00321 #else /* not CHAR_IS_UNSIGNED */ 00322 typedef short UINT8; 00323 #endif /* CHAR_IS_UNSIGNED */ 00324 #endif /* HAVE_UNSIGNED_CHAR */ 00325 00326 /* UINT16 must hold at least the values 0..65535. */ 00327 00328 #ifdef HAVE_UNSIGNED_SHORT 00329 typedef unsigned short UINT16; 00330 #else /* not HAVE_UNSIGNED_SHORT */ 00331 typedef unsigned int UINT16; 00332 #endif /* HAVE_UNSIGNED_SHORT */ 00333 00334 /* INT16 must hold at least the values -32768..32767. */ 00335 00336 #ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ 00337 typedef short INT16; 00338 #endif 00339 00340 /* INT32 must hold at least signed 32-bit values. */ 00341 00342 #ifdef NEED_INT32 /* X11/xmd.h correctly defines INT32 */ 00343 typedef long INT32; 00344 #endif 00345 00346 /* Datatype used for image dimensions. The JPEG standard only supports 00347 * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore 00348 * "unsigned int" is sufficient on all machines. However, if you need to 00349 * handle larger images and you don't mind deviating from the spec, you 00350 * can change this datatype. 00351 */ 00352 00353 typedef unsigned int JDIMENSION; 00354 00355 #define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ 00356 00357 00358 /* These macros are used in all function definitions and extern declarations. 00359 * You could modify them if you need to change function linkage conventions; 00360 * in particular, you'll need to do that to make the library a Windows DLL. 00361 * Another application is to make all functions global for use with debuggers 00362 * or code profilers that require it. 00363 */ 00364 00365 /* a function called through method pointers: */ 00366 #define METHODDEF(type) static type 00367 /* a function used only in its module: */ 00368 #define LOCAL(type) static type 00369 /* a function referenced thru EXTERNs: */ 00370 #define GLOBAL(type) type 00371 /* a reference to a GLOBAL function: */ 00372 #define EXTERN(type) extern type 00373 00374 00375 /* This macro is used to declare a "method", that is, a function pointer. 00376 * We want to supply prototype parameters if the compiler can cope. 00377 * Note that the arglist parameter must be parenthesized! 00378 * Again, you can customize this if you need special linkage keywords. 00379 */ 00380 00381 #ifdef HAVE_PROTOTYPES 00382 #define JMETHOD(type,methodname,arglist) type (*methodname) arglist 00383 #else 00384 #define JMETHOD(type,methodname,arglist) type (*methodname) () 00385 #endif 00386 00387 00388 /* Here is the pseudo-keyword for declaring pointers that must be "far" 00389 * on 80x86 machines. Most of the specialized coding for 80x86 is handled 00390 * by just saying "FAR *" where such a pointer is needed. In a few places 00391 * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. 00392 */ 00393 00394 #ifdef NEED_FAR_POINTERS 00395 #define FAR far 00396 #else 00397 //#define FAR 00398 #endif 00399 00400 00401 /* 00402 * On a few systems, type boolean and/or its values FALSE, TRUE may appear 00403 * in standard header files. Or you may have conflicts with application- 00404 * specific header files that you want to include together with these files. 00405 * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. 00406 */ 00407 00408 #ifndef HAVE_BOOLEAN 00409 //typedef int boolean; 00410 #endif 00411 #ifndef FALSE /* in case these macros already exist */ 00412 #define FALSE 0 /* values of boolean */ 00413 #endif 00414 #ifndef TRUE 00415 #define TRUE 1 00416 #endif 00417 00418 00419 /* 00420 * The remaining options affect code selection within the JPEG library, 00421 * but they don't need to be visible to most applications using the library. 00422 * To minimize application namespace pollution, the symbols won't be 00423 * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. 00424 */ 00425 00426 #ifdef JPEG_INTERNALS 00427 #define JPEG_INTERNAL_OPTIONS 00428 #endif 00429 00430 #ifdef JPEG_INTERNAL_OPTIONS 00431 00432 00433 /* 00434 * These defines indicate whether to include various optional functions. 00435 * Undefining some of these symbols will produce a smaller but less capable 00436 * library. Note that you can leave certain source files out of the 00437 * compilation/linking process if you've #undef'd the corresponding symbols. 00438 * (You may HAVE to do that if your compiler doesn't like null source files.) 00439 */ 00440 00441 /* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */ 00442 00443 /* Capability options common to encoder and decoder: */ 00444 00445 #define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ 00446 #define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ 00447 #define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ 00448 00449 /* Encoder capability options: */ 00450 00451 #undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ 00452 #define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ 00453 #define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ 00454 #define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ 00455 /* Note: if you selected 12-bit data precision, it is dangerous to turn off 00456 * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit 00457 * precision, so jchuff.c normally uses entropy optimization to compute 00458 * usable tables for higher precision. If you don't want to do optimization, 00459 * you'll have to supply different default Huffman tables. 00460 * The exact same statements apply for progressive JPEG: the default tables 00461 * don't work for progressive mode. (This may get fixed, however.) 00462 */ 00463 #define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ 00464 00465 /* Decoder capability options: */ 00466 00467 #undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ 00468 #define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ 00469 #define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ 00470 #define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ 00471 #define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ 00472 #define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ 00473 #undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ 00474 #define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ 00475 #define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ 00476 #define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ 00477 00478 /* more capability options later, no doubt */ 00479 00480 00481 /* 00482 * Ordering of RGB data in scanlines passed to or from the application. 00483 * If your application wants to deal with data in the order B,G,R, just 00484 * change these macros. You can also deal with formats such as R,G,B,X 00485 * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing 00486 * the offsets will also change the order in which colormap data is organized. 00487 * RESTRICTIONS: 00488 * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. 00489 * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not 00490 * useful if you are using JPEG color spaces other than YCbCr or grayscale. 00491 * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE 00492 * is not 3 (they don't understand about dummy color components!). So you 00493 * can't use color quantization if you change that value. 00494 */ 00495 00496 #define RGB_RED 0 /* Offset of Red in an RGB scanline element */ 00497 #define RGB_GREEN 1 /* Offset of Green */ 00498 #define RGB_BLUE 2 /* Offset of Blue */ 00499 #define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ 00500 00501 00502 /* Definitions for speed-related optimizations. */ 00503 00504 00505 /* If your compiler supports inline functions, define INLINE 00506 * as the inline keyword; otherwise define it as empty. 00507 */ 00508 00509 #ifndef INLINE 00510 #ifdef __GNUC__ /* for instance, GNU C knows about inline */ 00511 #define INLINE __inline__ 00512 #endif 00513 #ifndef INLINE 00514 #define INLINE /* default is to define it as empty */ 00515 #endif 00516 #endif 00517 00518 00519 /* On some machines (notably 68000 series) "int" is 32 bits, but multiplying 00520 * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER 00521 * as short on such a machine. MULTIPLIER must be at least 16 bits wide. 00522 */ 00523 00524 #ifndef MULTIPLIER 00525 #define MULTIPLIER int /* type for fastest integer multiply */ 00526 #endif 00527 00528 00529 /* FAST_FLOAT should be either float or double, whichever is done faster 00530 * by your compiler. (Note that this type is only used in the floating point 00531 * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) 00532 * Typically, float is faster in ANSI C compilers, while double is faster in 00533 * pre-ANSI compilers (because they insist on converting to double anyway). 00534 * The code below therefore chooses float if we have ANSI-style prototypes. 00535 */ 00536 00537 #ifndef FAST_FLOAT 00538 #ifdef HAVE_PROTOTYPES 00539 #define FAST_FLOAT float 00540 #else 00541 #define FAST_FLOAT double 00542 #endif 00543 #endif 00544 00545 #endif /* JPEG_INTERNAL_OPTIONS */ 00546 00547 00548 #if defined(__cplusplus) 00549 extern "C" { 00550 #endif 00551 00552 00553 /* Version ID for the JPEG library. 00554 * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". 00555 */ 00556 00557 #define JPEG_LIB_VERSION 62 /* Version 6b */ 00558 00559 00560 /* Various constants determining the sizes of things. 00561 * All of these are specified by the JPEG standard, so don't change them 00562 * if you want to be compatible. 00563 */ 00564 00565 #define DCTSIZE 8 /* The basic DCT block is 8x8 samples */ 00566 #define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */ 00567 #define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */ 00568 #define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */ 00569 #define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */ 00570 #define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */ 00571 #define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */ 00572 /* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard; 00573 * the PostScript DCT filter can emit files with many more than 10 blocks/MCU. 00574 * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU 00575 * to handle it. We even let you do this from the jconfig.h file. However, 00576 * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe 00577 * sometimes emits noncompliant files doesn't mean you should too. 00578 */ 00579 #define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */ 00580 #ifndef D_MAX_BLOCKS_IN_MCU 00581 #define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */ 00582 #endif 00583 00584 00585 /* Data structures for images (arrays of samples and of DCT coefficients). 00586 * On 80x86 machines, the image arrays are too big for near pointers, 00587 * but the pointer arrays can fit in near memory. 00588 */ 00589 00590 typedef JSAMPLE FAR *JSAMPROW; /* ptr to one image row of pixel samples. */ 00591 typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */ 00592 typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */ 00593 00594 typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */ 00595 typedef JBLOCK FAR *JBLOCKROW; /* pointer to one row of coefficient blocks */ 00596 typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */ 00597 typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */ 00598 00599 typedef JCOEF FAR *JCOEFPTR; /* useful in a couple of places */ 00600 00601 00602 /* Types for JPEG compression parameters and working tables. */ 00603 00604 00605 /* DCT coefficient quantization tables. */ 00606 00607 typedef struct { 00608 /* This array gives the coefficient quantizers in natural array order 00609 * (not the zigzag order in which they are stored in a JPEG DQT marker). 00610 * CAUTION: IJG versions prior to v6a kept this array in zigzag order. 00611 */ 00612 UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */ 00613 /* This field is used only during compression. It's initialized FALSE when 00614 * the table is created, and set TRUE when it's been output to the file. 00615 * You could suppress output of a table by setting this to TRUE. 00616 * (See jpeg_suppress_tables for an example.) 00617 */ 00618 boolean sent_table; /* TRUE when table has been output */ 00619 } JQUANT_TBL; 00620 00621 00622 /* Huffman coding tables. */ 00623 00624 typedef struct { 00625 /* These two fields directly represent the contents of a JPEG DHT marker */ 00626 UINT8 bits[17]; /* bits[k] = # of symbols with codes of */ 00627 /* length k bits; bits[0] is unused */ 00628 UINT8 huffval[256]; /* The symbols, in order of incr code length */ 00629 /* This field is used only during compression. It's initialized FALSE when 00630 * the table is created, and set TRUE when it's been output to the file. 00631 * You could suppress output of a table by setting this to TRUE. 00632 * (See jpeg_suppress_tables for an example.) 00633 */ 00634 boolean sent_table; /* TRUE when table has been output */ 00635 } JHUFF_TBL; 00636 00637 00638 /* Basic info about one component (color channel). */ 00639 00640 typedef struct { 00641 /* These values are fixed over the whole image. */ 00642 /* For compression, they must be supplied by parameter setup; */ 00643 /* for decompression, they are read from the SOF marker. */ 00644 int component_id; /* identifier for this component (0..255) */ 00645 int component_index; /* its index in SOF or cinfo->comp_info[] */ 00646 int h_samp_factor; /* horizontal sampling factor (1..4) */ 00647 int v_samp_factor; /* vertical sampling factor (1..4) */ 00648 int quant_tbl_no; /* quantization table selector (0..3) */ 00649 /* These values may vary between scans. */ 00650 /* For compression, they must be supplied by parameter setup; */ 00651 /* for decompression, they are read from the SOS marker. */ 00652 /* The decompressor output side may not use these variables. */ 00653 int dc_tbl_no; /* DC entropy table selector (0..3) */ 00654 int ac_tbl_no; /* AC entropy table selector (0..3) */ 00655 00656 /* Remaining fields should be treated as private by applications. */ 00657 00658 /* These values are computed during compression or decompression startup: */ 00659 /* Component's size in DCT blocks. 00660 * Any dummy blocks added to complete an MCU are not counted; therefore 00661 * these values do not depend on whether a scan is interleaved or not. 00662 */ 00663 JDIMENSION width_in_blocks; 00664 JDIMENSION height_in_blocks; 00665 /* Size of a DCT block in samples. Always DCTSIZE for compression. 00666 * For decompression this is the size of the output from one DCT block, 00667 * reflecting any scaling we choose to apply during the IDCT step. 00668 * Values of 1,2,4,8 are likely to be supported. Note that different 00669 * components may receive different IDCT scalings. 00670 */ 00671 int DCT_scaled_size; 00672 /* The downsampled dimensions are the component's actual, unpadded number 00673 * of samples at the main buffer (preprocessing/compression interface), thus 00674 * downsampled_width = ceil(image_width * Hi/Hmax) 00675 * and similarly for height. For decompression, IDCT scaling is included, so 00676 * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE) 00677 */ 00678 JDIMENSION downsampled_width; /* actual width in samples */ 00679 JDIMENSION downsampled_height; /* actual height in samples */ 00680 /* This flag is used only for decompression. In cases where some of the 00681 * components will be ignored (eg grayscale output from YCbCr image), 00682 * we can skip most computations for the unused components. 00683 */ 00684 boolean component_needed; /* do we need the value of this component? */ 00685 00686 /* These values are computed before starting a scan of the component. */ 00687 /* The decompressor output side may not use these variables. */ 00688 int MCU_width; /* number of blocks per MCU, horizontally */ 00689 int MCU_height; /* number of blocks per MCU, vertically */ 00690 int MCU_blocks; /* MCU_width * MCU_height */ 00691 int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_scaled_size */ 00692 int last_col_width; /* # of non-dummy blocks across in last MCU */ 00693 int last_row_height; /* # of non-dummy blocks down in last MCU */ 00694 00695 /* Saved quantization table for component; NULL if none yet saved. 00696 * See jdinput.c comments about the need for this information. 00697 * This field is currently used only for decompression. 00698 */ 00699 JQUANT_TBL * quant_table; 00700 00701 /* Private per-component storage for DCT or IDCT subsystem. */ 00702 void * dct_table; 00703 } jpeg_component_info; 00704 00705 00706 /* The script for encoding a multiple-scan file is an array of these: */ 00707 00708 typedef struct { 00709 int comps_in_scan; /* number of components encoded in this scan */ 00710 int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */ 00711 int Ss, Se; /* progressive JPEG spectral selection parms */ 00712 int Ah, Al; /* progressive JPEG successive approx. parms */ 00713 } jpeg_scan_info; 00714 00715 /* The decompressor can save APPn and COM markers in a list of these: */ 00716 00717 typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr; 00718 00719 struct jpeg_marker_struct { 00720 jpeg_saved_marker_ptr next; /* next in list, or NULL */ 00721 UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */ 00722 unsigned int original_length; /* # bytes of data in the file */ 00723 unsigned int data_length; /* # bytes of data saved at data[] */ 00724 JOCTET FAR * data; /* the data contained in the marker */ 00725 /* the marker length word is not counted in data_length or original_length */ 00726 }; 00727 00728 /* Known color spaces. */ 00729 00730 typedef enum { 00731 JCS_UNKNOWN, /* error/unspecified */ 00732 JCS_GRAYSCALE, /* monochrome */ 00733 JCS_RGB, /* red/green/blue */ 00734 JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */ 00735 JCS_CMYK, /* C/M/Y/K */ 00736 JCS_YCCK /* Y/Cb/Cr/K */ 00737 } J_COLOR_SPACE; 00738 00739 /* DCT/IDCT algorithm options. */ 00740 00741 typedef enum { 00742 JDCT_ISLOW, /* slow but accurate integer algorithm */ 00743 JDCT_IFAST, /* faster, less accurate integer method */ 00744 JDCT_FLOAT /* floating-point: accurate, fast on fast HW */ 00745 } J_DCT_METHOD; 00746 00747 #ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */ 00748 #define JDCT_DEFAULT JDCT_ISLOW 00749 #endif 00750 #ifndef JDCT_FASTEST /* may be overridden in jconfig.h */ 00751 #define JDCT_FASTEST JDCT_IFAST 00752 #endif 00753 00754 /* Dithering options for decompression. */ 00755 00756 typedef enum { 00757 JDITHER_NONE, /* no dithering */ 00758 JDITHER_ORDERED, /* simple ordered dither */ 00759 JDITHER_FS /* Floyd-Steinberg error diffusion dither */ 00760 } J_DITHER_MODE; 00761 00762 00763 /* Common fields between JPEG compression and decompression master structs. */ 00764 00765 #define jpeg_common_fields \ 00766 struct jpeg_error_mgr * err; /* Error handler module */\ 00767 struct jpeg_memory_mgr * mem; /* Memory manager module */\ 00768 struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\ 00769 void * client_data; /* Available for use by application */\ 00770 boolean is_decompressor; /* So common code can tell which is which */\ 00771 int global_state /* For checking call sequence validity */ 00772 00773 /* Routines that are to be used by both halves of the library are declared 00774 * to receive a pointer to this structure. There are no actual instances of 00775 * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct. 00776 */ 00777 struct jpeg_common_struct { 00778 jpeg_common_fields; /* Fields common to both master struct types */ 00779 /* Additional fields follow in an actual jpeg_compress_struct or 00780 * jpeg_decompress_struct. All three structs must agree on these 00781 * initial fields! (This would be a lot cleaner in C++.) 00782 */ 00783 }; 00784 00785 typedef struct jpeg_common_struct * j_common_ptr; 00786 typedef struct jpeg_compress_struct * j_compress_ptr; 00787 typedef struct jpeg_decompress_struct * j_decompress_ptr; 00788 00789 00790 /* Master record for a compression instance */ 00791 00792 struct jpeg_compress_struct 00793 { 00794 jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */ 00795 00796 /* Destination for compressed data */ 00797 struct jpeg_destination_mgr * dest; 00798 00799 /* Description of source image --- these fields must be filled in by 00800 * outer application before starting compression. in_color_space must 00801 * be correct before you can even call jpeg_set_defaults(). 00802 */ 00803 00804 JDIMENSION image_width; /* input image width */ 00805 JDIMENSION image_height; /* input image height */ 00806 int input_components; /* # of color components in input image */ 00807 J_COLOR_SPACE in_color_space; /* colorspace of input image */ 00808 00809 double input_gamma; /* image gamma of input image */ 00810 00811 /* Compression parameters --- these fields must be set before calling 00812 * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to 00813 * initialize everything to reasonable defaults, then changing anything 00814 * the application specifically wants to change. That way you won't get 00815 * burnt when new parameters are added. Also note that there are several 00816 * helper routines to simplify changing parameters. 00817 */ 00818 00819 int data_precision; /* bits of precision in image data */ 00820 00821 int num_components; /* # of color components in JPEG image */ 00822 J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ 00823 00824 jpeg_component_info * comp_info; 00825 /* comp_info[i] describes component that appears i'th in SOF */ 00826 00827 JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; 00828 /* ptrs to coefficient quantization tables, or NULL if not defined */ 00829 00830 JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; 00831 JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; 00832 /* ptrs to Huffman coding tables, or NULL if not defined */ 00833 00834 UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ 00835 UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ 00836 UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ 00837 00838 int num_scans; /* # of entries in scan_info array */ 00839 const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */ 00840 /* The default value of scan_info is NULL, which causes a single-scan 00841 * sequential JPEG file to be emitted. To create a multi-scan file, 00842 * set num_scans and scan_info to point to an array of scan definitions. 00843 */ 00844 00845 boolean raw_data_in; /* TRUE=caller supplies downsampled data */ 00846 boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ 00847 boolean optimize_coding; /* TRUE=optimize entropy encoding parms */ 00848 boolean CCIR601_sampling; /* TRUE=first samples are cosited */ 00849 int smoothing_factor; /* 1..100, or 0 for no input smoothing */ 00850 J_DCT_METHOD dct_method; /* DCT algorithm selector */ 00851 00852 /* The restart interval can be specified in absolute MCUs by setting 00853 * restart_interval, or in MCU rows by setting restart_in_rows 00854 * (in which case the correct restart_interval will be figured 00855 * for each scan). 00856 */ 00857 unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */ 00858 int restart_in_rows; /* if > 0, MCU rows per restart interval */ 00859 00860 /* Parameters controlling emission of special markers. */ 00861 00862 boolean write_JFIF_header; /* should a JFIF marker be written? */ 00863 UINT8 JFIF_major_version; /* What to write for the JFIF version number */ 00864 UINT8 JFIF_minor_version; 00865 /* These three values are not used by the JPEG code, merely copied */ 00866 /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */ 00867 /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */ 00868 /* ratio is defined by X_density/Y_density even when density_unit=0. */ 00869 UINT8 density_unit; /* JFIF code for pixel size units */ 00870 UINT16 X_density; /* Horizontal pixel density */ 00871 UINT16 Y_density; /* Vertical pixel density */ 00872 boolean write_Adobe_marker; /* should an Adobe marker be written? */ 00873 00874 /* State variable: index of next scanline to be written to 00875 * jpeg_write_scanlines(). Application may use this to control its 00876 * processing loop, e.g., "while (next_scanline < image_height)". 00877 */ 00878 00879 JDIMENSION next_scanline; /* 0 .. image_height-1 */ 00880 00881 /* Remaining fields are known throughout compressor, but generally 00882 * should not be touched by a surrounding application. 00883 */ 00884 00885 /* 00886 * These fields are computed during compression startup 00887 */ 00888 boolean progressive_mode; /* TRUE if scan script uses progressive mode */ 00889 int max_h_samp_factor; /* largest h_samp_factor */ 00890 int max_v_samp_factor; /* largest v_samp_factor */ 00891 00892 JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */ 00893 /* The coefficient controller receives data in units of MCU rows as defined 00894 * for fully interleaved scans (whether the JPEG file is interleaved or not). 00895 * There are v_samp_factor * DCTSIZE sample rows of each component in an 00896 * "iMCU" (interleaved MCU) row. 00897 */ 00898 00899 /* 00900 * These fields are valid during any one scan. 00901 * They describe the components and MCUs actually appearing in the scan. 00902 */ 00903 int comps_in_scan; /* # of JPEG components in this scan */ 00904 jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; 00905 /* *cur_comp_info[i] describes component that appears i'th in SOS */ 00906 00907 JDIMENSION MCUs_per_row; /* # of MCUs across the image */ 00908 JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ 00909 00910 int blocks_in_MCU; /* # of DCT blocks per MCU */ 00911 int MCU_membership[C_MAX_BLOCKS_IN_MCU]; 00912 /* MCU_membership[i] is index in cur_comp_info of component owning */ 00913 /* i'th block in an MCU */ 00914 00915 int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ 00916 00917 /* 00918 * Links to compression subobjects (methods and private variables of modules) 00919 */ 00920 struct jpeg_comp_master * master; 00921 struct jpeg_c_main_controller * main; 00922 struct jpeg_c_prep_controller * prep; 00923 struct jpeg_c_coef_controller * coef; 00924 struct jpeg_marker_writer * marker; 00925 struct jpeg_color_converter * cconvert; 00926 struct jpeg_downsampler * downsample; 00927 struct jpeg_forward_dct * fdct; 00928 struct jpeg_entropy_encoder * entropy; 00929 jpeg_scan_info * script_space; /* workspace for jpeg_simple_progression */ 00930 int script_space_size; 00931 }; 00932 00933 00934 /* Master record for a decompression instance */ 00935 00936 struct jpeg_decompress_struct 00937 { 00938 jpeg_common_fields; /* Fields shared with jpeg_compress_struct */ 00939 00940 /* Source of compressed data */ 00941 struct jpeg_source_mgr * src; 00942 00943 /* Basic description of image --- filled in by jpeg_read_header(). */ 00944 /* Application may inspect these values to decide how to process image. */ 00945 00946 JDIMENSION image_width; /* nominal image width (from SOF marker) */ 00947 JDIMENSION image_height; /* nominal image height */ 00948 int num_components; /* # of color components in JPEG image */ 00949 J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ 00950 00951 /* Decompression processing parameters --- these fields must be set before 00952 * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes 00953 * them to default values. 00954 */ 00955 00956 J_COLOR_SPACE out_color_space; /* colorspace for output */ 00957 00958 unsigned int scale_num, scale_denom; /* fraction by which to scale image */ 00959 00960 double output_gamma; /* image gamma wanted in output */ 00961 00962 boolean buffered_image; /* TRUE=multiple output passes */ 00963 boolean raw_data_out; /* TRUE=downsampled data wanted */ 00964 00965 J_DCT_METHOD dct_method; /* IDCT algorithm selector */ 00966 boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */ 00967 boolean do_block_smoothing; /* TRUE=apply interblock smoothing */ 00968 00969 boolean quantize_colors; /* TRUE=colormapped output wanted */ 00970 /* the following are ignored if not quantize_colors: */ 00971 J_DITHER_MODE dither_mode; /* type of color dithering to use */ 00972 boolean two_pass_quantize; /* TRUE=use two-pass color quantization */ 00973 int desired_number_of_colors; /* max # colors to use in created colormap */ 00974 /* these are significant only in buffered-image mode: */ 00975 boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */ 00976 boolean enable_external_quant;/* enable future use of external colormap */ 00977 boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */ 00978 00979 /* Description of actual output image that will be returned to application. 00980 * These fields are computed by jpeg_start_decompress(). 00981 * You can also use jpeg_calc_output_dimensions() to determine these values 00982 * in advance of calling jpeg_start_decompress(). 00983 */ 00984 00985 JDIMENSION output_width; /* scaled image width */ 00986 JDIMENSION output_height; /* scaled image height */ 00987 int out_color_components; /* # of color components in out_color_space */ 00988 int output_components; /* # of color components returned */ 00989 /* output_components is 1 (a colormap index) when quantizing colors; 00990 * otherwise it equals out_color_components. 00991 */ 00992 int rec_outbuf_height; /* min recommended height of scanline buffer */ 00993 /* If the buffer passed to jpeg_read_scanlines() is less than this many rows 00994 * high, space and time will be wasted due to unnecessary data copying. 00995 * Usually rec_outbuf_height will be 1 or 2, at most 4. 00996 */ 00997 00998 /* When quantizing colors, the output colormap is described by these fields. 00999 * The application can supply a colormap by setting colormap non-NULL before 01000 * calling jpeg_start_decompress; otherwise a colormap is created during 01001 * jpeg_start_decompress or jpeg_start_output. 01002 * The map has out_color_components rows and actual_number_of_colors columns. 01003 */ 01004 int actual_number_of_colors; /* number of entries in use */ 01005 JSAMPARRAY colormap; /* The color map as a 2-D pixel array */ 01006 01007 /* State variables: these variables indicate the progress of decompression. 01008 * The application may examine these but must not modify them. 01009 */ 01010 01011 /* Row index of next scanline to be read from jpeg_read_scanlines(). 01012 * Application may use this to control its processing loop, e.g., 01013 * "while (output_scanline < output_height)". 01014 */ 01015 JDIMENSION output_scanline; /* 0 .. output_height-1 */ 01016 01017 /* Current input scan number and number of iMCU rows completed in scan. 01018 * These indicate the progress of the decompressor input side. 01019 */ 01020 int input_scan_number; /* Number of SOS markers seen so far */ 01021 JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */ 01022 01023 /* The "output scan number" is the notional scan being displayed by the 01024 * output side. The decompressor will not allow output scan/row number 01025 * to get ahead of input scan/row, but it can fall arbitrarily far behind. 01026 */ 01027 int output_scan_number; /* Nominal scan number being displayed */ 01028 JDIMENSION output_iMCU_row; /* Number of iMCU rows read */ 01029 01030 /* Current progression status. coef_bits[c][i] indicates the precision 01031 * with which component c's DCT coefficient i (in zigzag order) is known. 01032 * It is -1 when no data has yet been received, otherwise it is the point 01033 * transform (shift) value for the most recent scan of the coefficient 01034 * (thus, 0 at completion of the progression). 01035 * This pointer is NULL when reading a non-progressive file. 01036 */ 01037 int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */ 01038 01039 /* Internal JPEG parameters --- the application usually need not look at 01040 * these fields. Note that the decompressor output side may not use 01041 * any parameters that can change between scans. 01042 */ 01043 01044 /* Quantization and Huffman tables are carried forward across input 01045 * datastreams when processing abbreviated JPEG datastreams. 01046 */ 01047 01048 JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; 01049 /* ptrs to coefficient quantization tables, or NULL if not defined */ 01050 01051 JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; 01052 JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; 01053 /* ptrs to Huffman coding tables, or NULL if not defined */ 01054 01055 /* These parameters are never carried across datastreams, since they 01056 * are given in SOF/SOS markers or defined to be reset by SOI. 01057 */ 01058 01059 int data_precision; /* bits of precision in image data */ 01060 01061 jpeg_component_info * comp_info; 01062 /* comp_info[i] describes component that appears i'th in SOF */ 01063 01064 boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */ 01065 boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ 01066 01067 UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ 01068 UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ 01069 UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ 01070 01071 unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */ 01072 01073 /* These fields record data obtained from optional markers recognized by 01074 * the JPEG library. 01075 */ 01076 boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */ 01077 /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */ 01078 UINT8 JFIF_major_version; /* JFIF version number */ 01079 UINT8 JFIF_minor_version; 01080 UINT8 density_unit; /* JFIF code for pixel size units */ 01081 UINT16 X_density; /* Horizontal pixel density */ 01082 UINT16 Y_density; /* Vertical pixel density */ 01083 boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */ 01084 UINT8 Adobe_transform; /* Color transform code from Adobe marker */ 01085 01086 boolean CCIR601_sampling; /* TRUE=first samples are cosited */ 01087 01088 /* Aside from the specific data retained from APPn markers known to the 01089 * library, the uninterpreted contents of any or all APPn and COM markers 01090 * can be saved in a list for examination by the application. 01091 */ 01092 jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */ 01093 01094 /* Remaining fields are known throughout decompressor, but generally 01095 * should not be touched by a surrounding application. 01096 */ 01097 01098 /* 01099 * These fields are computed during decompression startup 01100 */ 01101 int max_h_samp_factor; /* largest h_samp_factor */ 01102 int max_v_samp_factor; /* largest v_samp_factor */ 01103 01104 int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */ 01105 01106 JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */ 01107 /* The coefficient controller's input and output progress is measured in 01108 * units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows 01109 * in fully interleaved JPEG scans, but are used whether the scan is 01110 * interleaved or not. We define an iMCU row as v_samp_factor DCT block 01111 * rows of each component. Therefore, the IDCT output contains 01112 * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row. 01113 */ 01114 01115 JSAMPLE * sample_range_limit; /* table for fast range-limiting */ 01116 01117 /* 01118 * These fields are valid during any one scan. 01119 * They describe the components and MCUs actually appearing in the scan. 01120 * Note that the decompressor output side must not use these fields. 01121 */ 01122 int comps_in_scan; /* # of JPEG components in this scan */ 01123 jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; 01124 /* *cur_comp_info[i] describes component that appears i'th in SOS */ 01125 01126 JDIMENSION MCUs_per_row; /* # of MCUs across the image */ 01127 JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ 01128 01129 int blocks_in_MCU; /* # of DCT blocks per MCU */ 01130 int MCU_membership[D_MAX_BLOCKS_IN_MCU]; 01131 /* MCU_membership[i] is index in cur_comp_info of component owning */ 01132 /* i'th block in an MCU */ 01133 01134 int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ 01135 01136 /* This field is shared between entropy decoder and marker parser. 01137 * It is either zero or the code of a JPEG marker that has been 01138 * read from the data source, but has not yet been processed. 01139 */ 01140 int unread_marker; 01141 01142 /* 01143 * Links to decompression subobjects (methods, private variables of modules) 01144 */ 01145 struct jpeg_decomp_master * master; 01146 struct jpeg_d_main_controller * main; 01147 struct jpeg_d_coef_controller * coef; 01148 struct jpeg_d_post_controller * post; 01149 struct jpeg_input_controller * inputctl; 01150 struct jpeg_marker_reader * marker; 01151 struct jpeg_entropy_decoder * entropy; 01152 struct jpeg_inverse_dct * idct; 01153 struct jpeg_upsampler * upsample; 01154 struct jpeg_color_deconverter * cconvert; 01155 struct jpeg_color_quantizer * cquantize; 01156 }; 01157 01158 01159 /* "Object" declarations for JPEG modules that may be supplied or called 01160 * directly by the surrounding application. 01161 * As with all objects in the JPEG library, these structs only define the 01162 * publicly visible methods and state variables of a module. Additional 01163 * private fields may exist after the public ones. 01164 */ 01165 01166 01167 /* Error handler object */ 01168 01169 struct jpeg_error_mgr { 01170 /* Error exit handler: does not return to caller */ 01171 JMETHOD(void, error_exit, (j_common_ptr cinfo)); 01172 /* Conditionally emit a trace or warning message */ 01173 JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level)); 01174 /* Routine that actually outputs a trace or error message */ 01175 JMETHOD(void, output_message, (j_common_ptr cinfo)); 01176 /* Format a message string for the most recent JPEG error or message */ 01177 JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer)); 01178 #define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */ 01179 /* Reset error state variables at start of a new image */ 01180 JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo)); 01181 01182 /* The message ID code and any parameters are saved here. 01183 * A message can have one string parameter or up to 8 int parameters. 01184 */ 01185 int msg_code; 01186 #define JMSG_STR_PARM_MAX 80 01187 union { 01188 int i[8]; 01189 char s[JMSG_STR_PARM_MAX]; 01190 } msg_parm; 01191 01192 /* Standard state variables for error facility */ 01193 01194 int trace_level; /* max msg_level that will be displayed */ 01195 01196 /* For recoverable corrupt-data errors, we emit a warning message, 01197 * but keep going unless emit_message chooses to abort. emit_message 01198 * should count warnings in num_warnings. The surrounding application 01199 * can check for bad data by seeing if num_warnings is nonzero at the 01200 * end of processing. 01201 */ 01202 long num_warnings; /* number of corrupt-data warnings */ 01203 01204 /* These fields point to the table(s) of error message strings. 01205 * An application can change the table pointer to switch to a different 01206 * message list (typically, to change the language in which errors are 01207 * reported). Some applications may wish to add additional error codes 01208 * that will be handled by the JPEG library error mechanism; the second 01209 * table pointer is used for this purpose. 01210 * 01211 * First table includes all errors generated by JPEG library itself. 01212 * Error code 0 is reserved for a "no such error string" message. 01213 */ 01214 const char * const * jpeg_message_table; /* Library errors */ 01215 int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */ 01216 /* Second table can be added by application (see cjpeg/djpeg for example). 01217 * It contains strings numbered first_addon_message..last_addon_message. 01218 */ 01219 const char * const * addon_message_table; /* Non-library errors */ 01220 int first_addon_message; /* code for first string in addon table */ 01221 int last_addon_message; /* code for last string in addon table */ 01222 }; 01223 01224 01225 /* Progress monitor object */ 01226 01227 struct jpeg_progress_mgr { 01228 JMETHOD(void, progress_monitor, (j_common_ptr cinfo)); 01229 01230 long pass_counter; /* work units completed in this pass */ 01231 long pass_limit; /* total number of work units in this pass */ 01232 int completed_passes; /* passes completed so far */ 01233 int total_passes; /* total number of passes expected */ 01234 }; 01235 01236 01237 /* Data destination object for compression */ 01238 01239 struct jpeg_destination_mgr { 01240 JOCTET * next_output_byte; /* => next byte to write in buffer */ 01241 size_t free_in_buffer; /* # of byte spaces remaining in buffer */ 01242 01243 JMETHOD(void, init_destination, (j_compress_ptr cinfo)); 01244 JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo)); 01245 JMETHOD(void, term_destination, (j_compress_ptr cinfo)); 01246 }; 01247 01248 01249 /* Data source object for decompression */ 01250 01251 typedef struct jpeg_source_mgr 01252 { 01253 FILE * infile; /* source stream */ 01254 JOCTET * buffer; /* start of buffer */ 01255 boolean start_of_file; /* have we gotten any data yet? */ 01256 01257 const JOCTET * next_input_byte; /* => next byte to read from buffer */ 01258 size_t bytes_in_buffer; /* # of bytes remaining in buffer */ 01259 01260 JMETHOD(void, init_source, (j_decompress_ptr cinfo)); 01261 JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo)); 01262 JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes)); 01263 JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired)); 01264 JMETHOD(void, term_source, (j_decompress_ptr cinfo)); 01265 } jpeg_source_mgr; 01266 01267 01268 /* Memory manager object. 01269 * Allocates "small" objects (a few K total), "large" objects (tens of K), 01270 * and "really big" objects (virtual arrays with backing store if needed). 01271 * The memory manager does not allow individual objects to be freed; rather, 01272 * each created object is assigned to a pool, and whole pools can be freed 01273 * at once. This is faster and more convenient than remembering exactly what 01274 * to free, especially where malloc()/free() are not too speedy. 01275 * NB: alloc routines never return NULL. They exit to error_exit if not 01276 * successful. 01277 */ 01278 01279 #define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */ 01280 #define JPOOL_IMAGE 1 /* lasts until done with image/datastream */ 01281 #define JPOOL_NUMPOOLS 2 01282 01283 typedef struct jvirt_sarray_control * jvirt_sarray_ptr; 01284 typedef struct jvirt_barray_control * jvirt_barray_ptr; 01285 01286 01287 struct jpeg_memory_mgr { 01288 /* Method pointers */ 01289 JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id, 01290 size_t sizeofobject)); 01291 JMETHOD(void FAR *, alloc_large, (j_common_ptr cinfo, int pool_id, 01292 size_t sizeofobject)); 01293 JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id, 01294 JDIMENSION samplesperrow, 01295 JDIMENSION numrows)); 01296 JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id, 01297 JDIMENSION blocksperrow, 01298 JDIMENSION numrows)); 01299 JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo, 01300 int pool_id, 01301 boolean pre_zero, 01302 JDIMENSION samplesperrow, 01303 JDIMENSION numrows, 01304 JDIMENSION maxaccess)); 01305 JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo, 01306 int pool_id, 01307 boolean pre_zero, 01308 JDIMENSION blocksperrow, 01309 JDIMENSION numrows, 01310 JDIMENSION maxaccess)); 01311 JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo)); 01312 JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo, 01313 jvirt_sarray_ptr ptr, 01314 JDIMENSION start_row, 01315 JDIMENSION num_rows, 01316 boolean writable)); 01317 JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo, 01318 jvirt_barray_ptr ptr, 01319 JDIMENSION start_row, 01320 JDIMENSION num_rows, 01321 boolean writable)); 01322 JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id)); 01323 JMETHOD(void, self_destruct, (j_common_ptr cinfo)); 01324 01325 /* Limit on memory allocation for this JPEG object. (Note that this is 01326 * merely advisory, not a guaranteed maximum; it only affects the space 01327 * used for virtual-array buffers.) May be changed by outer application 01328 * after creating the JPEG object. 01329 */ 01330 long max_memory_to_use; 01331 01332 /* Maximum allocation request accepted by alloc_large. */ 01333 long max_alloc_chunk; 01334 }; 01335 01336 01337 /* Routine signature for application-supplied marker processing methods. 01338 * Need not pass marker code since it is stored in cinfo->unread_marker. 01339 */ 01340 typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo)); 01341 01342 01343 /* Declarations for routines called by application. 01344 * The JPP macro hides prototype parameters from compilers that can't cope. 01345 * Note JPP requires double parentheses. 01346 */ 01347 01348 #ifdef HAVE_PROTOTYPES 01349 #define JPP(arglist) arglist 01350 #else 01351 #define JPP(arglist) () 01352 #endif 01353 01354 01355 /* Short forms of external names for systems with brain-damaged linkers. 01356 * We shorten external names to be unique in the first six letters, which 01357 * is good enough for all known systems. 01358 * (If your compiler itself needs names to be unique in less than 15 01359 * characters, you are out of luck. Get a better compiler.) 01360 */ 01361 01362 #ifdef NEED_SHORT_EXTERNAL_NAMES 01363 #define jpeg_std_error jStdError 01364 #define jpeg_CreateCompress jCreaCompress 01365 #define jpeg_CreateDecompress jCreaDecompress 01366 #define jpeg_destroy_compress jDestCompress 01367 #define jpeg_destroy_decompress jDestDecompress 01368 #define jpeg_stdio_dest jStdDest 01369 #define jpeg_stdio_src jStdSrc 01370 #define jpeg_set_defaults jSetDefaults 01371 #define jpeg_set_colorspace jSetColorspace 01372 #define jpeg_default_colorspace jDefColorspace 01373 #define jpeg_set_quality jSetQuality 01374 #define jpeg_set_linear_quality jSetLQuality 01375 #define jpeg_add_quant_table jAddQuantTable 01376 #define jpeg_quality_scaling jQualityScaling 01377 #define jpeg_simple_progression jSimProgress 01378 #define jpeg_suppress_tables jSuppressTables 01379 #define jpeg_alloc_quant_table jAlcQTable 01380 #define jpeg_alloc_huff_table jAlcHTable 01381 #define jpeg_start_compress jStrtCompress 01382 #define jpeg_write_scanlines jWrtScanlines 01383 #define jpeg_finish_compress jFinCompress 01384 #define jpeg_write_raw_data jWrtRawData 01385 #define jpeg_write_marker jWrtMarker 01386 #define jpeg_write_m_header jWrtMHeader 01387 #define jpeg_write_m_byte jWrtMByte 01388 #define jpeg_write_tables jWrtTables 01389 #define jpeg_read_header jReadHeader 01390 #define jpeg_start_decompress jStrtDecompress 01391 #define jpeg_read_scanlines jReadScanlines 01392 #define jpeg_finish_decompress jFinDecompress 01393 #define jpeg_read_raw_data jReadRawData 01394 #define jpeg_has_multiple_scans jHasMultScn 01395 #define jpeg_start_output jStrtOutput 01396 #define jpeg_finish_output jFinOutput 01397 #define jpeg_input_complete jInComplete 01398 #define jpeg_new_colormap jNewCMap 01399 #define jpeg_consume_input jConsumeInput 01400 #define jpeg_calc_output_dimensions jCalcDimensions 01401 #define jpeg_save_markers jSaveMarkers 01402 #define jpeg_set_marker_processor jSetMarker 01403 #define jpeg_read_coefficients jReadCoefs 01404 #define jpeg_write_coefficients jWrtCoefs 01405 #define jpeg_copy_critical_parameters jCopyCrit 01406 #define jpeg_abort_compress jAbrtCompress 01407 #define jpeg_abort_decompress jAbrtDecompress 01408 #define jpeg_abort jAbort 01409 #define jpeg_destroy jDestroy 01410 #define jpeg_resync_to_restart jResyncRestart 01411 #endif /* NEED_SHORT_EXTERNAL_NAMES */ 01412 01413 01414 /* Default error-management setup */ 01415 EXTERN(struct jpeg_error_mgr *) jpeg_std_error 01416 JPP((struct jpeg_error_mgr * err)); 01417 01418 /* Initialization of JPEG compression objects. 01419 * jpeg_create_compress() and jpeg_create_decompress() are the exported 01420 * names that applications should call. These expand to calls on 01421 * jpeg_CreateCompress and jpeg_CreateDecompress with additional information 01422 * passed for version mismatch checking. 01423 * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx. 01424 */ 01425 #define jpeg_create_compress(cinfo) \ 01426 jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \ 01427 (size_t) sizeof(struct jpeg_compress_struct)) 01428 #define jpeg_create_decompress(cinfo) \ 01429 jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \ 01430 (size_t) sizeof(struct jpeg_decompress_struct)) 01431 EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo, 01432 int version, size_t structsize)); 01433 EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo, 01434 int version, size_t structsize)); 01435 /* Destruction of JPEG compression objects */ 01436 EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo)); 01437 EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo)); 01438 01439 /* Standard data source and destination managers: stdio streams. */ 01440 /* Caller is responsible for opening the file before and closing after. */ 01441 EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile)); 01442 EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile)); 01443 01444 /* Default parameter setup for compression */ 01445 EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo)); 01446 /* Compression parameter setup aids */ 01447 EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo, 01448 J_COLOR_SPACE colorspace)); 01449 EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo)); 01450 EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality, 01451 boolean force_baseline)); 01452 EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo, 01453 int scale_factor, 01454 boolean force_baseline)); 01455 EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl, 01456 const unsigned int *basic_table, 01457 int scale_factor, 01458 boolean force_baseline)); 01459 EXTERN(int) jpeg_quality_scaling JPP((int quality)); 01460 EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo)); 01461 EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo, 01462 boolean suppress)); 01463 EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo)); 01464 EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo)); 01465 01466 /* Main entry points for compression */ 01467 EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo, 01468 boolean write_all_tables)); 01469 EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo, 01470 JSAMPARRAY scanlines, 01471 JDIMENSION num_lines)); 01472 EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo)); 01473 01474 /* Replaces jpeg_write_scanlines when writing raw downsampled data. */ 01475 EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo, 01476 JSAMPIMAGE data, 01477 JDIMENSION num_lines)); 01478 01479 /* Write a special marker. See libjpeg.doc concerning safe usage. */ 01480 EXTERN(void) jpeg_write_marker 01481 JPP((j_compress_ptr cinfo, int marker, 01482 const JOCTET * dataptr, unsigned int datalen)); 01483 /* Same, but piecemeal. */ 01484 EXTERN(void) jpeg_write_m_header 01485 JPP((j_compress_ptr cinfo, int marker, unsigned int datalen)); 01486 EXTERN(void) jpeg_write_m_byte 01487 JPP((j_compress_ptr cinfo, int val)); 01488 01489 /* Alternate compression function: just write an abbreviated table file */ 01490 EXTERN(void) jpeg_write_tables JPP((j_compress_ptr cinfo)); 01491 01492 /* Decompression startup: read start of JPEG datastream to see what's there */ 01493 EXTERN(int) jpeg_read_header JPP((j_decompress_ptr cinfo, 01494 boolean require_image)); 01495 /* Return value is one of: */ 01496 #define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */ 01497 #define JPEG_HEADER_OK 1 /* Found valid image datastream */ 01498 #define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */ 01499 /* If you pass require_image = TRUE (normal case), you need not check for 01500 * a TABLES_ONLY return code; an abbreviated file will cause an error exit. 01501 * JPEG_SUSPENDED is only possible if you use a data source module that can 01502 * give a suspension return (the stdio source module doesn't). 01503 */ 01504 01505 /* Main entry points for decompression */ 01506 EXTERN(boolean) jpeg_start_decompress JPP((j_decompress_ptr cinfo)); 01507 EXTERN(JDIMENSION) jpeg_read_scanlines JPP((j_decompress_ptr cinfo, 01508 JSAMPARRAY scanlines, 01509 JDIMENSION max_lines)); 01510 EXTERN(boolean) jpeg_finish_decompress JPP((j_decompress_ptr cinfo)); 01511 01512 /* Replaces jpeg_read_scanlines when reading raw downsampled data. */ 01513 EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo, 01514 JSAMPIMAGE data, 01515 JDIMENSION max_lines)); 01516 01517 /* Additional entry points for buffered-image mode. */ 01518 EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo)); 01519 EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo, 01520 int scan_number)); 01521 EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo)); 01522 EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo)); 01523 EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo)); 01524 EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo)); 01525 /* Return value is one of: */ 01526 /* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */ 01527 #define JPEG_REACHED_SOS 1 /* Reached start of new scan */ 01528 #define JPEG_REACHED_EOI 2 /* Reached end of image */ 01529 #define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */ 01530 #define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */ 01531 01532 /* Precalculate output dimensions for current decompression parameters. */ 01533 EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo)); 01534 01535 /* Control saving of COM and APPn markers into marker_list. */ 01536 EXTERN(void) jpeg_save_markers 01537 JPP((j_decompress_ptr cinfo, int marker_code, 01538 unsigned int length_limit)); 01539 01540 /* Install a special processing method for COM or APPn markers. */ 01541 EXTERN(void) jpeg_set_marker_processor 01542 JPP((j_decompress_ptr cinfo, int marker_code, 01543 jpeg_marker_parser_method routine)); 01544 01545 /* Read or write raw DCT coefficients --- useful for lossless transcoding. */ 01546 EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo)); 01547 EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo, 01548 jvirt_barray_ptr * coef_arrays)); 01549 EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo, 01550 j_compress_ptr dstinfo)); 01551 01552 /* If you choose to abort compression or decompression before completing 01553 * jpeg_finish_(de)compress, then you need to clean up to release memory, 01554 * temporary files, etc. You can just call jpeg_destroy_(de)compress 01555 * if you're done with the JPEG object, but if you want to clean it up and 01556 * reuse it, call this: 01557 */ 01558 EXTERN(void) jpeg_abort_compress JPP((j_compress_ptr cinfo)); 01559 EXTERN(void) jpeg_abort_decompress JPP((j_decompress_ptr cinfo)); 01560 01561 EXTERN(void)default_decompress_parms JPP((j_decompress_ptr cinfo)); 01562 01563 /* Generic versions of jpeg_abort and jpeg_destroy that work on either 01564 * flavor of JPEG object. These may be more convenient in some places. 01565 */ 01566 EXTERN(void) jpeg_abort JPP((j_common_ptr cinfo)); 01567 EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo)); 01568 01569 /* Default restart-marker-resync procedure for use by data source modules */ 01570 EXTERN(boolean) jpeg_resync_to_restart JPP((j_decompress_ptr cinfo, 01571 int desired)); 01572 01573 01574 /* These marker codes are exported since applications and data source modules 01575 * are likely to want to use them. 01576 */ 01577 01578 #define JPEG_RST0 0xD0 /* RST0 marker code */ 01579 #define JPEG_EOI 0xD9 /* EOI marker code */ 01580 #define JPEG_APP0 0xE0 /* APP0 marker code */ 01581 #define JPEG_COM 0xFE /* COM marker code */ 01582 01583 01584 /* If we have a brain-damaged compiler that emits warnings (or worse, errors) 01585 * for structure definitions that are never filled in, keep it quiet by 01586 * supplying dummy definitions for the various substructures. 01587 */ 01588 01589 #ifdef INCOMPLETE_TYPES_BROKEN 01590 #ifndef JPEG_INTERNALS /* will be defined in jpegint.h */ 01591 struct jvirt_sarray_control { long dummy; }; 01592 struct jvirt_barray_control { long dummy; }; 01593 struct jpeg_comp_master { long dummy; }; 01594 struct jpeg_c_main_controller { long dummy; }; 01595 struct jpeg_c_prep_controller { long dummy; }; 01596 struct jpeg_c_coef_controller { long dummy; }; 01597 struct jpeg_marker_writer { long dummy; }; 01598 struct jpeg_color_converter { long dummy; }; 01599 struct jpeg_downsampler { long dummy; }; 01600 struct jpeg_forward_dct { long dummy; }; 01601 struct jpeg_entropy_encoder { long dummy; }; 01602 struct jpeg_decomp_master { long dummy; }; 01603 struct jpeg_d_main_controller { long dummy; }; 01604 struct jpeg_d_coef_controller { long dummy; }; 01605 struct jpeg_d_post_controller { long dummy; }; 01606 struct jpeg_input_controller { long dummy; }; 01607 struct jpeg_marker_reader { long dummy; }; 01608 struct jpeg_entropy_decoder { long dummy; }; 01609 struct jpeg_inverse_dct { long dummy; }; 01610 struct jpeg_upsampler { long dummy; }; 01611 struct jpeg_color_deconverter { long dummy; }; 01612 struct jpeg_color_quantizer { long dummy; }; 01613 #endif /* JPEG_INTERNALS */ 01614 #endif /* INCOMPLETE_TYPES_BROKEN */ 01615 01616 01617 /* 01618 * The JPEG library modules define JPEG_INTERNALS before including this file. 01619 * The internal structure declarations are read only when that is true. 01620 * Applications using the library should not include jpegint.h, but may wish 01621 * to include jerror.h. 01622 */ 01623 01624 #ifdef JPEG_INTERNALS 01625 #include "jpegint.h" /* fetch private declarations */ 01626 #include "jerror.h" /* fetch error codes too */ 01627 #endif 01628 01629 #if defined(__cplusplus) 01630 }; 01631 #endif 01632 01633 #endif /* JPEGLIB_H */