Skip to content

rawprepare: fall back to full range when white point is not above black - #22890

Merged
TurboGit merged 2 commits into
darktable-org:masterfrom
RafatH0ssain:rawprepare-white-below-black
Nov 2, 2026
Merged

TurboGit merged 2 commits into
darktable-org:masterfrom
RafatH0ssain:rawprepare-white-below-black

Conversation

@RafatH0ssain

Copy link
Copy Markdown
Contributor

If a raw reader reports a white point at or below the black level, commit_params() in rawprepare computes div = white - black <= 0. The image then renders black or inverted, and nothing tells you why. This happened with LibRaw on the Canon EOS R50 V (white 90 or 148, black 2047; upstream fix in LibRaw/LibRaw#875).

As suggested in #22597, this adds a cheap check in rawprepare's commit_params():

  • if raw_white_point <= max(raw_black_level_separate[]), the module uses UINT16_MAX for the scaling and for the white point it passes downstream, so the image is dark but not inverted
  • the module shows an "invalid white point" trouble message (also printed to stderr), so the user can set a correct value in the module
  • the message only appears while the module is actually active, and it is cleared once the white point is valid again; the clear happens before _image_set_rawcrops() so it can't wipe the existing crop-parameter message

This doesn't touch camera support. The R50 V modelMap entry from the issue is left out on purpose, per the discussion there.

Tested on macOS (Apple Silicon, Homebrew, no OpenMP):

  • builds with -Werror (rawprepare.c clean); ctest 40/40 pass
  • darktable-cli on mire1.cr2 with the rawprepare white point set to 100 (black 1030): before, the image is essentially black (mean 0.0003) with no message. After, it renders darker but not inverted (mean 0.18 against 0.41 normally) and logs Trouble: [raw black/white point] 'white point not above black level, using maximum'
  • darkroom (GUI): opening the same image shows the "invalid white point" banner on the raw black/white point module. Resetting the white point to the camera value (13600) clears it and the image renders normally, and undo brings the banner back
  • integration suite: 169/191 pass. The other 22 fail the same way on this machine without the patch, with identical max dE per test (isolated pixels, avg dE ~0.001), so they look like platform differences. None of the 191 tests hit the new fallback

AI disclosure: the change was drafted with AI assistance (Claude Code + an OpenCode model) and reviewed by me.

Related: #22597

@jenshannoschwalm

Copy link
Copy Markdown
Collaborator

Please have a look at the dev-doc about thread sharing gui data :-) You also will find examples in other modules ...

@jenshannoschwalm

Copy link
Copy Markdown
Collaborator

Squash both commits and then it's good.

@TurboGit TurboGit added this to the 5.8 milestone Nov 2, 2026
@TurboGit TurboGit added bugfix pull request fixing a bug priority: low core features work as expected, only secondary/optional features don't scope: image processing correcting pixels labels Nov 2, 2026

@TurboGit TurboGit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@TurboGit
TurboGit merged commit 56b0ca0 into darktable-org:master Nov 2, 2026
10 checks passed
@RafatH0ssain
RafatH0ssain deleted the rawprepare-white-below-black branch November 2, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix pull request fixing a bug priority: low core features work as expected, only secondary/optional features don't scope: image processing correcting pixels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants