Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/jpeg/jmorecfg.h
8730 views
1
/*
2
* jmorecfg.h
3
*
4
* Copyright (C) 1991-1997, Thomas G. Lane.
5
* Modified 1997-2025 by Guido Vollbeding.
6
* This file is part of the Independent JPEG Group's software.
7
* For conditions of distribution and use, see the accompanying README file.
8
*
9
* This file contains additional configuration options that customize the
10
* JPEG software for special applications or support machine-dependent
11
* optimizations. Most users will not need to touch this file.
12
*/
13
14
15
#define JPEG_DATA_PRECISION 8 /* see table below */
16
#define BITS_IN_JSAMPLE JPEG_DATA_PRECISION /* see table below */
17
/*
18
* Most useful alternative for "HDR" (High Dynamic Range) application
19
* with backward compatibility for file interchange (see table below;
20
* move comment marks for selection):
21
#define BITS_IN_JSAMPLE 10
22
*/
23
/* For still higher demands (see table below):
24
#define BITS_IN_JSAMPLE 11
25
*/
26
/* or
27
#define BITS_IN_JSAMPLE 12
28
*/
29
30
/* | BITS_IN_JSAMPLE
31
* JPEG_DATA_PRECISION | read / write with full DCT up to lossless operation
32
* | exceptions see below
33
* -------------------------------------------------------------------------------
34
* {[_8_]} | _8_ <9> <10> <11>* <12>~
35
* [_9_] | <8> _9_ <10> <11> <12>*
36
* [_10_] | <8> <9> _10_ <11> <12> 13 *
37
* _11_ | <8> <9> <10> _11_ <12> 13 14 *
38
* _12_ | <8> <9> <10> <11> _12_ 13 14 15 *
39
* 13 | 8 9 10 11 12 13 14 15 16 *
40
*
41
* _x_ currently and previously implemented - default configuration
42
* <x> newly implemented
43
* {x} current standard for file interchange - backward compatible
44
* [x] next standard for file interchange - common DCT implementation category
45
* * does not support GCC lossless (GCbCr lossless - requires 1 extra bit)
46
* ~ 1 bit precision loss - effective 11 bits precision (lossy)
47
*
48
* Since the DCT coefficients are 3 bits larger than sample values with normal DCT
49
* processing, it is possible to support sample values with up to 3 more bits than
50
* the nominal JPEG data precision parameter by adapted DCT processing with up to
51
* lossless operation. The generated JPEG files are fully interchangeable for the
52
* same JPEG data precision parameter. Another BITS_IN_JSAMPLE setting will just
53
* reconstruct an image with corresponding precision.
54
*
55
* A special case for JPEG data precision 8 with 12-bit sample size (4 more bits)
56
* is provided so that all previously available sample formats are now supported
57
* for file interchange with backward compatibility.
58
* If full-feature DCT up to lossless operation with up to 12-bit sample size is
59
* required, it is recommended to select JPEG data precision 10, because it falls
60
* in the same DCT implementation category with 8 and 9 which may be commonly
61
* supported at run-time as the next standard for file interchange.
62
*
63
* Remaining bit depths and variability at run-time may be added later and
64
* are currently not supported, sorry.
65
* Exception: The transcoding part (jpegtran) supports all settings in a
66
* single instance, since it operates on the level of DCT coefficients and
67
* not sample values. The DCT coefficients are of the same type (16 bits)
68
* in all cases (see below).
69
*/
70
71
72
/*
73
* Maximum number of components (color channels) allowed in JPEG image.
74
* To meet the letter of the JPEG spec, set this to 255. However, darn
75
* few applications need more than 4 channels (maybe 5 for CMYK + alpha
76
* mask). We recommend 10 as a reasonable compromise; use 4 if you are
77
* really short on memory. (Each allowed component costs a hundred or so
78
* bytes of storage, whether actually used in an image or not.)
79
*/
80
81
#define MAX_COMPONENTS 10 /* maximum number of image components */
82
83
84
/*
85
* Basic data types.
86
* You may need to change these if you have a machine with unusual data
87
* type sizes; for example, "char" not 8 bits, "short" not 16 bits,
88
* or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits,
89
* but it had better be at least 16.
90
*/
91
92
/* Representation of a single sample (pixel element value).
93
* We frequently allocate large arrays of these, so it's important to keep
94
* them small. But if you have memory to burn and access to char or short
95
* arrays is very slow on your hardware, you might want to change these.
96
*/
97
98
#if BITS_IN_JSAMPLE == 8
99
/* JSAMPLE should be the smallest type that will hold the values 0..255.
100
* You can use a signed char by having GETJSAMPLE mask it with 0xFF.
101
*/
102
103
#ifdef HAVE_UNSIGNED_CHAR
104
105
typedef unsigned char JSAMPLE;
106
#define GETJSAMPLE(value) ((int) (value))
107
108
#else /* not HAVE_UNSIGNED_CHAR */
109
110
typedef char JSAMPLE;
111
#ifdef CHAR_IS_UNSIGNED
112
#define GETJSAMPLE(value) ((int) (value))
113
#else
114
#define GETJSAMPLE(value) ((int) (value) & 0xFF)
115
#endif /* CHAR_IS_UNSIGNED */
116
117
#endif /* HAVE_UNSIGNED_CHAR */
118
119
#define MAXJSAMPLE 255
120
#define CENTERJSAMPLE 128
121
122
#endif /* BITS_IN_JSAMPLE == 8 */
123
124
125
#if BITS_IN_JSAMPLE == 9
126
/* JSAMPLE should be the smallest type that will hold the values 0..511.
127
* On nearly all machines "short" will do nicely.
128
*/
129
130
typedef short JSAMPLE;
131
#define GETJSAMPLE(value) ((int) (value))
132
133
#define MAXJSAMPLE 511
134
#define CENTERJSAMPLE 256
135
136
#endif /* BITS_IN_JSAMPLE == 9 */
137
138
139
#if BITS_IN_JSAMPLE == 10
140
/* JSAMPLE should be the smallest type that will hold the values 0..1023.
141
* On nearly all machines "short" will do nicely.
142
*/
143
144
typedef short JSAMPLE;
145
#define GETJSAMPLE(value) ((int) (value))
146
147
#define MAXJSAMPLE 1023
148
#define CENTERJSAMPLE 512
149
150
#endif /* BITS_IN_JSAMPLE == 10 */
151
152
153
#if BITS_IN_JSAMPLE == 11
154
/* JSAMPLE should be the smallest type that will hold the values 0..2047.
155
* On nearly all machines "short" will do nicely.
156
*/
157
158
typedef short JSAMPLE;
159
#define GETJSAMPLE(value) ((int) (value))
160
161
#define MAXJSAMPLE 2047
162
#define CENTERJSAMPLE 1024
163
164
#endif /* BITS_IN_JSAMPLE == 11 */
165
166
167
#if BITS_IN_JSAMPLE == 12
168
/* JSAMPLE should be the smallest type that will hold the values 0..4095.
169
* On nearly all machines "short" will do nicely.
170
*/
171
172
typedef short JSAMPLE;
173
#define GETJSAMPLE(value) ((int) (value))
174
175
#define MAXJSAMPLE 4095
176
#define CENTERJSAMPLE 2048
177
178
#endif /* BITS_IN_JSAMPLE == 12 */
179
180
181
/* Representation of a DCT frequency coefficient.
182
* This should be a signed value of at least 16 bits; "short" is usually OK.
183
* Again, we allocate large arrays of these, but you can change to int
184
* if you have memory to burn and "short" is really slow.
185
*/
186
187
typedef short JCOEF;
188
189
190
/* Compressed datastreams are represented as arrays of JOCTET.
191
* These must be EXACTLY 8 bits wide, at least once they are written to
192
* external storage. Note that when using the stdio data source/destination
193
* managers, this is also the data type passed to fread/fwrite.
194
*/
195
196
#ifdef HAVE_UNSIGNED_CHAR
197
198
typedef unsigned char JOCTET;
199
#define GETJOCTET(value) (value)
200
201
#else /* not HAVE_UNSIGNED_CHAR */
202
203
typedef char JOCTET;
204
#ifdef CHAR_IS_UNSIGNED
205
#define GETJOCTET(value) (value)
206
#else
207
#define GETJOCTET(value) ((value) & 0xFF)
208
#endif /* CHAR_IS_UNSIGNED */
209
210
#endif /* HAVE_UNSIGNED_CHAR */
211
212
213
/* These typedefs are used for various table entries and so forth.
214
* They must be at least as wide as specified; but making them too big
215
* won't cost a huge amount of memory, so we don't provide special
216
* extraction code like we did for JSAMPLE. (In other words, these
217
* typedefs live at a different point on the speed/space tradeoff curve.)
218
*/
219
220
/* UINT8 must hold at least the values 0..255. */
221
222
#ifdef HAVE_UNSIGNED_CHAR
223
typedef unsigned char UINT8;
224
#else /* not HAVE_UNSIGNED_CHAR */
225
#ifdef CHAR_IS_UNSIGNED
226
typedef char UINT8;
227
#else /* not CHAR_IS_UNSIGNED */
228
typedef short UINT8;
229
#endif /* CHAR_IS_UNSIGNED */
230
#endif /* HAVE_UNSIGNED_CHAR */
231
232
/* UINT16 must hold at least the values 0..65535. */
233
234
#ifdef HAVE_UNSIGNED_SHORT
235
typedef unsigned short UINT16;
236
#else /* not HAVE_UNSIGNED_SHORT */
237
typedef unsigned int UINT16;
238
#endif /* HAVE_UNSIGNED_SHORT */
239
240
/* INT16 must hold at least the values -32768..32767. */
241
242
#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */
243
typedef short INT16;
244
#endif
245
246
/* INT32 must hold at least signed 32-bit values. */
247
248
#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */
249
#ifndef _BASETSD_H_ /* Microsoft defines it in basetsd.h */
250
#ifndef _BASETSD_H /* MinGW is slightly different */
251
#ifndef QGLOBAL_H /* Qt defines it in qglobal.h */
252
typedef long INT32;
253
#endif
254
#endif
255
#endif
256
#endif
257
258
/* Datatype used for image dimensions. The JPEG standard only supports
259
* images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
260
* "unsigned int" is sufficient on all machines. However, if you need to
261
* handle larger images and you don't mind deviating from the spec, you
262
* can change this datatype.
263
*/
264
265
typedef unsigned int JDIMENSION;
266
267
#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */
268
269
270
/* These macros are used in all function definitions and extern declarations.
271
* You could modify them if you need to change function linkage conventions;
272
* in particular, you'll need to do that to make the library a Windows DLL.
273
* Another application is to make all functions global for use with debuggers
274
* or code profilers that require it.
275
*/
276
277
/* a function called through method pointers: */
278
#define METHODDEF(type) static type
279
/* a function used only in its module: */
280
#define LOCAL(type) static type
281
/* a function referenced thru EXTERNs: */
282
#define GLOBAL(type) type
283
/* a reference to a GLOBAL function: */
284
#define EXTERN(type) extern type
285
286
287
/* This macro is used to declare a "method", that is, a function pointer.
288
* We want to supply prototype parameters if the compiler can cope.
289
* Note that the arglist parameter must be parenthesized!
290
* Again, you can customize this if you need special linkage keywords.
291
*/
292
293
#ifdef HAVE_PROTOTYPES
294
#define JMETHOD(type,methodname,arglist) type (*methodname) arglist
295
#else
296
#define JMETHOD(type,methodname,arglist) type (*methodname) ()
297
#endif
298
299
300
/* The noreturn type identifier is used to declare functions
301
* which cannot return.
302
* Compilers can thus create more optimized code and perform
303
* better checks for warnings and errors.
304
* Static analyzer tools can make improved inferences about
305
* execution paths and are prevented from giving false alerts.
306
*
307
* Unfortunately, the proposed specifications of corresponding
308
* extensions in the Dec 2011 ISO C standard revision (C11),
309
* GCC, MSVC, etc. are not viable.
310
* Thus we introduce a user defined type to declare noreturn
311
* functions at least for clarity. A proper compiler would
312
* have a suitable noreturn type to match in place of void.
313
*/
314
315
#ifndef HAVE_NORETURN_T
316
typedef void noreturn_t;
317
#endif
318
319
320
/* Here is the pseudo-keyword for declaring pointers that must be "far"
321
* on 80x86 machines. Most of the specialized coding for 80x86 is handled
322
* by just saying "FAR *" where such a pointer is needed. In a few places
323
* explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol.
324
*/
325
326
#ifndef FAR
327
#ifdef NEED_FAR_POINTERS
328
#define FAR far
329
#else
330
#define FAR
331
#endif
332
#endif
333
334
335
/*
336
* On a few systems, type boolean and/or its values FALSE, TRUE may appear
337
* in standard header files. Or you may have conflicts with application-
338
* specific header files that you want to include together with these files.
339
* Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
340
*/
341
342
#ifndef HAVE_BOOLEAN
343
#if defined FALSE || defined TRUE || defined QGLOBAL_H
344
/* Qt3 defines FALSE and TRUE as "const" variables in qglobal.h */
345
typedef int boolean;
346
#ifndef FALSE /* in case these macros already exist */
347
#define FALSE 0 /* values of boolean */
348
#endif
349
#ifndef TRUE
350
#define TRUE 1
351
#endif
352
#else
353
typedef enum { FALSE = 0, TRUE = 1 } boolean;
354
#endif
355
#endif
356
357
358
/*
359
* The remaining options affect code selection within the JPEG library,
360
* but they don't need to be visible to most applications using the library.
361
* To minimize application namespace pollution, the symbols won't be
362
* defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.
363
*/
364
365
#ifdef JPEG_INTERNALS
366
#define JPEG_INTERNAL_OPTIONS
367
#endif
368
369
#ifdef JPEG_INTERNAL_OPTIONS
370
371
372
/*
373
* These defines indicate whether to include various optional functions.
374
* Undefining some of these symbols will produce a smaller but less capable
375
* library. Note that you can leave certain source files out of the
376
* compilation/linking process if you've #undef'd the corresponding symbols.
377
* (You may HAVE to do that if your compiler doesn't like null source files.)
378
*/
379
380
/* Capability options common to encoder and decoder: */
381
382
#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */
383
#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */
384
#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */
385
386
/* Encoder capability options: */
387
388
#define C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
389
#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
390
#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN) */
391
#define DCT_SCALING_SUPPORTED /* Input rescaling via DCT? (Requires DCT_ISLOW) */
392
#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
393
/* Note: if you selected more than 8-bit data precision, it is dangerous to
394
* turn off ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only
395
* good for 8-bit precision, so arithmetic coding is recommended for higher
396
* precision. The Huffman encoder normally uses entropy optimization to
397
* compute usable tables for higher precision. Otherwise, you'll have to
398
* supply different default Huffman tables.
399
* The exact same statements apply for progressive JPEG: the default tables
400
* don't work for progressive mode. (This may get fixed, however.)
401
*/
402
#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */
403
404
/* Decoder capability options: */
405
406
#define D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
407
#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
408
#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN) */
409
#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? (Requires DCT_ISLOW) */
410
#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
411
#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
412
#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
413
#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */
414
#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */
415
#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */
416
417
/* more capability options later, no doubt */
418
419
420
/*
421
* Ordering of RGB data in scanlines passed to or from the application.
422
* If your application wants to deal with data in the order B,G,R, just
423
* #define JPEG_USE_RGB_CUSTOM in jconfig.h, or define your own custom
424
* order in jconfig.h and #define JPEG_HAVE_RGB_CUSTOM.
425
* You can also deal with formats such as R,G,B,X (one extra byte per pixel)
426
* by changing RGB_PIXELSIZE.
427
* Note that changing the offsets will also change
428
* the order in which colormap data is organized.
429
* RESTRICTIONS:
430
* 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.
431
* 2. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
432
* is not 3 (they don't understand about dummy color components!).
433
* So you can't use color quantization if you change that value.
434
*/
435
436
#ifndef JPEG_HAVE_RGB_CUSTOM
437
#ifdef JPEG_USE_RGB_CUSTOM
438
#define RGB_RED 2 /* Offset of Red in an RGB scanline element */
439
#define RGB_GREEN 1 /* Offset of Green */
440
#define RGB_BLUE 0 /* Offset of Blue */
441
#else
442
#define RGB_RED 0 /* Offset of Red in an RGB scanline element */
443
#define RGB_GREEN 1 /* Offset of Green */
444
#define RGB_BLUE 2 /* Offset of Blue */
445
#endif
446
#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
447
#endif
448
449
450
/* Definitions for speed-related optimizations. */
451
452
453
/* If your compiler supports inline functions, define INLINE
454
* as the inline keyword; otherwise define it as empty.
455
*/
456
457
#ifndef INLINE
458
#ifdef __GNUC__ /* for instance, GNU C knows about inline */
459
#define INLINE __inline__
460
#endif
461
#ifndef INLINE
462
#define INLINE /* default is to define it as empty */
463
#endif
464
#endif
465
466
467
/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying
468
* two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER
469
* as short on such a machine. MULTIPLIER must be at least 16 bits wide.
470
*/
471
472
#ifndef MULTIPLIER
473
#define MULTIPLIER int /* type for fastest integer multiply */
474
#endif
475
476
477
/* FAST_FLOAT should be either float or double, whichever is done faster
478
* by your compiler. (Note that this type is only used in the floating point
479
* DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)
480
* Typically, float is faster in ANSI C compilers, while double is faster in
481
* pre-ANSI compilers (because they insist on converting to double anyway).
482
* The code below therefore chooses float if we have ANSI-style prototypes.
483
*/
484
485
#ifndef FAST_FLOAT
486
#ifdef HAVE_PROTOTYPES
487
#define FAST_FLOAT float
488
#else
489
#define FAST_FLOAT double
490
#endif
491
#endif
492
493
#endif /* JPEG_INTERNAL_OPTIONS */
494
495