home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / c / xv221src / jpeg / jconfig.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-24  |  11.5 KB  |  341 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. #ifndef __GNUC__
  94. #define NEED_FAR_POINTERS
  95. #endif /* __GNUC__ */
  96. #endif
  97.  
  98. /* The next three symbols only affect the system-dependent user interface
  99.  * modules (jcmain.c, jdmain.c).  You can ignore these if you are supplying
  100.  * your own user interface code.
  101.  */
  102.  
  103. /* Define this if you want to name both input and output files on the command
  104.  * line, rather than using stdout and optionally stdin.  You MUST do this if
  105.  * your system can't cope with binary I/O to stdin/stdout.  See comments at
  106.  * head of jcmain.c or jdmain.c.
  107.  */
  108.  
  109. #ifdef MSDOS            /* two-file style is needed for PCs */
  110. #define TWO_FILE_COMMANDLINE
  111. #endif
  112. #ifdef THINK_C            /* needed for Macintosh too */
  113. #define TWO_FILE_COMMANDLINE
  114. #endif
  115.  
  116. /* Define this if your system needs explicit cleanup of temporary files.
  117.  * This is crucial under MS-DOS, where the temporary "files" may be areas
  118.  * of extended memory; on most other systems it's not as important.
  119.  */
  120.  
  121. #ifdef MSDOS
  122. #define NEED_SIGNAL_CATCHER
  123. #endif
  124.  
  125. /* By default, we open image files with fopen(...,"rb") or fopen(...,"wb").
  126.  * This is necessary on systems that distinguish text files from binary files,
  127.  * and is harmless on most systems that don't.  If you have one of the rare
  128.  * systems that complains about the "b" spec, define this symbol.
  129.  */
  130.  
  131. /* #define DONT_USE_B_MODE */
  132.  
  133.  
  134. /* If you're getting bored, that's the end of the symbols you HAVE to
  135.  * worry about.  Go fix the makefile and compile.
  136.  */
  137.  
  138.  
  139. /* On a few systems, type boolean and/or macros FALSE, TRUE may appear
  140.  * in standard header files.  Or you may have conflicts with application-
  141.  * specific header files that you want to include together with these files.
  142.  * In that case you need only comment out these definitions.
  143.  */
  144.  
  145. typedef int boolean;
  146. #undef FALSE            /* in case these macros already exist */
  147. #undef TRUE
  148. #define FALSE    0        /* values of boolean */
  149. #define TRUE (!FALSE)
  150.  
  151. /* This defines the size of the I/O buffers for entropy compression
  152.  * and decompression; you could reduce it if memory is tight.
  153.  */
  154.  
  155. #define JPEG_BUF_SIZE    4096 /* bytes */
  156.  
  157.  
  158.  
  159. /* These symbols determine the JPEG functionality supported. */
  160.  
  161. /*
  162.  * These defines indicate whether to include various optional functions.
  163.  * Undefining some of these symbols will produce a smaller but less capable
  164.  * program file.  Note that you can leave certain source files out of the
  165.  * compilation/linking process if you've #undef'd the corresponding symbols.
  166.  * (You may HAVE to do that if your compiler doesn't like null source files.)
  167.  */
  168.  
  169. /* Arithmetic coding is unsupported for legal reasons.  Complaints to IBM. */
  170. #undef  ARITH_CODING_SUPPORTED    /* Arithmetic coding back end? */
  171. #define MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
  172. #define ENTROPY_OPT_SUPPORTED    /* Optimization of entropy coding parms? */
  173. #define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing during decoding? */
  174. #define QUANT_1PASS_SUPPORTED    /* 1-pass color quantization? */
  175. #define QUANT_2PASS_SUPPORTED    /* 2-pass color quantization? */
  176. /* these defines indicate which JPEG file formats are allowed */
  177. #define JFIF_SUPPORTED        /* JFIF or "raw JPEG" files */
  178. #undef  JTIFF_SUPPORTED        /* JPEG-in-TIFF (not yet implemented) */
  179. /* these defines indicate which image (non-JPEG) file formats are allowed */
  180. #define GIF_SUPPORTED        /* GIF image file format */
  181. /* #define RLE_SUPPORTED */    /* RLE image file format (by default, no) */
  182. #define PPM_SUPPORTED        /* PPM/PGM image file format */
  183. #define TARGA_SUPPORTED        /* Targa image file format */
  184. #undef  TIFF_SUPPORTED        /* TIFF image file format (not yet impl.) */
  185.  
  186. /* more capability options later, no doubt */
  187.  
  188.  
  189. /*
  190.  * Define exactly one of these three symbols to indicate whether you want
  191.  * 8-bit, 12-bit, or 16-bit sample (pixel component) values.  8-bit is the
  192.  * default and is nearly always the right thing to use.  You can use 12-bit if
  193.  * you need to support image formats with more than 8 bits of resolution in a
  194.  * color value.  16-bit should only be used for the lossless JPEG mode (not
  195.  * currently supported).  Note that 12- and 16-bit values take up twice as
  196.  * much memory as 8-bit!
  197.  * Note: if you select 12- or 16-bit precision, it is dangerous to turn off
  198.  * ENTROPY_OPT_SUPPORTED.  The standard Huffman tables are only good for 8-bit
  199.  * precision, so jchuff.c normally uses entropy optimization to compute
  200.  * usable tables for higher precision.  If you don't want to do optimization,
  201.  * you'll have to supply different default Huffman tables.
  202.  */
  203.  
  204. #define EIGHT_BIT_SAMPLES
  205. #undef  TWELVE_BIT_SAMPLES
  206. #undef  SIXTEEN_BIT_SAMPLES
  207.  
  208.  
  209.  
  210. /*
  211.  * The remaining definitions don't need to be hand-edited in most cases.
  212.  * You may need to change these if you have a machine with unusual data
  213.  * types; for example, "char" not 8 bits, "short" not 16 bits,
  214.  * or "long" not 32 bits.  We don't care whether "int" is 16 or 32 bits,
  215.  * but it had better be at least 16.
  216.  */
  217.  
  218. /* First define the representation of a single pixel element value. */
  219.  
  220. #ifdef EIGHT_BIT_SAMPLES
  221. /* JSAMPLE should be the smallest type that will hold the values 0..255.
  222.  * You can use a signed char by having GETJSAMPLE mask it with 0xFF.
  223.  * If you have only signed chars, and you are more worried about speed than
  224.  * memory usage, it might be a win to make JSAMPLE be short.
  225.  */
  226.  
  227. #ifdef HAVE_UNSIGNED_CHAR
  228.  
  229. typedef unsigned char JSAMPLE;
  230. #define GETJSAMPLE(value)  (value)
  231.  
  232. #else /* not HAVE_UNSIGNED_CHAR */
  233. #ifdef CHAR_IS_UNSIGNED
  234.  
  235. typedef char JSAMPLE;
  236. #define GETJSAMPLE(value)  (value)
  237.  
  238. #else /* not CHAR_IS_UNSIGNED */
  239.  
  240. typedef char JSAMPLE;
  241. #define GETJSAMPLE(value)  ((value) & 0xFF)
  242.  
  243. #endif /* CHAR_IS_UNSIGNED */
  244. #endif /* HAVE_UNSIGNED_CHAR */
  245.  
  246. #define BITS_IN_JSAMPLE   8
  247. #define MAXJSAMPLE    255
  248. #define CENTERJSAMPLE    128
  249.  
  250. #endif /* EIGHT_BIT_SAMPLES */
  251.  
  252.  
  253. #ifdef TWELVE_BIT_SAMPLES
  254. /* JSAMPLE should be the smallest type that will hold the values 0..4095. */
  255. /* On nearly all machines "short" will do nicely. */
  256.  
  257. typedef short JSAMPLE;
  258. #define GETJSAMPLE(value)  (value)
  259.  
  260. #define BITS_IN_JSAMPLE   12
  261. #define MAXJSAMPLE    4095
  262. #define CENTERJSAMPLE    2048
  263.  
  264. #endif /* TWELVE_BIT_SAMPLES */
  265.  
  266.  
  267. #ifdef SIXTEEN_BIT_SAMPLES
  268. /* JSAMPLE should be the smallest type that will hold the values 0..65535. */
  269.  
  270. #ifdef HAVE_UNSIGNED_SHORT
  271.  
  272. typedef unsigned short JSAMPLE;
  273. #define GETJSAMPLE(value)  (value)
  274.  
  275. #else /* not HAVE_UNSIGNED_SHORT */
  276.  
  277. /* If int is 32 bits this'll be horrendously inefficient storage-wise.
  278.  * But since we don't actually support 16-bit samples (ie lossless coding) yet,
  279.  * I'm not going to worry about making a smarter definition ...
  280.  */
  281. typedef unsigned int JSAMPLE;
  282. #define GETJSAMPLE(value)  (value)
  283.  
  284. #endif /* HAVE_UNSIGNED_SHORT */
  285.  
  286. #define BITS_IN_JSAMPLE    16
  287. #define MAXJSAMPLE    65535
  288. #define CENTERJSAMPLE    32768
  289.  
  290. #endif /* SIXTEEN_BIT_SAMPLES */
  291.  
  292.  
  293. /* Here we define the representation of a DCT frequency coefficient.
  294.  * This should be a signed 16-bit value; "short" is usually right.
  295.  * It's important that this be exactly 16 bits, no more and no less;
  296.  * more will cost you a BIG hit of memory, less will give wrong answers.
  297.  */
  298.  
  299. typedef short JCOEF;
  300.  
  301.  
  302. /* The remaining typedefs are used for various table entries and so forth.
  303.  * They must be at least as wide as specified; but making them too big
  304.  * won't cost a huge amount of memory, so we don't provide special
  305.  * extraction code like we did for JSAMPLE.  (In other words, these
  306.  * typedefs live at a different point on the speed/space tradeoff curve.)
  307.  */
  308.  
  309. /* UINT8 must hold at least the values 0..255. */
  310.  
  311. #ifdef HAVE_UNSIGNED_CHAR
  312. typedef unsigned char UINT8;
  313. #else /* not HAVE_UNSIGNED_CHAR */
  314. #ifdef CHAR_IS_UNSIGNED
  315. typedef char UINT8;
  316. #else /* not CHAR_IS_UNSIGNED */
  317. typedef short UINT8;
  318. #endif /* CHAR_IS_UNSIGNED */
  319. #endif /* HAVE_UNSIGNED_CHAR */
  320.  
  321. /* UINT16 must hold at least the values 0..65535. */
  322.  
  323. #ifdef HAVE_UNSIGNED_SHORT
  324. typedef unsigned short UINT16;
  325. #else /* not HAVE_UNSIGNED_SHORT */
  326. typedef unsigned int UINT16;
  327. #endif /* HAVE_UNSIGNED_SHORT */
  328.  
  329. /* INT16 must hold at least the values -32768..32767. */
  330.  
  331. #ifndef XMD_H            /* X11/xmd.h correctly defines INT16 */
  332. typedef short INT16;
  333. #endif
  334.  
  335. /* INT32 must hold signed 32-bit values; if your machine happens */
  336. /* to have 64-bit longs, you might want to change this. */
  337.  
  338. #ifndef XMD_H            /* X11/xmd.h correctly defines INT32 */
  339. typedef long INT32;
  340. #endif
  341.