home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / GRAPHICS / JPEGSRC.V4.lzh / jconfig.h < prev    next >
Text File  |  1993-01-14  |  12KB  |  359 lines

  1. /*
  2.  * jconfig.h
  3.  *
  4.  * Copyright (C) 1991, 1992, 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.  * This file contains preprocessor declarations that help customize
  9.  * the JPEG software for a particular application, machine, or compiler.
  10.  * Edit these declarations as needed (or add -D flags to the Makefile).
  11.  */
  12.  
  13.  
  14. /*
  15.  * These symbols indicate the properties of your machine or compiler.
  16.  * The conditional definitions given may do the right thing already,
  17.  * but you'd best look them over closely, especially if your compiler
  18.  * does not handle full ANSI C.  An ANSI-compliant C compiler should
  19.  * provide all the necessary features; __STDC__ is supposed to be
  20.  * predefined by such compilers.
  21.  */
  22.  
  23. /*
  24.  * HAVE_STDC is tested below to see whether ANSI features are available.
  25.  * We avoid testing __STDC__ directly for arcane reasons of portability.
  26.  * (On some compilers, __STDC__ is only defined if a switch is given,
  27.  * but the switch also disables machine-specific features we need to get at.
  28.  * In that case, -DHAVE_STDC in the Makefile is a convenient solution.)
  29.  */
  30.  
  31. #ifdef __STDC__            /* if compiler claims to be ANSI, believe it */
  32. #define HAVE_STDC
  33. #endif
  34.  
  35.  
  36. /* Does your compiler support function prototypes? */
  37. /* (If not, you also need to use ansi2knr, see SETUP) */
  38.  
  39. #ifdef HAVE_STDC        /* ANSI C compilers always have prototypes */
  40. #define PROTO
  41. #else
  42. #ifdef __cplusplus        /* So do C++ compilers */
  43. #define PROTO
  44. #endif
  45. #endif
  46.  
  47. /* Does your compiler support the declaration "unsigned char" ? */
  48. /* How about "unsigned short" ? */
  49.  
  50. #ifdef HAVE_STDC        /* ANSI C compilers must support both */
  51. #define HAVE_UNSIGNED_CHAR
  52. #define HAVE_UNSIGNED_SHORT
  53. #endif
  54.  
  55. /* Define this if an ordinary "char" type is unsigned.
  56.  * If you're not sure, leaving it undefined will work at some cost in speed.
  57.  * If you defined HAVE_UNSIGNED_CHAR then it doesn't matter very much.
  58.  */
  59.  
  60. /* #define CHAR_IS_UNSIGNED */
  61.  
  62. /* Define this if your compiler implements ">>" on signed values as a logical
  63.  * (unsigned) shift; leave it undefined if ">>" is a signed (arithmetic) shift,
  64.  * which is the normal and rational definition.
  65.  */
  66.  
  67. /* #define RIGHT_SHIFT_IS_UNSIGNED */
  68.  
  69. /* Define "void" as "char" if your compiler doesn't know about type void.
  70.  * NOTE: be sure to define void such that "void *" represents the most general
  71.  * pointer type, e.g., that returned by malloc().
  72.  */
  73.  
  74. /* #define void char */
  75.  
  76. /* Define const as empty if your compiler doesn't know the "const" keyword. */
  77. /* (Even if it does, defining const as empty won't break anything.) */
  78.  
  79. #ifndef HAVE_STDC        /* ANSI C and C++ compilers should know it. */
  80. #ifndef __cplusplus
  81. #define const
  82. #endif
  83. #endif
  84.  
  85. /* For 80x86 machines, you need to define NEED_FAR_POINTERS,
  86.  * unless you are using a large-data memory model or 80386 flat-memory mode.
  87.  * On less brain-damaged CPUs this symbol must not be defined.
  88.  * (Defining this symbol causes large data structures to be referenced through
  89.  * "far" pointers and to be allocated with a special version of malloc.)
  90.  */
  91.  
  92. #ifdef MSDOS
  93. #define NEED_FAR_POINTERS
  94. #endif
  95.  
  96.  
  97. /* The next three symbols only affect the system-dependent user interface
  98.  * modules (jcmain.c, jdmain.c).  You can ignore these if you are supplying
  99.  * your own user interface code.
  100.  */
  101.  
  102. /* Define this if you want to name both input and output files on the command
  103.  * line, rather than using stdout and optionally stdin.  You MUST do this if
  104.  * your system can't cope with binary I/O to stdin/stdout.  See comments at
  105.  * head of jcmain.c or jdmain.c.
  106.  */
  107.  
  108. #ifdef MSDOS            /* two-file style is needed for PCs */
  109. #ifndef USE_SETMODE        /* unless you have setmode() */
  110. #define TWO_FILE_COMMANDLINE
  111. #endif
  112. #endif
  113. #ifdef THINK_C            /* it's needed for Macintosh too */
  114. #define TWO_FILE_COMMANDLINE
  115. #endif
  116.  
  117. /* Define this if your system needs explicit cleanup of temporary files.
  118.  * This is crucial under MS-DOS, where the temporary "files" may be areas
  119.  * of extended memory; on most other systems it's not as important.
  120.  */
  121.  
  122. #ifdef MSDOS
  123. #define NEED_SIGNAL_CATCHER
  124. #endif
  125.  
  126. /* By default, we open image files with fopen(...,"rb") or fopen(...,"wb").
  127.  * This is necessary on systems that distinguish text files from binary files,
  128.  * and is harmless on most systems that don't.  If you have one of the rare
  129.  * systems that complains about the "b" spec, define this symbol.
  130.  */
  131.  
  132. /* #define DONT_USE_B_MODE */
  133.  
  134.  
  135. /* If you're getting bored, that's the end of the symbols you HAVE to
  136.  * worry about.  Go fix the makefile and compile.
  137.  */
  138.  
  139.  
  140. /* If your compiler supports inline functions, define INLINE
  141.  * as the inline keyword; otherwise define it as empty.
  142.  */
  143.  
  144. #ifdef __GNUC__            /* for instance, GNU C knows about inline */
  145. #define INLINE __inline__
  146. #endif
  147. #ifndef INLINE            /* default is to define it as empty */
  148. #define INLINE
  149. #endif
  150.  
  151. /* On a few systems, type boolean and/or macros FALSE, TRUE may appear
  152.  * in standard header files.  Or you may have conflicts with application-
  153.  * specific header files that you want to include together with these files.
  154.  * In that case you need only comment out these definitions.
  155.  */
  156.  
  157. typedef int boolean;
  158. #undef FALSE            /* in case these macros already exist */
  159. #undef TRUE
  160. #define FALSE    0        /* values of boolean */
  161. #define TRUE    1
  162.  
  163. /* This defines the size of the I/O buffers for entropy compression
  164.  * and decompression; you could reduce it if memory is tight.
  165.  */
  166.  
  167. #define JPEG_BUF_SIZE    4096 /* bytes */
  168.  
  169.  
  170.  
  171. /* These symbols determine the JPEG functionality supported. */
  172.  
  173. /*
  174.  * These defines indicate whether to include various optional functions.
  175.  * Undefining some of these symbols will produce a smaller but less capable
  176.  * program file.  Note that you can leave certain source files out of the
  177.  * compilation/linking process if you've #undef'd the corresponding symbols.
  178.  * (You may HAVE to do that if your compiler doesn't like null source files.)
  179.  */
  180.  
  181. /* Arithmetic coding is unsupported for legal reasons.  Complaints to IBM. */
  182.  
  183. /* Encoder capability options: */
  184. #undef  C_ARITH_CODING_SUPPORTED    /* Arithmetic coding back end? */
  185. #undef  C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files?  (NYI) */
  186. #define ENTROPY_OPT_SUPPORTED        /* Optimization of entropy coding parms? */
  187. #define INPUT_SMOOTHING_SUPPORTED   /* Input image smoothing option? */
  188. /* Decoder capability options: */
  189. #undef  D_ARITH_CODING_SUPPORTED    /* Arithmetic coding back end? */
  190. #define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
  191. #define BLOCK_SMOOTHING_SUPPORTED   /* Block smoothing during decoding? */
  192. #define QUANT_1PASS_SUPPORTED    /* 1-pass color quantization? */
  193. #define QUANT_2PASS_SUPPORTED    /* 2-pass color quantization? */
  194. /* these defines indicate which JPEG file formats are allowed */
  195. #define JFIF_SUPPORTED        /* JFIF or "raw JPEG" files */
  196. #undef  JTIFF_SUPPORTED        /* JPEG-in-TIFF (not yet implemented) */
  197. /* these defines indicate which image (non-JPEG) file formats are allowed */
  198. #define GIF_SUPPORTED        /* GIF image file format */
  199. /* #define RLE_SUPPORTED */    /* RLE image file format (by default, no) */
  200. #define PPM_SUPPORTED        /* PPM/PGM image file format */
  201. #define TARGA_SUPPORTED        /* Targa image file format */
  202. #undef  TIFF_SUPPORTED        /* TIFF image file format (not yet impl.) */
  203.  
  204. /* more capability options later, no doubt */
  205.  
  206.  
  207. /*
  208.  * Define exactly one of these three symbols to indicate whether you want
  209.  * 8-bit, 12-bit, or 16-bit sample (pixel component) values.  8-bit is the
  210.  * default and is nearly always the right thing to use.  You can use 12-bit if
  211.  * you need to support image formats with more than 8 bits of resolution in a
  212.  * color value.  16-bit should only be used for the lossless JPEG mode (not
  213.  * currently supported).  Note that 12- and 16-bit values take up twice as
  214.  * much memory as 8-bit!
  215.  * Note: if you select 12- or 16-bit precision, it is dangerous to turn off
  216.  * ENTROPY_OPT_SUPPORTED.  The standard Huffman tables are only good for 8-bit
  217.  * precision, so jchuff.c normally uses entropy optimization to compute
  218.  * usable tables for higher precision.  If you don't want to do optimization,
  219.  * you'll have to supply different default Huffman tables.
  220.  */
  221.  
  222. #define EIGHT_BIT_SAMPLES
  223. #undef  TWELVE_BIT_SAMPLES
  224. #undef  SIXTEEN_BIT_SAMPLES
  225.  
  226.  
  227.  
  228. /*
  229.  * The remaining definitions don't need to be hand-edited in most cases.
  230.  * You may need to change these if you have a machine with unusual data
  231.  * types; for example, "char" not 8 bits, "short" not 16 bits,
  232.  * or "long" not 32 bits.  We don't care whether "int" is 16 or 32 bits,
  233.  * but it had better be at least 16.
  234.  */
  235.  
  236. /* First define the representation of a single pixel element value. */
  237.  
  238. #ifdef EIGHT_BIT_SAMPLES
  239. /* JSAMPLE should be the smallest type that will hold the values 0..255.
  240.  * You can use a signed char by having GETJSAMPLE mask it with 0xFF.
  241.  * If you have only signed chars, and you are more worried about speed than
  242.  * memory usage, it might be a win to make JSAMPLE be short.
  243.  */
  244.  
  245. #ifdef HAVE_UNSIGNED_CHAR
  246.  
  247. typedef unsigned char JSAMPLE;
  248. #define GETJSAMPLE(value)  (value)
  249.  
  250. #else /* not HAVE_UNSIGNED_CHAR */
  251. #ifdef CHAR_IS_UNSIGNED
  252.  
  253. typedef char JSAMPLE;
  254. #define GETJSAMPLE(value)  (value)
  255.  
  256. #else /* not CHAR_IS_UNSIGNED */
  257.  
  258. typedef char JSAMPLE;
  259. #define GETJSAMPLE(value)  ((value) & 0xFF)
  260.  
  261. #endif /* CHAR_IS_UNSIGNED */
  262. #endif /* HAVE_UNSIGNED_CHAR */
  263.  
  264. #define BITS_IN_JSAMPLE   8
  265. #define MAXJSAMPLE    255
  266. #define CENTERJSAMPLE    128
  267.  
  268. #endif /* EIGHT_BIT_SAMPLES */
  269.  
  270.  
  271. #ifdef TWELVE_BIT_SAMPLES
  272. /* JSAMPLE should be the smallest type that will hold the values 0..4095. */
  273. /* On nearly all machines "short" will do nicely. */
  274.  
  275. typedef short JSAMPLE;
  276. #define GETJSAMPLE(value)  (value)
  277.  
  278. #define BITS_IN_JSAMPLE   12
  279. #define MAXJSAMPLE    4095
  280. #define CENTERJSAMPLE    2048
  281.  
  282. #endif /* TWELVE_BIT_SAMPLES */
  283.  
  284.  
  285. #ifdef SIXTEEN_BIT_SAMPLES
  286. /* JSAMPLE should be the smallest type that will hold the values 0..65535. */
  287.  
  288. #ifdef HAVE_UNSIGNED_SHORT
  289.  
  290. typedef unsigned short JSAMPLE;
  291. #define GETJSAMPLE(value)  (value)
  292.  
  293. #else /* not HAVE_UNSIGNED_SHORT */
  294.  
  295. /* If int is 32 bits this'll be horrendously inefficient storage-wise.
  296.  * But since we don't actually support 16-bit samples (ie lossless coding) yet,
  297.  * I'm not going to worry about making a smarter definition ...
  298.  */
  299. typedef unsigned int JSAMPLE;
  300. #define GETJSAMPLE(value)  (value)
  301.  
  302. #endif /* HAVE_UNSIGNED_SHORT */
  303.  
  304. #define BITS_IN_JSAMPLE    16
  305. #define MAXJSAMPLE    65535
  306. #define CENTERJSAMPLE    32768
  307.  
  308. #endif /* SIXTEEN_BIT_SAMPLES */
  309.  
  310.  
  311. /* Here we define the representation of a DCT frequency coefficient.
  312.  * This should be a signed 16-bit value; "short" is usually right.
  313.  * It's important that this be exactly 16 bits, no more and no less;
  314.  * more will cost you a BIG hit of memory, less will give wrong answers.
  315.  */
  316.  
  317. typedef short JCOEF;
  318.  
  319.  
  320. /* The remaining typedefs are used for various table entries and so forth.
  321.  * They must be at least as wide as specified; but making them too big
  322.  * won't cost a huge amount of memory, so we don't provide special
  323.  * extraction code like we did for JSAMPLE.  (In other words, these
  324.  * typedefs live at a different point on the speed/space tradeoff curve.)
  325.  */
  326.  
  327. /* UINT8 must hold at least the values 0..255. */
  328.  
  329. #ifdef HAVE_UNSIGNED_CHAR
  330. typedef unsigned char UINT8;
  331. #else /* not HAVE_UNSIGNED_CHAR */
  332. #ifdef CHAR_IS_UNSIGNED
  333. typedef char UINT8;
  334. #else /* not CHAR_IS_UNSIGNED */
  335. typedef short UINT8;
  336. #endif /* CHAR_IS_UNSIGNED */
  337. #endif /* HAVE_UNSIGNED_CHAR */
  338.  
  339. /* UINT16 must hold at least the values 0..65535. */
  340.  
  341. #ifdef HAVE_UNSIGNED_SHORT
  342. typedef unsigned short UINT16;
  343. #else /* not HAVE_UNSIGNED_SHORT */
  344. typedef unsigned int UINT16;
  345. #endif /* HAVE_UNSIGNED_SHORT */
  346.  
  347. /* INT16 must hold at least the values -32768..32767. */
  348.  
  349. #ifndef XMD_H            /* X11/xmd.h correctly defines INT16 */
  350. typedef short INT16;
  351. #endif
  352.  
  353. /* INT32 must hold signed 32-bit values; if your machine happens */
  354. /* to have 64-bit longs, you might want to change this. */
  355.  
  356. #ifndef XMD_H            /* X11/xmd.h correctly defines INT32 */
  357. typedef long INT32;
  358. #endif
  359.