Line 0
Link Here
|
|
|
1 |
--- src/gif/lzw_enc.c.orig 2009-03-22 12:58:44.562353006 +0100 |
2 |
+++ src/gif/lzw_enc.c 2009-03-22 12:59:37.848069207 +0100 |
3 |
@@ -14,9 +14,9 @@ |
4 |
#include "config.h" |
5 |
|
6 |
#ifdef DEBUG |
7 |
-# define dprintf(x) jzp_printf x |
8 |
+# define dbprintf(x) jzp_printf x |
9 |
#else |
10 |
-# define dprintf(x) |
11 |
+# define dbprintf(x) |
12 |
#endif |
13 |
|
14 |
|
15 |
@@ -46,7 +46,7 @@ |
16 |
if (i_buf[i] > max_sym) |
17 |
max_sym = i_buf[i]; |
18 |
dict_stride = max_sym + 1; |
19 |
- dprintf(("max_sym = %.2X\n", max_sym)); |
20 |
+ dbprintf(("max_sym = %.2X\n", max_sym)); |
21 |
|
22 |
/* -------------------------------------------------------------------- */ |
23 |
/* Compute and output the starting code-size. */ |
24 |
@@ -54,7 +54,7 @@ |
25 |
for (code_size = 2; code_size < 8; code_size++) |
26 |
if ((1 << code_size) > max_sym) |
27 |
break; |
28 |
- dprintf(("code_size = %.2X\n", code_size)); |
29 |
+ dbprintf(("code_size = %.2X\n", code_size)); |
30 |
/* -------------------------------------------------------------------- */ |
31 |
/* Allocate the dictionary. We store the tree in a 2-D array. One */ |
32 |
/* dimension is the code number, and the other is the codes it chains */ |
33 |
@@ -89,7 +89,7 @@ |
34 |
/* -------------------------------------------------------------------- */ |
35 |
while (i_ptr <= i_end && code != end_of_info) |
36 |
{ |
37 |
- dprintf(("remaining: %10d\n", i_end - i_ptr)); |
38 |
+ dbprintf(("remaining: %10d\n", i_end - i_ptr)); |
39 |
|
40 |
/* ---------------------------------------------------------------- */ |
41 |
/* If dictionary's full, send a clear code and flush dictionary. */ |
42 |
@@ -97,7 +97,7 @@ |
43 |
/* ---------------------------------------------------------------- */ |
44 |
if (next_new_code == 0x1000) |
45 |
{ |
46 |
- dprintf(("CLEAR %.3X %d\n", clear_code, curr_size)); |
47 |
+ dbprintf(("CLEAR %.3X %d\n", clear_code, curr_size)); |
48 |
|
49 |
curr_word |= clear_code << curr_bits; |
50 |
curr_bits += curr_size; |
51 |
@@ -106,7 +106,7 @@ |
52 |
/* Handle packaging data into 256-byte records */ |
53 |
if (o_ptr - last_len_byte == 256) |
54 |
{ |
55 |
- dprintf(("last_len_byte=%.8X o_ptr=%.8X\n", |
56 |
+ dbprintf(("last_len_byte=%.8X o_ptr=%.8X\n", |
57 |
last_len_byte, o_ptr)); |
58 |
|
59 |
*last_len_byte = 255; |
60 |
@@ -125,7 +125,7 @@ |
61 |
memset(dict, 0, 4096*sizeof(uint_16)*dict_stride); |
62 |
} else |
63 |
{ |
64 |
- dprintf(("new code: %.3X = %.3X + %.2X\n", next_new_code, |
65 |
+ dbprintf(("new code: %.3X = %.3X + %.2X\n", next_new_code, |
66 |
code, next_char)); |
67 |
|
68 |
dict[code*dict_stride + next_char] = next_new_code; |
69 |
@@ -135,7 +135,7 @@ |
70 |
} |
71 |
|
72 |
code = next_char; /* Previous concat becomes new initial code */ |
73 |
- dprintf(("next code: %.2X %c\n", code, code == end_of_info ? '*':' ')); |
74 |
+ dbprintf(("next code: %.2X %c\n", code, code == end_of_info ? '*':' ')); |
75 |
|
76 |
/* ---------------------------------------------------------------- */ |
77 |
/* Keep concatenating as long as we stay in the dictionary. */ |
78 |
@@ -143,7 +143,7 @@ |
79 |
if (i_ptr == i_end) |
80 |
{ |
81 |
next_char = end_of_info; |
82 |
- dprintf(("--> next is EOI!\n")); |
83 |
+ dbprintf(("--> next is EOI!\n")); |
84 |
} else |
85 |
{ |
86 |
next_code = -1; |
87 |
@@ -151,7 +151,7 @@ |
88 |
{ |
89 |
next_char = *i_ptr++; |
90 |
next_code = dict[code*dict_stride + next_char]; |
91 |
- dprintf(("--> code: %.3X + %.2X = %.3X\n", code, |
92 |
+ dbprintf(("--> code: %.3X + %.2X = %.3X\n", code, |
93 |
next_char, next_code)); |
94 |
|
95 |
if (next_code) |
96 |
@@ -162,7 +162,7 @@ |
97 |
|
98 |
if (next_char == end_of_info) |
99 |
{ |
100 |
- dprintf(("--> next is EOI! (b)\n")); |
101 |
+ dbprintf(("--> next is EOI! (b)\n")); |
102 |
} |
103 |
} |
104 |
|
105 |
@@ -174,14 +174,14 @@ |
106 |
/* ---------------------------------------------------------------- */ |
107 |
curr_word |= code << curr_bits; |
108 |
curr_bits += curr_size; |
109 |
- dprintf(("SEND %.4X %d curr: %.8X %2d\n", code, curr_size, |
110 |
+ dbprintf(("SEND %.4X %d curr: %.8X %2d\n", code, curr_size, |
111 |
curr_word, curr_bits)); |
112 |
while (curr_bits > 8) |
113 |
{ |
114 |
/* Handle packaging data into 256-byte records */ |
115 |
if (o_ptr - last_len_byte == 256) |
116 |
{ |
117 |
- dprintf(("last_len_byte=%.8X o_ptr=%.8X\n", last_len_byte, |
118 |
+ dbprintf(("last_len_byte=%.8X o_ptr=%.8X\n", last_len_byte, |
119 |
o_ptr)); |
120 |
*last_len_byte = 255; |
121 |
last_len_byte = o_ptr++; |
122 |
@@ -203,7 +203,7 @@ |
123 |
/* Handle packaging data into 256-byte records */ |
124 |
if (o_ptr - last_len_byte == 256) |
125 |
{ |
126 |
- dprintf(("last_len_byte=%.8X o_ptr=%.8X\n", last_len_byte, o_ptr)); |
127 |
+ dbprintf(("last_len_byte=%.8X o_ptr=%.8X\n", last_len_byte, o_ptr)); |
128 |
*last_len_byte = 255; |
129 |
last_len_byte = o_ptr++; |
130 |
} |
131 |
@@ -223,7 +223,7 @@ |
132 |
*last_len_byte = o_ptr - last_len_byte - 1; |
133 |
*o_ptr++ = 0; |
134 |
|
135 |
- dprintf(("encoded %d bytes\n", o_ptr - o_buf)); |
136 |
+ dbprintf(("encoded %d bytes\n", o_ptr - o_buf)); |
137 |
|
138 |
return o_ptr - o_buf; |
139 |
|
140 |
@@ -232,11 +232,11 @@ |
141 |
} |
142 |
|
143 |
//#define DEBUG |
144 |
-#undef dprintf |
145 |
+#undef dbprintf |
146 |
#ifdef DEBUG |
147 |
-# define dprintf(x) jzp_printf x |
148 |
+# define dbprintf(x) jzp_printf x |
149 |
#else |
150 |
-# define dprintf(x) |
151 |
+# define dbprintf(x) |
152 |
#endif |
153 |
|
154 |
int lzw_encode2(const uint_8 *i_buf, const uint_8 *i_buf_alt, |
155 |
@@ -270,7 +270,7 @@ |
156 |
} |
157 |
|
158 |
dict_stride = max_sym + 1; |
159 |
- dprintf(("max_sym = %.2X\n", max_sym)); |
160 |
+ dbprintf(("max_sym = %.2X\n", max_sym)); |
161 |
|
162 |
/* -------------------------------------------------------------------- */ |
163 |
/* Compute and output the starting code-size. */ |
164 |
@@ -278,7 +278,7 @@ |
165 |
for (code_size = 2; code_size < 8; code_size++) |
166 |
if ((1 << code_size) > max_sym) |
167 |
break; |
168 |
- dprintf(("code_size = %.2X\n", code_size)); |
169 |
+ dbprintf(("code_size = %.2X\n", code_size)); |
170 |
/* -------------------------------------------------------------------- */ |
171 |
/* Allocate the dictionary. We store the tree in a 2-D array. One */ |
172 |
/* dimension is the code number, and the other is the codes it chains */ |
173 |
@@ -312,7 +312,7 @@ |
174 |
/* -------------------------------------------------------------------- */ |
175 |
while (i_idx <= i_len && code != end_of_info) |
176 |
{ |
177 |
- dprintf(("remaining: %10d\n", i_len - i_idx)); |
178 |
+ dbprintf(("remaining: %10d\n", i_len - i_idx)); |
179 |
|
180 |
/* ---------------------------------------------------------------- */ |
181 |
/* If dictionary's full, send a clear code and flush dictionary. */ |
182 |
@@ -320,7 +320,7 @@ |
183 |
/* ---------------------------------------------------------------- */ |
184 |
if (next_new_code == 0x1000) |
185 |
{ |
186 |
- dprintf(("CLEAR %.3X %d\n", clear_code, curr_size)); |
187 |
+ dbprintf(("CLEAR %.3X %d\n", clear_code, curr_size)); |
188 |
|
189 |
curr_word |= clear_code << curr_bits; |
190 |
curr_bits += curr_size; |
191 |
@@ -329,7 +329,7 @@ |
192 |
/* Handle packaging data into 256-byte records */ |
193 |
if (o_ptr - last_len_byte == 256) |
194 |
{ |
195 |
- dprintf(("last_len_byte=%.8X o_ptr=%.8X\n", |
196 |
+ dbprintf(("last_len_byte=%.8X o_ptr=%.8X\n", |
197 |
last_len_byte, o_ptr)); |
198 |
|
199 |
*last_len_byte = 255; |
200 |
@@ -348,7 +348,7 @@ |
201 |
memset(dict, 0, 4096*sizeof(uint_16)*dict_stride); |
202 |
} else |
203 |
{ |
204 |
- dprintf(("new code: %.3X = %.3X + %.2X\n", next_new_code, |
205 |
+ dbprintf(("new code: %.3X = %.3X + %.2X\n", next_new_code, |
206 |
code, next_char)); |
207 |
|
208 |
dict[code*dict_stride + next_char] = next_new_code; |
209 |
@@ -358,7 +358,7 @@ |
210 |
} |
211 |
|
212 |
code = next_char; /* Previous concat becomes new initial code */ |
213 |
- dprintf(("next code: %.2X %c\n", code, code == end_of_info ? '*':' ')); |
214 |
+ dbprintf(("next code: %.2X %c\n", code, code == end_of_info ? '*':' ')); |
215 |
|
216 |
/* ---------------------------------------------------------------- */ |
217 |
/* Keep concatenating as long as we stay in the dictionary. */ |
218 |
@@ -366,7 +366,7 @@ |
219 |
if (i_idx == i_len) |
220 |
{ |
221 |
next_char = end_of_info; |
222 |
- dprintf(("--> next is EOI!\n")); |
223 |
+ dbprintf(("--> next is EOI!\n")); |
224 |
} else |
225 |
{ |
226 |
next_code = -1; |
227 |
@@ -378,19 +378,19 @@ |
228 |
if ((tmp = dict[code*dict_stride + i_buf[i_idx]]) != 0) |
229 |
{ |
230 |
next_code = tmp; |
231 |
- dprintf(("--> code: %.3X + %.2X(a) = %.3X\n", code, |
232 |
+ dbprintf(("--> code: %.3X + %.2X(a) = %.3X\n", code, |
233 |
next_char, next_code)); |
234 |
} else |
235 |
if ((tmp = dict[code*dict_stride + i_buf_alt[i_idx]]) != 0) |
236 |
{ |
237 |
next_char = i_buf_alt[i_idx]; |
238 |
next_code = tmp; |
239 |
- dprintf(("--> code: %.3X + %.2X(b) = %.3X\n", code, |
240 |
+ dbprintf(("--> code: %.3X + %.2X(b) = %.3X\n", code, |
241 |
next_char, next_code)); |
242 |
} else |
243 |
{ |
244 |
next_code = 0; |
245 |
- dprintf(("--> code: %.3X + %.2X(c) = %.3X\n", code, |
246 |
+ dbprintf(("--> code: %.3X + %.2X(c) = %.3X\n", code, |
247 |
next_char, next_code)); |
248 |
} |
249 |
i_idx++; |
250 |
@@ -403,7 +403,7 @@ |
251 |
|
252 |
if (next_char == end_of_info) |
253 |
{ |
254 |
- dprintf(("--> next is EOI! (b)\n")); |
255 |
+ dbprintf(("--> next is EOI! (b)\n")); |
256 |
} |
257 |
} |
258 |
|
259 |
@@ -415,14 +415,14 @@ |
260 |
/* ---------------------------------------------------------------- */ |
261 |
curr_word |= code << curr_bits; |
262 |
curr_bits += curr_size; |
263 |
- dprintf(("SEND %.4X %d curr: %.8X %2d\n", code, curr_size, |
264 |
+ dbprintf(("SEND %.4X %d curr: %.8X %2d\n", code, curr_size, |
265 |
curr_word, curr_bits)); |
266 |
while (curr_bits > 8) |
267 |
{ |
268 |
/* Handle packaging data into 256-byte records */ |
269 |
if (o_ptr - last_len_byte == 256) |
270 |
{ |
271 |
- dprintf(("last_len_byte=%.8X o_ptr=%.8X\n", last_len_byte, |
272 |
+ dbprintf(("last_len_byte=%.8X o_ptr=%.8X\n", last_len_byte, |
273 |
o_ptr)); |
274 |
*last_len_byte = 255; |
275 |
last_len_byte = o_ptr++; |
276 |
@@ -444,7 +444,7 @@ |
277 |
/* Handle packaging data into 256-byte records */ |
278 |
if (o_ptr - last_len_byte == 256) |
279 |
{ |
280 |
- dprintf(("last_len_byte=%.8X o_ptr=%.8X\n", last_len_byte, o_ptr)); |
281 |
+ dbprintf(("last_len_byte=%.8X o_ptr=%.8X\n", last_len_byte, o_ptr)); |
282 |
*last_len_byte = 255; |
283 |
last_len_byte = o_ptr++; |
284 |
} |
285 |
@@ -464,7 +464,7 @@ |
286 |
*last_len_byte = o_ptr - last_len_byte - 1; |
287 |
*o_ptr++ = 0; |
288 |
|
289 |
- dprintf(("encoded %d bytes\n", o_ptr - o_buf)); |
290 |
+ dbprintf(("encoded %d bytes\n", o_ptr - o_buf)); |
291 |
|
292 |
return o_ptr - o_buf; |
293 |
|