Repository navigation
Conversation
A missing RowsPerStrip, or one above the image height, is now limited to the height, so planar files without the entry decode and the strip buffer only holds rows that exist. Uncompressed strips, chunky or planar, that are larger than the single buffer allocation limit are read one row at a time. The image dimensions are recorded before the root frame is allocated, so an allocation failure reports the real size, and a frame that fails to decode is released. Directory chains that go backwards in the file are accepted; only a revisited directory is reported as circular.
4 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prerequisites
Description
This PR fixes several cases where the TIFF decoder rejects valid files, or fails on large files with a misleading message.
RowsPerStrip missing or above the image height
int.MaxValue. The chunky path replaced it with the image height, but the planar path did not. A planar file without the entry failed with "Strips larger than Int32.MaxValue bytes are not supported for compressed images". A legal RowsPerStrip larger than the height (for example 100000 on a 4000x2 RGB image) made the decoder ask for a 1.2 GB strip buffer, which is over the default single buffer limit.DecodeImageWithStripsnow limits RowsPerStrip to the image height. A missing entry means the height. Both layouts then size their strip buffers from rows that exist.Uncompressed strips larger than the single buffer limit
Int32.MaxValue. A strip between the allocator's single buffer limit (1 GB by default) and 2 GB failed, even when the decoded image fit in memory. Planar strips had no row fallback at all.SingleBufferAllocationLimitBytes. The planar path gets the same fallback: it reads each plane's row at its offset in the strip and never reads past the strip's byte count. Subsampled YCbCr data stores chroma for a block of rows together, so its rows cannot be decoded one at a time. It is excluded from the fallback and still decodes the whole strip.Allocation failures report "0x0"
Dimensionswas set only after every frame had decoded. When an allocation failed, the message read "possibly degenerate dimensions: 0x0". Also, a frame that failed to decode was never disposed, so its pixel buffer leaked.Directories stored out of file order
Testing
New
TiffDecoderStripLayoutTestsbuild small TIFF files in memory (no new image files) and cover:All 828 tests in the Tiff area pass in Release on net10.0.
Fixes #3243