diff options
author | Anton Khirnov <anton@khirnov.net> | 2016-01-13 14:07:37 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2016-02-14 22:08:13 +0100 |
commit | c51b2c79a7ba084253e892c56dd49ee97115c7de (patch) | |
tree | 6c5256804069367e6cedf0e9f390d86b54405fbf /libavcodec | |
parent | bd49be885e9ad6bae599c54473ba2fa2957eb140 (diff) |
Allow linking to CUDA dynamically instead of dlopen()ing it at runtime
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/nvenc.c | 13 | ||||
-rw-r--r-- | libavcodec/nvenc.h | 4 |
2 files changed, 17 insertions, 0 deletions
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 0783c355c8..ba6afb772d 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -148,6 +148,16 @@ static av_cold int nvenc_load_libraries(AVCodecContext *avctx) PNVENCODEAPICREATEINSTANCE nvenc_create_instance; NVENCSTATUS err; +#if CONFIG_CUDA + nvel->cu_init = cuInit; + nvel->cu_device_get_count = cuDeviceGetCount; + nvel->cu_device_get = cuDeviceGet; + nvel->cu_device_get_name = cuDeviceGetName; + nvel->cu_device_compute_capability = cuDeviceComputeCapability; + nvel->cu_ctx_create = cuCtxCreate_v2; + nvel->cu_ctx_pop_current = cuCtxPopCurrent_v2; + nvel->cu_ctx_destroy = cuCtxDestroy_v2; +#else LOAD_LIBRARY(nvel->cuda, CUDA_LIBNAME); LOAD_SYMBOL(nvel->cu_init, nvel->cuda, "cuInit"); @@ -159,6 +169,7 @@ static av_cold int nvenc_load_libraries(AVCodecContext *avctx) LOAD_SYMBOL(nvel->cu_ctx_create, nvel->cuda, "cuCtxCreate_v2"); LOAD_SYMBOL(nvel->cu_ctx_pop_current, nvel->cuda, "cuCtxPopCurrent_v2"); LOAD_SYMBOL(nvel->cu_ctx_destroy, nvel->cuda, "cuCtxDestroy_v2"); +#endif LOAD_LIBRARY(nvel->nvenc, NVENC_LIBNAME); @@ -859,8 +870,10 @@ av_cold int ff_nvenc_encode_close(AVCodecContext *avctx) if (ctx->nvel.nvenc) dlclose(ctx->nvel.nvenc); +#if !CONFIG_CUDA if (ctx->nvel.cuda) dlclose(ctx->nvel.cuda); +#endif return 0; } diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h index 6edca75195..a0020377e6 100644 --- a/libavcodec/nvenc.h +++ b/libavcodec/nvenc.h @@ -22,6 +22,8 @@ #include <cuda.h> #include <nvEncodeAPI.h> +#include "config.h" + #include "libavutil/fifo.h" #include "libavutil/opt.h" @@ -47,7 +49,9 @@ typedef NVENCSTATUS (NVENCAPI *PNVENCODEAPICREATEINSTANCE)(NV_ENCODE_API_FUNCTIO typedef struct NVENCLibraryContext { +#if !CONFIG_CUDA void *cuda; +#endif void *nvenc; PCUINIT cu_init; |