NVDEC with reconfigure not working for non-1080p frames

I have a decoder class built on NVDEC that mostly used NvDecoder.cpp from the Video Codec SDK as a starting point:

It is provided, and only processes H.264 I-frames.

I started out using the class to decode (and resize) 1080p H.264 I-frames, and it works as expected. When I change the code to call cuvidReconfigureDecoder in the pfnSequenceCallback for frames of different resolutions, the frames are not decoded correctly. The
pfnDecodePicture and pfnDisplayPicture callbacks succeed, but the resulting decoded images look strange.

CUVIDRECONFIGUREDECODERINFO reconfigParams = { 0 };
reconfigParams.ulWidth = m_currentCodedWidth = pVideoFormat->coded_width;
reconfigParams.ulHeight = m_currentCodedHeight = pVideoFormat->coded_height;
reconfigParams.ulTargetWidth = pVideoFormat->coded_width;
reconfigParams.ulTargetHeight = pVideoFormat->coded_height;
reconfigParams.ulNumDecodeSurfaces = 1;

reconfigParams.display_area.left = pVideoFormat->display_area.left;
reconfigParams.display_area.top = pVideoFormat->display_area.top;
reconfigParams.display_area.right = pVideoFormat->display_area.right;
reconfigParams.display_area.bottom = pVideoFormat->display_area.bottom;

cuvidReconfigureDecoder(m_hDecoder, &reconfigParams);

Here are examples of the resulting decoded frames (Y channel):
Working 1080p frame: https://s3.amazonaws.com/publicartifacts/1080p_Success.png
Broken 720p frame: https://s3.amazonaws.com/publicartifacts/720P_Failure.png
Broken 480p frame: https://s3.amazonaws.com/publicartifacts/480p_Failure.png

This is my first attempt at using NVDEC, so I’m not sure what could be wrong here. I’m hoping the appearance of the decoded frames will give someone a clue as to what’s going on. This is all being run on a Tesla K80 with driver 410.104, and targeting version 8.2.16 of the Video Codec SDK.

Can anyone provide some insight in to what the problem is here?

I confirm, we faced with the same issue, trying to reconfigure NVDEC on Tesla K80.

While the general decoding is working well, after reconfiguration decoder started to provide damaged pictures, just like in the post above. Driver version 418.56, Cuda version 10.1, video codec SDK version 8.2.16.

Nevertheless it works perfect on RTX 2080ti.

+1

cuvidReconfigureDecoder not work on Tesla K80 I test on any version driver.

Dear nvidia developers, the problem really exists. Will there be any comments on this problem?

cuvidReconfigureDecoder - really not work on Tesla K80

result decode after cuvidReconfigureDecoder on Tesla k80 https://wetel.ru/CustomDecodeRgba.png

Hi.

We are investigating this issue and being tracked internally as 2834148.

Thanks.

Thanks for your answer!

In fact we were able to get more details. Decoder provide broken images when the input frame size is changed. It works as expected if only output image size changes.

So obvious workaround here is to use multiple decoders with fixed input dimensions.

Dear @mandar_godse, are there any updates regarding the opened ticket 2834148? I didn’t find bug tracking system so I place a comment here…

We integrated recently h.265 decoding module, based on NVDEC and we really need this issue to be fixed please.

thanks!

Dear Eugene.filin,
I successfully used reconfigure feature in NVDEC on Q 5000 GPU. I hope my method will help you resolve your issue.

How I did it.
I did not make any changes in NvDecoder.cpp file. My reconfigure function is very similar to below function.

int MyReconfigDecoder (NvDecoder *pNvDecoder, int newWidth, int newHeight)
{
Dim resizeDim = {};
// check arguments here.

// newWidth and newHeight "must" be less than or equal to the max_width and max_height set during NvDecoder create time.

// send CUVID_PKT_ENDOFSTREAM to NvDecoder
pNvDecoder->Decode (nullptr, 0, nullptr, nullptr);

resizeDim.w = newWidth;
resizeDim.h = newHeight;
// call NvDecoder's setReconfigParams
pNvDecoder->setReconfigParams(NULL, &resizeDim);

return 0;

}

During subsequent calls to NvDecoder::Decode () with input data, decoder will give callback to “HandleVideoSequence” which calls ReconfigureDecoder (pVideoFormat); by itself.

Best Regards
sp kamm