# HG changeset patch # User michael # Date 1174830074 0 # Node ID 74caca70e2b329705b0fb6c75b96a86c9d36eb88 # Parent ea97803884e1f2f87e4413364f762d7a6288d73a simplify diff -r ea97803884e1 -r 74caca70e2b3 lzw.c --- a/lzw.c Sun Mar 25 06:00:06 2007 +0000 +++ b/lzw.c Sun Mar 25 13:41:14 2007 +0000 @@ -55,7 +55,7 @@ int end_code; int newcodes; ///< First available code int top_slot; ///< Highest code for current size - int top_slot2; ///< Highest possible code for current size (<=top_slot) + int extra_slot; int slot; ///< Last read code int fc, oc; uint8_t *sp; @@ -158,10 +158,10 @@ s->mode = mode; switch(s->mode){ case FF_LZW_GIF: - s->top_slot2 = s->top_slot; + s->extra_slot= 0; break; case FF_LZW_TIFF: - s->top_slot2 = s->top_slot - 1; + s->extra_slot= 1; break; default: return -1; @@ -208,9 +208,6 @@ s->curmask = mask[s->cursize]; s->slot = s->newcodes; s->top_slot = 1 << s->cursize; - s->top_slot2 = s->top_slot; - if(s->mode == FF_LZW_TIFF) - s->top_slot2--; while ((c = lzw_get_code(s)) == s->clear_code); if (c == s->end_code) { s->end_code = -1; @@ -239,12 +236,9 @@ s->prefix[s->slot++] = oc; oc = c; } - if (s->slot >= s->top_slot2) { + if (s->slot >= s->top_slot - s->extra_slot) { if (s->cursize < LZW_MAXBITS) { s->top_slot <<= 1; - s->top_slot2 = s->top_slot; - if(s->mode == FF_LZW_TIFF) - s->top_slot2--; s->curmask = mask[++s->cursize]; } }