Skip to content

Commit 9028793

Browse files
authored
Rename addVideoStreamDecoder into addVideoStream (#510)
1 parent a8299be commit 9028793

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

src/torchcodec/decoders/_core/VideoDecoder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ VideoDecoder::VideoStreamOptions::VideoStreamOptions(
418418
}
419419
}
420420

421-
void VideoDecoder::addVideoStreamDecoder(
421+
void VideoDecoder::addVideoStream(
422422
int streamIndex,
423423
const VideoStreamOptions& videoStreamOptions) {
424424
TORCH_CHECK(

src/torchcodec/decoders/_core/VideoDecoder.h

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

137137
struct AudioStreamOptions {};
138138

139-
void addVideoStreamDecoder(
139+
void addVideoStream(
140140
int streamIndex,
141141
const VideoStreamOptions& videoStreamOptions = VideoStreamOptions());
142142
void addAudioStreamDecoder(

src/torchcodec/decoders/_core/VideoDecoderOps.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,7 @@ void _add_video_stream(
220220
}
221221

222222
auto videoDecoder = unwrapTensorToGetDecoder(decoder);
223-
videoDecoder->addVideoStreamDecoder(
224-
stream_index.value_or(-1), videoStreamOptions);
223+
videoDecoder->addVideoStream(stream_index.value_or(-1), videoStreamOptions);
225224
}
226225

227226
void seek_to_pts(at::Tensor& decoder, double seconds) {

test/decoders/VideoDecoderTest.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ TEST(VideoDecoderTest, RespectsWidthAndHeightFromOptions) {
148148
VideoDecoder::VideoStreamOptions videoStreamOptions;
149149
videoStreamOptions.width = 100;
150150
videoStreamOptions.height = 120;
151-
decoder->addVideoStreamDecoder(-1, videoStreamOptions);
151+
decoder->addVideoStream(-1, videoStreamOptions);
152152
torch::Tensor tensor = decoder->getNextFrame().data;
153153
EXPECT_EQ(tensor.sizes(), std::vector<long>({3, 120, 100}));
154154
}
@@ -158,7 +158,7 @@ TEST(VideoDecoderTest, RespectsOutputTensorDimensionOrderFromOptions) {
158158
std::unique_ptr<VideoDecoder> decoder = std::make_unique<VideoDecoder>(path);
159159
VideoDecoder::VideoStreamOptions videoStreamOptions;
160160
videoStreamOptions.dimensionOrder = "NHWC";
161-
decoder->addVideoStreamDecoder(-1, videoStreamOptions);
161+
decoder->addVideoStream(-1, videoStreamOptions);
162162
torch::Tensor tensor = decoder->getNextFrame().data;
163163
EXPECT_EQ(tensor.sizes(), std::vector<long>({270, 480, 3}));
164164
}
@@ -167,7 +167,7 @@ TEST_P(VideoDecoderTest, ReturnsFirstTwoFramesOfVideo) {
167167
std::string path = getResourcePath("nasa_13013.mp4");
168168
std::unique_ptr<VideoDecoder> ourDecoder =
169169
createDecoderFromPath(path, GetParam());
170-
ourDecoder->addVideoStreamDecoder(-1);
170+
ourDecoder->addVideoStream(-1);
171171
auto output = ourDecoder->getNextFrame();
172172
torch::Tensor tensor0FromOurDecoder = output.data;
173173
EXPECT_EQ(tensor0FromOurDecoder.sizes(), std::vector<long>({3, 270, 480}));
@@ -206,7 +206,7 @@ TEST_P(VideoDecoderTest, DecodesFramesInABatchInNCHW) {
206206
ourDecoder->scanFileAndUpdateMetadataAndIndex();
207207
int bestVideoStreamIndex =
208208
*ourDecoder->getContainerMetadata().bestVideoStreamIndex;
209-
ourDecoder->addVideoStreamDecoder(bestVideoStreamIndex);
209+
ourDecoder->addVideoStream(bestVideoStreamIndex);
210210
// Frame with index 180 corresponds to timestamp 6.006.
211211
auto output = ourDecoder->getFramesAtIndices({0, 180});
212212
auto tensor = output.data;
@@ -228,7 +228,7 @@ TEST_P(VideoDecoderTest, DecodesFramesInABatchInNHWC) {
228228
ourDecoder->scanFileAndUpdateMetadataAndIndex();
229229
int bestVideoStreamIndex =
230230
*ourDecoder->getContainerMetadata().bestVideoStreamIndex;
231-
ourDecoder->addVideoStreamDecoder(
231+
ourDecoder->addVideoStream(
232232
bestVideoStreamIndex,
233233
VideoDecoder::VideoStreamOptions("dimension_order=NHWC"));
234234
// Frame with index 180 corresponds to timestamp 6.006.
@@ -250,7 +250,7 @@ TEST_P(VideoDecoderTest, SeeksCloseToEof) {
250250
std::string path = getResourcePath("nasa_13013.mp4");
251251
std::unique_ptr<VideoDecoder> ourDecoder =
252252
createDecoderFromPath(path, GetParam());
253-
ourDecoder->addVideoStreamDecoder(-1);
253+
ourDecoder->addVideoStream(-1);
254254
ourDecoder->setCursorPtsInSeconds(388388. / 30'000);
255255
auto output = ourDecoder->getNextFrame();
256256
EXPECT_EQ(output.ptsSeconds, 388'388. / 30'000);
@@ -263,7 +263,7 @@ TEST_P(VideoDecoderTest, GetsFramePlayedAtTimestamp) {
263263
std::string path = getResourcePath("nasa_13013.mp4");
264264
std::unique_ptr<VideoDecoder> ourDecoder =
265265
createDecoderFromPath(path, GetParam());
266-
ourDecoder->addVideoStreamDecoder(-1);
266+
ourDecoder->addVideoStream(-1);
267267
auto output = ourDecoder->getFramePlayedAt(6.006);
268268
EXPECT_EQ(output.ptsSeconds, 6.006);
269269
// The frame's duration is 0.033367 according to ffprobe,
@@ -293,7 +293,7 @@ TEST_P(VideoDecoderTest, SeeksToFrameWithSpecificPts) {
293293
std::string path = getResourcePath("nasa_13013.mp4");
294294
std::unique_ptr<VideoDecoder> ourDecoder =
295295
createDecoderFromPath(path, GetParam());
296-
ourDecoder->addVideoStreamDecoder(-1);
296+
ourDecoder->addVideoStream(-1);
297297
ourDecoder->setCursorPtsInSeconds(6.0);
298298
auto output = ourDecoder->getNextFrame();
299299
torch::Tensor tensor6FromOurDecoder = output.data;
@@ -393,7 +393,7 @@ TEST_P(VideoDecoderTest, PreAllocatedTensorFilterGraph) {
393393
ourDecoder->scanFileAndUpdateMetadataAndIndex();
394394
int bestVideoStreamIndex =
395395
*ourDecoder->getContainerMetadata().bestVideoStreamIndex;
396-
ourDecoder->addVideoStreamDecoder(
396+
ourDecoder->addVideoStream(
397397
bestVideoStreamIndex,
398398
VideoDecoder::VideoStreamOptions("color_conversion_library=filtergraph"));
399399
auto output =
@@ -410,7 +410,7 @@ TEST_P(VideoDecoderTest, PreAllocatedTensorSwscale) {
410410
ourDecoder->scanFileAndUpdateMetadataAndIndex();
411411
int bestVideoStreamIndex =
412412
*ourDecoder->getContainerMetadata().bestVideoStreamIndex;
413-
ourDecoder->addVideoStreamDecoder(
413+
ourDecoder->addVideoStream(
414414
bestVideoStreamIndex,
415415
VideoDecoder::VideoStreamOptions("color_conversion_library=swscale"));
416416
auto output =

0 commit comments

Comments
 (0)