Repository navigation
Conversation
C++ reads SubIFDs with GetOffsetAndLength(kTiffTagSubIfd, TIFF_TYPE_LONG), which ignores an entry of any other type. The port followed SHORT and IFD entries too.
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.
Follow SubIFDs only when the entry is a LONG, as C++ does
NOTE: #23 and #24 answer this on both sides: the port's
parse_sub_ifdsreads the SubIFDs entry as a LONG, or else as an IFD, and C++'sParseSubIfdsdoes the same. Neither follows a SHORT entry. On master with both, the three rows below agree: type IFD gives the 1024×768 preview on both sides, type SHORT gives no preview on both, and type IFD pointing at a SubIFD that runs off the end gives kFail on both. So this PR can be closed once #23 and #24 are merged. They need to land together: on master with #24 alone, all three rows differ.NOTE: Since #21, the port's
get_u32_vecreads only SHORT and LONG entries, so a SubIFDs entry of type IFD is no longer followed, and the first and third rows below now agree on master. A SubIFDs entry of type SHORT (the second row) still differs on master: C++ returns no preview and a full size of 160×120, and the port returns the 1024×768 preview and 6000×4000. This PR still closes that case, and the port's tests pass (44 + 174).Problem
When it parses an IFD,
ParseSubIfds(C++, Rust) follows the SubIFDs entry (tag 0x014A) into the sub-directories, where DNGs and NEFs keep their previews.GetOffsetAndLength(kTiffTagSubIfd, TIFF_TYPE_LONG, ...), which gives nothing unless the entry's type is LONG, so a SubIFDs entry of type IFD (13) or SHORT is not followed.get_u32_vec, which takes SHORT, LONG and IFD.For example:
C++ is on the left and the Rust port on the right. Each panel shows the image a viewer would show for that side's fields: the preview if there is one, and otherwise the thumbnail, scaled up.
When the SubIFDs entry of a DNG has type IFD, C++ never reads the SubIFD that holds the 1024×768 JPEG preview, so a viewer has only the 160×120 thumbnail. The port follows it and returns the preview:
Question
Which behaviour do we want: C++'s or the Rust port's? Specifically, should a SubIFDs entry be followed only when its type is LONG (like the C++ library), or also when it is IFD or SHORT (like the Rust port)?
This PR implements C++'s behaviour.
Fix
parse_sub_ifdsfollows the entry only whenget_offset_and_length(EXIF_TAG_SUB_IFDS, TiffType::Long)finds it, the port's counterpart of the C++ call, in place ofhas(EXIF_TAG_SUB_IFDS):The examples above then return what C++ returns. Replayed before and after (x86-64):
Notes for review:
full_widthandfull_heightalso differ before the patch (C++ 160×120, the port 6000×4000, from the SubIFD C++ never reads). The patched port matches C++ there too.