/*1* jmorecfg.h2*3* Copyright (C) 1991-1997, Thomas G. Lane.4* Modified 1997-2022 by Guido Vollbeding.5* This file is part of the Independent JPEG Group's software.6* For conditions of distribution and use, see the accompanying README file.7*8* This file contains additional configuration options that customize the9* JPEG software for special applications or support machine-dependent10* optimizations. Most users will not need to touch this file.11*/121314/*15* Define BITS_IN_JSAMPLE as either16* 8 for 8-bit sample values (the usual setting)17* 9 for 9-bit sample values18* 10 for 10-bit sample values19* 11 for 11-bit sample values20* 12 for 12-bit sample values21* Only 8, 9, 10, 11, and 12 bits sample data precision are supported for22* full-feature DCT processing. Further depths up to 16-bit may be added23* later for the lossless modes of operation.24* Run-time selection and conversion of data precision will be added later25* and are currently not supported, sorry.26* Exception: The transcoding part (jpegtran) supports all settings in a27* single instance, since it operates on the level of DCT coefficients and28* not sample values. The DCT coefficients are of the same type (16 bits)29* in all cases (see below).30*/3132#define BITS_IN_JSAMPLE 8 /* use 8, 9, 10, 11, or 12 */333435/*36* Maximum number of components (color channels) allowed in JPEG image.37* To meet the letter of the JPEG spec, set this to 255. However, darn38* few applications need more than 4 channels (maybe 5 for CMYK + alpha39* mask). We recommend 10 as a reasonable compromise; use 4 if you are40* really short on memory. (Each allowed component costs a hundred or so41* bytes of storage, whether actually used in an image or not.)42*/4344#define MAX_COMPONENTS 10 /* maximum number of image components */454647/*48* Basic data types.49* You may need to change these if you have a machine with unusual data50* type sizes; for example, "char" not 8 bits, "short" not 16 bits,51* or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits,52* but it had better be at least 16.53*/5455/* Representation of a single sample (pixel element value).56* We frequently allocate large arrays of these, so it's important to keep57* them small. But if you have memory to burn and access to char or short58* arrays is very slow on your hardware, you might want to change these.59*/6061#if BITS_IN_JSAMPLE == 862/* JSAMPLE should be the smallest type that will hold the values 0..255.63* You can use a signed char by having GETJSAMPLE mask it with 0xFF.64*/6566#ifdef HAVE_UNSIGNED_CHAR6768typedef unsigned char JSAMPLE;69#define GETJSAMPLE(value) ((int) (value))7071#else /* not HAVE_UNSIGNED_CHAR */7273typedef char JSAMPLE;74#ifdef CHAR_IS_UNSIGNED75#define GETJSAMPLE(value) ((int) (value))76#else77#define GETJSAMPLE(value) ((int) (value) & 0xFF)78#endif /* CHAR_IS_UNSIGNED */7980#endif /* HAVE_UNSIGNED_CHAR */8182#define MAXJSAMPLE 25583#define CENTERJSAMPLE 1288485#endif /* BITS_IN_JSAMPLE == 8 */868788#if BITS_IN_JSAMPLE == 989/* JSAMPLE should be the smallest type that will hold the values 0..511.90* On nearly all machines "short" will do nicely.91*/9293typedef short JSAMPLE;94#define GETJSAMPLE(value) ((int) (value))9596#define MAXJSAMPLE 51197#define CENTERJSAMPLE 2569899#endif /* BITS_IN_JSAMPLE == 9 */100101102#if BITS_IN_JSAMPLE == 10103/* JSAMPLE should be the smallest type that will hold the values 0..1023.104* On nearly all machines "short" will do nicely.105*/106107typedef short JSAMPLE;108#define GETJSAMPLE(value) ((int) (value))109110#define MAXJSAMPLE 1023111#define CENTERJSAMPLE 512112113#endif /* BITS_IN_JSAMPLE == 10 */114115116#if BITS_IN_JSAMPLE == 11117/* JSAMPLE should be the smallest type that will hold the values 0..2047.118* On nearly all machines "short" will do nicely.119*/120121typedef short JSAMPLE;122#define GETJSAMPLE(value) ((int) (value))123124#define MAXJSAMPLE 2047125#define CENTERJSAMPLE 1024126127#endif /* BITS_IN_JSAMPLE == 11 */128129130#if BITS_IN_JSAMPLE == 12131/* JSAMPLE should be the smallest type that will hold the values 0..4095.132* On nearly all machines "short" will do nicely.133*/134135typedef short JSAMPLE;136#define GETJSAMPLE(value) ((int) (value))137138#define MAXJSAMPLE 4095139#define CENTERJSAMPLE 2048140141#endif /* BITS_IN_JSAMPLE == 12 */142143144/* Representation of a DCT frequency coefficient.145* This should be a signed value of at least 16 bits; "short" is usually OK.146* Again, we allocate large arrays of these, but you can change to int147* if you have memory to burn and "short" is really slow.148*/149150typedef short JCOEF;151152153/* Compressed datastreams are represented as arrays of JOCTET.154* These must be EXACTLY 8 bits wide, at least once they are written to155* external storage. Note that when using the stdio data source/destination156* managers, this is also the data type passed to fread/fwrite.157*/158159#ifdef HAVE_UNSIGNED_CHAR160161typedef unsigned char JOCTET;162#define GETJOCTET(value) (value)163164#else /* not HAVE_UNSIGNED_CHAR */165166typedef char JOCTET;167#ifdef CHAR_IS_UNSIGNED168#define GETJOCTET(value) (value)169#else170#define GETJOCTET(value) ((value) & 0xFF)171#endif /* CHAR_IS_UNSIGNED */172173#endif /* HAVE_UNSIGNED_CHAR */174175176/* These typedefs are used for various table entries and so forth.177* They must be at least as wide as specified; but making them too big178* won't cost a huge amount of memory, so we don't provide special179* extraction code like we did for JSAMPLE. (In other words, these180* typedefs live at a different point on the speed/space tradeoff curve.)181*/182183/* UINT8 must hold at least the values 0..255. */184185#ifdef HAVE_UNSIGNED_CHAR186typedef unsigned char UINT8;187#else /* not HAVE_UNSIGNED_CHAR */188#ifdef CHAR_IS_UNSIGNED189typedef char UINT8;190#else /* not CHAR_IS_UNSIGNED */191typedef short UINT8;192#endif /* CHAR_IS_UNSIGNED */193#endif /* HAVE_UNSIGNED_CHAR */194195/* UINT16 must hold at least the values 0..65535. */196197#ifdef HAVE_UNSIGNED_SHORT198typedef unsigned short UINT16;199#else /* not HAVE_UNSIGNED_SHORT */200typedef unsigned int UINT16;201#endif /* HAVE_UNSIGNED_SHORT */202203/* INT16 must hold at least the values -32768..32767. */204205#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */206typedef short INT16;207#endif208209/* INT32 must hold at least signed 32-bit values. */210211#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */212#ifndef _BASETSD_H_ /* Microsoft defines it in basetsd.h */213#ifndef _BASETSD_H /* MinGW is slightly different */214#ifndef QGLOBAL_H /* Qt defines it in qglobal.h */215typedef long INT32;216#endif217#endif218#endif219#endif220221/* Datatype used for image dimensions. The JPEG standard only supports222* images up to 64K*64K due to 16-bit fields in SOF markers. Therefore223* "unsigned int" is sufficient on all machines. However, if you need to224* handle larger images and you don't mind deviating from the spec, you225* can change this datatype.226*/227228typedef unsigned int JDIMENSION;229230#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */231232233/* These macros are used in all function definitions and extern declarations.234* You could modify them if you need to change function linkage conventions;235* in particular, you'll need to do that to make the library a Windows DLL.236* Another application is to make all functions global for use with debuggers237* or code profilers that require it.238*/239240/* a function called through method pointers: */241#define METHODDEF(type) static type242/* a function used only in its module: */243#define LOCAL(type) static type244/* a function referenced thru EXTERNs: */245#define GLOBAL(type) type246/* a reference to a GLOBAL function: */247#define EXTERN(type) extern type248249250/* This macro is used to declare a "method", that is, a function pointer.251* We want to supply prototype parameters if the compiler can cope.252* Note that the arglist parameter must be parenthesized!253* Again, you can customize this if you need special linkage keywords.254*/255256#ifdef HAVE_PROTOTYPES257#define JMETHOD(type,methodname,arglist) type (*methodname) arglist258#else259#define JMETHOD(type,methodname,arglist) type (*methodname) ()260#endif261262263/* The noreturn type identifier is used to declare functions264* which cannot return.265* Compilers can thus create more optimized code and perform266* better checks for warnings and errors.267* Static analyzer tools can make improved inferences about268* execution paths and are prevented from giving false alerts.269*270* Unfortunately, the proposed specifications of corresponding271* extensions in the Dec 2011 ISO C standard revision (C11),272* GCC, MSVC, etc. are not viable.273* Thus we introduce a user defined type to declare noreturn274* functions at least for clarity. A proper compiler would275* have a suitable noreturn type to match in place of void.276*/277278#ifndef HAVE_NORETURN_T279typedef void noreturn_t;280#endif281282283/* Here is the pseudo-keyword for declaring pointers that must be "far"284* on 80x86 machines. Most of the specialized coding for 80x86 is handled285* by just saying "FAR *" where such a pointer is needed. In a few places286* explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol.287*/288289#ifndef FAR290#ifdef NEED_FAR_POINTERS291#define FAR far292#else293#define FAR294#endif295#endif296297298/*299* On a few systems, type boolean and/or its values FALSE, TRUE may appear300* in standard header files. Or you may have conflicts with application-301* specific header files that you want to include together with these files.302* Defining HAVE_BOOLEAN before including jpeglib.h should make it work.303*/304305#ifndef HAVE_BOOLEAN306#if defined FALSE || defined TRUE || defined QGLOBAL_H307/* Qt3 defines FALSE and TRUE as "const" variables in qglobal.h */308typedef int boolean;309#ifndef FALSE /* in case these macros already exist */310#define FALSE 0 /* values of boolean */311#endif312#ifndef TRUE313#define TRUE 1314#endif315#else316typedef enum { FALSE = 0, TRUE = 1 } boolean;317#endif318#endif319320321/*322* The remaining options affect code selection within the JPEG library,323* but they don't need to be visible to most applications using the library.324* To minimize application namespace pollution, the symbols won't be325* defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.326*/327328#ifdef JPEG_INTERNALS329#define JPEG_INTERNAL_OPTIONS330#endif331332#ifdef JPEG_INTERNAL_OPTIONS333334335/*336* These defines indicate whether to include various optional functions.337* Undefining some of these symbols will produce a smaller but less capable338* library. Note that you can leave certain source files out of the339* compilation/linking process if you've #undef'd the corresponding symbols.340* (You may HAVE to do that if your compiler doesn't like null source files.)341*/342343/* Capability options common to encoder and decoder: */344345#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */346#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */347#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */348349/* Encoder capability options: */350351#define C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */352#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */353#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN) */354#define DCT_SCALING_SUPPORTED /* Input rescaling via DCT? (Requires DCT_ISLOW) */355#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */356/* Note: if you selected more than 8-bit data precision, it is dangerous to357* turn off ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only358* good for 8-bit precision, so arithmetic coding is recommended for higher359* precision. The Huffman encoder normally uses entropy optimization to360* compute usable tables for higher precision. Otherwise, you'll have to361* supply different default Huffman tables.362* The exact same statements apply for progressive JPEG: the default tables363* don't work for progressive mode. (This may get fixed, however.)364*/365#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */366367/* Decoder capability options: */368369#define D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */370#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */371#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN) */372#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? (Requires DCT_ISLOW) */373#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */374#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */375#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */376#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */377#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */378#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */379380/* more capability options later, no doubt */381382383/*384* Ordering of RGB data in scanlines passed to or from the application.385* If your application wants to deal with data in the order B,G,R, just386* #define JPEG_USE_RGB_CUSTOM in jconfig.h, or define your own custom387* order in jconfig.h and #define JPEG_HAVE_RGB_CUSTOM.388* You can also deal with formats such as R,G,B,X (one extra byte per pixel)389* by changing RGB_PIXELSIZE.390* Note that changing the offsets will also change391* the order in which colormap data is organized.392* RESTRICTIONS:393* 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.394* 2. The color quantizer modules will not behave desirably if RGB_PIXELSIZE395* is not 3 (they don't understand about dummy color components!).396* So you can't use color quantization if you change that value.397*/398399#ifndef JPEG_HAVE_RGB_CUSTOM400#ifdef JPEG_USE_RGB_CUSTOM401#define RGB_RED 2 /* Offset of Red in an RGB scanline element */402#define RGB_GREEN 1 /* Offset of Green */403#define RGB_BLUE 0 /* Offset of Blue */404#else405#define RGB_RED 0 /* Offset of Red in an RGB scanline element */406#define RGB_GREEN 1 /* Offset of Green */407#define RGB_BLUE 2 /* Offset of Blue */408#endif409#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */410#endif411412413/* Definitions for speed-related optimizations. */414415416/* If your compiler supports inline functions, define INLINE417* as the inline keyword; otherwise define it as empty.418*/419420#ifndef INLINE421#ifdef __GNUC__ /* for instance, GNU C knows about inline */422#define INLINE __inline__423#endif424#ifndef INLINE425#define INLINE /* default is to define it as empty */426#endif427#endif428429430/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying431* two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER432* as short on such a machine. MULTIPLIER must be at least 16 bits wide.433*/434435#ifndef MULTIPLIER436#define MULTIPLIER int /* type for fastest integer multiply */437#endif438439440/* FAST_FLOAT should be either float or double, whichever is done faster441* by your compiler. (Note that this type is only used in the floating point442* DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)443* Typically, float is faster in ANSI C compilers, while double is faster in444* pre-ANSI compilers (because they insist on converting to double anyway).445* The code below therefore chooses float if we have ANSI-style prototypes.446*/447448#ifndef FAST_FLOAT449#ifdef HAVE_PROTOTYPES450#define FAST_FLOAT float451#else452#define FAST_FLOAT double453#endif454#endif455456#endif /* JPEG_INTERNAL_OPTIONS */457458459