JMORECFG.h
上传用户:qiutianh
上传日期:2022-08-08
资源大小:939k
文件大小:13k
源码类别:

图形图象

开发平台:

Visual C++

  1. ////////////////////////////////////////////////////////////////////////
  2. //
  3. // Note : this file is included as part of the Smaller Animals Software
  4. // JpegFile package. Though this file has not been modified from it's 
  5. // original IJG 6a form, it is not the responsibility on the Independent
  6. // JPEG Group to answer questions regarding this code.
  7. //
  8. // Any questions you have about this code should be addressed to :
  9. //
  10. // CHRISDL@PAGESZ.NET - the distributor of this package.
  11. //
  12. // Remember, by including this code in the JpegFile package, Smaller 
  13. // Animals Software assumes all responsibilities for answering questions
  14. // about it. If we (SA Software) can't answer your questions ourselves, we 
  15. // will direct you to people who can.
  16. //
  17. // Thanks, CDL.
  18. //
  19. ////////////////////////////////////////////////////////////////////////
  20. /*
  21.  * jmorecfg.h
  22.  *
  23.  * Copyright (C) 1991-1996, Thomas G. Lane.
  24.  * This file is part of the Independent JPEG Group's software.
  25.  * For conditions of distribution and use, see the accompanying README file.
  26.  *
  27.  * This file contains additional configuration options that customize the
  28.  * JPEG software for special applications or support machine-dependent
  29.  * optimizations.  Most users will not need to touch this file.
  30.  */
  31. /*
  32.  * Define BITS_IN_JSAMPLE as either
  33.  *   8   for 8-bit sample values (the usual setting)
  34.  *   12  for 12-bit sample values
  35.  * Only 8 and 12 are legal data precisions for lossy JPEG according to the
  36.  * JPEG standard, and the IJG code does not support anything else!
  37.  * We do not support run-time selection of data precision, sorry.
  38.  */
  39. #define BITS_IN_JSAMPLE  8 /* use 8 or 12 */
  40. /*
  41.  * Maximum number of components (color channels) allowed in JPEG image.
  42.  * To meet the letter of the JPEG spec, set this to 255.  However, darn
  43.  * few applications need more than 4 channels (maybe 5 for CMYK + alpha
  44.  * mask).  We recommend 10 as a reasonable compromise; use 4 if you are
  45.  * really short on memory.  (Each allowed component costs a hundred or so
  46.  * bytes of storage, whether actually used in an image or not.)
  47.  */
  48. #define MAX_COMPONENTS  10 /* maximum number of image components */
  49. /*
  50.  * Basic data types.
  51.  * You may need to change these if you have a machine with unusual data
  52.  * type sizes; for example, "char" not 8 bits, "short" not 16 bits,
  53.  * or "long" not 32 bits.  We don't care whether "int" is 16 or 32 bits,
  54.  * but it had better be at least 16.
  55.  */
  56. /* Representation of a single sample (pixel element value).
  57.  * We frequently allocate large arrays of these, so it's important to keep
  58.  * them small.  But if you have memory to burn and access to char or short
  59.  * arrays is very slow on your hardware, you might want to change these.
  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. #ifdef HAVE_UNSIGNED_CHAR
  66. typedef unsigned char JSAMPLE;
  67. #define GETJSAMPLE(value)  ((int) (value))
  68. #else /* not HAVE_UNSIGNED_CHAR */
  69. typedef char JSAMPLE;
  70. #ifdef CHAR_IS_UNSIGNED
  71. #define GETJSAMPLE(value)  ((int) (value))
  72. #else
  73. #define GETJSAMPLE(value)  ((int) (value) & 0xFF)
  74. #endif /* CHAR_IS_UNSIGNED */
  75. #endif /* HAVE_UNSIGNED_CHAR */
  76. #define MAXJSAMPLE 255
  77. #define CENTERJSAMPLE 128
  78. #endif /* BITS_IN_JSAMPLE == 8 */
  79. #if BITS_IN_JSAMPLE == 12
  80. /* JSAMPLE should be the smallest type that will hold the values 0..4095.
  81.  * On nearly all machines "short" will do nicely.
  82.  */
  83. typedef short JSAMPLE;
  84. #define GETJSAMPLE(value)  ((int) (value))
  85. #define MAXJSAMPLE 4095
  86. #define CENTERJSAMPLE 2048
  87. #endif /* BITS_IN_JSAMPLE == 12 */
  88. /* Representation of a DCT frequency coefficient.
  89.  * This should be a signed value of at least 16 bits; "short" is usually OK.
  90.  * Again, we allocate large arrays of these, but you can change to int
  91.  * if you have memory to burn and "short" is really slow.
  92.  */
  93. typedef short JCOEF;
  94. /* Compressed datastreams are represented as arrays of JOCTET.
  95.  * These must be EXACTLY 8 bits wide, at least once they are written to
  96.  * external storage.  Note that when using the stdio data source/destination
  97.  * managers, this is also the data type passed to fread/fwrite.
  98.  */
  99. #ifdef HAVE_UNSIGNED_CHAR
  100. typedef unsigned char JOCTET;
  101. #define GETJOCTET(value)  (value)
  102. #else /* not HAVE_UNSIGNED_CHAR */
  103. typedef char JOCTET;
  104. #ifdef CHAR_IS_UNSIGNED
  105. #define GETJOCTET(value)  (value)
  106. #else
  107. #define GETJOCTET(value)  ((value) & 0xFF)
  108. #endif /* CHAR_IS_UNSIGNED */
  109. #endif /* HAVE_UNSIGNED_CHAR */
  110. /* These typedefs are used for various table entries and so forth.
  111.  * They must be at least as wide as specified; but making them too big
  112.  * won't cost a huge amount of memory, so we don't provide special
  113.  * extraction code like we did for JSAMPLE.  (In other words, these
  114.  * typedefs live at a different point on the speed/space tradeoff curve.)
  115.  */
  116. /* UINT8 must hold at least the values 0..255. */
  117. #ifdef HAVE_UNSIGNED_CHAR
  118. typedef unsigned char UINT8;
  119. #else /* not HAVE_UNSIGNED_CHAR */
  120. #ifdef CHAR_IS_UNSIGNED
  121. typedef char UINT8;
  122. #else /* not CHAR_IS_UNSIGNED */
  123. typedef short UINT8;
  124. #endif /* CHAR_IS_UNSIGNED */
  125. #endif /* HAVE_UNSIGNED_CHAR */
  126. /* Ushort must hold at least the values 0..65535. */
  127. #ifdef HAVE_UNSIGNED_SHORT
  128. typedef unsigned short Ushort;
  129. #else /* not HAVE_UNSIGNED_SHORT */
  130. typedef unsigned int Ushort;
  131. #endif /* HAVE_UNSIGNED_SHORT */
  132. /* Datatype used for image dimensions.  The JPEG standard only supports
  133.  * images up to 64K*64K due to 16-bit fields in SOF markers.  Therefore
  134.  * "unsigned int" is sufficient on all machines.  However, if you need to
  135.  * handle larger images and you don't mind deviating from the spec, you
  136.  * can change this datatype.
  137.  */
  138. typedef unsigned int JDIMENSION;
  139. #define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
  140. /* These macros are used in all function definitions and extern declarations.
  141.  * You could modify them if you need to change function linkage conventions;
  142.  * in particular, you'll need to do that to make the library a Windows DLL.
  143.  * Another application is to make all functions global for use with debuggers
  144.  * or code profilers that require it.
  145.  */
  146. /* a function called through method pointers: */
  147. #define METHODDEF(type) static type
  148. /* a function used only in its module: */
  149. #define LOCAL(type) static type
  150. /* a function referenced thru EXTERNs: */
  151. #define GLOBAL(type) type
  152. /* a reference to a GLOBAL function: */
  153. #define EXTERN(type) extern type
  154. /* This macro is used to declare a "method", that is, a function pointer.
  155.  * We want to supply prototype parameters if the compiler can cope.
  156.  * Note that the arglist parameter must be parenthesized!
  157.  * Again, you can customize this if you need special linkage keywords.
  158.  */
  159. #ifdef HAVE_PROTOTYPES
  160. #define JMETHOD(type,methodname,arglist)  type (*methodname) arglist
  161. #else
  162. #define JMETHOD(type,methodname,arglist)  type (*methodname) ()
  163. #endif
  164. /* Here is the pseudo-keyword for declaring pointers that must be "far"
  165.  * on 80x86 machines.  Most of the specialized coding for 80x86 is handled
  166.  * by just saying "FAR *" where such a pointer is needed.  In a few places
  167.  * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol.
  168.  */
  169. #ifdef NEED_FAR_POINTERS
  170. #define FAR  far
  171. #else
  172. #ifndef FAR
  173. #define FAR
  174. #endif
  175. #endif
  176. /*
  177.  * On a few systems, type boolean and/or its values FALSE, TRUE may appear
  178.  * in standard header files.  Or you may have conflicts with application-
  179.  * specific header files that you want to include together with these files.
  180.  * Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
  181.  */
  182. #ifndef HAVE_BOOLEAN
  183. typedef int boolean;
  184. #endif
  185. #ifndef FALSE /* in case these macros already exist */
  186. #define FALSE 0 /* values of boolean */
  187. #endif
  188. #ifndef TRUE
  189. #define TRUE 1
  190. #endif
  191. /*
  192.  * The remaining options affect code selection within the JPEG library,
  193.  * but they don't need to be visible to most applications using the library.
  194.  * To minimize application namespace pollution, the symbols won't be
  195.  * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.
  196.  */
  197. #ifdef JPEG_INTERNALS
  198. #define JPEG_INTERNAL_OPTIONS
  199. #endif
  200. #ifdef JPEG_INTERNAL_OPTIONS
  201. /*
  202.  * These defines indicate whether to include various optional functions.
  203.  * Undefining some of these symbols will produce a smaller but less capable
  204.  * library.  Note that you can leave certain source files out of the
  205.  * compilation/linking process if you've #undef'd the corresponding symbols.
  206.  * (You may HAVE to do that if your compiler doesn't like null source files.)
  207.  */
  208. /* Arithmetic coding is unsupported for legal reasons.  Complaints to IBM. */
  209. /* Capability options common to encoder and decoder: */
  210. #define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */
  211. #define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */
  212. #define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */
  213. /* Encoder capability options: */
  214. #undef  C_ARITH_CODING_SUPPORTED    /* Arithmetic coding back end? */
  215. #define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
  216. #define C_PROGRESSIVE_SUPPORTED     /* Progressive JPEG? (Requires MULTISCAN)*/
  217. #define ENTROPY_OPT_SUPPORTED     /* Optimization of entropy coding parms? */
  218. /* Note: if you selected 12-bit data precision, it is dangerous to turn off
  219.  * ENTROPY_OPT_SUPPORTED.  The standard Huffman tables are only good for 8-bit
  220.  * precision, so jchuff.c normally uses entropy optimization to compute
  221.  * usable tables for higher precision.  If you don't want to do optimization,
  222.  * you'll have to supply different default Huffman tables.
  223.  * The exact same statements apply for progressive JPEG: the default tables
  224.  * don't work for progressive mode.  (This may get fixed, however.)
  225.  */
  226. #define INPUT_SMOOTHING_SUPPORTED   /* Input image smoothing option? */
  227. /* Decoder capability options: */
  228. #undef  D_ARITH_CODING_SUPPORTED    /* Arithmetic coding back end? */
  229. #define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
  230. #define D_PROGRESSIVE_SUPPORTED     /* Progressive JPEG? (Requires MULTISCAN)*/
  231. #define BLOCK_SMOOTHING_SUPPORTED   /* Block smoothing? (Progressive only) */
  232. #define IDCT_SCALING_SUPPORTED     /* Output rescaling via IDCT? */
  233. #undef  UPSAMPLE_SCALING_SUPPORTED  /* Output rescaling at upsample stage? */
  234. #define UPSAMPLE_MERGING_SUPPORTED  /* Fast path for sloppy upsampling? */
  235. #define QUANT_1PASS_SUPPORTED     /* 1-pass color quantization? */
  236. #define QUANT_2PASS_SUPPORTED     /* 2-pass color quantization? */
  237. /* more capability options later, no doubt */
  238. /*
  239.  * Ordering of RGB data in scanlines passed to or from the application.
  240.  * If your application wants to deal with data in the order B,G,R, just
  241.  * change these macros.  You can also deal with formats such as R,G,B,X
  242.  * (one extra byte per pixel) by changing RGB_PIXELSIZE.  Note that changing
  243.  * the offsets will also change the order in which colormap data is organized.
  244.  * RESTRICTIONS:
  245.  * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.
  246.  * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not
  247.  *    useful if you are using JPEG color spaces other than YCbCr or grayscale.
  248.  * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
  249.  *    is not 3 (they don't understand about dummy color components!).  So you
  250.  *    can't use color quantization if you change that value.
  251.  */
  252. #define RGB_RED 0 /* Offset of Red in an RGB scanline element */
  253. #define RGB_GREEN 1 /* Offset of Green */
  254. #define RGB_BLUE 2 /* Offset of Blue */
  255. #define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
  256. /* Definitions for speed-related optimizations. */
  257. /* If your compiler supports inline functions, define INLINE
  258.  * as the inline keyword; otherwise define it as empty.
  259.  */
  260. #ifndef INLINE
  261. #ifdef __GNUC__ /* for instance, GNU C knows about inline */
  262. #define INLINE __inline__
  263. #endif
  264. #ifndef INLINE
  265. #define INLINE /* default is to define it as empty */
  266. #endif
  267. #endif
  268. /* On some machines (notably 68000 series) "int" is 32 bits, but multiplying
  269.  * two 16-bit shorts is faster than multiplying two ints.  Define MULTIPLIER
  270.  * as short on such a machine.  MULTIPLIER must be at least 16 bits wide.
  271.  */
  272. #ifndef MULTIPLIER
  273. #define MULTIPLIER  int /* type for fastest integer multiply */
  274. #endif
  275. /* FAST_FLOAT should be either float or double, whichever is done faster
  276.  * by your compiler.  (Note that this type is only used in the floating point
  277.  * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)
  278.  * Typically, float is faster in ANSI C compilers, while double is faster in
  279.  * pre-ANSI compilers (because they insist on converting to double anyway).
  280.  * The code below therefore chooses float if we have ANSI-style prototypes.
  281.  */
  282. #ifndef FAST_FLOAT
  283. #ifdef HAVE_PROTOTYPES
  284. #define FAST_FLOAT  float
  285. #else
  286. #define FAST_FLOAT  double
  287. #endif
  288. #endif
  289. #endif /* JPEG_INTERNAL_OPTIONS */