This post concerns NVDEC, the decoder library inside the Nvidia Video Codec SDK.
To map frames that have been demuxed, cuvidMapVideoFrame
is provided.
Lines 1109
-1116
from cuviddec.h
as part of Nvidia Video Codec SDK 12.1.14:
/****************************************************************************************************************************/
//! \fn CUresult CUDAAPI cuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr,
//! unsigned int * pPitch, CUVIDPROCPARAMS *pVPP);
//! Post-process and map video frame corresponding to nPicIdx for use in cuda. Returns cuda device pointer and associated
//! pitch of the video frame
/****************************************************************************************************************************/
extern CUresult CUDAAPI cuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr,
unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
As the docs note, this lets you access a CUdeviceptr
which contains your decoded memory. Part of this operation is supplying to the decoder a CUVIDPROCPARAMS
struct, which contains information about how to interpret the video output.
Lines 940
-964
from cuviddec.h
as part of Nvidia Video Codec SDK 12.1.14:
/******************************************************/
//! \struct CUVIDPROCPARAMS
//! Picture parameters for postprocessing
//! This structure is used in cuvidMapVideoFrame API
/******************************************************/
typedef struct _CUVIDPROCPARAMS
{
int progressive_frame; /**< IN: Input is progressive (deinterlace_mode will be ignored) */
int second_field; /**< IN: Output the second field (ignored if deinterlace mode is Weave) */
int top_field_first; /**< IN: Input frame is top field first (1st field is top, 2nd field is bottom) */
int unpaired_field; /**< IN: Input only contains one field (2nd field is invalid) */
// The fields below are used for raw YUV input
unsigned int reserved_flags; /**< Reserved for future use (set to zero) */
unsigned int reserved_zero; /**< Reserved (set to zero) */
unsigned long long raw_input_dptr; /**< IN: Input CUdeviceptr for raw YUV extensions */
unsigned int raw_input_pitch; /**< IN: pitch in bytes of raw YUV input (should be aligned appropriately) */
unsigned int raw_input_format; /**< IN: Input YUV format (cudaVideoCodec_enum) */
unsigned long long raw_output_dptr; /**< IN: Output CUdeviceptr for raw YUV extensions */
unsigned int raw_output_pitch; /**< IN: pitch in bytes of raw YUV output (should be aligned appropriately) */
unsigned int Reserved1; /**< Reserved for future use (set to zero) */
CUstream output_stream; /**< IN: stream object used by cuvidMapVideoFrame */
unsigned int Reserved[46]; /**< Reserved for future use (set to zero) */
unsigned long long *histogram_dptr; /**< OUT: Output CUdeviceptr for histogram extensions */
void *Reserved2[1]; /**< Reserved for future use (set to zero) */
} CUVIDPROCPARAMS;
Included in this struct are a selection of fields to be used with “raw YUV input”. What is this? The sample code pretends they don’t exisit. The docs do not acknowledge them either. I am unable to find any examples or even reference to these fields online.