FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions
Video Decoder

Data Structures

struct  CUVIDDECODECREATEINFO
 
struct  CUVIDH264DPBENTRY
 
struct  CUVIDH264MVCEXT
 
struct  CUVIDH264SVCEXT
 
struct  CUVIDH264PICPARAMS
 
struct  CUVIDMPEG2PICPARAMS
 
struct  CUVIDMPEG4PICPARAMS
 
struct  CUVIDVC1PICPARAMS
 
struct  CUVIDJPEGPICPARAMS
 
struct  CUVIDHEVCPICPARAMS
 
struct  CUVIDVP8PICPARAMS
 
struct  CUVIDVP9PICPARAMS
 
struct  CUVIDPICPARAMS
 
struct  CUVIDPROCPARAMS
 

Macros

#define I_VOP   0
 
#define P_VOP   1
 
#define B_VOP   2
 
#define S_VOP   3
 

Enumerations

enum  cudaVideoCodec {
  cudaVideoCodec_MPEG1 =0, cudaVideoCodec_MPEG2, cudaVideoCodec_MPEG4, cudaVideoCodec_VC1,
  cudaVideoCodec_H264, cudaVideoCodec_JPEG, cudaVideoCodec_H264_SVC, cudaVideoCodec_H264_MVC,
  cudaVideoCodec_HEVC, cudaVideoCodec_VP8, cudaVideoCodec_VP9, cudaVideoCodec_NumCodecs,
  cudaVideoCodec_YUV420 = (('I'<<24)|('Y'<<16)|('U'<<8)|('V')), cudaVideoCodec_YV12 = (('Y'<<24)|('V'<<16)|('1'<<8)|('2')), cudaVideoCodec_NV12 = (('N'<<24)|('V'<<16)|('1'<<8)|('2')), cudaVideoCodec_YUYV = (('Y'<<24)|('U'<<16)|('Y'<<8)|('V')),
  cudaVideoCodec_UYVY = (('U'<<24)|('Y'<<16)|('V'<<8)|('Y'))
}
 
enum  cudaVideoSurfaceFormat { cudaVideoSurfaceFormat_NV12 =0 }
 
enum  cudaVideoDeinterlaceMode { cudaVideoDeinterlaceMode_Weave =0, cudaVideoDeinterlaceMode_Bob, cudaVideoDeinterlaceMode_Adaptive }
 
enum  cudaVideoChromaFormat { cudaVideoChromaFormat_Monochrome =0, cudaVideoChromaFormat_420, cudaVideoChromaFormat_422, cudaVideoChromaFormat_444 }
 
enum  cudaVideoCreateFlags { cudaVideoCreate_Default = 0x00, cudaVideoCreate_PreferCUDA = 0x01, cudaVideoCreate_PreferDXVA = 0x02, cudaVideoCreate_PreferCUVID = 0x04 }
 

Functions

CUresult CUDAAPI cuvidCreateDecoder (CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci)
 In order to minimize decode latencies, there should be always at least 2 pictures in the decode queue at any time, in order to make sure that all decode engines are always busy. More...
 
CUresult CUDAAPI cuvidDestroyDecoder (CUvideodecoder hDecoder)
 Destroy the decoder object. More...
 
CUresult CUDAAPI cuvidDecodePicture (CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams)
 Decode a single picture (field or frame) More...
 
CUresult CUDAAPI cuvidMapVideoFrame (CUvideodecoder hDecoder, int nPicIdx, unsigned int *pDevPtr, unsigned int *pPitch, CUVIDPROCPARAMS *pVPP)
 Post-process and map a video frame for use in cuda. More...
 
CUresult CUDAAPI cuvidUnmapVideoFrame (CUvideodecoder hDecoder, unsigned int DevPtr)
 Unmap a previously mapped video frame. More...
 
CUresult CUDAAPI cuvidCtxLockCreate (CUvideoctxlock *pLock, CUcontext ctx)
 Context-locking: to facilitate multi-threaded implementations, the following 4 functions provide a simple mutex-style host synchronization. More...
 
CUresult CUDAAPI cuvidCtxLockDestroy (CUvideoctxlock lck)
 
CUresult CUDAAPI cuvidCtxLock (CUvideoctxlock lck, unsigned int reserved_flags)
 
CUresult CUDAAPI cuvidCtxUnlock (CUvideoctxlock lck, unsigned int reserved_flags)
 

Detailed Description

Macro Definition Documentation

#define I_VOP   0

Definition at line 331 of file cuviddec.h.

#define P_VOP   1

Definition at line 332 of file cuviddec.h.

#define B_VOP   2

Definition at line 333 of file cuviddec.h.

#define S_VOP   3

Definition at line 334 of file cuviddec.h.

Enumeration Type Documentation

Video Codec Enums

Enumerator
cudaVideoCodec_MPEG1 

MPEG1.

cudaVideoCodec_MPEG2 

MPEG2.

cudaVideoCodec_MPEG4 

MPEG4.

cudaVideoCodec_VC1 

VC1.

cudaVideoCodec_H264 

H264.

cudaVideoCodec_JPEG 

JPEG.

cudaVideoCodec_H264_SVC 

H264-SVC.

cudaVideoCodec_H264_MVC 

H264-MVC.

cudaVideoCodec_HEVC 

HEVC.

cudaVideoCodec_VP8 

