From c51b2c79a7ba084253e892c56dd49ee97115c7de Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 13 Jan 2016 14:07:37 +0100 Subject: Allow linking to CUDA dynamically instead of dlopen()ing it at runtime --- libavcodec/nvenc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'libavcodec/nvenc.c') 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; } -- cgit v1.2.3