Skip to content

Commit 8019219

Browse files
committed
Make getNextDecodedOutputNoDemux private
1 parent 3ae34c7 commit 8019219

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/torchcodec/decoders/_core/VideoDecoder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,6 @@ class VideoDecoder {
217217
// Decodes the frame where the current cursor position is. It also advances
218218
// the cursor to the next frame.
219219
DecodedOutput getNextFrame();
220-
DecodedOutput getNextDecodedOutputNoDemux(
221-
std::optional<torch::Tensor> preAllocatedOutputTensor = std::nullopt);
222220
// Decodes the first frame in any added stream that is visible at a given
223221
// timestamp. Frames in the video have a presentation timestamp and a
224222
// duration. For example, if a frame has presentation timestamp of 5.0s and a
@@ -393,6 +391,8 @@ class VideoDecoder {
393391
int streamIndex,
394392
int64_t frameIndex,
395393
std::optional<torch::Tensor> preAllocatedOutputTensor = std::nullopt);
394+
DecodedOutput getNextDecodedOutputNoDemux(
395+
std::optional<torch::Tensor> preAllocatedOutputTensor = std::nullopt);
396396

397397
DecoderOptions options_;
398398
ContainerMetadata containerMetadata_;

test/decoders/VideoDecoderTest.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ TEST(VideoDecoderTest, RespectsWidthAndHeightFromOptions) {
148148
streamOptions.width = 100;
149149
streamOptions.height = 120;
150150
decoder->addVideoStreamDecoder(-1, streamOptions);
151-
torch::Tensor tensor = decoder->getNextDecodedOutputNoDemux().frame;
151+
torch::Tensor tensor = decoder->getNextFrame().frame;
152152
EXPECT_EQ(tensor.sizes(), std::vector<long>({3, 120, 100}));
153153
}
154154

@@ -159,7 +159,7 @@ TEST(VideoDecoderTest, RespectsOutputTensorDimensionOrderFromOptions) {
159159
VideoDecoder::VideoStreamDecoderOptions streamOptions;
160160
streamOptions.dimensionOrder = "NHWC";
161161
decoder->addVideoStreamDecoder(-1, streamOptions);
162-
torch::Tensor tensor = decoder->getNextDecodedOutputNoDemux().frame;
162+
torch::Tensor tensor = decoder->getNextFrame().frame;
163163
EXPECT_EQ(tensor.sizes(), std::vector<long>({270, 480, 3}));
164164
}
165165

@@ -168,12 +168,12 @@ TEST_P(VideoDecoderTest, ReturnsFirstTwoFramesOfVideo) {
168168
std::unique_ptr<VideoDecoder> ourDecoder =
169169
createDecoderFromPath(path, GetParam());
170170
ourDecoder->addVideoStreamDecoder(-1);
171-
auto output = ourDecoder->getNextDecodedOutputNoDemux();
171+
auto output = ourDecoder->getNextFrame();
172172
torch::Tensor tensor0FromOurDecoder = output.frame;
173173
EXPECT_EQ(tensor0FromOurDecoder.sizes(), std::vector<long>({3, 270, 480}));
174174
EXPECT_EQ(output.ptsSeconds, 0.0);
175175
EXPECT_EQ(output.pts, 0);
176-
output = ourDecoder->getNextDecodedOutputNoDemux();
176+
output = ourDecoder->getNextFrame();
177177
torch::Tensor tensor1FromOurDecoder = output.frame;
178178
EXPECT_EQ(tensor1FromOurDecoder.sizes(), std::vector<long>({3, 270, 480}));
179179
EXPECT_EQ(output.ptsSeconds, 1'001. / 30'000);
@@ -254,11 +254,11 @@ TEST_P(VideoDecoderTest, SeeksCloseToEof) {
254254
createDecoderFromPath(path, GetParam());
255255
ourDecoder->addVideoStreamDecoder(-1);
256256
ourDecoder->setCursorPtsInSeconds(388388. / 30'000);
257-
auto output = ourDecoder->getNextDecodedOutputNoDemux();
257+
auto output = ourDecoder->getNextFrame();
258258
EXPECT_EQ(output.ptsSeconds, 388'388. / 30'000);
259-
output = ourDecoder->getNextDecodedOutputNoDemux();
259+
output = ourDecoder->getNextFrame();
260260
EXPECT_EQ(output.ptsSeconds, 389'389. / 30'000);
261-
EXPECT_THROW(ourDecoder->getNextDecodedOutputNoDemux(), std::exception);
261+
EXPECT_THROW(ourDecoder->getNextFrame(), std::exception);
262262
}
263263

264264
TEST_P(VideoDecoderTest, GetsFramePlayedAtTimestamp) {
@@ -298,7 +298,7 @@ TEST_P(VideoDecoderTest, SeeksToFrameWithSpecificPts) {
298298
createDecoderFromPath(path, GetParam());
299299
ourDecoder->addVideoStreamDecoder(-1);
300300
ourDecoder->setCursorPtsInSeconds(6.0);
301-
auto output = ourDecoder->getNextDecodedOutputNoDemux();
301+
auto output = ourDecoder->getNextFrame();
302302
torch::Tensor tensor6FromOurDecoder = output.frame;
303303
EXPECT_EQ(output.ptsSeconds, 180'180. / 30'000);
304304
torch::Tensor tensor6FromFFMPEG =
@@ -314,7 +314,7 @@ TEST_P(VideoDecoderTest, SeeksToFrameWithSpecificPts) {
314314
EXPECT_GT(ourDecoder->getDecodeStats().numPacketsSentToDecoder, 180);
315315

316316
ourDecoder->setCursorPtsInSeconds(6.1);
317-
output = ourDecoder->getNextDecodedOutputNoDemux();
317+
output = ourDecoder->getNextFrame();
318318
torch::Tensor tensor61FromOurDecoder = output.frame;
319319
EXPECT_EQ(output.ptsSeconds, 183'183. / 30'000);
320320
torch::Tensor tensor61FromFFMPEG =
@@ -334,7 +334,7 @@ TEST_P(VideoDecoderTest, SeeksToFrameWithSpecificPts) {
334334
EXPECT_LT(ourDecoder->getDecodeStats().numPacketsSentToDecoder, 10);
335335

336336
ourDecoder->setCursorPtsInSeconds(10.0);
337-
output = ourDecoder->getNextDecodedOutputNoDemux();
337+
output = ourDecoder->getNextFrame();
338338
torch::Tensor tensor10FromOurDecoder = output.frame;
339339
EXPECT_EQ(output.ptsSeconds, 300'300. / 30'000);
340340
torch::Tensor tensor10FromFFMPEG =
@@ -351,7 +351,7 @@ TEST_P(VideoDecoderTest, SeeksToFrameWithSpecificPts) {
351351
EXPECT_GT(ourDecoder->getDecodeStats().numPacketsSentToDecoder, 60);
352352

353353
ourDecoder->setCursorPtsInSeconds(6.0);
354-
output = ourDecoder->getNextDecodedOutputNoDemux();
354+
output = ourDecoder->getNextFrame();
355355
tensor6FromOurDecoder = output.frame;
356356
EXPECT_EQ(output.ptsSeconds, 180'180. / 30'000);
357357
EXPECT_TRUE(torch::equal(tensor6FromOurDecoder, tensor6FromFFMPEG));
@@ -366,7 +366,7 @@ TEST_P(VideoDecoderTest, SeeksToFrameWithSpecificPts) {
366366

367367
constexpr double kPtsOfLastFrameInVideoStream = 389'389. / 30'000; // ~12.9
368368
ourDecoder->setCursorPtsInSeconds(kPtsOfLastFrameInVideoStream);
369-
output = ourDecoder->getNextDecodedOutputNoDemux();
369+
output = ourDecoder->getNextFrame();
370370
torch::Tensor tensor7FromOurDecoder = output.frame;
371371
EXPECT_EQ(output.ptsSeconds, 389'389. / 30'000);
372372
torch::Tensor tensor7FromFFMPEG =

0 commit comments

Comments
 (0)