-
-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
patterns/tiff: support BigTIFF and tiled TIFF; bugfixes and cleanups #159
Merged
Conversation
This file contains 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
I've split out multiple-test support to #161, and marked this PR as draft until that lands. |
Don't require unfolding the array entry to see what tag it contains.
Rationals, uniquely, are primitives with two fields. Add a struct to represent this, rather than inlining them.
Small fields are always left-aligned in the 4-byte Value Offset. On little-endian TIFFs we currently cheat this by declaring a 32-bit value and letting little-endianness handle the semantics. However, this adds some extra conditionals, and misrepresents the resulting field as 32 bits. Drop the cheat.
We were using the field type to make assumptions about whether the Value Offset is a Value or an Offset, which is incorrect. If the Count multiplied by the field size is larger than 4, the field is an Offset; otherwise it's a Value. Add display sugar for single-element arrays to avoid extra nesting.
get_ifds_offsets() and BIG/LITTLE aren't used at all. get_total_IFDs() is only used for declaring the length of TIFFFile.IFDs, and isn't needed because IFDs are structured as a linked list.
The call in TIFFFile is redundant. Drop both calls and open-code the check at the top level, before executing any code. The BigTIFF check will eventually be added alongside this one. Fail if we don't recognize the magic number.
They're redundant with the fields in the DirectoryEntry array. Also they're buggy: they assume the field Value Offsets are always offsets, which isn't true for single-strip IFDs, and they ignore a partial last strip in multiple-strip IFDs.
We're making extra work for ourselves by avoiding the type system. Also, by calculating the number of strips we expect rather than the number of strips we actually have, we're miscounting and omitting any partial last strip. Instead, read the strip offsets and byte counts directly from the IFDEntry array.
Use 64-bit temporary variables for values that can be 64 bits in BigTIFF.
Rebased and marked ready for review! |
Thanks a lot! |
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.
Major changes:
See individual commits for details.
cc: the original authors, @jacksonbarreto and @joelalves