Repository navigation
decoder: reuse the planes of a picture that left the reference set - #40
Merged
Merged
Conversation
… Frame is valid until the next call Every decoded picture allocated and zeroed three planes (1.4 MB at 1280x720): 82 MB of the 127 MB a 46-picture decode allocated, and about 10 % of its CPU in madvise, memclr and page faults. The planes of a picture that was returned by an earlier call and is neither a reference nor waiting to be output now go to a free list (bounded at 34) and serve the next picture of that size. This is a change of contract, stated on decoder.Frame: a Frame is valid until the next call to Decode or Flush on the same Decoder. The internal decoder keeps the old behaviour unless SetRecycle(true) (the public decoder sets it), so nothing else that uses it changes. go-avkit/decode copies every picture out at once, so it is unaffected. A macroblock a corrupt stream never states keeps the samples of the picture that was there before instead of zero (documented in the README). Checked: TestRecyclingChangesNoOutput decodes every conformance clip one access unit per call with and without reuse and compares every picture; TestRecyclingBoundsTheBytesAllocated requires less than half the bytes; 69 of 73 JVT streams stay bit-exact (4 pending oops1/go.264#2); race detector clean. Timing deferred: load above 8 when written. Needs a MINOR release (a documented lifetime is a contract change below v1). Refs go-avkit/decode#10 🤖 Generated with [Claude Code](https://claude.com/claude-code)
tannevaled
added a commit
that referenced
this pull request
Nov 10, 2026
Mid-GOP decode 257 -> 179 ms and 127 -> 16 MB, against ffmpeg -threads 1 at 88 ms (process start included). Release v0.8.0: #40 documents a Frame as valid until the next call, a contract change. Refs go-avkit/decode#10 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.
decoder: reuse the planes of a picture that left the reference set; a Frame is valid until the next call
Every decoded picture allocated and zeroed three planes (1.4 MB at 1280x720): 82 MB
of the 127 MB a 46-picture decode allocated, and about 10 % of its CPU in
madvise, memclr and page faults. The planes of a picture that was returned by an
earlier call and is neither a reference nor waiting to be output now go to a free
list (bounded at 34) and serve the next picture of that size.
This is a change of contract, stated on decoder.Frame: a Frame is valid until the
next call to Decode or Flush on the same Decoder. The internal decoder keeps the
old behaviour unless SetRecycle(true) (the public decoder sets it), so nothing
else that uses it changes. go-avkit/decode copies every picture out at once, so
it is unaffected. A macroblock a corrupt stream never states keeps the samples of
the picture that was there before instead of zero (documented in the README).
Checked: TestRecyclingChangesNoOutput decodes every conformance clip one access
unit per call with and without reuse and compares every picture;
TestRecyclingBoundsTheBytesAllocated requires less than half the bytes; 69 of 73
JVT streams stay bit-exact (4 pending oops1/go.264#2); race detector clean.
Timing deferred: load above 8 when written.
Needs a MINOR release (a documented lifetime is a contract change below v1).
Refs go-avkit/decode#10
🤖 Generated with Claude Code