|
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 |
|
4 @@ -17,18 +17,20 @@ |
|
5 */ |
|
6 |
|
7 #define JPEG_INTERNALS |
|
8 #include "jinclude.h" |
|
9 #include "jpeglib.h" |
|
10 #include "jchuff.h" /* Declarations shared with jcphuff.c */ |
|
11 #include <limits.h> |
|
12 |
|
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" |
|
18 +}; |
|
19 |
|
20 #ifndef min |
|
21 #define min(a,b) ((a)<(b)?(a):(b)) |
|
22 #endif |
|
23 |
|
24 |
|
25 /* Expanded entropy encoder object for Huffman encoding. |
|
26 * |
|
27 @@ -266,25 +268,16 @@ jpeg_make_c_derived_tbl (j_compress_ptr |
|
28 |
|
29 for (p = 0; p < lastp; p++) { |
|
30 i = htbl->huffval[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]; |
|
35 } |
|
36 - |
|
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; |
|
42 - } |
|
43 - jpeg_nbits_table_init = 1; |
|
44 - } |
|
45 } |
|
46 |
|
47 |
|
48 /* Outputting bytes to the file */ |
|
49 |
|
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 |
|
56 @@ -7,16 +7,17 @@ |
|
57 * Copyright (C) 2009, 2011, D. R. Commander. |
|
58 * For conditions of distribution and use, see the accompanying README file. |
|
59 * |
|
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. |
|
63 */ |
|
64 |
|
65 +#include <stdint.h> |
|
66 |
|
67 /* |
|
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.) |
|
79 */ |
|
80 |
|
81 /* UINT8 must hold at least the values 0..255. */ |
|
82 |
|
83 -#ifdef HAVE_UNSIGNED_CHAR |
|
84 -typedef unsigned char UINT8; |
|
85 -#else /* not HAVE_UNSIGNED_CHAR */ |
|
86 -#ifdef __CHAR_UNSIGNED__ |
|
87 -typedef char UINT8; |
|
88 -#else /* not __CHAR_UNSIGNED__ */ |
|
89 -typedef short UINT8; |
|
90 -#endif /* __CHAR_UNSIGNED__ */ |
|
91 -#endif /* HAVE_UNSIGNED_CHAR */ |
|
92 +typedef uint8_t UINT8; |
|
93 |
|
94 /* UINT16 must hold at least the values 0..65535. */ |
|
95 |
|
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; |
|
102 |
|
103 /* INT16 must hold at least the values -32768..32767. */ |
|
104 |
|
105 -#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ |
|
106 -typedef short INT16; |
|
107 -#endif |
|
108 +typedef int16_t INT16; |
|
109 |
|
110 /* INT32 must hold at least signed 32-bit values. */ |
|
111 |
|
112 -#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ |
|
113 -typedef long INT32; |
|
114 -#endif |
|
115 +typedef int32_t INT32; |
|
116 |
|
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. |
|
122 */ |
|
123 |