michael@0: diff -up8 jchuff.c jchuff.c michael@0: --- jchuff.c 2012-12-30 21:42:18 -0500 michael@0: +++ jchuff.c 2013-02-16 19:37:01 -0500 michael@0: @@ -17,18 +17,20 @@ michael@0: */ michael@0: michael@0: #define JPEG_INTERNALS michael@0: #include "jinclude.h" michael@0: #include "jpeglib.h" michael@0: #include "jchuff.h" /* Declarations shared with jcphuff.c */ michael@0: #include michael@0: michael@0: -static unsigned char jpeg_nbits_table[65536]; michael@0: -static int jpeg_nbits_table_init = 0; michael@0: +static const unsigned char jpeg_nbits_table[65536] = { michael@0: +/* Number i needs jpeg_nbits_table[i] bits to be represented. */ michael@0: +#include "jpeg_nbits_table.h" michael@0: +}; michael@0: michael@0: #ifndef min michael@0: #define min(a,b) ((a)<(b)?(a):(b)) michael@0: #endif michael@0: michael@0: michael@0: /* Expanded entropy encoder object for Huffman encoding. michael@0: * michael@0: @@ -266,25 +268,16 @@ jpeg_make_c_derived_tbl (j_compress_ptr michael@0: michael@0: for (p = 0; p < lastp; p++) { michael@0: i = htbl->huffval[p]; michael@0: if (i < 0 || i > maxsymbol || dtbl->ehufsi[i]) michael@0: ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); michael@0: dtbl->ehufco[i] = huffcode[p]; michael@0: dtbl->ehufsi[i] = huffsize[p]; michael@0: } michael@0: - michael@0: - if(!jpeg_nbits_table_init) { michael@0: - for(i = 0; i < 65536; i++) { michael@0: - int nbits = 0, temp = i; michael@0: - while (temp) {temp >>= 1; nbits++;} michael@0: - jpeg_nbits_table[i] = nbits; michael@0: - } michael@0: - jpeg_nbits_table_init = 1; michael@0: - } michael@0: } michael@0: michael@0: michael@0: /* Outputting bytes to the file */ michael@0: michael@0: /* Emit a byte, taking 'action' if must suspend. */ michael@0: #define emit_byte(state,val,action) \ michael@0: { *(state)->next_output_byte++ = (JOCTET) (val); \ michael@0: diff -up8 jmorecfg.h jmorecfg.h michael@0: --- jmorecfg.h 2013-01-06 12:59:42 -0500 michael@0: +++ jmorecfg.h 2013-02-16 19:37:01 -0500 michael@0: @@ -7,16 +7,17 @@ michael@0: * Copyright (C) 2009, 2011, D. R. Commander. michael@0: * For conditions of distribution and use, see the accompanying README file. michael@0: * michael@0: * This file contains additional configuration options that customize the michael@0: * JPEG software for special applications or support machine-dependent michael@0: * optimizations. Most users will not need to touch this file. michael@0: */ michael@0: michael@0: +#include michael@0: michael@0: /* michael@0: * Define BITS_IN_JSAMPLE as either michael@0: * 8 for 8-bit sample values (the usual setting) michael@0: * 12 for 12-bit sample values michael@0: * Only 8 and 12 are legal data precisions for lossy JPEG according to the michael@0: * JPEG standard, and the IJG code does not support anything else! michael@0: * We do not support run-time selection of data precision, sorry. michael@0: @@ -128,45 +129,29 @@ typedef char JOCTET; michael@0: * They must be at least as wide as specified; but making them too big michael@0: * won't cost a huge amount of memory, so we don't provide special michael@0: * extraction code like we did for JSAMPLE. (In other words, these michael@0: * typedefs live at a different point on the speed/space tradeoff curve.) michael@0: */ michael@0: michael@0: /* UINT8 must hold at least the values 0..255. */ michael@0: michael@0: -#ifdef HAVE_UNSIGNED_CHAR michael@0: -typedef unsigned char UINT8; michael@0: -#else /* not HAVE_UNSIGNED_CHAR */ michael@0: -#ifdef __CHAR_UNSIGNED__ michael@0: -typedef char UINT8; michael@0: -#else /* not __CHAR_UNSIGNED__ */ michael@0: -typedef short UINT8; michael@0: -#endif /* __CHAR_UNSIGNED__ */ michael@0: -#endif /* HAVE_UNSIGNED_CHAR */ michael@0: +typedef uint8_t UINT8; michael@0: michael@0: /* UINT16 must hold at least the values 0..65535. */ michael@0: michael@0: -#ifdef HAVE_UNSIGNED_SHORT michael@0: -typedef unsigned short UINT16; michael@0: -#else /* not HAVE_UNSIGNED_SHORT */ michael@0: -typedef unsigned int UINT16; michael@0: -#endif /* HAVE_UNSIGNED_SHORT */ michael@0: +typedef uint16_t UINT16; michael@0: michael@0: /* INT16 must hold at least the values -32768..32767. */ michael@0: michael@0: -#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ michael@0: -typedef short INT16; michael@0: -#endif michael@0: +typedef int16_t INT16; michael@0: michael@0: /* INT32 must hold at least signed 32-bit values. */ michael@0: michael@0: -#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ michael@0: -typedef long INT32; michael@0: -#endif michael@0: +typedef int32_t INT32; michael@0: michael@0: /* Datatype used for image dimensions. The JPEG standard only supports michael@0: * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore michael@0: * "unsigned int" is sufficient on all machines. However, if you need to michael@0: * handle larger images and you don't mind deviating from the spec, you michael@0: * can change this datatype. michael@0: */ michael@0: