jpayne@69: /* jpayne@69: * jmorecfg.h jpayne@69: * jpayne@69: * Copyright (C) 1991-1997, Thomas G. Lane. jpayne@69: * Modified 1997-2013 by Guido Vollbeding. jpayne@69: * This file is part of the Independent JPEG Group's software. jpayne@69: * For conditions of distribution and use, see the accompanying README file. jpayne@69: * jpayne@69: * This file contains additional configuration options that customize the jpayne@69: * JPEG software for special applications or support machine-dependent jpayne@69: * optimizations. Most users will not need to touch this file. jpayne@69: */ jpayne@69: jpayne@69: jpayne@69: /* jpayne@69: * Define BITS_IN_JSAMPLE as either jpayne@69: * 8 for 8-bit sample values (the usual setting) jpayne@69: * 9 for 9-bit sample values jpayne@69: * 10 for 10-bit sample values jpayne@69: * 11 for 11-bit sample values jpayne@69: * 12 for 12-bit sample values jpayne@69: * Only 8, 9, 10, 11, and 12 bits sample data precision are supported for jpayne@69: * full-feature DCT processing. Further depths up to 16-bit may be added jpayne@69: * later for the lossless modes of operation. jpayne@69: * Run-time selection and conversion of data precision will be added later jpayne@69: * and are currently not supported, sorry. jpayne@69: * Exception: The transcoding part (jpegtran) supports all settings in a jpayne@69: * single instance, since it operates on the level of DCT coefficients and jpayne@69: * not sample values. The DCT coefficients are of the same type (16 bits) jpayne@69: * in all cases (see below). jpayne@69: */ jpayne@69: jpayne@69: #define BITS_IN_JSAMPLE 8 /* use 8, 9, 10, 11, or 12 */ jpayne@69: jpayne@69: jpayne@69: /* jpayne@69: * Maximum number of components (color channels) allowed in JPEG image. jpayne@69: * To meet the letter of the JPEG spec, set this to 255. However, darn jpayne@69: * few applications need more than 4 channels (maybe 5 for CMYK + alpha jpayne@69: * mask). We recommend 10 as a reasonable compromise; use 4 if you are jpayne@69: * really short on memory. (Each allowed component costs a hundred or so jpayne@69: * bytes of storage, whether actually used in an image or not.) jpayne@69: */ jpayne@69: jpayne@69: #define MAX_COMPONENTS 10 /* maximum number of image components */ jpayne@69: jpayne@69: jpayne@69: /* jpayne@69: * Basic data types. jpayne@69: * You may need to change these if you have a machine with unusual data jpayne@69: * type sizes; for example, "char" not 8 bits, "short" not 16 bits, jpayne@69: * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, jpayne@69: * but it had better be at least 16. jpayne@69: */ jpayne@69: jpayne@69: /* Representation of a single sample (pixel element value). jpayne@69: * We frequently allocate large arrays of these, so it's important to keep jpayne@69: * them small. But if you have memory to burn and access to char or short jpayne@69: * arrays is very slow on your hardware, you might want to change these. jpayne@69: */ jpayne@69: jpayne@69: #if BITS_IN_JSAMPLE == 8 jpayne@69: /* JSAMPLE should be the smallest type that will hold the values 0..255. jpayne@69: * You can use a signed char by having GETJSAMPLE mask it with 0xFF. jpayne@69: */ jpayne@69: jpayne@69: #ifdef HAVE_UNSIGNED_CHAR jpayne@69: jpayne@69: typedef unsigned char JSAMPLE; jpayne@69: #define GETJSAMPLE(value) ((int) (value)) jpayne@69: jpayne@69: #else /* not HAVE_UNSIGNED_CHAR */ jpayne@69: jpayne@69: typedef char JSAMPLE; jpayne@69: #ifdef CHAR_IS_UNSIGNED jpayne@69: #define GETJSAMPLE(value) ((int) (value)) jpayne@69: #else jpayne@69: #define GETJSAMPLE(value) ((int) (value) & 0xFF) jpayne@69: #endif /* CHAR_IS_UNSIGNED */ jpayne@69: jpayne@69: #endif /* HAVE_UNSIGNED_CHAR */ jpayne@69: jpayne@69: #define MAXJSAMPLE 255 jpayne@69: #define CENTERJSAMPLE 128 jpayne@69: jpayne@69: #endif /* BITS_IN_JSAMPLE == 8 */ jpayne@69: jpayne@69: jpayne@69: #if BITS_IN_JSAMPLE == 9 jpayne@69: /* JSAMPLE should be the smallest type that will hold the values 0..511. jpayne@69: * On nearly all machines "short" will do nicely. jpayne@69: */ jpayne@69: jpayne@69: typedef short JSAMPLE; jpayne@69: #define GETJSAMPLE(value) ((int) (value)) jpayne@69: jpayne@69: #define MAXJSAMPLE 511 jpayne@69: #define CENTERJSAMPLE 256 jpayne@69: jpayne@69: #endif /* BITS_IN_JSAMPLE == 9 */ jpayne@69: jpayne@69: jpayne@69: #if BITS_IN_JSAMPLE == 10 jpayne@69: /* JSAMPLE should be the smallest type that will hold the values 0..1023. jpayne@69: * On nearly all machines "short" will do nicely. jpayne@69: */ jpayne@69: jpayne@69: typedef short JSAMPLE; jpayne@69: #define GETJSAMPLE(value) ((int) (value)) jpayne@69: jpayne@69: #define MAXJSAMPLE 1023 jpayne@69: #define CENTERJSAMPLE 512 jpayne@69: jpayne@69: #endif /* BITS_IN_JSAMPLE == 10 */ jpayne@69: jpayne@69: jpayne@69: #if BITS_IN_JSAMPLE == 11 jpayne@69: /* JSAMPLE should be the smallest type that will hold the values 0..2047. jpayne@69: * On nearly all machines "short" will do nicely. jpayne@69: */ jpayne@69: jpayne@69: typedef short JSAMPLE; jpayne@69: #define GETJSAMPLE(value) ((int) (value)) jpayne@69: jpayne@69: #define MAXJSAMPLE 2047 jpayne@69: #define CENTERJSAMPLE 1024 jpayne@69: jpayne@69: #endif /* BITS_IN_JSAMPLE == 11 */ jpayne@69: jpayne@69: jpayne@69: #if BITS_IN_JSAMPLE == 12 jpayne@69: /* JSAMPLE should be the smallest type that will hold the values 0..4095. jpayne@69: * On nearly all machines "short" will do nicely. jpayne@69: */ jpayne@69: jpayne@69: typedef short JSAMPLE; jpayne@69: #define GETJSAMPLE(value) ((int) (value)) jpayne@69: jpayne@69: #define MAXJSAMPLE 4095 jpayne@69: #define CENTERJSAMPLE 2048 jpayne@69: jpayne@69: #endif /* BITS_IN_JSAMPLE == 12 */ jpayne@69: jpayne@69: jpayne@69: /* Representation of a DCT frequency coefficient. jpayne@69: * This should be a signed value of at least 16 bits; "short" is usually OK. jpayne@69: * Again, we allocate large arrays of these, but you can change to int jpayne@69: * if you have memory to burn and "short" is really slow. jpayne@69: */ jpayne@69: jpayne@69: typedef short JCOEF; jpayne@69: jpayne@69: jpayne@69: /* Compressed datastreams are represented as arrays of JOCTET. jpayne@69: * These must be EXACTLY 8 bits wide, at least once they are written to jpayne@69: * external storage. Note that when using the stdio data source/destination jpayne@69: * managers, this is also the data type passed to fread/fwrite. jpayne@69: */ jpayne@69: jpayne@69: #ifdef HAVE_UNSIGNED_CHAR jpayne@69: jpayne@69: typedef unsigned char JOCTET; jpayne@69: #define GETJOCTET(value) (value) jpayne@69: jpayne@69: #else /* not HAVE_UNSIGNED_CHAR */ jpayne@69: jpayne@69: typedef char JOCTET; jpayne@69: #ifdef CHAR_IS_UNSIGNED jpayne@69: #define GETJOCTET(value) (value) jpayne@69: #else jpayne@69: #define GETJOCTET(value) ((value) & 0xFF) jpayne@69: #endif /* CHAR_IS_UNSIGNED */ jpayne@69: jpayne@69: #endif /* HAVE_UNSIGNED_CHAR */ jpayne@69: jpayne@69: jpayne@69: /* These typedefs are used for various table entries and so forth. jpayne@69: * They must be at least as wide as specified; but making them too big jpayne@69: * won't cost a huge amount of memory, so we don't provide special jpayne@69: * extraction code like we did for JSAMPLE. (In other words, these jpayne@69: * typedefs live at a different point on the speed/space tradeoff curve.) jpayne@69: */ jpayne@69: jpayne@69: /* UINT8 must hold at least the values 0..255. */ jpayne@69: jpayne@69: #ifdef HAVE_UNSIGNED_CHAR jpayne@69: typedef unsigned char UINT8; jpayne@69: #else /* not HAVE_UNSIGNED_CHAR */ jpayne@69: #ifdef CHAR_IS_UNSIGNED jpayne@69: typedef char UINT8; jpayne@69: #else /* not CHAR_IS_UNSIGNED */ jpayne@69: typedef short UINT8; jpayne@69: #endif /* CHAR_IS_UNSIGNED */ jpayne@69: #endif /* HAVE_UNSIGNED_CHAR */ jpayne@69: jpayne@69: /* UINT16 must hold at least the values 0..65535. */ jpayne@69: jpayne@69: #ifdef HAVE_UNSIGNED_SHORT jpayne@69: typedef unsigned short UINT16; jpayne@69: #else /* not HAVE_UNSIGNED_SHORT */ jpayne@69: typedef unsigned int UINT16; jpayne@69: #endif /* HAVE_UNSIGNED_SHORT */ jpayne@69: jpayne@69: /* INT16 must hold at least the values -32768..32767. */ jpayne@69: jpayne@69: #ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ jpayne@69: typedef short INT16; jpayne@69: #endif jpayne@69: jpayne@69: /* INT32 must hold at least signed 32-bit values. */ jpayne@69: jpayne@69: #ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ jpayne@69: #ifndef _BASETSD_H_ /* Microsoft defines it in basetsd.h */ jpayne@69: #ifndef _BASETSD_H /* MinGW is slightly different */ jpayne@69: #ifndef QGLOBAL_H /* Qt defines it in qglobal.h */ jpayne@69: typedef long INT32; jpayne@69: #endif jpayne@69: #endif jpayne@69: #endif jpayne@69: #endif jpayne@69: jpayne@69: /* Datatype used for image dimensions. The JPEG standard only supports jpayne@69: * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore jpayne@69: * "unsigned int" is sufficient on all machines. However, if you need to jpayne@69: * handle larger images and you don't mind deviating from the spec, you jpayne@69: * can change this datatype. jpayne@69: */ jpayne@69: jpayne@69: typedef unsigned int JDIMENSION; jpayne@69: jpayne@69: #define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ jpayne@69: jpayne@69: jpayne@69: /* These macros are used in all function definitions and extern declarations. jpayne@69: * You could modify them if you need to change function linkage conventions; jpayne@69: * in particular, you'll need to do that to make the library a Windows DLL. jpayne@69: * Another application is to make all functions global for use with debuggers jpayne@69: * or code profilers that require it. jpayne@69: */ jpayne@69: jpayne@69: /* a function called through method pointers: */ jpayne@69: #define METHODDEF(type) static type jpayne@69: /* a function used only in its module: */ jpayne@69: #define LOCAL(type) static type jpayne@69: /* a function referenced thru EXTERNs: */ jpayne@69: #define GLOBAL(type) type jpayne@69: /* a reference to a GLOBAL function: */ jpayne@69: #define EXTERN(type) extern type jpayne@69: jpayne@69: jpayne@69: /* This macro is used to declare a "method", that is, a function pointer. jpayne@69: * We want to supply prototype parameters if the compiler can cope. jpayne@69: * Note that the arglist parameter must be parenthesized! jpayne@69: * Again, you can customize this if you need special linkage keywords. jpayne@69: */ jpayne@69: jpayne@69: #ifdef HAVE_PROTOTYPES jpayne@69: #define JMETHOD(type,methodname,arglist) type (*methodname) arglist jpayne@69: #else jpayne@69: #define JMETHOD(type,methodname,arglist) type (*methodname) () jpayne@69: #endif jpayne@69: jpayne@69: jpayne@69: /* The noreturn type identifier is used to declare functions jpayne@69: * which cannot return. jpayne@69: * Compilers can thus create more optimized code and perform jpayne@69: * better checks for warnings and errors. jpayne@69: * Static analyzer tools can make improved inferences about jpayne@69: * execution paths and are prevented from giving false alerts. jpayne@69: * jpayne@69: * Unfortunately, the proposed specifications of corresponding jpayne@69: * extensions in the Dec 2011 ISO C standard revision (C11), jpayne@69: * GCC, MSVC, etc. are not viable. jpayne@69: * Thus we introduce a user defined type to declare noreturn jpayne@69: * functions at least for clarity. A proper compiler would jpayne@69: * have a suitable noreturn type to match in place of void. jpayne@69: */ jpayne@69: jpayne@69: #ifndef HAVE_NORETURN_T jpayne@69: typedef void noreturn_t; jpayne@69: #endif jpayne@69: jpayne@69: jpayne@69: /* Here is the pseudo-keyword for declaring pointers that must be "far" jpayne@69: * on 80x86 machines. Most of the specialized coding for 80x86 is handled jpayne@69: * by just saying "FAR *" where such a pointer is needed. In a few places jpayne@69: * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. jpayne@69: */ jpayne@69: jpayne@69: #ifndef FAR jpayne@69: #ifdef NEED_FAR_POINTERS jpayne@69: #define FAR far jpayne@69: #else jpayne@69: #define FAR jpayne@69: #endif jpayne@69: #endif jpayne@69: jpayne@69: jpayne@69: /* jpayne@69: * On a few systems, type boolean and/or its values FALSE, TRUE may appear jpayne@69: * in standard header files. Or you may have conflicts with application- jpayne@69: * specific header files that you want to include together with these files. jpayne@69: * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. jpayne@69: */ jpayne@69: jpayne@69: #ifndef HAVE_BOOLEAN jpayne@69: #if defined FALSE || defined TRUE || defined QGLOBAL_H jpayne@69: /* Qt3 defines FALSE and TRUE as "const" variables in qglobal.h */ jpayne@69: typedef int boolean; jpayne@69: #ifndef FALSE /* in case these macros already exist */ jpayne@69: #define FALSE 0 /* values of boolean */ jpayne@69: #endif jpayne@69: #ifndef TRUE jpayne@69: #define TRUE 1 jpayne@69: #endif jpayne@69: #else jpayne@69: typedef enum { FALSE = 0, TRUE = 1 } boolean; jpayne@69: #endif jpayne@69: #endif jpayne@69: jpayne@69: jpayne@69: /* jpayne@69: * The remaining options affect code selection within the JPEG library, jpayne@69: * but they don't need to be visible to most applications using the library. jpayne@69: * To minimize application namespace pollution, the symbols won't be jpayne@69: * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. jpayne@69: */ jpayne@69: jpayne@69: #ifdef JPEG_INTERNALS jpayne@69: #define JPEG_INTERNAL_OPTIONS jpayne@69: #endif jpayne@69: jpayne@69: #ifdef JPEG_INTERNAL_OPTIONS jpayne@69: jpayne@69: jpayne@69: /* jpayne@69: * These defines indicate whether to include various optional functions. jpayne@69: * Undefining some of these symbols will produce a smaller but less capable jpayne@69: * library. Note that you can leave certain source files out of the jpayne@69: * compilation/linking process if you've #undef'd the corresponding symbols. jpayne@69: * (You may HAVE to do that if your compiler doesn't like null source files.) jpayne@69: */ jpayne@69: jpayne@69: /* Capability options common to encoder and decoder: */ jpayne@69: jpayne@69: #define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ jpayne@69: #define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ jpayne@69: #define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ jpayne@69: jpayne@69: /* Encoder capability options: */ jpayne@69: jpayne@69: #define C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ jpayne@69: #define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ jpayne@69: #define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ jpayne@69: #define DCT_SCALING_SUPPORTED /* Input rescaling via DCT? (Requires DCT_ISLOW)*/ jpayne@69: #define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ jpayne@69: /* Note: if you selected more than 8-bit data precision, it is dangerous to jpayne@69: * turn off ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only jpayne@69: * good for 8-bit precision, so arithmetic coding is recommended for higher jpayne@69: * precision. The Huffman encoder normally uses entropy optimization to jpayne@69: * compute usable tables for higher precision. Otherwise, you'll have to jpayne@69: * supply different default Huffman tables. jpayne@69: * The exact same statements apply for progressive JPEG: the default tables jpayne@69: * don't work for progressive mode. (This may get fixed, however.) jpayne@69: */ jpayne@69: #define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ jpayne@69: jpayne@69: /* Decoder capability options: */ jpayne@69: jpayne@69: #define D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ jpayne@69: #define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ jpayne@69: #define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ jpayne@69: #define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? (Requires DCT_ISLOW)*/ jpayne@69: #define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ jpayne@69: #define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ jpayne@69: #undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ jpayne@69: #define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ jpayne@69: #define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ jpayne@69: #define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ jpayne@69: jpayne@69: /* more capability options later, no doubt */ jpayne@69: jpayne@69: jpayne@69: /* jpayne@69: * Ordering of RGB data in scanlines passed to or from the application. jpayne@69: * If your application wants to deal with data in the order B,G,R, just jpayne@69: * change these macros. You can also deal with formats such as R,G,B,X jpayne@69: * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing jpayne@69: * the offsets will also change the order in which colormap data is organized. jpayne@69: * RESTRICTIONS: jpayne@69: * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. jpayne@69: * 2. The color quantizer modules will not behave desirably if RGB_PIXELSIZE jpayne@69: * is not 3 (they don't understand about dummy color components!). So you jpayne@69: * can't use color quantization if you change that value. jpayne@69: */ jpayne@69: jpayne@69: #define RGB_RED 0 /* Offset of Red in an RGB scanline element */ jpayne@69: #define RGB_GREEN 1 /* Offset of Green */ jpayne@69: #define RGB_BLUE 2 /* Offset of Blue */ jpayne@69: #define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ jpayne@69: jpayne@69: jpayne@69: /* Definitions for speed-related optimizations. */ jpayne@69: jpayne@69: jpayne@69: /* If your compiler supports inline functions, define INLINE jpayne@69: * as the inline keyword; otherwise define it as empty. jpayne@69: */ jpayne@69: jpayne@69: #ifndef INLINE jpayne@69: #ifdef __GNUC__ /* for instance, GNU C knows about inline */ jpayne@69: #define INLINE __inline__ jpayne@69: #endif jpayne@69: #ifndef INLINE jpayne@69: #define INLINE /* default is to define it as empty */ jpayne@69: #endif jpayne@69: #endif jpayne@69: jpayne@69: jpayne@69: /* On some machines (notably 68000 series) "int" is 32 bits, but multiplying jpayne@69: * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER jpayne@69: * as short on such a machine. MULTIPLIER must be at least 16 bits wide. jpayne@69: */ jpayne@69: jpayne@69: #ifndef MULTIPLIER jpayne@69: #define MULTIPLIER int /* type for fastest integer multiply */ jpayne@69: #endif jpayne@69: jpayne@69: jpayne@69: /* FAST_FLOAT should be either float or double, whichever is done faster jpayne@69: * by your compiler. (Note that this type is only used in the floating point jpayne@69: * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) jpayne@69: * Typically, float is faster in ANSI C compilers, while double is faster in jpayne@69: * pre-ANSI compilers (because they insist on converting to double anyway). jpayne@69: * The code below therefore chooses float if we have ANSI-style prototypes. jpayne@69: */ jpayne@69: jpayne@69: #ifndef FAST_FLOAT jpayne@69: #ifdef HAVE_PROTOTYPES jpayne@69: #define FAST_FLOAT float jpayne@69: #else jpayne@69: #define FAST_FLOAT double jpayne@69: #endif jpayne@69: #endif jpayne@69: jpayne@69: #endif /* JPEG_INTERNAL_OPTIONS */