/media/libjpeg/jmorecfg.h

http://github.com/zpao/v8monkey · C Header · 355 lines · 119 code · 86 blank · 150 comment · 2 complexity · 7d7d6dcc2b532c53ccc905eea9bb0fa7 MD5 · raw file

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