Skip to content

feat(dv): recognise a recordless Dolby Vision Profile 5 from its first RPU - #567

Merged
superuser404notfound merged 2 commits into
superuser404notfound:mainfrom
oxyc:pr/recordless-dv-profile5
Sep 20, 2026
Merged

superuser404notfound merged 2 commits into
superuser404notfound:mainfrom
oxyc:pr/recordless-dv-profile5

Conversation

@oxyc

@oxyc oxyc commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Some Matroska releases are Dolby Vision Profile 5 but carry no DV record in the container (and an
unspecified VUI), so the engine loads them as plain SDR and the IPT picture is decoded as YCbCr: a
violet/green cast. This reads the first RPU for that narrow case and adds the missing record, so the
existing Profile 5 paths take over.

What changed

  • For a probed HEVC stream that is 10-bit 4:2:0, has no AV_PKT_DATA_DOVI_CONF, and has transfer, matrix
    and primaries all unspecified, the demuxer reads the first RPU (rpuProfileOfSource, libdovi's
    guessed_profile). Only if it reads exactly profile 5 does it add a Profile 5 record (level 6, RPU
    present, no EL, BL present, compat 0) to the stream's coded_side_data. Route, display criteria and
    the segment muxer's dvcC/dvh1 then follow the existing Profile 5 paths; the load, the HLS producer's
    own open and rebuilds agree with no verdict to carry.
  • Narrow on purpose (the A Dolby Vision Profile 5 record its own RPU contradicts should be routed as what the RPU says #532 principle): any named colour description, 8-bit, non-HEVC, or an existing
    record never reaches a packet read; a failed or non-5 read leaves the source as it was. URL sources only
    (non-live, non-disc); cost is one extra open and up to 16 packets, for candidates only.
  • A recordless P5 routed to the software path now meets the existing DV P5 displaying a green-purple color shift #176 refusal, like a real P5 record,
    instead of playing with a cast.
  • Separate commit: skips the P5 colr override for a synthesized record (the source deliberately says
    nothing about colour; a plain ffmpeg -c copy -tag:v dvh1 copy carries no colr). It is not shown to be
    necessary, only that playback is correct without it; happy to drop it.

Test plan

  • Device / OS: Apple TV 4K (3rd generation, AppleTV14,1), tvOS 27.0 (24J361); also aetherctl on macOS.
  • Source media (container / video codec + profile / audio / HDR-DV): Matroska / HEVC Main 10, 3840x2160,
    full range, colour tags unspecified / AC-3 5.1 / Dolby Vision Profile 5 with no container record
    (streaming-service WEB-DL; every frame carries a profile 5 RPU).
    • Synthetic repro (test pattern, 3 s, HEVC with profile 5 RPUs and no container record):
      recordless-p5-synthetic.mp4. aetherctl probe reports format: sdr on unmodified main and
      AE#recordless: DV profile 5 ... / format: dolbyVision with this change. It shows the detection, not
      the colour cast.
    • The real file is copyrighted so it isn't attached; happy to email a real clip where the green tint is
      visible, on request.
  • Result: before, prepared: codec=hvc1 ... range=SDR DV=none. After, AE#recordless: DV profile 5 from the first RPU, DV source: profile=5 compat=0 level=6, prepared: codec=dvh1.05.06 ... range=PQ DV=profile5, master CODECS="dvh1.05.06" VIDEO-RANGE=PQ, and the served init.mp4 carries dvh1 >
    hvcC, dvcC. Played on the Apple TV with correct colours. 7 new unit tests; 32 pass, 4 skipped for
    fixtures not in-repo.
recordless-p5-synthetic.mp4

Checklist

  • CHANGELOG.md updated
  • Commit messages follow Conventional Commits (feat(...), fix(...), chore(...))
  • The fix lives in the engine, not in a host-side workaround
  • Public API changes are intentional and documented (none)

oxyc and others added 2 commits September 19, 2026 23:16
…t RPU

A Matroska release can be Profile 5 (IPT-PQ-c2, no base layer) with the dvcC/dvvC
BlockAdditionMapping dropped and an unspecified VUI. The engine reads Dolby Vision only
from the container record, so it loaded as SDR hvc1 and the IPT picture was decoded as
YCbCr. For untagged 10-bit HEVC with no record, the demuxer now reads the first RPU and,
only if libdovi reads exactly profile 5, adds the record a genuine Profile 5 container
would carry, so every downstream reader follows the existing Profile 5 paths.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ized

The P5 colr override (nclx BT.2020 / PQ / BT.2020 NCL) exists for MP4 sources that lost
their VUI. A record synthesized from the RPU belongs to a file whose VUI says nothing on
purpose (IPT-PQ-c2 has no VUI code point), and the reference `ffmpeg -c copy -tag:v dvh1`
output for the same file carries no colr at all, so the tuple stays unspecified there.

Kept as its own commit: it is not shown to be necessary, only that playback is correct
with it absent.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@oxyc
oxyc force-pushed the pr/recordless-dv-profile5 branch from fcd0521 to 7f10ec0 Compare September 20, 2026 02:17
superuser404notfound pushed a commit that referenced this pull request Sep 20, 2026
feat(dv): recognise a recordless Dolby Vision Profile 5 from its first RPU

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015PM3xUJB6ZQyqnmGK1fp6F
@superuser404notfound
superuser404notfound merged commit 70ad782 into superuser404notfound:main Sep 20, 2026
superuser404notfound pushed a commit that referenced this pull request Sep 20, 2026
…#567)

PR #567 skipped the Profile 5 `colr nclx` override for a record the engine
synthesizes from the RPU. That override is the #19 repair, and the shape it
repairs is exactly the one the new detection gates on: a Profile 5 whose VUI
says nothing, which is every genuine Profile 5, IPT-PQ-c2 having no VUI code
point.

Measured on one bitstream in two containers, 8 s of Dolby's own P5 asset with
its `dvcC` block addition mapping intact and with it renamed away: with the
record, `init.mp4` is 883 B and carries `colr nclx` 9 / 16 / 9 with the
full-range flag; with the record stripped and the skip in place, 864 B and no
`colr`. One picture, two deliveries, decided by what the container happened to
write down. With this the recordless file is served byte for byte like the
recorded one.

That leaves `Demuxer.synthesizedDolbyVisionRecord` with no reader, so it goes
with it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015PM3xUJB6ZQyqnmGK1fp6F
superuser404notfound pushed a commit that referenced this pull request Sep 20, 2026
…567)

