diff options
Diffstat (limited to 'deflate.h')
-rw-r--r-- | deflate.h | 25 |
1 files changed, 11 insertions, 14 deletions
@@ -217,7 +217,7 @@ typedef struct internal_state { | |||
217 | /* Depth of each subtree used as tie breaker for trees of equal frequency | 217 | /* Depth of each subtree used as tie breaker for trees of equal frequency |
218 | */ | 218 | */ |
219 | 219 | ||
220 | uchf *l_buf; /* buffer for literals or lengths */ | 220 | uchf *sym_buf; /* buffer for distances and literals/lengths */ |
221 | 221 | ||
222 | uInt lit_bufsize; | 222 | uInt lit_bufsize; |
223 | /* Size of match buffer for literals/lengths. There are 4 reasons for | 223 | /* Size of match buffer for literals/lengths. There are 4 reasons for |
@@ -239,13 +239,8 @@ typedef struct internal_state { | |||
239 | * - I can't count above 4 | 239 | * - I can't count above 4 |
240 | */ | 240 | */ |
241 | 241 | ||
242 | uInt last_lit; /* running index in l_buf */ | 242 | uInt sym_next; /* running index in sym_buf */ |
243 | 243 | uInt sym_end; /* symbol table full when sym_next reaches this */ | |
244 | ushf *d_buf; | ||
245 | /* Buffer for distances. To simplify the code, d_buf and l_buf have | ||
246 | * the same number of elements. To use different lengths, an extra flag | ||
247 | * array would be necessary. | ||
248 | */ | ||
249 | 244 | ||
250 | ulg opt_len; /* bit length of current block with optimal trees */ | 245 | ulg opt_len; /* bit length of current block with optimal trees */ |
251 | ulg static_len; /* bit length of current block with static trees */ | 246 | ulg static_len; /* bit length of current block with static trees */ |
@@ -325,20 +320,22 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, | |||
325 | 320 | ||
326 | # define _tr_tally_lit(s, c, flush) \ | 321 | # define _tr_tally_lit(s, c, flush) \ |
327 | { uch cc = (c); \ | 322 | { uch cc = (c); \ |
328 | s->d_buf[s->last_lit] = 0; \ | 323 | s->sym_buf[s->sym_next++] = 0; \ |
329 | s->l_buf[s->last_lit++] = cc; \ | 324 | s->sym_buf[s->sym_next++] = 0; \ |
325 | s->sym_buf[s->sym_next++] = cc; \ | ||
330 | s->dyn_ltree[cc].Freq++; \ | 326 | s->dyn_ltree[cc].Freq++; \ |
331 | flush = (s->last_lit == s->lit_bufsize-1); \ | 327 | flush = (s->sym_next == s->sym_end); \ |
332 | } | 328 | } |
333 | # define _tr_tally_dist(s, distance, length, flush) \ | 329 | # define _tr_tally_dist(s, distance, length, flush) \ |
334 | { uch len = (uch)(length); \ | 330 | { uch len = (uch)(length); \ |
335 | ush dist = (ush)(distance); \ | 331 | ush dist = (ush)(distance); \ |
336 | s->d_buf[s->last_lit] = dist; \ | 332 | s->sym_buf[s->sym_next++] = dist; \ |
337 | s->l_buf[s->last_lit++] = len; \ | 333 | s->sym_buf[s->sym_next++] = dist >> 8; \ |
334 | s->sym_buf[s->sym_next++] = len; \ | ||
338 | dist--; \ | 335 | dist--; \ |
339 | s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ | 336 | s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ |
340 | s->dyn_dtree[d_code(dist)].Freq++; \ | 337 | s->dyn_dtree[d_code(dist)].Freq++; \ |
341 | flush = (s->last_lit == s->lit_bufsize-1); \ | 338 | flush = (s->sym_next == s->sym_end); \ |
342 | } | 339 | } |
343 | #else | 340 | #else |
344 | # define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) | 341 | # define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) |