Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/torchcodec/_core/SingleStreamDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,11 @@ bool SingleStreamDecoder::canWeAvoidSeeking() const {
// within getFramesPlayedInRangeAudio(), when setCursorPtsInSeconds() was
// called. For more context, see [Audio Decoding Design]
return !cursorWasJustSet_;
} else if (!cursorWasJustSet_) {
// For videos, when decoding consecutive frames, we don't need to seek.
return true;
}

if (cursor_ < lastDecodedAvFramePts_) {
// We can never skip a seek if we are seeking backwards.
return false;
Expand Down Expand Up @@ -1181,10 +1185,8 @@ UniqueAVFrame SingleStreamDecoder::decodeAVFrame(

resetDecodeStats();

if (cursorWasJustSet_) {
maybeSeekToBeforeDesiredPts();
cursorWasJustSet_ = false;
}
maybeSeekToBeforeDesiredPts();
cursorWasJustSet_ = false;

UniqueAVFrame avFrame(av_frame_alloc());
AutoAVPacket autoAVPacket;
Expand Down
Loading