File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -618,9 +618,15 @@ FrameOutput SingleStreamDecoder::getFrameAtIndexInternal(
618618 }
619619 validateFrameIndex (streamMetadata, frameIndex);
620620
621- int64_t pts = getPts (frameIndex);
622- setCursorPtsInSeconds (ptsToSeconds (pts, streamInfo.timeBase ));
623- return getNextFrameInternal (preAllocatedOutputTensor);
621+ // Only set cursor if we're not decoding sequentially
622+ if (frameIndex != lastDecodedFrameIndex_ + 1 ) {
623+ int64_t pts = getPts (frameIndex);
624+ setCursorPtsInSeconds (ptsToSeconds (pts, streamInfo.timeBase ));
625+ }
626+
627+ auto result = getNextFrameInternal (preAllocatedOutputTensor);
628+ lastDecodedFrameIndex_ = frameIndex;
629+ return result;
624630}
625631
626632FrameBatchOutput SingleStreamDecoder::getFramesAtIndices (
Original file line number Diff line number Diff line change @@ -345,6 +345,7 @@ class SingleStreamDecoder {
345345 bool cursorWasJustSet_ = false ;
346346 int64_t lastDecodedAvFramePts_ = 0 ;
347347 int64_t lastDecodedAvFrameDuration_ = 0 ;
348+ int64_t lastDecodedFrameIndex_ = INT64_MIN;
348349
349350 // Stores various internal decoding stats.
350351 DecodeStats decodeStats_;
You can’t perform that action at this time.
0 commit comments