Expand description
Raw FFI bindings to NVIDIA Video Codec SDK (nvcuvid + nvEncodeAPI).
Covers the minimal subset required by NvDecoder and
NvEncoder. Matches Video Codec SDK v12.x headers.
§Linking
build.rs emits -l nvcuvid and -l nvencodeapi (Windows: nvEncodeAPI64).
Libraries are located via CUDA_PATH env var.
§Safety
All functions in this module are unsafe extern "C". The safe wrappers
in nvdec.rs and nvenc.rs enforce invariants documented below.
Structs§
- CUDA_
MEMCP Y2D - 2D memory copy descriptor.
- CUVIDDECODECREATEINFO
- Parameters for
cuvidCreateDecoder. - CUVIDDECODECREATEINFO_
display_ area - Cropping rectangle for decode output.
- CUVIDDECODECREATEINFO_
target_ rect - Target output rectangle (scaling).
- CUVIDEOFORMAT
- Video format information emitted by the parser.
- CUVIDPARSERDISPINFO
- Parser dispatch info for a decoded picture.
- CUVIDPARSERPARAMS
- Parser creation params.
- CUVIDPICPARAMS
- Simplified picture params — full struct is codec-union, we use opaque bytes.
- CUVIDPROCPARAMS
- Processing params for
cuvidMapVideoFrame64. - CUVIDSOURCEDATAPACKET
- Bitstream packet fed to the parser.
- GUID
- GUID type mirroring Windows GUID layout.
- NV_
ENCODE_ API_ FUNCTION_ LIST - Subset of the NV_ENCODE_API_FUNCTION_LIST that we actually call.
- NV_
ENC_ CONFIG - Encoder configuration.
- NV_
ENC_ CONFIG_ HEVC - HEVC-specific config (simplified).
- NV_
ENC_ CREATE_ BITSTREAM_ BUFFER - Create bitstream buffer.
- NV_
ENC_ INITIALIZE_ PARAMS - Encoder initialization params.
- NV_
ENC_ LOCK_ BITSTREAM - Lock bitstream output.
- NV_
ENC_ MAP_ INPUT_ RESOURCE - Map input resource.
- NV_
ENC_ OPEN_ ENCODE_ SESSION_ EX_ PARAMS - Session open params.
- NV_
ENC_ PIC_ PARAMS - Encode picture params.
- NV_
ENC_ PRESET_ CONFIG - Preset config wrapper.
- NV_
ENC_ RC_ PARAMS - Rate control params (simplified).
- NV_
ENC_ REGISTER_ RESOURCE - Register external resource.
Enums§
- CUmemorytype
- NV_
ENC_ BUFFER_ FORMAT - NV_
ENC_ DEVICE_ TYPE - NV_
ENC_ INPUT_ RESOURCE_ TYPE - NV_
ENC_ PIC_ STRUCT - NV_
ENC_ PIC_ TYPE - NV_
ENC_ TUNING_ INFO - cuda
Video Chroma Format - cuda
Video Codec - cuda
Video Create Flags - cuda
Video Deinterlace Mode - cuda
Video Surface Format
Constants§
- CUDA_
SUCCESS - CUVID_
PKT_ DISCONTINUITY - CUVID_
PKT_ ENDOFSTREAM - Parser input flags.
- CUVID_
PKT_ TIMESTAMP - CU_
EVENT_ DISABLE_ TIMING - NVENCAPI_
MAJOR_ VERSION - Matches
NVENCAPI_MAJOR_VERSIONinnvEncodeAPI.h. - NVENCAPI_
MINOR_ VERSION - Matches
NVENCAPI_MINOR_VERSIONinnvEncodeAPI.h. - NVENCAPI_
VERSION - Matches
NVENCAPI_VERSIONinnvEncodeAPI.h. - NV_
ENCODE_ API_ FUNCTION_ LIST_ VER - NV_
ENC_ CODEC_ H264_ GUID - H.264 encode GUID.
- NV_
ENC_ CODEC_ HEVC_ GUID - H.265/HEVC encode GUID.
- NV_
ENC_ ERR_ DEVICE_ NOT_ EXIST - NV_
ENC_ ERR_ ENCODER_ BUSY - NV_
ENC_ ERR_ ENCODER_ NOT_ INITIALIZED - NV_
ENC_ ERR_ EVENT_ NOT_ REGISTERD - NV_
ENC_ ERR_ GENERIC - NV_
ENC_ ERR_ INVALID_ CALL - NV_
ENC_ ERR_ INVALID_ DEVICE - NV_
ENC_ ERR_ INVALID_ ENCODERDEVICE - NV_
ENC_ ERR_ INVALID_ EVENT - NV_
ENC_ ERR_ INVALID_ PARAM - NV_
ENC_ ERR_ INVALID_ PTR - NV_
ENC_ ERR_ INVALID_ VERSION - NV_
ENC_ ERR_ LOCK_ BUSY - NV_
ENC_ ERR_ MAP_ FAILED - NV_
ENC_ ERR_ NEED_ MORE_ INPUT - NV_
ENC_ ERR_ NOT_ ENOUGH_ BUFFER - NV_
ENC_ ERR_ NO_ ENCODE_ DEVICE - NV_
ENC_ ERR_ OUT_ OF_ MEMORY - NV_
ENC_ ERR_ UNSUPPORTED_ DEVICE - NV_
ENC_ ERR_ UNSUPPORTED_ PARAM - NV_
ENC_ HEVC_ PROFILE_ MAIN10_ GUID - H.265 Main10 profile GUID.
- NV_
ENC_ HEVC_ PROFILE_ MAIN_ GUID - H.265 Main profile GUID.
- NV_
ENC_ OPEN_ ENCODE_ SESSION_ EX_ PARAMS_ VER - NV_
ENC_ PIC_ FLAG_ EOS - End-of-stream flag for NV_ENC_PIC_PARAMS.
- NV_
ENC_ PIC_ FLAG_ FORCEIDR - Force IDR flag.
- NV_
ENC_ PRESET_ P7_ GUID - Low-latency high-quality preset GUID (P7).
- NV_
ENC_ SUCCESS
Functions§
- NvEncodeAPI
Create ⚠Instance - Entry point to get the NVENC function table.
- NvEncodeAPI
GetMax ⚠Supported Version - check_
cu - Convert a CUDA result to an engine Result.
- check_
nvenc - Convert an NVENC status to an engine Result.
- cuCtx
GetCurrent ⚠ - cuCtx
SetCurrent ⚠ - cuEvent
Create ⚠ - cuEvent
Destroy_ ⚠v2 - cuEvent
Record ⚠ - cuMemcpy2D
Async_ ⚠v2 - cuStream
Synchronize ⚠ - cuStream
Wait ⚠Event - cuvid
Create ⚠Decoder - cuvid
Create ⚠Video Parser - cuvid
Decode ⚠Picture - cuvid
Destroy ⚠Decoder - cuvid
Destroy ⚠Video Parser - cuvid
MapVideo ⚠Frame64 - cuvid
Parse ⚠Video Data - cuvid
Unmap ⚠Video Frame64 - nvenc_
status_ name - Human-readable NVENC status names for diagnostics.
- nvenc_
struct_ version - Matches
NVENCAPI_STRUCT_VERSION(ver)innvEncodeAPI.h.
Type Aliases§
- CUcontext
- CUDA context handle.
- CUdeviceptr
- CUDA device pointer (64-bit).
- CUevent
- CUDA event handle.
- CUresult
- CUDA result code.
- CUstream
- CUDA stream handle.
- CUvideodecoder
- Opaque decoder handle.
- CUvideoparser
- Opaque parser handle.
- NVENCSTATUS
- NVENC status code.
- PFNVIDDECODECALLBACK
- Callback: a picture has been decoded.
- PFNVIDDISPLAYCALLBACK
- Callback: a decoded picture is ready for display.
- PFNVIDSEQUENCECALLBACK
- Callback: sequence header parsed (reports format).
Unions§
- NV_
ENC_ CODEC_ CONFIG - Codec-specific config union (simplified — only HEVC used).