HEIF export: write HDR10 content light level (MaxCLL/MaxFALL) for PQ#21365
Open
MaykThewessen wants to merge 2 commits into
Open
HEIF export: write HDR10 content light level (MaxCLL/MaxFALL) for PQ#21365MaykThewessen wants to merge 2 commits into
MaykThewessen wants to merge 2 commits into
Conversation
darktable's HEIF exporter already tags PQ/HLG Rec.2020 (and P3) output with the correct nclx colour information, but never wrote the HDR10 content-light-level box, which players and displays use to tone-map (and which platforms such as iOS/Instagram expect on HDR stills). For PQ (SMPTE ST 2084) output the float samples are absolute-luminance encoded, so derive the values from the pixels via the PQ EOTF: - MaxCLL = brightest single sample (max RGB component), in nits, - MaxFALL = mean per-sample peak light level, in nits. Written via heif_image_set_content_light_level(). HLG is relative, so skipped. This mirrors the equivalent AVIF change and rounds out HDR10 HEIF output. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
5457a72 to
15dba50
Compare
Same NaN-safety fix as AVIF: a non-finite sample poisoned the MaxFALL sum and the final clli cast. Treat non-finite per-pixel nits as 0. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR: HEIF export — write HDR10 content light level (MaxCLL/MaxFALL) for PQ
Branch:
upstream-heif-export(1 commit,src/imageio/format/heif.c, +58 / -0)Base:
darktable-org/darktable:masterRefs: part of #18078 (companion to the AVIF change in #21357)
What this does
darktable's HEIF exporter already tags output with the correct
nclxcolourinformation (
color_primaries/transfer_characteristics/matrix_coefficients)for PQ and HLG Rec.2020 and P3 profiles, but never wrote the HDR10 content
light level box (
clli: MaxCLL and MaxFALL). Players, OSes and HDR displaysuse those values to tone-map, and platforms such as iOS/Instagram expect them on
HDR stills.
This adds
cllifor PQ output, mirroring the equivalent AVIF change.How
For PQ (SMPTE ST 2084) the exported float samples are absolute-luminance
encoded, so the real content light levels are derived from the pixels via the PQ
EOTF:
Written via
heif_image_set_content_light_level(), gated on the PQ transfercharacteristic. HLG is relative (no fixed nit scale) and is left untouched, as
is the ICC-fallback path.
Testing
Exported a 12-bit PQ Rec.2020
.heiffromdarktable-cliand inspected it:Without this change the
cllibox is absent. (The high numbers above are from afully-saturated synthetic test image with no filmic roll-off; a normally graded
photo lands much lower.) Same
_pq_to_nitsderivation as the AVIF path, forconsistent HDR10 signalling across both formats.