add libjpeg
[reactos.git] / reactos / dll / 3rdparty / libjpeg / jmorecfg.h
1 /*
2 * jmorecfg.h
3 *
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.
7 *
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.
11 */
12
13
14 /*
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.
21 */
22
23 #define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
24
25 #if (defined (_MSC_VER) && (_MSC_VER >= 800))
26 #define HAVE_UNSIGNED_CHAR
27 #define HAVE_ALL_INTS
28 #define EXTERN(type) extern type __cdecl
29 #endif
30
31 /*
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.)
38 */
39
40 #define MAX_COMPONENTS 10 /* maximum number of image components */
41
42
43 /*
44 * Basic data types.
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.
49 */
50
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.
55 */
56
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.
60 */
61
62 #ifdef HAVE_UNSIGNED_CHAR
63
64 typedef unsigned char JSAMPLE;
65 #define GETJSAMPLE(value) ((int) (value))
66
67 #else /* not HAVE_UNSIGNED_CHAR */
68
69 typedef char JSAMPLE;
70 #ifdef CHAR_IS_UNSIGNED
71 #define GETJSAMPLE(value) ((int) (value))
72 #else
73 #define GETJSAMPLE(value) ((int) (value) & 0xFF)
74 #endif /* CHAR_IS_UNSIGNED */
75
76 #endif /* HAVE_UNSIGNED_CHAR */
77
78 #define MAXJSAMPLE 255
79 #define CENTERJSAMPLE 128
80
81 #endif /* BITS_IN_JSAMPLE == 8 */
82
83
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.
87 */
88
89 typedef short JSAMPLE;
90 #define GETJSAMPLE(value) ((int) (value))
91
92 #define MAXJSAMPLE 4095
93 #define CENTERJSAMPLE 2048
94
95 #endif /* BITS_IN_JSAMPLE == 12 */
96
97
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.
102 */
103
104 typedef short JCOEF;
105
106
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.
111 */
112
113 #ifdef HAVE_UNSIGNED_CHAR
114
115 typedef unsigned char JOCTET;
116 #define GETJOCTET(value) (value)
117
118 #else /* not HAVE_UNSIGNED_CHAR */
119
120 typedef char JOCTET;
121 #ifdef CHAR_IS_UNSIGNED
122 #define GETJOCTET(value) (value)
123 #else
124 #define GETJOCTET(value) ((value) & 0xFF)
125 #endif /* CHAR_IS_UNSIGNED */
126
127 #endif /* HAVE_UNSIGNED_CHAR */
128
129
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.)
135 */
136
137 /* UINT8 must hold at least the values 0..255. */
138 #ifndef HAVE_ALL_INTS
139
140 #ifdef HAVE_UNSIGNED_CHAR
141 typedef unsigned char UINT8;
142 #else /* not HAVE_UNSIGNED_CHAR */
143 #ifdef CHAR_IS_UNSIGNED
144 typedef char UINT8;
145 #else /* not CHAR_IS_UNSIGNED */
146 typedef short UINT8;
147 #endif /* CHAR_IS_UNSIGNED */
148 #endif /* HAVE_UNSIGNED_CHAR */
149
150 /* UINT16 must hold at least the values 0..65535. */
151
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 */
157
158 /* INT16 must hold at least the values -32768..32767. */
159
160 #ifndef XMD_H /* X11/xmd.h correctly defines INT16 */
161 typedef short INT16;
162 #endif
163
164 /* INT32 must hold at least signed 32-bit values. */
165
166 #if !defined(XMD_H) && !defined(_WIN32) /* X11/xmd.h correctly defines INT32 */
167 typedef long INT32;
168 #endif
169
170 #endif /* HAVE_ALL_INTS */
171
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.
177 */
178
179 typedef unsigned int JDIMENSION;
180
181 #define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */
182
183
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.
189 */
190
191 #ifdef _WIN32
192 # if defined(ALL_STATIC)
193 # if defined(JPEG_DLL)
194 # undef JPEG_DLL
195 # endif
196 # if !defined(JPEG_STATIC)
197 # define JPEG_STATIC
198 # endif
199 # endif
200 # if defined(JPEG_DLL)
201 # if defined(JPEG_STATIC)
202 # undef JPEG_STATIC
203 # endif
204 # endif
205 # if defined(JPEG_DLL)
206 /* building a DLL */
207 # define JPEG_IMPEXP __declspec(dllexport)
208 # elif defined(JPEG_STATIC)
209 /* building or linking to a static library */
210 # define JPEG_IMPEXP
211 # else
212 /* linking to the DLL */
213 # define JPEG_IMPEXP __declspec(dllimport)
214 # endif
215 # if !defined(JPEG_API)
216 # define JPEG_API __cdecl
217 # endif
218 /* The only remaining magic that is necessary for cygwin */
219 #elif defined(__CYGWIN__)
220 # if !defined(JPEG_IMPEXP)
221 # define JPEG_IMPEXP
222 # endif
223 # if !defined(JPEG_API)
224 # define JPEG_API __cdecl
225 # endif
226 #endif
227
228 /* Ensure our magic doesn't hurt other platforms */
229 #if !defined(JPEG_IMPEXP)
230 # define JPEG_IMPEXP
231 #endif
232 #if !defined(JPEG_API)
233 # define JPEG_API
234 #endif
235
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: */
243 #ifndef EXTERN
244 # define EXTERN(type) extern JPEG_IMPEXP type JPEG_API
245 /* a reference to a "GLOBAL" function exported by sourcefiles of utility progs */
246 #endif /* EXTERN */
247 #define EXTERN_1(type) extern type JPEG_API
248
249
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.
254 */
255
256 #ifdef HAVE_PROTOTYPES
257 #define JMETHOD(type,methodname,arglist) type (*methodname) arglist
258 #else
259 #define JMETHOD(type,methodname,arglist) type (*methodname) ()
260 #endif
261
262
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.
267 */
268
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 */
273 #ifndef FAR
274 #ifdef NEED_FAR_POINTERS
275 #define FAR far
276 #else
277 #define FAR
278 #endif
279 #endif
280
281
282 /*
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.
287 */
288
289 #ifndef HAVE_BOOLEAN
290 typedef int boolean;
291 #endif
292 #ifndef FALSE /* in case these macros already exist */
293 #define FALSE 0 /* values of boolean */
294 #endif
295 #ifndef TRUE
296 #define TRUE 1
297 #endif
298
299
300 /*
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.
305 */
306
307 #ifdef JPEG_INTERNALS
308 #define JPEG_INTERNAL_OPTIONS
309 #endif
310
311 #ifdef JPEG_INTERNAL_OPTIONS
312
313
314 /*
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.)
320 */
321
322 /* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */
323
324 /* Capability options common to encoder and decoder: */
325
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 */
329
330 /* Encoder capability options: */
331
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.)
343 */
344 #define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */
345
346 /* Decoder capability options: */
347
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? */
358
359 /* more capability options later, no doubt */
360
361
362 /*
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.
368 * RESTRICTIONS:
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.
375 */
376
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 */
381
382
383 /* Definitions for speed-related optimizations. */
384
385
386 /* If your compiler supports inline functions, define INLINE
387 * as the inline keyword; otherwise define it as empty.
388 */
389
390 #ifndef INLINE
391 #ifdef __GNUC__ /* for instance, GNU C knows about inline */
392 #define INLINE __inline__
393 #endif
394 #ifndef INLINE
395 #define INLINE /* default is to define it as empty */
396 #endif
397 #endif
398
399
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.
403 */
404
405 #ifndef MULTIPLIER
406 #define MULTIPLIER int /* type for fastest integer multiply */
407 #endif
408
409
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.
416 */
417
418 #ifndef FAST_FLOAT
419 #ifdef HAVE_PROTOTYPES
420 #define FAST_FLOAT float
421 #else
422 #define FAST_FLOAT double
423 #endif
424 #endif
425
426 #endif /* JPEG_INTERNAL_OPTIONS */