Skip to content

HDR stage 2 (zero-copy 10-bit) + Apple Log capture - #84

Merged
MyNamesEMurray merged 4 commits into
mainfrom
claude/init-lklchz
Jul 26, 2026
Merged

HDR stage 2 (zero-copy 10-bit) + Apple Log capture#84
MyNamesEMurray merged 4 commits into
mainfrom
claude/init-lklchz

Conversation

@MyNamesEMurray

Copy link
Copy Markdown
Owner

What & why

Two features, both built on the stage-1 groundwork:

Stage 2 — zero-copy 10-bit. The GPU pipeline's zero-copy mappers stop refusing 10-bit hardware surfaces: VAAPI P010 imports as R16 + GR1616 dmabuf planes (Linux), D3D11VA gets a keyed-mutex shared P010 texture with the cache keyed on surface format so an SDR↔HDR switch mid-connection recreates it (Windows). The draw site needed nothing — it already keys techniques and scale factors off the mapped-format enum stage 1 introduced. macOS keeps its BGRA path (VideoToolbox converts 10-bit itself), documented as a known limitation. HDR + GPU pipeline should now log zero-copy active (D3D11 shared P010) instead of falling back.

Apple Log (roadmap P3, unlocked by 10-bit HEVC). The app captures .appleLog (iOS 17+, runtime-gated per format — Log formats are x422, not HLG's x420) and encodes HEVC Main10 tagged BT.2020 primaries/matrix with the transfer deliberately unset: H.273 has no Apple Log code point, so VUI transfer=unspecified is the only correct value, and the wire's VIDEO_CONFIG {"color":"log"} (spec'd since stage 1) is the label. The plugin shows the untouched flat log image — correct BT.2020-matrix decode, then hands off — for the LUT-in-OBS grading workflow; the async path's accidental-but-correct behaviour is now explicit, and the GPU pipeline gains dedicated Log shader techniques (it would previously have HLG-linearized log frames). The Options HDR toggle becomes a Standard / HDR (HLG) / Apple Log picker with one-time migration from the old key; degrade is always to SDR, never sideways between HLG and Log. Apple Log 2 (Apple-Gamut primaries) is explicitly reserved as a future "log2" — never conflated with "log".

Docs: PROTOCOL.md ("log" specified, "log2" reserved, STATE colour fields documented), README, PERFORMANCE.md.

How it was tested

  • Decode harness (real h264-decoder.c, three generated samples): SDR and HLG outputs byte-identical before/after; the new log-like sample (ffprobe-verified VUI: bt2020/unspecified/bt2020nc) decodes to frames=18 format=I010 trc=default — the flat-image path.
  • Plugin builds clean with -Wall -Wextra -Werror (Linux, compiles the VAAPI arm for real); the Windows arm is header-verified (gs_texture_create_p010 declared in the _WIN32 block of graphics.h with the same shape as the NV12 creator) but needs a real-hardware run.
  • Swift sources parse clean via syntax-check.sh; full type check in CI's macOS job.
  • Needs device testing: (1) HDR + GPU pipeline on Windows — expect the P010 zero-copy announce and a before/after bench pair (Tools → LensLink Settings → benchmark logging, then tools/bench-report.py) since this container has no GPU to quote numbers from, per PERFORMANCE.md; (2) Apple Log on an iPhone 15 Pro+ — the key unknown is x422 appearing in availableVideoPixelFormatTypes (if not, Log degrades safely to SDR rather than crashing — the [TestFlight] Crash on iPhone16_1, iOS 27.0 (build 1047) #81 guard covers it); (3) a LUT sanity pass in OBS on the log image.

🤖 Generated with Claude Code

https://claude.ai/code/session_015dWUcqAkNNuNELnMPS4RdT


Generated by Claude Code

claude added 4 commits July 25, 2026 23:56
Stage 2 of HDR: the zero-copy mappers stop refusing 10-bit hardware
surfaces. VAAPI P010 imports as R16 + GR1616 dmabuf planes; D3D11VA
gets a keyed-mutex shared P010 texture pair, with the texture cache
keyed on the surface format so an SDR<->HDR switch mid-connection
recreates it instead of copying into a mismatched texture. The draw
site needs nothing — it already picks techniques and scale factors
from the mapped format. macOS keeps its BGRA behaviour (VideoToolbox
converts 10-bit itself, display-referred) with the limitation
documented. NV12 behaviour is unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015dWUcqAkNNuNELnMPS4RdT
PROTOCOL.md promotes "log" from reserved to specified — Apple Log 1
only (BT.2020 primaries/matrix, VUI transfer unspecified since H.273
has no Apple Log code point; the JSON field is the sole label and the
receiver shows the flat image for LUT grading) — and reserves "log2",
which uses Apple-Gamut primaries and must never be sent as "log". The
STATE snapshot's colour fields (hdr/color + HEVC-only codecs), missed
in the stage-1 spec update, are now documented. README gains the Apple
Log feature bullet; PERFORMANCE.md covers the x422 capture quirk and
the 10-bit zero-copy path with a placeholder for a real bench pair.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015dWUcqAkNNuNELnMPS4RdT
The decoder's BT.2020 branch becomes an explicit transfer switch: HLG
and PQ map as before, and anything else — Apple Log's VUI says
transfer unspecified, since H.273 has no code point for it — keeps the
BT.2020 matrix and 10-bit ranges but renders as ordinary SDR, which is
precisely the flat log image the user's Apply LUT filter expects.
(This already happened by accident; now it's explicit, commented, and
harness-proven byte-identical for SDR/HLG.) The GPU-pipeline draw site
stops keying techniques on pixel format alone — 10-bit + HLG/PQ takes
the HLG chain and extended canvas as before, while 10-bit with any
other transfer takes new Log techniques: same BT.2020 limited-range
matrix, no EOTF, no primaries conversion, no brightness scaling,
clipped to the SDR canvas.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015dWUcqAkNNuNELnMPS4RdT
StreamColor gains .log (Apple Log 1 only; Apple Log 2 with Apple-Gamut
primaries is reserved for a future "log2"). Log capture requires
iOS 17 and a lens with an x422 format advertising .appleLog — gated at
runtime per format, never by model — and delivers x422 straight into
the Main10 HEVC encode (VideoToolbox converts internally), tagged
BT.2020 primaries/matrix with the transfer deliberately unset so the
VUI reads unspecified, the only correct value for Apple Log. The
Options toggle becomes a Standard / HDR (HLG) / Apple Log picker
(Log row only where capturable), persisted under "streamColor" with a
one-time migration from "hdrEnabled". The issue-#81 attach-first pixel
format guard covers all 10-bit formats; degrade is always to SDR,
never sideways between HLG and Log (a Log stream that silently turned
HLG would grade wrong). STATE announces "color":"log" (HLG keeps its
"hdr" flag byte-for-byte); SDR behaviour is unchanged throughout.

Release-Bump: minor
Release-Beta: true

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015dWUcqAkNNuNELnMPS4RdT
@MyNamesEMurray
MyNamesEMurray enabled auto-merge July 26, 2026 00:12
@MyNamesEMurray
MyNamesEMurray merged commit 0df3294 into main Jul 26, 2026
6 checks passed
@MyNamesEMurray
MyNamesEMurray deleted the claude/init-lklchz branch July 26, 2026 00:14
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