diff --git a/src/torchcodec/decoders/_core/VideoDecoder.cpp b/src/torchcodec/decoders/_core/VideoDecoder.cpp index 94d2b9538..bcd020c45 100644 --- a/src/torchcodec/decoders/_core/VideoDecoder.cpp +++ b/src/torchcodec/decoders/_core/VideoDecoder.cpp @@ -1007,10 +1007,8 @@ void VideoDecoder::validateFrameIndex( VideoDecoder::DecodedOutput VideoDecoder::getFrameAtIndex( int streamIndex, - int64_t frameIndex, - std::optional preAllocatedOutputTensor) { - auto output = getFrameAtIndexInternal( - streamIndex, frameIndex, preAllocatedOutputTensor); + int64_t frameIndex) { + auto output = getFrameAtIndexInternal(streamIndex, frameIndex); output.frame = MaybePermuteHWC2CHW(streamIndex, output.frame); return output; } diff --git a/src/torchcodec/decoders/_core/VideoDecoder.h b/src/torchcodec/decoders/_core/VideoDecoder.h index 7411af187..ce4a0cc10 100644 --- a/src/torchcodec/decoders/_core/VideoDecoder.h +++ b/src/torchcodec/decoders/_core/VideoDecoder.h @@ -225,7 +225,11 @@ class VideoDecoder { // seconds=5.999, etc. DecodedOutput getFramePlayedAtTimestampNoDemux(double seconds); - DecodedOutput getFrameAtIndex( + DecodedOutput getFrameAtIndex(int streamIndex, int64_t frameIndex); + // This is morally private but needs to be exposed for C++ tests. Once + // getFrameAtIndex supports the preAllocatedOutputTensor parameter, we can + // move it back to private. + DecodedOutput getFrameAtIndexInternal( int streamIndex, int64_t frameIndex, std::optional preAllocatedOutputTensor = std::nullopt); @@ -387,10 +391,6 @@ class VideoDecoder { DecodedOutput& output, std::optional preAllocatedOutputTensor = std::nullopt); - DecodedOutput getFrameAtIndexInternal( - int streamIndex, - int64_t frameIndex, - std::optional preAllocatedOutputTensor = std::nullopt); DecodedOutput getNextFrameOutputNoDemuxInternal( std::optional preAllocatedOutputTensor = std::nullopt); diff --git a/test/decoders/VideoDecoderTest.cpp b/test/decoders/VideoDecoderTest.cpp index 5f2e62203..1fbbd9a0c 100644 --- a/test/decoders/VideoDecoderTest.cpp +++ b/test/decoders/VideoDecoderTest.cpp @@ -400,7 +400,7 @@ TEST_P(VideoDecoderTest, PreAllocatedTensorFilterGraph) { bestVideoStreamIndex, VideoDecoder::VideoStreamDecoderOptions( "color_conversion_library=filtergraph")); - auto output = ourDecoder->getFrameAtIndex( + auto output = ourDecoder->getFrameAtIndexInternal( bestVideoStreamIndex, 0, preAllocatedOutputTensor); EXPECT_EQ(output.frame.data_ptr(), preAllocatedOutputTensor.data_ptr()); } @@ -418,7 +418,7 @@ TEST_P(VideoDecoderTest, PreAllocatedTensorSwscale) { bestVideoStreamIndex, VideoDecoder::VideoStreamDecoderOptions( "color_conversion_library=swscale")); - auto output = ourDecoder->getFrameAtIndex( + auto output = ourDecoder->getFrameAtIndexInternal( bestVideoStreamIndex, 0, preAllocatedOutputTensor); EXPECT_EQ(output.frame.data_ptr(), preAllocatedOutputTensor.data_ptr()); }