Skip to content
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

dcraw: use the right black levels for linear DNGs #6444

Conversation

sgotti
Copy link
Contributor

@sgotti sgotti commented Mar 25, 2022

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.

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.
The 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.
@Thanatomanic
Copy link
Contributor

Seems good, thanks for diving into this! I agree that the fix could be cleaner, but this can be said about using dcraw in general imo

@Thanatomanic Thanatomanic merged commit bd118a4 into Beep6581:dev Mar 26, 2022
pmjdebruijn pushed a commit to pmjdebruijn/RawTherapee that referenced this pull request Apr 20, 2022
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.
The 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Linear DNG with multiple subifds has wrong black levels.
2 participants