Skip to content

Commit 2cd2059

Browse files
committed
use const AVFrame& avFrame
1 parent e386b56 commit 2cd2059

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/torchcodec/decoders/_core/VideoDecoder.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ void VideoDecoder::convertAVFrameToDecodedOutputOnCPU(
901901
int height = 0;
902902
int width = 0;
903903
std::tie(height, width) =
904-
getHeightAndWidthFromOptionsOrAVFrame(streamInfo.options, frame);
904+
getHeightAndWidthFromOptionsOrAVFrame(streamInfo.options, *frame);
905905
if (preAllocatedOutputTensor.has_value()) {
906906
tensor = preAllocatedOutputTensor.value();
907907
auto shape = tensor.sizes();
@@ -1318,7 +1318,7 @@ void VideoDecoder::convertFrameToBufferUsingSwsScale(
13181318
int outputHeight = 0;
13191319
int outputWidth = 0;
13201320
std::tie(outputHeight, outputWidth) =
1321-
getHeightAndWidthFromOptionsOrAVFrame(activeStream.options, frame);
1321+
getHeightAndWidthFromOptionsOrAVFrame(activeStream.options, *frame);
13221322
if (activeStream.swsContext.get() == nullptr) {
13231323
SwsContext* swsContext = sws_getContext(
13241324
frame->width,
@@ -1387,7 +1387,7 @@ torch::Tensor VideoDecoder::convertFrameToTensorUsingFilterGraph(
13871387
int height = 0;
13881388
int width = 0;
13891389
std::tie(height, width) = getHeightAndWidthFromOptionsOrAVFrame(
1390-
streams_[streamIndex].options, filteredFrame.get());
1390+
streams_[streamIndex].options, *filteredFrame.get());
13911391
std::vector<int64_t> shape = {height, width, 3};
13921392

13931393
std::vector<int64_t> strides = {filteredFrame->linesize[0], 3, 1};
@@ -1423,10 +1423,10 @@ std::tuple<int, int> getHeightAndWidthFromOptionsOrMetadata(
14231423

14241424
std::tuple<int, int> getHeightAndWidthFromOptionsOrAVFrame(
14251425
const VideoDecoder::VideoStreamDecoderOptions& options,
1426-
AVFrame* avFrame) {
1426+
const AVFrame& avFrame) {
14271427
return std::make_tuple(
1428-
options.height.value_or(avFrame->height),
1429-
options.width.value_or(avFrame->width));
1428+
options.height.value_or(avFrame.height),
1429+
options.width.value_or(avFrame.width));
14301430
}
14311431

14321432
torch::Tensor allocateEmptyHWCTensor(

src/torchcodec/decoders/_core/VideoDecoder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ std::tuple<int, int> getHeightAndWidthFromOptionsOrMetadata(
463463

464464
std::tuple<int, int> getHeightAndWidthFromOptionsOrAVFrame(
465465
const VideoDecoder::VideoStreamDecoderOptions& options,
466-
AVFrame* avFrame);
466+
const AVFrame& avFrame);
467467

468468
torch::Tensor allocateEmptyHWCTensor(
469469
int height,

0 commit comments

Comments
 (0)