Repository navigation
fix(hevc): return final parameter sets and isolate appends - #686
Merged
Merged
Conversation
Signed-off-by: Perfloop Agent <[email protected]> Signed-off-by: Tomás Senart <[email protected]>
Signed-off-by: Perfloop Agent <[email protected]> Signed-off-by: Tomás Senart <[email protected]>
Signed-off-by: Perfloop Agent <[email protected]> Signed-off-by: Tomás Senart <[email protected]>
Signed-off-by: Perfloop Agent <[email protected]> Signed-off-by: Tomás Senart <[email protected]>
|
Hi, I'm Tomás, I build Perfloop. I approved this contribution and will handle review feedback here. We found this bug while developing Perfloop's auto-formalization capabilities. We've had Go changes merged in Dolt, Prometheus, Skipper, parquet-go, RoaringBitmap, and more. If you'd like anything in this patch changed, just let me know and I'll update it. |
Collaborator
|
@tsenart. Thanks. Looks fine. |
tobbee
added a commit
that referenced
this pull request
Nov 3, 2026
…yte stream GetParameterSetsFromByteStream scanned for start codes with i < n-4, so a start code followed by a single byte at the very end was not found. Since the final NAL unit is now returned (#686), the parameter set before it swallowed those bytes: 00 00 01 40 01 09 00 00 01 26 gave the VPS 40 01 09 00 00 01 26 instead of 40 01 09. ExtractNalusOfTypeFromByteStream already scans with i < n-3. With the wider scan, a final NAL unit can be a single byte. HEVC NAL unit headers are two bytes, so such a unit is skipped rather than returned as a one-byte parameter set; this keeps the existing truncated-header test passing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EagxH8eFdCXEeeD3Pb6SyT
tobbee
added a commit
that referenced
this pull request
Nov 3, 2026
avc.GetParameterSetsFromByteStream had the two bugs that #686 fixed for HEVC. The NAL unit still open when the data ended was never handled, so a stream that ended with an SPS or PPS and no video lost that set. The returned slices kept the spare capacity of the shared copy buffer, so appending to sps[0] overwrote the first bytes of the next set, e.g. turning the PPS 68 ce 22 into ff ce 22. Use the same structure as hevc: one addParameterSet closure for both a detected start code and the end of the data, which skips non-parameter-set units before trimming, and full slice expressions that cap each returned set at its length. The scan also uses i < n-3, so a start code followed by one byte at the end is found, as in ExtractNalusOfTypeFromByteStream. An AVC NAL unit header is one byte, so no header-length check is needed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EagxH8eFdCXEeeD3Pb6SyT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HEVC parameter-set extraction now returns a complete final unit when an Annex-B stream ends before video. Appending to a returned parameter set no longer overwrites other returned sets.
TestGetParameterSetsFromByteStreamEOFfails without this change and passes with it.TestGetParameterSetsFromByteStreamAppendIsolationfails without this change and passes with it.What changed
Start-code recognition, per-type order and input-independent copied outputs are unchanged.
Tests
TestGetParameterSetsFromByteStreamEOFuses complete VPS, SPS and PPS units from the existinghevc/testdata/blackframe.265fixture, with both start-code lengths and padded or unpadded endings. It checks exact output bytes and counts, then modifies the input to check copy ownership.TestGetParameterSetsFromByteStreamAppendIsolationappends to the first returned VPS, SPS or PPS and checks that every other returned set remains unchanged.TestGetParameterSetsFromByteStreamcovers detected boundaries, repeated sets, first-video exclusion and empty or incomplete-header input. These tests live in hevc/annexb_test.go.3 recorded checks pass with this change.
This does not add HEVC syntax validation. The frequency of affected inputs and downstream failures remains unmeasured; no performance improvement is claimed.
Case and evidence
Generated by Perfloop. Human sponsor: Tomás Senart.