From dfc34e56f7932089be4fc32715eb0d02073a73c8 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Sat, 7 Nov 2009 12:13:39 +0000 Subject: [PATCH] restoring old version of jpeg lib git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4706 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/include/jconfig.h | 4 +- source/include/jerror.h | 9 ++-- source/include/jmorecfg.h | 97 ++++++++++++++++++++++++++++++--------- source/include/jpeglib.h | 89 +++++++++++++++-------------------- 4 files changed, 118 insertions(+), 81 deletions(-) diff --git a/source/include/jconfig.h b/source/include/jconfig.h index 679404da..5cafaa25 100644 --- a/source/include/jconfig.h +++ b/source/include/jconfig.h @@ -1,5 +1,5 @@ -/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */ -/* see jconfig.txt for explanations */ +/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */ +/* see jconfig.doc for explanations */ #define HAVE_PROTOTYPES #define HAVE_UNSIGNED_CHAR diff --git a/source/include/jerror.h b/source/include/jerror.h index 1cfb2b19..fcdf6a83 100644 --- a/source/include/jerror.h +++ b/source/include/jerror.h @@ -2,7 +2,6 @@ * 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. * @@ -40,15 +39,17 @@ typedef enum { JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */ /* For maintenance convenience, list is alphabetical by message code name */ +JMESSAGE(JERR_ARITH_NOTIMPL, + "Sorry, there are legal restrictions on arithmetic coding") 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_DCTSIZE, "IDCT output block size %d not supported") JMESSAGE(JERR_BAD_DROP_SAMPLING, - "Component index %d: mismatching sampling ratio %d:%d, %d:%d, %c") + "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") @@ -95,7 +96,6 @@ 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") @@ -173,7 +173,6 @@ JMESSAGE(JTRC_UNKNOWN_IDS, 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, diff --git a/source/include/jmorecfg.h b/source/include/jmorecfg.h index a84a7ec3..f54191b0 100644 --- a/source/include/jmorecfg.h +++ b/source/include/jmorecfg.h @@ -2,7 +2,6 @@ * 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. * @@ -23,6 +22,11 @@ #define BITS_IN_JSAMPLE 8 /* use 8 or 12 */ +#if (defined (_MSC_VER) && (_MSC_VER >= 800)) +#define HAVE_UNSIGNED_CHAR +#define HAVE_ALL_INTS +#define EXTERN(type) extern type __cdecl +#endif /* * Maximum number of components (color channels) allowed in JPEG image. @@ -131,6 +135,7 @@ typedef char JOCTET; */ /* UINT8 must hold at least the values 0..255. */ +#ifndef HAVE_ALL_INTS #ifdef HAVE_UNSIGNED_CHAR typedef unsigned char UINT8; @@ -158,15 +163,11 @@ typedef short INT16; /* INT32 must hold at least signed 32-bit values. */ -#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ -#ifndef _BASETSD_H /* MinGW's basetsd.h */ -#ifndef _BASETSD_H_ /* Microsoft defines it in basetsd.h */ -#ifndef QGLOBAL_H /* Qt defines it in qglobal.h */ +#if !defined(XMD_H) && !defined(_WIN32) /* X11/xmd.h correctly defines INT32 */ typedef long INT32; #endif -#endif -#endif -#endif + +#endif /* HAVE_ALL_INTS */ /* Datatype used for image dimensions. The JPEG standard only supports * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore @@ -187,14 +188,63 @@ typedef unsigned int JDIMENSION; * or code profilers that require it. */ +#ifdef _WIN32 +# if defined(ALL_STATIC) +# if defined(JPEG_DLL) +# undef JPEG_DLL +# endif +# if !defined(JPEG_STATIC) +# define JPEG_STATIC +# endif +# endif +# if defined(JPEG_DLL) +# if defined(JPEG_STATIC) +# undef JPEG_STATIC +# endif +# endif +# if defined(JPEG_DLL) +/* building a DLL */ +# define JPEG_IMPEXP __declspec(dllexport) +# elif defined(JPEG_STATIC) +/* building or linking to a static library */ +# define JPEG_IMPEXP +# else +/* linking to the DLL */ +# define JPEG_IMPEXP __declspec(dllimport) +# endif +# if !defined(JPEG_API) +# define JPEG_API __cdecl +# endif +/* The only remaining magic that is necessary for cygwin */ +#elif defined(__CYGWIN__) +# if !defined(JPEG_IMPEXP) +# define JPEG_IMPEXP +# endif +# if !defined(JPEG_API) +# define JPEG_API __cdecl +# endif +#endif + +/* Ensure our magic doesn't hurt other platforms */ +#if !defined(JPEG_IMPEXP) +# define JPEG_IMPEXP +#endif +#if !defined(JPEG_API) +# define JPEG_API +#endif + /* a function called through method pointers: */ -#define METHODDEF(type) static type +#define METHODDEF(type) static type /* a function used only in its module: */ -#define LOCAL(type) static type +#define LOCAL(type) static type /* a function referenced thru EXTERNs: */ -#define GLOBAL(type) type +#define GLOBAL(type) type JPEG_API /* a reference to a GLOBAL function: */ -#define EXTERN(type) extern type +#ifndef EXTERN +# define EXTERN(type) extern JPEG_IMPEXP type JPEG_API +/* a reference to a "GLOBAL" function exported by sourcefiles of utility progs */ +#endif /* EXTERN */ +#define EXTERN_1(type) extern type JPEG_API /* This macro is used to declare a "method", that is, a function pointer. @@ -216,12 +266,16 @@ typedef unsigned int JDIMENSION; * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. */ +/* jmorecfg.h line 220 */ +/* HJH modification: several of the windows header files already define FAR + because of this, the code below was changed so that it only tinkers with + the FAR define if FAR is still undefined */ #ifndef FAR -#ifdef NEED_FAR_POINTERS -#define FAR far -#else -#define FAR -#endif + #ifdef NEED_FAR_POINTERS + #define FAR far + #else + #define FAR + #endif #endif @@ -265,6 +319,8 @@ typedef int boolean; * (You may HAVE to do that if your compiler doesn't like null source files.) */ +/* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */ + /* Capability options common to encoder and decoder: */ #define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ @@ -273,10 +329,9 @@ typedef int boolean; /* Encoder capability options: */ -#define C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ +#undef 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 @@ -290,12 +345,12 @@ typedef int boolean; /* Decoder capability options: */ -#define D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ +#undef 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) */ +#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ #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? */ diff --git a/source/include/jpeglib.h b/source/include/jpeglib.h index 341a19c9..e5fed222 100644 --- a/source/include/jpeglib.h +++ b/source/include/jpeglib.h @@ -2,7 +2,6 @@ * 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. * @@ -11,9 +10,21 @@ * and perhaps jerror.h if they want to know the exact error codes. */ + +typedef unsigned char UINT8; +typedef signed char INT8; +typedef unsigned short UINT16; +typedef short INT16; +typedef unsigned UINT32; +typedef int INT32; + #ifndef JPEGLIB_H #define JPEGLIB_H +#ifdef __cplusplus +extern "C" { +#endif + /* * First we include the configuration files that record how this * installation of the JPEG library is set up. jconfig.h can be @@ -26,18 +37,15 @@ #endif #include "jmorecfg.h" /* seldom changed options */ - #ifdef __cplusplus -#ifndef DONT_USE_EXTERN_C extern "C" { -#endif -#endif +#endif /* __cplusplus */ /* Version ID for the JPEG library. - * Might be useful for tests like "#if JPEG_LIB_VERSION >= 70". + * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". */ -#define JPEG_LIB_VERSION 70 /* Version 7.0 */ +#define JPEG_LIB_VERSION 62 /* Version 6b */ /* Various constants determining the sizes of things. @@ -92,7 +100,7 @@ typedef struct { * (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 */ + unsigned int 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. @@ -145,18 +153,18 @@ typedef struct { */ 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. + /* Size of a DCT block in samples. Always DCTSIZE for compression. + * For decompression this is the size of the output from one DCT block, + * reflecting any scaling we choose to apply during the IDCT step. + * Values of 1,2,4,8 are likely to be supported. Note that different + * components may receive different IDCT scalings. */ - int DCT_h_scaled_size; - int DCT_v_scaled_size; + int DCT_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. + * of samples at the main buffer (preprocessing/compression interface), thus + * downsampled_width = ceil(image_width * Hi/Hmax) + * and similarly for height. For decompression, IDCT scaling is included, so + * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE) */ JDIMENSION downsampled_width; /* actual width in samples */ JDIMENSION downsampled_height; /* actual height in samples */ @@ -298,17 +306,6 @@ struct jpeg_compress_struct { * 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 */ @@ -316,17 +313,14 @@ struct jpeg_compress_struct { 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). - */ - + /* 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 */ - + 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 */ @@ -342,7 +336,6 @@ struct jpeg_compress_struct { 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 */ @@ -386,9 +379,6 @@ struct jpeg_compress_struct { 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). @@ -600,8 +590,7 @@ struct jpeg_decompress_struct { 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 */ + int min_DCT_scaled_size; /* smallest DCT_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 @@ -609,7 +598,7 @@ struct jpeg_decompress_struct { * 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. + * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row. */ JSAMPLE * sample_range_limit; /* table for fast range-limiting */ @@ -867,7 +856,6 @@ typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo)); #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 @@ -877,7 +865,6 @@ typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo)); #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 @@ -949,8 +936,6 @@ EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality, 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, @@ -970,15 +955,12 @@ EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo, 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. */ +/* Write a special marker. See libjpeg.doc concerning safe usage. */ EXTERN(void) jpeg_write_marker JPP((j_compress_ptr cinfo, int marker, const JOCTET * dataptr, unsigned int datalen)); @@ -1113,6 +1095,9 @@ struct jpeg_color_quantizer { long dummy; }; #endif /* JPEG_INTERNALS */ #endif /* INCOMPLETE_TYPES_BROKEN */ +#ifdef __cplusplus +} +#endif /* * The JPEG library modules define JPEG_INTERNALS before including this file. @@ -1127,9 +1112,7 @@ struct jpeg_color_quantizer { long dummy; }; #endif #ifdef __cplusplus -#ifndef DONT_USE_EXTERN_C } #endif -#endif #endif /* JPEGLIB_H */