Allow an LZW literal width of 0

This commit is contained in:
Nigel Tao committed 2019-05-26 15:52:07 +10:00
1 parent af4e327a8f
commit d41430c4f5
3 files changed
+16 -16

No files matched your search

+3 -3
View File
@@ -451,7 +451,7 @@ pri func decoder.skip_frame?(src base.io_reader) {
// Process the LZW literal width.
lw = args.src.read_u8?()
if (lw < 1) or (8 < lw) {
if lw > 8 {
return "#bad literal width"
}
@@ -942,9 +942,9 @@ pri func decoder.decode_id_part1?(dst ptr base.pixel_buffer, src base.io_reader)
// Process the LZW literal width. The spec says that "images which have one
// color bit must be indicated as having a code size [i.e. literal width]
// of 2", but in practice, some encoders use a literal width of 1.
// of 2", but in practice, some encoders use a literal width of 1 or 0.
lw = args.src.read_u8?()
if (lw < 1) or (8 < lw) {
if lw > 8 {
return "#bad literal width"
}
this.lzw.set_literal_width!(lw:lw as base.u32)