Repository navigation
feat(dovi): join a split enhancement layer, add the layer probe and passthrough digest behind the dual-layer trait - #969
Conversation
… track or pid A Profile 7 title can carry its enhancement layer on a separate track (two-track MKV or MP4) or a separate PID (two-PID M2TS) instead of inside the base layer's access units. The demuxer now joins such a layer into the dual-layer composer. - The 8.1 fold pairs each enhancement unit and its RPU with the base frame by time in microseconds, with a 2 ms tolerance. - The join queues are bounded by time (2 s locked, 4 s searching, 6 s for the enhancement layer), so a missing or late layer cannot grow memory. - NAL length sizes the join cannot parse are refused, and the title plays as base layer only. - A lost unit costs at most one GOP of wrong pairs: the join waits a bounded look-ahead for the next base IRAP and repairs the pairing from there. Tested on the Mac: 0 differing frames against the single-track reference on five layouts and on a real P7 FEL segment, full plays and seeks. Still needs a real disc with a separate enhancement PID and an Apple TV run. Source: fel/dual-track-input @ 1284d691
Each frame handed to the decoder now gets a digest of the RPU attached at hand-off compared with the source RPU: every display-management level and the CM version (v2.9 or v4.0) are read from both and must match. For the dual-layer mode-2 path, header fields and mapping fields that mode 2 is expected to rewrite are checked against an allow-list, and any other difference fails the frame. The matrix is compared by normalised category so equivalent signalling does not count as a change. The digest exists only with the DualLayerDolbyVision trait; with the trait off nothing is built, and with it on but the digest not enabled the hand-off costs one check per frame. It is switched on with AETHER_DM_DIGEST (1, log or hex), optionally appending JSON lines to AETHER_DM_DIGEST_FILE. aetherctl gains a dmpass command that feeds N packets of a clip through the decoder, prints a per-frame result and exits 0 only when every frame passes; --out writes both readings and both RPU byte strings per frame. Source: fel/dm-passthrough @ 0b9641dc
…ltype/elsurvey/elframe probeDolbyVisionEnhancementLayer reads whether a source's enhancement layer is FEL or MEL off the first RPU, and AetherEngine.prewarmDualLayerDolbyVision() compiles the composer shaders ahead of the first dual-layer frame, off the cooperative pool. aetherctl gains three commands: eltype classifies many sources as FEL or MEL in parallel, elsurvey measures what a FEL title's enhancement layer does to the picture (its per-code inverse NLQ is pinned to the composer by a test), and elframe dumps one frame composed with and without its residual at full precision. A frame whose RPU disables the residual is dumped without it in both pictures and reports residualDisabledByRpu. docs/api.md, docs/cli.md and docs/dolby-vision-fel.md describe them. The probe, the prewarm and the three commands come from FireKahuna's fork (TheFireKahuna/AetherEngine); they were adapted to this composer, with fixes on top for the Sendable row emitter, the prewarm queue and the elframe dump. Source: fork-picks/fel-tools @ 9486840c
… counts and trait notes Adds the missing changelog entry for the enhancement-layer probe, the prewarm and the new aetherctl commands, corrects the subcommand count and the eltype trait note, lists the new diagnostics in the SPI bullet, says the probe handles single-track sources only, and words the route log and a test comment without private paths. Source: pr/fel-inputs-tools review nits
There was a problem hiding this comment.
Automated review
Status: 🟠 Needs changes. Real issues to fix before merge.
The PR joins a Profile 7 enhancement layer that sits on its own PID or track into the single-track unit the dual-layer composer reads. It also folds the enhancement layer's RPUs into the base layer for two-track Matroska / MP4 files (8.1 path, not behind the trait), and adds an el_type probe, a shader prewarm and a display-metadata digest. The direction is right. The join is done in the demuxer, gated on the route decision and undone when the route is not taken, and the trait-only files stay behind #if DualLayerDolbyVision.
Findings
- Should fix: The new 8.1 fold for two-track MP4 still releases a base picture without its RPU once more than 8 are held. This PR's own join notes say libavformat's mov reader hands out each track in chunks of up to a second. In a chunk-interleaved MP4 (MP4Box defaults to 0.5 s, so 12 pictures at 23.976), the pictures past the eighth go out with no Dolby Vision metadata. (
Sources/AetherEngine/Demuxer/Demuxer.swift:566) - Should fix: The change outside the trait (two-track detection in
SeparateDolbyVisionLayers.detectTracks, plus the demuxer's enable/disable round trip that rewrites and restores the base extradata) only has tests that need fixtures which are not checked in. CI never runs that path. (Sources/AetherEngine/Disc/SeparateDolbyVisionLayers.swift:39) - Nit: The
feltestsection ofdocs/cli.mdnow says it "does not need" the trait and, in the same sentence, that it exits 64 without it. (docs/cli.md:521) - Nit: "sixteen units" in
docs/dolby-vision-fel.mdquotesDolbyVisionLayerJoin.agreeingRunForRepairwithout a pin inDocumentedConstantsTests, unlike the neighbouring "16 slots" bound. (docs/dolby-vision-fel.md:329)
Checklist: CHANGELOG yes, docs yes, tests partly (the join logic and unit bytes are covered; detection and the demuxer wiring are not), traits both ways yes
Needs a device run: On Apple TV: two-track MKV and two-PID inputs on the dual-layer route against their single-track remux (picture and drops), a real disc with a separate enhancement PID, and the 8.1 fold on a chunk-interleaved two-track MP4. Whether AETHER_DM_DIGEST costs anything measurable on the TV also needs a device.
Thanks for a substantial and carefully documented piece of work.
Automated review by Quint (Claude) of fe73203. It reads the code, it does not build or run it; a maintainer reviews and merges.
| /// Base-layer packets waiting for the enhancement-layer unit with their PTS, and RPUs that came before their | ||
| /// picture. The enhancement unit usually follows its base unit, sometimes a picture or two later. | ||
| private var doviPairing = DolbyVisionLayerPairing<UnsafeMutablePointer<AVPacket>>() | ||
| private var doviPairing = DolbyVisionLayerPairing<UnsafeMutablePointer<AVPacket>>( |
There was a problem hiding this comment.
The fold now also serves two-track Matroska / MP4 files, which is the behaviour change outside the trait. But DolbyVisionLayerPairing still releases the oldest base picture without an RPU as soon as more than holdLimit (8) wait, and drops early RPUs past 16. That bound was sized for a Blu-ray transport stream, where the enhancement unit follows a picture or two behind.
DolbyVisionLayerJoin.queueTimeLimitMicros documents why that does not hold for MP4: libavformat's mov reader hands out each track in chunks of up to a second. Take an MP4 interleaved at 0.5 s (MP4Box's default), so 12 pictures at 23.976, or one muxed in 1 s chunks. Each chunk has 4 to 16 base pictures with no Dolby Vision metadata, and the RPUs that arrive later are kept as early RPUs and then evicted. If the enhancement chunk comes first, the first 8 RPUs are evicted instead.
foldsWithoutTheJoin would only catch this if its dual.mp4 fixture were chunk-interleaved; an ffmpeg-muxed file interleaves sample by sample. Suggested fix: for .track carriage, give the pairing the same time bound the join uses (with the count as a memory backstop), and add a chunk-interleaved MP4 to the fixture set.
| /// One HEVC track declaring the enhancement layer only, one declaring the base layer, the enhancement layer no | ||
| /// larger than the base layer. Anything ambiguous (several candidates) or unlinked is left alone: a file with two | ||
| /// unrelated HEVC video tracks is not a dual-layer source. | ||
| static func detectTracks(_ ctx: UnsafeMutablePointer<AVFormatContext>) -> SeparateDolbyVisionLayers? { |
There was a problem hiding this comment.
This detection now runs in every build, trait or not, and changes what a two-track MKV / MP4 plays. Neither it nor the demuxer wiring has a test CI runs. DolbyVisionDualTrackFilesTests skips without DV_FEL_DUAL_TRACK_DIR, and SeparateDolbyVisionLayersTests covers only the byte helpers.
Two tests could run without a device or media:
detectTrackson a context built withavformat_alloc_context+av_find_input_format("matroska")+ two HEVC streams carryingAV_PKT_DATA_DOVI_CONF. Cover the accepted pair, a larger enhancement layer, two base candidates, and a non-Matroska/MP4 format.enableDolbyVisionEnhancementLayerJoin/disableDolbyVisionEnhancementLayerJoinrestoring the base layer's original extradata byte for byte. This is what keeps the 8.1 path unchanged when the load does not take the route.
| ## feltest | ||
|
|
||
| Needs the `DualLayerDolbyVision` trait; without it the subcommand exits 64 and says so. Runs the Dolby Vision Profile 7 FEL dual-layer pipeline over a real clip: demuxes, splits each packet into the base layer, the enhancement layer (typically 1080p) and the RPU, decodes both layers in hardware `VTDecompressionSession`s, composes each frame with `DoviFelComposer` on Metal, and audits the output twice. The pixel audit reports mean and standard deviation of Y / Cb / Cr, so a black picture or collapsed chroma fails. The metadata audit checks that every delivered frame carries a `DolbyVisionRPUData` attachment, and warns (without failing) when the payload never changes, since a static-metadata clip is valid. The verdict also requires at least one frame the composer actually reconstructed: a bypassed frame comes out as its base layer and counts as output but not as composed. Exit codes: `0` verified, `1` probe error, `2` no frames output, `3` chroma collapsed to a flat 64, `4` frames emitted without per-frame Dolby Vision metadata, `5` no frame was composed. See [dolby-vision-fel.md](dolby-vision-fel.md). | ||
| Does not need the `DualLayerDolbyVision` trait; without it the subcommand exits 64 and says so. Runs the Dolby Vision Profile 7 FEL dual-layer pipeline over a real clip: demuxes, splits each packet into the base layer, the enhancement layer (typically 1080p) and the RPU, decodes both layers in hardware `VTDecompressionSession`s, composes each frame with `DoviFelComposer` on Metal, and audits the output twice. The pixel audit reports mean and standard deviation of Y / Cb / Cr, so a black picture or collapsed chroma fails. The metadata audit checks that every delivered frame carries a `DolbyVisionRPUData` attachment, and warns (without failing) when the payload never changes, since a static-metadata clip is valid. The verdict also requires at least one frame the composer actually reconstructed: a bypassed frame comes out as its base layer and counts as output but not as composed. Exit codes: `0` verified, `1` probe error, `2` no frames output, `3` chroma collapsed to a flat 64, `4` frames emitted without per-frame Dolby Vision metadata, `5` no frame was composed. See [dolby-vision-fel.md](dolby-vision-fel.md). |
There was a problem hiding this comment.
Nit: this sentence now reads "Does not need the DualLayerDolbyVision trait; without it the subcommand exits 64", which contradicts itself. feltest still needs the trait. The edit looks like it was meant for the new eltype section; please restore "Needs" here.
| demuxer joins the two (`Demuxer.enableDolbyVisionEnhancementLayerJoin`, `DolbyVisionLayerJoin`) into the unit a | ||
| single-track remux carries: the n-th base access unit and the n-th enhancement access unit, each layer in its own | ||
| decode order, anchored at an IRAP the layers share (after a seek, units before it are retired). A missing or extra | ||
| enhancement unit is repaired by presentation time once sixteen units agreed; a source whose layers never share an |
There was a problem hiding this comment.
Nit: "once sixteen units agreed" quotes DolbyVisionLayerJoin.agreeingRunForRepair. The neighbouring "more than 16 slots off its unit" bound is pinned in DocumentedConstantsTests (testPictureOrderPairingBoundMatchesDocumentation). A matching pin (writing the number as 16 makes it easy to assert) would keep the doc from drifting if the constant changes.
…d, and test track detection without fixtures The 8.1 fold released a base picture without its RPU once more than 8 were held, so a chunk-interleaved MP4 (up to a second per track chunk) lost the metadata of every picture past the eighth. The hold is now bounded by 128 pictures or a 2 s span. Adds fixture-free tests for the chunk case, the span release, two-track detection, the Profile 7 declaration, framing and the extradata swap and restore, pins the 16-unit repair run in the documented constants, and restores the feltest trait note. Source: pr/fel-inputs-tools review round 1
|
Pushed 12d0f99 for the automated review: the two-track fold now holds a whole chunk of base pictures (128 pictures or a 2 s span, was 8), with fixture-free tests for the chunk case, track detection and the extradata swap; the feltest trait note is restored and the 16-unit repair run is pinned in DocumentedConstantsTests. |
There was a problem hiding this comment.
Automated review
Status: 🟢 Clean. Nothing left to fix, ready for a maintainer.
I re-checked the PR at 12d0f99. It joins a split Profile 7 enhancement layer (its own track or PID) for the dual-layer composer, folds the enhancement layer's RPUs into the base layer for two-track MKV / MP4, and adds the el_type probe, the shader prewarm and the display-metadata digest. The direction is still right, and every finding from the last review is fixed.
Findings
- Fixed: the fold now holds 128 pictures or 2 s of base pictures (it held 8), so a chunk-interleaved MP4 keeps every RPU.
chunkInterleavedPairsAllandspanReleasesUnpairedcover this. - Fixed:
SeparateDolbyVisionTrackDetectionTestsruns without fixtures. It covers two-track detection (accepted pair, either track order, two bases, two enhancement layers, an enhancement layer larger than the base, a non-P7 base, mpegts), the framing and join gate, and the extradata swap and restore. - Fixed: the
feltesttrait note indocs/cli.mdis restored, andagreeingRunForRepairis now pinned inDocumentedConstantsTests.
No new findings.
Checklist: CHANGELOG yes, docs yes, tests yes, traits both ways yes
Needs a device run: On Apple TV: two-track MKV and two-PID inputs on the dual-layer route, compared with their single-track remux (picture and drops). Also a real disc with a separate enhancement PID, the 8.1 fold on a chunk-interleaved two-track MP4, and whether AETHER_DM_DIGEST costs anything measurable. One more thing to watch: Blu-ray PIDs share the pairing bound, which grew from 8 pictures to 2 s. When an enhancement unit is missing, video packets can now lag audio and subtitles by up to 2 s in the demuxer's output. A disc with a gap in its enhancement layer would show whether that matters.
Thanks for the quick and thorough follow-up.
Automated review by Quint (Claude) of 12d0f99. It reads the code, it does not build or run it; a maintainer reviews and merges.
…969) The fold now waits up to 128 pictures or 2 s for a base picture's RPU (was 8), Blu-ray PIDs included; the entry said nothing about it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SeT6NgupsgTSme7g6RFnE5
84eaeb1
into
superuser404notfound:main
|
Thanks, merged into main as Before the merge, the full suite was green on top of main, both with and without The follow-up only adds a sentence to the CHANGELOG entry. The longer hold in One request for the Apple TV round: please play the trait-off case first. A two-track MKV or MP4 now plays as 8.1, where it used to play the base layer alone. That is the only part of this PR that reaches hosts which never set the trait, so it matters most to verify. |
|
Released in 7.56.0 ( |
Summary
Three Profile 7 FEL additions that all sit behind the
DualLayerDolbyVisiontrait, which is off by default:AetherEngine.probeDolbyVisionEnhancementLayerreports FEL or MEL off the first RPU.prewarmDualLayerDolbyVision()compiles the composer shaders before the first frame.aetherctlgainseltype,elsurveyandelframe. Adapted from TheFireKahuna's fork, with fixes on top.AETHER_DM_DIGEST, plusaetherctl dmpass.One behaviour change is not behind the trait: a two-track MKV or MP4 is now detected and its RPUs are folded into the base layer (Profile 8.1), where it used to play the base layer alone. The CHANGELOG says so.
The Annex B chroma upsampling is not in this PR. It builds on the integer EL path from the compose-queue work and is in #970 and is not part of this PR.
Tested on Mac
swift buildpasses with and without the trait.Still needs Apple TV
AETHER_DM_DIGESTon a TV run, to confirm the hand-off check costs nothing measurable.