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