summaryrefslogtreecommitdiff
path: root/libavcodec/nvenc.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2016-01-13 14:07:37 +0100
committerAnton Khirnov <anton@khirnov.net>2016-02-14 22:08:13 +0100
commitc51b2c79a7ba084253e892c56dd49ee97115c7de (patch)
tree6c5256804069367e6cedf0e9f390d86b54405fbf /libavcodec/nvenc.c
parentbd49be885e9ad6bae599c54473ba2fa2957eb140 (diff)
downloadffmpeg-c51b2c79a7ba084253e892c56dd49ee97115c7de.tar.gz
Allow linking to CUDA dynamically instead of dlopen()ing it at runtime
Diffstat (limited to 'libavcodec/nvenc.c')
-rw-r--r--libavcodec/nvenc.c13
1 files changed, 13 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;
}