00001 /* 00002 * jmorecfg.h 00003 * 00004 * Copyright (C) 1991-1997, Thomas G. Lane. 00005 * Modified 1997-2009 by Guido Vollbeding. 00006 * This file is part of the Independent JPEG Group's software. 00007 * For conditions of distribution and use, see the accompanying README file. 00008 * 00009 * This file contains additional configuration options that customize the 00010 * JPEG software for special applications or support machine-dependent 00011 * optimizations. Most users will not need to touch this file. 00012 */ 00013 00014 00015 /* 00016 * Define BITS_IN_JSAMPLE as either 00017 * 8 for 8-bit sample values (the usual setting) 00018 * 12 for 12-bit sample values 00019 * Only 8 and 12 are legal data precisions for lossy JPEG according to the 00020 * JPEG standard, and the IJG code does not support anything else! 00021 * We do not support run-time selection of data precision, sorry. 00022 */ 00023 00024 #define BITS_IN_JSAMPLE 8 /* use 8 or 12 */ 00025 00026 00027 /* 00028 * Maximum number of components (color channels) allowed in JPEG image. 00029 * To meet the letter of the JPEG spec, set this to 255. However, darn 00030 * few applications need more than 4 channels (maybe 5 for CMYK + alpha 00031 * mask). We recommend 10 as a reasonable compromise; use 4 if you are 00032 * really short on memory. (Each allowed component costs a hundred or so 00033 * bytes of storage, whether actually used in an image or not.) 00034 */ 00035 00036 #define MAX_COMPONENTS 10 /* maximum number of image components */ 00037 00038 00039 /* 00040 * Basic data types. 00041 * You may need to change these if you have a machine with unusual data 00042 * type sizes; for example, "char" not 8 bits, "short" not 16 bits, 00043 * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, 00044 * but it had better be at least 16. 00045 */ 00046 00047 /* Representation of a single sample (pixel element value). 00048 * We frequently allocate large arrays of these, so it's important to keep 00049 * them small. But if you have memory to burn and access to char or short 00050 * arrays is very slow on your hardware, you might want to change these. 00051 */ 00052 00053 #if BITS_IN_JSAMPLE == 8 00054 /* JSAMPLE should be the smallest type that will hold the values 0..255. 00055 * You can use a signed char by having GETJSAMPLE mask it with 0xFF. 00056 */ 00057 00058 #ifdef HAVE_UNSIGNED_CHAR 00059 00060 typedef unsigned char JSAMPLE; 00061 #define GETJSAMPLE(value) ((int) (value)) 00062 00063 #else /* not HAVE_UNSIGNED_CHAR */ 00064 00065 typedef char JSAMPLE; 00066 #ifdef CHAR_IS_UNSIGNED 00067 #define GETJSAMPLE(value) ((int) (value)) 00068 #else 00069 #define GETJSAMPLE(value) ((int) (value) & 0xFF) 00070 #endif /* CHAR_IS_UNSIGNED */ 00071 00072 #endif /* HAVE_UNSIGNED_CHAR */ 00073 00074 #define MAXJSAMPLE 255 00075 #define CENTERJSAMPLE 128 00076 00077 #endif /* BITS_IN_JSAMPLE == 8 */ 00078 00079 00080 #if BITS_IN_JSAMPLE == 12 00081 /* JSAMPLE should be the smallest type that will hold the values 0..4095. 00082 * On nearly all machines "short" will do nicely. 00083 */ 00084 00085 typedef short JSAMPLE; 00086 #define GETJSAMPLE(value) ((int) (value)) 00087 00088 #define MAXJSAMPLE 4095 00089 #define CENTERJSAMPLE 2048 00090 00091 #endif /* BITS_IN_JSAMPLE == 12 */ 00092 00093 00094 /* Representation of a DCT frequency coefficient. 00095 * This should be a signed value of at least 16 bits; "short" is usually OK. 00096 * Again, we allocate large arrays of these, but you can change to int 00097 * if you have memory to burn and "short" is really slow. 00098 */ 00099 00100 typedef short JCOEF; 00101 00102 00103 /* Compressed datastreams are represented as arrays of JOCTET. 00104 * These must be EXACTLY 8 bits wide, at least once they are written to 00105 * external storage. Note that when using the stdio data source/destination 00106 * managers, this is also the data type passed to fread/fwrite. 00107 */ 00108 00109 #ifdef HAVE_UNSIGNED_CHAR 00110 00111 typedef unsigned char JOCTET; 00112 #define GETJOCTET(value) (value) 00113 00114 #else /* not HAVE_UNSIGNED_CHAR */ 00115 00116 typedef char JOCTET; 00117 #ifdef CHAR_IS_UNSIGNED 00118 #define GETJOCTET(value) (value) 00119 #else 00120 #define GETJOCTET(value) ((value) & 0xFF) 00121 #endif /* CHAR_IS_UNSIGNED */ 00122 00123 #endif /* HAVE_UNSIGNED_CHAR */ 00124 00125 00126 /* These typedefs are used for various table entries and so forth. 00127 * They must be at least as wide as specified; but making them too big 00128 * won't cost a huge amount of memory, so we don't provide special 00129 * extraction code like we did for JSAMPLE. (In other words, these 00130 * typedefs live at a different point on the speed/space tradeoff curve.) 00131 */ 00132 00133 /* UINT8 must hold at least the values 0..255. */ 00134 00135 #ifdef HAVE_UNSIGNED_CHAR 00136 typedef unsigned char UINT8; 00137 #else /* not HAVE_UNSIGNED_CHAR */ 00138 #ifdef CHAR_IS_UNSIGNED 00139 typedef char UINT8; 00140 #else /* not CHAR_IS_UNSIGNED */ 00141 typedef short UINT8; 00142 #endif /* CHAR_IS_UNSIGNED */ 00143 #endif /* HAVE_UNSIGNED_CHAR */ 00144 00145 /* UINT16 must hold at least the values 0..65535. */ 00146 00147 #ifdef HAVE_UNSIGNED_SHORT 00148 typedef unsigned short UINT16; 00149 #else /* not HAVE_UNSIGNED_SHORT */ 00150 typedef unsigned int UINT16; 00151 #endif /* HAVE_UNSIGNED_SHORT */ 00152 00153 /* INT16 must hold at least the values -32768..32767. */ 00154 00155 #ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ 00156 typedef short INT16; 00157 #endif 00158 00159 /* INT32 must hold at least signed 32-bit values. */ 00160 00161 #ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ 00162 #ifndef _BASETSD_H_ /* Microsoft defines it in basetsd.h */ 00163 #ifndef _BASETSD_H /* MinGW is slightly different */ 00164 #ifndef QGLOBAL_H /* Qt defines it in qglobal.h */ 00165 typedef long INT32; 00166 #endif 00167 #endif 00168 #endif 00169 #endif 00170 00171 /* Datatype used for image dimensions. The JPEG standard only supports 00172 * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore 00173 * "unsigned int" is sufficient on all machines. However, if you need to 00174 * handle larger images and you don't mind deviating from the spec, you 00175 * can change this datatype. 00176 */ 00177 00178 typedef unsigned int JDIMENSION; 00179 00180 #define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ 00181 00182 00183 /* These macros are used in all function definitions and extern declarations. 00184 * You could modify them if you need to change function linkage conventions; 00185 * in particular, you'll need to do that to make the library a Windows DLL. 00186 * Another application is to make all functions global for use with debuggers 00187 * or code profilers that require it. 00188 */ 00189 00190 /* a function called through method pointers: */ 00191 #define METHODDEF(type) static type 00192 /* a function used only in its module: */ 00193 #define LOCAL(type) static type 00194 /* a function referenced thru EXTERNs: */ 00195 #define GLOBAL(type) type 00196 /* a reference to a GLOBAL function: */ 00197 #define EXTERN(type) extern type 00198 00199 00200 /* This macro is used to declare a "method", that is, a function pointer. 00201 * We want to supply prototype parameters if the compiler can cope. 00202 * Note that the arglist parameter must be parenthesized! 00203 * Again, you can customize this if you need special linkage keywords. 00204 */ 00205 00206 #ifdef HAVE_PROTOTYPES 00207 #define JMETHOD(type,methodname,arglist) type (*methodname) arglist 00208 #else 00209 #define JMETHOD(type,methodname,arglist) type (*methodname) () 00210 #endif 00211 00212 00213 /* Here is the pseudo-keyword for declaring pointers that must be "far" 00214 * on 80x86 machines. Most of the specialized coding for 80x86 is handled 00215 * by just saying "FAR *" where such a pointer is needed. In a few places 00216 * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. 00217 */ 00218 00219 #ifndef FAR 00220 #ifdef NEED_FAR_POINTERS 00221 #define FAR far 00222 #else 00223 #define FAR 00224 #endif 00225 #endif 00226 00227 00228 /* 00229 * On a few systems, type boolean and/or its values FALSE, TRUE may appear 00230 * in standard header files. Or you may have conflicts with application- 00231 * specific header files that you want to include together with these files. 00232 * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. 00233 */ 00234 00235 #ifndef HAVE_BOOLEAN 00236 typedef int boolean; 00237 #endif 00238 #ifndef FALSE /* in case these macros already exist */ 00239 #define FALSE 0 /* values of boolean */ 00240 #endif 00241 #ifndef TRUE 00242 #define TRUE 1 00243 #endif 00244 00245 00246 /* 00247 * The remaining options affect code selection within the JPEG library, 00248 * but they don't need to be visible to most applications using the library. 00249 * To minimize application namespace pollution, the symbols won't be 00250 * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. 00251 */ 00252 00253 #ifdef JPEG_INTERNALS 00254 #define JPEG_INTERNAL_OPTIONS 00255 #endif 00256 00257 #ifdef JPEG_INTERNAL_OPTIONS 00258 00259 00260 /* 00261 * These defines indicate whether to include various optional functions. 00262 * Undefining some of these symbols will produce a smaller but less capable 00263 * library. Note that you can leave certain source files out of the 00264 * compilation/linking process if you've #undef'd the corresponding symbols. 00265 * (You may HAVE to do that if your compiler doesn't like null source files.) 00266 */ 00267 00268 /* Capability options common to encoder and decoder: */ 00269 00270 #define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ 00271 #define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ 00272 #define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ 00273 00274 /* Encoder capability options: */ 00275 00276 #define C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ 00277 #define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ 00278 #define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ 00279 #define DCT_SCALING_SUPPORTED /* Input rescaling via DCT? (Requires DCT_ISLOW)*/ 00280 #define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ 00281 /* Note: if you selected 12-bit data precision, it is dangerous to turn off 00282 * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit 00283 * precision, so jchuff.c normally uses entropy optimization to compute 00284 * usable tables for higher precision. If you don't want to do optimization, 00285 * you'll have to supply different default Huffman tables. 00286 * The exact same statements apply for progressive JPEG: the default tables 00287 * don't work for progressive mode. (This may get fixed, however.) 00288 */ 00289 #define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ 00290 00291 /* Decoder capability options: */ 00292 00293 #define D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ 00294 #define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ 00295 #define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ 00296 #define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ 00297 #define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ 00298 #define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ 00299 #undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ 00300 #define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ 00301 #define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ 00302 #define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ 00303 00304 /* more capability options later, no doubt */ 00305 00306 00307 /* 00308 * Ordering of RGB data in scanlines passed to or from the application. 00309 * If your application wants to deal with data in the order B,G,R, just 00310 * change these macros. You can also deal with formats such as R,G,B,X 00311 * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing 00312 * the offsets will also change the order in which colormap data is organized. 00313 * RESTRICTIONS: 00314 * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. 00315 * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not 00316 * useful if you are using JPEG color spaces other than YCbCr or grayscale. 00317 * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE 00318 * is not 3 (they don't understand about dummy color components!). So you 00319 * can't use color quantization if you change that value. 00320 */ 00321 00322 #define RGB_RED 0 /* Offset of Red in an RGB scanline element */ 00323 #define RGB_GREEN 1 /* Offset of Green */ 00324 #define RGB_BLUE 2 /* Offset of Blue */ 00325 #define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ 00326 00327 00328 /* Definitions for speed-related optimizations. */ 00329 00330 00331 /* If your compiler supports inline functions, define INLINE 00332 * as the inline keyword; otherwise define it as empty. 00333 */ 00334 00335 #ifndef INLINE 00336 #ifdef __GNUC__ /* for instance, GNU C knows about inline */ 00337 #define INLINE __inline__ 00338 #endif 00339 #ifndef INLINE 00340 #define INLINE /* default is to define it as empty */ 00341 #endif 00342 #endif 00343 00344 00345 /* On some machines (notably 68000 series) "int" is 32 bits, but multiplying 00346 * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER 00347 * as short on such a machine. MULTIPLIER must be at least 16 bits wide. 00348 */ 00349 00350 #ifndef MULTIPLIER 00351 #define MULTIPLIER int /* type for fastest integer multiply */ 00352 #endif 00353 00354 00355 /* FAST_FLOAT should be either float or double, whichever is done faster 00356 * by your compiler. (Note that this type is only used in the floating point 00357 * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) 00358 * Typically, float is faster in ANSI C compilers, while double is faster in 00359 * pre-ANSI compilers (because they insist on converting to double anyway). 00360 * The code below therefore chooses float if we have ANSI-style prototypes. 00361 */ 00362 00363 #ifndef FAST_FLOAT 00364 #ifdef HAVE_PROTOTYPES 00365 #define FAST_FLOAT float 00366 #else 00367 #define FAST_FLOAT double 00368 #endif 00369 #endif 00370 00371 #endif /* JPEG_INTERNAL_OPTIONS */