@@ -97,12 +97,17 @@ static UniqueCUvideodecoder createDecoder(CUVIDEOFORMAT* videoFormat) {
9797 " x" ,
9898 caps.nMaxHeight );
9999
100+ // See nMaxMBCount in cuviddec.h
101+ constexpr unsigned int macroblockConstant = 256 ;
100102 TORCH_CHECK (
101- videoFormat->coded_width * videoFormat->coded_height / 256 <=
103+ videoFormat->coded_width * videoFormat->coded_height /
104+ macroblockConstant <=
102105 caps.nMaxMBCount ,
103106 " 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,
106111 " vs supported:" ,
107112 caps.nMaxMBCount );
108113
@@ -310,8 +315,10 @@ void BetaCudaDeviceInterface::applyBSF(ReferenceAVPacket& packet) {
310315 // fields of the filtered packet into the original packet. The filtered packet
311316 // fields are re-set by av_packet_move_ref, so when it goes out of scope and
312317 // 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.
315322}
316323
317324// Parser triggers this callback within cuvidParseVideoData when a frame is
@@ -411,6 +418,9 @@ UniqueAVFrame BetaCudaDeviceInterface::convertCudaFrameToAVFrame(
411418 avFrame->format = AV_PIX_FMT_CUDA;
412419 avFrame->pts = dispInfo.timestamp ;
413420
421+ // TODONVDEC P0: Zero division error!!!
422+ // TODONVDEC P0: Move AVRational arithmetic to FFMPEGCommon, and put the
423+ // similar SingleStreamDecoder stuff there too.
414424 unsigned int frameRateNum = videoFormat_.frame_rate .numerator ;
415425 unsigned int frameRateDen = videoFormat_.frame_rate .denominator ;
416426 int64_t duration = static_cast <int64_t >((frameRateDen * timeBase_.den )) /
0 commit comments