Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify getHeightAndWidthFromOptionsOrAVFrame
NicolasHug committed Mar 17, 2025
commit b07d188834495c7c91c451273ea735a0ce59152c
2 changes: 1 addition & 1 deletion src/torchcodec/decoders/_core/CudaDevice.cpp
Original file line number Diff line number Diff line change
@@ -198,7 +198,7 @@ void convertAVFrameToFrameOutputOnCuda(
"Expected format to be AV_PIX_FMT_CUDA, got " +
std::string(av_get_pix_fmt_name((AVPixelFormat)avFrame->format)));
auto frameDims = getHeightAndWidthFromOptionsOrAVFrame(
videoStreamOptions, *(avFrame.get()));
videoStreamOptions, avFrame);
int height = frameDims.height;
int width = frameDims.width;
torch::Tensor& dst = frameOutput.data;
8 changes: 4 additions & 4 deletions src/torchcodec/decoders/_core/VideoDecoder.cpp
Original file line number Diff line number Diff line change
@@ -1205,7 +1205,7 @@ void VideoDecoder::convertAVFrameToFrameOutputOnCPU(
auto& streamInfo = streamInfos_[activeStreamIndex_];

auto frameDims = getHeightAndWidthFromOptionsOrAVFrame(
streamInfo.videoStreamOptions, *(avFrame.get()));
streamInfo.videoStreamOptions, avFrame);
int expectedOutputHeight = frameDims.height;
int expectedOutputWidth = frameDims.width;

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

FrameDims getHeightAndWidthFromOptionsOrAVFrame(
const VideoDecoder::VideoStreamOptions& videoStreamOptions,
const AVFrame& avFrame) {
const UniqueAVFrame& avFrame) {
return FrameDims(
videoStreamOptions.height.value_or(avFrame.height),
videoStreamOptions.width.value_or(avFrame.width));
videoStreamOptions.height.value_or(avFrame->height),
videoStreamOptions.width.value_or(avFrame->width));
}

} // namespace facebook::torchcodec
2 changes: 1 addition & 1 deletion src/torchcodec/decoders/_core/VideoDecoder.h
Original file line number Diff line number Diff line change
@@ -552,7 +552,7 @@ FrameDims getHeightAndWidthFromOptionsOrMetadata(

FrameDims getHeightAndWidthFromOptionsOrAVFrame(
const VideoDecoder::VideoStreamOptions& videoStreamOptions,
const AVFrame& avFrame);
const UniqueAVFrame& avFrame);

torch::Tensor allocateEmptyHWCTensor(
int height,