Skip to content

Commit 1456fd1

Browse files
committed
Align high-level decoding entry points names with Python
1 parent 95fafc0 commit 1456fd1

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

src/torchcodec/decoders/_core/VideoDecoder.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ void VideoDecoder::convertAVFrameToDecodedOutputOnCPU(
10641064
}
10651065
}
10661066

1067-
VideoDecoder::DecodedOutput VideoDecoder::getFramePlayedAtTimestampNoDemux(
1067+
VideoDecoder::DecodedOutput VideoDecoder::getFramePlayedAtNoDemux(
10681068
double seconds) {
10691069
for (auto& [streamIndex, streamInfo] : streamInfos_) {
10701070
double frameStartTime =
@@ -1314,7 +1314,7 @@ VideoDecoder::BatchDecodedOutput VideoDecoder::getFramesAtIndices(
13141314
return output;
13151315
}
13161316

1317-
VideoDecoder::BatchDecodedOutput VideoDecoder::getFramesPlayedByTimestamps(
1317+
VideoDecoder::BatchDecodedOutput VideoDecoder::getFramesPlayedAt(
13181318
int streamIndex,
13191319
const std::vector<double>& timestamps) {
13201320
validateUserProvidedStreamIndex(streamIndex);
@@ -1382,8 +1382,7 @@ VideoDecoder::BatchDecodedOutput VideoDecoder::getFramesInRange(
13821382
return output;
13831383
}
13841384

1385-
VideoDecoder::BatchDecodedOutput
1386-
VideoDecoder::getFramesPlayedByTimestampInRange(
1385+
VideoDecoder::BatchDecodedOutput VideoDecoder::getFramesPlayedInRange(
13871386
int streamIndex,
13881387
double startSeconds,
13891388
double stopSeconds) {

src/torchcodec/decoders/_core/VideoDecoder.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class VideoDecoder {
208208
// duration of 1.0s, it will be visible in the timestamp range [5.0, 6.0).
209209
// i.e. it will be returned when this function is called with seconds=5.0 or
210210
// seconds=5.999, etc.
211-
DecodedOutput getFramePlayedAtTimestampNoDemux(double seconds);
211+
DecodedOutput getFramePlayedAtNoDemux(double seconds);
212212

213213
DecodedOutput getFrameAtIndex(int streamIndex, int64_t frameIndex);
214214
// This is morally private but needs to be exposed for C++ tests. Once
@@ -236,7 +236,7 @@ class VideoDecoder {
236236
int streamIndex,
237237
const std::vector<int64_t>& frameIndices);
238238

239-
BatchDecodedOutput getFramesPlayedByTimestamps(
239+
BatchDecodedOutput getFramesPlayedAt(
240240
int streamIndex,
241241
const std::vector<double>& timestamps);
242242

@@ -265,7 +265,7 @@ class VideoDecoder {
265265
// Valid values for startSeconds and stopSeconds are:
266266
//
267267
// [minPtsSecondsFromScan, maxPtsSecondsFromScan)
268-
BatchDecodedOutput getFramesPlayedByTimestampInRange(
268+
BatchDecodedOutput getFramesPlayedInRange(
269269
int streamIndex,
270270
double startSeconds,
271271
double stopSeconds);

src/torchcodec/decoders/_core/VideoDecoderOps.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ OpsDecodedOutput get_next_frame(at::Tensor& decoder) {
245245

246246
OpsDecodedOutput get_frame_at_pts(at::Tensor& decoder, double seconds) {
247247
auto videoDecoder = unwrapTensorToGetDecoder(decoder);
248-
auto result = videoDecoder->getFramePlayedAtTimestampNoDemux(seconds);
248+
auto result = videoDecoder->getFramePlayedAtNoDemux(seconds);
249249
return makeOpsDecodedOutput(result);
250250
}
251251

@@ -287,8 +287,7 @@ OpsBatchDecodedOutput get_frames_by_pts(
287287
at::ArrayRef<double> timestamps) {
288288
auto videoDecoder = unwrapTensorToGetDecoder(decoder);
289289
std::vector<double> timestampsVec(timestamps.begin(), timestamps.end());
290-
auto result =
291-
videoDecoder->getFramesPlayedByTimestamps(stream_index, timestampsVec);
290+
auto result = videoDecoder->getFramesPlayedAt(stream_index, timestampsVec);
292291
return makeOpsBatchDecodedOutput(result);
293292
}
294293

@@ -298,7 +297,7 @@ OpsBatchDecodedOutput get_frames_by_pts_in_range(
298297
double start_seconds,
299298
double stop_seconds) {
300299
auto videoDecoder = unwrapTensorToGetDecoder(decoder);
301-
auto result = videoDecoder->getFramesPlayedByTimestampInRange(
300+
auto result = videoDecoder->getFramesPlayedInRange(
302301
stream_index, start_seconds, stop_seconds);
303302
return makeOpsBatchDecodedOutput(result);
304303
}

test/decoders/VideoDecoderTest.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,18 +267,18 @@ TEST_P(VideoDecoderTest, GetsFramePlayedAtTimestamp) {
267267
std::unique_ptr<VideoDecoder> ourDecoder =
268268
createDecoderFromPath(path, GetParam());
269269
ourDecoder->addVideoStreamDecoder(-1);
270-
auto output = ourDecoder->getFramePlayedAtTimestampNoDemux(6.006);
270+
auto output = ourDecoder->getFramePlayedAtNoDemux(6.006);
271271
EXPECT_EQ(output.ptsSeconds, 6.006);
272272
// The frame's duration is 0.033367 according to ffprobe,
273273
// so the next frame is played at timestamp=6.039367.
274274
const double kNextFramePts = 6.039366666666667;
275275
// The frame that is played a microsecond before the next frame is still
276276
// the previous frame.
277-
output = ourDecoder->getFramePlayedAtTimestampNoDemux(kNextFramePts - 1e-6);
277+
output = ourDecoder->getFramePlayedAtNoDemux(kNextFramePts - 1e-6);
278278
EXPECT_EQ(output.ptsSeconds, 6.006);
279279
// The frame that is played at the exact pts of the frame is the next
280280
// frame.
281-
output = ourDecoder->getFramePlayedAtTimestampNoDemux(kNextFramePts);
281+
output = ourDecoder->getFramePlayedAtNoDemux(kNextFramePts);
282282
EXPECT_EQ(output.ptsSeconds, kNextFramePts);
283283

284284
// This is the timestamp of the last frame in this video.
@@ -288,8 +288,8 @@ TEST_P(VideoDecoderTest, GetsFramePlayedAtTimestamp) {
288288
kPtsOfLastFrameInVideoStream + kDurationOfLastFrameInVideoStream;
289289
// Sanity check: make sure duration is strictly positive.
290290
EXPECT_GT(kPtsPlusDurationOfLastFrame, kPtsOfLastFrameInVideoStream);
291-
output = ourDecoder->getFramePlayedAtTimestampNoDemux(
292-
kPtsPlusDurationOfLastFrame - 1e-6);
291+
output =
292+
ourDecoder->getFramePlayedAtNoDemux(kPtsPlusDurationOfLastFrame - 1e-6);
293293
EXPECT_EQ(output.ptsSeconds, kPtsOfLastFrameInVideoStream);
294294
}
295295

0 commit comments

Comments
 (0)