Skip to content

decoder: read the parameter sets and slice headers with h264's readers - #44

Merged
tannevaled merged 1 commit into
mainfrom
decoder-on-root
Nov 10, 2026
Merged

tannevaled merged 1 commit into
mainfrom
decoder-on-root

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

decoder: read the parameter sets and slice headers with h264's readers (step 2c)

The decoder parsed its streams with internal/syntax, a second implementation of
what the root package reads. It now uses the root: ParseSPS, ParsePPS (with PPSIDs
to pick its sequence set), SlicePPSID and ParseSliceReferences, whose DataBit says
where the macroblocks start.

  • internal/decoder/header.go joins the two halves of a slice header into the one
    value the decoder uses, with the weight defaults filled in (an entry that states
    no weight weighs 2^denominator, offset 0).
  • level, loopfilter and the decoder take h264.SPS, h264.PPS and h264.ChromaQP.
  • The root keeps its stricter checks and gains the ones the decoder's reader had:
    seq_parameter_set_id <= 31, max_num_ref_frames <= 16, a picture at most 1024
    macroblocks across (read before the +1 that wraps), a crop that does not remove
    the picture (computed in 64 bits; the 32-bit difference could wrap).
  • A parameter set the root refuses as unsupported surfaces as ErrUnsupported.
    Parameter sets still refer to each other as before: a picture set read before its
    sequence set is read as 8-bit 4:2:0, and one that states scaling lists needs it.

Checked: 69 of 73 JVT streams bit-exact against ffmpeg as before (4 pending
oops1/go.264#2); every test of ./... passes; the stream-building tests keep
internal/syntax's fixture writers and a converter (compat_test.go) until the
parsers there are removed (next step). Timing is deferred: slices are now
unescaped twice (once by the reader of the header, once for the macroblock data).

Refs go-avkit/decode#10

🤖 Generated with Claude Code

…s (step 2c)

The decoder parsed its streams with internal/syntax, a second implementation of
what the root package reads. It now uses the root: ParseSPS, ParsePPS (with PPSIDs
to pick its sequence set), SlicePPSID and ParseSliceReferences, whose DataBit says
where the macroblocks start.

* internal/decoder/header.go joins the two halves of a slice header into the one
  value the decoder uses, with the weight defaults filled in (an entry that states
  no weight weighs 2^denominator, offset 0).
* level, loopfilter and the decoder take h264.SPS, h264.PPS and h264.ChromaQP.
* The root keeps its stricter checks and gains the ones the decoder's reader had:
  seq_parameter_set_id <= 31, max_num_ref_frames <= 16, a picture at most 1024
  macroblocks across (read before the +1 that wraps), a crop that does not remove
  the picture (computed in 64 bits; the 32-bit difference could wrap).
* A parameter set the root refuses as unsupported surfaces as ErrUnsupported.
  Parameter sets still refer to each other as before: a picture set read before its
  sequence set is read as 8-bit 4:2:0, and one that states scaling lists needs it.

Checked: 69 of 73 JVT streams bit-exact against ffmpeg as before (4 pending
oops1/go.264#2); every test of ./... passes; the stream-building tests keep
internal/syntax's fixture writers and a converter (compat_test.go) until the
parsers there are removed (next step). Timing is deferred: slices are now
unescaped twice (once by the reader of the header, once for the macroblock data).

Refs go-avkit/decode#10

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@tannevaled
tannevaled merged commit 204922c into main Nov 10, 2026
13 checks passed
@tannevaled
tannevaled deleted the decoder-on-root branch November 10, 2026 20:34
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