Skip to content

Commit fd074f6

Browse files
authored
Indexes -> Indices (#257)
1 parent e17ac50 commit fd074f6

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

benchmarks/decoders/benchmark_decoders.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,10 @@ def get_frames_from_video(self, video_file, pts_list):
206206
metadata = json.loads(get_json_metadata(decoder))
207207
average_fps = metadata["averageFps"]
208208
best_video_stream = metadata["bestVideoStreamIndex"]
209-
indexes_list = [int(pts * average_fps) for pts in pts_list]
209+
indices_list = [int(pts * average_fps) for pts in pts_list]
210210
frames = []
211211
frames = get_frames_at_indices(
212-
decoder, stream_index=best_video_stream, frame_indices=indexes_list
212+
decoder, stream_index=best_video_stream, frame_indices=indices_list
213213
)
214214
return frames
215215

src/torchcodec/decoders/_core/VideoDecoder.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -992,19 +992,19 @@ VideoDecoder::DecodedOutput VideoDecoder::getFrameAtIndex(
992992
return getNextDecodedOutputNoDemux();
993993
}
994994

995-
VideoDecoder::BatchDecodedOutput VideoDecoder::getFramesAtIndexes(
995+
VideoDecoder::BatchDecodedOutput VideoDecoder::getFramesAtIndices(
996996
int streamIndex,
997-
const std::vector<int64_t>& frameIndexes) {
997+
const std::vector<int64_t>& frameIndices) {
998998
validateUserProvidedStreamIndex(streamIndex);
999-
validateScannedAllStreams("getFramesAtIndexes");
999+
validateScannedAllStreams("getFramesAtIndices");
10001000

10011001
const auto& streamMetadata = containerMetadata_.streams[streamIndex];
10021002
const auto& options = streams_[streamIndex].options;
1003-
BatchDecodedOutput output(frameIndexes.size(), options, streamMetadata);
1003+
BatchDecodedOutput output(frameIndices.size(), options, streamMetadata);
10041004

10051005
int i = 0;
10061006
const auto& stream = streams_[streamIndex];
1007-
for (int64_t frameIndex : frameIndexes) {
1007+
for (int64_t frameIndex : frameIndices) {
10081008
if (frameIndex < 0 || frameIndex >= stream.allFrames.size()) {
10091009
throw std::runtime_error(
10101010
"Invalid frame index=" + std::to_string(frameIndex));

src/torchcodec/decoders/_core/VideoDecoder.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,11 @@ class VideoDecoder {
233233
const VideoStreamDecoderOptions& options,
234234
const StreamMetadata& metadata);
235235
};
236-
// Returns frames at the given indexes for a given stream as a single stacked
236+
// Returns frames at the given indices for a given stream as a single stacked
237237
// Tensor.
238-
BatchDecodedOutput getFramesAtIndexes(
238+
BatchDecodedOutput getFramesAtIndices(
239239
int streamIndex,
240-
const std::vector<int64_t>& frameIndexes);
240+
const std::vector<int64_t>& frameIndices);
241241
// Returns frames within a given range for a given stream as a single stacked
242242
// Tensor. The range is defined by [start, stop). The values retrieved from
243243
// the range are:

src/torchcodec/decoders/_core/VideoDecoderOps.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ at::Tensor get_frames_at_indices(
225225
auto videoDecoder = unwrapTensorToGetDecoder(decoder);
226226
std::vector<int64_t> frameIndicesVec(
227227
frame_indices.begin(), frame_indices.end());
228-
auto result = videoDecoder->getFramesAtIndexes(stream_index, frameIndicesVec);
228+
auto result = videoDecoder->getFramesAtIndices(stream_index, frameIndicesVec);
229229
return result.frames;
230230
}
231231

test/decoders/VideoDecoderTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ TEST_P(VideoDecoderTest, DecodesFramesInABatchInNCHW) {
210210
*ourDecoder->getContainerMetadata().bestVideoStreamIndex;
211211
ourDecoder->addVideoStreamDecoder(bestVideoStreamIndex);
212212
// Frame with index 180 corresponds to timestamp 6.006.
213-
auto output = ourDecoder->getFramesAtIndexes(bestVideoStreamIndex, {0, 180});
213+
auto output = ourDecoder->getFramesAtIndices(bestVideoStreamIndex, {0, 180});
214214
auto tensor = output.frames;
215215
EXPECT_EQ(tensor.sizes(), std::vector<long>({2, 3, 270, 480}));
216216

@@ -234,7 +234,7 @@ TEST_P(VideoDecoderTest, DecodesFramesInABatchInNHWC) {
234234
bestVideoStreamIndex,
235235
VideoDecoder::VideoStreamDecoderOptions("dimension_order=NHWC"));
236236
// Frame with index 180 corresponds to timestamp 6.006.
237-
auto output = ourDecoder->getFramesAtIndexes(bestVideoStreamIndex, {0, 180});
237+
auto output = ourDecoder->getFramesAtIndices(bestVideoStreamIndex, {0, 180});
238238
auto tensor = output.frames;
239239
EXPECT_EQ(tensor.sizes(), std::vector<long>({2, 270, 480, 3}));
240240

0 commit comments

Comments
 (0)