Skip to content

Commit 7e4dd10

Browse files
committed
Define constant, add TODO for AVRational
1 parent f9c7297 commit 7e4dd10

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/torchcodec/_core/BetaCudaDeviceInterface.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,17 @@ static UniqueCUvideodecoder createDecoder(CUVIDEOFORMAT* videoFormat) {
9090
"x",
9191
caps.nMaxHeight);
9292

93+
// See nMaxMBCount in cuviddec.h
94+
constexpr unsigned int macroblockConstant = 256;
9395
TORCH_CHECK(
94-
videoFormat->coded_width * videoFormat->coded_height / 256 <=
96+
videoFormat->coded_width * videoFormat->coded_height /
97+
macroblockConstant <=
9598
caps.nMaxMBCount,
9699
"Video is too large (too many macroblocks). "
97-
"Provided (width * height / 256): ",
98-
videoFormat->coded_width * videoFormat->coded_height / 256,
100+
"Provided (width * height / ",
101+
macroblockConstant,
102+
"): ",
103+
videoFormat->coded_width * videoFormat->coded_height / macroblockConstant,
99104
" vs supported:",
100105
caps.nMaxMBCount);
101106

@@ -440,6 +445,9 @@ UniqueAVFrame BetaCudaDeviceInterface::convertCudaFrameToAVFrame(
440445
avFrame->format = AV_PIX_FMT_CUDA;
441446
avFrame->pts = dispInfo.timestamp; // == guessedPts
442447

448+
// TODONVDEC P0: Zero division error!!!
449+
// TODONVDEC P0: Move AVRational arithmetic to FFMPEGCommon, and put the
450+
// similar SingleStreamDecoder stuff there too.
443451
unsigned int frameRateNum = videoFormat_.frame_rate.numerator;
444452
unsigned int frameRateDen = videoFormat_.frame_rate.denominator;
445453
int64_t duration = static_cast<int64_t>((frameRateDen * timeBase_.den)) /

0 commit comments

Comments
 (0)