28 #ifndef AV_COMPAT_CUDA_DYNLINK_LOADER_H
29 #define AV_COMPAT_CUDA_DYNLINK_LOADER_H
40 # define LIB_HANDLE HMODULE
42 # define LIB_HANDLE void*
45 #if defined(_WIN32) || defined(__CYGWIN__)
46 # define CUDA_LIBNAME "nvcuda.dll"
47 # define NVCUVID_LIBNAME "nvcuvid.dll"
49 # define NVENC_LIBNAME "nvEncodeAPI64.dll"
51 # define NVENC_LIBNAME "nvEncodeAPI.dll"
54 # define CUDA_LIBNAME "libcuda.so.1"
55 # define NVCUVID_LIBNAME "libnvcuvid.so.1"
56 # define NVENC_LIBNAME "libnvidia-encode.so.1"
59 #define LOAD_LIBRARY(l, path) \
61 if (!((l) = dlopen(path, RTLD_LAZY))) { \
62 av_log(NULL, AV_LOG_ERROR, "Cannot load %s\n", path); \
63 ret = AVERROR_UNKNOWN; \
66 av_log(NULL, AV_LOG_TRACE, "Loaded lib: %s\n", path); \
69 #define LOAD_SYMBOL(fun, tp, symbol) \
71 if (!((f->fun) = (tp*)dlsym(f->lib, symbol))) { \
72 av_log(NULL, AV_LOG_ERROR, "Cannot load %s\n", symbol); \
73 ret = AVERROR_UNKNOWN; \
76 av_log(NULL, AV_LOG_TRACE, "Loaded sym: %s\n", symbol); \
79 #define LOAD_SYMBOL_OPT(fun, tp, symbol) \
81 if (!((f->fun) = (tp*)dlsym(f->lib, symbol))) { \
82 av_log(NULL, AV_LOG_DEBUG, "Cannot load optional %s\n", symbol); \
84 av_log(NULL, AV_LOG_TRACE, "Loaded sym: %s\n", symbol); \
88 #define GENERIC_LOAD_FUNC_PREAMBLE(T, n, N) \
92 n##_free_functions(functions); \
94 f = *functions = av_mallocz(sizeof(*f)); \
96 return AVERROR(ENOMEM); \
98 LOAD_LIBRARY(f->lib, N);
100 #define GENERIC_LOAD_FUNC_FINALE(n) \
103 n##_free_functions(functions); \
106 #define GENERIC_FREE_FUNC() \
109 if (*functions && (*functions)->lib) \
110 dlclose((*functions)->lib); \
113 #ifdef AV_COMPAT_DYNLINK_CUDA_H
172 #ifdef AV_COMPAT_DYNLINK_CUDA_H
189 #ifdef AV_COMPAT_DYNLINK_CUDA_H
221 #ifdef __CUVID_DEVPTR64
257 #undef GENERIC_LOAD_FUNC_PREAMBLE
260 #undef GENERIC_LOAD_FUNC_FINALE
261 #undef GENERIC_FREE_FUNC
263 #undef NVCUVID_LIBNAME
tcuvidGetSourceAudioFormat * cuvidGetSourceAudioFormat
CUresult CUDAAPI tcuvidDestroyVideoSource(CUvideosource obj)
tcuDeviceGetName * cuDeviceGetName
CUresult CUDAAPI tcuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams)
CUresult CUDAAPI tcuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx)
tcuvidCtxLockDestroy * cuvidCtxLockDestroy
CUresult CUDAAPI tcuCtxPushCurrent_v2(CUcontext *pctx)
CUresult CUDAAPI tcuDeviceComputeCapability(int *major, int *minor, CUdevice dev)
static void cuvid_free_functions(CuvidFunctions **functions)
NVIDIA GPUs - beginning with the Kepler generation - contain a hardware-based encoder (referred to as...
static const struct drawtext_function functions[]
tcuvidCtxUnlock * cuvidCtxUnlock
tcuvidUnmapVideoFrame * cuvidUnmapVideoFrame
NV_ENCODE_API_FUNCTION_LIST.
tcuvidSetVideoSourceState * cuvidSetVideoSourceState
CUresult CUDAAPI tcuMemAlloc_v2(CUdeviceptr *dptr, size_t bytesize)
tcuvidCtxLockCreate * cuvidCtxLockCreate
tcuMemFree_v2 * cuMemFree
tcuvidCtxLock * cuvidCtxLock
#define GENERIC_FREE_FUNC()
tcuvidGetVideoSourceState * cuvidGetVideoSourceState
CUresult CUDAAPI tcuGetErrorName(CUresult error, const char **pstr)
tcuvidGetDecoderCaps * cuvidGetDecoderCaps
tcuvidCreateVideoParser * cuvidCreateVideoParser
tcuvidMapVideoFrame * cuvidMapVideoFrame
tcuvidDestroyDecoder * cuvidDestroyDecoder
tcuvidDestroyVideoSource * cuvidDestroyVideoSource
#define LOAD_SYMBOL_OPT(fun, tp, symbol)
static void cuda_free_functions(CudaFunctions **functions)
CUresult CUDAAPI tcuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci)
tcuCtxPushCurrent_v2 * cuCtxPushCurrent
CUresult CUDAAPI tcuvidSetVideoSourceState(CUvideosource obj, cudaVideoState state)
CUresult CUDAAPI tcuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket)
#define LOAD_SYMBOL(fun, tp, symbol)
tcuvidCreateVideoSource * cuvidCreateVideoSource
tcuvidDecodePicture * cuvidDecodePicture
CUresult CUDAAPI tcuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags)
tcuvidParseVideoData * cuvidParseVideoData
CUresult CUDAAPI tcuDeviceGet(CUdevice *device, int ordinal)
CUresult CUDAAPI tcuvidCtxLockDestroy(CUvideoctxlock lck)
#define GENERIC_LOAD_FUNC_FINALE(n)
tcuCtxCreate_v2 * cuCtxCreate
CUresult CUDAAPI tcuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags)
CUresult CUDAAPI tcuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags)
tcuvidCreateDecoder * cuvidCreateDecoder
NVENCSTATUS NVENCAPI tNvEncodeAPICreateInstance(NV_ENCODE_API_FUNCTION_LIST *functionList)
tNvEncodeAPICreateInstance * NvEncodeAPICreateInstance
tcuGetErrorString * cuGetErrorString
static int cuda_load_functions(CudaFunctions **functions)
CUresult CUDAAPI tcuvidDestroyDecoder(CUvideodecoder hDecoder)
CUresult CUDAAPI tcuCtxDestroy_v2(CUcontext ctx)
CUresult CUDAAPI tcuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx, unsigned int *pDevPtr, unsigned int *pPitch, CUVIDPROCPARAMS *pVPP)
tcuGetErrorName * cuGetErrorName
CUresult CUDAAPI tcuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags)
static void nvenc_free_functions(NvencFunctions **functions)
tcuvidGetSourceVideoFormat * cuvidGetSourceVideoFormat
CUresult CUDAAPI tcuvidCreateVideoSourceW(CUvideosource *pObj, const wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams)
tcuMemAlloc_v2 * cuMemAlloc
CUresult CUDAAPI tcuvidCreateVideoSource(CUvideosource *pObj, const char *pszFileName, CUVIDSOURCEPARAMS *pParams)
tcuvidCreateVideoSourceW * cuvidCreateVideoSourceW
tcuMemcpy2D_v2 * cuMemcpy2D
CUresult CUDAAPI tcuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams)
CUresult CUDAAPI tcuInit(unsigned int Flags)
NVENCSTATUS NVENCAPI NvEncodeAPIGetMaxSupportedVersion(uint32_t *version)
Get the largest NvEncodeAPI version supported by the driver.
CUresult CUDAAPI tcuCtxCreate_v2(CUcontext *pctx, unsigned int flags, CUdevice dev)
NVENCSTATUS NVENCAPI tNvEncodeAPIGetMaxSupportedVersion(uint32_t *version)
CUresult CUDAAPI tcuMemFree_v2(CUdeviceptr dptr)
CUresult CUDAAPI tcuDeviceGetName(char *name, int len, CUdevice dev)
CUresult CUDAAPI tcuCtxPopCurrent_v2(CUcontext *pctx)
tcuDeviceGetCount * cuDeviceGetCount
CUresult CUDAAPI tcuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr)
CUresult CUDAAPI tcuvidGetDecoderCaps(CUVIDDECODECAPS *pdc)
tcuCtxPopCurrent_v2 * cuCtxPopCurrent
tcuvidDestroyVideoParser * cuvidDestroyVideoParser
CUresult CUDAAPI tcuGetErrorString(CUresult error, const char **pstr)
CUresult CUDAAPI tcuMemcpy2D_v2(const CUDA_MEMCPY2D *pcopy)
tcuDeviceComputeCapability * cuDeviceComputeCapability
cudaVideoState CUDAAPI tcuvidGetVideoSourceState(CUvideosource obj)
tcuCtxDestroy_v2 * cuCtxDestroy
NVENCSTATUS NVENCAPI NvEncodeAPICreateInstance(NV_ENCODE_API_FUNCTION_LIST *functionList)
Entry Point to the NvEncodeAPI interface.
CUresult CUDAAPI tcuvidDestroyVideoParser(CUvideoparser obj)
#define GENERIC_LOAD_FUNC_PREAMBLE(T, n, N)
static int cuvid_load_functions(CuvidFunctions **functions)
tcuDeviceGet * cuDeviceGet
tNvEncodeAPIGetMaxSupportedVersion * NvEncodeAPIGetMaxSupportedVersion
CUresult CUDAAPI tcuDeviceGetCount(int *count)
static int nvenc_load_functions(NvencFunctions **functions)