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, symbol) \
71 if (!((f->fun) = 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 GENERIC_LOAD_FUNC_PREAMBLE(T, n, N) \
83 n##_free_functions(functions); \
85 f = *functions = av_mallocz(sizeof(*f)); \
87 return AVERROR(ENOMEM); \
89 LOAD_LIBRARY(f->lib, N);
91 #define GENERIC_LOAD_FUNC_FINALE(n) \
94 n##_free_functions(functions); \
97 #define GENERIC_FREE_FUNC() \
100 if (*functions && (*functions)->lib) \
101 dlclose((*functions)->lib); \
104 #ifdef AV_COMPAT_DYNLINK_CUDA_H
159 #ifdef AV_COMPAT_DYNLINK_CUDA_H
176 #ifdef AV_COMPAT_DYNLINK_CUDA_H
185 LOAD_SYMBOL(cuDeviceComputeCapability,
"cuDeviceComputeCapability");
187 LOAD_SYMBOL(cuCtxPushCurrent,
"cuCtxPushCurrent_v2");
188 LOAD_SYMBOL(cuCtxPopCurrent,
"cuCtxPopCurrent_v2");
204 LOAD_SYMBOL(cuvidCreateDecoder,
"cuvidCreateDecoder");
205 LOAD_SYMBOL(cuvidDestroyDecoder,
"cuvidDestroyDecoder");
206 LOAD_SYMBOL(cuvidDecodePicture,
"cuvidDecodePicture");
207 #ifdef __CUVID_DEVPTR64
208 LOAD_SYMBOL(cuvidMapVideoFrame,
"cuvidMapVideoFrame64");
209 LOAD_SYMBOL(cuvidUnmapVideoFrame,
"cuvidUnmapVideoFrame64");
211 LOAD_SYMBOL(cuvidMapVideoFrame,
"cuvidMapVideoFrame");
212 LOAD_SYMBOL(cuvidUnmapVideoFrame,
"cuvidUnmapVideoFrame");
214 LOAD_SYMBOL(cuvidCtxLockCreate,
"cuvidCtxLockCreate");
215 LOAD_SYMBOL(cuvidCtxLockDestroy,
"cuvidCtxLockDestroy");
219 LOAD_SYMBOL(cuvidCreateVideoSource,
"cuvidCreateVideoSource");
220 LOAD_SYMBOL(cuvidCreateVideoSourceW,
"cuvidCreateVideoSourceW");
221 LOAD_SYMBOL(cuvidDestroyVideoSource,
"cuvidDestroyVideoSource");
222 LOAD_SYMBOL(cuvidSetVideoSourceState,
"cuvidSetVideoSourceState");
223 LOAD_SYMBOL(cuvidGetVideoSourceState,
"cuvidGetVideoSourceState");
224 LOAD_SYMBOL(cuvidGetSourceVideoFormat,
"cuvidGetSourceVideoFormat");
225 LOAD_SYMBOL(cuvidGetSourceAudioFormat,
"cuvidGetSourceAudioFormat");
226 LOAD_SYMBOL(cuvidCreateVideoParser,
"cuvidCreateVideoParser");
227 LOAD_SYMBOL(cuvidParseVideoData,
"cuvidParseVideoData");
228 LOAD_SYMBOL(cuvidDestroyVideoParser,
"cuvidDestroyVideoParser");
243 #undef GENERIC_LOAD_FUNC_PREAMBLE
246 #undef GENERIC_LOAD_FUNC_FINALE
247 #undef GENERIC_FREE_FUNC
249 #undef NVCUVID_LIBNAME
tcuvidGetSourceAudioFormat * cuvidGetSourceAudioFormat
tcuDeviceGetName * cuDeviceGetName
tcuvidCtxLockDestroy * cuvidCtxLockDestroy
CUresult CUDAAPI tcuvidDestroyVideoSource(CUvideosource obj)
CUresult CUDAAPI tcuCtxPushCurrent_v2(CUcontext *pctx)
CUresult CUDAAPI tcuDeviceComputeCapability(int *major, int *minor, CUdevice dev)
static void cuvid_free_functions(CuvidFunctions **functions)
#define LOAD_SYMBOL(fun, symbol)
NvEncodeAPI provides a NVENC Video Encoding interface to NVIDIA GPU devices based on the Kepler archi...
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 tcuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags)
CUresult CUDAAPI tcuGetErrorName(CUresult error, const char **pstr)
CUresult CUDAAPI tcuvidSetVideoSourceState(CUvideosource obj, cudaVideoState state)
tcuvidCreateVideoParser * cuvidCreateVideoParser
tcuvidMapVideoFrame * cuvidMapVideoFrame
tcuvidDestroyDecoder * cuvidDestroyDecoder
tcuvidDestroyVideoSource * cuvidDestroyVideoSource
static void cuda_free_functions(CudaFunctions **functions)
tcuCtxPushCurrent_v2 * cuCtxPushCurrent
CUresult CUDAAPI tcuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags)
CUresult CUDAAPI tcuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket)
CUresult CUDAAPI tcuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx, unsigned int *pDevPtr, unsigned int *pPitch, CUVIDPROCPARAMS *pVPP)
tcuvidCreateVideoSource * cuvidCreateVideoSource
CUresult CUDAAPI tcuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams)
tcuvidDecodePicture * cuvidDecodePicture
tcuvidParseVideoData * cuvidParseVideoData
CUresult CUDAAPI tcuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx)
CUresult CUDAAPI tcuDeviceGet(CUdevice *device, int ordinal)
#define GENERIC_LOAD_FUNC_FINALE(n)
tcuCtxCreate_v2 * cuCtxCreate
tcuvidCreateDecoder * cuvidCreateDecoder
CUresult CUDAAPI tcuvidCreateVideoSourceW(CUvideosource *pObj, const wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams)
tcuGetErrorString * cuGetErrorString
static int cuda_load_functions(CudaFunctions **functions)
CUresult CUDAAPI tcuCtxDestroy_v2(CUcontext ctx)
tcuGetErrorName * cuGetErrorName
CUresult CUDAAPI tcuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags)
static void nvenc_free_functions(NvencFunctions **functions)
CUresult CUDAAPI tcuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr)
tcuvidGetSourceVideoFormat * cuvidGetSourceVideoFormat
tcuMemAlloc_v2 * cuMemAlloc
CUresult CUDAAPI tcuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags)
CUresult CUDAAPI tcuvidCtxLockDestroy(CUvideoctxlock lck)
tcuvidCreateVideoSourceW * cuvidCreateVideoSourceW
tcuMemcpy2D_v2 * cuMemcpy2D
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)
CUresult CUDAAPI tcuMemFree_v2(CUdeviceptr dptr)
CUresult CUDAAPI tcuvidDestroyVideoParser(CUvideoparser obj)
CUresult CUDAAPI tcuDeviceGetName(char *name, int len, CUdevice dev)
CUresult CUDAAPI tcuCtxPopCurrent_v2(CUcontext *pctx)
NVENCSTATUS(NVENCAPI *NvEncodeAPICreateInstance)(NV_ENCODE_API_FUNCTION_LIST *functionList)
CUresult CUDAAPI tcuvidDestroyDecoder(CUvideodecoder hDecoder)
CUresult CUDAAPI tcuvidCreateVideoSource(CUvideosource *pObj, const char *pszFileName, CUVIDSOURCEPARAMS *pParams)
tcuDeviceGetCount * cuDeviceGetCount
cudaVideoState CUDAAPI tcuvidGetVideoSourceState(CUvideosource obj)
CUresult CUDAAPI tcuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams)
tcuCtxPopCurrent_v2 * cuCtxPopCurrent
tcuvidDestroyVideoParser * cuvidDestroyVideoParser
CUresult CUDAAPI tcuGetErrorString(CUresult error, const char **pstr)
CUresult CUDAAPI tcuMemcpy2D_v2(const CUDA_MEMCPY2D *pcopy)
tcuDeviceComputeCapability * cuDeviceComputeCapability
tcuCtxDestroy_v2 * cuCtxDestroy
NVENCSTATUS NVENCAPI NvEncodeAPICreateInstance(NV_ENCODE_API_FUNCTION_LIST *functionList)
Entry Point to the NvEncodeAPI interface.
CUresult CUDAAPI tcuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci)
#define GENERIC_LOAD_FUNC_PREAMBLE(T, n, N)
static int cuvid_load_functions(CuvidFunctions **functions)
tcuDeviceGet * cuDeviceGet
CUresult CUDAAPI tcuDeviceGetCount(int *count)
static int nvenc_load_functions(NvencFunctions **functions)