]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - libs/jpeg6/jmorecfg.h
transfer from internal tree r5311 branches/1.4-gpl
[xonotic/netradiant.git] / libs / jpeg6 / jmorecfg.h
1 /*\r
2 \r
3  * jmorecfg.h\r
4 \r
5  *\r
6 \r
7  * Copyright (C) 1991-1995, Thomas G. Lane.\r
8 \r
9  * This file is part of the Independent JPEG Group's software.\r
10 \r
11  * For conditions of distribution and use, see the accompanying README file.\r
12 \r
13  *\r
14 \r
15  * This file contains additional configuration options that customize the\r
16 \r
17  * JPEG software for special applications or support machine-dependent\r
18 \r
19  * optimizations.  Most users will not need to touch this file.\r
20 \r
21  */\r
22 \r
23 \r
24 \r
25 \r
26 \r
27 /*\r
28 \r
29  * Define BITS_IN_JSAMPLE as either\r
30 \r
31  *   8   for 8-bit sample values (the usual setting)\r
32 \r
33  *   12  for 12-bit sample values\r
34 \r
35  * Only 8 and 12 are legal data precisions for lossy JPEG according to the\r
36 \r
37  * JPEG standard, and the IJG code does not support anything else!\r
38 \r
39  * We do not support run-time selection of data precision, sorry.\r
40 \r
41  */\r
42 \r
43 \r
44 \r
45 #define BITS_IN_JSAMPLE  8      /* use 8 or 12 */\r
46 \r
47 \r
48 \r
49 \r
50 \r
51 /*\r
52 \r
53  * Maximum number of components (color channels) allowed in JPEG image.\r
54 \r
55  * To meet the letter of the JPEG spec, set this to 255.  However, darn\r
56 \r
57  * few applications need more than 4 channels (maybe 5 for CMYK + alpha\r
58 \r
59  * mask).  We recommend 10 as a reasonable compromise; use 4 if you are\r
60 \r
61  * really short on memory.  (Each allowed component costs a hundred or so\r
62 \r
63  * bytes of storage, whether actually used in an image or not.)\r
64 \r
65  */\r
66 \r
67 \r
68 \r
69 #define MAX_COMPONENTS  10      /* maximum number of image components */\r
70 \r
71 \r
72 \r
73 \r
74 \r
75 /*\r
76 \r
77  * Basic data types.\r
78 \r
79  * You may need to change these if you have a machine with unusual data\r
80 \r
81  * type sizes; for example, "char" not 8 bits, "short" not 16 bits,\r
82 \r
83  * or "long" not 32 bits.  We don't care whether "int" is 16 or 32 bits,\r
84 \r
85  * but it had better be at least 16.\r
86 \r
87  */\r
88 \r
89 \r
90 \r
91 /* Representation of a single sample (pixel element value).\r
92 \r
93  * We frequently allocate large arrays of these, so it's important to keep\r
94 \r
95  * them small.  But if you have memory to burn and access to char or short\r
96 \r
97  * arrays is very slow on your hardware, you might want to change these.\r
98 \r
99  */\r
100 \r
101 \r
102 \r
103 #if BITS_IN_JSAMPLE == 8\r
104 \r
105 /* JSAMPLE should be the smallest type that will hold the values 0..255.\r
106 \r
107  * You can use a signed char by having GETJSAMPLE mask it with 0xFF.\r
108 \r
109  */\r
110 \r
111 \r
112 \r
113 #ifdef HAVE_UNSIGNED_CHAR\r
114 \r
115 \r
116 \r
117 typedef unsigned char JSAMPLE;\r
118 \r
119 #define GETJSAMPLE(value)  ((int) (value))\r
120 \r
121 \r
122 \r
123 #else /* not HAVE_UNSIGNED_CHAR */\r
124 \r
125 \r
126 \r
127 typedef char JSAMPLE;\r
128 \r
129 #ifdef CHAR_IS_UNSIGNED\r
130 \r
131 #define GETJSAMPLE(value)  ((int) (value))\r
132 \r
133 #else\r
134 \r
135 #define GETJSAMPLE(value)  ((int) (value) & 0xFF)\r
136 \r
137 #endif /* CHAR_IS_UNSIGNED */\r
138 \r
139 \r
140 \r
141 #endif /* HAVE_UNSIGNED_CHAR */\r
142 \r
143 \r
144 \r
145 #define MAXJSAMPLE      255\r
146 \r
147 #define CENTERJSAMPLE   128\r
148 \r
149 \r
150 \r
151 #endif /* BITS_IN_JSAMPLE == 8 */\r
152 \r
153 \r
154 \r
155 \r
156 \r
157 #if BITS_IN_JSAMPLE == 12\r
158 \r
159 /* JSAMPLE should be the smallest type that will hold the values 0..4095.\r
160 \r
161  * On nearly all machines "short" will do nicely.\r
162 \r
163  */\r
164 \r
165 \r
166 \r
167 typedef short JSAMPLE;\r
168 \r
169 #define GETJSAMPLE(value)  ((int) (value))\r
170 \r
171 \r
172 \r
173 #define MAXJSAMPLE      4095\r
174 \r
175 #define CENTERJSAMPLE   2048\r
176 \r
177 \r
178 \r
179 #endif /* BITS_IN_JSAMPLE == 12 */\r
180 \r
181 \r
182 \r
183 \r
184 \r
185 /* Representation of a DCT frequency coefficient.\r
186 \r
187  * This should be a signed value of at least 16 bits; "short" is usually OK.\r
188 \r
189  * Again, we allocate large arrays of these, but you can change to int\r
190 \r
191  * if you have memory to burn and "short" is really slow.\r
192 \r
193  */\r
194 \r
195 \r
196 \r
197 typedef short JCOEF;\r
198 \r
199 \r
200 \r
201 \r
202 \r
203 /* Compressed datastreams are represented as arrays of JOCTET.\r
204 \r
205  * These must be EXACTLY 8 bits wide, at least once they are written to\r
206 \r
207  * external storage.  Note that when using the stdio data source/destination\r
208 \r
209  * managers, this is also the data type passed to fread/fwrite.\r
210 \r
211  */\r
212 \r
213 \r
214 \r
215 #ifdef HAVE_UNSIGNED_CHAR\r
216 \r
217 \r
218 \r
219 typedef unsigned char JOCTET;\r
220 \r
221 #define GETJOCTET(value)  (value)\r
222 \r
223 \r
224 \r
225 #else /* not HAVE_UNSIGNED_CHAR */\r
226 \r
227 \r
228 \r
229 typedef char JOCTET;\r
230 \r
231 #ifdef CHAR_IS_UNSIGNED\r
232 \r
233 #define GETJOCTET(value)  (value)\r
234 \r
235 #else\r
236 \r
237 #define GETJOCTET(value)  ((value) & 0xFF)\r
238 \r
239 #endif /* CHAR_IS_UNSIGNED */\r
240 \r
241 \r
242 \r
243 #endif /* HAVE_UNSIGNED_CHAR */\r
244 \r
245 \r
246 \r
247 \r
248 \r
249 /* These typedefs are used for various table entries and so forth.\r
250 \r
251  * They must be at least as wide as specified; but making them too big\r
252 \r
253  * won't cost a huge amount of memory, so we don't provide special\r
254 \r
255  * extraction code like we did for JSAMPLE.  (In other words, these\r
256 \r
257  * typedefs live at a different point on the speed/space tradeoff curve.)\r
258 \r
259  */\r
260 \r
261 \r
262 \r
263 /* UINT8 must hold at least the values 0..255. */\r
264 \r
265 \r
266 \r
267 #ifdef HAVE_UNSIGNED_CHAR\r
268 \r
269 typedef unsigned char UINT8;\r
270 \r
271 #else /* not HAVE_UNSIGNED_CHAR */\r
272 \r
273 #ifdef CHAR_IS_UNSIGNED\r
274 \r
275 typedef char UINT8;\r
276 \r
277 #else /* not CHAR_IS_UNSIGNED */\r
278 \r
279 typedef short UINT8;\r
280 \r
281 #endif /* CHAR_IS_UNSIGNED */\r
282 \r
283 #endif /* HAVE_UNSIGNED_CHAR */\r
284 \r
285 \r
286 \r
287 /* UINT16 must hold at least the values 0..65535. */\r
288 \r
289 \r
290 \r
291 #ifdef HAVE_UNSIGNED_SHORT\r
292 \r
293 typedef unsigned short UINT16;\r
294 \r
295 #else /* not HAVE_UNSIGNED_SHORT */\r
296 \r
297 typedef unsigned int UINT16;\r
298 \r
299 #endif /* HAVE_UNSIGNED_SHORT */\r
300 \r
301 \r
302 \r
303 /* INT16 must hold at least the values -32768..32767. */\r
304 \r
305 \r
306 \r
307 #ifndef XMD_H                   /* X11/xmd.h correctly defines INT16 */\r
308 \r
309 typedef short INT16;\r
310 \r
311 #endif\r
312 \r
313 \r
314 \r
315 /* INT32 must hold at least signed 32-bit values. */\r
316 \r
317 \r
318 \r
319 //#ifndef XMD_H                 /* X11/xmd.h correctly defines INT32 */\r
320 \r
321 //typedef long INT32;\r
322 \r
323 //#endif\r
324 \r
325 \r
326 \r
327 /* Datatype used for image dimensions.  The JPEG standard only supports\r
328 \r
329  * images up to 64K*64K due to 16-bit fields in SOF markers.  Therefore\r
330 \r
331  * "unsigned int" is sufficient on all machines.  However, if you need to\r
332 \r
333  * handle larger images and you don't mind deviating from the spec, you\r
334 \r
335  * can change this datatype.\r
336 \r
337  */\r
338 \r
339 \r
340 \r
341 typedef unsigned int JDIMENSION;\r
342 \r
343 \r
344 \r
345 #define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */\r
346 \r
347 \r
348 \r
349 \r
350 \r
351 /* These defines are used in all function definitions and extern declarations.\r
352 \r
353  * You could modify them if you need to change function linkage conventions.\r
354 \r
355  * Another application is to make all functions global for use with debuggers\r
356 \r
357  * or code profilers that require it.\r
358 \r
359  */\r
360 \r
361 \r
362 \r
363 #define METHODDEF static        /* a function called through method pointers */\r
364 \r
365 #define LOCAL     static        /* a function used only in its module */\r
366 \r
367 #define GLOBAL                  /* a function referenced thru EXTERNs */\r
368 \r
369 #define EXTERN    extern        /* a reference to a GLOBAL function */\r
370 \r
371 \r
372 \r
373 \r
374 \r
375 /* Here is the pseudo-keyword for declaring pointers that must be "far"\r
376 \r
377  * on 80x86 machines.  Most of the specialized coding for 80x86 is handled\r
378 \r
379  * by just saying "FAR *" where such a pointer is needed.  In a few places\r
380 \r
381  * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol.\r
382 \r
383  */\r
384 \r
385 \r
386 \r
387 #ifdef NEED_FAR_POINTERS\r
388 \r
389 #undef FAR\r
390 \r
391 #define FAR  far\r
392 \r
393 #else\r
394 \r
395 #undef FAR\r
396 \r
397 #define FAR\r
398 \r
399 #endif\r
400 \r
401 \r
402 \r
403 \r
404 \r
405 /*\r
406 \r
407  * On a few systems, type boolean and/or its values FALSE, TRUE may appear\r
408 \r
409  * in standard header files.  Or you may have conflicts with application-\r
410 \r
411  * specific header files that you want to include together with these files.\r
412 \r
413  * Defining HAVE_BOOLEAN before including jpeglib.h should make it work.\r
414 \r
415  */\r
416 \r
417 \r
418 \r
419 //#ifndef HAVE_BOOLEAN\r
420 \r
421 //typedef int boolean;\r
422 \r
423 //#endif\r
424 \r
425 #ifndef FALSE                   /* in case these macros already exist */\r
426 \r
427 #define FALSE   0               /* values of boolean */\r
428 \r
429 #endif\r
430 \r
431 #ifndef TRUE\r
432 \r
433 #define TRUE    1\r
434 \r
435 #endif\r
436 \r
437 \r
438 \r
439 \r
440 \r
441 /*\r
442 \r
443  * The remaining options affect code selection within the JPEG library,\r
444 \r
445  * but they don't need to be visible to most applications using the library.\r
446 \r
447  * To minimize application namespace pollution, the symbols won't be\r
448 \r
449  * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.\r
450 \r
451  */\r
452 \r
453 \r
454 \r
455 #ifdef JPEG_INTERNALS\r
456 \r
457 #define JPEG_INTERNAL_OPTIONS\r
458 \r
459 #endif\r
460 \r
461 \r
462 \r
463 #ifdef JPEG_INTERNAL_OPTIONS\r
464 \r
465 \r
466 \r
467 \r
468 \r
469 /*\r
470 \r
471  * These defines indicate whether to include various optional functions.\r
472 \r
473  * Undefining some of these symbols will produce a smaller but less capable\r
474 \r
475  * library.  Note that you can leave certain source files out of the\r
476 \r
477  * compilation/linking process if you've #undef'd the corresponding symbols.\r
478 \r
479  * (You may HAVE to do that if your compiler doesn't like null source files.)\r
480 \r
481  */\r
482 \r
483 \r
484 \r
485 /* Arithmetic coding is unsupported for legal reasons.  Complaints to IBM. */\r
486 \r
487 \r
488 \r
489 /* Capability options common to encoder and decoder: */\r
490 \r
491 \r
492 \r
493 #undef DCT_ISLOW_SUPPORTED      /* slow but accurate integer algorithm */\r
494 \r
495 #undef DCT_IFAST_SUPPORTED      /* faster, less accurate integer method */\r
496 \r
497 #define DCT_FLOAT_SUPPORTED     /* floating-point: accurate, fast on fast HW */\r
498 \r
499 \r
500 \r
501 /* Encoder capability options: */\r
502 \r
503 \r
504 \r
505 #undef  C_ARITH_CODING_SUPPORTED    /* Arithmetic coding back end? */\r
506 \r
507 #define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */\r
508 \r
509 #define C_PROGRESSIVE_SUPPORTED     /* Progressive JPEG? (Requires MULTISCAN)*/\r
510 \r
511 #define ENTROPY_OPT_SUPPORTED       /* Optimization of entropy coding parms? */\r
512 \r
513 /* Note: if you selected 12-bit data precision, it is dangerous to turn off\r
514 \r
515  * ENTROPY_OPT_SUPPORTED.  The standard Huffman tables are only good for 8-bit\r
516 \r
517  * precision, so jchuff.c normally uses entropy optimization to compute\r
518 \r
519  * usable tables for higher precision.  If you don't want to do optimization,\r
520 \r
521  * you'll have to supply different default Huffman tables.\r
522 \r
523  * The exact same statements apply for progressive JPEG: the default tables\r
524 \r
525  * don't work for progressive mode.  (This may get fixed, however.)\r
526 \r
527  */\r
528 \r
529 #define INPUT_SMOOTHING_SUPPORTED   /* Input image smoothing option? */\r
530 \r
531 \r
532 \r
533 /* Decoder capability options: */\r
534 \r
535 \r
536 \r
537 #undef  D_ARITH_CODING_SUPPORTED    /* Arithmetic coding back end? */\r
538 \r
539 #undef D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */\r
540 \r
541 #undef D_PROGRESSIVE_SUPPORTED      /* Progressive JPEG? (Requires MULTISCAN)*/\r
542 \r
543 #undef BLOCK_SMOOTHING_SUPPORTED   /* Block smoothing? (Progressive only) */\r
544 \r
545 #undef IDCT_SCALING_SUPPORTED       /* Output rescaling via IDCT? */\r
546 \r
547 #undef  UPSAMPLE_SCALING_SUPPORTED  /* Output rescaling at upsample stage? */\r
548 \r
549 #undef UPSAMPLE_MERGING_SUPPORTED  /* Fast path for sloppy upsampling? */\r
550 \r
551 #undef QUANT_1PASS_SUPPORTED        /* 1-pass color quantization? */\r
552 \r
553 #undef QUANT_2PASS_SUPPORTED        /* 2-pass color quantization? */\r
554 \r
555 \r
556 \r
557 /* more capability options later, no doubt */\r
558 \r
559 \r
560 \r
561 \r
562 \r
563 /*\r
564 \r
565  * Ordering of RGB data in scanlines passed to or from the application.\r
566 \r
567  * If your application wants to deal with data in the order B,G,R, just\r
568 \r
569  * change these macros.  You can also deal with formats such as R,G,B,X\r
570 \r
571  * (one extra byte per pixel) by changing RGB_PIXELSIZE.  Note that changing\r
572 \r
573  * the offsets will also change the order in which colormap data is organized.\r
574 \r
575  * RESTRICTIONS:\r
576 \r
577  * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.\r
578 \r
579  * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not\r
580 \r
581  *    useful if you are using JPEG color spaces other than YCbCr or grayscale.\r
582 \r
583  * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE\r
584 \r
585  *    is not 3 (they don't understand about dummy color components!).  So you\r
586 \r
587  *    can't use color quantization if you change that value.\r
588 \r
589  */\r
590 \r
591 \r
592 \r
593 #define RGB_RED         0       /* Offset of Red in an RGB scanline element */\r
594 \r
595 #define RGB_GREEN       1       /* Offset of Green */\r
596 \r
597 #define RGB_BLUE        2       /* Offset of Blue */\r
598 \r
599 // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=900\r
600 // ydnar: setting this fucks jpeg loading in q3map2, disabling "fix" (3)\r
601 #define RGB_PIXELSIZE   4       /* JSAMPLEs per RGB scanline element */\r
602 \r
603 \r
604 \r
605 \r
606 \r
607 /* Definitions for speed-related optimizations. */\r
608 \r
609 \r
610 \r
611 \r
612 \r
613 /* If your compiler supports inline functions, define INLINE\r
614 \r
615  * as the inline keyword; otherwise define it as empty.\r
616 \r
617  */\r
618 \r
619 \r
620 \r
621 #ifndef INLINE\r
622 \r
623 #ifdef __GNUC__                 /* for instance, GNU C knows about inline */\r
624 \r
625 #define INLINE __inline__\r
626 \r
627 #endif\r
628 \r
629 #ifndef INLINE\r
630 \r
631 #define INLINE                  /* default is to define it as empty */\r
632 \r
633 #endif\r
634 \r
635 #endif\r
636 \r
637 \r
638 \r
639 \r
640 \r
641 /* On some machines (notably 68000 series) "int" is 32 bits, but multiplying\r
642 \r
643  * two 16-bit shorts is faster than multiplying two ints.  Define MULTIPLIER\r
644 \r
645  * as short on such a machine.  MULTIPLIER must be at least 16 bits wide.\r
646 \r
647  */\r
648 \r
649 \r
650 \r
651 #ifndef MULTIPLIER\r
652 \r
653 #define MULTIPLIER  int         /* type for fastest integer multiply */\r
654 \r
655 #endif\r
656 \r
657 \r
658 \r
659 \r
660 \r
661 /* FAST_FLOAT should be either float or double, whichever is done faster\r
662 \r
663  * by your compiler.  (Note that this type is only used in the floating point\r
664 \r
665  * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)\r
666 \r
667  * Typically, float is faster in ANSI C compilers, while double is faster in\r
668 \r
669  * pre-ANSI compilers (because they insist on converting to double anyway).\r
670 \r
671  * The code below therefore chooses float if we have ANSI-style prototypes.\r
672 \r
673  */\r
674 \r
675 \r
676 \r
677 #ifndef FAST_FLOAT\r
678 \r
679 #ifdef HAVE_PROTOTYPES\r
680 \r
681 #define FAST_FLOAT  float\r
682 \r
683 #else\r
684 \r
685 #define FAST_FLOAT  double\r
686 \r
687 #endif\r
688 \r
689 #endif\r
690 \r
691 \r
692 \r
693 #endif /* JPEG_INTERNAL_OPTIONS */\r