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