Skip to content

Commit d98c78a

Browse files
committed
Merge branch 'simplify_skip' into avoid_seeking_checks
2 parents e68d7ce + 86ec99e commit d98c78a

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
@@ -1106,6 +1106,9 @@ I P P P I P P P I P P I P P I P
11061106
*/
11071107
bool SingleStreamDecoder::canWeAvoidSeeking() const {
11081108
const StreamInfo& streamInfo = streamInfos_.at(activeStreamIndex_);
1109+
if (!cursorWasJustSet_) {
1110+
return true;
1111+
}
11091112
if (streamInfo.avMediaType == AVMEDIA_TYPE_AUDIO) {
11101113
// For audio, we only need to seek if a backwards seek was requested
11111114
// within getFramesPlayedInRangeAudio(), when setCursorPtsInSeconds() was
@@ -1187,10 +1190,8 @@ UniqueAVFrame SingleStreamDecoder::decodeAVFrame(
11871190

11881191
resetDecodeStats();
11891192

1190-
if (cursorWasJustSet_) {
1191-
maybeSeekToBeforeDesiredPts();
1192-
cursorWasJustSet_ = false;
1193-
}
1193+
maybeSeekToBeforeDesiredPts();
1194+
cursorWasJustSet_ = false;
11941195

11951196
UniqueAVFrame avFrame(av_frame_alloc());
11961197
AutoAVPacket autoAVPacket;

0 commit comments

Comments
 (0)