Repository navigation
feat(decoder): seek by resetting the decoder instead of rebuilding it - #61
Merged
Merged
Conversation
Owner
|
Thanks! As for if it fits: primarily this crate was created for low latency encoding in moonshine, but I made it a standalone crate so that it could also be used for other purposes. Nice to hear it's being used in other projects 👍 Decoding itself is not something I currently use, but I would like pixelforge to support it properly. Getting feedback from people using it in those scenarios is helpful, so once more: thanks! |
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.
Seeking in a file currently means dropping the
Decoderand building a new one, which recreates the video session, its images and the completion thread on every jump. I'm using the decoder in a video editor, where scrubbing and frame stepping make that the common case.This adds two calls on
DecodeSink, forwarded byDecoder:reset()declares a discontinuity. It drops buffered input and the pictures held for reordering, clears reference state, and keeps the session, its images and the parameter sets. Feeding resumes at a keyframe.flush()delivers the pictures still held for reordering and keeps the source open, so a decoder that reached the end of a file can still seek afterwards. It is a separate commit and easy to drop.Seek to first frame on an RTX 4080 SUPER, median of 30 seeks per method (H.264 without B-frames, same
VideoContextfor both):reset()Decoder::newDoes this fit?
The library is built around live streams, so I'd rather ask than assume: is file seeking something you want in pixelforge? If it is, I'm happy to rework this to your taste and keep contributing along these lines. If not, no problem, I'll carry it in a fork.
Things worth knowing
reset()waits for the work already submitted, so when it returns every frame from before the seek is on the source. Callers tell old frames from new ones by theptsthey supplied. There are no new public types.RESETcontrol operation as the first decode of a new session. For that,dpb_slot_activeis split into "written" (which governs the image layout) andneeds_reset.ptswhen nothing was carried over (0 on a new decoder). That is fixed here because telling frames apart after a reset depends on it.InvalidInputafterfinish().Testing
flush()is compared with whatfinish()delivers, then the decoder is reused.cargo test -- --ignoredpasses (79 tests) on NVIDIA 620.70.06, the only device I have. Thedmabuftests were not run.WRITE_AFTER_WRITEhazards between the decode and the copy queue's layout transition.mainreports the same on its existing decode tests, so I left that alone. There are no core or thread-safety findings.🤖 Created with GPT-6.2 Sol in Codex and reviewed with Claude Fable 5.2 in Claude Code.