Skip to content

Commit a6a2b6a

Browse files
committed
Use validateFrameIndex in getFramesInIndices
1 parent bc10db8 commit a6a2b6a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/torchcodec/decoders/_core/VideoDecoder.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,10 +1275,8 @@ VideoDecoder::BatchDecodedOutput VideoDecoder::getFramesAtIndices(
12751275
for (auto f = 0; f < frameIndices.size(); ++f) {
12761276
auto indexInOutput = indicesAreSorted ? f : argsort[f];
12771277
auto indexInVideo = frameIndices[indexInOutput];
1278-
if (indexInVideo < 0 || indexInVideo >= getNumFrames(streamMetadata)) {
1279-
throw std::runtime_error(
1280-
"Invalid frame index=" + std::to_string(indexInVideo));
1281-
}
1278+
validateFrameIndex(streamMetadata, indexInVideo);
1279+
12821280
if ((f > 0) && (indexInVideo == previousIndexInVideo)) {
12831281
// Avoid decoding the same frame twice
12841282
auto previousIndexInOutput = indicesAreSorted ? f - 1 : argsort[f - 1];

0 commit comments

Comments
 (0)