1
0

jmorecfg.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. /*
  2. * jmorecfg.h
  3. *
  4. * Copyright (C) 1991-1997, Thomas G. Lane.
  5. * Modified 1997-2013 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. * Define BITS_IN_JSAMPLE as either
  15. * 8 for 8-bit sample values (the usual setting)
  16. * 9 for 9-bit sample values
  17. * 10 for 10-bit sample values
  18. * 11 for 11-bit sample values
  19. * 12 for 12-bit sample values
  20. * Only 8, 9, 10, 11, and 12 bits sample data precision are supported for
  21. * full-feature DCT processing. Further depths up to 16-bit may be added
  22. * later for the lossless modes of operation.
  23. * Run-time selection and conversion of data precision will be added later
  24. * and are currently not supported, sorry.
  25. * Exception: The transcoding part (jpegtran) supports all settings in a
  26. * single instance, since it operates on the level of DCT coefficients and
  27. * not sample values. The DCT coefficients are of the same type (16 bits)
  28. * in all cases (see below).
  29. */
  30. #define BITS_IN_JSAMPLE 8 /* use 8, 9, 10, 11, or 12 */
  31. /*
  32. * Maximum number of components (color channels) allowed in JPEG image.
  33. * To meet the letter of the JPEG spec, set this to 255. However, darn
  34. * few applications need more than 4 channels (maybe 5 for CMYK + alpha
  35. * mask). We recommend 10 as a reasonable compromise; use 4 if you are
  36. * really short on memory. (Each allowed component costs a hundred or so
  37. * bytes of storage, whether actually used in an image or not.)
  38. */
  39. #define MAX_COMPONENTS 10 /* maximum number of image components */
  40. /*
  41. * Basic data types.
  42. * You may need to change these if you have a machine with unusual data
  43. * type sizes; for example, "char" not 8 bits, "short" not 16 bits,
  44. * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits,
  45. * but it had better be at least 16.
  46. */
  47. /* Representation of a single sample (pixel element value).
  48. * We frequently allocate large arrays of these, so it's important to keep
  49. * them small. But if you have memory to burn and access to char or short
  50. * arrays is very slow on your hardware, you might want to change these.
  51. */
  52. #if BITS_IN_JSAMPLE == 8
  53. /* JSAMPLE should be the smallest type that will hold the values 0..255.
  54. * You can use a signed char by having GETJSAMPLE mask it with 0xFF.
  55. */
  56. #ifdef HAVE_UNSIGNED_CHAR
  57. typedef unsigned char JSAMPLE;
  58. #define GETJSAMPLE(value) ((int) (value))
  59. #else /* not HAVE_UNSIGNED_CHAR */
  60. typedef char JSAMPLE;
  61. #ifdef CHAR_IS_UNSIGNED
  62. #define GETJSAMPLE(value) ((int) (value))
  63. #else
  64. #define GETJSAMPLE(value) ((int) (value) & 0xFF)
  65. #endif /* CHAR_IS_UNSIGNED */
  66. #endif /* HAVE_UNSIGNED_CHAR */
  67. #define MAXJSAMPLE 255
  68. #define CENTERJSAMPLE 128
  69. #endif /* BITS_IN_JSAMPLE == 8 */
  70. #if BITS_IN_JSAMPLE == 9
  71. /* JSAMPLE should be the smallest type that will hold the values 0..511.
  72. * On nearly all machines "short" will do nicely.
  73. */
  74. typedef short JSAMPLE;
  75. #define GETJSAMPLE(value) ((int) (value))
  76. #define MAXJSAMPLE 511
  77. #define CENTERJSAMPLE 256
  78. #endif /* BITS_IN_JSAMPLE == 9 */
  79. #if BITS_IN_JSAMPLE == 10
  80. /* JSAMPLE should be the smallest type that will hold the values 0..1023.
  81. * On nearly all machines "short" will do nicely.
  82. */
  83. typedef short JSAMPLE;
  84. #define GETJSAMPLE(value) ((int) (value))
  85. #define MAXJSAMPLE 1023
  86. #define CENTERJSAMPLE 512
  87. #endif /* BITS_IN_JSAMPLE == 10 */
  88. #if BITS_IN_JSAMPLE == 11
  89. /* JSAMPLE should be the smallest type that will hold the values 0..2047.
  90. * On nearly all machines "short" will do nicely.
  91. */
  92. typedef short JSAMPLE;
  93. #define GETJSAMPLE(value) ((int) (value))
  94. #define MAXJSAMPLE 2047
  95. #define CENTERJSAMPLE 1024
  96. #endif /* BITS_IN_JSAMPLE == 11 */
  97. #if BITS_IN_JSAMPLE == 12
  98. /* JSAMPLE should be the smallest type that will hold the values 0..4095.
  99. * On nearly all machines "short" will do nicely.
  100. */
  101. typedef short JSAMPLE;
  102. #define GETJSAMPLE(value) ((int) (value))
  103. #define MAXJSAMPLE 4095
  104. #define CENTERJSAMPLE 2048
  105. #endif /* BITS_IN_JSAMPLE == 12 */
  106. /* Representation of a DCT frequency coefficient.
  107. * This should be a signed value of at least 16 bits; "short" is usually OK.
  108. * Again, we allocate large arrays of these, but you can change to int
  109. * if you have memory to burn and "short" is really slow.
  110. */
  111. typedef short JCOEF;
  112. /* Compressed datastreams are represented as arrays of JOCTET.
  113. * These must be EXACTLY 8 bits wide, at least once they are written to
  114. * external storage. Note that when using the stdio data source/destination
  115. * managers, this is also the data type passed to fread/fwrite.
  116. */
  117. #ifdef HAVE_UNSIGNED_CHAR
  118. typedef unsigned char JOCTET;
  119. #define GETJOCTET(value) (value)
  120. #else /* not HAVE_UNSIGNED_CHAR */
  121. typedef char JOCTET;
  122. #ifdef CHAR_IS_UNSIGNED
  123. #define GETJOCTET(value) (value)
  124. #else
  125. #define GETJOCTET(value) ((value) & 0xFF)
  126. #endif /* CHAR_IS_UNSIGNED */
  127. #endif /* HAVE_UNSIGNED_CHAR */
  128. /* These typedefs are used for various table entries and so forth.
  129. * They must be at least as wide as specified; but making them too big
  130. * won't cost a huge amount of memory, so we don't provide special
  131. * extraction code like we did for JSAMPLE. (In other words, these
  132. * typedefs live at a different point on the speed/space tradeoff curve.)
  133. */
  134. /* UINT8 must hold at least the values 0..255. */
  135. #ifdef HAVE_UNSIGNED_CHAR
  136. typedef unsigned char UINT8;
  137. #else /* not HAVE_UNSIGNED_CHAR */
  138. #ifdef CHAR_IS_UNSIGNED
  139. typedef char UINT8;
  140. #else /* not CHAR_IS_UNSIGNED */
  141. typedef short UINT8;
  142. #endif /* CHAR_IS_UNSIGNED */
  143. #endif /* HAVE_UNSIGNED_CHAR */
  144. /* UINT16 must hold at least the values 0..65535. */
  145. #ifdef HAVE_UNSIGNED_SHORT
  146. typedef unsigned short UINT16;
  147. #else /* not HAVE_UNSIGNED_SHORT */
  148. typedef unsigned int UINT16;
  149. #endif /* HAVE_UNSIGNED_SHORT */
  150. /* INT16 must hold at least the values -32768..32767. */
  151. #ifndef XMD_H /* X11/xmd.h correctly defines INT16 */
  152. typedef short INT16;
  153. #endif
  154. /* INT32 must hold at least signed 32-bit values. */
  155. #ifndef XMD_H /* X11/xmd.h correctly defines INT32 */
  156. #ifndef _BASETSD_H_ /* Microsoft defines it in basetsd.h */
  157. #ifndef _BASETSD_H /* MinGW is slightly different */
  158. #ifndef QGLOBAL_H /* Qt defines it in qglobal.h */
  159. typedef long INT32;
  160. #endif
  161. #endif
  162. #endif
  163. #endif
  164. /* Datatype used for image dimensions. The JPEG standard only supports
  165. * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
  166. * "unsigned int" is sufficient on all machines. However, if you need to
  167. * handle larger images and you don't mind deviating from the spec, you
  168. * can change this datatype.
  169. */
  170. typedef unsigned int JDIMENSION;
  171. #define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */
  172. /* These macros are used in all function definitions and extern declarations.
  173. * You could modify them if you need to change function linkage conventions;
  174. * in particular, you'll need to do that to make the library a Windows DLL.
  175. * Another application is to make all functions global for use with debuggers
  176. * or code profilers that require it.
  177. */
  178. /* a function called through method pointers: */
  179. #define METHODDEF(type) static type
  180. /* a function used only in its module: */
  181. #define LOCAL(type) static type
  182. /* a function referenced thru EXTERNs: */
  183. #define GLOBAL(type) type
  184. /* a reference to a GLOBAL function: */
  185. #define EXTERN(type) extern type
  186. /* This macro is used to declare a "method", that is, a function pointer.
  187. * We want to supply prototype parameters if the compiler can cope.
  188. * Note that the arglist parameter must be parenthesized!
  189. * Again, you can customize this if you need special linkage keywords.
  190. */
  191. #ifdef HAVE_PROTOTYPES
  192. #define JMETHOD(type,methodname,arglist) type (*methodname) arglist
  193. #else
  194. #define JMETHOD(type,methodname,arglist) type (*methodname) ()
  195. #endif
  196. /* The noreturn type identifier is used to declare functions
  197. * which cannot return.
  198. * Compilers can thus create more optimized code and perform
  199. * better checks for warnings and errors.
  200. * Static analyzer tools can make improved inferences about
  201. * execution paths and are prevented from giving false alerts.
  202. *
  203. * Unfortunately, the proposed specifications of corresponding
  204. * extensions in the Dec 2011 ISO C standard revision (C11),
  205. * GCC, MSVC, etc. are not viable.
  206. * Thus we introduce a user defined type to declare noreturn
  207. * functions at least for clarity. A proper compiler would
  208. * have a suitable noreturn type to match in place of void.
  209. */
  210. #ifndef HAVE_NORETURN_T
  211. typedef void noreturn_t;
  212. #endif
  213. /* Here is the pseudo-keyword for declaring pointers that must be "far"
  214. * on 80x86 machines. Most of the specialized coding for 80x86 is handled
  215. * by just saying "FAR *" where such a pointer is needed. In a few places
  216. * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol.
  217. */
  218. #ifndef FAR
  219. #ifdef NEED_FAR_POINTERS
  220. #define FAR far
  221. #else
  222. #define FAR
  223. #endif
  224. #endif
  225. /*
  226. * On a few systems, type boolean and/or its values FALSE, TRUE may appear
  227. * in standard header files. Or you may have conflicts with application-
  228. * specific header files that you want to include together with these files.
  229. * Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
  230. */
  231. #ifndef HAVE_BOOLEAN
  232. #if defined FALSE || defined TRUE || defined QGLOBAL_H
  233. /* Qt3 defines FALSE and TRUE as "const" variables in qglobal.h */
  234. typedef int boolean;
  235. #ifndef FALSE /* in case these macros already exist */
  236. #define FALSE 0 /* values of boolean */
  237. #endif
  238. #ifndef TRUE
  239. #define TRUE 1
  240. #endif
  241. #else
  242. typedef enum { FALSE = 0, TRUE = 1 } boolean;
  243. #endif
  244. #endif
  245. /*
  246. * The remaining options affect code selection within the JPEG library,
  247. * but they don't need to be visible to most applications using the library.
  248. * To minimize application namespace pollution, the symbols won't be
  249. * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.
  250. */
  251. #ifdef JPEG_INTERNALS
  252. #define JPEG_INTERNAL_OPTIONS
  253. #endif
  254. #ifdef JPEG_INTERNAL_OPTIONS
  255. /*
  256. * These defines indicate whether to include various optional functions.
  257. * Undefining some of these symbols will produce a smaller but less capable
  258. * library. Note that you can leave certain source files out of the
  259. * compilation/linking process if you've #undef'd the corresponding symbols.
  260. * (You may HAVE to do that if your compiler doesn't like null source files.)
  261. */
  262. /* Capability options common to encoder and decoder: */
  263. #define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */
  264. #define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */
  265. #define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */
  266. /* Encoder capability options: */
  267. #define C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
  268. #define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
  269. #define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
  270. #define DCT_SCALING_SUPPORTED /* Input rescaling via DCT? (Requires DCT_ISLOW)*/
  271. #define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
  272. /* Note: if you selected more than 8-bit data precision, it is dangerous to
  273. * turn off ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only
  274. * good for 8-bit precision, so arithmetic coding is recommended for higher
  275. * precision. The Huffman encoder normally uses entropy optimization to
  276. * compute usable tables for higher precision. Otherwise, you'll have to
  277. * supply different default Huffman tables.
  278. * The exact same statements apply for progressive JPEG: the default tables
  279. * don't work for progressive mode. (This may get fixed, however.)
  280. */
  281. #define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */
  282. /* Decoder capability options: */
  283. #define D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
  284. #define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
  285. #define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
  286. #define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? (Requires DCT_ISLOW)*/
  287. #define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
  288. #define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
  289. #undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
  290. #define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */
  291. #define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */
  292. #define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */
  293. /* more capability options later, no doubt */
  294. /*
  295. * Ordering of RGB data in scanlines passed to or from the application.
  296. * If your application wants to deal with data in the order B,G,R, just
  297. * change these macros. You can also deal with formats such as R,G,B,X
  298. * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing
  299. * the offsets will also change the order in which colormap data is organized.
  300. * RESTRICTIONS:
  301. * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.
  302. * 2. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
  303. * is not 3 (they don't understand about dummy color components!). So you
  304. * can't use color quantization if you change that value.
  305. */
  306. #define RGB_RED 0 /* Offset of Red in an RGB scanline element */
  307. #define RGB_GREEN 1 /* Offset of Green */
  308. #define RGB_BLUE 2 /* Offset of Blue */
  309. #define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
  310. /* Definitions for speed-related optimizations. */
  311. /* If your compiler supports inline functions, define INLINE
  312. * as the inline keyword; otherwise define it as empty.
  313. */
  314. #ifndef INLINE
  315. #ifdef __GNUC__ /* for instance, GNU C knows about inline */
  316. #define INLINE __inline__
  317. #endif
  318. #ifndef INLINE
  319. #define INLINE /* default is to define it as empty */
  320. #endif
  321. #endif
  322. /* On some machines (notably 68000 series) "int" is 32 bits, but multiplying
  323. * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER
  324. * as short on such a machine. MULTIPLIER must be at least 16 bits wide.
  325. */
  326. #ifndef MULTIPLIER
  327. #define MULTIPLIER int /* type for fastest integer multiply */
  328. #endif
  329. /* FAST_FLOAT should be either float or double, whichever is done faster
  330. * by your compiler. (Note that this type is only used in the floating point
  331. * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)
  332. * Typically, float is faster in ANSI C compilers, while double is faster in
  333. * pre-ANSI compilers (because they insist on converting to double anyway).
  334. * The code below therefore chooses float if we have ANSI-style prototypes.
  335. */
  336. #ifndef FAST_FLOAT
  337. #ifdef HAVE_PROTOTYPES
  338. #define FAST_FLOAT float
  339. #else
  340. #define FAST_FLOAT double
  341. #endif
  342. #endif
  343. #endif /* JPEG_INTERNAL_OPTIONS */