summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorTimo Rothenpieler <timo@rothenpieler.org>2017-02-06 18:04:39 -0800
committerLuca Barbato <lu_zero@gentoo.org>2017-02-09 23:29:32 +0100
commita52976c0feab6e86138983c248bd01fa45cdda69 (patch)
tree9fed57bd647c435c3027f9300df4a8a46c5ecfe9 /libavcodec
parent77c23704c769168e4210956314775a1931f6aa0b (diff)
nvenc: make gpu indices independent of supported capabilities
Do not allocate a CUDA context for every available gpu. Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/nvenc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index fe7b7f40f0..90b9d1a62a 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -359,6 +359,9 @@ static int nvenc_check_device(AVCodecContext *avctx, int idx)
if (((major << 4) | minor) < NVENC_CAP)
goto fail;
+ if (ctx->device != idx && ctx->device != ANY_DEVICE)
+ return -1;
+
ret = nvel->cu_ctx_create(&ctx->cu_context_internal, 0, cu_device);
if (ret != CUDA_SUCCESS)
goto fail;
@@ -377,7 +380,7 @@ static int nvenc_check_device(AVCodecContext *avctx, int idx)
av_log(avctx, loglevel, "supports NVENC\n");
- if (ctx->device == cu_device || ctx->device == ANY_DEVICE)
+ if (ctx->device == idx || ctx->device == ANY_DEVICE)
return 0;
fail3: