4 * Copyright (C) 1991-1997, Thomas G. Lane.
5 * This file is part of the Independent JPEG Group's software.
6 * For conditions of distribution and use, see the accompanying README file.
8 * This file contains additional configuration options that customize the
9 * JPEG software for special applications or support machine-dependent
10 * optimizations. Most users will not need to touch this file.
15 * Define BITS_IN_JSAMPLE as either
16 * 8 for 8-bit sample values (the usual setting)
17 * 12 for 12-bit sample values
18 * Only 8 and 12 are legal data precisions for lossy JPEG according to the
19 * JPEG standard, and the IJG code does not support anything else!
20 * We do not support run-time selection of data precision, sorry.
23 #define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
25 #if (defined (_MSC_VER) && (_MSC_VER >= 800))
26 #define HAVE_UNSIGNED_CHAR
28 #define EXTERN(type) extern type __cdecl
32 * Maximum number of components (color channels) allowed in JPEG image.
33 * To meet the letter of the JPEG spec, set this to 255. However, darn
34 * few applications need more than 4 channels (maybe 5 for CMYK + alpha
35 * mask). We recommend 10 as a reasonable compromise; use 4 if you are
36 * really short on memory. (Each allowed component costs a hundred or so
37 * bytes of storage, whether actually used in an image or not.)
40 #define MAX_COMPONENTS 10 /* maximum number of image components */
45 * You may need to change these if you have a machine with unusual data
46 * type sizes; for example, "char" not 8 bits, "short" not 16 bits,
47 * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits,
48 * but it had better be at least 16.
51 /* Representation of a single sample (pixel element value).
52 * We frequently allocate large arrays of these, so it's important to keep
53 * them small. But if you have memory to burn and access to char or short
54 * arrays is very slow on your hardware, you might want to change these.
57 #if BITS_IN_JSAMPLE == 8
58 /* JSAMPLE should be the smallest type that will hold the values 0..255.
59 * You can use a signed char by having GETJSAMPLE mask it with 0xFF.
62 #ifdef HAVE_UNSIGNED_CHAR
64 typedef unsigned char JSAMPLE
;
65 #define GETJSAMPLE(value) ((int) (value))
67 #else /* not HAVE_UNSIGNED_CHAR */
70 #ifdef CHAR_IS_UNSIGNED
71 #define GETJSAMPLE(value) ((int) (value))
73 #define GETJSAMPLE(value) ((int) (value) & 0xFF)
74 #endif /* CHAR_IS_UNSIGNED */
76 #endif /* HAVE_UNSIGNED_CHAR */
78 #define MAXJSAMPLE 255
79 #define CENTERJSAMPLE 128
81 #endif /* BITS_IN_JSAMPLE == 8 */
84 #if BITS_IN_JSAMPLE == 12
85 /* JSAMPLE should be the smallest type that will hold the values 0..4095.
86 * On nearly all machines "short" will do nicely.
89 typedef short JSAMPLE
;
90 #define GETJSAMPLE(value) ((int) (value))
92 #define MAXJSAMPLE 4095
93 #define CENTERJSAMPLE 2048
95 #endif /* BITS_IN_JSAMPLE == 12 */
98 /* Representation of a DCT frequency coefficient.
99 * This should be a signed value of at least 16 bits; "short" is usually OK.
100 * Again, we allocate large arrays of these, but you can change to int
101 * if you have memory to burn and "short" is really slow.
107 /* Compressed datastreams are represented as arrays of JOCTET.
108 * These must be EXACTLY 8 bits wide, at least once they are written to
109 * external storage. Note that when using the stdio data source/destination
110 * managers, this is also the data type passed to fread/fwrite.
113 #ifdef HAVE_UNSIGNED_CHAR
115 typedef unsigned char JOCTET
;
116 #define GETJOCTET(value) (value)
118 #else /* not HAVE_UNSIGNED_CHAR */
121 #ifdef CHAR_IS_UNSIGNED
122 #define GETJOCTET(value) (value)
124 #define GETJOCTET(value) ((value) & 0xFF)
125 #endif /* CHAR_IS_UNSIGNED */
127 #endif /* HAVE_UNSIGNED_CHAR */
130 /* These typedefs are used for various table entries and so forth.
131 * They must be at least as wide as specified; but making them too big
132 * won't cost a huge amount of memory, so we don't provide special
133 * extraction code like we did for JSAMPLE. (In other words, these
134 * typedefs live at a different point on the speed/space tradeoff curve.)
137 /* UINT8 must hold at least the values 0..255. */
138 #ifndef HAVE_ALL_INTS
140 #ifdef HAVE_UNSIGNED_CHAR
141 typedef unsigned char UINT8
;
142 #else /* not HAVE_UNSIGNED_CHAR */
143 #ifdef CHAR_IS_UNSIGNED
145 #else /* not CHAR_IS_UNSIGNED */
147 #endif /* CHAR_IS_UNSIGNED */
148 #endif /* HAVE_UNSIGNED_CHAR */
150 /* UINT16 must hold at least the values 0..65535. */
152 #ifdef HAVE_UNSIGNED_SHORT
153 typedef unsigned short UINT16
;
154 #else /* not HAVE_UNSIGNED_SHORT */
155 typedef unsigned int UINT16
;
156 #endif /* HAVE_UNSIGNED_SHORT */
158 /* INT16 must hold at least the values -32768..32767. */
160 #ifndef XMD_H /* X11/xmd.h correctly defines INT16 */
164 /* INT32 must hold at least signed 32-bit values. */
166 #if !defined(XMD_H) && !defined(_WIN32) /* X11/xmd.h correctly defines INT32 */
170 #endif /* HAVE_ALL_INTS */
172 /* Datatype used for image dimensions. The JPEG standard only supports
173 * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
174 * "unsigned int" is sufficient on all machines. However, if you need to
175 * handle larger images and you don't mind deviating from the spec, you
176 * can change this datatype.
179 typedef unsigned int JDIMENSION
;
181 #define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */
184 /* These macros are used in all function definitions and extern declarations.
185 * You could modify them if you need to change function linkage conventions;
186 * in particular, you'll need to do that to make the library a Windows DLL.
187 * Another application is to make all functions global for use with debuggers
188 * or code profilers that require it.
192 # if defined(ALL_STATIC)
193 # if defined(JPEG_DLL)
196 # if !defined(JPEG_STATIC)
200 # if defined(JPEG_DLL)
201 # if defined(JPEG_STATIC)
205 # if defined(JPEG_DLL)
207 # define JPEG_IMPEXP __declspec(dllexport)
208 # elif defined(JPEG_STATIC)
209 /* building or linking to a static library */
212 /* linking to the DLL */
213 # define JPEG_IMPEXP __declspec(dllimport)
215 # if !defined(JPEG_API)
216 # define JPEG_API __cdecl
218 /* The only remaining magic that is necessary for cygwin */
219 #elif defined(__CYGWIN__)
220 # if !defined(JPEG_IMPEXP)
223 # if !defined(JPEG_API)
224 # define JPEG_API __cdecl
228 /* Ensure our magic doesn't hurt other platforms */
229 #if !defined(JPEG_IMPEXP)
232 #if !defined(JPEG_API)
236 /* a function called through method pointers: */
237 #define METHODDEF(type) static type
238 /* a function used only in its module: */
239 #define LOCAL(type) static type
240 /* a function referenced thru EXTERNs: */
241 #define GLOBAL(type) type JPEG_API
242 /* a reference to a GLOBAL function: */
244 # define EXTERN(type) extern JPEG_IMPEXP type JPEG_API
245 /* a reference to a "GLOBAL" function exported by sourcefiles of utility progs */
247 #define EXTERN_1(type) extern type JPEG_API
250 /* This macro is used to declare a "method", that is, a function pointer.
251 * We want to supply prototype parameters if the compiler can cope.
252 * Note that the arglist parameter must be parenthesized!
253 * Again, you can customize this if you need special linkage keywords.
256 #ifdef HAVE_PROTOTYPES
257 #define JMETHOD(type,methodname,arglist) type (*methodname) arglist
259 #define JMETHOD(type,methodname,arglist) type (*methodname) ()
263 /* Here is the pseudo-keyword for declaring pointers that must be "far"
264 * on 80x86 machines. Most of the specialized coding for 80x86 is handled
265 * by just saying "FAR *" where such a pointer is needed. In a few places
266 * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol.
269 /* jmorecfg.h line 220 */
270 /* HJH modification: several of the windows header files already define FAR
271 because of this, the code below was changed so that it only tinkers with
272 the FAR define if FAR is still undefined */
274 #ifdef NEED_FAR_POINTERS
283 * On a few systems, type boolean and/or its values FALSE, TRUE may appear
284 * in standard header files. Or you may have conflicts with application-
285 * specific header files that you want to include together with these files.
286 * Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
292 #ifndef FALSE /* in case these macros already exist */
293 #define FALSE 0 /* values of boolean */
301 * The remaining options affect code selection within the JPEG library,
302 * but they don't need to be visible to most applications using the library.
303 * To minimize application namespace pollution, the symbols won't be
304 * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.
307 #ifdef JPEG_INTERNALS
308 #define JPEG_INTERNAL_OPTIONS
311 #ifdef JPEG_INTERNAL_OPTIONS
315 * These defines indicate whether to include various optional functions.
316 * Undefining some of these symbols will produce a smaller but less capable
317 * library. Note that you can leave certain source files out of the
318 * compilation/linking process if you've #undef'd the corresponding symbols.
319 * (You may HAVE to do that if your compiler doesn't like null source files.)
322 /* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */
324 /* Capability options common to encoder and decoder: */
326 #define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */
327 #define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */
328 #define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */
330 /* Encoder capability options: */
332 #undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
333 #define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
334 #define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
335 #define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
336 /* Note: if you selected 12-bit data precision, it is dangerous to turn off
337 * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit
338 * precision, so jchuff.c normally uses entropy optimization to compute
339 * usable tables for higher precision. If you don't want to do optimization,
340 * you'll have to supply different default Huffman tables.
341 * The exact same statements apply for progressive JPEG: the default tables
342 * don't work for progressive mode. (This may get fixed, however.)
344 #define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */
346 /* Decoder capability options: */
348 #undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
349 #define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
350 #define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
351 #define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
352 #define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
353 #define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */
354 #undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
355 #define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */
356 #define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */
357 #define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */
359 /* more capability options later, no doubt */
363 * Ordering of RGB data in scanlines passed to or from the application.
364 * If your application wants to deal with data in the order B,G,R, just
365 * change these macros. You can also deal with formats such as R,G,B,X
366 * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing
367 * the offsets will also change the order in which colormap data is organized.
369 * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.
370 * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not
371 * useful if you are using JPEG color spaces other than YCbCr or grayscale.
372 * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
373 * is not 3 (they don't understand about dummy color components!). So you
374 * can't use color quantization if you change that value.
377 #define RGB_RED 0 /* Offset of Red in an RGB scanline element */
378 #define RGB_GREEN 1 /* Offset of Green */
379 #define RGB_BLUE 2 /* Offset of Blue */
380 #define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
383 /* Definitions for speed-related optimizations. */
386 /* If your compiler supports inline functions, define INLINE
387 * as the inline keyword; otherwise define it as empty.
391 #ifdef __GNUC__ /* for instance, GNU C knows about inline */
392 #define INLINE __inline__
395 #define INLINE /* default is to define it as empty */
400 /* On some machines (notably 68000 series) "int" is 32 bits, but multiplying
401 * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER
402 * as short on such a machine. MULTIPLIER must be at least 16 bits wide.
406 #define MULTIPLIER int /* type for fastest integer multiply */
410 /* FAST_FLOAT should be either float or double, whichever is done faster
411 * by your compiler. (Note that this type is only used in the floating point
412 * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)
413 * Typically, float is faster in ANSI C compilers, while double is faster in
414 * pre-ANSI compilers (because they insist on converting to double anyway).
415 * The code below therefore chooses float if we have ANSI-style prototypes.
419 #ifdef HAVE_PROTOTYPES
420 #define FAST_FLOAT float
422 #define FAST_FLOAT double
426 #endif /* JPEG_INTERNAL_OPTIONS */