dcraw: use the right black levels for linear DNGs #6444
Merged
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.
Linear dng (like the one created by Adobe DNG Converter) contains
multiple tiff subifd with different kind of images (the Primary Image
and multiple previews), these defines different kind of black levels.
Currently dcraw has a global cblack array that is overwritten by the
last parsed tiff ifd. With such kind of linear dng it's the last subifd.
This causes the use of the wrong black levels with the image having
usually a magenta color cast.
The dng spec uses the NewSubFileType tag to define the primary image
with tag value as 0.
This patch reads also the NewSubFileType tag and populates the cblack
array provided by the other tags only if it's the primary image.
Fixes #6443
Note
This patch tries to handle the current dcraw.cc code that tries handle all kind of raw images in a single class.
A cleaner fix will be to save the cblack levels for every tiff_ifd and then use the right one. But the global cblack is also uses in other places for other raw files.
Additionally, for DNG files could be possible to exactly know the right raw image using the
NewSubFileType
instead currently there's a quite convoluted code to detect which one to use.ART has the same issue when using the dcraw code. Enabling libraw support in ART instead returns the right black levels.