Skip to content

fix(demux): repair HEVC MP4s without composition offsets (#699) - #700

Merged
superuser404notfound merged 1 commit into
mainfrom
fix/699-hevc-composition-offsets
Oct 5, 2026
Merged

superuser404notfound merged 1 commit into
mainfrom
fix/699-hevc-composition-offsets

Conversation

@superuser404notfound

Copy link
Copy Markdown
Owner

What

The flicker reported in #699 is not related to HDR Vivid. The reporting asset (CUVA conformance stream B.1-04.mp4, 4K50 HEVC Main 10, HLG base) carries B pictures and no ctts table, so every sample reports PTS == DTS. This is the #409 defect, but the #409 repair only armed on H.264, so the HEVC file went to AVPlayer and the software decoder in decode order.

  • H264PictureOrderReader now also opens libavcodec's HEVC parser (which takes hvcC length-prefixed payloads directly), and the repair session arms on HEVC as well.
  • The window self-check refused the asset: its mini-GOP is five pictures at a reorder delay of 2, so the next anchor (POC 15) is decoded while 11 to 14 are still to come, more than the videoDelay + 1 allowance. The check now also accepts a decode-order prefix of at least minimumSamples pictures that fills its own display range exactly. That is the stricter test, and a stray rank that halves the measured step still fails it.
  • The partial-region repair (fix(video): repair partial H.264 MP4 composition offsets #513) reads H.264 NAL types, so it stays H.264-only.

Verification

  • Reporting asset, served HLS read back with ffprobe: 0 backward steps across all 1500 frames, uniform 20 ms. Before: swdecode reported 35 of 88 backward steps, the served master presented 0.00, 0.06, 0.08, 0.04, 0.10, 0.02 …
  • New HEVC twin pair (libx265 hierarchical B, setts=pts=DTS on one): the repaired twin matches the healthy twin packet for packet (HEVCCompositionOffsetRepairTests). On main they differ.
  • swift test: 4065 swift-testing + 17 XCTest, exit 0. check-doc-links.py clean.
  • aetherctl play on the asset: VERDICT: OK; presented-frame counts are the same as main within run-to-run noise (about 1450 per arm, two runs each).

🤖 Generated with Claude Code

https://claude.ai/code/session_01WJcXkGQrMiBPixVEFTSBJS

The #409 repair only armed on H.264, so an HEVC MP4 whose writer dropped
ctts while the bitstream reorders pictures reached AVPlayer and the
software decoder in decode order, which shows as flicker. The picture
order reader now takes the HEVC parser as well, and the window self-check
also accepts a decode-order prefix of at least nine pictures that fills
its own range exactly, which covers a hierarchical mini-GOP longer than
the reorder delay (five pictures at delay 2 on the reporting asset). The
partial-region repair stays H.264-only.

Reporting asset (CUVA conformance B.1-04, 4K50 HEVC Main 10): 0 backward
steps across all 1500 served frames, 35 of 88 before. New HEVC twin pair
reproduces the healthy twin's timestamps packet for packet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJcXkGQrMiBPixVEFTSBJS
@superuser404notfound
superuser404notfound merged commit a6b422c into main Oct 5, 2026
10 of 12 checks passed
@superuser404notfound
superuser404notfound deleted the fix/699-hevc-composition-offsets branch October 5, 2026 19:20
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.

1 participant