The #532 budget is spent by sources that are broken before a packet is read: a
Profile 5 record over a BT.2020 YCbCr VUI states its own contradiction, so
walking sixteen packets for it costs nothing anyone else pays. The recordless
gate from #567 is met by every untagged 10-bit HEVC, and an SDR encode with no
colour description is a common shape that walks the whole budget to learn
nothing.

Measured against an origin at 150 ms latency and 1 MB/s, on a 30 MB untagged
10-bit SDR Matroska: `probe` costs 0.50 s with no audit, 2.75 s at a budget of
16, 1.21 s at 4 and about 1.2 s at 2. A Profile 5 carries an RPU in every frame
and answers in the first video packet, which the recordless Profile 5 fixture
still does at this budget, so four is slack rather than budget. The two gates
now name their own.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015PM3xUJB6ZQyqnmGK1fp6F
superuser404notfound pushed a commit that referenced this pull request Sep 20, 2026
@superuser404notfound

Copy link
Copy Markdown
Owner

Merged, thank you. The detection is the right shape: the record goes onto the demuxed stream before classification, so the route, the display criteria, the segment muxer's dvcC and the #176 software refusal all follow with no verdict to carry, and because the hook sits behind the skipStreamInfo guard in probeStreams the subtitle and Atmos side demuxers and the audit's own second open never reach it, so it cannot recurse and those passes pay nothing.

Reproduced here before merging, on a recordless Profile 5 built from Dolby's own P5 asset (the dvcC block addition mapping renamed so libavformat drops the record, bitstream untouched): main reports format: sdr, the branch reports AE#recordless: DV profile 5 from the first RPU and serves CODECS="dvh1.05.06", VIDEO-RANGE=PQ, init.mp4 with dvh1 > hvcC, dvcC. Full suite green.

Two things I pulled in afterwards rather than sending the PR back.

The colr commit is reverted. That override is the AE#19 repair, and it exists for exactly the signal shape this detection gates on: a Profile 5 whose VUI says nothing gets the canonical IPT-PQ-c2 tuple written as colr nclx so AVPlayer's Dolby Vision decoder engages on the dvh1 sample entry. Measured on one bitstream in two containers, the same 8 s of Dolby's P5 asset with and without its record: with the record, init.mp4 is 883 B and carries colr nclx 9 / 16 / 9 with the full-range flag; with the record stripped, your branch serves 864 B and no colr. That makes the same bytes two different deliveries depending only on what the container happened to write down. If the green cast you saw with the override is reproducible on your file, it is worth its own issue rather than a branch of the new path: every recorded Profile 5 gets that identical stamp today, including a full-range one, so it would be a defect in the shipped route. A pair of runs on your file, current main against main with the colr skip put back, would settle it, and the skip goes back in if it shows (27648d2).

The recordless arm reads fewer packets. 16 is right for #532, where the record-over-VUI pairing already proves the source is broken before a packet is read. Here the budget is spent mostly by sources that were never Dolby Vision: an untagged 10-bit HEVC SDR encode is a common shape. Measured against an origin with 150 ms of latency and 1 MB/s, on a 30 MB untagged 10-bit SDR MKV, probe goes from 0.50 s on main to 2.75 s on the branch, to 1.21 s with a budget of 4 and to about 1.2 s with a budget of 2. A Profile 5 answers in the first video packet by construction, and the recordless Profile 5 fixture still does at 4, so that arm now reads 4 (44c9b66) and #532 keeps its 16.

Thanks for the write-up as well: the synthetic repro and the before and after lines made this reviewable without the source file.

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