Back to index

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