Skip to content

Commit 86ec99e

Browse files
committed
Simplify seek skipping logic
1 parent 289ff5d commit 86ec99e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/torchcodec/_core/SingleStreamDecoder.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,9 @@ I P P P I P P P I P P I P P I P
11001100
*/
11011101
bool SingleStreamDecoder::canWeAvoidSeeking() const {
11021102
const StreamInfo& streamInfo = streamInfos_.at(activeStreamIndex_);
1103+
if (!cursorWasJustSet_) {
1104+
return true;
1105+
}
11031106
if (streamInfo.avMediaType == AVMEDIA_TYPE_AUDIO) {
11041107
// For audio, we only need to seek if a backwards seek was requested
11051108
// within getFramesPlayedInRangeAudio(), when setCursorPtsInSeconds() was
@@ -1181,10 +1184,8 @@ UniqueAVFrame SingleStreamDecoder::decodeAVFrame(
11811184

11821185
resetDecodeStats();
11831186

1184-
if (cursorWasJustSet_) {
1185-
maybeSeekToBeforeDesiredPts();
1186-
cursorWasJustSet_ = false;
1187-
}
1187+
maybeSeekToBeforeDesiredPts();
1188+
cursorWasJustSet_ = false;
11881189

11891190
UniqueAVFrame avFrame(av_frame_alloc());
11901191
AutoAVPacket autoAVPacket;

0 commit comments

Comments
 (0)