compression.lzw: fix for gif89a decoding - maximum code size is 12 bits.

db4
John Benediktsson 2011-01-26 21:06:43 -08:00
parent 1defecf279
commit 0b6dae0a93
1 changed files with 9 additions and 4 deletions

View File

@ -1,7 +1,7 @@
! Copyright (C) 2009 Doug Coleman. ! Copyright (C) 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors combinators io kernel math namespaces USING: accessors combinators io kernel math math.order
sequences vectors ; namespaces sequences vectors ;
QUALIFIED-WITH: bitstreams bs QUALIFIED-WITH: bitstreams bs
IN: compression.lzw IN: compression.lzw
@ -62,8 +62,13 @@ GENERIC: code-space-full? ( lzw -- ? )
M: tiff-lzw code-space-full? size-and-limit 1 - = ; M: tiff-lzw code-space-full? size-and-limit 1 - = ;
M: gif-lzw code-space-full? size-and-limit = ; M: gif-lzw code-space-full? size-and-limit = ;
GENERIC: increment-code-size ( lzw -- lzw )
M: lzw increment-code-size [ 1 + ] change-code-size ;
M: gif-lzw increment-code-size [ 1 + 12 min ] change-code-size ;
: maybe-increment-code-size ( lzw -- lzw ) : maybe-increment-code-size ( lzw -- lzw )
dup code-space-full? [ [ 1 + ] change-code-size ] when ; dup code-space-full? [ increment-code-size ] when ;
: add-to-table ( seq lzw -- ) : add-to-table ( seq lzw -- )
[ table>> push ] [ table>> push ]