AVIF export: write HDR10 content light level (MaxCLL/MaxFALL) for PQ#21357
Open
MaykThewessen wants to merge 2 commits into
Open
AVIF export: write HDR10 content light level (MaxCLL/MaxFALL) for PQ#21357MaykThewessen wants to merge 2 commits into
MaykThewessen wants to merge 2 commits into
Conversation
Author
Tested end-to-endExported a test image through the PQ Rec.2020 output profile to 12-bit AVIF
With this PR the |
darktable already tags AVIF exports with the correct nclx colorPrimaries / transferCharacteristics / matrixCoefficients for PQ/HLG Rec.2020 and P3 output profiles, but never wrote the HDR10 content-light-level box, which players and displays use to tone-map (and which platforms like iOS/Instagram expect). 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 into image->clli. HLG is relative, so it is skipped there. Implements the core of feature request darktable-org#18078. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
95f62bd to
88b3428
Compare
A non-finite float sample poisoned the MaxFALL sum and made the final 16-bit clli cast undefined. Treat non-finite per-pixel nits as 0 in the accumulation. 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: AVIF export — write HDR10 content light level (MaxCLL/MaxFALL) for PQ
Branch:
upstream-avif-hdr10-clli(1 commit,src/imageio/format/avif.c, +56 / -0)Base:
darktable-org/darktable:masterRefs: part of #18078
What this does
darktable already tags AVIF exports with the correct
nclxcolor information(
colorPrimaries/transferCharacteristics/matrixCoefficients) for PQ andHLG Rec.2020 and P3 output profiles. However, it never writes the HDR10
content light level box (
clli: MaxCLL and MaxFALL). Many players, OSes andHDR displays use those values to tone-map, and several platforms (e.g.
iOS/Instagram) expect them on HDR stills.
This PR computes and writes
cllifor PQ output.How
For PQ (SMPTE ST 2084) the exported float samples are absolute-luminance
encoded, so the real content light levels can be derived from the pixels via the
PQ EOTF:
(the frame-average light level; for a still, the whole image is the frame).
These are written into
image->clli(maxCLL/maxPALL). A debug line isemitted under
DT_DEBUG_IMAGEIO.HLG is not handled here: it is a relative system with no fixed nit scale, so
clliis not meaningful and is left unset.Scope / notes
nclxis being written natively.(const float *)in, 4-channel layout the restof
write_image()already uses.Testing
e.g.
avifdec --info out.aviforexiftool out.avif, and confirm theMaxCLL / MaxFALL values are present and sane (debug log prints the values when
run with
-d imageio).