|
||||
File indexing completed on 2024-05-18 08:30:04
0001 /* 0002 * jmorecfg.h 0003 * 0004 * Copyright (C) 1991-1997, Thomas G. Lane. 0005 * Modified 1997-2013 by Guido Vollbeding. 0006 * This file is part of the Independent JPEG Group's software. 0007 * For conditions of distribution and use, see the accompanying README file. 0008 * 0009 * This file contains additional configuration options that customize the 0010 * JPEG software for special applications or support machine-dependent 0011 * optimizations. Most users will not need to touch this file. 0012 */ 0013 0014 0015 /* 0016 * Define BITS_IN_JSAMPLE as either 0017 * 8 for 8-bit sample values (the usual setting) 0018 * 9 for 9-bit sample values 0019 * 10 for 10-bit sample values 0020 * 11 for 11-bit sample values 0021 * 12 for 12-bit sample values 0022 * Only 8, 9, 10, 11, and 12 bits sample data precision are supported for 0023 * full-feature DCT processing. Further depths up to 16-bit may be added 0024 * later for the lossless modes of operation. 0025 * Run-time selection and conversion of data precision will be added later 0026 * and are currently not supported, sorry. 0027 * Exception: The transcoding part (jpegtran) supports all settings in a 0028 * single instance, since it operates on the level of DCT coefficients and 0029 * not sample values. The DCT coefficients are of the same type (16 bits) 0030 * in all cases (see below). 0031 */ 0032 0033 #define BITS_IN_JSAMPLE 8 /* use 8, 9, 10, 11, or 12 */ 0034 0035 0036 /* 0037 * Maximum number of components (color channels) allowed in JPEG image. 0038 * To meet the letter of the JPEG spec, set this to 255. However, darn 0039 * few applications need more than 4 channels (maybe 5 for CMYK + alpha 0040 * mask). We recommend 10 as a reasonable compromise; use 4 if you are 0041 * really short on memory. (Each allowed component costs a hundred or so 0042 * bytes of storage, whether actually used in an image or not.) 0043 */ 0044 0045 #define MAX_COMPONENTS 10 /* maximum number of image components */ 0046 0047 0048 /* 0049 * Basic data types. 0050 * You may need to change these if you have a machine with unusual data 0051 * type sizes; for example, "char" not 8 bits, "short" not 16 bits, 0052 * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, 0053 * but it had better be at least 16. 0054 */ 0055 0056 /* Representation of a single sample (pixel element value). 0057 * We frequently allocate large arrays of these, so it's important to keep 0058 * them small. But if you have memory to burn and access to char or short 0059 * arrays is very slow on your hardware, you might want to change these. 0060 */ 0061 0062 #if BITS_IN_JSAMPLE == 8 0063 /* JSAMPLE should be the smallest type that will hold the values 0..255. 0064 * You can use a signed char by having GETJSAMPLE mask it with 0xFF. 0065 */ 0066 0067 #ifdef HAVE_UNSIGNED_CHAR 0068 0069 typedef unsigned char JSAMPLE; 0070 #define GETJSAMPLE(value) ((int) (value)) 0071 0072 #else /* not HAVE_UNSIGNED_CHAR */ 0073 0074 typedef char JSAMPLE; 0075 #ifdef CHAR_IS_UNSIGNED 0076 #define GETJSAMPLE(value) ((int) (value)) 0077 #else 0078 #define GETJSAMPLE(value) ((int) (value) & 0xFF) 0079 #endif /* CHAR_IS_UNSIGNED */ 0080 0081 #endif /* HAVE_UNSIGNED_CHAR */ 0082 0083 #define MAXJSAMPLE 255 0084 #define CENTERJSAMPLE 128 0085 0086 #endif /* BITS_IN_JSAMPLE == 8 */ 0087 0088 0089 #if BITS_IN_JSAMPLE == 9 0090 /* JSAMPLE should be the smallest type that will hold the values 0..511. 0091 * On nearly all machines "short" will do nicely. 0092 */ 0093 0094 typedef short JSAMPLE; 0095 #define GETJSAMPLE(value) ((int) (value)) 0096 0097 #define MAXJSAMPLE 511 0098 #define CENTERJSAMPLE 256 0099 0100 #endif /* BITS_IN_JSAMPLE == 9 */ 0101 0102 0103 #if BITS_IN_JSAMPLE == 10 0104 /* JSAMPLE should be the smallest type that will hold the values 0..1023. 0105 * On nearly all machines "short" will do nicely. 0106 */ 0107 0108 typedef short JSAMPLE; 0109 #define GETJSAMPLE(value) ((int) (value)) 0110 0111 #define MAXJSAMPLE 1023 0112 #define CENTERJSAMPLE 512 0113 0114 #endif /* BITS_IN_JSAMPLE == 10 */ 0115 0116 0117 #if BITS_IN_JSAMPLE == 11 0118 /* JSAMPLE should be the smallest type that will hold the values 0..2047. 0119 * On nearly all machines "short" will do nicely. 0120 */ 0121 0122 typedef short JSAMPLE; 0123 #define GETJSAMPLE(value) ((int) (value)) 0124 0125 #define MAXJSAMPLE 2047 0126 #define CENTERJSAMPLE 1024 0127 0128 #endif /* BITS_IN_JSAMPLE == 11 */ 0129 0130 0131 #if BITS_IN_JSAMPLE == 12 0132 /* JSAMPLE should be the smallest type that will hold the values 0..4095. 0133 * On nearly all machines "short" will do nicely. 0134 */ 0135 0136 typedef short JSAMPLE; 0137 #define GETJSAMPLE(value) ((int) (value)) 0138 0139 #define MAXJSAMPLE 4095 0140 #define CENTERJSAMPLE 2048 0141 0142 #endif /* BITS_IN_JSAMPLE == 12 */ 0143 0144 0145 /* Representation of a DCT frequency coefficient. 0146 * This should be a signed value of at least 16 bits; "short" is usually OK. 0147 * Again, we allocate large arrays of these, but you can change to int 0148 * if you have memory to burn and "short" is really slow. 0149 */ 0150 0151 typedef short JCOEF; 0152 0153 0154 /* Compressed datastreams are represented as arrays of JOCTET. 0155 * These must be EXACTLY 8 bits wide, at least once they are written to 0156 * external storage. Note that when using the stdio data source/destination 0157 * managers, this is also the data type passed to fread/fwrite. 0158 */ 0159 0160 #ifdef HAVE_UNSIGNED_CHAR 0161 0162 typedef unsigned char JOCTET; 0163 #define GETJOCTET(value) (value) 0164 0165 #else /* not HAVE_UNSIGNED_CHAR */ 0166 0167 typedef char JOCTET; 0168 #ifdef CHAR_IS_UNSIGNED 0169 #define GETJOCTET(value) (value) 0170 #else 0171 #define GETJOCTET(value) ((value) & 0xFF) 0172 #endif /* CHAR_IS_UNSIGNED */ 0173 0174 #endif /* HAVE_UNSIGNED_CHAR */ 0175 0176 0177 /* These typedefs are used for various table entries and so forth. 0178 * They must be at least as wide as specified; but making them too big 0179 * won't cost a huge amount of memory, so we don't provide special 0180 * extraction code like we did for JSAMPLE. (In other words, these 0181 * typedefs live at a different point on the speed/space tradeoff curve.) 0182 */ 0183 0184 /* UINT8 must hold at least the values 0..255. */ 0185 0186 #ifdef HAVE_UNSIGNED_CHAR 0187 typedef unsigned char UINT8; 0188 #else /* not HAVE_UNSIGNED_CHAR */ 0189 #ifdef CHAR_IS_UNSIGNED 0190 typedef char UINT8; 0191 #else /* not CHAR_IS_UNSIGNED */ 0192 typedef short UINT8; 0193 #endif /* CHAR_IS_UNSIGNED */ 0194 #endif /* HAVE_UNSIGNED_CHAR */ 0195 0196 /* UINT16 must hold at least the values 0..65535. */ 0197 0198 #ifdef HAVE_UNSIGNED_SHORT 0199 typedef unsigned short UINT16; 0200 #else /* not HAVE_UNSIGNED_SHORT */ 0201 typedef unsigned int UINT16; 0202 #endif /* HAVE_UNSIGNED_SHORT */ 0203 0204 /* INT16 must hold at least the values -32768..32767. */ 0205 0206 #ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ 0207 typedef short INT16; 0208 #endif 0209 0210 /* INT32 must hold at least signed 32-bit values. */ 0211 0212 #ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ 0213 #ifndef _BASETSD_H_ /* Microsoft defines it in basetsd.h */ 0214 #ifndef _BASETSD_H /* MinGW is slightly different */ 0215 #ifndef QGLOBAL_H /* Qt defines it in qglobal.h */ 0216 typedef long INT32; 0217 #endif 0218 #endif 0219 #endif 0220 #endif 0221 0222 /* Datatype used for image dimensions. The JPEG standard only supports 0223 * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore 0224 * "unsigned int" is sufficient on all machines. However, if you need to 0225 * handle larger images and you don't mind deviating from the spec, you 0226 * can change this datatype. 0227 */ 0228 0229 typedef unsigned int JDIMENSION; 0230 0231 #define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ 0232 0233 0234 /* These macros are used in all function definitions and extern declarations. 0235 * You could modify them if you need to change function linkage conventions; 0236 * in particular, you'll need to do that to make the library a Windows DLL. 0237 * Another application is to make all functions global for use with debuggers 0238 * or code profilers that require it. 0239 */ 0240 0241 /* a function called through method pointers: */ 0242 #define METHODDEF(type) static type 0243 /* a function used only in its module: */ 0244 #define LOCAL(type) static type 0245 /* a function referenced thru EXTERNs: */ 0246 #define GLOBAL(type) type 0247 /* a reference to a GLOBAL function: */ 0248 #define EXTERN(type) extern type 0249 0250 0251 /* This macro is used to declare a "method", that is, a function pointer. 0252 * We want to supply prototype parameters if the compiler can cope. 0253 * Note that the arglist parameter must be parenthesized! 0254 * Again, you can customize this if you need special linkage keywords. 0255 */ 0256 0257 #ifdef HAVE_PROTOTYPES 0258 #define JMETHOD(type,methodname,arglist) type (*methodname) arglist 0259 #else 0260 #define JMETHOD(type,methodname,arglist) type (*methodname) () 0261 #endif 0262 0263 0264 /* The noreturn type identifier is used to declare functions 0265 * which cannot return. 0266 * Compilers can thus create more optimized code and perform 0267 * better checks for warnings and errors. 0268 * Static analyzer tools can make improved inferences about 0269 * execution paths and are prevented from giving false alerts. 0270 * 0271 * Unfortunately, the proposed specifications of corresponding 0272 * extensions in the Dec 2011 ISO C standard revision (C11), 0273 * GCC, MSVC, etc. are not viable. 0274 * Thus we introduce a user defined type to declare noreturn 0275 * functions at least for clarity. A proper compiler would 0276 * have a suitable noreturn type to match in place of void. 0277 */ 0278 0279 #ifndef HAVE_NORETURN_T 0280 typedef void noreturn_t; 0281 #endif 0282 0283 0284 /* Here is the pseudo-keyword for declaring pointers that must be "far" 0285 * on 80x86 machines. Most of the specialized coding for 80x86 is handled 0286 * by just saying "FAR *" where such a pointer is needed. In a few places 0287 * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. 0288 */ 0289 0290 #ifndef FAR 0291 #ifdef NEED_FAR_POINTERS 0292 #define FAR far 0293 #else 0294 #define FAR 0295 #endif 0296 #endif 0297 0298 0299 /* 0300 * On a few systems, type boolean and/or its values FALSE, TRUE may appear 0301 * in standard header files. Or you may have conflicts with application- 0302 * specific header files that you want to include together with these files. 0303 * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. 0304 */ 0305 0306 #ifndef HAVE_BOOLEAN 0307 #if defined FALSE || defined TRUE || defined QGLOBAL_H 0308 /* Qt3 defines FALSE and TRUE as "const" variables in qglobal.h */ 0309 typedef int boolean; 0310 #ifndef FALSE /* in case these macros already exist */ 0311 #define FALSE 0 /* values of boolean */ 0312 #endif 0313 #ifndef TRUE 0314 #define TRUE 1 0315 #endif 0316 #else 0317 typedef enum { FALSE = 0, TRUE = 1 } boolean; 0318 #endif 0319 #endif 0320 0321 0322 /* 0323 * The remaining options affect code selection within the JPEG library, 0324 * but they don't need to be visible to most applications using the library. 0325 * To minimize application namespace pollution, the symbols won't be 0326 * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. 0327 */ 0328 0329 #ifdef JPEG_INTERNALS 0330 #define JPEG_INTERNAL_OPTIONS 0331 #endif 0332 0333 #ifdef JPEG_INTERNAL_OPTIONS 0334 0335 0336 /* 0337 * These defines indicate whether to include various optional functions. 0338 * Undefining some of these symbols will produce a smaller but less capable 0339 * library. Note that you can leave certain source files out of the 0340 * compilation/linking process if you've #undef'd the corresponding symbols. 0341 * (You may HAVE to do that if your compiler doesn't like null source files.) 0342 */ 0343 0344 /* Capability options common to encoder and decoder: */ 0345 0346 #define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ 0347 #define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ 0348 #define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ 0349 0350 /* Encoder capability options: */ 0351 0352 #define C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ 0353 #define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ 0354 #define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ 0355 #define DCT_SCALING_SUPPORTED /* Input rescaling via DCT? (Requires DCT_ISLOW)*/ 0356 #define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ 0357 /* Note: if you selected more than 8-bit data precision, it is dangerous to 0358 * turn off ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only 0359 * good for 8-bit precision, so arithmetic coding is recommended for higher 0360 * precision. The Huffman encoder normally uses entropy optimization to 0361 * compute usable tables for higher precision. Otherwise, you'll have to 0362 * supply different default Huffman tables. 0363 * The exact same statements apply for progressive JPEG: the default tables 0364 * don't work for progressive mode. (This may get fixed, however.) 0365 */ 0366 #define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ 0367 0368 /* Decoder capability options: */ 0369 0370 #define D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ 0371 #define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ 0372 #define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ 0373 #define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? (Requires DCT_ISLOW)*/ 0374 #define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ 0375 #define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ 0376 #undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ 0377 #define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ 0378 #define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ 0379 #define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ 0380 0381 /* more capability options later, no doubt */ 0382 0383 0384 /* 0385 * Ordering of RGB data in scanlines passed to or from the application. 0386 * If your application wants to deal with data in the order B,G,R, just 0387 * change these macros. You can also deal with formats such as R,G,B,X 0388 * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing 0389 * the offsets will also change the order in which colormap data is organized. 0390 * RESTRICTIONS: 0391 * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. 0392 * 2. The color quantizer modules will not behave desirably if RGB_PIXELSIZE 0393 * is not 3 (they don't understand about dummy color components!). So you 0394 * can't use color quantization if you change that value. 0395 */ 0396 0397 #define RGB_RED 0 /* Offset of Red in an RGB scanline element */ 0398 #define RGB_GREEN 1 /* Offset of Green */ 0399 #define RGB_BLUE 2 /* Offset of Blue */ 0400 #define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ 0401 0402 0403 /* Definitions for speed-related optimizations. */ 0404 0405 0406 /* If your compiler supports inline functions, define INLINE 0407 * as the inline keyword; otherwise define it as empty. 0408 */ 0409 0410 #ifndef INLINE 0411 #ifdef __GNUC__ /* for instance, GNU C knows about inline */ 0412 #define INLINE __inline__ 0413 #endif 0414 #ifndef INLINE 0415 #define INLINE /* default is to define it as empty */ 0416 #endif 0417 #endif 0418 0419 0420 /* On some machines (notably 68000 series) "int" is 32 bits, but multiplying 0421 * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER 0422 * as short on such a machine. MULTIPLIER must be at least 16 bits wide. 0423 */ 0424 0425 #ifndef MULTIPLIER 0426 #define MULTIPLIER int /* type for fastest integer multiply */ 0427 #endif 0428 0429 0430 /* FAST_FLOAT should be either float or double, whichever is done faster 0431 * by your compiler. (Note that this type is only used in the floating point 0432 * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) 0433 * Typically, float is faster in ANSI C compilers, while double is faster in 0434 * pre-ANSI compilers (because they insist on converting to double anyway). 0435 * The code below therefore chooses float if we have ANSI-style prototypes. 0436 */ 0437 0438 #ifndef FAST_FLOAT 0439 #ifdef HAVE_PROTOTYPES 0440 #define FAST_FLOAT float 0441 #else 0442 #define FAST_FLOAT double 0443 #endif 0444 #endif 0445 0446 #endif /* JPEG_INTERNAL_OPTIONS */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.5 LXR engine. The LXR team |