VP8.

cudaVideoCodec_VP9 

VP9.

cudaVideoCodec_NumCodecs 

Max COdecs.

cudaVideoCodec_YUV420 

Y,U,V (4:2:0)

cudaVideoCodec_YV12 

Y,V,U (4:2:0)

cudaVideoCodec_NV12 

Y,UV (4:2:0)

cudaVideoCodec_YUYV 

YUYV/YUY2 (4:2:2)

cudaVideoCodec_UYVY 

UYVY (4:2:2)

Definition at line 64 of file cuviddec.h.

Video Surface Formats Enums

Enumerator
cudaVideoSurfaceFormat_NV12 

NV12 (currently the only supported output format)

Definition at line 89 of file cuviddec.h.

Deinterlacing Modes Enums

Enumerator
cudaVideoDeinterlaceMode_Weave 

Weave both fields (no deinterlacing)

cudaVideoDeinterlaceMode_Bob 

Drop one field.

cudaVideoDeinterlaceMode_Adaptive 

Adaptive deinterlacing.

Definition at line 97 of file cuviddec.h.

Chroma Formats Enums

Enumerator
cudaVideoChromaFormat_Monochrome 

MonoChrome.

cudaVideoChromaFormat_420 

4:2:0

cudaVideoChromaFormat_422 

4:2:2

cudaVideoChromaFormat_444 

4:4:4

Definition at line 107 of file cuviddec.h.

Decoder Flags Enums

Enumerator
cudaVideoCreate_Default 

Default operation mode: use dedicated video engines.

cudaVideoCreate_PreferCUDA 

Use a CUDA-based decoder if faster than dedicated engines (requires a valid vidLock object for multi-threading)

cudaVideoCreate_PreferDXVA 

Go through DXVA internally if possible (requires D3D9 interop)

cudaVideoCreate_PreferCUVID 

Use dedicated video engines directly.

Definition at line 118 of file cuviddec.h.

Function Documentation

CUresult CUDAAPI cuvidCreateDecoder ( CUvideodecoder phDecoder,
CUVIDDECODECREATEINFO pdci 
)

In order to minimize decode latencies, there should be always at least 2 pictures in the decode queue at any time, in order to make sure that all decode engines are always busy.

Overall data flow:

  • cuvidCreateDecoder(...) For each picture:
  • cuvidDecodePicture(N)
  • cuvidMapVideoFrame(N-4)
  • do some processing in cuda
  • cuvidUnmapVideoFrame(N-4)
  • cuvidDecodePicture(N+1)
  • cuvidMapVideoFrame(N-3) ...
  • cuvidDestroyDecoder(...)

NOTE:

  • When the cuda context is created from a D3D device, the D3D device must also be created with the D3DCREATE_MULTITHREADED flag.
  • There is a limit to how many pictures can be mapped simultaneously (ulNumOutputSurfaces)
  • cuVidDecodePicture may block the calling thread if there are too many pictures pending in the decode queue

Create the decoder object

Referenced by cuvid_test_dummy_decoder().

CUresult CUDAAPI cuvidDestroyDecoder ( CUvideodecoder  hDecoder)

Destroy the decoder object.

Referenced by cuvid_decode_end(), cuvid_handle_video_sequence(), and cuvid_test_dummy_decoder().

CUresult CUDAAPI cuvidDecodePicture ( CUvideodecoder  hDecoder,
CUVIDPICPARAMS pPicParams 
)

Decode a single picture (field or frame)

Referenced by cuvid_handle_picture_decode().

CUresult CUDAAPI cuvidMapVideoFrame ( CUvideodecoder  hDecoder,
int  nPicIdx,
unsigned int *  pDevPtr,
unsigned int *  pPitch,
CUVIDPROCPARAMS pVPP 
)

Post-process and map a video frame for use in cuda.

Referenced by cuvid_output_frame().

CUresult CUDAAPI cuvidUnmapVideoFrame ( CUvideodecoder  hDecoder,
unsigned int  DevPtr 
)

Unmap a previously mapped video frame.

Referenced by cuvid_output_frame().

CUresult CUDAAPI cuvidCtxLockCreate ( CUvideoctxlock pLock,
CUcontext  ctx 
)

Context-locking: to facilitate multi-threaded implementations, the following 4 functions provide a simple mutex-style host synchronization.

If a non-NULL context is specified in CUVIDDECODECREATEINFO, the codec library will acquire the mutex associated with the given context before making any cuda calls. A multi-threaded application could create a lock associated with a context handle so that multiple threads can safely share the same cuda context:

  • use cuCtxPopCurrent immediately after context creation in order to create a 'floating' context that can be passed to cuvidCtxLockCreate.
  • When using a floating context, all cuda calls should only be made within a cuvidCtxLock/cuvidCtxUnlock section.

NOTE: This is a safer alternative to cuCtxPushCurrent and cuCtxPopCurrent, and is not related to video decoder in any way (implemented as a critical section associated with cuCtx{Push|Pop}Current calls).

CUresult CUDAAPI cuvidCtxLockDestroy ( CUvideoctxlock  lck)
CUresult CUDAAPI cuvidCtxLock ( CUvideoctxlock  lck,
unsigned int  reserved_flags 
)
CUresult CUDAAPI cuvidCtxUnlock ( CUvideoctxlock  lck,
unsigned int  reserved_flags 
)