Skip to content

Commit d43dd91

Browse files
committed
Use timestamps as parameter name
1 parent 3a8839d commit d43dd91

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

src/torchcodec/decoders/_core/VideoDecoder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ VideoDecoder::BatchDecodedOutput VideoDecoder::getFramesAtIndices(
10921092

10931093
VideoDecoder::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

@@ -1106,9 +1106,9 @@ VideoDecoder::BatchDecodedOutput VideoDecoder::getFramesDisplayedByTimestamps(
11061106
double minSeconds = streamMetadata.minPtsSecondsFromScan.value();
11071107
double maxSeconds = streamMetadata.maxPtsSecondsFromScan.value();
11081108

1109-
std::vector<int64_t> frameIndices(framePtss.size());
1110-
for (auto i = 0; i < framePtss.size(); ++i) {
1111-
auto framePts = framePtss[i];
1109+
std::vector<int64_t> frameIndices(timestamps.size());
1110+
for (auto i = 0; i < timestamps.size(); ++i) {
1111+
auto framePts = timestamps[i];
11121112
TORCH_CHECK(
11131113
framePts >= minSeconds && framePts < maxSeconds,
11141114
"frame pts is " + std::to_string(framePts) + "; must be in range [" +

src/torchcodec/decoders/_core/VideoDecoder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ class VideoDecoder {
246246

247247
BatchDecodedOutput getFramesDisplayedByTimestamps(
248248
int streamIndex,
249-
const std::vector<double>& framePtss);
249+
const std::vector<double>& timestamps);
250250

251251
// Returns frames within a given range for a given stream as a single stacked
252252
// Tensor. The range is defined by [start, stop). The values retrieved from

src/torchcodec/decoders/_core/VideoDecoderOps.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ TORCH_LIBRARY(torchcodec_ns, m) {
4646
m.def(
4747
"get_frames_by_pts_in_range(Tensor(a!) decoder, *, int stream_index, float start_seconds, float stop_seconds) -> (Tensor, Tensor, Tensor)");
4848
m.def(
49-
"get_frames_by_pts(Tensor(a!) decoder, *, int stream_index, float[] frame_ptss) -> (Tensor, Tensor, Tensor)");
49+
"get_frames_by_pts(Tensor(a!) decoder, *, int stream_index, float[] timestamps) -> (Tensor, Tensor, Tensor)");
5050
m.def("get_json_metadata(Tensor(a!) decoder) -> str");
5151
m.def("get_container_json_metadata(Tensor(a!) decoder) -> str");
5252
m.def(
@@ -245,11 +245,11 @@ OpsBatchDecodedOutput get_frames_in_range(
245245
OpsBatchDecodedOutput get_frames_by_pts(
246246
at::Tensor& decoder,
247247
int64_t stream_index,
248-
at::ArrayRef<double> frame_ptss) {
248+
at::ArrayRef<double> timestamps) {
249249
auto videoDecoder = unwrapTensorToGetDecoder(decoder);
250-
std::vector<double> framePtssVec(frame_ptss.begin(), frame_ptss.end());
250+
std::vector<double> timestampsVec(timestamps.begin(), timestamps.end());
251251
auto result =
252-
videoDecoder->getFramesDisplayedByTimestamps(stream_index, framePtssVec);
252+
videoDecoder->getFramesDisplayedByTimestamps(stream_index, timestampsVec);
253253
return makeOpsBatchDecodedOutput(result);
254254
}
255255

src/torchcodec/decoders/_core/VideoDecoderOps.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ OpsDecodedOutput get_frame_at_pts(at::Tensor& decoder, double seconds);
7979
OpsBatchDecodedOutput get_frames_by_pts(
8080
at::Tensor& decoder,
8181
int64_t stream_index,
82-
at::ArrayRef<double> frame_ptss);
82+
at::ArrayRef<double> timestamps);
8383

8484
// Return the frame that is visible at a given index in the video.
8585
OpsDecodedOutput get_frame_at_index(

src/torchcodec/decoders/_core/video_decoder_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def get_frames_by_pts_abstract(
178178
decoder: torch.Tensor,
179179
*,
180180
stream_index: int,
181-
frame_ptss: List[float],
181+
timestamps: List[float],
182182
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
183183
image_size = [get_ctx().new_dynamic_size() for _ in range(4)]
184184
return (

test/decoders/test_video_decoder_ops.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,16 @@ def test_get_frames_by_pts(self):
163163
stream_index = 3
164164

165165
# Note: 13.01 should give the last video frame for the NASA video
166-
frame_ptss = [2, 0, 1, 0 + 1e-3, 13.01, 2 + 1e-3]
166+
timestamps = [2, 0, 1, 0 + 1e-3, 13.01, 2 + 1e-3]
167167

168168
expected_frames = [
169-
get_frame_at_pts(decoder, seconds=pts)[0] for pts in frame_ptss
169+
get_frame_at_pts(decoder, seconds=pts)[0] for pts in timestamps
170170
]
171171

172172
frames, *_ = get_frames_by_pts(
173173
decoder,
174174
stream_index=stream_index,
175-
frame_ptss=frame_ptss,
175+
timestamps=timestamps,
176176
)
177177
for frame, expected_frame in zip(frames, expected_frames):
178178
assert_tensor_equal(frame, expected_frame)

0 commit comments

Comments
 (0)