Skip to content

NAT-550: Add opt-in HDR-to-SDR tone mapping - #173

Merged
eugene-mux merged 4 commits into
em/nat-549-generated-resumefrom
em/nat-550-hdr-tone-mapping
Oct 28, 2026
Merged

eugene-mux merged 4 commits into
em/nat-549-generated-resumefrom
em/nat-550-hdr-tone-mapping

Conversation

@eugene-mux

@eugene-mux eugene-mux commented Oct 22, 2026 •

Copy link
Copy Markdown

Description

Add opt-in HDR-to-SDR tone mapping for supported H.264/HEVC HLG and PQ inputs, preserving the codec family. Preserve remains the default; unsupported or failed conversions retain original-file fallback.

Changes

  • Check decoder, encoder, and OpenGL capabilities before selecting Media3's pixel-conversion path.
  • Require BT.709 8-bit 4:2:0 SDR output after reinspection.
  • Reuse existing cancellation, cleanup, audio, orientation, and generated-resume behavior.

Validation

  • 301 debug and 301 release unit tests pass; SDK/sample release builds and lint-vital checks pass.
  • Real HLG/PQ fixtures verify preservation and capability rejection on the emulator.
  • Archived Pixel 8 Pro/Galaxy S23 outputs verify changed pixels and BT.709 SDR as feasibility evidence. Current SDK hardware and quality acceptance remain pending.

Note

Medium Risk
Changes video export, HDR/color handling, and capability gating on the standardization path; mitigated by opt-in API, strict preflight, and original-file fallback on failure.

Overview
Adds an opt-in HDR→SDR tone-mapping path for supported H.264/HEVC HLG and PQ inputs when toneMapsToSdr is set (e.g. via HdrHandling.ToneMapToSDR), while preserve stays default and failures still fall back to the original file.

Planning & gates: SdrEncodingTargets.from no longer blanket-rejects tone mapping; it requires BT.2020 color evidence, matching codec/profile/pixel format, and records source frame rate for decoder preflight. Capability checks add API 29+, an OpenGL YUV-target probe, HDR decoder format validation, and BT.709 limited SDR encoder format support.

Export: Media3 composition uses HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_OPEN_GL (not metadata-only HDR keep), and the strict encoder factory insists on ColorInfo.SDR_BT709_LIMITED when tone mapping.

Validation: Post-export checks add OutputExpectation.Color—tone-mapped outputs must show BT.709 / SDR video transfer / limited range in inspected metadata, not just SDR dynamic range.

Reviewed by Cursor Bugbot for commit 812fb82. Bugbot is set up for automated code reviews on this repo. Configure here.

@eugene-mux
eugene-mux marked this pull request as ready for review October 22, 2026 22:35
@eugene-mux
eugene-mux requested a review from a team as a code owner October 22, 2026 22:35
@eugene-mux
eugene-mux requested a review from daytime-em October 22, 2026 22:35
@eugene-mux
eugene-mux added this pull request to stack #166 October 22, 2026 22:35
@eugene-mux
eugene-mux force-pushed the em/nat-550-hdr-tone-mapping branch from 76171b3 to 8d68e26 Compare October 22, 2026 23:02

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 812fb82. Configure here.

@eugene-mux
eugene-mux merged commit a51b41c into feature/nat-534-hevc-standard-ingest Oct 28, 2026
2 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 4, 2026
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.

2 participants