Repository navigation
Conversation
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.
Keep the caller's size in GetDngInformation when there is no DefaultCropSize, as C++ does
Problem
GetDngInformation(C++, Rust) reads a DNG's full width and height and its CFA pattern size, first from IFD0 and then from the first SubIFD. The size comes fromGetFullDimension32(C++, Rust), which here can only find DefaultCropSize, the one size tagGetDngInformationasks the parser for. When the directory has no DefaultCropSize:GetFullDimension32returns true without writing anything, andGetDngInformationthen checks the width and height the caller passed in. If both are nonzero, it goes on to read the CFA pattern size as if the size had been found.get_full_dimension32returnsTagNotFound, andGetDngInformationreturns false.For example, a DNG whose raw SubIFD has CFARepeatPatternDim 2×2 and whose DefaultCropSize (4000×3000) has its tag changed to 0xC610, which piex does not read, called with width 640, height 480 and an empty
cfa_pattern_dim:cfa_pattern_dimCalled with width and height 0, both return false. With the tag in place, both return true with 4000×3000.
Question
Which behaviour do we want: C++'s or the Rust port's? Specifically, should
GetDngInformationreturn true (like the C++ library), or return false (like the Rust port)?This PR implements C++'s behaviour.
Fix
In
get_dng_info_internal, aTagNotFoundfromget_full_dimension32now passes when the caller's width and height are both nonzero, as C++ does:The example above then returns what C++ returns. Replayed before and after:
cfa_pattern_dimNotes for review:
GetFullCropDimensionsays the same about returning true there without writing. To keep the port's behavior, we can close this PR.get_dng_informationstarts from 0×0, so it returns false as before.