Skip to content

Commit b07d188

Browse files
committed
Simplify getHeightAndWidthFromOptionsOrAVFrame
1 parent 3141c18 commit b07d188

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/torchcodec/decoders/_core/CudaDevice.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ void convertAVFrameToFrameOutputOnCuda(
198198
"Expected format to be AV_PIX_FMT_CUDA, got " +
199199
std::string(av_get_pix_fmt_name((AVPixelFormat)avFrame->format)));
200200
auto frameDims = getHeightAndWidthFromOptionsOrAVFrame(
201-
videoStreamOptions, *(avFrame.get()));
201+
videoStreamOptions, avFrame);
202202
int height = frameDims.height;
203203
int width = frameDims.width;
204204
torch::Tensor& dst = frameOutput.data;

src/torchcodec/decoders/_core/VideoDecoder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ void VideoDecoder::convertAVFrameToFrameOutputOnCPU(
12051205
auto& streamInfo = streamInfos_[activeStreamIndex_];
12061206

12071207
auto frameDims = getHeightAndWidthFromOptionsOrAVFrame(
1208-
streamInfo.videoStreamOptions, *(avFrame.get()));
1208+
streamInfo.videoStreamOptions, avFrame);
12091209
int expectedOutputHeight = frameDims.height;
12101210
int expectedOutputWidth = frameDims.width;
12111211

@@ -1941,10 +1941,10 @@ FrameDims getHeightAndWidthFromOptionsOrMetadata(
19411941

19421942
FrameDims getHeightAndWidthFromOptionsOrAVFrame(
19431943
const VideoDecoder::VideoStreamOptions& videoStreamOptions,
1944-
const AVFrame& avFrame) {
1944+
const UniqueAVFrame& avFrame) {
19451945
return FrameDims(
1946-
videoStreamOptions.height.value_or(avFrame.height),
1947-
videoStreamOptions.width.value_or(avFrame.width));
1946+
videoStreamOptions.height.value_or(avFrame->height),
1947+
videoStreamOptions.width.value_or(avFrame->width));
19481948
}
19491949

19501950
} // namespace facebook::torchcodec

src/torchcodec/decoders/_core/VideoDecoder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ FrameDims getHeightAndWidthFromOptionsOrMetadata(
552552

553553
FrameDims getHeightAndWidthFromOptionsOrAVFrame(
554554
const VideoDecoder::VideoStreamOptions& videoStreamOptions,
555-
const AVFrame& avFrame);
555+
const UniqueAVFrame& avFrame);
556556

557557
torch::Tensor allocateEmptyHWCTensor(
558558
int height,

0 commit comments

Comments
 (0)