7 * Copyright (C) 1991-1995, Thomas G. Lane.
\r
9 * This file is part of the Independent JPEG Group's software.
\r
11 * For conditions of distribution and use, see the accompanying README file.
\r
15 * This file contains additional configuration options that customize the
\r
17 * JPEG software for special applications or support machine-dependent
\r
19 * optimizations. Most users will not need to touch this file.
\r
29 * Define BITS_IN_JSAMPLE as either
\r
31 * 8 for 8-bit sample values (the usual setting)
\r
33 * 12 for 12-bit sample values
\r
35 * Only 8 and 12 are legal data precisions for lossy JPEG according to the
\r
37 * JPEG standard, and the IJG code does not support anything else!
\r
39 * We do not support run-time selection of data precision, sorry.
\r
45 #define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
\r
53 * Maximum number of components (color channels) allowed in JPEG image.
\r
55 * To meet the letter of the JPEG spec, set this to 255. However, darn
\r
57 * few applications need more than 4 channels (maybe 5 for CMYK + alpha
\r
59 * mask). We recommend 10 as a reasonable compromise; use 4 if you are
\r
61 * really short on memory. (Each allowed component costs a hundred or so
\r
63 * bytes of storage, whether actually used in an image or not.)
\r
69 #define MAX_COMPONENTS 10 /* maximum number of image components */
\r
79 * You may need to change these if you have a machine with unusual data
\r
81 * type sizes; for example, "char" not 8 bits, "short" not 16 bits,
\r
83 * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits,
\r
85 * but it had better be at least 16.
\r
91 /* Representation of a single sample (pixel element value).
\r
93 * We frequently allocate large arrays of these, so it's important to keep
\r
95 * them small. But if you have memory to burn and access to char or short
\r
97 * arrays is very slow on your hardware, you might want to change these.
\r
103 #if BITS_IN_JSAMPLE == 8
\r
105 /* JSAMPLE should be the smallest type that will hold the values 0..255.
\r
107 * You can use a signed char by having GETJSAMPLE mask it with 0xFF.
\r
113 #ifdef HAVE_UNSIGNED_CHAR
\r
117 typedef unsigned char JSAMPLE;
\r
119 #define GETJSAMPLE(value) ((int) (value))
\r
123 #else /* not HAVE_UNSIGNED_CHAR */
\r
127 typedef char JSAMPLE;
\r
129 #ifdef CHAR_IS_UNSIGNED
\r
131 #define GETJSAMPLE(value) ((int) (value))
\r
135 #define GETJSAMPLE(value) ((int) (value) & 0xFF)
\r
137 #endif /* CHAR_IS_UNSIGNED */
\r
141 #endif /* HAVE_UNSIGNED_CHAR */
\r
145 #define MAXJSAMPLE 255
\r
147 #define CENTERJSAMPLE 128
\r
151 #endif /* BITS_IN_JSAMPLE == 8 */
\r
157 #if BITS_IN_JSAMPLE == 12
\r
159 /* JSAMPLE should be the smallest type that will hold the values 0..4095.
\r
161 * On nearly all machines "short" will do nicely.
\r
167 typedef short JSAMPLE;
\r
169 #define GETJSAMPLE(value) ((int) (value))
\r
173 #define MAXJSAMPLE 4095
\r
175 #define CENTERJSAMPLE 2048
\r
179 #endif /* BITS_IN_JSAMPLE == 12 */
\r
185 /* Representation of a DCT frequency coefficient.
\r
187 * This should be a signed value of at least 16 bits; "short" is usually OK.
\r
189 * Again, we allocate large arrays of these, but you can change to int
\r
191 * if you have memory to burn and "short" is really slow.
\r
197 typedef short JCOEF;
\r
203 /* Compressed datastreams are represented as arrays of JOCTET.
\r
205 * These must be EXACTLY 8 bits wide, at least once they are written to
\r
207 * external storage. Note that when using the stdio data source/destination
\r
209 * managers, this is also the data type passed to fread/fwrite.
\r
215 #ifdef HAVE_UNSIGNED_CHAR
\r
219 typedef unsigned char JOCTET;
\r
221 #define GETJOCTET(value) (value)
\r
225 #else /* not HAVE_UNSIGNED_CHAR */
\r
229 typedef char JOCTET;
\r
231 #ifdef CHAR_IS_UNSIGNED
\r
233 #define GETJOCTET(value) (value)
\r
237 #define GETJOCTET(value) ((value) & 0xFF)
\r
239 #endif /* CHAR_IS_UNSIGNED */
\r
243 #endif /* HAVE_UNSIGNED_CHAR */
\r
249 /* These typedefs are used for various table entries and so forth.
\r
251 * They must be at least as wide as specified; but making them too big
\r
253 * won't cost a huge amount of memory, so we don't provide special
\r
255 * extraction code like we did for JSAMPLE. (In other words, these
\r
257 * typedefs live at a different point on the speed/space tradeoff curve.)
\r
263 /* UINT8 must hold at least the values 0..255. */
\r
267 #ifdef HAVE_UNSIGNED_CHAR
\r
269 typedef unsigned char UINT8;
\r
271 #else /* not HAVE_UNSIGNED_CHAR */
\r
273 #ifdef CHAR_IS_UNSIGNED
\r
275 typedef char UINT8;
\r
277 #else /* not CHAR_IS_UNSIGNED */
\r
279 typedef short UINT8;
\r
281 #endif /* CHAR_IS_UNSIGNED */
\r
283 #endif /* HAVE_UNSIGNED_CHAR */
\r
287 /* UINT16 must hold at least the values 0..65535. */
\r
291 #ifdef HAVE_UNSIGNED_SHORT
\r
293 typedef unsigned short UINT16;
\r
295 #else /* not HAVE_UNSIGNED_SHORT */
\r
297 typedef unsigned int UINT16;
\r
299 #endif /* HAVE_UNSIGNED_SHORT */
\r
303 /* INT16 must hold at least the values -32768..32767. */
\r
307 #ifndef XMD_H /* X11/xmd.h correctly defines INT16 */
\r
309 typedef short INT16;
\r
315 /* INT32 must hold at least signed 32-bit values. */
\r
319 //#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */
\r
321 //typedef long INT32;
\r
327 /* Datatype used for image dimensions. The JPEG standard only supports
\r
329 * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
\r
331 * "unsigned int" is sufficient on all machines. However, if you need to
\r
333 * handle larger images and you don't mind deviating from the spec, you
\r
335 * can change this datatype.
\r
341 typedef unsigned int JDIMENSION;
\r
345 #define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */
\r
351 /* These defines are used in all function definitions and extern declarations.
\r
353 * You could modify them if you need to change function linkage conventions.
\r
355 * Another application is to make all functions global for use with debuggers
\r
357 * or code profilers that require it.
\r
363 #define METHODDEF static /* a function called through method pointers */
\r
365 #define LOCAL static /* a function used only in its module */
\r
367 #define GLOBAL /* a function referenced thru EXTERNs */
\r
369 #define EXTERN extern /* a reference to a GLOBAL function */
\r
375 /* Here is the pseudo-keyword for declaring pointers that must be "far"
\r
377 * on 80x86 machines. Most of the specialized coding for 80x86 is handled
\r
379 * by just saying "FAR *" where such a pointer is needed. In a few places
\r
381 * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol.
\r
387 #ifdef NEED_FAR_POINTERS
\r
407 * On a few systems, type boolean and/or its values FALSE, TRUE may appear
\r
409 * in standard header files. Or you may have conflicts with application-
\r
411 * specific header files that you want to include together with these files.
\r
413 * Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
\r
419 //#ifndef HAVE_BOOLEAN
\r
421 //typedef int boolean;
\r
425 #ifndef FALSE /* in case these macros already exist */
\r
427 #define FALSE 0 /* values of boolean */
\r
443 * The remaining options affect code selection within the JPEG library,
\r
445 * but they don't need to be visible to most applications using the library.
\r
447 * To minimize application namespace pollution, the symbols won't be
\r
449 * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.
\r
455 #ifdef JPEG_INTERNALS
\r
457 #define JPEG_INTERNAL_OPTIONS
\r
463 #ifdef JPEG_INTERNAL_OPTIONS
\r
471 * These defines indicate whether to include various optional functions.
\r
473 * Undefining some of these symbols will produce a smaller but less capable
\r
475 * library. Note that you can leave certain source files out of the
\r
477 * compilation/linking process if you've #undef'd the corresponding symbols.
\r
479 * (You may HAVE to do that if your compiler doesn't like null source files.)
\r
485 /* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */
\r
489 /* Capability options common to encoder and decoder: */
\r
493 #undef DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */
\r
495 #undef DCT_IFAST_SUPPORTED /* faster, less accurate integer method */
\r
497 #define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */
\r
501 /* Encoder capability options: */
\r
505 #undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
\r
507 #define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
\r
509 #define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
\r
511 #define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
\r
513 /* Note: if you selected 12-bit data precision, it is dangerous to turn off
\r
515 * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit
\r
517 * precision, so jchuff.c normally uses entropy optimization to compute
\r
519 * usable tables for higher precision. If you don't want to do optimization,
\r
521 * you'll have to supply different default Huffman tables.
\r
523 * The exact same statements apply for progressive JPEG: the default tables
\r
525 * don't work for progressive mode. (This may get fixed, however.)
\r
529 #define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */
\r
533 /* Decoder capability options: */
\r
537 #undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
\r
539 #undef D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
\r
541 #undef D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
\r
543 #undef BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
\r
545 #undef IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */
\r
547 #undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
\r
549 #undef UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */
\r
551 #undef QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */
\r
553 #undef QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */
\r
557 /* more capability options later, no doubt */
\r
565 * Ordering of RGB data in scanlines passed to or from the application.
\r
567 * If your application wants to deal with data in the order B,G,R, just
\r
569 * change these macros. You can also deal with formats such as R,G,B,X
\r
571 * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing
\r
573 * the offsets will also change the order in which colormap data is organized.
\r
577 * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.
\r
579 * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not
\r
581 * useful if you are using JPEG color spaces other than YCbCr or grayscale.
\r
583 * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
\r
585 * is not 3 (they don't understand about dummy color components!). So you
\r
587 * can't use color quantization if you change that value.
\r
593 #define RGB_RED 0 /* Offset of Red in an RGB scanline element */
\r
595 #define RGB_GREEN 1 /* Offset of Green */
\r
597 #define RGB_BLUE 2 /* Offset of Blue */
\r
599 // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=900
\r
600 // ydnar: setting this fucks jpeg loading in q3map2, disabling "fix" (3)
\r
601 #define RGB_PIXELSIZE 4 /* JSAMPLEs per RGB scanline element */
\r
607 /* Definitions for speed-related optimizations. */
\r
613 /* If your compiler supports inline functions, define INLINE
\r
615 * as the inline keyword; otherwise define it as empty.
\r
623 #ifdef __GNUC__ /* for instance, GNU C knows about inline */
\r
625 #define INLINE __inline__
\r
631 #define INLINE /* default is to define it as empty */
\r
641 /* On some machines (notably 68000 series) "int" is 32 bits, but multiplying
\r
643 * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER
\r
645 * as short on such a machine. MULTIPLIER must be at least 16 bits wide.
\r
653 #define MULTIPLIER int /* type for fastest integer multiply */
\r
661 /* FAST_FLOAT should be either float or double, whichever is done faster
\r
663 * by your compiler. (Note that this type is only used in the floating point
\r
665 * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)
\r
667 * Typically, float is faster in ANSI C compilers, while double is faster in
\r
669 * pre-ANSI compilers (because they insist on converting to double anyway).
\r
671 * The code below therefore chooses float if we have ANSI-style prototypes.
\r
679 #ifdef HAVE_PROTOTYPES
\r
681 #define FAST_FLOAT float
\r
685 #define FAST_FLOAT double
\r
693 #endif /* JPEG_INTERNAL_OPTIONS */
\r