Repository navigation
feat(renderer): bounded video look-ahead gate and display-order PTS for reordered streams - #766
Conversation
libdovi is built panic=abort, so a single panic ends the host process. A CRC-valid but hostile Dolby Vision RPU could reach one on the native Profile 7 -> 8.1 conversion. Adds DoviRpuGuard: it checks the RPU CRC and pre-scans the payload for the inputs that make libdovi 3.4 panic or allocate without bound (linear interpolation pieces, polynomial/MMR mixes that break the writer, pivot and block counts the payload cannot hold, undefined display-management block lengths). The existing paths now check each RPU with it before parsing: the Profile 8.1 conversion in DoviRpuConverter (convertPacketToProfile81), the enhancement-layer-type probe, and the DolbyVisionRecordAudit RPU read. The mode 2 convert -> write pair on a parsed RPU is factored into DoviRpuConverter.convertedUnspec62 so the tests drive production's own entry point. A rejected RPU degrades the frame to the HDR10 base exactly as a libdovi failure already did (superuser404notfound#135). This hardens the existing native 8.1 conversion; it changes no routing and adds no Dolby Vision FEL code. The guard knows the paths listed above; it does not prove there are no others. Tests: DoviRpuGuardTests (crafted RPUs, verdicts, conversion round trip) and a DolbyVisionRecordAudit case. The CRC-valid mutation fuzz and the real-file guard test arrive with the composer, whose parameter walk they also exercise.
…or reordered streams Adds the SampleBufferRenderer pieces the dual-layer Dolby Vision path needs for pacing, as inert, opt-in additions: - felVideoLookaheadFrames (9) and mayEnqueueVideoFrame / setFELLookahead: a gate that runs BEFORE decode and refuses a compressed frame more than nine frame intervals ahead of the playback clock, so composed 4K frames (about 25 MB each) cannot pile up behind Apple's readiness gate alone. - displayOrderPTS: estimates a packet's display-order PTS in decode order from the largest amount a later packet fell below the highest PTS seen, so B-frame streams do not swing the cap with the position in the GOP. A gap larger than HEVC's 16-picture reorder ceiling is treated as a timestamp discontinuity and does not poison the learned lead. Nothing calls the gate yet and it is off unless setFELLookahead(enabled:) is called, so non-FEL pacing is unchanged. The decoder and the host wiring come in later PRs; the composer-side pool sizing that follows this cap (DoviFelComposer.outputPoolAllocationThreshold) is pinned in the composer PR. Tests: SampleBufferRendererLookaheadTests, SampleBufferRendererReorderDepthTests.
|
Merged as 96fed93, thanks @pkajaba. Checked: with One thing to keep in mind for the wiring in #769 / #770, not for this PR: the gate compares against the playback clock, so a forward timestamp jump of more than nine frames would hold video back until the clock reaches it. On a P7 VOD remux that should not happen, but the wiring PR should either keep the gate to VOD or let a forward discontinuity reset Next is #767. |
Part 2/10 of #702, stacked on #765. It targets
mainand carries #765's commit, so review only the top commit; the diff shrinks to it as the earlier PRs merge.Summary
Two inert additions to
SampleBufferRendererthat the dual-layer path needs for pacing. Nothing calls them yet and the gate is off unlesssetFELLookahead(enabled:)is called, so pacing is unchanged for every source.What's in it
felVideoLookaheadFrames(9),mayEnqueueVideoFrameandsetFELLookahead: a gate that runs before decode and refuses a compressed frame more than nine frame intervals ahead of the playback clock, so composed 4K frames (about 25 MB each) cannot pile up behind Apple's readiness gate alone.displayOrderPTS: estimates a packet's display-order PTS in decode order from the largest amount a later packet fell below the highest PTS seen, so B-frame streams do not swing the cap with the GOP position. A gap beyond HEVC's 16-picture reorder ceiling is a timestamp discontinuity and does not poison the learned lead.maxLearnedReorderFrames= 8. Without a ceiling, one backward timestamp glitch inside the 16-picture window (a 12-frame one, say) raised the lead, and with it the admitted look-ahead, for the whole session. 8 is above the 7 frames of decode-order lag that a hierarchical-B GOP of 8 gives (measured on a UHD Blu-ray FEL remux; other clips measured 2 to 4); a cap of 4, the renderer's post-decode reorder depth, would have cut the look-ahead from 9 frames to about 6 on that remux. The cap is unrelated tohardwareDecoderReorderDepth.setFELLookahead(enable and disable) as well as by a seek flush, since what was learned belonged to the previous stream or setting.How it was tested
swift testfiltered to every test file the stack adds or changes up to this PR (cumulative:git diff --name-only --diff-filter=AM origin/main HEAD -- Tests/AetherEngineTests, one suite per file): 86 tests in 4 suites pass on this commit alone. Real-clip tests skip withoutDV_FEL_TESTS_DIR.swift build --build-testsandaetherctlbuild at this commit.What it does not do
FEL stack for #702, merge in order: #765 → #766 → #767 → #768 → #769 → #770 → #771 → #772 → #773 → #774. Standalone read-ahead fixes: #775, #776.