kusano 7d535a
/*
kusano 7d535a
 * jmorecfg.h
kusano 7d535a
 *
kusano 7d535a
 * Copyright (C) 1991-1997, Thomas G. Lane.
kusano 7d535a
 * Modified 1997-2012 by Guido Vollbeding.
kusano 7d535a
 * This file is part of the Independent JPEG Group's software.
kusano 7d535a
 * For conditions of distribution and use, see the accompanying README file.
kusano 7d535a
 *
kusano 7d535a
 * This file contains additional configuration options that customize the
kusano 7d535a
 * JPEG software for special applications or support machine-dependent
kusano 7d535a
 * optimizations.  Most users will not need to touch this file.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * Define BITS_IN_JSAMPLE as either
kusano 7d535a
 *   8   for 8-bit sample values (the usual setting)
kusano 7d535a
 *   12  for 12-bit sample values
kusano 7d535a
 * Only 8 and 12 are legal data precisions for lossy JPEG according to the
kusano 7d535a
 * JPEG standard, and the IJG code does not support anything else!
kusano 7d535a
 * We do not support run-time selection of data precision, sorry.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#define BITS_IN_JSAMPLE  8	/* use 8 or 12 */
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * Maximum number of components (color channels) allowed in JPEG image.
kusano 7d535a
 * To meet the letter of the JPEG spec, set this to 255.  However, darn
kusano 7d535a
 * few applications need more than 4 channels (maybe 5 for CMYK + alpha
kusano 7d535a
 * mask).  We recommend 10 as a reasonable compromise; use 4 if you are
kusano 7d535a
 * really short on memory.  (Each allowed component costs a hundred or so
kusano 7d535a
 * bytes of storage, whether actually used in an image or not.)
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#define MAX_COMPONENTS  10	/* maximum number of image components */
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * Basic data types.
kusano 7d535a
 * You may need to change these if you have a machine with unusual data
kusano 7d535a
 * type sizes; for example, "char" not 8 bits, "short" not 16 bits,
kusano 7d535a
 * or "long" not 32 bits.  We don't care whether "int" is 16 or 32 bits,
kusano 7d535a
 * but it had better be at least 16.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
