Inter-predicted short-term RPS sets are not derived, so slice headers fail to parse
perfloop-oss/mp4ff · Uncatalogued correctness
https://perfloop.ai/t/oss/case_s2bd2jcjew
Verdict
VERIFIED · settled 2026-11-11 · merged as Eyevinn/mp4ff#705
What happened: The check fails before this change and passes with it.
Hypothesis
mp4ff reads HEVC reference-picture sets predicted from another set without building the resulting picture lists. That can make slice-header parsing skip fields and lose its bit position. The reported conformance failures and breadth of affected streams have not been independently reproduced in this run.
At base 8a0670f2c1d8aff2e5aca0ac726c234cd15ce60d, parseShortTermRPS (hevc/sps.go:872-942) discards the prediction's sign and magnitude at lines 896-898. Its inter-predicted branch reads the used/use-delta flags and stores NumDeltaPocs, but leaves DeltaPocS0/S1, UsedByCurrPicS0/S1 and NumNegativePics/NumPositivePics empty or zero (880-916). POC means picture order count; the missing values describe reference pictures before and after the current picture. SPS parsing uses this helper at hevc/sps.go:470-483, and slice-local parsing calls it at hevc/slice.go:198-216. ShortTermRPS.countInUsePics counts those used flags (hevc/sps.go:835-848). ParseSliceHeader uses the resulting NumPicTotalCurr to decide whether to consume reference-list modification syntax (hevc/slice.go:289-301), with later fields and alignment checks at 334-347 and 411-428. This connects the missing derivation to the claimed undercount and wrong subsequent bit offset, rather than establishing that every inter-predicted slice must fail.
The submitter reports that an independent audit ran mp4ff over the public JCT-VC conformance streams LTRPSPS_A, RPLM_A and RPLM_B: about 1,100 slices fail with "bit after alignment" on current master 8a0670f. They report that FFmpeg trace_headers parses the same slices, specifically tracing LTRPSPS_A slice 2. These are attributed, unconfirmed audit results to check during the Case. The submitter says any HEVC stream whose SPS or slice uses inter-RPS prediction is affected and describes it as a common encoder option; the actual triggering conditions and prevalence remain uncertain. Their derivation references are H.265 7.4.8, equations 7-61/7-62, and FFmpeg n7.1 hevc_ps.c, ff_hevc_decode_short_term_rps.
The smallest useful next check is to replay the reported LTRPSPS_A slice 2 on the unchanged base and compare its derived reference pictures, used flags, current-picture count and subsequent field positions against the specification and FFmpeg. Then check the reported failure count across all three streams and whether the same missing derivation explains it. The proof target includes both SPS and slice-local prediction, later sets referring to predicted sets, correct negative/positive picture state and header alignment, base-failing regressions drawn from the conformance slices, and unchanged intra-coded RPS parsing. A Go fixture/table-test layout is a provisional method, not an additional frozen requirement. A mismatch with the reference derivation or bit positions can confirm or reject the proposed causal explanation.
Fresh upstream open-PR reads of https://github.com/Eyevinn/mp4ff/pulls returned no candidates. CONTRIBUTING.md:1-3 directs contributions to GitHub issues and master-branch PRs; no separate review venue was identified in the bounded documentation read. The local history is shallow, and recent-file history requests to https://api.github.com/repos/Eyevinn/mp4ff/commits?path=hevc%2Fsps.go&per_page=5 and the corresponding hevc/slice.go request were refused with HTTP 403. Recent merged overlap therefore remains an evidence gap, not an upstream-clear conclusion.
Change to test: Derive the inter-predicted short-term RPS from its reference set as H.265 specifies, including delta POCs and used flags for negative and positive pictures, so later sets and slice headers receive correct NumNegativePics, NumPositivePics and NumPicTotalCurr. Add tests from the failing conformance slices that fail on the base revision, and keep intra-coded RPS parsing unchanged.
Where it lives
perfloop-oss/mp4ff · hevc/slice.go
Evidence
The check fails before this change and passes with it: `For the embedded LTRPSPS_A, RPLM_A and RPLM_B conformance parameter sets and slice-header excerpts, HEVC parsing derives the ordered short-term reference-picture distances, used flags and counts through SPS prediction chains and slice-local prediction, and reads reference-list modifications and QP deltas through alignment at the expected header size.`
The check fails before this change and passes with it: `For the four fixed positive-shift, negative-shift, zero-cancellation and empty-selection cases, short-term HEVC RPS prediction preserves ordered negative and positive picture distances and their used flags, excludes zero POC, sets consistent counts, and leaves the following syntax unchanged.`
The check fails before this change and passes with it: `Given successful parsing of their in-stream parameter sets, HEVC parsing completes all 1700 slice headers in the embedded SHA-256-verified LTRPSPS_A_Qualcomm_1, RPLM_A_qualcomm_4 and RPLM_B_qualcomm_4 conformance streams without errors.`
Conformance predicted SPS parsing · 16 sample pairs
| metric | baseline | candidate | paired median change | confidence range | required | result |
|---|---|---|---|---|---|---|
ns/op |
1676 |
2233 |
+34.2% (+573.5) |
+259 to +969 |
loss ≤ stated 1 × |baseline median| |
PASSED |
B/op |
1808 |
2000 |
+10.6% (+192) |
+192 to +192 |
loss ≤ stated 0.4 × |baseline median| |
PASSED |
allocs/op |
9 |
11 |
+22.2% (+2) |
+2 to +2 |
loss ≤ stated 3 × |baseline median| |
PASSED |
Conformance slice-local RPS parsing · 16 sample pairs
| metric | baseline | candidate | paired median change | confidence range | required | result |
|---|---|---|---|---|---|---|
ns/op |
306.2 |
459 |
+51.1% (+156.6) |
+88.6 to +216.8 |
loss ≤ stated 1 × |baseline median| |
PASSED |
B/op |
400 |
480 |
+20% (+80) |
+80 to +80 |
loss ≤ stated 0.4 × |baseline median| |
PASSED |
allocs/op |
2 |
6 |
+200% (+4) |
+4 to +4 |
loss ≤ stated 3 × |baseline median| |
PASSED |
Empty predicted SPS parsing · 16 sample pairs
| metric | baseline | candidate | paired median change | confidence range | required | result |
|---|---|---|---|---|---|---|
ns/op |
649.7 |
709.1 |
+49.35 |
−54.8 to +192.4 |
loss ≤ stated 0.5 × |baseline median| |
PASSED |
B/op |
584 |
584 |
0 |
0 to 0 |
loss ≤ 0.05 × |baseline median| |
PASSED |
allocs/op |
4 |
4 |
0 |
0 to 0 |
loss ≤ 0.05 × |baseline median| |
PASSED |
Empty slice-local RPS parsing · 16 sample pairs
| metric | baseline | candidate | paired median change | confidence range | required | result |
|---|---|---|---|---|---|---|
ns/op |
225.9 |
278.3 |
+24.7% (+55.9) |
+9.5 to +74.7 |
loss ≤ stated 0.5 × |baseline median| |
PASSED |
B/op |
400 |
400 |
0 |
0 to 0 |
loss ≤ 0.05 × |baseline median| |
PASSED |
allocs/op |
2 |
2 |
0 |
0 to 0 |
loss ≤ 0.05 × |baseline median| |
PASSED |
Conformance slice parsing · 16 sample pairs
| metric | baseline | candidate | paired median change | confidence range | required | result |
|---|---|---|---|---|---|---|
slice-parse-failures |
1106 |
0 |
−100% (−1106) |
−1106 to −1106 |
gain > 0; gain > 0.05 × |baseline median|; arm medians separated; base median within 550 to +∞ |
PASSED |
Checks: 5 of 5 passed. Verification: no defect found.