Fix lzw decoding stopping short of full decode
When the required amount of data was just a tiny bit larger than full a page size (one buffer increment), the decoder would stop since all compressed data had been read. However, the lzw decoder contains a small internal bit buffer for code decoding. That is, some remaining bytes had been retained and were still left to be decoded.
This commit is contained in:
1 parent
8ab9d30eff
commit
4d8c64bf1e
3 files changed
+44
-9
No files matched your search
@@ -43,6 +43,14 @@ pub enum TiffFormatError {
|
||||
TiffSignatureInvalid,
|
||||
ImageFileDirectoryNotFound,
|
||||
InconsistentSizesEncountered,
|
||||
UnexpectedCompressedData {
|
||||
actual: usize,
|
||||
required: usize,
|
||||
},
|
||||
InconsistentStripElements {
|
||||
actual: usize,
|
||||
required: usize,
|
||||
},
|
||||
InvalidTag,
|
||||
InvalidTagValueType(Tag),
|
||||
RequiredTagNotFound(Tag),
|
||||
@@ -66,6 +74,20 @@ impl fmt::Display for TiffFormatError {
|
||||
TiffSignatureInvalid => write!(fmt, "TIFF signature invalid."),
|
||||
ImageFileDirectoryNotFound => write!(fmt, "Image file directory not found."),
|
||||
InconsistentSizesEncountered => write!(fmt, "Inconsistent sizes encountered."),
|
||||
UnexpectedCompressedData { actual, required } => {
|
||||
write!(
|
||||
fmt,
|
||||
"Decompression returned different amount of bytes than expected: got {}, expected {}.",
|
||||
actual, required
|
||||
)
|
||||
}
|
||||
InconsistentStripElements { actual, required } => {
|
||||
write!(
|
||||
fmt,
|
||||
"Inconsistent elements in strip: got {}, expected {}.",
|
||||
actual, required
|
||||
)
|
||||
}
|
||||
InvalidTag => write!(fmt, "Image contains invalid tag."),
|
||||
InvalidTagValueType(ref tag) => {
|
||||
write!(fmt, "Tag `{:?}` did not have the expected value type.", tag)
|
||||
|
||||
Reference in new issue
Block a user