Skip to content

Commit 8bb3c08

Browse files
committed
Comment
1 parent 142abda commit 8bb3c08

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/torchcodec/_core/SingleStreamDecoder.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ int64_t secondsToClosestPts(double seconds, const AVRational& timeBase) {
2626
std::round(seconds * timeBase.den / timeBase.num));
2727
}
2828

29-
// Some videos aren't properly encoded and do not specify pts values (for
30-
// packets, and thus for frames). Unset values correspond to INT64_MIN. When
31-
// that happens, we fall-back to the dts value which hopefully exists and is
32-
// correct.
29+
// Some videos aren't properly encoded and do not specify pts values for
30+
// packets, and thus for frames. Unset values correspond to INT64_MIN. When that
31+
// happens, we fallback to the dts value which hopefully exists and is correct.
32+
// Accessing AVFrames and AVPackets's pts values should **always** go through
33+
// the helpers below. Then, the "pts" fields in our structs like FrameInfo.pts
34+
// should be interpreted as "pts if it exists, dts otherwise".
3335
int64_t getPtsOrDts(ReferenceAVPacket& packet) {
3436
return packet->pts == INT64_MIN ? packet->dts : packet->pts;
3537
}

0 commit comments

Comments
 (0)