media/libjpeg/jmorecfg.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 * jmorecfg.h
michael@0 3 *
michael@0 4 * This file was part of the Independent JPEG Group's software:
michael@0 5 * Copyright (C) 1991-1997, Thomas G. Lane.
michael@0 6 * Modifications:
michael@0 7 * Copyright (C) 2009, 2011, D. R. Commander.
michael@0 8 * For conditions of distribution and use, see the accompanying README file.
michael@0 9 *
michael@0 10 * This file contains additional configuration options that customize the
michael@0 11 * JPEG software for special applications or support machine-dependent
michael@0 12 * optimizations. Most users will not need to touch this file.
michael@0 13 */
michael@0 14
michael@0 15 #include <stdint.h>
michael@0 16
michael@0 17 /*
michael@0 18 * Define BITS_IN_JSAMPLE as either
michael@0 19 * 8 for 8-bit sample values (the usual setting)
michael@0 20 * 12 for 12-bit sample values
michael@0 21 * Only 8 and 12 are legal data precisions for lossy JPEG according to the
michael@0 22 * JPEG standard, and the IJG code does not support anything else!
michael@0 23 * We do not support run-time selection of data precision, sorry.
michael@0 24 */
michael@0 25
michael@0 26 #define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
michael@0 27
michael@0 28
michael@0 29 /*
michael@0 30 * Maximum number of components (color channels) allowed in JPEG image.
michael@0 31 * To meet the letter of the JPEG spec, set this to 255. However, darn
michael@0 32 * few applications need more than 4 channels (maybe 5 for CMYK + alpha
michael@0 33 * mask). We recommend 10 as a reasonable compromise; use 4 if you are
michael@0 34 * really short on memory. (Each allowed component costs a hundred or so
michael@0 35 * bytes of storage, whether actually used in an image or not.)
michael@0 36 */
michael@0 37
michael@0 38 #define MAX_COMPONENTS 10 /* maximum number of image components */
michael@0 39
michael@0 40
michael@0 41 /*
michael@0 42 * Basic data types.
michael@0 43 * You may need to change these if you have a machine with unusual data
michael@0 44 * type sizes; for example, "char" not 8 bits, "short" not 16 bits,
michael@0 45 * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits,
michael@0 46 * but it had better be at least 16.
michael@0 47 */
michael@0 48
michael@0 49 /* Representation of a single sample (pixel element value).
michael@0 50 * We frequently allocate large arrays of these, so it's important to keep
michael@0 51 * them small. But if you have memory to burn and access to char or short
michael@0 52 * arrays is very slow on your hardware, you might want to change these.
michael@0 53 */
michael@0 54
michael@0 55 #if BITS_IN_JSAMPLE == 8
michael@0 56 /* JSAMPLE should be the smallest type that will hold the values 0..255.
michael@0 57 * You can use a signed char by having GETJSAMPLE mask it with 0xFF.
michael@0 58 */
michael@0 59
michael@0 60 #ifdef HAVE_UNSIGNED_CHAR
michael@0 61
michael@0 62 typedef unsigned char JSAMPLE;
michael@0 63 #define GETJSAMPLE(value) ((int) (value))
michael@0 64
michael@0 65 #else /* not HAVE_UNSIGNED_CHAR */
michael@0 66
michael@0 67 typedef char JSAMPLE;
michael@0 68 #ifdef __CHAR_UNSIGNED__
michael@0 69 #define GETJSAMPLE(value) ((int) (value))
michael@0 70 #else
michael@0 71 #define GETJSAMPLE(value) ((int) (value) & 0xFF)
michael@0 72 #endif /* __CHAR_UNSIGNED__ */
michael@0 73
michael@0 74 #endif /* HAVE_UNSIGNED_CHAR */
michael@0 75
michael@0 76 #define MAXJSAMPLE 255
michael@0 77 #define CENTERJSAMPLE 128
michael@0 78
michael@0 79 #endif /* BITS_IN_JSAMPLE == 8 */
michael@0 80
michael@0 81
michael@0 82 #if BITS_IN_JSAMPLE == 12
michael@0 83 /* JSAMPLE should be the smallest type that will hold the values 0..4095.
michael@0 84 * On nearly all machines "short" will do nicely.
michael@0 85 */
michael@0 86
michael@0 87 typedef short JSAMPLE;
michael@0 88 #define GETJSAMPLE(value) ((int) (value))
michael@0 89
michael@0 90 #define MAXJSAMPLE 4095
michael@0 91 #define CENTERJSAMPLE 2048
michael@0 92
michael@0 93 #endif /* BITS_IN_JSAMPLE == 12 */
michael@0 94
michael@0 95
michael@0 96 /* Representation of a DCT frequency coefficient.
michael@0 97 * This should be a signed value of at least 16 bits; "short" is usually OK.
michael@0 98 * Again, we allocate large arrays of these, but you can change to int
michael@0 99 * if you have memory to burn and "short" is really slow.
michael@0 100 */
michael@0 101
michael@0 102 typedef short JCOEF;
michael@0 103
michael@0 104
michael@0 105 /* Compressed datastreams are represented as arrays of JOCTET.
michael@0 106 * These must be EXACTLY 8 bits wide, at least once they are written to
michael@0 107 * external storage. Note that when using the stdio data source/destination
michael@0 108 * managers, this is also the data type passed to fread/fwrite.
michael@0 109 */
michael@0 110
michael@0 111 #ifdef HAVE_UNSIGNED_CHAR
michael@0 112
michael@0 113 typedef unsigned char JOCTET;
michael@0 114 #define GETJOCTET(value) (value)
michael@0 115
michael@0 116 #else /* not HAVE_UNSIGNED_CHAR */
michael@0 117
michael@0 118 typedef char JOCTET;
michael@0 119 #ifdef __CHAR_UNSIGNED__
michael@0 120 #define GETJOCTET(value) (value)
michael@0 121 #else
michael@0 122 #define GETJOCTET(value) ((value) & 0xFF)
michael@0 123 #endif /* __CHAR_UNSIGNED__ */
michael@0 124
michael@0 125 #endif /* HAVE_UNSIGNED_CHAR */
michael@0 126
michael@0 127
michael@0 128 /* These typedefs are used for various table entries and so forth.
michael@0 129 * They must be at least as wide as specified; but making them too big
michael@0 130 * won't cost a huge amount of memory, so we don't provide special
michael@0 131 * extraction code like we did for JSAMPLE. (In other words, these
michael@0 132 * typedefs live at a different point on the speed/space tradeoff curve.)
michael@0 133 */
michael@0 134
michael@0 135 /* UINT8 must hold at least the values 0..255. */
michael@0 136
michael@0 137 typedef uint8_t UINT8;
michael@0 138
michael@0 139 /* UINT16 must hold at least the values 0..65535. */
michael@0 140
michael@0 141 typedef uint16_t UINT16;
michael@0 142
michael@0 143 /* INT16 must hold at least the values -32768..32767. */
michael@0 144
michael@0 145 typedef int16_t INT16;
michael@0 146
michael@0 147 /* INT32 must hold at least signed 32-bit values. */
michael@0 148
michael@0 149 typedef int32_t INT32;
michael@0 150
michael@0 151 /* Datatype used for image dimensions. The JPEG standard only supports
michael@0 152 * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
michael@0 153 * "unsigned int" is sufficient on all machines. However, if you need to
michael@0 154 * handle larger images and you don't mind deviating from the spec, you
michael@0 155 * can change this datatype.
michael@0 156 */
michael@0 157
michael@0 158 typedef unsigned int JDIMENSION;
michael@0 159
michael@0 160 #define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */
michael@0 161
michael@0 162
michael@0 163 /* These macros are used in all function definitions and extern declarations.
michael@0 164 * You could modify them if you need to change function linkage conventions;
michael@0 165 * in particular, you'll need to do that to make the library a Windows DLL.
michael@0 166 * Another application is to make all functions global for use with debuggers
michael@0 167 * or code profilers that require it.
michael@0 168 */
michael@0 169
michael@0 170 /* a function called through method pointers: */
michael@0 171 #define METHODDEF(type) static type
michael@0 172 /* a function used only in its module: */
michael@0 173 #define LOCAL(type) static type
michael@0 174 /* a function referenced thru EXTERNs: */
michael@0 175 #define GLOBAL(type) type
michael@0 176 /* a reference to a GLOBAL function: */
michael@0 177 #define EXTERN(type) extern type
michael@0 178
michael@0 179
michael@0 180 /* This macro is used to declare a "method", that is, a function pointer.
michael@0 181 * We want to supply prototype parameters if the compiler can cope.
michael@0 182 * Note that the arglist parameter must be parenthesized!
michael@0 183 * Again, you can customize this if you need special linkage keywords.
michael@0 184 */
michael@0 185
michael@0 186 #ifdef HAVE_PROTOTYPES
michael@0 187 #define JMETHOD(type,methodname,arglist) type (*methodname) arglist
michael@0 188 #else
michael@0 189 #define JMETHOD(type,methodname,arglist) type (*methodname) ()
michael@0 190 #endif
michael@0 191
michael@0 192
michael@0 193 /* Here is the pseudo-keyword for declaring pointers that must be "far"
michael@0 194 * on 80x86 machines. Most of the specialized coding for 80x86 is handled
michael@0 195 * by just saying "FAR *" where such a pointer is needed. In a few places
michael@0 196 * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol.
michael@0 197 */
michael@0 198
michael@0 199 #ifdef NEED_FAR_POINTERS
michael@0 200 #ifndef FAR
michael@0 201 #define FAR far
michael@0 202 #endif
michael@0 203 #else
michael@0 204 #undef FAR
michael@0 205 #define FAR
michael@0 206 #endif
michael@0 207
michael@0 208
michael@0 209 /*
michael@0 210 * On a few systems, type boolean and/or its values FALSE, TRUE may appear
michael@0 211 * in standard header files. Or you may have conflicts with application-
michael@0 212 * specific header files that you want to include together with these files.
michael@0 213 * Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
michael@0 214 */
michael@0 215
michael@0 216 #ifndef HAVE_BOOLEAN
michael@0 217 typedef int boolean;
michael@0 218 #endif
michael@0 219 #ifndef FALSE /* in case these macros already exist */
michael@0 220 #define FALSE 0 /* values of boolean */
michael@0 221 #endif
michael@0 222 #ifndef TRUE
michael@0 223 #define TRUE 1
michael@0 224 #endif
michael@0 225
michael@0 226
michael@0 227 /*
michael@0 228 * The remaining options affect code selection within the JPEG library,
michael@0 229 * but they don't need to be visible to most applications using the library.
michael@0 230 * To minimize application namespace pollution, the symbols won't be
michael@0 231 * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.
michael@0 232 */
michael@0 233
michael@0 234 #ifdef JPEG_INTERNALS
michael@0 235 #define JPEG_INTERNAL_OPTIONS
michael@0 236 #endif
michael@0 237
michael@0 238 #ifdef JPEG_INTERNAL_OPTIONS
michael@0 239
michael@0 240
michael@0 241 /*
michael@0 242 * These defines indicate whether to include various optional functions.
michael@0 243 * Undefining some of these symbols will produce a smaller but less capable
michael@0 244 * library. Note that you can leave certain source files out of the
michael@0 245 * compilation/linking process if you've #undef'd the corresponding symbols.
michael@0 246 * (You may HAVE to do that if your compiler doesn't like null source files.)
michael@0 247 */
michael@0 248
michael@0 249 /* Capability options common to encoder and decoder: */
michael@0 250
michael@0 251 #define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */
michael@0 252 #define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */
michael@0 253 #define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */
michael@0 254
michael@0 255 /* Encoder capability options: */
michael@0 256
michael@0 257 #define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
michael@0 258 #define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
michael@0 259 #define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
michael@0 260 /* Note: if you selected 12-bit data precision, it is dangerous to turn off
michael@0 261 * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit
michael@0 262 * precision, so jchuff.c normally uses entropy optimization to compute
michael@0 263 * usable tables for higher precision. If you don't want to do optimization,
michael@0 264 * you'll have to supply different default Huffman tables.
michael@0 265 * The exact same statements apply for progressive JPEG: the default tables
michael@0 266 * don't work for progressive mode. (This may get fixed, however.)
michael@0 267 */
michael@0 268 #define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */
michael@0 269
michael@0 270 /* Decoder capability options: */
michael@0 271
michael@0 272 #define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
michael@0 273 #define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
michael@0 274 #define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
michael@0 275 #define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
michael@0 276 #define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */
michael@0 277 #undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
michael@0 278 #define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */
michael@0 279 #define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */
michael@0 280 #define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */
michael@0 281
michael@0 282 /* more capability options later, no doubt */
michael@0 283
michael@0 284
michael@0 285 /*
michael@0 286 * Ordering of RGB data in scanlines passed to or from the application.
michael@0 287 * If your application wants to deal with data in the order B,G,R, just
michael@0 288 * change these macros. You can also deal with formats such as R,G,B,X
michael@0 289 * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing
michael@0 290 * the offsets will also change the order in which colormap data is organized.
michael@0 291 * RESTRICTIONS:
michael@0 292 * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.
michael@0 293 * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not
michael@0 294 * useful if you are using JPEG color spaces other than YCbCr or grayscale.
michael@0 295 * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
michael@0 296 * is not 3 (they don't understand about dummy color components!). So you
michael@0 297 * can't use color quantization if you change that value.
michael@0 298 */
michael@0 299
michael@0 300 #define RGB_RED 0 /* Offset of Red in an RGB scanline element */
michael@0 301 #define RGB_GREEN 1 /* Offset of Green */
michael@0 302 #define RGB_BLUE 2 /* Offset of Blue */
michael@0 303 #define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
michael@0 304
michael@0 305 #define JPEG_NUMCS 16
michael@0 306
michael@0 307 #define EXT_RGB_RED 0
michael@0 308 #define EXT_RGB_GREEN 1
michael@0 309 #define EXT_RGB_BLUE 2
michael@0 310 #define EXT_RGB_PIXELSIZE 3
michael@0 311
michael@0 312 #define EXT_RGBX_RED 0
michael@0 313 #define EXT_RGBX_GREEN 1
michael@0 314 #define EXT_RGBX_BLUE 2
michael@0 315 #define EXT_RGBX_PIXELSIZE 4
michael@0 316
michael@0 317 #define EXT_BGR_RED 2
michael@0 318 #define EXT_BGR_GREEN 1
michael@0 319 #define EXT_BGR_BLUE 0
michael@0 320 #define EXT_BGR_PIXELSIZE 3
michael@0 321
michael@0 322 #define EXT_BGRX_RED 2
michael@0 323 #define EXT_BGRX_GREEN 1
michael@0 324 #define EXT_BGRX_BLUE 0
michael@0 325 #define EXT_BGRX_PIXELSIZE 4
michael@0 326
michael@0 327 #define EXT_XBGR_RED 3
michael@0 328 #define EXT_XBGR_GREEN 2
michael@0 329 #define EXT_XBGR_BLUE 1
michael@0 330 #define EXT_XBGR_PIXELSIZE 4
michael@0 331
michael@0 332 #define EXT_XRGB_RED 1
michael@0 333 #define EXT_XRGB_GREEN 2
michael@0 334 #define EXT_XRGB_BLUE 3
michael@0 335 #define EXT_XRGB_PIXELSIZE 4
michael@0 336
michael@0 337 static const int rgb_red[JPEG_NUMCS] = {
michael@0 338 -1, -1, RGB_RED, -1, -1, -1, EXT_RGB_RED, EXT_RGBX_RED,
michael@0 339 EXT_BGR_RED, EXT_BGRX_RED, EXT_XBGR_RED, EXT_XRGB_RED,
michael@0 340 EXT_RGBX_RED, EXT_BGRX_RED, EXT_XBGR_RED, EXT_XRGB_RED
michael@0 341 };
michael@0 342
michael@0 343 static const int rgb_green[JPEG_NUMCS] = {
michael@0 344 -1, -1, RGB_GREEN, -1, -1, -1, EXT_RGB_GREEN, EXT_RGBX_GREEN,
michael@0 345 EXT_BGR_GREEN, EXT_BGRX_GREEN, EXT_XBGR_GREEN, EXT_XRGB_GREEN,
michael@0 346 EXT_RGBX_GREEN, EXT_BGRX_GREEN, EXT_XBGR_GREEN, EXT_XRGB_GREEN
michael@0 347 };
michael@0 348
michael@0 349 static const int rgb_blue[JPEG_NUMCS] = {
michael@0 350 -1, -1, RGB_BLUE, -1, -1, -1, EXT_RGB_BLUE, EXT_RGBX_BLUE,
michael@0 351 EXT_BGR_BLUE, EXT_BGRX_BLUE, EXT_XBGR_BLUE, EXT_XRGB_BLUE,
michael@0 352 EXT_RGBX_BLUE, EXT_BGRX_BLUE, EXT_XBGR_BLUE, EXT_XRGB_BLUE
michael@0 353 };
michael@0 354
michael@0 355 static const int rgb_pixelsize[JPEG_NUMCS] = {
michael@0 356 -1, -1, RGB_PIXELSIZE, -1, -1, -1, EXT_RGB_PIXELSIZE, EXT_RGBX_PIXELSIZE,
michael@0 357 EXT_BGR_PIXELSIZE, EXT_BGRX_PIXELSIZE, EXT_XBGR_PIXELSIZE, EXT_XRGB_PIXELSIZE,
michael@0 358 EXT_RGBX_PIXELSIZE, EXT_BGRX_PIXELSIZE, EXT_XBGR_PIXELSIZE, EXT_XRGB_PIXELSIZE
michael@0 359 };
michael@0 360
michael@0 361 /* Definitions for speed-related optimizations. */
michael@0 362
michael@0 363 /* On some machines (notably 68000 series) "int" is 32 bits, but multiplying
michael@0 364 * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER
michael@0 365 * as short on such a machine. MULTIPLIER must be at least 16 bits wide.
michael@0 366 */
michael@0 367
michael@0 368 #ifndef MULTIPLIER
michael@0 369 #ifndef WITH_SIMD
michael@0 370 #define MULTIPLIER int /* type for fastest integer multiply */
michael@0 371 #else
michael@0 372 #define MULTIPLIER short /* prefer 16-bit with SIMD for parellelism */
michael@0 373 #endif
michael@0 374 #endif
michael@0 375
michael@0 376
michael@0 377 /* FAST_FLOAT should be either float or double, whichever is done faster
michael@0 378 * by your compiler. (Note that this type is only used in the floating point
michael@0 379 * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)
michael@0 380 * Typically, float is faster in ANSI C compilers, while double is faster in
michael@0 381 * pre-ANSI compilers (because they insist on converting to double anyway).
michael@0 382 * The code below therefore chooses float if we have ANSI-style prototypes.
michael@0 383 */
michael@0 384
michael@0 385 #ifndef FAST_FLOAT
michael@0 386 #ifdef HAVE_PROTOTYPES
michael@0 387 #define FAST_FLOAT float
michael@0 388 #else
michael@0 389 #define FAST_FLOAT double
michael@0 390 #endif
michael@0 391 #endif
michael@0 392
michael@0 393 #endif /* JPEG_INTERNAL_OPTIONS */

mercurial