dcmjpeg/libijg8/jmorecfg8.h

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


Generated on 6 Jan 2011 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.5.1