jmorecfg.h revision a2e6a9dd47eb10c701a42a16f305ded1a02cd886
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 * --------------------------------------------------------------------- 9 * x86 SIMD extension for IJG JPEG library 10 * Copyright (C) 1999-2006, MIYASAKA Masaru. 11 * This file has been modified for SIMD extension. 12 * Last Modified : March 28, 2005 13 * --------------------------------------------------------------------- 14 * 15 * This file contains additional configuration options that customize the 16 * JPEG software for special applications or support machine-dependent 17 * optimizations. Most users will not need to touch this file. 18 */ 19 20 21/* 22 * Define BITS_IN_JSAMPLE as either 23 * 8 for 8-bit sample values (the usual setting) 24 * 12 for 12-bit sample values 25 * Only 8 and 12 are legal data precisions for lossy JPEG according to the 26 * JPEG standard, and the IJG code does not support anything else! 27 * We do not support run-time selection of data precision, sorry. 28 */ 29 30/* SIMD Ext: This SIMD code only copes with 8-bit sample values. */ 31 32#define BITS_IN_JSAMPLE 8 /* SIMD Ext: cannot be changed! */ 33 34 35/* 36 * Maximum number of components (color channels) allowed in JPEG image. 37 * To meet the letter of the JPEG spec, set this to 255. However, darn 38 * few applications need more than 4 channels (maybe 5 for CMYK + alpha 39 * mask). We recommend 10 as a reasonable compromise; use 4 if you are 40 * really short on memory. (Each allowed component costs a hundred or so 41 * bytes of storage, whether actually used in an image or not.) 42 */ 43 44#define MAX_COMPONENTS 10 /* maximum number of image components */ 45 46 47/* 48 * Basic data types. 49 * You may need to change these if you have a machine with unusual data 50 * type sizes; for example, "char" not 8 bits, "short" not 16 bits, 51 * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, 52 * but it had better be at least 16. 53 */ 54 55/* Representation of a single sample (pixel element value). 56 * We frequently allocate large arrays of these, so it's important to keep 57 * them small. But if you have memory to burn and access to char or short 58 * arrays is very slow on your hardware, you might want to change these. 59 */ 60 61#if BITS_IN_JSAMPLE == 8 62/* JSAMPLE should be the smallest type that will hold the values 0..255. 63 * You can use a signed char by having GETJSAMPLE mask it with 0xFF. 64 */ 65 66#ifdef HAVE_UNSIGNED_CHAR 67 68typedef unsigned char JSAMPLE; 69#define GETJSAMPLE(value) ((int) (value)) 70 71#else /* not HAVE_UNSIGNED_CHAR */ 72 73typedef char JSAMPLE; 74#ifdef CHAR_IS_UNSIGNED 75#define GETJSAMPLE(value) ((int) (value)) 76#else 77#define GETJSAMPLE(value) ((int) (value) & 0xFF) 78#endif /* CHAR_IS_UNSIGNED */ 79 80#endif /* HAVE_UNSIGNED_CHAR */ 81 82#define MAXJSAMPLE 255 83#define CENTERJSAMPLE 128 84 85#endif /* BITS_IN_JSAMPLE == 8 */ 86 87 88#if BITS_IN_JSAMPLE == 12 89/* JSAMPLE should be the smallest type that will hold the values 0..4095. 90 * On nearly all machines "short" will do nicely. 91 */ 92 93typedef short JSAMPLE; 94#define GETJSAMPLE(value) ((int) (value)) 95 96#define MAXJSAMPLE 4095 97#define CENTERJSAMPLE 2048 98 99#endif /* BITS_IN_JSAMPLE == 12 */ 100 101 102/* Representation of a DCT frequency coefficient. 103 * This should be a signed value of at least 16 bits; "short" is usually OK. 104 * Again, we allocate large arrays of these, but you can change to int 105 * if you have memory to burn and "short" is really slow. 106 */ 107 108typedef short JCOEF; 109 110 111/* Compressed datastreams are represented as arrays of JOCTET. 112 * These must be EXACTLY 8 bits wide, at least once they are written to 113 * external storage. Note that when using the stdio data source/destination 114 * managers, this is also the data type passed to fread/fwrite. 115 */ 116 117#ifdef HAVE_UNSIGNED_CHAR 118 119typedef unsigned char JOCTET; 120#define GETJOCTET(value) (value) 121 122#else /* not HAVE_UNSIGNED_CHAR */ 123 124typedef char JOCTET; 125#ifdef CHAR_IS_UNSIGNED 126#define GETJOCTET(value) (value) 127#else 128#define GETJOCTET(value) ((value) & 0xFF) 129#endif /* CHAR_IS_UNSIGNED */ 130 131#endif /* HAVE_UNSIGNED_CHAR */ 132 133 134/* These typedefs are used for various table entries and so forth. 135 * They must be at least as wide as specified; but making them too big 136 * won't cost a huge amount of memory, so we don't provide special 137 * extraction code like we did for JSAMPLE. (In other words, these 138 * typedefs live at a different point on the speed/space tradeoff curve.) 139 */ 140 141/* UINT8 must hold at least the values 0..255. */ 142 143#ifdef HAVE_UNSIGNED_CHAR 144typedef unsigned char UINT8; 145#else /* not HAVE_UNSIGNED_CHAR */ 146#ifdef CHAR_IS_UNSIGNED 147typedef char UINT8; 148#else /* not CHAR_IS_UNSIGNED */ 149typedef short UINT8; 150#endif /* CHAR_IS_UNSIGNED */ 151#endif /* HAVE_UNSIGNED_CHAR */ 152 153/* UINT16 must hold at least the values 0..65535. */ 154 155#ifdef HAVE_UNSIGNED_SHORT 156typedef unsigned short UINT16; 157#else /* not HAVE_UNSIGNED_SHORT */ 158typedef unsigned int UINT16; 159#endif /* HAVE_UNSIGNED_SHORT */ 160 161/* INT16 must hold at least the values -32768..32767. */ 162 163#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ 164typedef short INT16; 165#endif 166 167/* INT32 must hold at least signed 32-bit values. */ 168 169 /* X11/xmd.h and basetsd.h (Win32 SDK) correctly define INT32 */ 170#if !defined(XMD_H) && !defined(_BASETSD_H_) && !defined(_BASETSD_H) 171typedef long INT32; 172#endif 173 174/* Datatype used for image dimensions. The JPEG standard only supports 175 * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore 176 * "unsigned int" is sufficient on all machines. However, if you need to 177 * handle larger images and you don't mind deviating from the spec, you 178 * can change this datatype. 179 */ 180 181typedef unsigned int JDIMENSION; 182 183#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ 184 185 186/* These macros are used in all function definitions and extern declarations. 187 * You could modify them if you need to change function linkage conventions; 188 * in particular, you'll need to do that to make the library a Windows DLL. 189 * Another application is to make all functions global for use with debuggers 190 * or code profilers that require it. 191 */ 192 193#if defined(_MSC_VER) || defined(__BORLANDC__) || \ 194 defined(__WATCOMC__) || defined(__MWERKS__) || \ 195 defined(__ICC) || defined(__INTEL_COMPILER) 196#define JCDECL __cdecl 197#elif defined(__GNUC__) 198#define JCDECL __attribute__((__cdecl__)) 199#else 200#define JCDECL 201#endif 202 203/* a function called through method pointers: */ 204#define METHODDEF(type) static type JCDECL 205/* a function used only in its module: */ 206#define LOCAL(type) static type 207/* a function referenced thru EXTERNs: */ 208#define GLOBAL(type) type JCDECL 209/* a reference to a GLOBAL function: */ 210#define EXTERN(type) extern type JCDECL 211 212 213/* This macro is used to declare a "method", that is, a function pointer. 214 * We want to supply prototype parameters if the compiler can cope. 215 * Note that the arglist parameter must be parenthesized! 216 * Again, you can customize this if you need special linkage keywords. 217 */ 218 219#ifdef HAVE_PROTOTYPES 220#define JMETHOD(type,methodname,arglist) type (JCDECL *methodname) arglist 221#else 222#define JMETHOD(type,methodname,arglist) type (JCDECL *methodname) () 223#endif 224 225 226/* Here is the pseudo-keyword for declaring pointers that must be "far" 227 * on 80x86 machines. Most of the specialized coding for 80x86 is handled 228 * by just saying "FAR *" where such a pointer is needed. In a few places 229 * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. 230 */ 231 232#ifndef FAR 233#ifdef NEED_FAR_POINTERS 234#define FAR far 235#else 236#define FAR 237#endif 238#endif /* !FAR */ 239 240 241/* 242 * On a few systems, type boolean and/or its values FALSE, TRUE may appear 243 * in standard header files. Or you may have conflicts with application- 244 * specific header files that you want to include together with these files. 245 * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. 246 */ 247 248#ifndef HAVE_BOOLEAN 249#ifdef TYPEDEF_UCHAR_BOOLEAN 250#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ 251typedef unsigned char boolean; 252#endif 253#else /* !TYPEDEF_UCHAR_BOOLEAN */ 254typedef int boolean; 255#endif /* TYPEDEF_UCHAR_BOOLEAN */ 256#endif /* !HAVE_BOOLEAN */ 257#ifndef FALSE /* in case these macros already exist */ 258#define FALSE 0 /* values of boolean */ 259#endif 260#ifndef TRUE 261#define TRUE 1 262#endif 263 264 265/* 266 * The remaining options affect code selection within the JPEG library, 267 * but they don't need to be visible to most applications using the library. 268 * To minimize application namespace pollution, the symbols won't be 269 * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. 270 */ 271 272#ifdef JPEG_INTERNALS 273#define JPEG_INTERNAL_OPTIONS 274#endif 275 276#ifdef JPEG_INTERNAL_OPTIONS 277 278 279/* 280 * These defines indicate whether to include various optional functions. 281 * Undefining some of these symbols will produce a smaller but less capable 282 * library. Note that you can leave certain source files out of the 283 * compilation/linking process if you've #undef'd the corresponding symbols. 284 * (You may HAVE to do that if your compiler doesn't like null source files.) 285 */ 286 287/* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */ 288 289/* Capability options common to encoder and decoder: */ 290 291#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ 292#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ 293#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ 294 295/* Encoder capability options: */ 296 297#undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ 298#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ 299#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ 300#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ 301/* Note: if you selected 12-bit data precision, it is dangerous to turn off 302 * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit 303 * precision, so jchuff.c normally uses entropy optimization to compute 304 * usable tables for higher precision. If you don't want to do optimization, 305 * you'll have to supply different default Huffman tables. 306 * The exact same statements apply for progressive JPEG: the default tables 307 * don't work for progressive mode. (This may get fixed, however.) 308 */ 309#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ 310 311/* Decoder capability options: */ 312 313#undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ 314#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ 315#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ 316#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ 317#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ 318#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ 319#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ 320#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ 321#define UPSAMPLE_H1V2_SUPPORTED /* Fast/fancy processing for 1h2v? */ 322#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ 323#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ 324 325/* more capability options later, no doubt */ 326 327 328/* 329 * Ordering of RGB data in scanlines passed to or from the application. 330 * If your application wants to deal with data in the order B,G,R, just 331 * change these macros. You can also deal with formats such as R,G,B,X 332 * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing 333 * the offsets will also change the order in which colormap data is organized. 334 * RESTRICTIONS: 335 * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. 336 * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not 337 * useful if you are using JPEG color spaces other than YCbCr or grayscale. 338 * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE 339 * is not 3 (they don't understand about dummy color components!). So you 340 * can't use color quantization if you change that value. 341 */ 342 343#define RGB_RED 0 /* Offset of Red in an RGB scanline element */ 344#define RGB_GREEN 1 /* Offset of Green */ 345#define RGB_BLUE 2 /* Offset of Blue */ 346#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ 347 348#undef RGBX_FILLER_0XFF /* fill dummy bytes with 0xFF in RGBX format */ 349 350 351/* SIMD support options: */ 352 353#ifndef JSIMD_MMX_NOT_SUPPORTED 354#define JSIMD_ENCODER_MMX_SUPPORTED /* Use MMX in encoding process */ 355#define JSIMD_DECODER_MMX_SUPPORTED /* Use MMX in decoding process */ 356#endif 357#ifndef JSIMD_3DNOW_NOT_SUPPORTED 358#define JSIMD_ENCODER_3DNOW_SUPPORTED /* Use 3DNow! in encoding process */ 359#define JSIMD_DECODER_3DNOW_SUPPORTED /* Use 3DNow! in decoding process */ 360#endif 361#ifndef JSIMD_SSE_NOT_SUPPORTED 362#define JSIMD_ENCODER_SSE_SUPPORTED /* Use SSE in encoding process */ 363#define JSIMD_DECODER_SSE_SUPPORTED /* Use SSE in decoding process */ 364#endif 365#ifndef JSIMD_SSE2_NOT_SUPPORTED 366#define JSIMD_ENCODER_SSE2_SUPPORTED /* Use SSE2 in encoding process */ 367#define JSIMD_DECODER_SSE2_SUPPORTED /* Use SSE2 in decoding process */ 368#endif 369 370/* (encoder part): */ 371 372#undef JFDCT_INT_QUANTIZE_WITH_DIVISION /* Use general quantization method */ 373 374#if defined(JSIMD_ENCODER_MMX_SUPPORTED) 375#define JCCOLOR_RGBYCC_MMX_SUPPORTED /* RGB->YCC conversion with MMX */ 376#define JCSAMPLE_MMX_SUPPORTED /* downsampling with MMX */ 377#define JFDCT_INT_MMX_SUPPORTED /* forward DCT with MMX */ 378#endif 379#if defined(JSIMD_ENCODER_SSE2_SUPPORTED) 380#define JCCOLOR_RGBYCC_SSE2_SUPPORTED /* RGB->YCC conversion with SSE2 */ 381#define JCSAMPLE_SSE2_SUPPORTED /* downsampling with SSE2 */ 382#define JFDCT_INT_SSE2_SUPPORTED /* forward DCT with SSE2 */ 383#endif 384#if defined(JSIMD_ENCODER_3DNOW_SUPPORTED) && \ 385 defined(JSIMD_ENCODER_MMX_SUPPORTED) 386#define JFDCT_FLT_3DNOW_MMX_SUPPORTED /* forward DCT with 3DNow!/MMX */ 387#endif 388#if defined(JSIMD_ENCODER_SSE_SUPPORTED) && \ 389 defined(JSIMD_ENCODER_MMX_SUPPORTED) 390#define JFDCT_FLT_SSE_MMX_SUPPORTED /* forward DCT with SSE/MMX */ 391#endif 392#if defined(JSIMD_ENCODER_SSE_SUPPORTED) && \ 393 defined(JSIMD_ENCODER_SSE2_SUPPORTED) 394#define JFDCT_FLT_SSE_SSE2_SUPPORTED /* forward DCT with SSE/SSE2 */ 395#endif 396 397/* (decoder part): */ 398 399#if defined(JSIMD_DECODER_MMX_SUPPORTED) 400#define JDCOLOR_YCCRGB_MMX_SUPPORTED /* YCC->RGB conversion with MMX */ 401#define JDMERGE_MMX_SUPPORTED /* merged upsampling with MMX */ 402#define JDSAMPLE_FANCY_MMX_SUPPORTED /* fancy upsampling with MMX */ 403#define JDSAMPLE_SIMPLE_MMX_SUPPORTED /* sloppy upsampling with MMX */ 404#define JIDCT_INT_MMX_SUPPORTED /* inverse DCT with MMX */ 405#endif 406#if defined(JSIMD_DECODER_SSE2_SUPPORTED) 407#define JDCOLOR_YCCRGB_SSE2_SUPPORTED /* YCC->RGB conversion with SSE2 */ 408#define JDMERGE_SSE2_SUPPORTED /* merged upsampling with SSE2 */ 409#define JDSAMPLE_FANCY_SSE2_SUPPORTED /* fancy upsampling with SSE2 */ 410#define JDSAMPLE_SIMPLE_SSE2_SUPPORTED /* sloppy upsampling with SSE2 */ 411#define JIDCT_INT_SSE2_SUPPORTED /* inverse DCT with SSE2 */ 412#endif 413#if defined(JSIMD_DECODER_3DNOW_SUPPORTED) && \ 414 defined(JSIMD_DECODER_MMX_SUPPORTED) 415#define JIDCT_FLT_3DNOW_MMX_SUPPORTED /* inverse DCT with 3DNow!/MMX */ 416#endif 417#if defined(JSIMD_DECODER_SSE_SUPPORTED) && \ 418 defined(JSIMD_DECODER_MMX_SUPPORTED) 419#define JIDCT_FLT_SSE_MMX_SUPPORTED /* inverse DCT with SSE/MMX */ 420#endif 421#if defined(JSIMD_DECODER_SSE_SUPPORTED) && \ 422 defined(JSIMD_DECODER_SSE2_SUPPORTED) 423#define JIDCT_FLT_SSE_SSE2_SUPPORTED /* inverse DCT with SSE/SSE2 */ 424#endif 425 426 427/* Definitions for speed-related optimizations. */ 428 429 430/* If your compiler supports inline functions, define INLINE 431 * as the inline keyword; otherwise define it as empty. 432 */ 433 434#ifndef INLINE 435#ifdef __GNUC__ /* for instance, GNU C knows about inline */ 436#define INLINE __inline__ 437#endif 438#ifdef _MSC_VER 439#define INLINE __inline 440#endif 441#ifndef INLINE 442#define INLINE /* default is to define it as empty */ 443#endif 444#endif 445 446 447/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying 448 * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER 449 * as short on such a machine. MULTIPLIER must be at least 16 bits wide. 450 */ 451 452#ifndef MULTIPLIER 453#define MULTIPLIER int /* type for fastest integer multiply */ 454#endif 455 456 457/* FAST_FLOAT should be either float or double, whichever is done faster 458 * by your compiler. (Note that this type is only used in the floating point 459 * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) 460 * Typically, float is faster in ANSI C compilers, while double is faster in 461 * pre-ANSI compilers (because they insist on converting to double anyway). 462 * The code below therefore chooses float if we have ANSI-style prototypes. 463 */ 464 465#ifndef FAST_FLOAT 466#ifdef HAVE_PROTOTYPES 467#define FAST_FLOAT float 468#else 469#define FAST_FLOAT double 470#endif 471#endif 472 473#endif /* JPEG_INTERNAL_OPTIONS */ 474