diff --git a/benchmarks/decoders/benchmark_decoders.py b/benchmarks/decoders/benchmark_decoders.py index 6e6b61181..db4c2a6cb 100644 --- a/benchmarks/decoders/benchmark_decoders.py +++ b/benchmarks/decoders/benchmark_decoders.py @@ -206,10 +206,10 @@ def get_frames_from_video(self, video_file, pts_list): metadata = json.loads(get_json_metadata(decoder)) average_fps = metadata["averageFps"] best_video_stream = metadata["bestVideoStreamIndex"] - indexes_list = [int(pts * average_fps) for pts in pts_list] + indices_list = [int(pts * average_fps) for pts in pts_list] frames = [] frames = get_frames_at_indices( - decoder, stream_index=best_video_stream, frame_indices=indexes_list + decoder, stream_index=best_video_stream, frame_indices=indices_list ) return frames diff --git a/src/torchcodec/decoders/_core/VideoDecoder.cpp b/src/torchcodec/decoders/_core/VideoDecoder.cpp index 446b12a4b..c51d38687 100644 --- a/src/torchcodec/decoders/_core/VideoDecoder.cpp +++ b/src/torchcodec/decoders/_core/VideoDecoder.cpp @@ -967,19 +967,19 @@ VideoDecoder::DecodedOutput VideoDecoder::getFrameAtIndex( return getNextDecodedOutputNoDemux(); } -VideoDecoder::BatchDecodedOutput VideoDecoder::getFramesAtIndexes( +VideoDecoder::BatchDecodedOutput VideoDecoder::getFramesAtIndices( int streamIndex, - const std::vector& frameIndexes) { + const std::vector& frameIndices) { validateUserProvidedStreamIndex(streamIndex); - validateScannedAllStreams("getFramesAtIndexes"); + validateScannedAllStreams("getFramesAtIndices"); const auto& streamMetadata = containerMetadata_.streams[streamIndex]; const auto& options = streams_[streamIndex].options; - BatchDecodedOutput output(frameIndexes.size(), options, streamMetadata); + BatchDecodedOutput output(frameIndices.size(), options, streamMetadata); int i = 0; const auto& stream = streams_[streamIndex]; - for (int64_t frameIndex : frameIndexes) { + for (int64_t frameIndex : frameIndices) { if (frameIndex < 0 || frameIndex >= stream.allFrames.size()) { throw std::runtime_error( "Invalid frame index=" + std::to_string(frameIndex)); diff --git a/src/torchcodec/decoders/_core/VideoDecoder.h b/src/torchcodec/decoders/_core/VideoDecoder.h index a3a1888b5..2f542d564 100644 --- a/src/torchcodec/decoders/_core/VideoDecoder.h +++ b/src/torchcodec/decoders/_core/VideoDecoder.h @@ -233,11 +233,11 @@ class VideoDecoder { const VideoStreamDecoderOptions& options, const StreamMetadata& metadata); }; - // Returns frames at the given indexes for a given stream as a single stacked + // Returns frames at the given indices for a given stream as a single stacked // Tensor. - BatchDecodedOutput getFramesAtIndexes( + BatchDecodedOutput getFramesAtIndices( int streamIndex, - const std::vector& frameIndexes); + const std::vector& frameIndices); // Returns frames within a given range for a given stream as a single stacked // Tensor. The range is defined by [start, stop). The values retrieved from // the range are: diff --git a/src/torchcodec/decoders/_core/VideoDecoderOps.cpp b/src/torchcodec/decoders/_core/VideoDecoderOps.cpp index 8b3a373d1..a9819b74e 100644 --- a/src/torchcodec/decoders/_core/VideoDecoderOps.cpp +++ b/src/torchcodec/decoders/_core/VideoDecoderOps.cpp @@ -224,7 +224,7 @@ at::Tensor get_frames_at_indices( auto videoDecoder = unwrapTensorToGetDecoder(decoder); std::vector frameIndicesVec( frame_indices.begin(), frame_indices.end()); - auto result = videoDecoder->getFramesAtIndexes(stream_index, frameIndicesVec); + auto result = videoDecoder->getFramesAtIndices(stream_index, frameIndicesVec); return result.frames; } diff --git a/test/decoders/VideoDecoderTest.cpp b/test/decoders/VideoDecoderTest.cpp index 148d32a1f..fb0607021 100644 --- a/test/decoders/VideoDecoderTest.cpp +++ b/test/decoders/VideoDecoderTest.cpp @@ -210,7 +210,7 @@ TEST_P(VideoDecoderTest, DecodesFramesInABatchInNCHW) { *ourDecoder->getContainerMetadata().bestVideoStreamIndex; ourDecoder->addVideoStreamDecoder(bestVideoStreamIndex); // Frame with index 180 corresponds to timestamp 6.006. - auto output = ourDecoder->getFramesAtIndexes(bestVideoStreamIndex, {0, 180}); + auto output = ourDecoder->getFramesAtIndices(bestVideoStreamIndex, {0, 180}); auto tensor = output.frames; EXPECT_EQ(tensor.sizes(), std::vector({2, 3, 270, 480})); @@ -234,7 +234,7 @@ TEST_P(VideoDecoderTest, DecodesFramesInABatchInNHWC) { bestVideoStreamIndex, VideoDecoder::VideoStreamDecoderOptions("dimension_order=NHWC")); // Frame with index 180 corresponds to timestamp 6.006. - auto output = ourDecoder->getFramesAtIndexes(bestVideoStreamIndex, {0, 180}); + auto output = ourDecoder->getFramesAtIndices(bestVideoStreamIndex, {0, 180}); auto tensor = output.frames; EXPECT_EQ(tensor.sizes(), std::vector({2, 270, 480, 3}));