Skip to content

colorspaces: encode PQ and HLG thumbnails the way the pipe does - #22751

Merged
TurboGit merged 1 commit into
darktable-org:masterfrom
nicknezis:pq-display-thumbnails
Oct 23, 2026
Merged

TurboGit merged 1 commit into
darktable-org:masterfrom
nicknezis:pq-display-thumbnails

Conversation

@nicknezis

Copy link
Copy Markdown
Contributor

With a PQ or HLG display profile, lighttable and filmstrip thumbnails are much lighter than the darkroom view, as seen while testing #22669. The open image's own filmstrip thumbnail looks right.

Cause. Since 4b0878d the pipe encodes PQ with 1.0 at reference white (203 nits) and applies the HLG OOTF itself, through dt_hdr_encode(). The thumbnail display transforms (transform_srgb_to_display, transform_adobe_rgb_to_display) still go straight through LittleCMS to the built-in PQ/HLG ICC profiles, whose shapers (_PQ_fct(), _HLG_fct()) put PQ 1.0 at 10000 nits and have no OOTF. The image open in the darkroom escapes this because its filmstrip thumbnail is drawn from the preview pipe's backbuf (dtgtk/thumbnail.c), which colorout has already encoded.

Fix. For PQ and HLG display profiles, the sRGB/AdobeRGB display transforms now end in linear light (via dt_colorspaces_linearize_profile(), as colorout does), and a new dt_colorspaces_transform_to_display() applies dt_hdr_encode() before writing 8-bit BGRA. Lighttable/filmstrip (dt_view_image_get_surface()) and the tethering live view use it. Other display profiles keep the plain 8-bit transform, so SDR output is byte-identical. The display2 transforms get the same treatment for consistency, though nothing uses them at the moment. The ICC profiles themselves are unchanged, so exports and imports are not affected.

Checked. Builds without warnings (Ubuntu 24.04, GCC, OpenCL off); the hdr unit tests pass. A scratch program linked against libdarktable, run headless with --conf ui_last/color/display_type=..., pushed an AdobeRGB gray ramp through the old and new thumbnail transforms and compared with dt_hdr_encode() of the same linear values (display code, green channel):

AdobeRGB code PQ old PQ new PQ pipe HLG old HLG new HLG pipe
0 0.055 0.000 0.000 0.000 0.000 0.000
117 (18% gray) 0.816 0.412 0.411 0.659 0.435 0.436
186 (50%) 0.925 0.510 0.509 0.867 0.631 0.632
255 (white) 1.000 0.580 0.581 1.000 0.749 0.750

HLG P3 gives the same grays; saturated colors differ only by primaries. With the sRGB display profile, old and new output are identical.

Not checked. I haven't looked at the thumbnails in the GUI on a PQ or HLG screen, nor the tethering live view.

Release notes. None added: the mismatch came in with 4b0878d in this cycle, so no release had it. Happy to add one if you'd rather.

This change was written with AI assistance (Claude Code) and reviewed by me.

Since 4b0878d the pipe encodes PQ with 1.0 at reference white (203
nits) and applies the HLG OOTF itself, through dt_hdr_encode(). The
thumbnail display transforms still went straight through LittleCMS to
the built-in PQ and HLG ICC profiles, whose shapers put PQ 1.0 at
10000 nits and have no OOTF. With a PQ or HLG display profile,
lighttable and filmstrip thumbnails were therefore much lighter than
the darkroom view: AdobeRGB white landed at code 1.0 instead of 0.58
for PQ and 0.75 for HLG, mid gray at 0.82 instead of 0.41 for PQ. The
image open in the darkroom looked right only because its filmstrip
thumbnail is drawn from the preview pipe's output, which colorout has
already encoded.

For PQ and HLG display profiles the sRGB and AdobeRGB display
transforms now end in linear light, as colorout does, and the new
dt_colorspaces_transform_to_display() applies dt_hdr_encode() before
writing 8-bit BGRA. Lighttable, filmstrip and the tethering live view
use it. Other display profiles keep the plain 8-bit transform.
@TurboGit TurboGit added this to the 5.8 milestone Oct 23, 2026
@TurboGit TurboGit added bugfix pull request fixing a bug scope: color management ensuring consistency of colour adaptation through display/output profiles labels Oct 23, 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.

Works for me in all views, lighttable, darkroom, slideshow and print. Good to go, thanks!

@TurboGit
TurboGit merged commit 6a48308 into darktable-org:master Oct 23, 2026
10 checks passed
@nicknezis
nicknezis deleted the pq-display-thumbnails branch October 24, 2026 06:08
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 scope: color management ensuring consistency of colour adaptation through display/output profiles

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants