decodePicture CUDA cannot initialize and giving problems

I am trying to use the CUDA structure CUVIDPICPARAMS according to my needs. I want to decode only one byte at a time and has my own input data from the video. Here is how i am defining the struct to use as

CUVIDPICPARAMS pPictureParameters;
CUvideodecoder decoder_info;
memset(&oVideoDecodeCreateInfo, 0, sizeof(CUVIDDECODECREATEINFO));

oVideoDecodeCreateInfo.CodecType           = cudaVideoCodec_H264;// cudaVideoCodec_MPEG2;
oVideoDecodeCreateInfo.ulWidth             = width;
oVideoDecodeCreateInfo.ulHeight            = height;
oVideoDecodeCreateInfo.ulNumDecodeSurfaces = 20U;

while (oVideoDecodeCreateInfo.ulNumDecodeSurfaces * width * height > 16*1024*1024)

oVideoDecodeCreateInfo.ChromaFormat        = cudaVideoChromaFormat_420;
oVideoDecodeCreateInfo.OutputFormat        = cudaVideoSurfaceFormat_NV12;
oVideoDecodeCreateInfo.DeinterlaceMode     = cudaVideoDeinterlaceMode_Adaptive;

// No scaling
oVideoDecodeCreateInfo.ulTargetWidth       = oVideoDecodeCreateInfo.ulWidth;
oVideoDecodeCreateInfo.ulTargetHeight      = oVideoDecodeCreateInfo.ulHeight;
oVideoDecodeCreateInfo.ulNumOutputSurfaces = 2;  // We won't simultaneously map more than 8 surfaces
oVideoDecodeCreateInfo.ulCreationFlags     = cudaVideoCreate_PreferCUDA;

//oVideoDecodeCreateInfo.vidLock             = vidCtxLock;

CUresult oResult = cuvidCreateDecoder(&decoder_info,&oVideoDecodeCreateInfo);
assert(CUDA_SUCCESS == oResult);

//CUresult result = cuvidDecodePicture();

int nDestPitch = width*4;
CUdeviceptr pDevPtr[2] = {0,0};
unsigned int pPitch = 0;

pPictureParameters.CurrPicIdx =  1;
pPictureParameters.field_pic_flag = 0;

pPictureParameters.PicWidthInMbs = (width+15)/16;
pPictureParameters.FrameHeightInMbs = (height+15)/16;
pPictureParameters.pBitstreamData = input_image;
pPictureParameters.nBitstreamDataLen = Datasize;
//pPictureParameters.pSliceDataOffsets = 0;
pPictureParameters.nNumSlices = pPictureParameters.FrameHeightInMbs;
pPictureParameters.pSliceDataOffsets = 0;
//pPictureParameters.bottom_field_flag = 0;

CUresult result = cuvidDecodePicture(decoder_info,&pPictureParameters);
assert(CUDA_SUCCESS == result);

I want to decode a single BYTE frame at a second so initializing the pic parameters. But i cannot initialize the H264 and other codec values. Can anybody help me out here in this situation. I am getting CUDA error of invalid value. Thank you.

Same problem for me too. Any help please.

This question is over a year old, but I’ll leave help for those searching. You’ll have to either get the parser functions working (defined in nvcuvid.h) or create an H264 parser of your own. The second option is not for the faint of heart. For this, you’ll need the 2003 and 2014 h264 spec documents to know what info to put where.