Skip to content

jpegrutils: interpret Apple gain-map headroom as linear - #491

Open
gregbenz wants to merge 1 commit into
google:mainfrom
gregbenz:codex/apple-gainmap-headroom
Open

gregbenz wants to merge 1 commit into
google:mainfrom
gregbenz:codex/apple-gainmap-headroom

Conversation

@gregbenz

Copy link
Copy Markdown
Contributor

Apple's HDRGainMapHeadroom is already a linear ratio, but the XMP parser applies the conversion from log2 space used for Adobe GainMapMax. For the existing apple_gainmap_new.jpg fixture, this turns a headroom of 4.532783 into 23.147476, causing excessive HDR gain and carrying the wrong value into re-encoded metadata.

This change reads the Apple value directly while preserving Adobe's logarithmic conversion and the older Apple EXIF fallback. It also corrects the fixture expectation and adds a focused regression test.

Apple describes headroom as the HDR-to-SDR luminance ratio in Applying Apple HDR effect to your photos. ImageIO reports the same linear values for the tested Apple JPEGs.

The regression fails before this change and passes afterward. The full local suite passes (1,097 passed, 224 skipped), as do the focused ASan/UBSan checks. Together with #484, all 49 JPEG tests pass. I also tested two Apple-only iPhone JPEGs through libvips and ImageMagick; both retain the corrected headroom. ISO and XMP JPEG outputs decode successfully.

This is independent of #484's color-space flag fix. It does not change the gain-map reconstruction formula or add Apple HEIC support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant