darktable-org / darktable-org/darktable

PQ and HLG transfer function problems (too dark import, too bright export)

Open
#20,562 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

no-issue-activity
Dominant language
C
Stars
13.1k
Forks
1.4k
Avg merge
22h 14m
Merged PRs (30d)
198

Description

Is there an existing issue for this?
  • I checked and did not find my issue in the already reported ones
Describe the bug

When importing HLG or PQ encoded images, they appear much too dark. When exporting HLG or PQ encoded images, they appear much too bright.

For HLG, the presentation matches roughly what I expect when the OOTF mapping between scene and display light is missing (an issue i encountered in Gtk's color pipeline, so I had a direct comparison). For PQ, imports are about 1/50th expected brightness and exports 50x too bright, suggesting lack of luminance scaling to 203 nits reference white. However, I have yet to dig into the darktable color pipeline past a casual glance.

I have created some test images over in https://github.com/kennylevinsen/hdr-test-images which I use to validate implementations, made to match the kind of output I get from a Nikon Z5ii's HEIF HLG BT.2020 image files - files that cursed sent me on a journey of digging into HLG support issues.

Looking at the original PR implementing the HDR image support (https://github.com/darktable-org/darktable/pull/3749), it seems that there was some confusion by the very dark/very bright image, so I guess the issue has been present all along.

Steps to reproduce
  1. Open the hdr test images
  2. Observe that images which should all have roughly identical presentation

Note that the HLG target luminance is not set in stone, but the 1000 nit recommendation from the spec seem like a common target and should at the very least be treated as the default.

Expected behavior

No response

Logfile | Screenshot | Screencast

PQ test file from Netflix, Loupe vs. Darktable:
Image

PQ test file from my test repo, Loupe vs. Darktable:
Image

HLG test file from my test rep, fixed Loupe vs. Darktable:
Image

HLG test file from my test repo, Loupe before the HLG OOTF fix vs. Darktable (hence my gut-feeling):
Image

For export, the behavior is the exact inverse - too bright images for HLG, retina-searing images for PQ. However, the behavior is symmetric so importing a darktable export cancels out the luminance error.

Commit

No response

Where did you obtain darktable from?

distro packaging

darktable version

2:5.4.1-1

What OS are you using?

Linux

What is the version of your OS?

Arch

Describe your system

sway (wayland)

Are you using OpenCL GPU in darktable?

I dont know

If yes, what is the GPU card and driver?

No response

Please provide additional context if applicable. You can attach files too, but might need to rename to .txt or .zip

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the HDR test images linked in the report, comparing HLG and PQ imports and exports. Trace the relevant darktable color pipeline for transfer-function and luminance handling; done means the test images have the expected presentation in both directions without the reported brightness scaling errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
computer-graphics
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.