1 diff -up8 jchuff.c jchuff.c
2 --- jchuff.c 2012-12-30 21:42:18 -0500
3 +++ jchuff.c 2013-02-16 19:37:01 -0500
10 #include "jchuff.h" /* Declarations shared with jcphuff.c */
13 -static unsigned char jpeg_nbits_table[65536];
14 -static int jpeg_nbits_table_init = 0;
15 +static const unsigned char jpeg_nbits_table[65536] = {
16 +/* Number i needs jpeg_nbits_table[i] bits to be represented. */
17 +#include "jpeg_nbits_table.h"
21 #define min(a,b) ((a)<(b)?(a):(b))
25 /* Expanded entropy encoder object for Huffman encoding.
27 @@ -266,25 +268,16 @@ jpeg_make_c_derived_tbl (j_compress_ptr
29 for (p = 0; p < lastp; p++) {
31 if (i < 0 || i > maxsymbol || dtbl->ehufsi[i])
32 ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
33 dtbl->ehufco[i] = huffcode[p];
34 dtbl->ehufsi[i] = huffsize[p];
37 - if(!jpeg_nbits_table_init) {
38 - for(i = 0; i < 65536; i++) {
39 - int nbits = 0, temp = i;
40 - while (temp) {temp >>= 1; nbits++;}
41 - jpeg_nbits_table[i] = nbits;
43 - jpeg_nbits_table_init = 1;
48 /* Outputting bytes to the file */
50 /* Emit a byte, taking 'action' if must suspend. */
51 #define emit_byte(state,val,action) \
52 { *(state)->next_output_byte++ = (JOCTET) (val); \
53 diff -up8 jmorecfg.h jmorecfg.h
54 --- jmorecfg.h 2013-01-06 12:59:42 -0500
55 +++ jmorecfg.h 2013-02-16 19:37:01 -0500
57 * Copyright (C) 2009, 2011, D. R. Commander.
58 * For conditions of distribution and use, see the accompanying README file.
60 * This file contains additional configuration options that customize the
61 * JPEG software for special applications or support machine-dependent
62 * optimizations. Most users will not need to touch this file.
68 * Define BITS_IN_JSAMPLE as either
69 * 8 for 8-bit sample values (the usual setting)
70 * 12 for 12-bit sample values
71 * Only 8 and 12 are legal data precisions for lossy JPEG according to the
72 * JPEG standard, and the IJG code does not support anything else!
73 * We do not support run-time selection of data precision, sorry.
74 @@ -128,45 +129,29 @@ typedef char JOCTET;
75 * They must be at least as wide as specified; but making them too big
76 * won't cost a huge amount of memory, so we don't provide special
77 * extraction code like we did for JSAMPLE. (In other words, these
78 * typedefs live at a different point on the speed/space tradeoff curve.)
81 /* UINT8 must hold at least the values 0..255. */
83 -#ifdef HAVE_UNSIGNED_CHAR
84 -typedef unsigned char UINT8;
85 -#else /* not HAVE_UNSIGNED_CHAR */
86 -#ifdef __CHAR_UNSIGNED__
88 -#else /* not __CHAR_UNSIGNED__ */
90 -#endif /* __CHAR_UNSIGNED__ */
91 -#endif /* HAVE_UNSIGNED_CHAR */
92 +typedef uint8_t UINT8;
94 /* UINT16 must hold at least the values 0..65535. */
96 -#ifdef HAVE_UNSIGNED_SHORT
97 -typedef unsigned short UINT16;
98 -#else /* not HAVE_UNSIGNED_SHORT */
99 -typedef unsigned int UINT16;
100 -#endif /* HAVE_UNSIGNED_SHORT */
101 +typedef uint16_t UINT16;
103 /* INT16 must hold at least the values -32768..32767. */
105 -#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */
106 -typedef short INT16;
108 +typedef int16_t INT16;
110 /* INT32 must hold at least signed 32-bit values. */
112 -#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */
115 +typedef int32_t INT32;
117 /* Datatype used for image dimensions. The JPEG standard only supports
118 * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
119 * "unsigned int" is sufficient on all machines. However, if you need to
120 * handle larger images and you don't mind deviating from the spec, you
121 * can change this datatype.