Skip to main content

Module sys

Module sys 

Source
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_MEMCPY2D
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
cudaVideoChromaFormat
cudaVideoCodec
cudaVideoCreateFlags
cudaVideoDeinterlaceMode
cudaVideoSurfaceFormat

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_VERSION in nvEncodeAPI.h.
NVENCAPI_MINOR_VERSION
Matches NVENCAPI_MINOR_VERSION in nvEncodeAPI.h.
NVENCAPI_VERSION
Matches NVENCAPI_VERSION in nvEncodeAPI.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§

NvEncodeAPICreateInstance
Entry point to get the NVENC function table.
NvEncodeAPIGetMaxSupportedVersion
check_cu
Convert a CUDA result to an engine Result.
check_nvenc
Convert an NVENC status to an engine Result.
cuCtxGetCurrent
cuCtxSetCurrent
cuEventCreate
cuEventDestroy_v2
cuEventRecord
cuMemcpy2DAsync_v2
cuStreamSynchronize
cuStreamWaitEvent
cuvidCreateDecoder
cuvidCreateVideoParser
cuvidDecodePicture
cuvidDestroyDecoder
cuvidDestroyVideoParser
cuvidMapVideoFrame64
cuvidParseVideoData
cuvidUnmapVideoFrame64
nvenc_status_name
Human-readable NVENC status names for diagnostics.
nvenc_struct_version
Matches NVENCAPI_STRUCT_VERSION(ver) in nvEncodeAPI.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).