Skip to content

Port the govpx v0.5.3 decoder subset (M0 D0a) - #1

Merged
tannevaled merged 4 commits into
mainfrom
d0a-port
Nov 28, 2026
Merged

tannevaled merged 4 commits into
mainfrom
d0a-port

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

What

M0 step D0a of docs/design/vpx-decoder.md: a port of the VP8/VP9 decoder subset of govpx v0.5.3 (BSD-3-Clause), so that every later change is made here and measured against libvpx.

  • Public packages: vpx (Image, error sentinels), vp8, vp9 (New, Options{MaxWidth, MaxHeight, Threads, RowMT}, DecodeWithPTS, NextFrame, LastFrameCorrupted, Close).
  • internal/ is the output of tools/portgovpx (a per-declaration closure of the decoder under 13 GOOS/GOARCH/GOEXPERIMENT configurations). Every file carries Code generated ... DO NOT EDIT. and its govpx path. The only change from govpx is a Patch applied by the generator (nextPowerOfTwo, whose v >> 32 does not compile where int is 32 bits); the tree was generated before the last commit of this PR, which only removed an unused comment-range helper and added tests (a doc comment is still printed exactly once, asserted on a fixture); I did not re-run the generator over the full tree after that commit.
  • Licences: third_party/{govpx,libvpx,goav1} and PATENTS.

Evidence

  • libvpx's 376 decoder vectors, picture by picture against libvpx's md5, with 0 and 4 threads (4:4:0 included): 757 pass, 0 fail.
  • FuzzReadBool (against RFC 6386, past the end of the data), FuzzVP8Decode, FuzzVP9Decode with committed corpora; 40-45 s runs clean.
  • buildscan --vet passes under all 21 CI configurations. It found two defects before the first push: the 386 build failure above and no CI lane compiling the arm64 SIMD files (an arm64 simd vectors lane is added).

Gates

The mutation gate (mutsweep) does not sweep the generated tree: its files are marked generated, and they are measured by the vectors and the fuzz corpora instead. The hand-written code (vp8, vp9, tools/vpxfetch, tools/portgovpx) is swept: every guard of tools/portgovpx and tools/vpxfetch is caught by an assertion (0 survived, 0 hung, 0 caught only by a panic). The sweep first found 14 survivors, 1 hang and 4 panic-only catches in the generator; they were fixed with tests, four guards that cannot fire (two Rel, Unquote, the printer's write error) were removed, and three host-failure calls became replaceable variables so their error return is asserted.

No waiver variable was used.

Not in this PR

Performance (M0's t1 targets are measured in D0c on the fractal host), the Picture type, and decode's switch to this module (D0b, D0c).

🤖 Generated with Claude Code

tannevaled and others added 4 commits November 28, 2026 22:56
The decoder subset of govpx v0.5.3, extracted by tools/portgovpx (a
per-declaration closure of VP8Decoder and VP9Decoder under 13
GOOS/GOARCH/GOEXPERIMENT configurations, import prefix rewritten, a
derivation header on each file). Public packages: vpx (Image, errors),
vp8, vp9 (New, Options{MaxWidth, MaxHeight, Threads, RowMT}, DecodeWithPTS,
NextFrame, LastFrameCorrupted, Close).

Tests: libvpx's 376 decoder vectors picture by picture (0 and 4 threads,
4:4:0 included), FuzzReadBool against RFC 6386, FuzzVP8Decode and
FuzzVP9Decode with committed corpora. CI: gofmt, 3 OSes, vectors on amd64,
amd64+simd and arm64, 386, qemu lanes, tools modules.

Licences: third_party/govpx (BSD-3), third_party/libvpx (LICENSE, PATENTS),
third_party/goav1 (BSD-2) and PATENTS (AOM) for the AV1-derived kernels.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Found by buildscan --vet: govpx's nextPowerOfTwo shifts by 32 and does not
compile where int is 32 bits; no CI lane compiled the arm64 SIMD files.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
internal/ is the output of tools/portgovpx. Its files now carry the
"Code generated ... DO NOT EDIT." line, and the one change from govpx
(nextPowerOfTwo, which does not compile for 32-bit int) is a Patch the
generator applies, with a test, instead of a hand edit. Regenerating from
govpx v0.5.3 reproduces the committed tree plus the header line.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
mutsweep over tools/portgovpx found 14 guards no test held, one that
hung the suite and four held only by a crash; over tools/vpxfetch, two
held by a nil dereference. Every one is now caught by an assertion.

- portgovpx: errors that cannot be provoked on a healthy host (Abs, ReadDir,
  packages.Load) go through replaceable package variables and are tested to
  be returned; Rel and Unquote, which cannot fail on their inputs, lose
  their dead guards; the unused docStart is dropped (a doc comment is
  printed from the declaration's Doc field, now asserted to appear once);
  the Write error paths, the verbatim copy of a wholly kept file, the
  root errors and the recursive-function termination each have a test, and
  a TestMain watchdog turns a spinning closure into a failure.
- vpxfetch: the two errors that surfaced as a nil dereference are asserted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 185fc0c into main Nov 28, 2026
14 checks passed
@tannevaled
tannevaled deleted the d0a-port branch November 28, 2026 22:55
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