Return the final HEVC parameter set when the stream ends
perfloop-oss/mp4ff · Uncatalogued correctness
https://perfloop.ai/t/oss/case_xxan1vbgsc
Verdict
VERIFIED · settled 2026-11-01 · merged as Eyevinn/mp4ff#686
What happened: The check fails before this change and passes with it.
Hypothesis
HEVC parameter-set extraction drops a complete final parameter set when no later start code follows it. Library callers supplying parameter-set-only Annex-B data can therefore receive incomplete decoder configuration. The affected input frequency and downstream failures remain unmeasured; no performance improvement is claimed.
At revision 702346275b141f91c229e5a759822d70d883d55c, GetParameterSetsFromByteStream records a set only inside the next-start-code branch at hevc/annexb.go:10–22. Natural scan completion goes directly to copying the recorded sets. Thus a final complete VPS, SPS or PPS is not finalized at EOF. This claim does not apply to sets intentionally excluded after the first video NAL, and it does not claim that a truncated one-byte HEVC header is a complete unit.
The checkProperty search on prop_vrsjjw35gb failed in 0.01s after both safe seeds passed: six complete VPS units produced five results. Its exact returned replay is stored. A deterministic rerun with go test ./hevc -run '^FuzzPerfloopHEVCTerminalCompleteness$' -count=1 -timeout=60s -v confirmed smaller witnesses for all three types. Each consists of one complete parameter set from hevc/testdata/blackframe.265, a three-byte prefix, and no AUD, video or padding. Each returned zero sets instead of one. The one-set seed closed by a complete AUD passed.
The smallest Case proof is to rerun these retained witnesses and check that EOF returns the final eligible set exactly once, without its prefix or padding. Regression controls must retain correct detected-boundary extraction, first-video exclusion and input-independent copies. Changing the copying strategy or scanning beyond video is unnecessary for this repair.
Prior hyp_85v17wxf43 describes analogous EOF completion in avc/annexb.go and also an AVC-specific terminal-header boundary. HEVC has a separate implementation, so that AVC repair does not repair this owner; this proposal is confined to complete HEVC units at natural EOF. It is also independent of the admitted HEVC append-isolation finding hyp_4x9fp1b098. The refreshed open-PR page and the implementation and discussion of https://github.com/Eyevinn/mp4ff/pull/657 concern AAC configuration parsing, encoding and descriptors, not HEVC boundary finalization. No customer closure reasons were returned.
Change to test: Finalize a complete pending VPS, SPS or PPS when scanning reaches EOF, preserving trailing-zero trimming and copied output ownership. Keep natural EOF distinct from stopping at the first video NAL so sets after video remain excluded.
Where it lives
Evidence
The check fails before this change and passes with it: `Given a complete VPS, SPS or PPS from hevc/testdata/blackframe.265 as the only Annex-B NAL unit, with a three- or four-byte start code and zero or two trailing zero bytes, GetParameterSetsFromByteStream returns that parameter set exactly once without the start code or padding.`
The check fails before this change and passes with it: `Given an Annex-B stream with two copies of each complete VPS, SPS and PPS from hevc/testdata/blackframe.265 followed by a complete AUD and no video, appending one byte to the first returned set of any type leaves every other returned parameter set unchanged.`
Checks: 3 of 3 passed. Verification: no defect found.