@@ -1092,23 +1092,25 @@ VideoDecoder::BatchDecodedOutput VideoDecoder::getFramesAtIndices(
10921092
10931093VideoDecoder::BatchDecodedOutput VideoDecoder::getFramesDisplayedByTimestamps (
10941094 int streamIndex,
1095- const std::vector<double >& framePtss ) {
1095+ const std::vector<double >& timestamps ) {
10961096 validateUserProvidedStreamIndex (streamIndex);
10971097 validateScannedAllStreams (" getFramesDisplayedByTimestamps" );
10981098
10991099 // The frame displayed at timestamp t and the one displayed at timestamp `t +
11001100 // eps` are probably the same frame, with the same index. The easiest way to
11011101 // avoid decoding that unique frame twice is to convert the input timestamps
11021102 // to indices, and leverage the de-duplication logic of getFramesAtIndices.
1103+ // This means this function requires a scan.
1104+ // TODO: longer term, we should implement this without requiring a scan
11031105
11041106 const auto & streamMetadata = containerMetadata_.streams [streamIndex];
11051107 const auto & stream = streams_[streamIndex];
11061108 double minSeconds = streamMetadata.minPtsSecondsFromScan .value ();
11071109 double maxSeconds = streamMetadata.maxPtsSecondsFromScan .value ();
11081110
1109- std::vector<int64_t > frameIndices (framePtss .size ());
1110- for (auto i = 0 ; i < framePtss .size (); ++i) {
1111- auto framePts = framePtss [i];
1111+ std::vector<int64_t > frameIndices (timestamps .size ());
1112+ for (auto i = 0 ; i < timestamps .size (); ++i) {
1113+ auto framePts = timestamps [i];
11121114 TORCH_CHECK (
11131115 framePts >= minSeconds && framePts < maxSeconds,
11141116 " frame pts is " + std::to_string (framePts) + " ; must be in range [" +
@@ -1119,8 +1121,8 @@ VideoDecoder::BatchDecodedOutput VideoDecoder::getFramesDisplayedByTimestamps(
11191121 stream.allFrames .begin (),
11201122 stream.allFrames .end () - 1 ,
11211123 framePts,
1122- [&stream](const FrameInfo& info, double start ) {
1123- return ptsToSeconds (info.nextPts , stream.timeBase ) <= start ;
1124+ [&stream](const FrameInfo& info, double framePts ) {
1125+ return ptsToSeconds (info.nextPts , stream.timeBase ) <= framePts ;
11241126 });
11251127 int64_t frameIndex = it - stream.allFrames .begin ();
11261128 frameIndices[i] = frameIndex;
0 commit comments