Skip to content

Commit 22f6c2f

Browse files
committed
Better convertAVFrameToTensorUsingFilterGraph
1 parent 2f5f3b2 commit 22f6c2f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/torchcodec/decoders/_core/VideoDecoder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,7 @@ void VideoDecoder::convertAVFrameToFrameOutputOnCPU(
12681268
createFilterGraph(streamInfo, expectedOutputHeight, expectedOutputWidth);
12691269
streamInfo.prevFrameContext = frameContext;
12701270
}
1271-
outputTensor = convertAVFrameToTensorUsingFilterGraph(avFrame.get());
1271+
outputTensor = convertAVFrameToTensorUsingFilterGraph(avFrame);
12721272

12731273
// Similarly to above, if this check fails it means the frame wasn't
12741274
// reshaped to its expected dimensions by filtergraph.
@@ -1319,11 +1319,11 @@ int VideoDecoder::convertAVFrameToTensorUsingSwsScale(
13191319
}
13201320

13211321
torch::Tensor VideoDecoder::convertAVFrameToTensorUsingFilterGraph(
1322-
const AVFrame* avFrame) {
1322+
const UniqueAVFrame& avFrame) {
13231323
FilterGraphContext& filterGraphContext =
13241324
streamInfos_[activeStreamIndex_].filterGraphContext;
13251325
int status =
1326-
av_buffersrc_write_frame(filterGraphContext.sourceContext, avFrame);
1326+
av_buffersrc_write_frame(filterGraphContext.sourceContext, avFrame.get());
13271327
if (status < AVSUCCESS) {
13281328
throw std::runtime_error("Failed to add frame to buffer source context");
13291329
}

src/torchcodec/decoders/_core/VideoDecoder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,12 @@ class VideoDecoder {
376376
std::optional<torch::Tensor> preAllocatedOutputTensor = std::nullopt);
377377

378378
void convertAudioAVFrameToFrameOutputOnCPU(
379-
UniqueAVFrame& avFrame,
379+
UniqueAVFrame& srcAVFrame,
380380
FrameOutput& frameOutput,
381381
std::optional<torch::Tensor> preAllocatedOutputTensor = std::nullopt);
382382

383383
torch::Tensor convertAVFrameToTensorUsingFilterGraph(
384-
const AVFrame* srcAVFrame);
384+
const UniqueAVFrame& avFrame);
385385

386386
int convertAVFrameToTensorUsingSwsScale(
387387
UniqueAVFrame& avFrame,

0 commit comments

Comments
 (0)