jmorecfg.h revision 8e9cef2e6f5156c4b055a04a8f979b7291fc6b7a
136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/*
236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * jmorecfg.h
336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane *
4a73e870ad02de20c2b34cb3a5382c2846c2afbe3DRC * This file was part of the Independent JPEG Group's software:
55ead57a34a398aa798f35bd7a6abad19b2e453e2Thomas G. Lane * Copyright (C) 1991-1997, Thomas G. Lane.
6c23e36e80009728b8c0f5e36ba6cb07885334d3bDRC * Modified 1997-2009 by Guido Vollbeding.
7da13af6b8d5427af89bbdc5698b4e09d0ea814feDRC * libjpeg-turbo Modifications:
88e9cef2e6f5156c4b055a04a8f979b7291fc6b7aDRC * Copyright (C) 2009, 2011, 2014-2015, D. R. Commander.
936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * For conditions of distribution and use, see the accompanying README file.
1036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane *
1136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * This file contains additional configuration options that customize the
1236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * JPEG software for special applications or support machine-dependent
1336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * optimizations.  Most users will not need to touch this file.
1436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
1536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
1636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
1736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/*
1836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * Maximum number of components (color channels) allowed in JPEG image.
1936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * To meet the letter of the JPEG spec, set this to 255.  However, darn
2036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * few applications need more than 4 channels (maybe 5 for CMYK + alpha
2136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * mask).  We recommend 10 as a reasonable compromise; use 4 if you are
2236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * really short on memory.  (Each allowed component costs a hundred or so
2336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * bytes of storage, whether actually used in an image or not.)
2436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
2536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
26e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define MAX_COMPONENTS  10      /* maximum number of image components */
2736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
2836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
2936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/*
3036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * Basic data types.
3136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * You may need to change these if you have a machine with unusual data
3236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * type sizes; for example, "char" not 8 bits, "short" not 16 bits,
3336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * or "long" not 32 bits.  We don't care whether "int" is 16 or 32 bits,
3436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * but it had better be at least 16.
3536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
3636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
3736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* Representation of a single sample (pixel element value).
3836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * We frequently allocate large arrays of these, so it's important to keep
3936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * them small.  But if you have memory to burn and access to char or short
4036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * arrays is very slow on your hardware, you might want to change these.
4136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
4236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
4336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#if BITS_IN_JSAMPLE == 8
4436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* JSAMPLE should be the smallest type that will hold the values 0..255.
4536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * You can use a signed char by having GETJSAMPLE mask it with 0xFF.
4636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
4736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
4836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#ifdef HAVE_UNSIGNED_CHAR
4936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
5036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lanetypedef unsigned char JSAMPLE;
5136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define GETJSAMPLE(value)  ((int) (value))
5236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
5336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#else /* not HAVE_UNSIGNED_CHAR */
5436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
5536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lanetypedef char JSAMPLE;
560ca44258fc43bc44ea31b875001311591cc5634cConstantin Kaplinsky#ifdef __CHAR_UNSIGNED__
5736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define GETJSAMPLE(value)  ((int) (value))
5836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#else
5936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define GETJSAMPLE(value)  ((int) (value) & 0xFF)
600ca44258fc43bc44ea31b875001311591cc5634cConstantin Kaplinsky#endif /* __CHAR_UNSIGNED__ */
6136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
6236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif /* HAVE_UNSIGNED_CHAR */
6336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
64e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define MAXJSAMPLE      255
65e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define CENTERJSAMPLE   128
6636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
6736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif /* BITS_IN_JSAMPLE == 8 */
6836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
6936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
7036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#if BITS_IN_JSAMPLE == 12
7136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* JSAMPLE should be the smallest type that will hold the values 0..4095.
7236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * On nearly all machines "short" will do nicely.
7336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
7436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
7536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lanetypedef short JSAMPLE;
7636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define GETJSAMPLE(value)  ((int) (value))
7736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
78e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define MAXJSAMPLE      4095
79e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define CENTERJSAMPLE   2048
8036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
8136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif /* BITS_IN_JSAMPLE == 12 */
8236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
8336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
8436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* Representation of a DCT frequency coefficient.
8536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * This should be a signed value of at least 16 bits; "short" is usually OK.
8636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * Again, we allocate large arrays of these, but you can change to int
8736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * if you have memory to burn and "short" is really slow.
8836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
8936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
9036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lanetypedef short JCOEF;
9136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
9236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
9336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* Compressed datastreams are represented as arrays of JOCTET.
9436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * These must be EXACTLY 8 bits wide, at least once they are written to
9536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * external storage.  Note that when using the stdio data source/destination
9636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * managers, this is also the data type passed to fread/fwrite.
9736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
9836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
9936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#ifdef HAVE_UNSIGNED_CHAR
10036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
10136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lanetypedef unsigned char JOCTET;
10236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define GETJOCTET(value)  (value)
10336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
10436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#else /* not HAVE_UNSIGNED_CHAR */
10536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
10636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lanetypedef char JOCTET;
1070ca44258fc43bc44ea31b875001311591cc5634cConstantin Kaplinsky#ifdef __CHAR_UNSIGNED__
10836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define GETJOCTET(value)  (value)
10936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#else
11036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define GETJOCTET(value)  ((value) & 0xFF)
1110ca44258fc43bc44ea31b875001311591cc5634cConstantin Kaplinsky#endif /* __CHAR_UNSIGNED__ */
11236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
11336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif /* HAVE_UNSIGNED_CHAR */
11436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
11536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
11636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* These typedefs are used for various table entries and so forth.
11736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * They must be at least as wide as specified; but making them too big
11836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * won't cost a huge amount of memory, so we don't provide special
11936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * extraction code like we did for JSAMPLE.  (In other words, these
12036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * typedefs live at a different point on the speed/space tradeoff curve.)
12136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
12236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
12336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* UINT8 must hold at least the values 0..255. */
12436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
12536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#ifdef HAVE_UNSIGNED_CHAR
12636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lanetypedef unsigned char UINT8;
12736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#else /* not HAVE_UNSIGNED_CHAR */
1280ca44258fc43bc44ea31b875001311591cc5634cConstantin Kaplinsky#ifdef __CHAR_UNSIGNED__
12936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lanetypedef char UINT8;
1300ca44258fc43bc44ea31b875001311591cc5634cConstantin Kaplinsky#else /* not __CHAR_UNSIGNED__ */
13136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lanetypedef short UINT8;
1320ca44258fc43bc44ea31b875001311591cc5634cConstantin Kaplinsky#endif /* __CHAR_UNSIGNED__ */
13336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif /* HAVE_UNSIGNED_CHAR */
13436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
13536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* UINT16 must hold at least the values 0..65535. */
13636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
13736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#ifdef HAVE_UNSIGNED_SHORT
13836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lanetypedef unsigned short UINT16;
13936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#else /* not HAVE_UNSIGNED_SHORT */
14036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lanetypedef unsigned int UINT16;
14136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif /* HAVE_UNSIGNED_SHORT */
14236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
14336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* INT16 must hold at least the values -32768..32767. */
14436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
145e5eaf37440b8e337ab150c017df7c03faf846c51DRC#ifndef XMD_H                   /* X11/xmd.h correctly defines INT16 */
14636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lanetypedef short INT16;
14736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif
14836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
14936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* INT32 must hold at least signed 32-bit values. */
15036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
151e5eaf37440b8e337ab150c017df7c03faf846c51DRC#ifndef XMD_H                   /* X11/xmd.h correctly defines INT32 */
1525996a25e2f50d20d6a8f09830724035b49c3927bGuido Vollbeding#ifndef _BASETSD_H_		/* Microsoft defines it in basetsd.h */
153989630f70cf1af69ebfefca8910d1647bf189712Guido Vollbeding#ifndef _BASETSD_H		/* MinGW is slightly different */
1545996a25e2f50d20d6a8f09830724035b49c3927bGuido Vollbeding#ifndef QGLOBAL_H		/* Qt defines it in qglobal.h */
1558e9cef2e6f5156c4b055a04a8f979b7291fc6b7aDRC#define __INT32_IS_ACTUALLY_LONG
15636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lanetypedef long INT32;
15736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif
1585996a25e2f50d20d6a8f09830724035b49c3927bGuido Vollbeding#endif
1595996a25e2f50d20d6a8f09830724035b49c3927bGuido Vollbeding#endif
160989630f70cf1af69ebfefca8910d1647bf189712Guido Vollbeding#endif
16136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
16236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* Datatype used for image dimensions.  The JPEG standard only supports
16336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * images up to 64K*64K due to 16-bit fields in SOF markers.  Therefore
16436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * "unsigned int" is sufficient on all machines.  However, if you need to
16536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * handle larger images and you don't mind deviating from the spec, you
166498d9bc92fcf39124b6f08e57326944dedd2ddd6Chandler Carruth * can change this datatype.  (Note that changing this datatype will
167498d9bc92fcf39124b6f08e57326944dedd2ddd6Chandler Carruth * potentially require modifying the SIMD code.  The x86-64 SIMD extensions,
168498d9bc92fcf39124b6f08e57326944dedd2ddd6Chandler Carruth * in particular, assume a 32-bit JDIMENSION.)
16936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
17036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
17136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lanetypedef unsigned int JDIMENSION;
17236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
17336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
17436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
17536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
176489583f5165e05d37302e8eeec58104ea0109127Thomas G. Lane/* These macros are used in all function definitions and extern declarations.
177489583f5165e05d37302e8eeec58104ea0109127Thomas G. Lane * You could modify them if you need to change function linkage conventions;
178489583f5165e05d37302e8eeec58104ea0109127Thomas G. Lane * in particular, you'll need to do that to make the library a Windows DLL.
17936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * Another application is to make all functions global for use with debuggers
18036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * or code profilers that require it.
18136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
18236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
183489583f5165e05d37302e8eeec58104ea0109127Thomas G. Lane/* a function called through method pointers: */
184e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define METHODDEF(type)         static type
185489583f5165e05d37302e8eeec58104ea0109127Thomas G. Lane/* a function used only in its module: */
186e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define LOCAL(type)             static type
187489583f5165e05d37302e8eeec58104ea0109127Thomas G. Lane/* a function referenced thru EXTERNs: */
188e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define GLOBAL(type)            type
189489583f5165e05d37302e8eeec58104ea0109127Thomas G. Lane/* a reference to a GLOBAL function: */
190e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define EXTERN(type)            extern type
191489583f5165e05d37302e8eeec58104ea0109127Thomas G. Lane
192489583f5165e05d37302e8eeec58104ea0109127Thomas G. Lane
193e2dd3e3e5cb479f8596325e72f0595a31bf79921DRC/* Originally, this macro was used as a way of defining function prototypes
194e2dd3e3e5cb479f8596325e72f0595a31bf79921DRC * for both modern compilers as well as older compilers that did not support
1952a6b8316fce86aa05c00bf44a29a28d2e9aec99cDRC * prototype parameters.  libjpeg-turbo has never supported these older,
1962a6b8316fce86aa05c00bf44a29a28d2e9aec99cDRC * non-ANSI compilers, but the macro is still included because there is some
1972a6b8316fce86aa05c00bf44a29a28d2e9aec99cDRC * software out there that uses it.
198e2dd3e3e5cb479f8596325e72f0595a31bf79921DRC */
199e2dd3e3e5cb479f8596325e72f0595a31bf79921DRC
200e2dd3e3e5cb479f8596325e72f0595a31bf79921DRC#define JMETHOD(type,methodname,arglist)  type (*methodname) arglist
201e2dd3e3e5cb479f8596325e72f0595a31bf79921DRC
202e2dd3e3e5cb479f8596325e72f0595a31bf79921DRC
2032a6b8316fce86aa05c00bf44a29a28d2e9aec99cDRC/* libjpeg-turbo no longer supports platforms that have far symbols (MS-DOS),
2042a6b8316fce86aa05c00bf44a29a28d2e9aec99cDRC * but again, some software relies on this macro.
2052a6b8316fce86aa05c00bf44a29a28d2e9aec99cDRC */
2062a6b8316fce86aa05c00bf44a29a28d2e9aec99cDRC
2072a6b8316fce86aa05c00bf44a29a28d2e9aec99cDRC#undef FAR
2082a6b8316fce86aa05c00bf44a29a28d2e9aec99cDRC#define FAR
2092a6b8316fce86aa05c00bf44a29a28d2e9aec99cDRC
2102a6b8316fce86aa05c00bf44a29a28d2e9aec99cDRC
21136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/*
21236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * On a few systems, type boolean and/or its values FALSE, TRUE may appear
21336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * in standard header files.  Or you may have conflicts with application-
21436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * specific header files that you want to include together with these files.
21536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
21636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
21736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
21836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#ifndef HAVE_BOOLEAN
21936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lanetypedef int boolean;
22036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif
221e5eaf37440b8e337ab150c017df7c03faf846c51DRC#ifndef FALSE                   /* in case these macros already exist */
222e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define FALSE   0               /* values of boolean */
22336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif
22436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#ifndef TRUE
225e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define TRUE    1
22636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif
22736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
22836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
22936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/*
23036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * The remaining options affect code selection within the JPEG library,
23136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * but they don't need to be visible to most applications using the library.
23236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * To minimize application namespace pollution, the symbols won't be
23336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.
23436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
23536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
23636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#ifdef JPEG_INTERNALS
23736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define JPEG_INTERNAL_OPTIONS
23836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif
23936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
24036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#ifdef JPEG_INTERNAL_OPTIONS
24136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
24236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
24336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/*
24436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * These defines indicate whether to include various optional functions.
24536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * Undefining some of these symbols will produce a smaller but less capable
24636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * library.  Note that you can leave certain source files out of the
24736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * compilation/linking process if you've #undef'd the corresponding symbols.
24836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * (You may HAVE to do that if your compiler doesn't like null source files.)
24936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
25036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
25136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* Capability options common to encoder and decoder: */
25236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
253e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define DCT_ISLOW_SUPPORTED     /* slow but accurate integer algorithm */
254e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define DCT_IFAST_SUPPORTED     /* faster, less accurate integer method */
255e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define DCT_FLOAT_SUPPORTED     /* floating-point: accurate, fast on fast HW */
25636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
25736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* Encoder capability options: */
25836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
259bc79e0680a45d1ca330d690dae0340c8e17ab5e3Thomas G. Lane#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
260e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define C_PROGRESSIVE_SUPPORTED     /* Progressive JPEG? (Requires MULTISCAN)*/
261e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define ENTROPY_OPT_SUPPORTED       /* Optimization of entropy coding parms? */
26236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* Note: if you selected 12-bit data precision, it is dangerous to turn off
26336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * ENTROPY_OPT_SUPPORTED.  The standard Huffman tables are only good for 8-bit
26436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * precision, so jchuff.c normally uses entropy optimization to compute
26536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * usable tables for higher precision.  If you don't want to do optimization,
26636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * you'll have to supply different default Huffman tables.
267bc79e0680a45d1ca330d690dae0340c8e17ab5e3Thomas G. Lane * The exact same statements apply for progressive JPEG: the default tables
268bc79e0680a45d1ca330d690dae0340c8e17ab5e3Thomas G. Lane * don't work for progressive mode.  (This may get fixed, however.)
26936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
27036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define INPUT_SMOOTHING_SUPPORTED   /* Input image smoothing option? */
27136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
27236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* Decoder capability options: */
27336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
27436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
275e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define D_PROGRESSIVE_SUPPORTED     /* Progressive JPEG? (Requires MULTISCAN)*/
276e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define SAVE_MARKERS_SUPPORTED      /* jpeg_save_markers() needed? */
277bc79e0680a45d1ca330d690dae0340c8e17ab5e3Thomas G. Lane#define BLOCK_SMOOTHING_SUPPORTED   /* Block smoothing? (Progressive only) */
278e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define IDCT_SCALING_SUPPORTED      /* Output rescaling via IDCT? */
27936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#undef  UPSAMPLE_SCALING_SUPPORTED  /* Output rescaling at upsample stage? */
28036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define UPSAMPLE_MERGING_SUPPORTED  /* Fast path for sloppy upsampling? */
281e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define QUANT_1PASS_SUPPORTED       /* 1-pass color quantization? */
282e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define QUANT_2PASS_SUPPORTED       /* 2-pass color quantization? */
28336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
28436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* more capability options later, no doubt */
28536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
28636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
28736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/*
288976fd9687e5773f3653385da7a3489ce4d58dd51DRC * The RGB_RED, RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE macros are a vestigial
289976fd9687e5773f3653385da7a3489ce4d58dd51DRC * feature of libjpeg.  The idea was that, if an application developer needed
290976fd9687e5773f3653385da7a3489ce4d58dd51DRC * to compress from/decompress to a BGR/BGRX/RGBX/XBGR/XRGB buffer, they could
291976fd9687e5773f3653385da7a3489ce4d58dd51DRC * change these macros, rebuild libjpeg, and link their application statically
292976fd9687e5773f3653385da7a3489ce4d58dd51DRC * with it.  In reality, few people ever did this, because there were some
293976fd9687e5773f3653385da7a3489ce4d58dd51DRC * severe restrictions involved (cjpeg and djpeg no longer worked properly,
294976fd9687e5773f3653385da7a3489ce4d58dd51DRC * compressing/decompressing RGB JPEGs no longer worked properly, and the color
295976fd9687e5773f3653385da7a3489ce4d58dd51DRC * quantizer wouldn't work with pixel sizes other than 3.)  Further, since all
296976fd9687e5773f3653385da7a3489ce4d58dd51DRC * of the O/S-supplied versions of libjpeg were built with the default values
297976fd9687e5773f3653385da7a3489ce4d58dd51DRC * of RGB_RED, RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE, many applications have
298976fd9687e5773f3653385da7a3489ce4d58dd51DRC * come to regard these values as immutable.
299976fd9687e5773f3653385da7a3489ce4d58dd51DRC *
300976fd9687e5773f3653385da7a3489ce4d58dd51DRC * The libjpeg-turbo colorspace extensions provide a much cleaner way of
301976fd9687e5773f3653385da7a3489ce4d58dd51DRC * compressing from/decompressing to buffers with arbitrary component orders
302976fd9687e5773f3653385da7a3489ce4d58dd51DRC * and pixel sizes.  Thus, we do not support changing the values of RGB_RED,
303976fd9687e5773f3653385da7a3489ce4d58dd51DRC * RGB_GREEN, RGB_BLUE, or RGB_PIXELSIZE.  In addition to the restrictions
304976fd9687e5773f3653385da7a3489ce4d58dd51DRC * listed above, changing these values will also break the SIMD extensions and
305976fd9687e5773f3653385da7a3489ce4d58dd51DRC * the regression tests.
30636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
30736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
308e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define RGB_RED         0       /* Offset of Red in an RGB scanline element */
309e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define RGB_GREEN       1       /* Offset of Green */
310e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define RGB_BLUE        2       /* Offset of Blue */
311e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define RGB_PIXELSIZE   3       /* JSAMPLEs per RGB scanline element */
31236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
31378df2e6115b0e579432d01cb034132cd4402a1baDRC#define JPEG_NUMCS 17
314f25c071eb745268452206bb633561b770c4d62eaDRC
315b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_RGB_RED        0
316b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_RGB_GREEN      1
317b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_RGB_BLUE       2
318b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_RGB_PIXELSIZE  3
319b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC
320b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_RGBX_RED       0
321b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_RGBX_GREEN     1
322b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_RGBX_BLUE      2
323b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_RGBX_PIXELSIZE 4
324b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC
325b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_BGR_RED        2
326b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_BGR_GREEN      1
327b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_BGR_BLUE       0
328b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_BGR_PIXELSIZE  3
329b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC
330b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_BGRX_RED       2
331b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_BGRX_GREEN     1
332b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_BGRX_BLUE      0
333b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_BGRX_PIXELSIZE 4
334b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC
335b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_XBGR_RED       3
336b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_XBGR_GREEN     2
337b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_XBGR_BLUE      1
338b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_XBGR_PIXELSIZE 4
339b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC
340b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_XRGB_RED       1
341b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_XRGB_GREEN     2
342b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_XRGB_BLUE      3
343b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC#define EXT_XRGB_PIXELSIZE 4
344b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC
345f25c071eb745268452206bb633561b770c4d62eaDRCstatic const int rgb_red[JPEG_NUMCS] = {
346b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC  -1, -1, RGB_RED, -1, -1, -1, EXT_RGB_RED, EXT_RGBX_RED,
34767ce3b2352fe1f7511edbfed74ec6960e41e97dcDRC  EXT_BGR_RED, EXT_BGRX_RED, EXT_XBGR_RED, EXT_XRGB_RED,
34878df2e6115b0e579432d01cb034132cd4402a1baDRC  EXT_RGBX_RED, EXT_BGRX_RED, EXT_XBGR_RED, EXT_XRGB_RED,
34978df2e6115b0e579432d01cb034132cd4402a1baDRC  -1
350f25c071eb745268452206bb633561b770c4d62eaDRC};
351f25c071eb745268452206bb633561b770c4d62eaDRC
352f25c071eb745268452206bb633561b770c4d62eaDRCstatic const int rgb_green[JPEG_NUMCS] = {
353b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC  -1, -1, RGB_GREEN, -1, -1, -1, EXT_RGB_GREEN, EXT_RGBX_GREEN,
35467ce3b2352fe1f7511edbfed74ec6960e41e97dcDRC  EXT_BGR_GREEN, EXT_BGRX_GREEN, EXT_XBGR_GREEN, EXT_XRGB_GREEN,
35578df2e6115b0e579432d01cb034132cd4402a1baDRC  EXT_RGBX_GREEN, EXT_BGRX_GREEN, EXT_XBGR_GREEN, EXT_XRGB_GREEN,
35678df2e6115b0e579432d01cb034132cd4402a1baDRC  -1
357f25c071eb745268452206bb633561b770c4d62eaDRC};
358f25c071eb745268452206bb633561b770c4d62eaDRC
359f25c071eb745268452206bb633561b770c4d62eaDRCstatic const int rgb_blue[JPEG_NUMCS] = {
360b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC  -1, -1, RGB_BLUE, -1, -1, -1, EXT_RGB_BLUE, EXT_RGBX_BLUE,
36167ce3b2352fe1f7511edbfed74ec6960e41e97dcDRC  EXT_BGR_BLUE, EXT_BGRX_BLUE, EXT_XBGR_BLUE, EXT_XRGB_BLUE,
36278df2e6115b0e579432d01cb034132cd4402a1baDRC  EXT_RGBX_BLUE, EXT_BGRX_BLUE, EXT_XBGR_BLUE, EXT_XRGB_BLUE,
36378df2e6115b0e579432d01cb034132cd4402a1baDRC  -1
364f25c071eb745268452206bb633561b770c4d62eaDRC};
365f25c071eb745268452206bb633561b770c4d62eaDRC
366f25c071eb745268452206bb633561b770c4d62eaDRCstatic const int rgb_pixelsize[JPEG_NUMCS] = {
367b4570bbf8cb3045e2b3cbf3d6a80d31735871d10DRC  -1, -1, RGB_PIXELSIZE, -1, -1, -1, EXT_RGB_PIXELSIZE, EXT_RGBX_PIXELSIZE,
36867ce3b2352fe1f7511edbfed74ec6960e41e97dcDRC  EXT_BGR_PIXELSIZE, EXT_BGRX_PIXELSIZE, EXT_XBGR_PIXELSIZE, EXT_XRGB_PIXELSIZE,
36978df2e6115b0e579432d01cb034132cd4402a1baDRC  EXT_RGBX_PIXELSIZE, EXT_BGRX_PIXELSIZE, EXT_XBGR_PIXELSIZE, EXT_XRGB_PIXELSIZE,
37078df2e6115b0e579432d01cb034132cd4402a1baDRC  -1
371f25c071eb745268452206bb633561b770c4d62eaDRC};
37236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
37336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* Definitions for speed-related optimizations. */
37436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
37536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying
37636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * two 16-bit shorts is faster than multiplying two ints.  Define MULTIPLIER
37736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * as short on such a machine.  MULTIPLIER must be at least 16 bits wide.
37836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
37936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
38036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#ifndef MULTIPLIER
3815eb84ff97f00c02aadfdce0cb30ab3e899c1b113Pierre Ossman#ifndef WITH_SIMD
382e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define MULTIPLIER  int         /* type for fastest integer multiply */
3835eb84ff97f00c02aadfdce0cb30ab3e899c1b113Pierre Ossman#else
3845eb84ff97f00c02aadfdce0cb30ab3e899c1b113Pierre Ossman#define MULTIPLIER short  /* prefer 16-bit with SIMD for parellelism */
3855eb84ff97f00c02aadfdce0cb30ab3e899c1b113Pierre Ossman#endif
38636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif
38736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
38836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
38936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* FAST_FLOAT should be either float or double, whichever is done faster
39036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * by your compiler.  (Note that this type is only used in the floating point
39136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)
39236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
39336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
39436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#ifndef FAST_FLOAT
39536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define FAST_FLOAT  float
39636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif
39736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
39836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif /* JPEG_INTERNAL_OPTIONS */
399