--- /dev/null
+/* jconfig.h. Generated from jconfig.cfg by configure. */
+/* jconfig.cfg --- source file edited by configure script */
+/* see jconfig.txt for explanations */
+
+#define HAVE_PROTOTYPES 1
+#define HAVE_UNSIGNED_CHAR 1
+#define HAVE_UNSIGNED_SHORT 1
+/* #undef void */
+/* #undef const */
+/* #undef CHAR_IS_UNSIGNED */
+#define HAVE_STDDEF_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_LOCALE_H 1
+/* #undef NEED_BSD_STRINGS */
+/* #undef NEED_SYS_TYPES_H */
+/* #undef NEED_FAR_POINTERS */
+/* #undef NEED_SHORT_EXTERNAL_NAMES */
+/* Define this if you get warnings about undefined structures. */
+/* #undef INCOMPLETE_TYPES_BROKEN */
+
+/* Define "boolean" as unsigned char, not int, on Windows systems. */
+#ifdef _WIN32
+#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
+typedef unsigned char boolean;
+#endif
+#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
+#endif
+
+#ifdef JPEG_INTERNALS
+
+/* #undef RIGHT_SHIFT_IS_UNSIGNED */
+#define INLINE __inline__
+/* These are for configuring the JPEG memory manager. */
+/* #undef DEFAULT_MAX_MEM */
+/* #undef NO_MKTEMP */
+
+#endif /* JPEG_INTERNALS */
+
+#ifdef JPEG_CJPEG_DJPEG
+
+#define BMP_SUPPORTED /* BMP image file format */
+#define GIF_SUPPORTED /* GIF image file format */
+#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
+/* #undef RLE_SUPPORTED */
+#define TARGA_SUPPORTED /* Targa image file format */
+
+/* #undef TWO_FILE_COMMANDLINE */
+/* #undef NEED_SIGNAL_CATCHER */
+/* #undef DONT_USE_B_MODE */
+
+/* Define this if you want percent-done progress reports from cjpeg/djpeg. */
+/* #undef PROGRESS_REPORT */
+
+#endif /* JPEG_CJPEG_DJPEG */
--- /dev/null
+/*
+ * jerror.h
+ *
+ * Copyright (C) 1994-1997, Thomas G. Lane.
+ * Modified 1997-2009 by Guido Vollbeding.
+ * This file is part of the Independent JPEG Group's software.
+ * For conditions of distribution and use, see the accompanying README file.
+ *
+ * This file defines the error and message codes for the JPEG library.
+ * Edit this file to add new codes, or to translate the message strings to
+ * some other language.
+ * A set of error-reporting macros are defined too. Some applications using
+ * the JPEG library may wish to include this file to get the error codes
+ * and/or the macros.
+ */
+
+/*
+ * To define the enum list of message codes, include this file without
+ * defining macro JMESSAGE. To create a message string table, include it
+ * again with a suitable JMESSAGE definition (see jerror.c for an example).
+ */
+#ifndef JMESSAGE
+#ifndef JERROR_H
+/* First time through, define the enum list */
+#define JMAKE_ENUM_LIST
+#else
+/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */
+#define JMESSAGE(code,string)
+#endif /* JERROR_H */
+#endif /* JMESSAGE */
+
+#ifdef JMAKE_ENUM_LIST
+
+typedef enum {
+
+#define JMESSAGE(code,string) code ,
+
+#endif /* JMAKE_ENUM_LIST */
+
+JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */
+
+/* For maintenance convenience, list is alphabetical by message code name */
+JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix")
+JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix")
+JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode")
+JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS")
+JMESSAGE(JERR_BAD_CROP_SPEC, "Invalid crop request")
+JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range")
+JMESSAGE(JERR_BAD_DCTSIZE, "DCT scaled block size %dx%d not supported")
+JMESSAGE(JERR_BAD_DROP_SAMPLING,
+ "Component index %d: mismatching sampling ratio %d:%d, %d:%d, %c")
+JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition")
+JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace")
+JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace")
+JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length")
+JMESSAGE(JERR_BAD_LIB_VERSION,
+ "Wrong JPEG library version: library is %d, caller expects %d")
+JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan")
+JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d")
+JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d")
+JMESSAGE(JERR_BAD_PROGRESSION,
+ "Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d")
+JMESSAGE(JERR_BAD_PROG_SCRIPT,
+ "Invalid progressive parameters at scan script entry %d")
+JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors")
+JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d")
+JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d")
+JMESSAGE(JERR_BAD_STRUCT_SIZE,
+ "JPEG parameter struct mismatch: library thinks size is %u, caller expects %u")
+JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access")
+JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small")
+JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here")
+JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet")
+JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d")
+JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request")
+JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d")
+JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x")
+JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d")
+JMESSAGE(JERR_DQT_INDEX, "Bogus DQT index %d")
+JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)")
+JMESSAGE(JERR_EMS_READ, "Read from EMS failed")
+JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed")
+JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan")
+JMESSAGE(JERR_FILE_READ, "Input file read error")
+JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?")
+JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet")
+JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow")
+JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry")
+JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels")
+JMESSAGE(JERR_INPUT_EMPTY, "Empty input file")
+JMESSAGE(JERR_INPUT_EOF, "Premature end of input file")
+JMESSAGE(JERR_MISMATCHED_QUANT_TABLE,
+ "Cannot transcode due to multiple use of quantization table %d")
+JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data")
+JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change")
+JMESSAGE(JERR_NOTIMPL, "Not implemented yet")
+JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time")
+JMESSAGE(JERR_NO_ARITH_TABLE, "Arithmetic table 0x%02x was not defined")
+JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported")
+JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined")
+JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image")
+JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined")
+JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x")
+JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)")
+JMESSAGE(JERR_QUANT_COMPONENTS,
+ "Cannot quantize more than %d color components")
+JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors")
+JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors")
+JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers")
+JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker")
+JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x")
+JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers")
+JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF")
+JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s")
+JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file")
+JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file")
+JMESSAGE(JERR_TFILE_WRITE,
+ "Write failed on temporary file --- out of disk space?")
+JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines")
+JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x")
+JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up")
+JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation")
+JMESSAGE(JERR_XMS_READ, "Read from XMS failed")
+JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed")
+JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT)
+JMESSAGE(JMSG_VERSION, JVERSION)
+JMESSAGE(JTRC_16BIT_TABLES,
+ "Caution: quantization tables are too coarse for baseline JPEG")
+JMESSAGE(JTRC_ADOBE,
+ "Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d")
+JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u")
+JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u")
+JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x")
+JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x")
+JMESSAGE(JTRC_DQT, "Define Quantization Table %d precision %d")
+JMESSAGE(JTRC_DRI, "Define Restart Interval %u")
+JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u")
+JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u")
+JMESSAGE(JTRC_EOI, "End Of Image")
+JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d")
+JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d")
+JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE,
+ "Warning: thumbnail image size does not match data length %u")
+JMESSAGE(JTRC_JFIF_EXTENSION,
+ "JFIF extension marker: type 0x%02x, length %u")
+JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image")
+JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u")
+JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x")
+JMESSAGE(JTRC_QUANTVALS, " %4u %4u %4u %4u %4u %4u %4u %4u")
+JMESSAGE(JTRC_QUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors")
+JMESSAGE(JTRC_QUANT_NCOLORS, "Quantizing to %d colors")
+JMESSAGE(JTRC_QUANT_SELECTED, "Selected %d colors for quantization")
+JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d")
+JMESSAGE(JTRC_RST, "RST%d")
+JMESSAGE(JTRC_SMOOTH_NOTIMPL,
+ "Smoothing not supported with nonstandard sampling ratios")
+JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d")
+JMESSAGE(JTRC_SOF_COMPONENT, " Component %d: %dhx%dv q=%d")
+JMESSAGE(JTRC_SOI, "Start of Image")
+JMESSAGE(JTRC_SOS, "Start Of Scan: %d components")
+JMESSAGE(JTRC_SOS_COMPONENT, " Component %d: dc=%d ac=%d")
+JMESSAGE(JTRC_SOS_PARAMS, " Ss=%d, Se=%d, Ah=%d, Al=%d")
+JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s")
+JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s")
+JMESSAGE(JTRC_THUMB_JPEG,
+ "JFIF extension marker: JPEG-compressed thumbnail image, length %u")
+JMESSAGE(JTRC_THUMB_PALETTE,
+ "JFIF extension marker: palette thumbnail image, length %u")
+JMESSAGE(JTRC_THUMB_RGB,
+ "JFIF extension marker: RGB thumbnail image, length %u")
+JMESSAGE(JTRC_UNKNOWN_IDS,
+ "Unrecognized component IDs %d %d %d, assuming YCbCr")
+JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u")
+JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u")
+JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d")
+JMESSAGE(JWRN_ARITH_BAD_CODE, "Corrupt JPEG data: bad arithmetic code")
+JMESSAGE(JWRN_BOGUS_PROGRESSION,
+ "Inconsistent progression sequence for component %d coefficient %d")
+JMESSAGE(JWRN_EXTRANEOUS_DATA,
+ "Corrupt JPEG data: %u extraneous bytes before marker 0x%02x")
+JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment")
+JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code")
+JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d")
+JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file")
+JMESSAGE(JWRN_MUST_RESYNC,
+ "Corrupt JPEG data: found marker 0x%02x instead of RST%d")
+JMESSAGE(JWRN_NOT_SEQUENTIAL, "Invalid SOS parameters for sequential JPEG")
+JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines")
+
+#ifdef JMAKE_ENUM_LIST
+
+ JMSG_LASTMSGCODE
+} J_MESSAGE_CODE;
+
+#undef JMAKE_ENUM_LIST
+#endif /* JMAKE_ENUM_LIST */
+
+/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */
+#undef JMESSAGE
+
+
+#ifndef JERROR_H
+#define JERROR_H
+
+/* Macros to simplify using the error and trace message stuff */
+/* The first parameter is either type of cinfo pointer */
+
+/* Fatal errors (print message and exit) */
+#define ERREXIT(cinfo,code) \
+ ((cinfo)->err->msg_code = (code), \
+ (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
+#define ERREXIT1(cinfo,code,p1) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
+#define ERREXIT2(cinfo,code,p1,p2) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (cinfo)->err->msg_parm.i[1] = (p2), \
+ (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
+#define ERREXIT3(cinfo,code,p1,p2,p3) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (cinfo)->err->msg_parm.i[1] = (p2), \
+ (cinfo)->err->msg_parm.i[2] = (p3), \
+ (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
+#define ERREXIT4(cinfo,code,p1,p2,p3,p4) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (cinfo)->err->msg_parm.i[1] = (p2), \
+ (cinfo)->err->msg_parm.i[2] = (p3), \
+ (cinfo)->err->msg_parm.i[3] = (p4), \
+ (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
+#define ERREXIT6(cinfo,code,p1,p2,p3,p4,p5,p6) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (cinfo)->err->msg_parm.i[1] = (p2), \
+ (cinfo)->err->msg_parm.i[2] = (p3), \
+ (cinfo)->err->msg_parm.i[3] = (p4), \
+ (cinfo)->err->msg_parm.i[4] = (p5), \
+ (cinfo)->err->msg_parm.i[5] = (p6), \
+ (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
+#define ERREXITS(cinfo,code,str) \
+ ((cinfo)->err->msg_code = (code), \
+ strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
+ (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
+
+#define MAKESTMT(stuff) do { stuff } while (0)
+
+/* Nonfatal errors (we can keep going, but the data is probably corrupt) */
+#define WARNMS(cinfo,code) \
+ ((cinfo)->err->msg_code = (code), \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
+#define WARNMS1(cinfo,code,p1) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
+#define WARNMS2(cinfo,code,p1,p2) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (cinfo)->err->msg_parm.i[1] = (p2), \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
+
+/* Informational/debugging messages */
+#define TRACEMS(cinfo,lvl,code) \
+ ((cinfo)->err->msg_code = (code), \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
+#define TRACEMS1(cinfo,lvl,code,p1) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
+#define TRACEMS2(cinfo,lvl,code,p1,p2) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (cinfo)->err->msg_parm.i[1] = (p2), \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
+#define TRACEMS3(cinfo,lvl,code,p1,p2,p3) \
+ MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
+ _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \
+ (cinfo)->err->msg_code = (code); \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
+#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4) \
+ MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
+ _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
+ (cinfo)->err->msg_code = (code); \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
+#define TRACEMS5(cinfo,lvl,code,p1,p2,p3,p4,p5) \
+ MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
+ _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
+ _mp[4] = (p5); \
+ (cinfo)->err->msg_code = (code); \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
+#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8) \
+ MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
+ _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
+ _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \
+ (cinfo)->err->msg_code = (code); \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
+#define TRACEMSS(cinfo,lvl,code,str) \
+ ((cinfo)->err->msg_code = (code), \
+ strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
+ (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
+
+#endif /* JERROR_H */
--- /dev/null
+/*
+ * jmorecfg.h
+ *
+ * Copyright (C) 1991-1997, Thomas G. Lane.
+ * Modified 1997-2009 by Guido Vollbeding.
+ * This file is part of the Independent JPEG Group's software.
+ * For conditions of distribution and use, see the accompanying README file.
+ *
+ * This file contains additional configuration options that customize the
+ * JPEG software for special applications or support machine-dependent
+ * optimizations. Most users will not need to touch this file.
+ */
+
+
+/*
+ * Define BITS_IN_JSAMPLE as either
+ * 8 for 8-bit sample values (the usual setting)
+ * 12 for 12-bit sample values
+ * Only 8 and 12 are legal data precisions for lossy JPEG according to the
+ * JPEG standard, and the IJG code does not support anything else!
+ * We do not support run-time selection of data precision, sorry.
+ */
+
+#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
+
+
+/*
+ * Maximum number of components (color channels) allowed in JPEG image.
+ * To meet the letter of the JPEG spec, set this to 255. However, darn
+ * few applications need more than 4 channels (maybe 5 for CMYK + alpha
+ * mask). We recommend 10 as a reasonable compromise; use 4 if you are
+ * really short on memory. (Each allowed component costs a hundred or so
+ * bytes of storage, whether actually used in an image or not.)
+ */
+
+#define MAX_COMPONENTS 10 /* maximum number of image components */
+
+
+/*
+ * Basic data types.
+ * You may need to change these if you have a machine with unusual data
+ * type sizes; for example, "char" not 8 bits, "short" not 16 bits,
+ * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits,
+ * but it had better be at least 16.
+ */
+
+/* Representation of a single sample (pixel element value).
+ * We frequently allocate large arrays of these, so it's important to keep
+ * them small. But if you have memory to burn and access to char or short
+ * arrays is very slow on your hardware, you might want to change these.
+ */
+
+#if BITS_IN_JSAMPLE == 8
+/* JSAMPLE should be the smallest type that will hold the values 0..255.
+ * You can use a signed char by having GETJSAMPLE mask it with 0xFF.
+ */
+
+#ifdef HAVE_UNSIGNED_CHAR
+
+typedef unsigned char JSAMPLE;
+#define GETJSAMPLE(value) ((int) (value))
+
+#else /* not HAVE_UNSIGNED_CHAR */
+
+typedef char JSAMPLE;
+#ifdef CHAR_IS_UNSIGNED
+#define GETJSAMPLE(value) ((int) (value))
+#else
+#define GETJSAMPLE(value) ((int) (value) & 0xFF)
+#endif /* CHAR_IS_UNSIGNED */
+
+#endif /* HAVE_UNSIGNED_CHAR */
+
+#define MAXJSAMPLE 255
+#define CENTERJSAMPLE 128
+
+#endif /* BITS_IN_JSAMPLE == 8 */
+
+
+#if BITS_IN_JSAMPLE == 12
+/* JSAMPLE should be the smallest type that will hold the values 0..4095.
+ * On nearly all machines "short" will do nicely.
+ */
+
+typedef short JSAMPLE;
+#define GETJSAMPLE(value) ((int) (value))
+
+#define MAXJSAMPLE 4095
+#define CENTERJSAMPLE 2048
+
+#endif /* BITS_IN_JSAMPLE == 12 */
+
+
+/* Representation of a DCT frequency coefficient.
+ * This should be a signed value of at least 16 bits; "short" is usually OK.
+ * Again, we allocate large arrays of these, but you can change to int
+ * if you have memory to burn and "short" is really slow.
+ */
+
+typedef short JCOEF;
+
+
+/* Compressed datastreams are represented as arrays of JOCTET.
+ * These must be EXACTLY 8 bits wide, at least once they are written to
+ * external storage. Note that when using the stdio data source/destination
+ * managers, this is also the data type passed to fread/fwrite.
+ */
+
+#ifdef HAVE_UNSIGNED_CHAR
+
+typedef unsigned char JOCTET;
+#define GETJOCTET(value) (value)
+
+#else /* not HAVE_UNSIGNED_CHAR */
+
+typedef char JOCTET;
+#ifdef CHAR_IS_UNSIGNED
+#define GETJOCTET(value) (value)
+#else
+#define GETJOCTET(value) ((value) & 0xFF)
+#endif /* CHAR_IS_UNSIGNED */
+
+#endif /* HAVE_UNSIGNED_CHAR */
+
+
+/* These typedefs are used for various table entries and so forth.
+ * They must be at least as wide as specified; but making them too big
+ * won't cost a huge amount of memory, so we don't provide special
+ * extraction code like we did for JSAMPLE. (In other words, these
+ * typedefs live at a different point on the speed/space tradeoff curve.)
+ */
+
+/* UINT8 must hold at least the values 0..255. */
+
+#ifdef HAVE_UNSIGNED_CHAR
+typedef unsigned char UINT8;
+#else /* not HAVE_UNSIGNED_CHAR */
+#ifdef CHAR_IS_UNSIGNED
+typedef char UINT8;
+#else /* not CHAR_IS_UNSIGNED */
+typedef short UINT8;
+#endif /* CHAR_IS_UNSIGNED */
+#endif /* HAVE_UNSIGNED_CHAR */
+
+/* UINT16 must hold at least the values 0..65535. */
+
+#ifdef HAVE_UNSIGNED_SHORT
+typedef unsigned short UINT16;
+#else /* not HAVE_UNSIGNED_SHORT */
+typedef unsigned int UINT16;
+#endif /* HAVE_UNSIGNED_SHORT */
+
+/* INT16 must hold at least the values -32768..32767. */
+
+#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */
+typedef short INT16;
+#endif
+
+/* INT32 must hold at least signed 32-bit values. */
+
+#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */
+#ifndef _BASETSD_H_ /* Microsoft defines it in basetsd.h */
+#ifndef _BASETSD_H /* MinGW is slightly different */
+#ifndef QGLOBAL_H /* Qt defines it in qglobal.h */
+typedef long INT32;
+#endif
+#endif
+#endif
+#endif
+
+/* Datatype used for image dimensions. The JPEG standard only supports
+ * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
+ * "unsigned int" is sufficient on all machines. However, if you need to
+ * handle larger images and you don't mind deviating from the spec, you
+ * can change this datatype.
+ */
+
+typedef unsigned int JDIMENSION;
+
+#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */
+
+
+/* These macros are used in all function definitions and extern declarations.
+ * You could modify them if you need to change function linkage conventions;
+ * in particular, you'll need to do that to make the library a Windows DLL.
+ * Another application is to make all functions global for use with debuggers
+ * or code profilers that require it.
+ */
+
+/* a function called through method pointers: */
+#define METHODDEF(type) static type
+/* a function used only in its module: */
+#define LOCAL(type) static type
+/* a function referenced thru EXTERNs: */
+#define GLOBAL(type) type
+/* a reference to a GLOBAL function: */
+#define EXTERN(type) extern type
+
+
+/* This macro is used to declare a "method", that is, a function pointer.
+ * We want to supply prototype parameters if the compiler can cope.
+ * Note that the arglist parameter must be parenthesized!
+ * Again, you can customize this if you need special linkage keywords.
+ */
+
+#ifdef HAVE_PROTOTYPES
+#define JMETHOD(type,methodname,arglist) type (*methodname) arglist
+#else
+#define JMETHOD(type,methodname,arglist) type (*methodname) ()
+#endif
+
+
+/* Here is the pseudo-keyword for declaring pointers that must be "far"
+ * on 80x86 machines. Most of the specialized coding for 80x86 is handled
+ * by just saying "FAR *" where such a pointer is needed. In a few places
+ * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol.
+ */
+
+#ifndef FAR
+#ifdef NEED_FAR_POINTERS
+#define FAR far
+#else
+#define FAR
+#endif
+#endif
+
+
+/*
+ * On a few systems, type boolean and/or its values FALSE, TRUE may appear
+ * in standard header files. Or you may have conflicts with application-
+ * specific header files that you want to include together with these files.
+ * Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
+ */
+
+#ifndef HAVE_BOOLEAN
+typedef int boolean;
+#endif
+#ifndef FALSE /* in case these macros already exist */
+#define FALSE 0 /* values of boolean */
+#endif
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+
+/*
+ * The remaining options affect code selection within the JPEG library,
+ * but they don't need to be visible to most applications using the library.
+ * To minimize application namespace pollution, the symbols won't be
+ * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.
+ */
+
+#ifdef JPEG_INTERNALS
+#define JPEG_INTERNAL_OPTIONS
+#endif
+
+#ifdef JPEG_INTERNAL_OPTIONS
+
+
+/*
+ * These defines indicate whether to include various optional functions.
+ * Undefining some of these symbols will produce a smaller but less capable
+ * library. Note that you can leave certain source files out of the
+ * compilation/linking process if you've #undef'd the corresponding symbols.
+ * (You may HAVE to do that if your compiler doesn't like null source files.)
+ */
+
+/* Capability options common to encoder and decoder: */
+
+#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */
+#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */
+#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */
+
+/* Encoder capability options: */
+
+#define C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
+#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
+#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
+#define DCT_SCALING_SUPPORTED /* Input rescaling via DCT? (Requires DCT_ISLOW)*/
+#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
+/* Note: if you selected 12-bit data precision, it is dangerous to turn off
+ * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit
+ * precision, so jchuff.c normally uses entropy optimization to compute
+ * usable tables for higher precision. If you don't want to do optimization,
+ * you'll have to supply different default Huffman tables.
+ * The exact same statements apply for progressive JPEG: the default tables
+ * don't work for progressive mode. (This may get fixed, however.)
+ */
+#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */
+
+/* Decoder capability options: */
+
+#define D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
+#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
+#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
+#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */
+#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
+#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
+#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
+#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */
+#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */
+#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */
+
+/* more capability options later, no doubt */
+
+
+/*
+ * Ordering of RGB data in scanlines passed to or from the application.
+ * If your application wants to deal with data in the order B,G,R, just
+ * change these macros. You can also deal with formats such as R,G,B,X
+ * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing
+ * the offsets will also change the order in which colormap data is organized.
+ * RESTRICTIONS:
+ * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.
+ * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not
+ * useful if you are using JPEG color spaces other than YCbCr or grayscale.
+ * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
+ * is not 3 (they don't understand about dummy color components!). So you
+ * can't use color quantization if you change that value.
+ */
+
+#define RGB_RED 0 /* Offset of Red in an RGB scanline element */
+#define RGB_GREEN 1 /* Offset of Green */
+#define RGB_BLUE 2 /* Offset of Blue */
+#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
+
+
+/* Definitions for speed-related optimizations. */
+
+
+/* If your compiler supports inline functions, define INLINE
+ * as the inline keyword; otherwise define it as empty.
+ */
+
+#ifndef INLINE
+#ifdef __GNUC__ /* for instance, GNU C knows about inline */
+#define INLINE __inline__
+#endif
+#ifndef INLINE
+#define INLINE /* default is to define it as empty */
+#endif
+#endif
+
+
+/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying
+ * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER
+ * as short on such a machine. MULTIPLIER must be at least 16 bits wide.
+ */
+
+#ifndef MULTIPLIER
+#define MULTIPLIER int /* type for fastest integer multiply */
+#endif
+
+
+/* FAST_FLOAT should be either float or double, whichever is done faster
+ * by your compiler. (Note that this type is only used in the floating point
+ * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)
+ * Typically, float is faster in ANSI C compilers, while double is faster in
+ * pre-ANSI compilers (because they insist on converting to double anyway).
+ * The code below therefore chooses float if we have ANSI-style prototypes.
+ */
+
+#ifndef FAST_FLOAT
+#ifdef HAVE_PROTOTYPES
+#define FAST_FLOAT float
+#else
+#define FAST_FLOAT double
+#endif
+#endif
+
+#endif /* JPEG_INTERNAL_OPTIONS */
--- /dev/null
+/*
+ * jpeglib.h
+ *
+ * Copyright (C) 1991-1998, Thomas G. Lane.
+ * Modified 2002-2009 by Guido Vollbeding.
+ * This file is part of the Independent JPEG Group's software.
+ * For conditions of distribution and use, see the accompanying README file.
+ *
+ * This file defines the application interface for the JPEG library.
+ * Most applications using the library need only include this file,
+ * and perhaps jerror.h if they want to know the exact error codes.
+ */
+
+#ifndef JPEGLIB_H
+#define JPEGLIB_H
+
+/*
+ * First we include the configuration files that record how this
+ * installation of the JPEG library is set up. jconfig.h can be
+ * generated automatically for many systems. jmorecfg.h contains
+ * manual configuration options that most people need not worry about.
+ */
+
+#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */
+#include "jconfig.h" /* widely used configuration options */
+#endif
+#include "jmorecfg.h" /* seldom changed options */
+
+
+#ifdef __cplusplus
+#ifndef DONT_USE_EXTERN_C
+extern "C" {
+#endif
+#endif
+
+/* Version ID for the JPEG library.
+ * Might be useful for tests like "#if JPEG_LIB_VERSION >= 80".
+ */
+
+#define JPEG_LIB_VERSION 80 /* Version 8.0 */
+
+
+/* Various constants determining the sizes of things.
+ * All of these are specified by the JPEG standard, so don't change them
+ * if you want to be compatible.
+ */
+
+#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */
+#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */
+#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */
+#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */
+#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */
+#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */
+#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */
+/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard;
+ * the PostScript DCT filter can emit files with many more than 10 blocks/MCU.
+ * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU
+ * to handle it. We even let you do this from the jconfig.h file. However,
+ * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe
+ * sometimes emits noncompliant files doesn't mean you should too.
+ */
+#define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */
+#ifndef D_MAX_BLOCKS_IN_MCU
+#define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */
+#endif
+
+
+/* Data structures for images (arrays of samples and of DCT coefficients).
+ * On 80x86 machines, the image arrays are too big for near pointers,
+ * but the pointer arrays can fit in near memory.
+ */
+
+typedef JSAMPLE FAR *JSAMPROW; /* ptr to one image row of pixel samples. */
+typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */
+typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */
+
+typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */
+typedef JBLOCK FAR *JBLOCKROW; /* pointer to one row of coefficient blocks */
+typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */
+typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */
+
+typedef JCOEF FAR *JCOEFPTR; /* useful in a couple of places */
+
+
+/* Types for JPEG compression parameters and working tables. */
+
+
+/* DCT coefficient quantization tables. */
+
+typedef struct {
+ /* This array gives the coefficient quantizers in natural array order
+ * (not the zigzag order in which they are stored in a JPEG DQT marker).
+ * CAUTION: IJG versions prior to v6a kept this array in zigzag order.
+ */
+ UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */
+ /* This field is used only during compression. It's initialized FALSE when
+ * the table is created, and set TRUE when it's been output to the file.
+ * You could suppress output of a table by setting this to TRUE.
+ * (See jpeg_suppress_tables for an example.)
+ */
+ boolean sent_table; /* TRUE when table has been output */
+} JQUANT_TBL;
+
+
+/* Huffman coding tables. */
+
+typedef struct {
+ /* These two fields directly represent the contents of a JPEG DHT marker */
+ UINT8 bits[17]; /* bits[k] = # of symbols with codes of */
+ /* length k bits; bits[0] is unused */
+ UINT8 huffval[256]; /* The symbols, in order of incr code length */
+ /* This field is used only during compression. It's initialized FALSE when
+ * the table is created, and set TRUE when it's been output to the file.
+ * You could suppress output of a table by setting this to TRUE.
+ * (See jpeg_suppress_tables for an example.)
+ */
+ boolean sent_table; /* TRUE when table has been output */
+} JHUFF_TBL;
+
+
+/* Basic info about one component (color channel). */
+
+typedef struct {
+ /* These values are fixed over the whole image. */
+ /* For compression, they must be supplied by parameter setup; */
+ /* for decompression, they are read from the SOF marker. */
+ int component_id; /* identifier for this component (0..255) */
+ int component_index; /* its index in SOF or cinfo->comp_info[] */
+ int h_samp_factor; /* horizontal sampling factor (1..4) */
+ int v_samp_factor; /* vertical sampling factor (1..4) */
+ int quant_tbl_no; /* quantization table selector (0..3) */
+ /* These values may vary between scans. */
+ /* For compression, they must be supplied by parameter setup; */
+ /* for decompression, they are read from the SOS marker. */
+ /* The decompressor output side may not use these variables. */
+ int dc_tbl_no; /* DC entropy table selector (0..3) */
+ int ac_tbl_no; /* AC entropy table selector (0..3) */
+
+ /* Remaining fields should be treated as private by applications. */
+
+ /* These values are computed during compression or decompression startup: */
+ /* Component's size in DCT blocks.
+ * Any dummy blocks added to complete an MCU are not counted; therefore
+ * these values do not depend on whether a scan is interleaved or not.
+ */
+ JDIMENSION width_in_blocks;
+ JDIMENSION height_in_blocks;
+ /* Size of a DCT block in samples,
+ * reflecting any scaling we choose to apply during the DCT step.
+ * Values from 1 to 16 are supported.
+ * Note that different components may receive different DCT scalings.
+ */
+ int DCT_h_scaled_size;
+ int DCT_v_scaled_size;
+ /* The downsampled dimensions are the component's actual, unpadded number
+ * of samples at the main buffer (preprocessing/compression interface);
+ * DCT scaling is included, so
+ * downsampled_width = ceil(image_width * Hi/Hmax * DCT_h_scaled_size/DCTSIZE)
+ * and similarly for height.
+ */
+ JDIMENSION downsampled_width; /* actual width in samples */
+ JDIMENSION downsampled_height; /* actual height in samples */
+ /* This flag is used only for decompression. In cases where some of the
+ * components will be ignored (eg grayscale output from YCbCr image),
+ * we can skip most computations for the unused components.
+ */
+ boolean component_needed; /* do we need the value of this component? */
+
+ /* These values are computed before starting a scan of the component. */
+ /* The decompressor output side may not use these variables. */
+ int MCU_width; /* number of blocks per MCU, horizontally */
+ int MCU_height; /* number of blocks per MCU, vertically */
+ int MCU_blocks; /* MCU_width * MCU_height */
+ int MCU_sample_width; /* MCU width in samples: MCU_width * DCT_h_scaled_size */
+ int last_col_width; /* # of non-dummy blocks across in last MCU */
+ int last_row_height; /* # of non-dummy blocks down in last MCU */
+
+ /* Saved quantization table for component; NULL if none yet saved.
+ * See jdinput.c comments about the need for this information.
+ * This field is currently used only for decompression.
+ */
+ JQUANT_TBL * quant_table;
+
+ /* Private per-component storage for DCT or IDCT subsystem. */
+ void * dct_table;
+} jpeg_component_info;
+
+
+/* The script for encoding a multiple-scan file is an array of these: */
+
+typedef struct {
+ int comps_in_scan; /* number of components encoded in this scan */
+ int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */
+ int Ss, Se; /* progressive JPEG spectral selection parms */
+ int Ah, Al; /* progressive JPEG successive approx. parms */
+} jpeg_scan_info;
+
+/* The decompressor can save APPn and COM markers in a list of these: */
+
+typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr;
+
+struct jpeg_marker_struct {
+ jpeg_saved_marker_ptr next; /* next in list, or NULL */
+ UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */
+ unsigned int original_length; /* # bytes of data in the file */
+ unsigned int data_length; /* # bytes of data saved at data[] */
+ JOCTET FAR * data; /* the data contained in the marker */
+ /* the marker length word is not counted in data_length or original_length */
+};
+
+/* Known color spaces. */
+
+typedef enum {
+ JCS_UNKNOWN, /* error/unspecified */
+ JCS_GRAYSCALE, /* monochrome */
+ JCS_RGB, /* red/green/blue */
+ JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */
+ JCS_CMYK, /* C/M/Y/K */
+ JCS_YCCK /* Y/Cb/Cr/K */
+} J_COLOR_SPACE;
+
+/* DCT/IDCT algorithm options. */
+
+typedef enum {
+ JDCT_ISLOW, /* slow but accurate integer algorithm */
+ JDCT_IFAST, /* faster, less accurate integer method */
+ JDCT_FLOAT /* floating-point: accurate, fast on fast HW */
+} J_DCT_METHOD;
+
+#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */
+#define JDCT_DEFAULT JDCT_ISLOW
+#endif
+#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */
+#define JDCT_FASTEST JDCT_IFAST
+#endif
+
+/* Dithering options for decompression. */
+
+typedef enum {
+ JDITHER_NONE, /* no dithering */
+ JDITHER_ORDERED, /* simple ordered dither */
+ JDITHER_FS /* Floyd-Steinberg error diffusion dither */
+} J_DITHER_MODE;
+
+
+/* Common fields between JPEG compression and decompression master structs. */
+
+#define jpeg_common_fields \
+ struct jpeg_error_mgr * err; /* Error handler module */\
+ struct jpeg_memory_mgr * mem; /* Memory manager module */\
+ struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\
+ void * client_data; /* Available for use by application */\
+ boolean is_decompressor; /* So common code can tell which is which */\
+ int global_state /* For checking call sequence validity */
+
+/* Routines that are to be used by both halves of the library are declared
+ * to receive a pointer to this structure. There are no actual instances of
+ * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct.
+ */
+struct jpeg_common_struct {
+ jpeg_common_fields; /* Fields common to both master struct types */
+ /* Additional fields follow in an actual jpeg_compress_struct or
+ * jpeg_decompress_struct. All three structs must agree on these
+ * initial fields! (This would be a lot cleaner in C++.)
+ */
+};
+
+typedef struct jpeg_common_struct * j_common_ptr;
+typedef struct jpeg_compress_struct * j_compress_ptr;
+typedef struct jpeg_decompress_struct * j_decompress_ptr;
+
+
+/* Master record for a compression instance */
+
+struct jpeg_compress_struct {
+ jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */
+
+ /* Destination for compressed data */
+ struct jpeg_destination_mgr * dest;
+
+ /* Description of source image --- these fields must be filled in by
+ * outer application before starting compression. in_color_space must
+ * be correct before you can even call jpeg_set_defaults().
+ */
+
+ JDIMENSION image_width; /* input image width */
+ JDIMENSION image_height; /* input image height */
+ int input_components; /* # of color components in input image */
+ J_COLOR_SPACE in_color_space; /* colorspace of input image */
+
+ double input_gamma; /* image gamma of input image */
+
+ /* Compression parameters --- these fields must be set before calling
+ * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to
+ * initialize everything to reasonable defaults, then changing anything
+ * the application specifically wants to change. That way you won't get
+ * burnt when new parameters are added. Also note that there are several
+ * helper routines to simplify changing parameters.
+ */
+
+ unsigned int scale_num, scale_denom; /* fraction by which to scale image */
+
+ JDIMENSION jpeg_width; /* scaled JPEG image width */
+ JDIMENSION jpeg_height; /* scaled JPEG image height */
+ /* Dimensions of actual JPEG image that will be written to file,
+ * derived from input dimensions by scaling factors above.
+ * These fields are computed by jpeg_start_compress().
+ * You can also use jpeg_calc_jpeg_dimensions() to determine these values
+ * in advance of calling jpeg_start_compress().
+ */
+
+ int data_precision; /* bits of precision in image data */
+
+ int num_components; /* # of color components in JPEG image */
+ J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */
+
+ jpeg_component_info * comp_info;
+ /* comp_info[i] describes component that appears i'th in SOF */
+
+ JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS];
+ int q_scale_factor[NUM_QUANT_TBLS];
+ /* ptrs to coefficient quantization tables, or NULL if not defined,
+ * and corresponding scale factors (percentage, initialized 100).
+ */
+
+ JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
+ JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
+ /* ptrs to Huffman coding tables, or NULL if not defined */
+
+ UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
+ UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
+ UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
+
+ int num_scans; /* # of entries in scan_info array */
+ const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */
+ /* The default value of scan_info is NULL, which causes a single-scan
+ * sequential JPEG file to be emitted. To create a multi-scan file,
+ * set num_scans and scan_info to point to an array of scan definitions.
+ */
+
+ boolean raw_data_in; /* TRUE=caller supplies downsampled data */
+ boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
+ boolean optimize_coding; /* TRUE=optimize entropy encoding parms */
+ boolean CCIR601_sampling; /* TRUE=first samples are cosited */
+ boolean do_fancy_downsampling; /* TRUE=apply fancy downsampling */
+ int smoothing_factor; /* 1..100, or 0 for no input smoothing */
+ J_DCT_METHOD dct_method; /* DCT algorithm selector */
+
+ /* The restart interval can be specified in absolute MCUs by setting
+ * restart_interval, or in MCU rows by setting restart_in_rows
+ * (in which case the correct restart_interval will be figured
+ * for each scan).
+ */
+ unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */
+ int restart_in_rows; /* if > 0, MCU rows per restart interval */
+
+ /* Parameters controlling emission of special markers. */
+
+ boolean write_JFIF_header; /* should a JFIF marker be written? */
+ UINT8 JFIF_major_version; /* What to write for the JFIF version number */
+ UINT8 JFIF_minor_version;
+ /* These three values are not used by the JPEG code, merely copied */
+ /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */
+ /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */
+ /* ratio is defined by X_density/Y_density even when density_unit=0. */
+ UINT8 density_unit; /* JFIF code for pixel size units */
+ UINT16 X_density; /* Horizontal pixel density */
+ UINT16 Y_density; /* Vertical pixel density */
+ boolean write_Adobe_marker; /* should an Adobe marker be written? */
+
+ /* State variable: index of next scanline to be written to
+ * jpeg_write_scanlines(). Application may use this to control its
+ * processing loop, e.g., "while (next_scanline < image_height)".
+ */
+
+ JDIMENSION next_scanline; /* 0 .. image_height-1 */
+
+ /* Remaining fields are known throughout compressor, but generally
+ * should not be touched by a surrounding application.
+ */
+
+ /*
+ * These fields are computed during compression startup
+ */
+ boolean progressive_mode; /* TRUE if scan script uses progressive mode */
+ int max_h_samp_factor; /* largest h_samp_factor */
+ int max_v_samp_factor; /* largest v_samp_factor */
+
+ int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
+ int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
+
+ JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */
+ /* The coefficient controller receives data in units of MCU rows as defined
+ * for fully interleaved scans (whether the JPEG file is interleaved or not).
+ * There are v_samp_factor * DCTSIZE sample rows of each component in an
+ * "iMCU" (interleaved MCU) row.
+ */
+
+ /*
+ * These fields are valid during any one scan.
+ * They describe the components and MCUs actually appearing in the scan.
+ */
+ int comps_in_scan; /* # of JPEG components in this scan */
+ jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
+ /* *cur_comp_info[i] describes component that appears i'th in SOS */
+
+ JDIMENSION MCUs_per_row; /* # of MCUs across the image */
+ JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */
+
+ int blocks_in_MCU; /* # of DCT blocks per MCU */
+ int MCU_membership[C_MAX_BLOCKS_IN_MCU];
+ /* MCU_membership[i] is index in cur_comp_info of component owning */
+ /* i'th block in an MCU */
+
+ int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
+
+ int block_size; /* the basic DCT block size: 1..16 */
+ const int * natural_order; /* natural-order position array */
+ int lim_Se; /* min( Se, DCTSIZE2-1 ) */
+
+ /*
+ * Links to compression subobjects (methods and private variables of modules)
+ */
+ struct jpeg_comp_master * master;
+ struct jpeg_c_main_controller * main;
+ struct jpeg_c_prep_controller * prep;
+ struct jpeg_c_coef_controller * coef;
+ struct jpeg_marker_writer * marker;
+ struct jpeg_color_converter * cconvert;
+ struct jpeg_downsampler * downsample;
+ struct jpeg_forward_dct * fdct;
+ struct jpeg_entropy_encoder * entropy;
+ jpeg_scan_info * script_space; /* workspace for jpeg_simple_progression */
+ int script_space_size;
+};
+
+
+/* Master record for a decompression instance */
+
+struct jpeg_decompress_struct {
+ jpeg_common_fields; /* Fields shared with jpeg_compress_struct */
+
+ /* Source of compressed data */
+ struct jpeg_source_mgr * src;
+
+ /* Basic description of image --- filled in by jpeg_read_header(). */
+ /* Application may inspect these values to decide how to process image. */
+
+ JDIMENSION image_width; /* nominal image width (from SOF marker) */
+ JDIMENSION image_height; /* nominal image height */
+ int num_components; /* # of color components in JPEG image */
+ J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */
+
+ /* Decompression processing parameters --- these fields must be set before
+ * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes
+ * them to default values.
+ */
+
+ J_COLOR_SPACE out_color_space; /* colorspace for output */
+
+ unsigned int scale_num, scale_denom; /* fraction by which to scale image */
+
+ double output_gamma; /* image gamma wanted in output */
+
+ boolean buffered_image; /* TRUE=multiple output passes */
+ boolean raw_data_out; /* TRUE=downsampled data wanted */
+
+ J_DCT_METHOD dct_method; /* IDCT algorithm selector */
+ boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */
+ boolean do_block_smoothing; /* TRUE=apply interblock smoothing */
+
+ boolean quantize_colors; /* TRUE=colormapped output wanted */
+ /* the following are ignored if not quantize_colors: */
+ J_DITHER_MODE dither_mode; /* type of color dithering to use */
+ boolean two_pass_quantize; /* TRUE=use two-pass color quantization */
+ int desired_number_of_colors; /* max # colors to use in created colormap */
+ /* these are significant only in buffered-image mode: */
+ boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */
+ boolean enable_external_quant;/* enable future use of external colormap */
+ boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */
+
+ /* Description of actual output image that will be returned to application.
+ * These fields are computed by jpeg_start_decompress().
+ * You can also use jpeg_calc_output_dimensions() to determine these values
+ * in advance of calling jpeg_start_decompress().
+ */
+
+ JDIMENSION output_width; /* scaled image width */
+ JDIMENSION output_height; /* scaled image height */
+ int out_color_components; /* # of color components in out_color_space */
+ int output_components; /* # of color components returned */
+ /* output_components is 1 (a colormap index) when quantizing colors;
+ * otherwise it equals out_color_components.
+ */
+ int rec_outbuf_height; /* min recommended height of scanline buffer */
+ /* If the buffer passed to jpeg_read_scanlines() is less than this many rows
+ * high, space and time will be wasted due to unnecessary data copying.
+ * Usually rec_outbuf_height will be 1 or 2, at most 4.
+ */
+
+ /* When quantizing colors, the output colormap is described by these fields.
+ * The application can supply a colormap by setting colormap non-NULL before
+ * calling jpeg_start_decompress; otherwise a colormap is created during
+ * jpeg_start_decompress or jpeg_start_output.
+ * The map has out_color_components rows and actual_number_of_colors columns.
+ */
+ int actual_number_of_colors; /* number of entries in use */
+ JSAMPARRAY colormap; /* The color map as a 2-D pixel array */
+
+ /* State variables: these variables indicate the progress of decompression.
+ * The application may examine these but must not modify them.
+ */
+
+ /* Row index of next scanline to be read from jpeg_read_scanlines().
+ * Application may use this to control its processing loop, e.g.,
+ * "while (output_scanline < output_height)".
+ */
+ JDIMENSION output_scanline; /* 0 .. output_height-1 */
+
+ /* Current input scan number and number of iMCU rows completed in scan.
+ * These indicate the progress of the decompressor input side.
+ */
+ int input_scan_number; /* Number of SOS markers seen so far */
+ JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */
+
+ /* The "output scan number" is the notional scan being displayed by the
+ * output side. The decompressor will not allow output scan/row number
+ * to get ahead of input scan/row, but it can fall arbitrarily far behind.
+ */
+ int output_scan_number; /* Nominal scan number being displayed */
+ JDIMENSION output_iMCU_row; /* Number of iMCU rows read */
+
+ /* Current progression status. coef_bits[c][i] indicates the precision
+ * with which component c's DCT coefficient i (in zigzag order) is known.
+ * It is -1 when no data has yet been received, otherwise it is the point
+ * transform (shift) value for the most recent scan of the coefficient
+ * (thus, 0 at completion of the progression).
+ * This pointer is NULL when reading a non-progressive file.
+ */
+ int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */
+
+ /* Internal JPEG parameters --- the application usually need not look at
+ * these fields. Note that the decompressor output side may not use
+ * any parameters that can change between scans.
+ */
+
+ /* Quantization and Huffman tables are carried forward across input
+ * datastreams when processing abbreviated JPEG datastreams.
+ */
+
+ JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS];
+ /* ptrs to coefficient quantization tables, or NULL if not defined */
+
+ JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
+ JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
+ /* ptrs to Huffman coding tables, or NULL if not defined */
+
+ /* These parameters are never carried across datastreams, since they
+ * are given in SOF/SOS markers or defined to be reset by SOI.
+ */
+
+ int data_precision; /* bits of precision in image data */
+
+ jpeg_component_info * comp_info;
+ /* comp_info[i] describes component that appears i'th in SOF */
+
+ boolean is_baseline; /* TRUE if Baseline SOF0 encountered */
+ boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */
+ boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
+
+ UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
+ UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
+ UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
+
+ unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */
+
+ /* These fields record data obtained from optional markers recognized by
+ * the JPEG library.
+ */
+ boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */
+ /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */
+ UINT8 JFIF_major_version; /* JFIF version number */
+ UINT8 JFIF_minor_version;
+ UINT8 density_unit; /* JFIF code for pixel size units */
+ UINT16 X_density; /* Horizontal pixel density */
+ UINT16 Y_density; /* Vertical pixel density */
+ boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */
+ UINT8 Adobe_transform; /* Color transform code from Adobe marker */
+
+ boolean CCIR601_sampling; /* TRUE=first samples are cosited */
+
+ /* Aside from the specific data retained from APPn markers known to the
+ * library, the uninterpreted contents of any or all APPn and COM markers
+ * can be saved in a list for examination by the application.
+ */
+ jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */
+
+ /* Remaining fields are known throughout decompressor, but generally
+ * should not be touched by a surrounding application.
+ */
+
+ /*
+ * These fields are computed during decompression startup
+ */
+ int max_h_samp_factor; /* largest h_samp_factor */
+ int max_v_samp_factor; /* largest v_samp_factor */
+
+ int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
+ int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
+
+ JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */
+ /* The coefficient controller's input and output progress is measured in
+ * units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows
+ * in fully interleaved JPEG scans, but are used whether the scan is
+ * interleaved or not. We define an iMCU row as v_samp_factor DCT block
+ * rows of each component. Therefore, the IDCT output contains
+ * v_samp_factor*DCT_v_scaled_size sample rows of a component per iMCU row.
+ */
+
+ JSAMPLE * sample_range_limit; /* table for fast range-limiting */
+
+ /*
+ * These fields are valid during any one scan.
+ * They describe the components and MCUs actually appearing in the scan.
+ * Note that the decompressor output side must not use these fields.
+ */
+ int comps_in_scan; /* # of JPEG components in this scan */
+ jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
+ /* *cur_comp_info[i] describes component that appears i'th in SOS */
+
+ JDIMENSION MCUs_per_row; /* # of MCUs across the image */
+ JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */
+
+ int blocks_in_MCU; /* # of DCT blocks per MCU */
+ int MCU_membership[D_MAX_BLOCKS_IN_MCU];
+ /* MCU_membership[i] is index in cur_comp_info of component owning */
+ /* i'th block in an MCU */
+
+ int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
+
+ /* These fields are derived from Se of first SOS marker.
+ */
+ int block_size; /* the basic DCT block size: 1..16 */
+ const int * natural_order; /* natural-order position array for entropy decode */
+ int lim_Se; /* min( Se, DCTSIZE2-1 ) for entropy decode */
+
+ /* This field is shared between entropy decoder and marker parser.
+ * It is either zero or the code of a JPEG marker that has been
+ * read from the data source, but has not yet been processed.
+ */
+ int unread_marker;
+
+ /*
+ * Links to decompression subobjects (methods, private variables of modules)
+ */
+ struct jpeg_decomp_master * master;
+ struct jpeg_d_main_controller * main;
+ struct jpeg_d_coef_controller * coef;
+ struct jpeg_d_post_controller * post;
+ struct jpeg_input_controller * inputctl;
+ struct jpeg_marker_reader * marker;
+ struct jpeg_entropy_decoder * entropy;
+ struct jpeg_inverse_dct * idct;
+ struct jpeg_upsampler * upsample;
+ struct jpeg_color_deconverter * cconvert;
+ struct jpeg_color_quantizer * cquantize;
+};
+
+
+/* "Object" declarations for JPEG modules that may be supplied or called
+ * directly by the surrounding application.
+ * As with all objects in the JPEG library, these structs only define the
+ * publicly visible methods and state variables of a module. Additional
+ * private fields may exist after the public ones.
+ */
+
+
+/* Error handler object */
+
+struct jpeg_error_mgr {
+ /* Error exit handler: does not return to caller */
+ JMETHOD(void, error_exit, (j_common_ptr cinfo));
+ /* Conditionally emit a trace or warning message */
+ JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level));
+ /* Routine that actually outputs a trace or error message */
+ JMETHOD(void, output_message, (j_common_ptr cinfo));
+ /* Format a message string for the most recent JPEG error or message */
+ JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer));
+#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */
+ /* Reset error state variables at start of a new image */
+ JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo));
+
+ /* The message ID code and any parameters are saved here.
+ * A message can have one string parameter or up to 8 int parameters.
+ */
+ int msg_code;
+#define JMSG_STR_PARM_MAX 80
+ union {
+ int i[8];
+ char s[JMSG_STR_PARM_MAX];
+ } msg_parm;
+
+ /* Standard state variables for error facility */
+
+ int trace_level; /* max msg_level that will be displayed */
+
+ /* For recoverable corrupt-data errors, we emit a warning message,
+ * but keep going unless emit_message chooses to abort. emit_message
+ * should count warnings in num_warnings. The surrounding application
+ * can check for bad data by seeing if num_warnings is nonzero at the
+ * end of processing.
+ */
+ long num_warnings; /* number of corrupt-data warnings */
+
+ /* These fields point to the table(s) of error message strings.
+ * An application can change the table pointer to switch to a different
+ * message list (typically, to change the language in which errors are
+ * reported). Some applications may wish to add additional error codes
+ * that will be handled by the JPEG library error mechanism; the second
+ * table pointer is used for this purpose.
+ *
+ * First table includes all errors generated by JPEG library itself.
+ * Error code 0 is reserved for a "no such error string" message.
+ */
+ const char * const * jpeg_message_table; /* Library errors */
+ int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */
+ /* Second table can be added by application (see cjpeg/djpeg for example).
+ * It contains strings numbered first_addon_message..last_addon_message.
+ */
+ const char * const * addon_message_table; /* Non-library errors */
+ int first_addon_message; /* code for first string in addon table */
+ int last_addon_message; /* code for last string in addon table */
+};
+
+
+/* Progress monitor object */
+
+struct jpeg_progress_mgr {
+ JMETHOD(void, progress_monitor, (j_common_ptr cinfo));
+
+ long pass_counter; /* work units completed in this pass */
+ long pass_limit; /* total number of work units in this pass */
+ int completed_passes; /* passes completed so far */
+ int total_passes; /* total number of passes expected */
+};
+
+
+/* Data destination object for compression */
+
+struct jpeg_destination_mgr {
+ JOCTET * next_output_byte; /* => next byte to write in buffer */
+ size_t free_in_buffer; /* # of byte spaces remaining in buffer */
+
+ JMETHOD(void, init_destination, (j_compress_ptr cinfo));
+ JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo));
+ JMETHOD(void, term_destination, (j_compress_ptr cinfo));
+};
+
+
+/* Data source object for decompression */
+
+struct jpeg_source_mgr {
+ const JOCTET * next_input_byte; /* => next byte to read from buffer */
+ size_t bytes_in_buffer; /* # of bytes remaining in buffer */
+
+ JMETHOD(void, init_source, (j_decompress_ptr cinfo));
+ JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo));
+ JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes));
+ JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired));
+ JMETHOD(void, term_source, (j_decompress_ptr cinfo));
+};
+
+
+/* Memory manager object.
+ * Allocates "small" objects (a few K total), "large" objects (tens of K),
+ * and "really big" objects (virtual arrays with backing store if needed).
+ * The memory manager does not allow individual objects to be freed; rather,
+ * each created object is assigned to a pool, and whole pools can be freed
+ * at once. This is faster and more convenient than remembering exactly what
+ * to free, especially where malloc()/free() are not too speedy.
+ * NB: alloc routines never return NULL. They exit to error_exit if not
+ * successful.
+ */
+
+#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */
+#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */
+#define JPOOL_NUMPOOLS 2
+
+typedef struct jvirt_sarray_control * jvirt_sarray_ptr;
+typedef struct jvirt_barray_control * jvirt_barray_ptr;
+
+
+struct jpeg_memory_mgr {
+ /* Method pointers */
+ JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id,
+ size_t sizeofobject));
+ JMETHOD(void FAR *, alloc_large, (j_common_ptr cinfo, int pool_id,
+ size_t sizeofobject));
+ JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id,
+ JDIMENSION samplesperrow,
+ JDIMENSION numrows));
+ JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id,
+ JDIMENSION blocksperrow,
+ JDIMENSION numrows));
+ JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo,
+ int pool_id,
+ boolean pre_zero,
+ JDIMENSION samplesperrow,
+ JDIMENSION numrows,
+ JDIMENSION maxaccess));
+ JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo,
+ int pool_id,
+ boolean pre_zero,
+ JDIMENSION blocksperrow,
+ JDIMENSION numrows,
+ JDIMENSION maxaccess));
+ JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo));
+ JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo,
+ jvirt_sarray_ptr ptr,
+ JDIMENSION start_row,
+ JDIMENSION num_rows,
+ boolean writable));
+ JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo,
+ jvirt_barray_ptr ptr,
+ JDIMENSION start_row,
+ JDIMENSION num_rows,
+ boolean writable));
+ JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id));
+ JMETHOD(void, self_destruct, (j_common_ptr cinfo));
+
+ /* Limit on memory allocation for this JPEG object. (Note that this is
+ * merely advisory, not a guaranteed maximum; it only affects the space
+ * used for virtual-array buffers.) May be changed by outer application
+ * after creating the JPEG object.
+ */
+ long max_memory_to_use;
+
+ /* Maximum allocation request accepted by alloc_large. */
+ long max_alloc_chunk;
+};
+
+
+/* Routine signature for application-supplied marker processing methods.
+ * Need not pass marker code since it is stored in cinfo->unread_marker.
+ */
+typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo));
+
+
+/* Declarations for routines called by application.
+ * The JPP macro hides prototype parameters from compilers that can't cope.
+ * Note JPP requires double parentheses.
+ */
+
+#ifdef HAVE_PROTOTYPES
+#define JPP(arglist) arglist
+#else
+#define JPP(arglist) ()
+#endif
+
+
+/* Short forms of external names for systems with brain-damaged linkers.
+ * We shorten external names to be unique in the first six letters, which
+ * is good enough for all known systems.
+ * (If your compiler itself needs names to be unique in less than 15
+ * characters, you are out of luck. Get a better compiler.)
+ */
+
+#ifdef NEED_SHORT_EXTERNAL_NAMES
+#define jpeg_std_error jStdError
+#define jpeg_CreateCompress jCreaCompress
+#define jpeg_CreateDecompress jCreaDecompress
+#define jpeg_destroy_compress jDestCompress
+#define jpeg_destroy_decompress jDestDecompress
+#define jpeg_stdio_dest jStdDest
+#define jpeg_stdio_src jStdSrc
+#define jpeg_mem_dest jMemDest
+#define jpeg_mem_src jMemSrc
+#define jpeg_set_defaults jSetDefaults
+#define jpeg_set_colorspace jSetColorspace
+#define jpeg_default_colorspace jDefColorspace
+#define jpeg_set_quality jSetQuality
+#define jpeg_set_linear_quality jSetLQuality
+#define jpeg_default_qtables jDefQTables
+#define jpeg_add_quant_table jAddQuantTable
+#define jpeg_quality_scaling jQualityScaling
+#define jpeg_simple_progression jSimProgress
+#define jpeg_suppress_tables jSuppressTables
+#define jpeg_alloc_quant_table jAlcQTable
+#define jpeg_alloc_huff_table jAlcHTable
+#define jpeg_start_compress jStrtCompress
+#define jpeg_write_scanlines jWrtScanlines
+#define jpeg_finish_compress jFinCompress
+#define jpeg_calc_jpeg_dimensions jCjpegDimensions
+#define jpeg_write_raw_data jWrtRawData
+#define jpeg_write_marker jWrtMarker
+#define jpeg_write_m_header jWrtMHeader
+#define jpeg_write_m_byte jWrtMByte
+#define jpeg_write_tables jWrtTables
+#define jpeg_read_header jReadHeader
+#define jpeg_start_decompress jStrtDecompress
+#define jpeg_read_scanlines jReadScanlines
+#define jpeg_finish_decompress jFinDecompress
+#define jpeg_read_raw_data jReadRawData
+#define jpeg_has_multiple_scans jHasMultScn
+#define jpeg_start_output jStrtOutput
+#define jpeg_finish_output jFinOutput
+#define jpeg_input_complete jInComplete
+#define jpeg_new_colormap jNewCMap
+#define jpeg_consume_input jConsumeInput
+#define jpeg_core_output_dimensions jCoreDimensions
+#define jpeg_calc_output_dimensions jCalcDimensions
+#define jpeg_save_markers jSaveMarkers
+#define jpeg_set_marker_processor jSetMarker
+#define jpeg_read_coefficients jReadCoefs
+#define jpeg_write_coefficients jWrtCoefs
+#define jpeg_copy_critical_parameters jCopyCrit
+#define jpeg_abort_compress jAbrtCompress
+#define jpeg_abort_decompress jAbrtDecompress
+#define jpeg_abort jAbort
+#define jpeg_destroy jDestroy
+#define jpeg_resync_to_restart jResyncRestart
+#endif /* NEED_SHORT_EXTERNAL_NAMES */
+
+
+/* Default error-management setup */
+EXTERN(struct jpeg_error_mgr *) jpeg_std_error
+ JPP((struct jpeg_error_mgr * err));
+
+/* Initialization of JPEG compression objects.
+ * jpeg_create_compress() and jpeg_create_decompress() are the exported
+ * names that applications should call. These expand to calls on
+ * jpeg_CreateCompress and jpeg_CreateDecompress with additional information
+ * passed for version mismatch checking.
+ * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx.
+ */
+#define jpeg_create_compress(cinfo) \
+ jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \
+ (size_t) sizeof(struct jpeg_compress_struct))
+#define jpeg_create_decompress(cinfo) \
+ jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \
+ (size_t) sizeof(struct jpeg_decompress_struct))
+EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo,
+ int version, size_t structsize));
+EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo,
+ int version, size_t structsize));
+/* Destruction of JPEG compression objects */
+EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo));
+EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo));
+
+/* Standard data source and destination managers: stdio streams. */
+/* Caller is responsible for opening the file before and closing after. */
+EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile));
+EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile));
+
+/* Data source and destination managers: memory buffers. */
+EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo,
+ unsigned char ** outbuffer,
+ unsigned long * outsize));
+EXTERN(void) jpeg_mem_src JPP((j_decompress_ptr cinfo,
+ unsigned char * inbuffer,
+ unsigned long insize));
+
+/* Default parameter setup for compression */
+EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo));
+/* Compression parameter setup aids */
+EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo,
+ J_COLOR_SPACE colorspace));
+EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo));
+EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality,
+ boolean force_baseline));
+EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo,
+ int scale_factor,
+ boolean force_baseline));
+EXTERN(void) jpeg_default_qtables JPP((j_compress_ptr cinfo,
+ boolean force_baseline));
+EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl,
+ const unsigned int *basic_table,
+ int scale_factor,
+ boolean force_baseline));
+EXTERN(int) jpeg_quality_scaling JPP((int quality));
+EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo));
+EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo,
+ boolean suppress));
+EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo));
+EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo));
+
+/* Main entry points for compression */
+EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo,
+ boolean write_all_tables));
+EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo,
+ JSAMPARRAY scanlines,
+ JDIMENSION num_lines));
+EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo));
+
+/* Precalculate JPEG dimensions for current compression parameters. */
+EXTERN(void) jpeg_calc_jpeg_dimensions JPP((j_compress_ptr cinfo));
+
+/* Replaces jpeg_write_scanlines when writing raw downsampled data. */
+EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo,
+ JSAMPIMAGE data,
+ JDIMENSION num_lines));
+
+/* Write a special marker. See libjpeg.txt concerning safe usage. */
+EXTERN(void) jpeg_write_marker
+ JPP((j_compress_ptr cinfo, int marker,
+ const JOCTET * dataptr, unsigned int datalen));
+/* Same, but piecemeal. */
+EXTERN(void) jpeg_write_m_header
+ JPP((j_compress_ptr cinfo, int marker, unsigned int datalen));
+EXTERN(void) jpeg_write_m_byte
+ JPP((j_compress_ptr cinfo, int val));
+
+/* Alternate compression function: just write an abbreviated table file */
+EXTERN(void) jpeg_write_tables JPP((j_compress_ptr cinfo));
+
+/* Decompression startup: read start of JPEG datastream to see what's there */
+EXTERN(int) jpeg_read_header JPP((j_decompress_ptr cinfo,
+ boolean require_image));
+/* Return value is one of: */
+#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */
+#define JPEG_HEADER_OK 1 /* Found valid image datastream */
+#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */
+/* If you pass require_image = TRUE (normal case), you need not check for
+ * a TABLES_ONLY return code; an abbreviated file will cause an error exit.
+ * JPEG_SUSPENDED is only possible if you use a data source module that can
+ * give a suspension return (the stdio source module doesn't).
+ */
+
+/* Main entry points for decompression */
+EXTERN(boolean) jpeg_start_decompress JPP((j_decompress_ptr cinfo));
+EXTERN(JDIMENSION) jpeg_read_scanlines JPP((j_decompress_ptr cinfo,
+ JSAMPARRAY scanlines,
+ JDIMENSION max_lines));
+EXTERN(boolean) jpeg_finish_decompress JPP((j_decompress_ptr cinfo));
+
+/* Replaces jpeg_read_scanlines when reading raw downsampled data. */
+EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo,
+ JSAMPIMAGE data,
+ JDIMENSION max_lines));
+
+/* Additional entry points for buffered-image mode. */
+EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo));
+EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo,
+ int scan_number));
+EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo));
+EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo));
+EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo));
+EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo));
+/* Return value is one of: */
+/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */
+#define JPEG_REACHED_SOS 1 /* Reached start of new scan */
+#define JPEG_REACHED_EOI 2 /* Reached end of image */
+#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */
+#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */
+
+/* Precalculate output dimensions for current decompression parameters. */
+EXTERN(void) jpeg_core_output_dimensions JPP((j_decompress_ptr cinfo));
+EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo));
+
+/* Control saving of COM and APPn markers into marker_list. */
+EXTERN(void) jpeg_save_markers
+ JPP((j_decompress_ptr cinfo, int marker_code,
+ unsigned int length_limit));
+
+/* Install a special processing method for COM or APPn markers. */
+EXTERN(void) jpeg_set_marker_processor
+ JPP((j_decompress_ptr cinfo, int marker_code,
+ jpeg_marker_parser_method routine));
+
+/* Read or write raw DCT coefficients --- useful for lossless transcoding. */
+EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo));
+EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo,
+ jvirt_barray_ptr * coef_arrays));
+EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo,
+ j_compress_ptr dstinfo));
+
+/* If you choose to abort compression or decompression before completing
+ * jpeg_finish_(de)compress, then you need to clean up to release memory,
+ * temporary files, etc. You can just call jpeg_destroy_(de)compress
+ * if you're done with the JPEG object, but if you want to clean it up and
+ * reuse it, call this:
+ */
+EXTERN(void) jpeg_abort_compress JPP((j_compress_ptr cinfo));
+EXTERN(void) jpeg_abort_decompress JPP((j_decompress_ptr cinfo));
+
+/* Generic versions of jpeg_abort and jpeg_destroy that work on either
+ * flavor of JPEG object. These may be more convenient in some places.
+ */
+EXTERN(void) jpeg_abort JPP((j_common_ptr cinfo));
+EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo));
+
+/* Default restart-marker-resync procedure for use by data source modules */
+EXTERN(boolean) jpeg_resync_to_restart JPP((j_decompress_ptr cinfo,
+ int desired));
+
+
+/* These marker codes are exported since applications and data source modules
+ * are likely to want to use them.
+ */
+
+#define JPEG_RST0 0xD0 /* RST0 marker code */
+#define JPEG_EOI 0xD9 /* EOI marker code */
+#define JPEG_APP0 0xE0 /* APP0 marker code */
+#define JPEG_COM 0xFE /* COM marker code */
+
+
+/* If we have a brain-damaged compiler that emits warnings (or worse, errors)
+ * for structure definitions that are never filled in, keep it quiet by
+ * supplying dummy definitions for the various substructures.
+ */
+
+#ifdef INCOMPLETE_TYPES_BROKEN
+#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */
+struct jvirt_sarray_control { long dummy; };
+struct jvirt_barray_control { long dummy; };
+struct jpeg_comp_master { long dummy; };
+struct jpeg_c_main_controller { long dummy; };
+struct jpeg_c_prep_controller { long dummy; };
+struct jpeg_c_coef_controller { long dummy; };
+struct jpeg_marker_writer { long dummy; };
+struct jpeg_color_converter { long dummy; };
+struct jpeg_downsampler { long dummy; };
+struct jpeg_forward_dct { long dummy; };
+struct jpeg_entropy_encoder { long dummy; };
+struct jpeg_decomp_master { long dummy; };
+struct jpeg_d_main_controller { long dummy; };
+struct jpeg_d_coef_controller { long dummy; };
+struct jpeg_d_post_controller { long dummy; };
+struct jpeg_input_controller { long dummy; };
+struct jpeg_marker_reader { long dummy; };
+struct jpeg_entropy_decoder { long dummy; };
+struct jpeg_inverse_dct { long dummy; };
+struct jpeg_upsampler { long dummy; };
+struct jpeg_color_deconverter { long dummy; };
+struct jpeg_color_quantizer { long dummy; };
+#endif /* JPEG_INTERNALS */
+#endif /* INCOMPLETE_TYPES_BROKEN */
+
+
+/*
+ * The JPEG library modules define JPEG_INTERNALS before including this file.
+ * The internal structure declarations are read only when that is true.
+ * Applications using the library should not include jpegint.h, but may wish
+ * to include jerror.h.
+ */
+
+#ifdef JPEG_INTERNALS
+#include "jpegint.h" /* fetch private declarations */
+#include "jerror.h" /* fetch error codes too */
+#endif
+
+#ifdef __cplusplus
+#ifndef DONT_USE_EXTERN_C
+}
+#endif
+#endif
+
+#endif /* JPEGLIB_H */
--- /dev/null
+#ifndef _ITDEFS_H_
+#define _ITDEFS_H_
+
+#pragma pack(1)
+
+typedef struct tagITFILEHEADER
+{
+ DWORD id; // 0x4D504D49
+ CHAR songname[26];
+ WORD reserved1; // 0x1004
+ WORD ordnum;
+ WORD insnum;
+ WORD smpnum;
+ WORD patnum;
+ WORD cwtv;
+ WORD cmwt;
+ WORD flags;
+ WORD special;
+ BYTE globalvol;
+ BYTE mv;
+ BYTE speed;
+ BYTE tempo;
+ BYTE sep;
+ BYTE zero;
+ WORD msglength;
+ DWORD msgoffset;
+ DWORD reserved2;
+ BYTE chnpan[64];
+ BYTE chnvol[64];
+} ITFILEHEADER;
+
+
+typedef struct tagITENVELOPE
+{
+ BYTE flags;
+ BYTE num;
+ BYTE lpb;
+ BYTE lpe;
+ BYTE slb;
+ BYTE sle;
+ BYTE data[25*3];
+ BYTE reserved;
+} ITENVELOPE;
+
+// Old Impulse Instrument Format (cmwt < 0x200)
+typedef struct tagITOLDINSTRUMENT
+{
+ DWORD id; // IMPI = 0x49504D49
+ CHAR filename[12]; // DOS file name
+ BYTE zero;
+ BYTE flags;
+ BYTE vls;
+ BYTE vle;
+ BYTE sls;
+ BYTE sle;
+ WORD reserved1;
+ WORD fadeout;
+ BYTE nna;
+ BYTE dnc;
+ WORD trkvers;
+ BYTE nos;
+ BYTE reserved2;
+ CHAR name[26];
+ WORD reserved3[3];
+ BYTE keyboard[240];
+ BYTE volenv[200];
+ BYTE nodes[50];
+} ITOLDINSTRUMENT;
+
+
+// Impulse Instrument Format
+typedef struct tagITINSTRUMENT
+{
+ DWORD id;
+ CHAR filename[12];
+ BYTE zero;
+ BYTE nna;
+ BYTE dct;
+ BYTE dca;
+ WORD fadeout;
+ signed char pps;
+ BYTE ppc;
+ BYTE gbv;
+ BYTE dfp;
+ BYTE rv;
+ BYTE rp;
+ WORD trkvers;
+ BYTE nos;
+ BYTE reserved1;
+ CHAR name[26];
+ BYTE ifc;
+ BYTE ifr;
+ BYTE mch;
+ BYTE mpr;
+ WORD mbank;
+ BYTE keyboard[240];
+ ITENVELOPE volenv;
+ ITENVELOPE panenv;
+ ITENVELOPE pitchenv;
+ BYTE dummy[4]; // was 7, but IT v2.17 saves 554 bytes
+} ITINSTRUMENT;
+
+
+// IT Sample Format
+typedef struct ITSAMPLESTRUCT
+{
+ DWORD id; // 0x53504D49
+ CHAR filename[12];
+ BYTE zero;
+ BYTE gvl;
+ BYTE flags;
+ BYTE vol;
+ CHAR name[26];
+ BYTE cvt;
+ BYTE dfp;
+ DWORD length;
+ DWORD loopbegin;
+ DWORD loopend;
+ DWORD C5Speed;
+ DWORD susloopbegin;
+ DWORD susloopend;
+ DWORD samplepointer;
+ BYTE vis;
+ BYTE vid;
+ BYTE vir;
+ BYTE vit;
+} ITSAMPLESTRUCT;
+
+#pragma pack()
+
+extern BYTE autovibit2xm[8];
+extern BYTE autovibxm2it[8];
+
+#endif
--- /dev/null
+/*
+ * This source code is public domain.
+ *
+ * Authors: Kenton Varda <temporal@gauge3d.org> (C interface wrapper)
+ */
+
+#ifndef MODPLUG_H__INCLUDED
+#define MODPLUG_H__INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct _ModPlugFile;
+typedef struct _ModPlugFile ModPlugFile;
+
+struct _ModPlugNote {
+ unsigned char Note;
+ unsigned char Instrument;
+ unsigned char VolumeEffect;
+ unsigned char Effect;
+ unsigned char Volume;
+ unsigned char Parameter;
+};
+typedef struct _ModPlugNote ModPlugNote;
+
+typedef void (*ModPlugMixerProc)(int*, unsigned long, unsigned long);
+
+/* Load a mod file. [data] should point to a block of memory containing the complete
+ * file, and [size] should be the size of that block.
+ * Return the loaded mod file on success, or NULL on failure. */
+ModPlugFile* ModPlug_Load(const void* data, int size);
+/* Unload a mod file. */
+void ModPlug_Unload(ModPlugFile* file);
+
+/* Read sample data into the buffer. Returns the number of bytes read. If the end
+ * of the mod has been reached, zero is returned. */
+int ModPlug_Read(ModPlugFile* file, void* buffer, int size);
+
+/* Get the name of the mod. The returned buffer is stored within the ModPlugFile
+ * structure and will remain valid until you unload the file. */
+const char* ModPlug_GetName(ModPlugFile* file);
+
+/* Get the length of the mod, in milliseconds. Note that this result is not always
+ * accurate, especially in the case of mods with loops. */
+int ModPlug_GetLength(ModPlugFile* file);
+
+/* Seek to a particular position in the song. Note that seeking and MODs don't mix very
+ * well. Some mods will be missing instruments for a short time after a seek, as ModPlug
+ * does not scan the sequence backwards to find out which instruments were supposed to be
+ * playing at that time. (Doing so would be difficult and not very reliable.) Also,
+ * note that seeking is not very exact in some mods -- especially those for which
+ * ModPlug_GetLength() does not report the full length. */
+void ModPlug_Seek(ModPlugFile* file, int millisecond);
+
+enum _ModPlug_Flags
+{
+ MODPLUG_ENABLE_OVERSAMPLING = 1 << 0, /* Enable oversampling (*highly* recommended) */
+ MODPLUG_ENABLE_NOISE_REDUCTION = 1 << 1, /* Enable noise reduction */
+ MODPLUG_ENABLE_REVERB = 1 << 2, /* Enable reverb */
+ MODPLUG_ENABLE_MEGABASS = 1 << 3, /* Enable megabass */
+ MODPLUG_ENABLE_SURROUND = 1 << 4 /* Enable surround sound. */
+};
+
+enum _ModPlug_ResamplingMode
+{
+ MODPLUG_RESAMPLE_NEAREST = 0, /* No interpolation (very fast, extremely bad sound quality) */
+ MODPLUG_RESAMPLE_LINEAR = 1, /* Linear interpolation (fast, good quality) */
+ MODPLUG_RESAMPLE_SPLINE = 2, /* Cubic spline interpolation (high quality) */
+ MODPLUG_RESAMPLE_FIR = 3 /* 8-tap fir filter (extremely high quality) */
+};
+
+typedef struct _ModPlug_Settings
+{
+ int mFlags; /* One or more of the MODPLUG_ENABLE_* flags above, bitwise-OR'ed */
+
+ /* Note that ModPlug always decodes sound at 44100kHz, 32 bit, stereo and then
+ * down-mixes to the settings you choose. */
+ int mChannels; /* Number of channels - 1 for mono or 2 for stereo */
+ int mBits; /* Bits per sample - 8, 16, or 32 */
+ int mFrequency; /* Sampling rate - 11025, 22050, or 44100 */
+ int mResamplingMode; /* One of MODPLUG_RESAMPLE_*, above */
+
+ int mStereoSeparation; /* Stereo separation, 1 - 256 */
+ int mMaxMixChannels; /* Maximum number of mixing channels (polyphony), 32 - 256 */
+
+ int mReverbDepth; /* Reverb level 0(quiet)-100(loud) */
+ int mReverbDelay; /* Reverb delay in ms, usually 40-200ms */
+ int mBassAmount; /* XBass level 0(quiet)-100(loud) */
+ int mBassRange; /* XBass cutoff in Hz 10-100 */
+ int mSurroundDepth; /* Surround level 0(quiet)-100(heavy) */
+ int mSurroundDelay; /* Surround delay in ms, usually 5-40ms */
+ int mLoopCount; /* Number of times to loop. Zero prevents looping.
+ -1 loops forever. */
+} ModPlug_Settings;
+
+/* Get and set the mod decoder settings. All options, except for channels, bits-per-sample,
+ * sampling rate, and loop count, will take effect immediately. Those options which don't
+ * take effect immediately will take effect the next time you load a mod. */
+void ModPlug_GetSettings(ModPlug_Settings* settings);
+void ModPlug_SetSettings(const ModPlug_Settings* settings);
+
+/* New ModPlug API Functions */
+/* NOTE: Master Volume (1-512) */
+unsigned int ModPlug_GetMasterVolume(ModPlugFile* file) ;
+void ModPlug_SetMasterVolume(ModPlugFile* file,unsigned int cvol) ;
+
+int ModPlug_GetCurrentSpeed(ModPlugFile* file);
+int ModPlug_GetCurrentTempo(ModPlugFile* file);
+int ModPlug_GetCurrentOrder(ModPlugFile* file);
+int ModPlug_GetCurrentPattern(ModPlugFile* file);
+int ModPlug_GetCurrentRow(ModPlugFile* file);
+int ModPlug_GetPlayingChannels(ModPlugFile* file);
+
+void ModPlug_SeekOrder(ModPlugFile* file,int order);
+int ModPlug_GetModuleType(ModPlugFile* file);
+char* ModPlug_GetMessage(ModPlugFile* file);
+
+
+#ifndef MODPLUG_NO_FILESAVE
+/*
+ * EXPERIMENTAL Export Functions
+ */
+/*Export to a Scream Tracker 3 S3M module. EXPERIMENTAL (only works on Little-Endian platforms)*/
+char ModPlug_ExportS3M(ModPlugFile* file, const char* filepath);
+
+/*Export to a Extended Module (XM). EXPERIMENTAL (only works on Little-Endian platforms)*/
+char ModPlug_ExportXM(ModPlugFile* file, const char* filepath);
+
+/*Export to a Amiga MOD file. EXPERIMENTAL.*/
+char ModPlug_ExportMOD(ModPlugFile* file, const char* filepath);
+
+/*Export to a Impulse Tracker IT file. Should work OK in Little-Endian & Big-Endian platforms :-) */
+char ModPlug_ExportIT(ModPlugFile* file, const char* filepath);
+#endif // MODPLUG_NO_FILESAVE
+
+unsigned int ModPlug_NumInstruments(ModPlugFile* file);
+unsigned int ModPlug_NumSamples(ModPlugFile* file);
+unsigned int ModPlug_NumPatterns(ModPlugFile* file);
+unsigned int ModPlug_NumChannels(ModPlugFile* file);
+unsigned int ModPlug_SampleName(ModPlugFile* file, unsigned int qual, char* buff);
+unsigned int ModPlug_InstrumentName(ModPlugFile* file, unsigned int qual, char* buff);
+
+/*
+ * Retrieve pattern note-data
+ */
+ModPlugNote* ModPlug_GetPattern(ModPlugFile* file, int pattern, unsigned int* numrows);
+
+/*
+ * =================
+ * Mixer callback
+ * =================
+ *
+ * Use this callback if you want to 'modify' the mixed data of LibModPlug.
+ *
+ * void proc(int* buffer,unsigned long channels,unsigned long nsamples) ;
+ *
+ * 'buffer': A buffer of mixed samples
+ * 'channels': N. of channels in the buffer
+ * 'nsamples': N. of samples in the buffeer (without taking care of n.channels)
+ *
+ * (Samples are signed 32-bit integers)
+ */
+void ModPlug_InitMixerCallback(ModPlugFile* file,ModPlugMixerProc proc) ;
+void ModPlug_UnloadMixerCallback(ModPlugFile* file) ;
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif
--- /dev/null
+/*
+ * This source code is public domain.
+ *
+ * Authors: Olivier Lapicque <olivierl@jps.net>,
+ * Adam Goode <adam@evdebs.org> (endian and char fixes for PPC)
+*/
+
+#if defined(HAVE_CONFIG_H) && !defined(CONFIG_H_INCLUDED)
+#include "config.h"
+#define CONFIG_H_INCLUDED 1
+#endif
+
+#ifndef __SNDFILE_H
+#define __SNDFILE_H
+
+#ifdef UNDER_CE
+int _strnicmp(const char *str1,const char *str2, int n);
+#endif
+
+#ifndef LPCBYTE
+typedef const BYTE * LPCBYTE;
+#endif
+
+#define MOD_AMIGAC2 0x1AB
+#define MAX_SAMPLE_LENGTH 16000000
+#define MAX_SAMPLE_RATE 192000
+#define MAX_ORDERS 256
+#define MAX_PATTERNS 240
+#define MAX_SAMPLES 240
+#define MAX_INSTRUMENTS MAX_SAMPLES
+#ifdef MODPLUG_FASTSOUNDLIB
+#define MAX_CHANNELS 80
+#else
+#define MAX_CHANNELS 128
+#endif
+#define MAX_BASECHANNELS 64
+#define MAX_ENVPOINTS 32
+#define MIN_PERIOD 0x0020
+#define MAX_PERIOD 0xFFFF
+#define MAX_PATTERNNAME 32
+#define MAX_CHANNELNAME 20
+#define MAX_INFONAME 80
+#define MAX_EQ_BANDS 6
+#define MAX_MIXPLUGINS 8
+
+
+#define MOD_TYPE_NONE 0x00
+#define MOD_TYPE_MOD 0x01
+#define MOD_TYPE_S3M 0x02
+#define MOD_TYPE_XM 0x04
+#define MOD_TYPE_MED 0x08
+#define MOD_TYPE_MTM 0x10
+#define MOD_TYPE_IT 0x20
+#define MOD_TYPE_669 0x40
+#define MOD_TYPE_ULT 0x80
+#define MOD_TYPE_STM 0x100
+#define MOD_TYPE_FAR 0x200
+#define MOD_TYPE_WAV 0x400
+#define MOD_TYPE_AMF 0x800
+#define MOD_TYPE_AMS 0x1000
+#define MOD_TYPE_DSM 0x2000
+#define MOD_TYPE_MDL 0x4000
+#define MOD_TYPE_OKT 0x8000
+#define MOD_TYPE_MID 0x10000
+#define MOD_TYPE_DMF 0x20000
+#define MOD_TYPE_PTM 0x40000
+#define MOD_TYPE_DBM 0x80000
+#define MOD_TYPE_MT2 0x100000
+#define MOD_TYPE_AMF0 0x200000
+#define MOD_TYPE_PSM 0x400000
+#define MOD_TYPE_J2B 0x800000
+#define MOD_TYPE_ABC 0x1000000
+#define MOD_TYPE_PAT 0x2000000
+#define MOD_TYPE_UMX 0x80000000 // Fake type
+#define MAX_MODTYPE 24
+
+
+
+// Channel flags:
+// Bits 0-7: Sample Flags
+#define CHN_16BIT 0x01
+#define CHN_LOOP 0x02
+#define CHN_PINGPONGLOOP 0x04
+#define CHN_SUSTAINLOOP 0x08
+#define CHN_PINGPONGSUSTAIN 0x10
+#define CHN_PANNING 0x20
+#define CHN_STEREO 0x40
+#define CHN_PINGPONGFLAG 0x80
+// Bits 8-31: Channel Flags
+#define CHN_MUTE 0x100
+#define CHN_KEYOFF 0x200
+#define CHN_NOTEFADE 0x400
+#define CHN_SURROUND 0x800
+#define CHN_NOIDO 0x1000
+#define CHN_HQSRC 0x2000
+#define CHN_FILTER 0x4000
+#define CHN_VOLUMERAMP 0x8000
+#define CHN_VIBRATO 0x10000
+#define CHN_TREMOLO 0x20000
+#define CHN_PANBRELLO 0x40000
+#define CHN_PORTAMENTO 0x80000
+#define CHN_GLISSANDO 0x100000
+#define CHN_VOLENV 0x200000
+#define CHN_PANENV 0x400000
+#define CHN_PITCHENV 0x800000
+#define CHN_FASTVOLRAMP 0x1000000
+#define CHN_EXTRALOUD 0x2000000
+#define CHN_REVERB 0x4000000
+#define CHN_NOREVERB 0x8000000
+
+
+#define ENV_VOLUME 0x0001
+#define ENV_VOLSUSTAIN 0x0002
+#define ENV_VOLLOOP 0x0004
+#define ENV_PANNING 0x0008
+#define ENV_PANSUSTAIN 0x0010
+#define ENV_PANLOOP 0x0020
+#define ENV_PITCH 0x0040
+#define ENV_PITCHSUSTAIN 0x0080
+#define ENV_PITCHLOOP 0x0100
+#define ENV_SETPANNING 0x0200
+#define ENV_FILTER 0x0400
+#define ENV_VOLCARRY 0x0800
+#define ENV_PANCARRY 0x1000
+#define ENV_PITCHCARRY 0x2000
+
+#define CMD_NONE 0
+#define CMD_ARPEGGIO 1
+#define CMD_PORTAMENTOUP 2
+#define CMD_PORTAMENTODOWN 3
+#define CMD_TONEPORTAMENTO 4
+#define CMD_VIBRATO 5
+#define CMD_TONEPORTAVOL 6
+#define CMD_VIBRATOVOL 7
+#define CMD_TREMOLO 8
+#define CMD_PANNING8 9
+#define CMD_OFFSET 10
+#define CMD_VOLUMESLIDE 11
+#define CMD_POSITIONJUMP 12
+#define CMD_VOLUME 13
+#define CMD_PATTERNBREAK 14
+#define CMD_RETRIG 15
+#define CMD_SPEED 16
+#define CMD_TEMPO 17
+#define CMD_TREMOR 18
+#define CMD_MODCMDEX 19
+#define CMD_S3MCMDEX 20
+#define CMD_CHANNELVOLUME 21
+#define CMD_CHANNELVOLSLIDE 22
+#define CMD_GLOBALVOLUME 23
+#define CMD_GLOBALVOLSLIDE 24
+#define CMD_KEYOFF 25
+#define CMD_FINEVIBRATO 26
+#define CMD_PANBRELLO 27
+#define CMD_XFINEPORTAUPDOWN 28
+#define CMD_PANNINGSLIDE 29
+#define CMD_SETENVPOSITION 30
+#define CMD_MIDI 31
+
+
+// Volume Column commands
+#define VOLCMD_VOLUME 1
+#define VOLCMD_PANNING 2
+#define VOLCMD_VOLSLIDEUP 3
+#define VOLCMD_VOLSLIDEDOWN 4
+#define VOLCMD_FINEVOLUP 5
+#define VOLCMD_FINEVOLDOWN 6
+#define VOLCMD_VIBRATOSPEED 7
+#define VOLCMD_VIBRATO 8
+#define VOLCMD_PANSLIDELEFT 9
+#define VOLCMD_PANSLIDERIGHT 10
+#define VOLCMD_TONEPORTAMENTO 11
+#define VOLCMD_PORTAUP 12
+#define VOLCMD_PORTADOWN 13
+
+#define RSF_16BIT 0x04
+#define RSF_STEREO 0x08
+
+#define RS_PCM8S 0 // 8-bit signed
+#define RS_PCM8U 1 // 8-bit unsigned
+#define RS_PCM8D 2 // 8-bit delta values
+#define RS_ADPCM4 3 // 4-bit ADPCM-packed
+#define RS_PCM16D 4 // 16-bit delta values
+#define RS_PCM16S 5 // 16-bit signed
+#define RS_PCM16U 6 // 16-bit unsigned
+#define RS_PCM16M 7 // 16-bit motorola order
+#define RS_STPCM8S (RS_PCM8S|RSF_STEREO) // stereo 8-bit signed
+#define RS_STPCM8U (RS_PCM8U|RSF_STEREO) // stereo 8-bit unsigned
+#define RS_STPCM8D (RS_PCM8D|RSF_STEREO) // stereo 8-bit delta values
+#define RS_STPCM16S (RS_PCM16S|RSF_STEREO) // stereo 16-bit signed
+#define RS_STPCM16U (RS_PCM16U|RSF_STEREO) // stereo 16-bit unsigned
+#define RS_STPCM16D (RS_PCM16D|RSF_STEREO) // stereo 16-bit delta values
+#define RS_STPCM16M (RS_PCM16M|RSF_STEREO) // stereo 16-bit signed big endian
+// IT 2.14 compressed samples
+#define RS_IT2148 0x10
+#define RS_IT21416 0x14
+#define RS_IT2158 0x12
+#define RS_IT21516 0x16
+// AMS Packed Samples
+#define RS_AMS8 0x11
+#define RS_AMS16 0x15
+// DMF Huffman compression
+#define RS_DMF8 0x13
+#define RS_DMF16 0x17
+// MDL Huffman compression
+#define RS_MDL8 0x20
+#define RS_MDL16 0x24
+#define RS_PTM8DTO16 0x25
+// Stereo Interleaved Samples
+#define RS_STIPCM8S (RS_PCM8S|0x40|RSF_STEREO) // stereo 8-bit signed
+#define RS_STIPCM8U (RS_PCM8U|0x40|RSF_STEREO) // stereo 8-bit unsigned
+#define RS_STIPCM16S (RS_PCM16S|0x40|RSF_STEREO) // stereo 16-bit signed
+#define RS_STIPCM16U (RS_PCM16U|0x40|RSF_STEREO) // stereo 16-bit unsigned
+#define RS_STIPCM16M (RS_PCM16M|0x40|RSF_STEREO) // stereo 16-bit signed big endian
+// 24-bit signed
+#define RS_PCM24S (RS_PCM16S|0x80) // mono 24-bit signed
+#define RS_STIPCM24S (RS_PCM16S|0x80|RSF_STEREO) // stereo 24-bit signed
+#define RS_PCM32S (RS_PCM16S|0xC0) // mono 24-bit signed
+#define RS_STIPCM32S (RS_PCM16S|0xC0|RSF_STEREO) // stereo 24-bit signed
+
+// NNA types
+#define NNA_NOTECUT 0
+#define NNA_CONTINUE 1
+#define NNA_NOTEOFF 2
+#define NNA_NOTEFADE 3
+
+// DCT types
+#define DCT_NONE 0
+#define DCT_NOTE 1
+#define DCT_SAMPLE 2
+#define DCT_INSTRUMENT 3
+
+// DNA types
+#define DNA_NOTECUT 0
+#define DNA_NOTEOFF 1
+#define DNA_NOTEFADE 2
+
+// Mixer Hardware-Dependent features
+#define SYSMIX_ENABLEMMX 0x01
+#define SYSMIX_WINDOWSNT 0x02
+#define SYSMIX_SLOWCPU 0x04
+#define SYSMIX_FASTCPU 0x08
+
+// Module flags
+#define SONG_EMBEDMIDICFG 0x0001
+#define SONG_FASTVOLSLIDES 0x0002
+#define SONG_ITOLDEFFECTS 0x0004
+#define SONG_ITCOMPATMODE 0x0008
+#define SONG_LINEARSLIDES 0x0010
+#define SONG_PATTERNLOOP 0x0020
+#define SONG_STEP 0x0040
+#define SONG_PAUSED 0x0080
+#define SONG_FADINGSONG 0x0100
+#define SONG_ENDREACHED 0x0200
+#define SONG_GLOBALFADE 0x0400
+#define SONG_CPUVERYHIGH 0x0800
+#define SONG_FIRSTTICK 0x1000
+#define SONG_MPTFILTERMODE 0x2000
+#define SONG_SURROUNDPAN 0x4000
+#define SONG_EXFILTERRANGE 0x8000
+#define SONG_AMIGALIMITS 0x10000
+
+// Global Options (Renderer)
+#define SNDMIX_REVERSESTEREO 0x0001
+#define SNDMIX_NOISEREDUCTION 0x0002
+#define SNDMIX_AGC 0x0004
+#define SNDMIX_NORESAMPLING 0x0008
+#define SNDMIX_HQRESAMPLER 0x0010
+#define SNDMIX_MEGABASS 0x0020
+#define SNDMIX_SURROUND 0x0040
+#define SNDMIX_REVERB 0x0080
+#define SNDMIX_EQ 0x0100
+#define SNDMIX_SOFTPANNING 0x0200
+#define SNDMIX_ULTRAHQSRCMODE 0x0400
+// Misc Flags (can safely be turned on or off)
+#define SNDMIX_DIRECTTODISK 0x10000
+#define SNDMIX_ENABLEMMX 0x20000
+#define SNDMIX_NOBACKWARDJUMPS 0x40000
+#define SNDMIX_MAXDEFAULTPAN 0x80000 // Used by the MOD loader
+
+
+// Reverb Types (GM2 Presets)
+enum {
+ REVERBTYPE_SMALLROOM,
+ REVERBTYPE_MEDIUMROOM,
+ REVERBTYPE_LARGEROOM,
+ REVERBTYPE_SMALLHALL,
+ REVERBTYPE_MEDIUMHALL,
+ REVERBTYPE_LARGEHALL,
+ NUM_REVERBTYPES
+};
+
+
+enum {
+ SRCMODE_NEAREST,
+ SRCMODE_LINEAR,
+ SRCMODE_SPLINE,
+ SRCMODE_POLYPHASE,
+ NUM_SRC_MODES
+};
+
+
+// Sample Struct
+typedef struct _MODINSTRUMENT
+{
+ UINT nLength,nLoopStart,nLoopEnd;
+ UINT nSustainStart, nSustainEnd;
+ signed char *pSample;
+ UINT nC4Speed;
+ WORD nPan;
+ WORD nVolume;
+ WORD nGlobalVol;
+ WORD uFlags;
+ signed char RelativeTone;
+ signed char nFineTune;
+ BYTE nVibType;
+ BYTE nVibSweep;
+ BYTE nVibDepth;
+ BYTE nVibRate;
+ CHAR name[22];
+} MODINSTRUMENT;
+
+
+// Instrument Struct
+typedef struct _INSTRUMENTHEADER
+{
+ UINT nFadeOut;
+ DWORD dwFlags;
+ WORD nGlobalVol;
+ WORD nPan;
+ WORD VolPoints[MAX_ENVPOINTS];
+ WORD PanPoints[MAX_ENVPOINTS];
+ WORD PitchPoints[MAX_ENVPOINTS];
+ BYTE VolEnv[MAX_ENVPOINTS];
+ BYTE PanEnv[MAX_ENVPOINTS];
+ BYTE PitchEnv[MAX_ENVPOINTS];
+ BYTE Keyboard[128];
+ BYTE NoteMap[128];
+
+ BYTE nVolEnv;
+ BYTE nPanEnv;
+ BYTE nPitchEnv;
+ BYTE nVolLoopStart;
+ BYTE nVolLoopEnd;
+ BYTE nVolSustainBegin;
+ BYTE nVolSustainEnd;
+ BYTE nPanLoopStart;
+ BYTE nPanLoopEnd;
+ BYTE nPanSustainBegin;
+ BYTE nPanSustainEnd;
+ BYTE nPitchLoopStart;
+ BYTE nPitchLoopEnd;
+ BYTE nPitchSustainBegin;
+ BYTE nPitchSustainEnd;
+ BYTE nNNA;
+ BYTE nDCT;
+ BYTE nDNA;
+ BYTE nPanSwing;
+ BYTE nVolSwing;
+ BYTE nIFC;
+ BYTE nIFR;
+ WORD wMidiBank;
+ BYTE nMidiProgram;
+ BYTE nMidiChannel;
+ BYTE nMidiDrumKey;
+ signed char nPPS;
+ unsigned char nPPC;
+ CHAR name[32];
+ CHAR filename[12];
+} INSTRUMENTHEADER;
+
+
+// Channel Struct
+typedef struct _MODCHANNEL
+{
+ // First 32-bytes: Most used mixing information: don't change it
+ signed char * pCurrentSample;
+ DWORD nPos;
+ DWORD nPosLo; // actually 16-bit
+ LONG nInc; // 16.16
+ LONG nRightVol;
+ LONG nLeftVol;
+ LONG nRightRamp;
+ LONG nLeftRamp;
+ // 2nd cache line
+ DWORD nLength;
+ DWORD dwFlags;
+ DWORD nLoopStart;
+ DWORD nLoopEnd;
+ LONG nRampRightVol;
+ LONG nRampLeftVol;
+ LONG nFilter_Y1, nFilter_Y2, nFilter_Y3, nFilter_Y4;
+ LONG nFilter_A0, nFilter_B0, nFilter_B1;
+ LONG nROfs, nLOfs;
+ LONG nRampLength;
+ // Information not used in the mixer
+ signed char * pSample;
+ LONG nNewRightVol, nNewLeftVol;
+ LONG nRealVolume, nRealPan;
+ LONG nVolume, nPan, nFadeOutVol;
+ LONG nPeriod, nC4Speed, nPortamentoDest;
+ INSTRUMENTHEADER *pHeader;
+ MODINSTRUMENT *pInstrument;
+ DWORD nVolEnvPosition, nPanEnvPosition, nPitchEnvPosition;
+ DWORD nMasterChn, nVUMeter;
+ LONG nGlobalVol, nInsVol;
+ LONG nFineTune, nTranspose;
+ LONG nPortamentoSlide, nAutoVibDepth;
+ UINT nAutoVibPos, nVibratoPos, nTremoloPos, nPanbrelloPos;
+ // 16-bit members
+ signed short nVolSwing, nPanSwing;
+ // 8-bit members
+ BYTE nNote, nNNA;
+ BYTE nNewNote, nNewIns, nCommand, nArpeggio;
+ BYTE nOldVolumeSlide, nOldFineVolUpDown;
+ BYTE nOldPortaUpDown, nOldFinePortaUpDown;
+ BYTE nOldPanSlide, nOldChnVolSlide;
+ BYTE nVibratoType, nVibratoSpeed, nVibratoDepth;
+ BYTE nTremoloType, nTremoloSpeed, nTremoloDepth;
+ BYTE nPanbrelloType, nPanbrelloSpeed, nPanbrelloDepth;
+ BYTE nOldCmdEx, nOldVolParam, nOldTempo;
+ BYTE nOldOffset, nOldHiOffset;
+ BYTE nCutOff, nResonance;
+ BYTE nRetrigCount, nRetrigParam;
+ BYTE nTremorCount, nTremorParam;
+ BYTE nPatternLoop, nPatternLoopCount;
+ BYTE nRowNote, nRowInstr;
+ BYTE nRowVolCmd, nRowVolume;
+ BYTE nRowCommand, nRowParam;
+ BYTE nLeftVU, nRightVU;
+ BYTE nActiveMacro, nPadding;
+} MODCHANNEL;
+
+
+typedef struct _MODCHANNELSETTINGS
+{
+ UINT nPan;
+ UINT nVolume;
+ DWORD dwFlags;
+ UINT nMixPlugin;
+ char szName[MAX_CHANNELNAME]; // changed from CHAR
+} MODCHANNELSETTINGS;
+
+
+typedef struct _MODCOMMAND
+{
+ BYTE note;
+ BYTE instr;
+ BYTE volcmd;
+ BYTE command;
+ BYTE vol;
+ BYTE param;
+} MODCOMMAND, *LPMODCOMMAND;
+
+////////////////////////////////////////////////////////////////////
+// Mix Plugins
+#define MIXPLUG_MIXREADY 0x01 // Set when cleared
+
+class IMixPlugin
+{
+public:
+ virtual ~IMixPlugin();
+ virtual int AddRef() = 0;
+ virtual int Release() = 0;
+ virtual void SaveAllParameters() = 0;
+ virtual void RestoreAllParameters() = 0;
+ virtual void Process(float *pOutL, float *pOutR, unsigned long nSamples) = 0;
+ virtual void Init(unsigned long nFreq, int bReset) = 0;
+ virtual void MidiSend(DWORD dwMidiCode) = 0;
+ virtual void MidiCommand(UINT nMidiCh, UINT nMidiProg, UINT note, UINT vol) = 0;
+};
+
+
+#define MIXPLUG_INPUTF_MASTEREFFECT 0x01 // Apply to master mix
+#define MIXPLUG_INPUTF_BYPASS 0x02 // Bypass effect
+#define MIXPLUG_INPUTF_WETMIX 0x04 // Wet Mix (dry added)
+
+typedef struct _SNDMIXPLUGINSTATE
+{
+ DWORD dwFlags; // MIXPLUG_XXXX
+ LONG nVolDecayL, nVolDecayR; // Buffer click removal
+ int *pMixBuffer; // Stereo effect send buffer
+ float *pOutBufferL; // Temp storage for int -> float conversion
+ float *pOutBufferR;
+} SNDMIXPLUGINSTATE, *PSNDMIXPLUGINSTATE;
+
+typedef struct _SNDMIXPLUGININFO
+{
+ DWORD dwPluginId1;
+ DWORD dwPluginId2;
+ DWORD dwInputRouting; // MIXPLUG_INPUTF_XXXX
+ DWORD dwOutputRouting; // 0=mix 0x80+=fx
+ DWORD dwReserved[4]; // Reserved for routing info
+ CHAR szName[32];
+ CHAR szLibraryName[64]; // original DLL name
+} SNDMIXPLUGININFO, *PSNDMIXPLUGININFO; // Size should be 128
+
+typedef struct _SNDMIXPLUGIN
+{
+ IMixPlugin *pMixPlugin;
+ PSNDMIXPLUGINSTATE pMixState;
+ ULONG nPluginDataSize;
+ PVOID pPluginData;
+ SNDMIXPLUGININFO Info;
+} SNDMIXPLUGIN, *PSNDMIXPLUGIN;
+
+typedef BOOL (*PMIXPLUGINCREATEPROC)(PSNDMIXPLUGIN);
+
+////////////////////////////////////////////////////////////////////
+
+enum {
+ MIDIOUT_START=0,
+ MIDIOUT_STOP,
+ MIDIOUT_TICK,
+ MIDIOUT_NOTEON,
+ MIDIOUT_NOTEOFF,
+ MIDIOUT_VOLUME,
+ MIDIOUT_PAN,
+ MIDIOUT_BANKSEL,
+ MIDIOUT_PROGRAM,
+};
+
+
+typedef struct MODMIDICFG
+{
+ char szMidiGlb[9*32]; // changed from CHAR
+ char szMidiSFXExt[16*32]; // changed from CHAR
+ char szMidiZXXExt[128*32]; // changed from CHAR
+} MODMIDICFG, *LPMODMIDICFG;
+
+#define NOTE_MAX 120 //Defines maximum notevalue as well as maximum number of notes.
+
+typedef VOID (* LPSNDMIXHOOKPROC)(int *, unsigned long, unsigned long); // buffer, samples, channels
+
+
+
+//==============
+class CSoundFile
+//==============
+{
+public: // Static Members
+ static UINT m_nXBassDepth, m_nXBassRange;
+ static UINT m_nReverbDepth, m_nReverbDelay, gnReverbType;
+ static UINT m_nProLogicDepth, m_nProLogicDelay;
+ static UINT m_nStereoSeparation;
+ static UINT m_nMaxMixChannels;
+ static LONG m_nStreamVolume;
+ static DWORD gdwSysInfo, gdwSoundSetup, gdwMixingFreq, gnBitsPerSample, gnChannels;
+ static UINT gnAGC, gnVolumeRampSamples, gnVUMeter, gnCPUUsage;
+ static LPSNDMIXHOOKPROC gpSndMixHook;
+ static PMIXPLUGINCREATEPROC gpMixPluginCreateProc;
+
+public: // for Editing
+ MODCHANNEL Chn[MAX_CHANNELS]; // Channels
+ UINT ChnMix[MAX_CHANNELS]; // Channels to be mixed
+ MODINSTRUMENT Ins[MAX_SAMPLES]; // Instruments
+ INSTRUMENTHEADER *Headers[MAX_INSTRUMENTS]; // Instrument Headers
+ MODCHANNELSETTINGS ChnSettings[MAX_BASECHANNELS]; // Channels settings
+ MODCOMMAND *Patterns[MAX_PATTERNS]; // Patterns
+ WORD PatternSize[MAX_PATTERNS]; // Patterns Lengths
+ BYTE Order[MAX_ORDERS]; // Pattern Orders
+ MODMIDICFG m_MidiCfg; // Midi macro config table
+ SNDMIXPLUGIN m_MixPlugins[MAX_MIXPLUGINS]; // Mix plugins
+ UINT m_nDefaultSpeed, m_nDefaultTempo, m_nDefaultGlobalVolume;
+ DWORD m_dwSongFlags; // Song flags SONG_XXXX
+ UINT m_nChannels, m_nMixChannels, m_nMixStat, m_nBufferCount;
+ UINT m_nType, m_nSamples, m_nInstruments;
+ UINT m_nTickCount, m_nTotalCount, m_nPatternDelay, m_nFrameDelay;
+ UINT m_nMusicSpeed, m_nMusicTempo;
+ UINT m_nNextRow, m_nRow;
+ UINT m_nPattern,m_nCurrentPattern,m_nNextPattern,m_nRestartPos;
+ UINT m_nMasterVolume, m_nGlobalVolume, m_nSongPreAmp;
+ UINT m_nFreqFactor, m_nTempoFactor, m_nOldGlbVolSlide;
+ LONG m_nMinPeriod, m_nMaxPeriod, m_nRepeatCount, m_nInitialRepeatCount;
+ DWORD m_nGlobalFadeSamples, m_nGlobalFadeMaxSamples;
+ UINT m_nMaxOrderPosition;
+ UINT m_nPatternNames;
+ LPSTR m_lpszSongComments, m_lpszPatternNames;
+ char m_szNames[MAX_INSTRUMENTS][32]; // changed from CHAR
+ CHAR CompressionTable[16];
+
+public:
+ CSoundFile();
+ ~CSoundFile();
+
+public:
+ BOOL Create(LPCBYTE lpStream, DWORD dwMemLength=0);
+ BOOL Destroy();
+ UINT GetType() const { return m_nType; }
+ UINT GetNumChannels() const;
+ UINT GetLogicalChannels() const { return m_nChannels; }
+ BOOL SetMasterVolume(UINT vol, BOOL bAdjustAGC=FALSE);
+ UINT GetMasterVolume() const { return m_nMasterVolume; }
+ UINT GetNumPatterns() const;
+ UINT GetNumInstruments() const;
+ UINT GetNumSamples() const { return m_nSamples; }
+ UINT GetCurrentPos() const;
+ UINT GetCurrentPattern() const { return m_nPattern; }
+ UINT GetCurrentOrder() const { return m_nCurrentPattern; }
+ UINT GetSongComments(LPSTR s, UINT cbsize, UINT linesize=32);
+ UINT GetRawSongComments(LPSTR s, UINT cbsize, UINT linesize=32);
+ UINT GetMaxPosition() const;
+ void SetCurrentPos(UINT nPos);
+ void SetCurrentOrder(UINT nOrder);
+ void GetTitle(LPSTR s) const { lstrcpyn(s,m_szNames[0],32); }
+ LPCSTR GetTitle() const { return m_szNames[0]; }
+ UINT GetSampleName(UINT nSample,LPSTR s=NULL) const;
+ UINT GetInstrumentName(UINT nInstr,LPSTR s=NULL) const;
+ UINT GetMusicSpeed() const { return m_nMusicSpeed; }
+ UINT GetMusicTempo() const { return m_nMusicTempo; }
+ DWORD GetLength(BOOL bAdjust, BOOL bTotal=FALSE);
+ DWORD GetSongTime() { return GetLength(FALSE, TRUE); }
+ void SetRepeatCount(int n) { m_nRepeatCount = n; m_nInitialRepeatCount = n; }
+ int GetRepeatCount() const { return m_nRepeatCount; }
+ BOOL IsPaused() const { return (m_dwSongFlags & SONG_PAUSED) ? TRUE : FALSE; }
+ void LoopPattern(int nPat, int nRow=0);
+ void CheckCPUUsage(UINT nCPU);
+ BOOL SetPatternName(UINT nPat, LPCSTR lpszName);
+ BOOL GetPatternName(UINT nPat, LPSTR lpszName, UINT cbSize=MAX_PATTERNNAME) const;
+ // Module Loaders
+ BOOL ReadXM(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadS3M(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadMod(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadMed(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadMTM(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadSTM(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadIT(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL Read669(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadUlt(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadWav(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadDSM(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadFAR(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadAMS(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadAMS2(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadMDL(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadOKT(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadDMF(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadPTM(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadDBM(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadAMF(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadMT2(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadPSM(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadJ2B(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadUMX(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadABC(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL TestABC(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadMID(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL TestMID(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadPAT(LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL TestPAT(LPCBYTE lpStream, DWORD dwMemLength);
+ // Save Functions
+#ifndef MODPLUG_NO_FILESAVE
+ UINT WriteSample(FILE *f, MODINSTRUMENT *pins, UINT nFlags, UINT nMaxLen=0);
+ BOOL SaveXM(LPCSTR lpszFileName, UINT nPacking=0);
+ BOOL SaveS3M(LPCSTR lpszFileName, UINT nPacking=0);
+ BOOL SaveMod(LPCSTR lpszFileName, UINT nPacking=0);
+ BOOL SaveIT(LPCSTR lpszFileName, UINT nPacking=0);
+#endif // MODPLUG_NO_FILESAVE
+ // MOD Convert function
+ UINT GetBestSaveFormat() const;
+ UINT GetSaveFormats() const;
+ void ConvertModCommand(MODCOMMAND *) const;
+ void S3MConvert(MODCOMMAND *m, BOOL bIT) const;
+ void S3MSaveConvert(UINT *pcmd, UINT *pprm, BOOL bIT) const;
+ WORD ModSaveCommand(const MODCOMMAND *m, BOOL bXM) const;
+
+public:
+ // Real-time sound functions
+ VOID ResetChannels();
+
+ UINT Read(LPVOID lpBuffer, UINT cbBuffer);
+ UINT CreateStereoMix(int count);
+ BOOL FadeSong(UINT msec);
+ BOOL GlobalFadeSong(UINT msec);
+ UINT GetTotalTickCount() const { return m_nTotalCount; }
+ VOID ResetTotalTickCount() { m_nTotalCount = 0; }
+
+public:
+ // Mixer Config
+ static BOOL InitPlayer(BOOL bReset=FALSE);
+ static BOOL SetMixConfig(UINT nStereoSeparation, UINT nMaxMixChannels);
+ static BOOL SetWaveConfig(UINT nRate,UINT nBits,UINT nChannels,BOOL bMMX=FALSE);
+ static BOOL SetResamplingMode(UINT nMode); // SRCMODE_XXXX
+ static BOOL IsStereo() { return (gnChannels > 1) ? TRUE : FALSE; }
+ static DWORD GetSampleRate() { return gdwMixingFreq; }
+ static DWORD GetBitsPerSample() { return gnBitsPerSample; }
+ static DWORD InitSysInfo();
+ static DWORD GetSysInfo() { return gdwSysInfo; }
+ // AGC
+ static BOOL GetAGC() { return (gdwSoundSetup & SNDMIX_AGC) ? TRUE : FALSE; }
+ static void SetAGC(BOOL b);
+ static void ResetAGC();
+ static void ProcessAGC(int count);
+
+ //GCCFIX -- added these functions back in!
+ static BOOL SetWaveConfigEx(BOOL bSurround,BOOL bNoOverSampling,BOOL bReverb,BOOL hqido,BOOL bMegaBass,BOOL bNR,BOOL bEQ);
+ // DSP Effects
+ static void InitializeDSP(BOOL bReset);
+ static void ProcessStereoDSP(int count);
+ static void ProcessMonoDSP(int count);
+ // [Reverb level 0(quiet)-100(loud)], [delay in ms, usually 40-200ms]
+ static BOOL SetReverbParameters(UINT nDepth, UINT nDelay);
+ // [XBass level 0(quiet)-100(loud)], [cutoff in Hz 10-100]
+ static BOOL SetXBassParameters(UINT nDepth, UINT nRange);
+ // [Surround level 0(quiet)-100(heavy)] [delay in ms, usually 5-40ms]
+ static BOOL SetSurroundParameters(UINT nDepth, UINT nDelay);
+public:
+ BOOL ReadNote();
+ BOOL ProcessRow();
+ BOOL ProcessEffects();
+ UINT GetNNAChannel(UINT nChn) const;
+ void CheckNNA(UINT nChn, UINT instr, int note, BOOL bForceCut);
+ void NoteChange(UINT nChn, int note, BOOL bPorta=FALSE, BOOL bResetEnv=TRUE);
+ void InstrumentChange(MODCHANNEL *pChn, UINT instr, BOOL bPorta=FALSE,BOOL bUpdVol=TRUE,BOOL bResetEnv=TRUE);
+ // Channel Effects
+ void PortamentoUp(MODCHANNEL *pChn, UINT param);
+ void PortamentoDown(MODCHANNEL *pChn, UINT param);
+ void FinePortamentoUp(MODCHANNEL *pChn, UINT param);
+ void FinePortamentoDown(MODCHANNEL *pChn, UINT param);
+ void ExtraFinePortamentoUp(MODCHANNEL *pChn, UINT param);
+ void ExtraFinePortamentoDown(MODCHANNEL *pChn, UINT param);
+ void TonePortamento(MODCHANNEL *pChn, UINT param);
+ void Vibrato(MODCHANNEL *pChn, UINT param);
+ void FineVibrato(MODCHANNEL *pChn, UINT param);
+ void VolumeSlide(MODCHANNEL *pChn, UINT param);
+ void PanningSlide(MODCHANNEL *pChn, UINT param);
+ void ChannelVolSlide(MODCHANNEL *pChn, UINT param);
+ void FineVolumeUp(MODCHANNEL *pChn, UINT param);
+ void FineVolumeDown(MODCHANNEL *pChn, UINT param);
+ void Tremolo(MODCHANNEL *pChn, UINT param);
+ void Panbrello(MODCHANNEL *pChn, UINT param);
+ void RetrigNote(UINT nChn, UINT param);
+ void NoteCut(UINT nChn, UINT nTick);
+ void KeyOff(UINT nChn);
+ int PatternLoop(MODCHANNEL *, UINT param);
+ void ExtendedMODCommands(UINT nChn, UINT param);
+ void ExtendedS3MCommands(UINT nChn, UINT param);
+ void ExtendedChannelEffect(MODCHANNEL *, UINT param);
+ void ProcessMidiMacro(UINT nChn, LPCSTR pszMidiMacro, UINT param=0);
+ void SetupChannelFilter(MODCHANNEL *pChn, BOOL bReset, int flt_modifier=256) const;
+ // Low-Level effect processing
+ void DoFreqSlide(MODCHANNEL *pChn, LONG nFreqSlide);
+ // Global Effects
+ void SetTempo(UINT param);
+ void SetSpeed(UINT param);
+ void GlobalVolSlide(UINT param);
+ DWORD IsSongFinished(UINT nOrder, UINT nRow) const;
+ BOOL IsValidBackwardJump(UINT nStartOrder, UINT nStartRow, UINT nJumpOrder, UINT nJumpRow) const;
+ // Read/Write sample functions
+ signed char GetDeltaValue(signed char prev, UINT n) const { return (signed char)(prev + CompressionTable[n & 0x0F]); }
+ UINT PackSample(int &sample, int next);
+ BOOL CanPackSample(LPSTR pSample, UINT nLen, UINT nPacking, BYTE *result=NULL);
+ UINT ReadSample(MODINSTRUMENT *pIns, UINT nFlags, LPCSTR pMemFile, DWORD dwMemLength);
+ BOOL DestroySample(UINT nSample);
+ BOOL DestroyInstrument(UINT nInstr);
+ BOOL IsSampleUsed(UINT nSample);
+ BOOL IsInstrumentUsed(UINT nInstr);
+ BOOL RemoveInstrumentSamples(UINT nInstr);
+ UINT DetectUnusedSamples(BOOL *);
+ BOOL RemoveSelectedSamples(BOOL *);
+ void AdjustSampleLoop(MODINSTRUMENT *pIns);
+ // I/O from another sound file
+ BOOL ReadInstrumentFromSong(UINT nInstr, CSoundFile *, UINT nSrcInstrument);
+ BOOL ReadSampleFromSong(UINT nSample, CSoundFile *, UINT nSrcSample);
+ // Period/Note functions
+ UINT GetNoteFromPeriod(UINT period) const;
+ UINT GetPeriodFromNote(UINT note, int nFineTune, UINT nC4Speed) const;
+ UINT GetFreqFromPeriod(UINT period, UINT nC4Speed, int nPeriodFrac=0) const;
+ // Misc functions
+ MODINSTRUMENT *GetSample(UINT n) { return Ins+n; }
+ void ResetMidiCfg();
+ UINT MapMidiInstrument(DWORD dwProgram, UINT nChannel, UINT nNote);
+ BOOL ITInstrToMPT(const void *p, INSTRUMENTHEADER *penv, UINT trkvers);
+ UINT SaveMixPlugins(FILE *f=NULL, BOOL bUpdate=TRUE);
+ UINT LoadMixPlugins(const void *pData, UINT nLen);
+#ifndef NO_FILTER
+ DWORD CutOffToFrequency(UINT nCutOff, int flt_modifier=256) const; // [0-255] => [1-10KHz]
+#endif
+
+ // Static helper functions
+public:
+ static DWORD TransposeToFrequency(int transp, int ftune=0);
+ static int FrequencyToTranspose(DWORD freq);
+ static void FrequencyToTranspose(MODINSTRUMENT *psmp);
+
+ // System-Dependant functions
+public:
+ static MODCOMMAND *AllocatePattern(UINT rows, UINT nchns);
+ static signed char* AllocateSample(UINT nbytes);
+ static void FreePattern(LPVOID pat);
+ static void FreeSample(LPVOID p);
+ static UINT Normalize24BitBuffer(LPBYTE pbuffer, UINT cbsizebytes, DWORD lmax24, DWORD dwByteInc);
+};
+
+
+// inline DWORD BigEndian(DWORD x) { return ((x & 0xFF) << 24) | ((x & 0xFF00) << 8) | ((x & 0xFF0000) >> 8) | ((x & 0xFF000000) >> 24); }
+// inline WORD BigEndianW(WORD x) { return (WORD)(((x >> 8) & 0xFF) | ((x << 8) & 0xFF00)); }
+
+
+//////////////////////////////////////////////////////////
+// WAVE format information
+
+#pragma pack(1)
+
+// Standard IFF chunks IDs
+#define IFFID_FORM 0x4d524f46
+#define IFFID_RIFF 0x46464952
+#define IFFID_WAVE 0x45564157
+#define IFFID_LIST 0x5453494C
+#define IFFID_INFO 0x4F464E49
+
+// IFF Info fields
+#define IFFID_ICOP 0x504F4349
+#define IFFID_IART 0x54524149
+#define IFFID_IPRD 0x44525049
+#define IFFID_INAM 0x4D414E49
+#define IFFID_ICMT 0x544D4349
+#define IFFID_IENG 0x474E4549
+#define IFFID_ISFT 0x54465349
+#define IFFID_ISBJ 0x4A425349
+#define IFFID_IGNR 0x524E4749
+#define IFFID_ICRD 0x44524349
+
+// Wave IFF chunks IDs
+#define IFFID_wave 0x65766177
+#define IFFID_fmt 0x20746D66
+#define IFFID_wsmp 0x706D7377
+#define IFFID_pcm 0x206d6370
+#define IFFID_data 0x61746164
+#define IFFID_smpl 0x6C706D73
+#define IFFID_xtra 0x61727478
+
+typedef struct WAVEFILEHEADER
+{
+ DWORD id_RIFF; // "RIFF"
+ DWORD filesize; // file length-8
+ DWORD id_WAVE;
+} WAVEFILEHEADER;
+
+
+typedef struct WAVEFORMATHEADER
+{
+ DWORD id_fmt; // "fmt "
+ DWORD hdrlen; // 16
+ WORD format; // 1
+ WORD channels; // 1:mono, 2:stereo
+ DWORD freqHz; // sampling freq
+ DWORD bytessec; // bytes/sec=freqHz*samplesize
+ WORD samplesize; // sizeof(sample)
+ WORD bitspersample; // bits per sample (8/16)
+} WAVEFORMATHEADER;
+
+
+typedef struct WAVEDATAHEADER
+{
+ DWORD id_data; // "data"
+ DWORD length; // length of data
+} WAVEDATAHEADER;
+
+
+typedef struct WAVESMPLHEADER
+{
+ // SMPL
+ DWORD smpl_id; // "smpl" -> 0x6C706D73
+ DWORD smpl_len; // length of smpl: 3Ch (54h with sustain loop)
+ DWORD dwManufacturer;
+ DWORD dwProduct;
+ DWORD dwSamplePeriod; // 1000000000/freqHz
+ DWORD dwBaseNote; // 3Ch = C-4 -> 60 + RelativeTone
+ DWORD dwPitchFraction;
+ DWORD dwSMPTEFormat;
+ DWORD dwSMPTEOffset;
+ DWORD dwSampleLoops; // number of loops
+ DWORD cbSamplerData;
+} WAVESMPLHEADER;
+
+
+typedef struct SAMPLELOOPSTRUCT
+{
+ DWORD dwIdentifier;
+ DWORD dwLoopType; // 0=normal, 1=bidi
+ DWORD dwLoopStart;
+ DWORD dwLoopEnd; // Byte offset ?
+ DWORD dwFraction;
+ DWORD dwPlayCount; // Loop Count, 0=infinite
+} SAMPLELOOPSTRUCT;
+
+
+typedef struct WAVESAMPLERINFO
+{
+ WAVESMPLHEADER wsiHdr;
+ SAMPLELOOPSTRUCT wsiLoops[2];
+} WAVESAMPLERINFO;
+
+
+typedef struct WAVELISTHEADER
+{
+ DWORD list_id; // "LIST" -> 0x5453494C
+ DWORD list_len;
+ DWORD info; // "INFO"
+} WAVELISTHEADER;
+
+
+typedef struct WAVEEXTRAHEADER
+{
+ DWORD xtra_id; // "xtra" -> 0x61727478
+ DWORD xtra_len;
+ DWORD dwFlags;
+ WORD wPan;
+ WORD wVolume;
+ WORD wGlobalVol;
+ WORD wReserved;
+ BYTE nVibType;
+ BYTE nVibSweep;
+ BYTE nVibDepth;
+ BYTE nVibRate;
+} WAVEEXTRAHEADER;
+
+#pragma pack()
+
+///////////////////////////////////////////////////////////
+// Low-level Mixing functions
+
+#define MIXBUFFERSIZE 512
+#define MIXING_ATTENUATION 4
+#define MIXING_CLIPMIN (-0x08000000)
+#define MIXING_CLIPMAX (0x07FFFFFF)
+#define VOLUMERAMPPRECISION 12
+#define FADESONGDELAY 100
+#define EQ_BUFFERSIZE (MIXBUFFERSIZE)
+#define AGC_PRECISION 9
+#define AGC_UNITY (1 << AGC_PRECISION)
+
+// Calling conventions
+#ifdef MSC_VER
+#define MPPASMCALL __cdecl
+#define MPPFASTCALL __fastcall
+#else
+#define MPPASMCALL
+#define MPPFASTCALL
+#endif
+
+#define MOD2XMFineTune(k) ((int)( (signed char)((k)<<4) ))
+#define XM2MODFineTune(k) ((int)( (k>>4)&0x0f ))
+
+int _muldiv(long a, long b, long c);
+int _muldivr(long a, long b, long c);
+
+
+// Byte swapping functions from the GNU C Library and libsdl
+
+/* Swap bytes in 16 bit value. */
+#ifdef __GNUC__
+# define bswap_16(x) \
+ (__extension__ \
+ ({ unsigned short int __bsx = (x); \
+ ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8)); }))
+#else
+static __inline unsigned short int
+bswap_16 (unsigned short int __bsx)
+{
+ return ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8));
+}
+#endif
+
+/* Swap bytes in 32 bit value. */
+#ifdef __GNUC__
+# define bswap_32(x) \
+ (__extension__ \
+ ({ unsigned int __bsx = (x); \
+ ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) | \
+ (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24)); }))
+#else
+static __inline unsigned int
+bswap_32 (unsigned int __bsx)
+{
+ return ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) |
+ (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24));
+}
+#endif
+
+#if (defined ARM) && (defined _WIN32_WCE)
+static __inline unsigned short int
+ARM_get16(const void *data)
+{
+ unsigned short int s;
+ memcpy(&s,data,sizeof(s));
+ return s;
+}
+
+static __inline unsigned int
+ARM_get32(const void *data)
+{
+ unsigned int s;
+ memcpy(&s,data,sizeof(s));
+ return s;
+}
+
+#define bswapLE16(X) ARM_get16(&X)
+#define bswapLE32(X) ARM_get32(&X)
+#define bswapBE16(X) bswap_16(ARM_get16(&X))
+#define bswapBE32(X) bswap_32(ARM_get32(&X))
+
+// From libsdl
+#elif defined(WORDS_BIGENDIAN) && WORDS_BIGENDIAN
+#define bswapLE16(X) bswap_16(X)
+#define bswapLE32(X) bswap_32(X)
+#define bswapBE16(X) (X)
+#define bswapBE32(X) (X)
+#else
+#define bswapLE16(X) (X)
+#define bswapLE32(X) (X)
+#define bswapBE16(X) bswap_16(X)
+#define bswapBE32(X) bswap_32(X)
+#endif
+
+#endif
--- /dev/null
+/*
+ * This source code is public domain.
+ *
+ * Authors: Rani Assaf <rani@magic.metawire.com>,
+ * Olivier Lapicque <olivierl@jps.net>,
+ * Adam Goode <adam@evdebs.org> (endian and char fixes for PPC)
+ */
+
+#ifndef _STDAFX_H_
+#define _STDAFX_H_
+
+/* Autoconf detection of stdint/inttypes */
+#if defined(HAVE_CONFIG_H) && !defined(CONFIG_H_INCLUDED)
+# include "config.h"
+# define CONFIG_H_INCLUDED 1
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+
+
+#ifdef _WIN32
+
+#ifdef MSC_VER
+#pragma warning (disable:4201)
+#pragma warning (disable:4514)
+#endif
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <windowsx.h>
+#include <mmsystem.h>
+#include <stdio.h>
+#include <malloc.h>
+
+#define srandom(_seed) srand(_seed)
+#define random() rand()
+#define sleep(_ms) Sleep(_ms)
+
+inline void ProcessPlugins(int n) {}
+
+#else
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
+
+typedef int8_t CHAR;
+typedef uint8_t UCHAR;
+typedef uint8_t* PUCHAR;
+typedef uint16_t USHORT;
+typedef uint32_t ULONG;
+typedef uint32_t UINT;
+typedef uint32_t DWORD;
+typedef int32_t LONG;
+typedef int64_t LONGLONG;
+typedef int32_t* LPLONG;
+typedef uint32_t* LPDWORD;
+typedef uint16_t WORD;
+typedef uint8_t BYTE;
+typedef uint8_t* LPBYTE;
+typedef bool BOOL;
+typedef char* LPSTR;
+typedef void* LPVOID;
+typedef uint16_t* LPWORD;
+typedef const char* LPCSTR;
+typedef void* PVOID;
+typedef void VOID;
+
+inline LONG MulDiv (long a, long b, long c)
+{
+ // if (!c) return 0;
+ return ((uint64_t) a * (uint64_t) b ) / c;
+}
+
+#define MODPLUG_NO_FILESAVE
+#define NO_AGC
+#define LPCTSTR LPCSTR
+#define lstrcpyn strncpy
+#define lstrcpy strcpy
+#define lstrcmp strcmp
+#define WAVE_FORMAT_PCM 1
+//#define ENABLE_EQ
+
+#define GHND 0
+
+inline int8_t * GlobalAllocPtr(unsigned int, size_t size)
+{
+ int8_t * p = (int8_t *) malloc(size);
+
+ if (p != NULL) memset(p, 0, size);
+ return p;
+}
+
+inline void ProcessPlugins(int n) {}
+
+#define GlobalFreePtr(p) free((void *)(p))
+
+#define strnicmp(a,b,c) strncasecmp(a,b,c)
+#define wsprintf sprintf
+
+#ifndef FALSE
+#define FALSE false
+#endif
+
+#ifndef TRUE
+#define TRUE true
+#endif
+
+#endif // _WIN32
+
+#endif
+
+
+
--- /dev/null
+# libjpeg.la - a libtool library file
+# Generated by ltmain.sh (GNU libtool) 2.2.6b
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname=''
+
+# Names of this library.
+library_names=''
+
+# The name of the static archive.
+old_library='libjpeg.a'
+
+# Linker flags that can not go in dependency_libs.
+inherited_linker_flags=''
+
+# Libraries that this one depends upon.
+dependency_libs=''
+
+# Names of additional weak libraries provided by this library
+weak_library_names=''
+
+# Version information for libjpeg.
+current=8
+age=0
+revision=2
+
+# Is this an already installed library?
+installed=yes
+
+# Should we warn about portability when linking against -modules?
+shouldnotlink=no
+
+# Files to dlopen/dlpreopen
+dlopen=''
+dlpreopen=''
+
+# Directory that this library needs to be installed in:
+libdir='/home/xonotic/dp.linux32/lib'
--- /dev/null
+# libmodplug.la - a libtool library file
+# Generated by ltmain.sh (GNU libtool) 2.2.6b
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname=''
+
+# Names of this library.
+library_names=''
+
+# The name of the static archive.
+old_library='libmodplug.a'
+
+# Linker flags that can not go in dependency_libs.
+inherited_linker_flags=''
+
+# Libraries that this one depends upon.
+dependency_libs=''
+
+# Names of additional weak libraries provided by this library
+weak_library_names=''
+
+# Version information for libmodplug.
+current=1
+age=0
+revision=0
+
+# Is this an already installed library?
+installed=yes
+
+# Should we warn about portability when linking against -modules?
+shouldnotlink=no
+
+# Files to dlopen/dlpreopen
+dlopen=''
+dlpreopen=''
+
+# Directory that this library needs to be installed in:
+libdir='/home/xonotic/dp.linux32/lib'
--- /dev/null
+prefix=/home/xonotic/dp.linux32
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: libmodplug
+Description: The ModPlug mod file playing library.
+Version: 0.8.8.1
+Requires:
+Libs: -L${libdir} -lmodplug
+Libs.private: -lstdc++ -lm
+Cflags: -I${includedir} -I${includedir}/libmodplug
--- /dev/null
+.TH CJPEG 1 "30 December 2009"
+.SH NAME
+cjpeg \- compress an image file to a JPEG file
+.SH SYNOPSIS
+.B cjpeg
+[
+.I options
+]
+[
+.I filename
+]
+.LP
+.SH DESCRIPTION
+.LP
+.B cjpeg
+compresses the named image file, or the standard input if no file is
+named, and produces a JPEG/JFIF file on the standard output.
+The currently supported input file formats are: PPM (PBMPLUS color
+format), PGM (PBMPLUS gray-scale format), BMP, Targa, and RLE (Utah Raster
+Toolkit format). (RLE is supported only if the URT library is available.)
+.SH OPTIONS
+All switch names may be abbreviated; for example,
+.B \-grayscale
+may be written
+.B \-gray
+or
+.BR \-gr .
+Most of the "basic" switches can be abbreviated to as little as one letter.
+Upper and lower case are equivalent (thus
+.B \-BMP
+is the same as
+.BR \-bmp ).
+British spellings are also accepted (e.g.,
+.BR \-greyscale ),
+though for brevity these are not mentioned below.
+.PP
+The basic switches are:
+.TP
+.BI \-quality " N[,...]"
+Scale quantization tables to adjust image quality. Quality is 0 (worst) to
+100 (best); default is 75. (See below for more info.)
+.TP
+.B \-grayscale
+Create monochrome JPEG file from color input. Be sure to use this switch when
+compressing a grayscale BMP file, because
+.B cjpeg
+isn't bright enough to notice whether a BMP file uses only shades of gray.
+By saying
+.BR \-grayscale ,
+you'll get a smaller JPEG file that takes less time to process.
+.TP
+.B \-optimize
+Perform optimization of entropy encoding parameters. Without this, default
+encoding parameters are used.
+.B \-optimize
+usually makes the JPEG file a little smaller, but
+.B cjpeg
+runs somewhat slower and needs much more memory. Image quality and speed of
+decompression are unaffected by
+.BR \-optimize .
+.TP
+.B \-progressive
+Create progressive JPEG file (see below).
+.TP
+.BI \-scale " M/N"
+Scale the output image by a factor M/N. Currently supported scale factors are
+8/N with all N from 1 to 16.
+.TP
+.B \-targa
+Input file is Targa format. Targa files that contain an "identification"
+field will not be automatically recognized by
+.BR cjpeg ;
+for such files you must specify
+.B \-targa
+to make
+.B cjpeg
+treat the input as Targa format.
+For most Targa files, you won't need this switch.
+.PP
+The
+.B \-quality
+switch lets you trade off compressed file size against quality of the
+reconstructed image: the higher the quality setting, the larger the JPEG file,
+and the closer the output image will be to the original input. Normally you
+want to use the lowest quality setting (smallest file) that decompresses into
+something visually indistinguishable from the original image. For this
+purpose the quality setting should be between 50 and 95; the default of 75 is
+often about right. If you see defects at
+.B \-quality
+75, then go up 5 or 10 counts at a time until you are happy with the output
+image. (The optimal setting will vary from one image to another.)
+.PP
+.B \-quality
+100 will generate a quantization table of all 1's, minimizing loss in the
+quantization step (but there is still information loss in subsampling, as well
+as roundoff error). This setting is mainly of interest for experimental
+purposes. Quality values above about 95 are
+.B not
+recommended for normal use; the compressed file size goes up dramatically for
+hardly any gain in output image quality.
+.PP
+In the other direction, quality values below 50 will produce very small files
+of low image quality. Settings around 5 to 10 might be useful in preparing an
+index of a large image library, for example. Try
+.B \-quality
+2 (or so) for some amusing Cubist effects. (Note: quality
+values below about 25 generate 2-byte quantization tables, which are
+considered optional in the JPEG standard.
+.B cjpeg
+emits a warning message when you give such a quality value, because some
+other JPEG programs may be unable to decode the resulting file. Use
+.B \-baseline
+if you need to ensure compatibility at low quality values.)
+.PP
+The
+.B \-quality
+option has been extended in IJG version 7 for support of separate quality
+settings for luminance and chrominance (or in general, for every provided
+quantization table slot). This feature is useful for high-quality
+applications which cannot accept the damage of color data by coarse
+subsampling settings. You can now easily reduce the color data amount more
+smoothly with finer control without separate subsampling. The resulting file
+is fully compliant with standard JPEG decoders.
+Note that the
+.B \-quality
+ratings refer to the quantization table slots, and that the last value is
+replicated if there are more q-table slots than parameters. The default
+q-table slots are 0 for luminance and 1 for chrominance with default tables as
+given in the JPEG standard. This is compatible with the old behaviour in case
+that only one parameter is given, which is then used for both luminance and
+chrominance (slots 0 and 1). More or custom quantization tables can be set
+with
+.B \-qtables
+and assigned to components with
+.B \-qslots
+parameter (see the "wizard" switches below).
+.B Caution:
+You must explicitly add
+.BI \-sample " 1x1"
+for efficient separate color
+quality selection, since the default value used by library is 2x2!
+.PP
+The
+.B \-progressive
+switch creates a "progressive JPEG" file. In this type of JPEG file, the data
+is stored in multiple scans of increasing quality. If the file is being
+transmitted over a slow communications link, the decoder can use the first
+scan to display a low-quality image very quickly, and can then improve the
+display with each subsequent scan. The final image is exactly equivalent to a
+standard JPEG file of the same quality setting, and the total file size is
+about the same --- often a little smaller.
+.PP
+Switches for advanced users:
+.TP
+.B \-dct int
+Use integer DCT method (default).
+.TP
+.B \-dct fast
+Use fast integer DCT (less accurate).
+.TP
+.B \-dct float
+Use floating-point DCT method.
+The float method is very slightly more accurate than the int method, but is
+much slower unless your machine has very fast floating-point hardware. Also
+note that results of the floating-point method may vary slightly across
+machines, while the integer methods should give the same results everywhere.
+The fast integer method is much less accurate than the other two.
+.TP
+.B \-nosmooth
+Don't use high-quality downsampling.
+.TP
+.BI \-restart " N"
+Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is
+attached to the number.
+.B \-restart 0
+(the default) means no restart markers.
+.TP
+.BI \-smooth " N"
+Smooth the input image to eliminate dithering noise. N, ranging from 1 to
+100, indicates the strength of smoothing. 0 (the default) means no smoothing.
+.TP
+.BI \-maxmemory " N"
+Set limit for amount of memory to use in processing large images. Value is
+in thousands of bytes, or millions of bytes if "M" is attached to the
+number. For example,
+.B \-max 4m
+selects 4000000 bytes. If more space is needed, temporary files will be used.
+.TP
+.BI \-outfile " name"
+Send output image to the named file, not to standard output.
+.TP
+.B \-verbose
+Enable debug printout. More
+.BR \-v 's
+give more output. Also, version information is printed at startup.
+.TP
+.B \-debug
+Same as
+.BR \-verbose .
+.PP
+The
+.B \-restart
+option inserts extra markers that allow a JPEG decoder to resynchronize after
+a transmission error. Without restart markers, any damage to a compressed
+file will usually ruin the image from the point of the error to the end of the
+image; with restart markers, the damage is usually confined to the portion of
+the image up to the next restart marker. Of course, the restart markers
+occupy extra space. We recommend
+.B \-restart 1
+for images that will be transmitted across unreliable networks such as Usenet.
+.PP
+The
+.B \-smooth
+option filters the input to eliminate fine-scale noise. This is often useful
+when converting dithered images to JPEG: a moderate smoothing factor of 10 to
+50 gets rid of dithering patterns in the input file, resulting in a smaller
+JPEG file and a better-looking image. Too large a smoothing factor will
+visibly blur the image, however.
+.PP
+Switches for wizards:
+.TP
+.B \-arithmetic
+Use arithmetic coding.
+.B Caution:
+arithmetic coded JPEG is not yet widely implemented, so many decoders will be
+unable to view an arithmetic coded JPEG file at all.
+.TP
+.B \-baseline
+Force baseline-compatible quantization tables to be generated. This clamps
+quantization values to 8 bits even at low quality settings. (This switch is
+poorly named, since it does not ensure that the output is actually baseline
+JPEG. For example, you can use
+.B \-baseline
+and
+.B \-progressive
+together.)
+.TP
+.BI \-qtables " file"
+Use the quantization tables given in the specified text file.
+.TP
+.BI \-qslots " N[,...]"
+Select which quantization table to use for each color component.
+.TP
+.BI \-sample " HxV[,...]"
+Set JPEG sampling factors for each color component.
+.TP
+.BI \-scans " file"
+Use the scan script given in the specified text file.
+.PP
+The "wizard" switches are intended for experimentation with JPEG. If you
+don't know what you are doing, \fBdon't use them\fR. These switches are
+documented further in the file wizard.txt.
+.SH EXAMPLES
+.LP
+This example compresses the PPM file foo.ppm with a quality factor of
+60 and saves the output as foo.jpg:
+.IP
+.B cjpeg \-quality
+.I 60 foo.ppm
+.B >
+.I foo.jpg
+.SH HINTS
+Color GIF files are not the ideal input for JPEG; JPEG is really intended for
+compressing full-color (24-bit) images. In particular, don't try to convert
+cartoons, line drawings, and other images that have only a few distinct
+colors. GIF works great on these, JPEG does not. If you want to convert a
+GIF to JPEG, you should experiment with
+.BR cjpeg 's
+.B \-quality
+and
+.B \-smooth
+options to get a satisfactory conversion.
+.B \-smooth 10
+or so is often helpful.
+.PP
+Avoid running an image through a series of JPEG compression/decompression
+cycles. Image quality loss will accumulate; after ten or so cycles the image
+may be noticeably worse than it was after one cycle. It's best to use a
+lossless format while manipulating an image, then convert to JPEG format when
+you are ready to file the image away.
+.PP
+The
+.B \-optimize
+option to
+.B cjpeg
+is worth using when you are making a "final" version for posting or archiving.
+It's also a win when you are using low quality settings to make very small
+JPEG files; the percentage improvement is often a lot more than it is on
+larger files. (At present,
+.B \-optimize
+mode is always selected when generating progressive JPEG files.)
+.SH ENVIRONMENT
+.TP
+.B JPEGMEM
+If this environment variable is set, its value is the default memory limit.
+The value is specified as described for the
+.B \-maxmemory
+switch.
+.B JPEGMEM
+overrides the default value specified when the program was compiled, and
+itself is overridden by an explicit
+.BR \-maxmemory .
+.SH SEE ALSO
+.BR djpeg (1),
+.BR jpegtran (1),
+.BR rdjpgcom (1),
+.BR wrjpgcom (1)
+.br
+.BR ppm (5),
+.BR pgm (5)
+.br
+Wallace, Gregory K. "The JPEG Still Picture Compression Standard",
+Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
+.SH AUTHOR
+Independent JPEG Group
+.SH BUGS
+GIF input files are no longer supported, to avoid the Unisys LZW patent.
+(Conversion of GIF files to JPEG is usually a bad idea anyway.)
+.PP
+Not all variants of BMP and Targa file formats are supported.
+.PP
+The
+.B \-targa
+switch is not a bug, it's a feature. (It would be a bug if the Targa format
+designers had not been clueless.)
--- /dev/null
+.TH DJPEG 1 "3 October 2009"
+.SH NAME
+djpeg \- decompress a JPEG file to an image file
+.SH SYNOPSIS
+.B djpeg
+[
+.I options
+]
+[
+.I filename
+]
+.LP
+.SH DESCRIPTION
+.LP
+.B djpeg
+decompresses the named JPEG file, or the standard input if no file is named,
+and produces an image file on the standard output. PBMPLUS (PPM/PGM), BMP,
+GIF, Targa, or RLE (Utah Raster Toolkit) output format can be selected.
+(RLE is supported only if the URT library is available.)
+.SH OPTIONS
+All switch names may be abbreviated; for example,
+.B \-grayscale
+may be written
+.B \-gray
+or
+.BR \-gr .
+Most of the "basic" switches can be abbreviated to as little as one letter.
+Upper and lower case are equivalent (thus
+.B \-BMP
+is the same as
+.BR \-bmp ).
+British spellings are also accepted (e.g.,
+.BR \-greyscale ),
+though for brevity these are not mentioned below.
+.PP
+The basic switches are:
+.TP
+.BI \-colors " N"
+Reduce image to at most N colors. This reduces the number of colors used in
+the output image, so that it can be displayed on a colormapped display or
+stored in a colormapped file format. For example, if you have an 8-bit
+display, you'd need to reduce to 256 or fewer colors.
+.TP
+.BI \-quantize " N"
+Same as
+.BR \-colors .
+.B \-colors
+is the recommended name,
+.B \-quantize
+is provided only for backwards compatibility.
+.TP
+.B \-fast
+Select recommended processing options for fast, low quality output. (The
+default options are chosen for highest quality output.) Currently, this is
+equivalent to \fB\-dct fast \-nosmooth \-onepass \-dither ordered\fR.
+.TP
+.B \-grayscale
+Force gray-scale output even if JPEG file is color. Useful for viewing on
+monochrome displays; also,
+.B djpeg
+runs noticeably faster in this mode.
+.TP
+.BI \-scale " M/N"
+Scale the output image by a factor M/N. Currently supported scale factors are
+M/N with all M from 1 to 16, where N is the source DCT size, which is 8 for
+baseline JPEG. If the /N part is omitted, then M specifies the DCT scaled
+size to be applied on the given input. For baseline JPEG this is equivalent
+to M/8 scaling, since the source DCT size for baseline JPEG is 8.
+Scaling is handy if the image is larger than your screen; also,
+.B djpeg
+runs much faster when scaling down the output.
+.TP
+.B \-bmp
+Select BMP output format (Windows flavor). 8-bit colormapped format is
+emitted if
+.B \-colors
+or
+.B \-grayscale
+is specified, or if the JPEG file is gray-scale; otherwise, 24-bit full-color
+format is emitted.
+.TP
+.B \-gif
+Select GIF output format. Since GIF does not support more than 256 colors,
+.B \-colors 256
+is assumed (unless you specify a smaller number of colors).
+.TP
+.B \-os2
+Select BMP output format (OS/2 1.x flavor). 8-bit colormapped format is
+emitted if
+.B \-colors
+or
+.B \-grayscale
+is specified, or if the JPEG file is gray-scale; otherwise, 24-bit full-color
+format is emitted.
+.TP
+.B \-pnm
+Select PBMPLUS (PPM/PGM) output format (this is the default format).
+PGM is emitted if the JPEG file is gray-scale or if
+.B \-grayscale
+is specified; otherwise PPM is emitted.
+.TP
+.B \-rle
+Select RLE output format. (Requires URT library.)
+.TP
+.B \-targa
+Select Targa output format. Gray-scale format is emitted if the JPEG file is
+gray-scale or if
+.B \-grayscale
+is specified; otherwise, colormapped format is emitted if
+.B \-colors
+is specified; otherwise, 24-bit full-color format is emitted.
+.PP
+Switches for advanced users:
+.TP
+.B \-dct int
+Use integer DCT method (default).
+.TP
+.B \-dct fast
+Use fast integer DCT (less accurate).
+.TP
+.B \-dct float
+Use floating-point DCT method.
+The float method is very slightly more accurate than the int method, but is
+much slower unless your machine has very fast floating-point hardware. Also
+note that results of the floating-point method may vary slightly across
+machines, while the integer methods should give the same results everywhere.
+The fast integer method is much less accurate than the other two.
+.TP
+.B \-dither fs
+Use Floyd-Steinberg dithering in color quantization.
+.TP
+.B \-dither ordered
+Use ordered dithering in color quantization.
+.TP
+.B \-dither none
+Do not use dithering in color quantization.
+By default, Floyd-Steinberg dithering is applied when quantizing colors; this
+is slow but usually produces the best results. Ordered dither is a compromise
+between speed and quality; no dithering is fast but usually looks awful. Note
+that these switches have no effect unless color quantization is being done.
+Ordered dither is only available in
+.B \-onepass
+mode.
+.TP
+.BI \-map " file"
+Quantize to the colors used in the specified image file. This is useful for
+producing multiple files with identical color maps, or for forcing a
+predefined set of colors to be used. The
+.I file
+must be a GIF or PPM file. This option overrides
+.B \-colors
+and
+.BR \-onepass .
+.TP
+.B \-nosmooth
+Don't use high-quality upsampling.
+.TP
+.B \-onepass
+Use one-pass instead of two-pass color quantization. The one-pass method is
+faster and needs less memory, but it produces a lower-quality image.
+.B \-onepass
+is ignored unless you also say
+.B \-colors
+.IR N .
+Also, the one-pass method is always used for gray-scale output (the two-pass
+method is no improvement then).
+.TP
+.BI \-maxmemory " N"
+Set limit for amount of memory to use in processing large images. Value is
+in thousands of bytes, or millions of bytes if "M" is attached to the
+number. For example,
+.B \-max 4m
+selects 4000000 bytes. If more space is needed, temporary files will be used.
+.TP
+.BI \-outfile " name"
+Send output image to the named file, not to standard output.
+.TP
+.B \-verbose
+Enable debug printout. More
+.BR \-v 's
+give more output. Also, version information is printed at startup.
+.TP
+.B \-debug
+Same as
+.BR \-verbose .
+.SH EXAMPLES
+.LP
+This example decompresses the JPEG file foo.jpg, quantizes it to
+256 colors, and saves the output in 8-bit BMP format in foo.bmp:
+.IP
+.B djpeg \-colors 256 \-bmp
+.I foo.jpg
+.B >
+.I foo.bmp
+.SH HINTS
+To get a quick preview of an image, use the
+.B \-grayscale
+and/or
+.B \-scale
+switches.
+.B \-grayscale \-scale 1/8
+is the fastest case.
+.PP
+Several options are available that trade off image quality to gain speed.
+.B \-fast
+turns on the recommended settings.
+.PP
+.B \-dct fast
+and/or
+.B \-nosmooth
+gain speed at a small sacrifice in quality.
+When producing a color-quantized image,
+.B \-onepass \-dither ordered
+is fast but much lower quality than the default behavior.
+.B \-dither none
+may give acceptable results in two-pass mode, but is seldom tolerable in
+one-pass mode.
+.PP
+If you are fortunate enough to have very fast floating point hardware,
+\fB\-dct float\fR may be even faster than \fB\-dct fast\fR. But on most
+machines \fB\-dct float\fR is slower than \fB\-dct int\fR; in this case it is
+not worth using, because its theoretical accuracy advantage is too small to be
+significant in practice.
+.SH ENVIRONMENT
+.TP
+.B JPEGMEM
+If this environment variable is set, its value is the default memory limit.
+The value is specified as described for the
+.B \-maxmemory
+switch.
+.B JPEGMEM
+overrides the default value specified when the program was compiled, and
+itself is overridden by an explicit
+.BR \-maxmemory .
+.SH SEE ALSO
+.BR cjpeg (1),
+.BR jpegtran (1),
+.BR rdjpgcom (1),
+.BR wrjpgcom (1)
+.br
+.BR ppm (5),
+.BR pgm (5)
+.br
+Wallace, Gregory K. "The JPEG Still Picture Compression Standard",
+Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
+.SH AUTHOR
+Independent JPEG Group
+.SH BUGS
+To avoid the Unisys LZW patent,
+.B djpeg
+produces uncompressed GIF files. These are larger than they should be, but
+are readable by standard GIF decoders.
--- /dev/null
+.TH JPEGTRAN 1 "28 December 2009"
+.SH NAME
+jpegtran \- lossless transformation of JPEG files
+.SH SYNOPSIS
+.B jpegtran
+[
+.I options
+]
+[
+.I filename
+]
+.LP
+.SH DESCRIPTION
+.LP
+.B jpegtran
+performs various useful transformations of JPEG files.
+It can translate the coded representation from one variant of JPEG to another,
+for example from baseline JPEG to progressive JPEG or vice versa. It can also
+perform some rearrangements of the image data, for example turning an image
+from landscape to portrait format by rotation.
+.PP
+.B jpegtran
+works by rearranging the compressed data (DCT coefficients), without
+ever fully decoding the image. Therefore, its transformations are lossless:
+there is no image degradation at all, which would not be true if you used
+.B djpeg
+followed by
+.B cjpeg
+to accomplish the same conversion. But by the same token,
+.B jpegtran
+cannot perform lossy operations such as changing the image quality.
+.PP
+.B jpegtran
+reads the named JPEG/JFIF file, or the standard input if no file is
+named, and produces a JPEG/JFIF file on the standard output.
+.SH OPTIONS
+All switch names may be abbreviated; for example,
+.B \-optimize
+may be written
+.B \-opt
+or
+.BR \-o .
+Upper and lower case are equivalent.
+British spellings are also accepted (e.g.,
+.BR \-optimise ),
+though for brevity these are not mentioned below.
+.PP
+To specify the coded JPEG representation used in the output file,
+.B jpegtran
+accepts a subset of the switches recognized by
+.BR cjpeg :
+.TP
+.B \-optimize
+Perform optimization of entropy encoding parameters.
+.TP
+.B \-progressive
+Create progressive JPEG file.
+.TP
+.BI \-restart " N"
+Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is
+attached to the number.
+.TP
+.B \-arithmetic
+Use arithmetic coding.
+.TP
+.BI \-scans " file"
+Use the scan script given in the specified text file.
+.PP
+See
+.BR cjpeg (1)
+for more details about these switches.
+If you specify none of these switches, you get a plain baseline-JPEG output
+file. The quality setting and so forth are determined by the input file.
+.PP
+The image can be losslessly transformed by giving one of these switches:
+.TP
+.B \-flip horizontal
+Mirror image horizontally (left-right).
+.TP
+.B \-flip vertical
+Mirror image vertically (top-bottom).
+.TP
+.B \-rotate 90
+Rotate image 90 degrees clockwise.
+.TP
+.B \-rotate 180
+Rotate image 180 degrees.
+.TP
+.B \-rotate 270
+Rotate image 270 degrees clockwise (or 90 ccw).
+.TP
+.B \-transpose
+Transpose image (across UL-to-LR axis).
+.TP
+.B \-transverse
+Transverse transpose (across UR-to-LL axis).
+.IP
+The transpose transformation has no restrictions regarding image dimensions.
+The other transformations operate rather oddly if the image dimensions are not
+a multiple of the iMCU size (usually 8 or 16 pixels), because they can only
+transform complete blocks of DCT coefficient data in the desired way.
+.IP
+.BR jpegtran 's
+default behavior when transforming an odd-size image is designed
+to preserve exact reversibility and mathematical consistency of the
+transformation set. As stated, transpose is able to flip the entire image
+area. Horizontal mirroring leaves any partial iMCU column at the right edge
+untouched, but is able to flip all rows of the image. Similarly, vertical
+mirroring leaves any partial iMCU row at the bottom edge untouched, but is
+able to flip all columns. The other transforms can be built up as sequences
+of transpose and flip operations; for consistency, their actions on edge
+pixels are defined to be the same as the end result of the corresponding
+transpose-and-flip sequence.
+.IP
+For practical use, you may prefer to discard any untransformable edge pixels
+rather than having a strange-looking strip along the right and/or bottom edges
+of a transformed image. To do this, add the
+.B \-trim
+switch:
+.TP
+.B \-trim
+Drop non-transformable edge blocks.
+.IP
+Obviously, a transformation with
+.B \-trim
+is not reversible, so strictly speaking
+.B jpegtran
+with this switch is not lossless. Also, the expected mathematical
+equivalences between the transformations no longer hold. For example,
+.B \-rot 270 -trim
+trims only the bottom edge, but
+.B \-rot 90 -trim
+followed by
+.B \-rot 180 -trim
+trims both edges.
+.IP
+If you are only interested in perfect transformation, add the
+.B \-perfect
+switch:
+.TP
+.B \-perfect
+Fails with an error if the transformation is not perfect.
+.IP
+For example you may want to do
+.IP
+.B (jpegtran \-rot 90 -perfect
+.I foo.jpg
+.B || djpeg
+.I foo.jpg
+.B | pnmflip \-r90 | cjpeg)
+.IP
+to do a perfect rotation if available or an approximated one if not.
+.PP
+We also offer a lossless-crop option, which discards data outside a given
+image region but losslessly preserves what is inside. Like the rotate and
+flip transforms, lossless crop is restricted by the current JPEG format: the
+upper left corner of the selected region must fall on an iMCU boundary. If
+this does not hold for the given crop parameters, we silently move the upper
+left corner up and/or left to make it so, simultaneously increasing the region
+dimensions to keep the lower right crop corner unchanged. (Thus, the output
+image covers at least the requested region, but may cover more.)
+
+The image can be losslessly cropped by giving the switch:
+.TP
+.B \-crop WxH+X+Y
+Crop to a rectangular subarea of width W, height H starting at point X,Y.
+.PP
+Other not-strictly-lossless transformation switches are:
+.TP
+.B \-grayscale
+Force grayscale output.
+.IP
+This option discards the chrominance channels if the input image is YCbCr
+(ie, a standard color JPEG), resulting in a grayscale JPEG file. The
+luminance channel is preserved exactly, so this is a better method of reducing
+to grayscale than decompression, conversion, and recompression. This switch
+is particularly handy for fixing a monochrome picture that was mistakenly
+encoded as a color JPEG. (In such a case, the space savings from getting rid
+of the near-empty chroma channels won't be large; but the decoding time for
+a grayscale JPEG is substantially less than that for a color JPEG.)
+.TP
+.BI \-scale " M/N"
+Scale the output image by a factor M/N.
+.IP
+Currently supported scale factors are M/N with all M from 1 to 16, where N is
+the source DCT size, which is 8 for baseline JPEG. If the /N part is omitted,
+then M specifies the DCT scaled size to be applied on the given input. For
+baseline JPEG this is equivalent to M/8 scaling, since the source DCT size
+for baseline JPEG is 8.
+.B Caution:
+An implementation of the JPEG SmartScale extension is required for this
+feature. SmartScale enabled JPEG is not yet widely implemented, so many
+decoders will be unable to view a SmartScale extended JPEG file at all.
+.PP
+.B jpegtran
+also recognizes these switches that control what to do with "extra" markers,
+such as comment blocks:
+.TP
+.B \-copy none
+Copy no extra markers from source file. This setting suppresses all
+comments and other excess baggage present in the source file.
+.TP
+.B \-copy comments
+Copy only comment markers. This setting copies comments from the source file,
+but discards any other inessential (for image display) data.
+.TP
+.B \-copy all
+Copy all extra markers. This setting preserves miscellaneous markers
+found in the source file, such as JFIF thumbnails, Exif data, and Photoshop
+settings. In some files these extra markers can be sizable.
+.IP
+The default behavior is
+.BR "\-copy comments" .
+(Note: in IJG releases v6 and v6a,
+.B jpegtran
+always did the equivalent of
+.BR "\-copy none" .)
+.PP
+Additional switches recognized by jpegtran are:
+.TP
+.BI \-maxmemory " N"
+Set limit for amount of memory to use in processing large images. Value is
+in thousands of bytes, or millions of bytes if "M" is attached to the
+number. For example,
+.B \-max 4m
+selects 4000000 bytes. If more space is needed, temporary files will be used.
+.TP
+.BI \-outfile " name"
+Send output image to the named file, not to standard output.
+.TP
+.B \-verbose
+Enable debug printout. More
+.BR \-v 's
+give more output. Also, version information is printed at startup.
+.TP
+.B \-debug
+Same as
+.BR \-verbose .
+.SH EXAMPLES
+.LP
+This example converts a baseline JPEG file to progressive form:
+.IP
+.B jpegtran \-progressive
+.I foo.jpg
+.B >
+.I fooprog.jpg
+.PP
+This example rotates an image 90 degrees clockwise, discarding any
+unrotatable edge pixels:
+.IP
+.B jpegtran \-rot 90 -trim
+.I foo.jpg
+.B >
+.I foo90.jpg
+.SH ENVIRONMENT
+.TP
+.B JPEGMEM
+If this environment variable is set, its value is the default memory limit.
+The value is specified as described for the
+.B \-maxmemory
+switch.
+.B JPEGMEM
+overrides the default value specified when the program was compiled, and
+itself is overridden by an explicit
+.BR \-maxmemory .
+.SH SEE ALSO
+.BR cjpeg (1),
+.BR djpeg (1),
+.BR rdjpgcom (1),
+.BR wrjpgcom (1)
+.br
+Wallace, Gregory K. "The JPEG Still Picture Compression Standard",
+Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
+.SH AUTHOR
+Independent JPEG Group
+.SH BUGS
+The transform options can't transform odd-size images perfectly. Use
+.B \-trim
+or
+.B \-perfect
+if you don't like the results.
+.PP
+The entire image is read into memory and then written out again, even in
+cases where this isn't really necessary. Expect swapping on large images,
+especially when using the more complex transform options.
--- /dev/null
+.TH RDJPGCOM 1 "02 April 2009"
+.SH NAME
+rdjpgcom \- display text comments from a JPEG file
+.SH SYNOPSIS
+.B rdjpgcom
+[
+.B \-raw
+]
+[
+.B \-verbose
+]
+[
+.I filename
+]
+.LP
+.SH DESCRIPTION
+.LP
+.B rdjpgcom
+reads the named JPEG/JFIF file, or the standard input if no file is named,
+and prints any text comments found in the file on the standard output.
+.PP
+The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file.
+Although the standard doesn't actually define what COM blocks are for, they
+are widely used to hold user-supplied text strings. This lets you add
+annotations, titles, index terms, etc to your JPEG files, and later retrieve
+them as text. COM blocks do not interfere with the image stored in the JPEG
+file. The maximum size of a COM block is 64K, but you can have as many of
+them as you like in one JPEG file.
+.SH OPTIONS
+.TP
+.B \-raw
+Normally
+.B rdjpgcom
+escapes non-printable characters in comments, for security reasons.
+This option avoids that.
+.PP
+.B \-verbose
+Causes
+.B rdjpgcom
+to also display the JPEG image dimensions.
+.PP
+Switch names may be abbreviated, and are not case sensitive.
+.SH HINTS
+.B rdjpgcom
+does not depend on the IJG JPEG library. Its source code is intended as an
+illustration of the minimum amount of code required to parse a JPEG file
+header correctly.
+.PP
+In
+.B \-verbose
+mode,
+.B rdjpgcom
+will also attempt to print the contents of any "APP12" markers as text.
+Some digital cameras produce APP12 markers containing useful textual
+information. If you like, you can modify the source code to print
+other APPn marker types as well.
+.SH SEE ALSO
+.BR cjpeg (1),
+.BR djpeg (1),
+.BR jpegtran (1),
+.BR wrjpgcom (1)
+.SH AUTHOR
+Independent JPEG Group
--- /dev/null
+.TH WRJPGCOM 1 "15 June 1995"
+.SH NAME
+wrjpgcom \- insert text comments into a JPEG file
+.SH SYNOPSIS
+.B wrjpgcom
+[
+.B \-replace
+]
+[
+.BI \-comment " text"
+]
+[
+.BI \-cfile " name"
+]
+[
+.I filename
+]
+.LP
+.SH DESCRIPTION
+.LP
+.B wrjpgcom
+reads the named JPEG/JFIF file, or the standard input if no file is named,
+and generates a new JPEG/JFIF file on standard output. A comment block is
+added to the file.
+.PP
+The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file.
+Although the standard doesn't actually define what COM blocks are for, they
+are widely used to hold user-supplied text strings. This lets you add
+annotations, titles, index terms, etc to your JPEG files, and later retrieve
+them as text. COM blocks do not interfere with the image stored in the JPEG
+file. The maximum size of a COM block is 64K, but you can have as many of
+them as you like in one JPEG file.
+.PP
+.B wrjpgcom
+adds a COM block, containing text you provide, to a JPEG file.
+Ordinarily, the COM block is added after any existing COM blocks; but you
+can delete the old COM blocks if you wish.
+.SH OPTIONS
+Switch names may be abbreviated, and are not case sensitive.
+.TP
+.B \-replace
+Delete any existing COM blocks from the file.
+.TP
+.BI \-comment " text"
+Supply text for new COM block on command line.
+.TP
+.BI \-cfile " name"
+Read text for new COM block from named file.
+.PP
+If you have only one line of comment text to add, you can provide it on the
+command line with
+.BR \-comment .
+The comment text must be surrounded with quotes so that it is treated as a
+single argument. Longer comments can be read from a text file.
+.PP
+If you give neither
+.B \-comment
+nor
+.BR \-cfile ,
+then
+.B wrjpgcom
+will read the comment text from standard input. (In this case an input image
+file name MUST be supplied, so that the source JPEG file comes from somewhere
+else.) You can enter multiple lines, up to 64KB worth. Type an end-of-file
+indicator (usually control-D) to terminate the comment text entry.
+.PP
+.B wrjpgcom
+will not add a COM block if the provided comment string is empty. Therefore
+\fB\-replace \-comment ""\fR can be used to delete all COM blocks from a file.
+.SH EXAMPLES
+.LP
+Add a short comment to in.jpg, producing out.jpg:
+.IP
+.B wrjpgcom \-c
+\fI"View of my back yard" in.jpg
+.B >
+.I out.jpg
+.PP
+Attach a long comment previously stored in comment.txt:
+.IP
+.B wrjpgcom
+.I in.jpg
+.B <
+.I comment.txt
+.B >
+.I out.jpg
+.PP
+or equivalently
+.IP
+.B wrjpgcom
+.B -cfile
+.I comment.txt
+.B <
+.I in.jpg
+.B >
+.I out.jpg
+.SH SEE ALSO
+.BR cjpeg (1),
+.BR djpeg (1),
+.BR jpegtran (1),
+.BR rdjpgcom (1)
+.SH AUTHOR
+Independent JPEG Group