/* Representation of a single sample (pixel element value).
kusano 7d535a
 * We frequently allocate large arrays of these, so it's important to keep
kusano 7d535a
 * them small.  But if you have memory to burn and access to char or short
kusano 7d535a
 * arrays is very slow on your hardware, you might want to change these.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#if BITS_IN_JSAMPLE == 8
kusano 7d535a
/* JSAMPLE should be the smallest type that will hold the values 0..255.
kusano 7d535a
 * You can use a signed char by having GETJSAMPLE mask it with 0xFF.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#ifdef HAVE_UNSIGNED_CHAR
kusano 7d535a
kusano 7d535a
typedef unsigned char JSAMPLE;
kusano 7d535a
#define GETJSAMPLE(value)  ((int) (value))
kusano 7d535a
kusano 7d535a
#else /* not HAVE_UNSIGNED_CHAR */
kusano 7d535a
kusano 7d535a
typedef char JSAMPLE;
kusano 7d535a
#ifdef CHAR_IS_UNSIGNED
kusano 7d535a
#define GETJSAMPLE(value)  ((int) (value))
kusano 7d535a
#else
kusano 7d535a
#define GETJSAMPLE(value)  ((int) (value) & 0xFF)
kusano 7d535a
#endif /* CHAR_IS_UNSIGNED */
kusano 7d535a
kusano 7d535a
#endif /* HAVE_UNSIGNED_CHAR */
kusano 7d535a
kusano 7d535a
#define MAXJSAMPLE	255
kusano 7d535a
#define CENTERJSAMPLE	128
kusano 7d535a
kusano 7d535a
#endif /* BITS_IN_JSAMPLE == 8 */
kusano 7d535a
kusano 7d535a
kusano 7d535a
#if BITS_IN_JSAMPLE == 12
kusano 7d535a
/* JSAMPLE should be the smallest type that will hold the values 0..4095.
kusano 7d535a
 * On nearly all machines "short" will do nicely.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
typedef short JSAMPLE;
kusano 7d535a
#define GETJSAMPLE(value)  ((int) (value))
kusano 7d535a
kusano 7d535a
#define MAXJSAMPLE	4095
kusano 7d535a
#define CENTERJSAMPLE	2048
kusano 7d535a
kusano 7d535a
#endif /* BITS_IN_JSAMPLE == 12 */
kusano 7d535a
kusano 7d535a
kusano 7d535a
/* Representation of a DCT frequency coefficient.
kusano 7d535a
 * This should be a signed value of at least 16 bits; "short" is usually OK.
kusano 7d535a
 * Again, we allocate large arrays of these, but you can change to int
kusano 7d535a
 * if you have memory to burn and "short" is really slow.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
typedef short JCOEF;
kusano 7d535a
kusano 7d535a
kusano 7d535a
/* Compressed datastreams are represented as arrays of JOCTET.
kusano 7d535a
 * These must be EXACTLY 8 bits wide, at least once they are written to
kusano 7d535a
 * external storage.  Note that when using the stdio data source/destination
kusano 7d535a
 * managers, this is also the data type passed to fread/fwrite.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#ifdef HAVE_UNSIGNED_CHAR
kusano 7d535a
kusano 7d535a
typedef unsigned char JOCTET;
kusano 7d535a
#define GETJOCTET(value)  (value)
kusano 7d535a
kusano 7d535a
#else /* not HAVE_UNSIGNED_CHAR */
kusano 7d535a
kusano 7d535a
typedef char JOCTET;
kusano 7d535a
#ifdef CHAR_IS_UNSIGNED
kusano 7d535a
#define GETJOCTET(value)  (value)
kusano 7d535a
#else
kusano 7d535a
#define GETJOCTET(value)  ((value) & 0xFF)
kusano 7d535a
#endif /* CHAR_IS_UNSIGNED */
kusano 7d535a
kusano 7d535a
#endif /* HAVE_UNSIGNED_CHAR */
kusano 7d535a
kusano 7d535a
kusano 7d535a
/* These typedefs are used for various table entries and so forth.
kusano 7d535a
 * They must be at least as wide as specified; but making them too big
kusano 7d535a
 * won't cost a huge amount of memory, so we don't provide special
kusano 7d535a
 * extraction code like we did for JSAMPLE.  (In other words, these
kusano 7d535a
 * typedefs live at a different point on the speed/space tradeoff curve.)
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
/* UINT8 must hold at least the values 0..255. */
kusano 7d535a
kusano 7d535a
#ifdef HAVE_UNSIGNED_CHAR
kusano 7d535a
typedef unsigned char UINT8;
kusano 7d535a
#else /* not HAVE_UNSIGNED_CHAR */
kusano 7d535a
#ifdef CHAR_IS_UNSIGNED
kusano 7d535a
typedef char UINT8;
kusano 7d535a
#else /* not CHAR_IS_UNSIGNED */
kusano 7d535a
typedef short UINT8;
kusano 7d535a
#endif /* CHAR_IS_UNSIGNED */
kusano 7d535a
#endif /* HAVE_UNSIGNED_CHAR */
kusano 7d535a
kusano 7d535a
/* UINT16 must hold at least the values 0..65535. */
kusano 7d535a
kusano 7d535a
#ifdef HAVE_UNSIGNED_SHORT
kusano 7d535a
typedef unsigned short UINT16;
kusano 7d535a
#else /* not HAVE_UNSIGNED_SHORT */
kusano 7d535a
typedef unsigned int UINT16;
kusano 7d535a
#endif /* HAVE_UNSIGNED_SHORT */
kusano 7d535a
kusano 7d535a
/* INT16 must hold at least the values -32768..32767. */
kusano 7d535a
kusano 7d535a
#ifndef XMD_H			/* X11/xmd.h correctly defines INT16 */
kusano 7d535a
typedef short INT16;
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
/* INT32 must hold at least signed 32-bit values. */
kusano 7d535a
kusano 7d535a
#ifndef XMD_H			/* X11/xmd.h correctly defines INT32 */
kusano 7d535a
#ifndef _BASETSD_H_		/* Microsoft defines it in basetsd.h */
kusano 7d535a
#ifndef _BASETSD_H		/* MinGW is slightly different */
kusano 7d535a
#ifndef QGLOBAL_H		/* Qt defines it in qglobal.h */
kusano 7d535a
typedef long INT32;
kusano 7d535a
#endif
kusano 7d535a
#endif
kusano 7d535a
#endif
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
/* Datatype used for image dimensions.  The JPEG standard only supports
kusano 7d535a
 * images up to 64K*64K due to 16-bit fields in SOF markers.  Therefore
kusano 7d535a
 * "unsigned int" is sufficient on all machines.  However, if you need to
kusano 7d535a
 * handle larger images and you don't mind deviating from the spec, you
kusano 7d535a
 * can change this datatype.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
typedef unsigned int JDIMENSION;
kusano 7d535a
kusano 7d535a
#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */
kusano 7d535a
kusano 7d535a
kusano 7d535a
/* These macros are used in all function definitions and extern declarations.
kusano 7d535a
 * You could modify them if you need to change function linkage conventions;
kusano 7d535a
 * in particular, you'll need to do that to make the library a Windows DLL.
kusano 7d535a
 * Another application is to make all functions global for use with debuggers
kusano 7d535a
 * or code profilers that require it.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
/* a function called through method pointers: */
kusano 7d535a
#define METHODDEF(type)		static type
kusano 7d535a
/* a function used only in its module: */
kusano 7d535a
#define LOCAL(type)		static type
kusano 7d535a
/* a function referenced thru EXTERNs: */
kusano 7d535a
#define GLOBAL(type)		type
kusano 7d535a
/* a reference to a GLOBAL function: */
kusano 7d535a
#define EXTERN(type)		extern type
kusano 7d535a
kusano 7d535a
kusano 7d535a
/* This macro is used to declare a "method", that is, a function pointer.
kusano 7d535a
 * We want to supply prototype parameters if the compiler can cope.
kusano 7d535a
 * Note that the arglist parameter must be parenthesized!
kusano 7d535a
 * Again, you can customize this if you need special linkage keywords.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#ifdef HAVE_PROTOTYPES
kusano 7d535a
#define JMETHOD(type,methodname,arglist)  type (*methodname) arglist
kusano 7d535a
#else
kusano 7d535a
#define JMETHOD(type,methodname,arglist)  type (*methodname) ()
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
kusano 7d535a
/* The noreturn type identifier is used to declare functions
kusano 7d535a
 * which cannot return.
kusano 7d535a
 * Compilers can thus create more optimized code and perform
kusano 7d535a
 * better checks for warnings and errors.
kusano 7d535a
 * Static analyzer tools can make improved inferences about
kusano 7d535a
 * execution paths and are prevented from giving false alerts.
kusano 7d535a
 *
kusano 7d535a
 * Unfortunately, the proposed specifications of corresponding
kusano 7d535a
 * extensions in the Dec 2011 ISO C standard revision (C11),
kusano 7d535a
 * GCC, MSVC, etc. are not viable.
kusano 7d535a
 * Thus we introduce a user defined type to declare noreturn
kusano 7d535a
 * functions at least for clarity.  A proper compiler would
kusano 7d535a
 * have a suitable noreturn type to match in place of void.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#ifndef HAVE_NORETURN_T
kusano 7d535a
typedef void noreturn_t;
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
kusano 7d535a
/* Here is the pseudo-keyword for declaring pointers that must be "far"
kusano 7d535a
 * on 80x86 machines.  Most of the specialized coding for 80x86 is handled
kusano 7d535a
 * by just saying "FAR *" where such a pointer is needed.  In a few places
kusano 7d535a
 * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#ifndef FAR
kusano 7d535a
#ifdef NEED_FAR_POINTERS
kusano 7d535a
#define FAR  far
kusano 7d535a
#else
kusano 7d535a
#define FAR
kusano 7d535a
#endif
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * On a few systems, type boolean and/or its values FALSE, TRUE may appear
kusano 7d535a
 * in standard header files.  Or you may have conflicts with application-
kusano 7d535a
 * specific header files that you want to include together with these files.
kusano 7d535a
 * Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#ifdef HAVE_BOOLEAN
kusano 7d535a
#ifndef FALSE			/* in case these macros already exist */
kusano 7d535a
#define FALSE	0		/* values of boolean */
kusano 7d535a
#endif
kusano 7d535a
#ifndef TRUE
kusano 7d535a
#define TRUE	1
kusano 7d535a
#endif
kusano 7d535a
#else
kusano 7d535a
#undef TRUE
kusano 7d535a
#undef FALSE
kusano 7d535a
typedef enum { FALSE = 0, TRUE = 1 } boolean;
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * The remaining options affect code selection within the JPEG library,
kusano 7d535a
 * but they don't need to be visible to most applications using the library.
