@@ -97,12 +97,17 @@ static UniqueCUvideodecoder createDecoder(CUVIDEOFORMAT* videoFormat) {
97
97
" x" ,
98
98
caps.nMaxHeight );
99
99
100
+ // See nMaxMBCount in cuviddec.h
101
+ constexpr unsigned int macroblockConstant = 256 ;
100
102
TORCH_CHECK (
101
- videoFormat->coded_width * videoFormat->coded_height / 256 <=
103
+ videoFormat->coded_width * videoFormat->coded_height /
104
+ macroblockConstant <=
102
105
caps.nMaxMBCount ,
103
106
" Video is too large (too many macroblocks). "
104
- " Provided (width * height / 256): " ,
105
- videoFormat->coded_width * videoFormat->coded_height / 256 ,
107
+ " Provided (width * height / " ,
108
+ macroblockConstant,
109
+ " ): " ,
110
+ videoFormat->coded_width * videoFormat->coded_height / macroblockConstant,
106
111
" vs supported:" ,
107
112
caps.nMaxMBCount );
108
113
@@ -310,8 +315,10 @@ void BetaCudaDeviceInterface::applyBSF(ReferenceAVPacket& packet) {
310
315
// fields of the filtered packet into the original packet. The filtered packet
311
316
// fields are re-set by av_packet_move_ref, so when it goes out of scope and
312
317
// gets destructed, it's not going to affect the original packet.
313
- av_packet_unref (packet.get ());
314
- av_packet_move_ref (packet.get (), filteredPacket.get ());
318
+ packet.reset (filteredPacket);
319
+ // TODONVDEC P0: consider cleaner ways to do this. Maybe we should let
320
+ // applyBSF return a new packet, and maybe that new packet needs to be a field
321
+ // on the interface to avoid complex lifetime issues.
315
322
}
316
323
317
324
// Parser triggers this callback within cuvidParseVideoData when a frame is
@@ -411,6 +418,9 @@ UniqueAVFrame BetaCudaDeviceInterface::convertCudaFrameToAVFrame(
411
418
avFrame->format = AV_PIX_FMT_CUDA;
412
419
avFrame->pts = dispInfo.timestamp ;
413
420
421
+ // TODONVDEC P0: Zero division error!!!
422
+ // TODONVDEC P0: Move AVRational arithmetic to FFMPEGCommon, and put the
423
+ // similar SingleStreamDecoder stuff there too.
414
424
unsigned int frameRateNum = videoFormat_.frame_rate .numerator ;
415
425
unsigned int frameRateDen = videoFormat_.frame_rate .denominator ;
416
426
int64_t duration = static_cast <int64_t >((frameRateDen * timeBase_.den )) /
0 commit comments