Repository navigation
perf(seek): raw Annex B IDR byte seeking - #73
Merged
Merged
Conversation
Build a byte-offset index for raw streams from the parser's NAL list (SPS/ PPS plus each IDR frame) and pass it to the decoder. SeekToFrame now compares decoding forward from the current position with a byte seek to the nearest IDR and picks the cheaper path, so backward/random jumps no longer decode from frame 0. Falls back to the old reset path when the byte seek fails. Adds DecoderTest.RawSeekJumpsToPreviousIdr, which seeks back to frame 22 and compares the image with a sequentially decoded reference. Fixes #6
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.
Summary
Fixes #6: raw Annex B streams no longer decode from frame 0 on every backward jump.
Changes
MainWindowbuilds a raw keyframe index from the parser NAL list: offsets of SPS/PPS and each IDR frame, passed to the player decoder viaSetRawKeyframeIndex().FFmpegDecoder::SeekToFrame()usesav_seek_frame(..., AVSEEK_FLAG_BYTE)to jump to the nearest IDR before the target, flushes, setscurrent_frame_to that IDR frame and decodes forward.SeekStatsgainedused_raw_keyframe.Verification
av_seek_framereturns 0 and the following packet starts at the requested offset).DecoderTest.RawSeekJumpsToPreviousIdr: seeks from frame 50 back to 22, checksused_raw_keyframeand compares the image pixel-for-pixel with a sequentially decoded frame 22.ctest: 73/73 pass.tidy.shon the changed files: 0 issues.Notes
seek_framesshould be close totarget - IDR frame.Fixes #6