Skip to content

Fixing the HEVC VPS detection and the Annex-B RTP framing - #60

Merged
wberube merged 2 commits into
masterfrom
hevc-vps-annexb
Oct 14, 2026
Merged

wberube merged 2 commits into
masterfrom
hevc-vps-annexb

Conversation

@wberube

@wberube wberube commented Oct 14, 2026

Copy link
Copy Markdown
Member

The source fix from #59 by @dpiers, narrowed to src/rtsp/rtp.c so it can land on its own.

  • Daniel Piers — Fixing the HEVC VPS detection and the Annex-B framing in the RTP packer: the VPS type extraction compared the mask before applying it, so a type-32 NAL never populated the VPS cache; short VPS payloads are now rejected before MIME encoding. The packer also only recognized a four-byte start code at the very front, so valid Annex-B access units fell to the raw path with their framing bytes still in the payload.
  • William Bérubé — Running every RTP pack through the shared NAL splitter: routes that framing change through the existing nal_split() rather than a hand-rolled prefix scan. The splitter already handles both start code lengths and returns the whole pack as a single NAL when none is present, so the raw fallback is preserved and the packetizer now matches the parameter cache.

The test harness, fixtures and CI job from #59 are intentionally left out for now.

dpiers and others added 2 commits October 13, 2026 23:49
The VPS type test compared the wrong way around: & binds looser than ==, so
nalptr[0] >> 1 & 0x3F == H265_NAL_TYPE_VPS evaluated as (nalptr[0] >> 1) & 0
and a type-32 NAL never populated the VPS cache. Group the shift and mask
before the comparison, matching the SPS and PPS checks below it, and reject
VPS payloads shorter than four bytes before they reach the MIME encoder.

The RTP packer only took the Annex-B path when a pack opened with a four-byte
start code, so a three-byte prefix, or a run of leading zeros before either
prefix, was sent as a raw NAL with the framing bytes still in the payload.
Count the leading zeros, accept either prefix, and hand the pack to the
existing splitter.

Extracted from #59, authored by Daniel Piers.
The RTP packer decided for itself whether a pack held Annex-B framing before
splitting it, and kept a raw path for anything that did not match. nal_split()
already scans for both start code lengths and hands the whole pack back as a
single NAL when none is present, so the hand-rolled detection and the separate
raw path were redundant, and out of step with the parameter cache, which has
always split unconditionally.

Drop the branch and run nal_split() over every pack.
@wberube
wberube merged commit 9094ef3 into master Oct 14, 2026
1 check passed
@wberube
wberube deleted the hevc-vps-annexb branch October 14, 2026 00:03
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.

2 participants