kusano 7d535a
 * To minimize application namespace pollution, the symbols won't be
kusano 7d535a
 * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#ifdef JPEG_INTERNALS
kusano 7d535a
#define JPEG_INTERNAL_OPTIONS
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
#ifdef JPEG_INTERNAL_OPTIONS
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * These defines indicate whether to include various optional functions.
kusano 7d535a
 * Undefining some of these symbols will produce a smaller but less capable
kusano 7d535a
 * library.  Note that you can leave certain source files out of the
kusano 7d535a
 * compilation/linking process if you've #undef'd the corresponding symbols.
kusano 7d535a
 * (You may HAVE to do that if your compiler doesn't like null source files.)
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
/* Capability options common to encoder and decoder: */
kusano 7d535a
kusano 7d535a
#define DCT_ISLOW_SUPPORTED	/* slow but accurate integer algorithm */
kusano 7d535a
#define DCT_IFAST_SUPPORTED	/* faster, less accurate integer method */
kusano 7d535a
#define DCT_FLOAT_SUPPORTED	/* floating-point: accurate, fast on fast HW */
kusano 7d535a
kusano 7d535a
/* Encoder capability options: */
kusano 7d535a
kusano 7d535a
#define C_ARITH_CODING_SUPPORTED    /* Arithmetic coding back end? */
kusano 7d535a
#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
kusano 7d535a
#define C_PROGRESSIVE_SUPPORTED	    /* Progressive JPEG? (Requires MULTISCAN)*/
kusano 7d535a
#define DCT_SCALING_SUPPORTED	    /* Input rescaling via DCT? (Requires DCT_ISLOW)*/
kusano 7d535a
#define ENTROPY_OPT_SUPPORTED	    /* Optimization of entropy coding parms? */
kusano 7d535a
/* Note: if you selected 12-bit data precision, it is dangerous to turn off
kusano 7d535a
 * ENTROPY_OPT_SUPPORTED.  The standard Huffman tables are only good for 8-bit
kusano 7d535a
 * precision, so jchuff.c normally uses entropy optimization to compute
kusano 7d535a
 * usable tables for higher precision.  If you don't want to do optimization,
kusano 7d535a
 * you'll have to supply different default Huffman tables.
kusano 7d535a
 * The exact same statements apply for progressive JPEG: the default tables
kusano 7d535a
 * don't work for progressive mode.  (This may get fixed, however.)
kusano 7d535a
 */
kusano 7d535a
#define INPUT_SMOOTHING_SUPPORTED   /* Input image smoothing option? */
kusano 7d535a
kusano 7d535a
/* Decoder capability options: */
kusano 7d535a
kusano 7d535a
#define D_ARITH_CODING_SUPPORTED    /* Arithmetic coding back end? */
kusano 7d535a
#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
kusano 7d535a
#define D_PROGRESSIVE_SUPPORTED	    /* Progressive JPEG? (Requires MULTISCAN)*/
kusano 7d535a
#define IDCT_SCALING_SUPPORTED	    /* Output rescaling via IDCT? */
kusano 7d535a
#define SAVE_MARKERS_SUPPORTED	    /* jpeg_save_markers() needed? */
kusano 7d535a
#define BLOCK_SMOOTHING_SUPPORTED   /* Block smoothing? (Progressive only) */
kusano 7d535a
#undef  UPSAMPLE_SCALING_SUPPORTED  /* Output rescaling at upsample stage? */
kusano 7d535a
#define UPSAMPLE_MERGING_SUPPORTED  /* Fast path for sloppy upsampling? */
kusano 7d535a
#define QUANT_1PASS_SUPPORTED	    /* 1-pass color quantization? */
kusano 7d535a
#define QUANT_2PASS_SUPPORTED	    /* 2-pass color quantization? */
kusano 7d535a
kusano 7d535a
/* more capability options later, no doubt */
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * Ordering of RGB data in scanlines passed to or from the application.
kusano 7d535a
 * If your application wants to deal with data in the order B,G,R, just
kusano 7d535a
 * change these macros.  You can also deal with formats such as R,G,B,X
kusano 7d535a
 * (one extra byte per pixel) by changing RGB_PIXELSIZE.  Note that changing
kusano 7d535a
 * the offsets will also change the order in which colormap data is organized.
kusano 7d535a
 * RESTRICTIONS:
kusano 7d535a
 * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.
kusano 7d535a
 * 2. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
kusano 7d535a
 *    is not 3 (they don't understand about dummy color components!).  So you
kusano 7d535a
 *    can't use color quantization if you change that value.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#define RGB_RED		0	/* Offset of Red in an RGB scanline element */
kusano 7d535a
#define RGB_GREEN	1	/* Offset of Green */
kusano 7d535a
#define RGB_BLUE	2	/* Offset of Blue */
kusano 7d535a
#define RGB_PIXELSIZE	3	/* JSAMPLEs per RGB scanline element */
kusano 7d535a
kusano 7d535a
kusano 7d535a
/* Definitions for speed-related optimizations. */
kusano 7d535a
kusano 7d535a
kusano 7d535a
/* If your compiler supports inline functions, define INLINE
kusano 7d535a
 * as the inline keyword; otherwise define it as empty.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#ifndef INLINE
kusano 7d535a
#ifdef __GNUC__			/* for instance, GNU C knows about inline */
kusano 7d535a
#define INLINE __inline__
kusano 7d535a
#endif
kusano 7d535a
#ifndef INLINE
kusano 7d535a
#define INLINE			/* default is to define it as empty */
kusano 7d535a
#endif
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
kusano 7d535a
/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying
kusano 7d535a
 * two 16-bit shorts is faster than multiplying two ints.  Define MULTIPLIER
kusano 7d535a
 * as short on such a machine.  MULTIPLIER must be at least 16 bits wide.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#ifndef MULTIPLIER
kusano 7d535a
#define MULTIPLIER  int		/* type for fastest integer multiply */
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
kusano 7d535a
/* FAST_FLOAT should be either float or double, whichever is done faster
kusano 7d535a
 * by your compiler.  (Note that this type is only used in the floating point
kusano 7d535a
 * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)
kusano 7d535a
 * Typically, float is faster in ANSI C compilers, while double is faster in
kusano 7d535a
 * pre-ANSI compilers (because they insist on converting to double anyway).
kusano 7d535a
 * The code below therefore chooses float if we have ANSI-style prototypes.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#ifndef FAST_FLOAT
kusano 7d535a
#ifdef HAVE_PROTOTYPES
kusano 7d535a
#define FAST_FLOAT  float
kusano 7d535a
#else
kusano 7d535a
#define FAST_FLOAT  double
kusano 7d535a
#endif
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
#endif /* JPEG_INTERNAL_OPTIONS */