Skip to content

Commit 2f5f3b2

Browse files
committed
Improve convertAVFrameToTensorUsingSwsScale
1 parent b07d188 commit 2f5f3b2

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/torchcodec/decoders/_core/VideoDecoder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,7 @@ void VideoDecoder::convertAVFrameToFrameOutputOnCPU(
12481248
streamInfo.prevFrameContext = frameContext;
12491249
}
12501250
int resultHeight =
1251-
convertAVFrameToTensorUsingSwsScale(avFrame.get(), outputTensor);
1251+
convertAVFrameToTensorUsingSwsScale(avFrame, outputTensor);
12521252
// If this check failed, it would mean that the frame wasn't reshaped to
12531253
// the expected height.
12541254
// TODO: Can we do the same check for width?
@@ -1299,7 +1299,7 @@ void VideoDecoder::convertAVFrameToFrameOutputOnCPU(
12991299
}
13001300

13011301
int VideoDecoder::convertAVFrameToTensorUsingSwsScale(
1302-
const AVFrame* avFrame,
1302+
UniqueAVFrame& avFrame,
13031303
torch::Tensor& outputTensor) {
13041304
StreamInfo& activeStreamInfo = streamInfos_[activeStreamIndex_];
13051305
SwsContext* swsContext = activeStreamInfo.swsContext.get();

src/torchcodec/decoders/_core/VideoDecoder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ class VideoDecoder {
384384
const AVFrame* srcAVFrame);
385385

386386
int convertAVFrameToTensorUsingSwsScale(
387-
const AVFrame* avFrame,
387+
UniqueAVFrame& avFrame,
388388
torch::Tensor& outputTensor);
389389

390390
UniqueAVFrame convertAudioAVFrameSampleFormat(

0 commit comments

Comments
 (0)