Skip to content

Commit 4dda5b7

Browse files
committed
Rename
1 parent 12c0e29 commit 4dda5b7

File tree

7 files changed

+25
-26
lines changed

7 files changed

+25
-26
lines changed

src/torchcodec/decoders/_core/VideoDecoder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,11 +1090,11 @@ VideoDecoder::BatchDecodedOutput VideoDecoder::getFramesAtIndices(
10901090
return output;
10911091
}
10921092

1093-
VideoDecoder::BatchDecodedOutput VideoDecoder::getFramesAtPtss(
1093+
VideoDecoder::BatchDecodedOutput VideoDecoder::getFramesDisplayedByTimestamps(
10941094
int streamIndex,
1095-
const std::vector<double>& framePtss){
1095+
const std::vector<double>& framePtss) {
10961096
validateUserProvidedStreamIndex(streamIndex);
1097-
validateScannedAllStreams("getFramesAtPtss");
1097+
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

src/torchcodec/decoders/_core/VideoDecoder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ class VideoDecoder {
244244
int streamIndex,
245245
const std::vector<int64_t>& frameIndices);
246246

247-
BatchDecodedOutput getFramesAtPtss(
247+
BatchDecodedOutput getFramesDisplayedByTimestamps(
248248
int streamIndex,
249249
const std::vector<double>& framePtss);
250250

src/torchcodec/decoders/_core/VideoDecoderOps.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ TORCH_LIBRARY(torchcodec_ns, m) {
4141
"get_frame_at_index(Tensor(a!) decoder, *, int stream_index, int frame_index) -> (Tensor, Tensor, Tensor)");
4242
m.def(
4343
"get_frames_at_indices(Tensor(a!) decoder, *, int stream_index, int[] frame_indices) -> (Tensor, Tensor, Tensor)");
44-
m.def(
45-
"get_frames_at_ptss(Tensor(a!) decoder, *, int stream_index, float[] frame_ptss) -> (Tensor, Tensor, Tensor)");
4644
m.def(
4745
"get_frames_in_range(Tensor(a!) decoder, *, int stream_index, int start, int stop, int? step=None) -> (Tensor, Tensor, Tensor)");
4846
m.def(
4947
"get_frames_by_pts_in_range(Tensor(a!) decoder, *, int stream_index, float start_seconds, float stop_seconds) -> (Tensor, Tensor, Tensor)");
48+
m.def(
49+
"get_frames_by_pts(Tensor(a!) decoder, *, int stream_index, float[] frame_ptss) -> (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(
@@ -211,17 +211,6 @@ OpsDecodedOutput get_frame_at_pts(at::Tensor& decoder, double seconds) {
211211
return makeOpsDecodedOutput(result);
212212
}
213213

214-
OpsBatchDecodedOutput get_frames_at_ptss(
215-
at::Tensor& decoder,
216-
int64_t stream_index,
217-
at::ArrayRef<double> frame_ptss) {
218-
auto videoDecoder = unwrapTensorToGetDecoder(decoder);
219-
std::vector<double> framePtssVec(frame_ptss.begin(), frame_ptss.end());
220-
auto result =
221-
videoDecoder->getFramesAtPtss(stream_index, framePtssVec);
222-
return makeOpsBatchDecodedOutput(result);
223-
}
224-
225214
OpsDecodedOutput get_frame_at_index(
226215
at::Tensor& decoder,
227216
int64_t stream_index,
@@ -253,6 +242,16 @@ OpsBatchDecodedOutput get_frames_in_range(
253242
stream_index, start, stop, step.value_or(1));
254243
return makeOpsBatchDecodedOutput(result);
255244
}
245+
OpsBatchDecodedOutput get_frames_by_pts(
246+
at::Tensor& decoder,
247+
int64_t stream_index,
248+
at::ArrayRef<double> frame_ptss) {
249+
auto videoDecoder = unwrapTensorToGetDecoder(decoder);
250+
std::vector<double> framePtssVec(frame_ptss.begin(), frame_ptss.end());
251+
auto result =
252+
videoDecoder->getFramesDisplayedByTimestamps(stream_index, framePtssVec);
253+
return makeOpsBatchDecodedOutput(result);
254+
}
256255

257256
OpsBatchDecodedOutput get_frames_by_pts_in_range(
258257
at::Tensor& decoder,
@@ -496,9 +495,9 @@ TORCH_LIBRARY_IMPL(torchcodec_ns, CPU, m) {
496495
m.impl("get_frame_at_pts", &get_frame_at_pts);
497496
m.impl("get_frame_at_index", &get_frame_at_index);
498497
m.impl("get_frames_at_indices", &get_frames_at_indices);
499-
m.impl("get_frames_at_ptss", &get_frames_at_ptss);
500498
m.impl("get_frames_in_range", &get_frames_in_range);
501499
m.impl("get_frames_by_pts_in_range", &get_frames_by_pts_in_range);
500+
m.impl("get_frames_by_pts", &get_frames_by_pts);
502501
m.impl("_test_frame_pts_equality", &_test_frame_pts_equality);
503502
m.impl(
504503
"scan_all_streams_to_update_metadata",

src/torchcodec/decoders/_core/VideoDecoderOps.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ using OpsBatchDecodedOutput = std::tuple<at::Tensor, at::Tensor, at::Tensor>;
7676
OpsDecodedOutput get_frame_at_pts(at::Tensor& decoder, double seconds);
7777

7878
// Return the frames at given ptss for a given stream
79-
OpsBatchDecodedOutput get_frames_at_ptss(
79+
OpsBatchDecodedOutput get_frames_by_pts(
8080
at::Tensor& decoder,
8181
int64_t stream_index,
8282
at::ArrayRef<double> frame_ptss);

src/torchcodec/decoders/_core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
get_frame_at_index,
2323
get_frame_at_pts,
2424
get_frames_at_indices,
25-
get_frames_at_ptss,
25+
get_frames_by_pts,
2626
get_frames_by_pts_in_range,
2727
get_frames_in_range,
2828
get_json_metadata,

src/torchcodec/decoders/_core/video_decoder_ops.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def load_torchcodec_extension():
7171
get_frame_at_pts = torch.ops.torchcodec_ns.get_frame_at_pts.default
7272
get_frame_at_index = torch.ops.torchcodec_ns.get_frame_at_index.default
7373
get_frames_at_indices = torch.ops.torchcodec_ns.get_frames_at_indices.default
74-
get_frames_at_ptss = torch.ops.torchcodec_ns.get_frames_at_ptss.default
74+
get_frames_by_pts = torch.ops.torchcodec_ns.get_frames_by_pts.default
7575
get_frames_in_range = torch.ops.torchcodec_ns.get_frames_in_range.default
7676
get_frames_by_pts_in_range = torch.ops.torchcodec_ns.get_frames_by_pts_in_range.default
7777
get_json_metadata = torch.ops.torchcodec_ns.get_json_metadata.default
@@ -173,8 +173,8 @@ def get_frame_at_pts_abstract(
173173
)
174174

175175

176-
@register_fake("torchcodec_ns::get_frames_at_ptss")
177-
def get_frames_at_pts_abstract(
176+
@register_fake("torchcodec_ns::get_frames_by_pts")
177+
def get_frames_by_pts_abstract(
178178
decoder: torch.Tensor,
179179
*,
180180
stream_index: int,

test/decoders/test_video_decoder_ops.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
get_frame_at_index,
2828
get_frame_at_pts,
2929
get_frames_at_indices,
30-
get_frames_at_ptss,
30+
get_frames_by_pts,
3131
get_frames_by_pts_in_range,
3232
get_frames_in_range,
3333
get_json_metadata,
@@ -156,7 +156,7 @@ def test_get_frames_at_indices_unsorted_indices(self):
156156
with pytest.raises(AssertionError):
157157
assert_tensor_equal(frames[0], frames[-1])
158158

159-
def test_get_frames_at_ptss(self):
159+
def test_get_frames_by_pts(self):
160160
decoder = create_from_file(str(NASA_VIDEO.path))
161161
_add_video_stream(decoder)
162162
scan_all_streams_to_update_metadata(decoder)
@@ -168,7 +168,7 @@ def test_get_frames_at_ptss(self):
168168
get_frame_at_pts(decoder, seconds=pts)[0] for pts in frame_ptss
169169
]
170170

171-
frames, *_ = get_frames_at_ptss(
171+
frames, *_ = get_frames_by_pts(
172172
decoder,
173173
stream_index=stream_index,
174174
frame_ptss=frame_ptss,

0 commit comments

Comments
 (0)