2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: jmorecfg.h /main/2 1996/05/09 03:53:12 drk $ */
27 * Copyright (C) 1991-1996, Thomas G. Lane.
28 * This file is part of the Independent JPEG Group's software.
29 * For conditions of distribution and use, see the accompanying README file.
31 * This file contains additional configuration options that customize the
32 * JPEG software for special applications or support machine-dependent
33 * optimizations. Most users will not need to touch this file.
38 * Define BITS_IN_JSAMPLE as either
39 * 8 for 8-bit sample values (the usual setting)
40 * 12 for 12-bit sample values
41 * Only 8 and 12 are legal data precisions for lossy JPEG according to the
42 * JPEG standard, and the IJG code does not support anything else!
43 * We do not support run-time selection of data precision, sorry.
46 #define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
50 * Maximum number of components (color channels) allowed in JPEG image.
51 * To meet the letter of the JPEG spec, set this to 255. However, darn
52 * few applications need more than 4 channels (maybe 5 for CMYK + alpha
53 * mask). We recommend 10 as a reasonable compromise; use 4 if you are
54 * really short on memory. (Each allowed component costs a hundred or so
55 * bytes of storage, whether actually used in an image or not.)
58 #define MAX_COMPONENTS 10 /* maximum number of image components */
63 * You may need to change these if you have a machine with unusual data
64 * type sizes; for example, "char" not 8 bits, "short" not 16 bits,
65 * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits,
66 * but it had better be at least 16.
69 /* Representation of a single sample (pixel element value).
70 * We frequently allocate large arrays of these, so it's important to keep
71 * them small. But if you have memory to burn and access to char or short
72 * arrays is very slow on your hardware, you might want to change these.
75 #if BITS_IN_JSAMPLE == 8
76 /* JSAMPLE should be the smallest type that will hold the values 0..255.
77 * You can use a signed char by having GETJSAMPLE mask it with 0xFF.
80 #ifdef HAVE_UNSIGNED_CHAR
82 typedef unsigned char JSAMPLE;
83 #define GETJSAMPLE(value) ((int) (value))
85 #else /* not HAVE_UNSIGNED_CHAR */
88 #ifdef CHAR_IS_UNSIGNED
89 #define GETJSAMPLE(value) ((int) (value))
91 #define GETJSAMPLE(value) ((int) (value) & 0xFF)
92 #endif /* CHAR_IS_UNSIGNED */
94 #endif /* HAVE_UNSIGNED_CHAR */
96 #define MAXJSAMPLE 255
97 #define CENTERJSAMPLE 128
99 #endif /* BITS_IN_JSAMPLE == 8 */
102 #if BITS_IN_JSAMPLE == 12
103 /* JSAMPLE should be the smallest type that will hold the values 0..4095.
104 * On nearly all machines "short" will do nicely.
107 typedef short JSAMPLE;
108 #define GETJSAMPLE(value) ((int) (value))
110 #define MAXJSAMPLE 4095
111 #define CENTERJSAMPLE 2048
113 #endif /* BITS_IN_JSAMPLE == 12 */
116 /* Representation of a DCT frequency coefficient.
117 * This should be a signed value of at least 16 bits; "short" is usually OK.
118 * Again, we allocate large arrays of these, but you can change to int
119 * if you have memory to burn and "short" is really slow.
125 /* Compressed datastreams are represented as arrays of JOCTET.
126 * These must be EXACTLY 8 bits wide, at least once they are written to
127 * external storage. Note that when using the stdio data source/destination
128 * managers, this is also the data type passed to fread/fwrite.
131 #ifdef HAVE_UNSIGNED_CHAR
133 typedef unsigned char JOCTET;
134 #define GETJOCTET(value) (value)
136 #else /* not HAVE_UNSIGNED_CHAR */
139 #ifdef CHAR_IS_UNSIGNED
140 #define GETJOCTET(value) (value)
142 #define GETJOCTET(value) ((value) & 0xFF)
143 #endif /* CHAR_IS_UNSIGNED */
145 #endif /* HAVE_UNSIGNED_CHAR */
148 /* These typedefs are used for various table entries and so forth.
149 * They must be at least as wide as specified; but making them too big
150 * won't cost a huge amount of memory, so we don't provide special
151 * extraction code like we did for JSAMPLE. (In other words, these
152 * typedefs live at a different point on the speed/space tradeoff curve.)
155 /* UINT8 must hold at least the values 0..255. */
157 #ifdef HAVE_UNSIGNED_CHAR
158 typedef unsigned char UINT8;
159 #else /* not HAVE_UNSIGNED_CHAR */
160 #ifdef CHAR_IS_UNSIGNED
162 #else /* not CHAR_IS_UNSIGNED */
164 #endif /* CHAR_IS_UNSIGNED */
165 #endif /* HAVE_UNSIGNED_CHAR */
167 /* UINT16 must hold at least the values 0..65535. */
169 #ifdef HAVE_UNSIGNED_SHORT
170 typedef unsigned short UINT16;
171 #else /* not HAVE_UNSIGNED_SHORT */
172 typedef unsigned int UINT16;
173 #endif /* HAVE_UNSIGNED_SHORT */
175 /* INT16 must hold at least the values -32768..32767. */
177 #ifndef XMD_H /* X11/xmd.h correctly defines INT16 */
181 /* INT32 must hold at least signed 32-bit values. */
183 #ifndef XMD_H /* X11/xmd.h correctly defines INT32 */
187 /* Datatype used for image dimensions. The JPEG standard only supports
188 * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
189 * "unsigned int" is sufficient on all machines. However, if you need to
190 * handle larger images and you don't mind deviating from the spec, you
191 * can change this datatype.
194 typedef unsigned int JDIMENSION;
196 #define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */
199 /* These macros are used in all function definitions and extern declarations.
200 * You could modify them if you need to change function linkage conventions;
201 * in particular, you'll need to do that to make the library a Windows DLL.
202 * Another application is to make all functions global for use with debuggers
203 * or code profilers that require it.
206 /* a function called through method pointers: */
207 #define METHODDEF(type) static type
208 /* a function used only in its module: */
209 #define LOCAL(type) static type
210 /* a function referenced thru EXTERNs: */
211 #define GLOBAL(type) type
212 /* a reference to a GLOBAL function: */
213 #define EXTERN(type) extern type
216 /* This macro is used to declare a "method", that is, a function pointer.
217 * We want to supply prototype parameters if the compiler can cope.
218 * Note that the arglist parameter must be parenthesized!
219 * Again, you can customize this if you need special linkage keywords.
222 #ifdef HAVE_PROTOTYPES
223 #define JMETHOD(type,methodname,arglist) type (*methodname) arglist
225 #define JMETHOD(type,methodname,arglist) type (*methodname) ()
229 /* Here is the pseudo-keyword for declaring pointers that must be "far"
230 * on 80x86 machines. Most of the specialized coding for 80x86 is handled
231 * by just saying "FAR *" where such a pointer is needed. In a few places
232 * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol.
235 #ifdef NEED_FAR_POINTERS
243 * On a few systems, type boolean and/or its values FALSE, TRUE may appear
244 * in standard header files. Or you may have conflicts with application-
245 * specific header files that you want to include together with these files.
246 * Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
252 #ifndef FALSE /* in case these macros already exist */
253 #define FALSE 0 /* values of boolean */
261 * The remaining options affect code selection within the JPEG library,
262 * but they don't need to be visible to most applications using the library.
263 * To minimize application namespace pollution, the symbols won't be
264 * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.
267 #ifdef JPEG_INTERNALS
268 #define JPEG_INTERNAL_OPTIONS
271 #ifdef JPEG_INTERNAL_OPTIONS
275 * These defines indicate whether to include various optional functions.
276 * Undefining some of these symbols will produce a smaller but less capable
277 * library. Note that you can leave certain source files out of the
278 * compilation/linking process if you've #undef'd the corresponding symbols.
279 * (You may HAVE to do that if your compiler doesn't like null source files.)
282 /* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */
284 /* Capability options common to encoder and decoder: */
286 #define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */
287 #define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */
288 #define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */
290 /* Encoder capability options: */
292 #undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
293 #define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
294 #define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
295 #define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
296 /* Note: if you selected 12-bit data precision, it is dangerous to turn off
297 * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit
298 * precision, so jchuff.c normally uses entropy optimization to compute
299 * usable tables for higher precision. If you don't want to do optimization,
300 * you'll have to supply different default Huffman tables.
301 * The exact same statements apply for progressive JPEG: the default tables
302 * don't work for progressive mode. (This may get fixed, however.)
304 #define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */
306 /* Decoder capability options: */
308 #undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
309 #define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
310 #define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
311 #define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
312 #define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */
313 #undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
314 #define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */
315 #define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */
316 #define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */
318 /* more capability options later, no doubt */
322 * Ordering of RGB data in scanlines passed to or from the application.
323 * If your application wants to deal with data in the order B,G,R, just
324 * change these macros. You can also deal with formats such as R,G,B,X
325 * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing
326 * the offsets will also change the order in which colormap data is organized.
328 * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.
329 * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not
330 * useful if you are using JPEG color spaces other than YCbCr or grayscale.
331 * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
332 * is not 3 (they don't understand about dummy color components!). So you
333 * can't use color quantization if you change that value.
336 #define RGB_RED 0 /* Offset of Red in an RGB scanline element */
337 #define RGB_GREEN 1 /* Offset of Green */
338 #define RGB_BLUE 2 /* Offset of Blue */
339 #define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
342 /* Definitions for speed-related optimizations. */
345 /* If your compiler supports inline functions, define INLINE
346 * as the inline keyword; otherwise define it as empty.
350 #ifdef __GNUC__ /* for instance, GNU C knows about inline */
351 #define INLINE __inline__
354 #define INLINE /* default is to define it as empty */
359 /* On some machines (notably 68000 series) "int" is 32 bits, but multiplying
360 * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER
361 * as short on such a machine. MULTIPLIER must be at least 16 bits wide.
365 #define MULTIPLIER int /* type for fastest integer multiply */
369 /* FAST_FLOAT should be either float or double, whichever is done faster
370 * by your compiler. (Note that this type is only used in the floating point
371 * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)
372 * Typically, float is faster in ANSI C compilers, while double is faster in
373 * pre-ANSI compilers (because they insist on converting to double anyway).
374 * The code below therefore chooses float if we have ANSI-style prototypes.
378 #ifdef HAVE_PROTOTYPES
379 #define FAST_FLOAT float
381 #define FAST_FLOAT double
385 #endif /* JPEG_INTERNAL_OPTIONS */