File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
src/torchcodec/decoders/_core Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -1119,8 +1119,13 @@ VideoDecoder::BatchDecodedOutput VideoDecoder::getFramesDisplayedByTimestamps(
11191119
11201120 auto it = std::lower_bound (
11211121 stream.allFrames .begin (),
1122- // See https://github.com/pytorch/torchcodec/pull/286 for why the `- 1`
1123- // is needed.
1122+ // We have to end the search at end() - 1 to exclude the last frame from
1123+ // the search: the last frame's nextPts field is 0, which breaks the
1124+ // working assumption of std::lower_bound() that the search space must
1125+ // be sorted. The last frame can still be correctly returned: when the
1126+ // binary search ends without a match, `end() - 1` will be returned, and
1127+ // that corresponds to the last frame.
1128+ // See https://github.com/pytorch/torchcodec/pull/286 for more details.
11241129 stream.allFrames .end () - 1 ,
11251130 framePts,
11261131 [&stream](const FrameInfo& info, double framePts) {
You can’t perform that action at this time.
0 commit comments