summaryrefslogtreecommitdiff
path: root/libavcodec/nvenc.c
diff options
context:
space:
mode:
authorTimo Rothenpieler <timo@rothenpieler.org>2017-01-18 23:01:28 +0100
committerTimo Rothenpieler <timo@rothenpieler.org>2017-01-20 10:29:36 +0100
commit5403d90f32656719a766254d77bbe4411e473eed (patch)
tree21a952129d0035cedaed06b354e28263b98105ed /libavcodec/nvenc.c
parent1c1031003b053e819185881ba512ebdffdbf637f (diff)
avcodec/nvenc: make gpu indices independend of supported capabilities
Diffstat (limited to 'libavcodec/nvenc.c')
-rw-r--r--libavcodec/nvenc.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 4ee99a9f30..27d1a2bfbb 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -338,6 +338,9 @@ static av_cold int nvenc_check_device(AVCodecContext *avctx, int idx)
goto fail;
}
+ if (ctx->device != idx && ctx->device != ANY_DEVICE)
+ return -1;
+
cu_res = dl_fn->cuda_dl->cuCtxCreate(&ctx->cu_context_internal, 0, cu_device);
if (cu_res != CUDA_SUCCESS) {
av_log(avctx, AV_LOG_FATAL, "Failed creating CUDA context for NVENC: 0x%x\n", (int)cu_res);
@@ -362,7 +365,7 @@ static av_cold int nvenc_check_device(AVCodecContext *avctx, int idx)
dl_fn->nvenc_device_count++;
- if (ctx->device == dl_fn->nvenc_device_count - 1 || ctx->device == ANY_DEVICE)
+ if (ctx->device == idx || ctx->device == ANY_DEVICE)
return 0;
fail3:
@@ -451,7 +454,7 @@ static av_cold int nvenc_setup_device(AVCodecContext *avctx)
return AVERROR_EXTERNAL;
}
- av_log(avctx, AV_LOG_FATAL, "Requested GPU %d, but only %d GPUs are available!\n", ctx->device, dl_fn->nvenc_device_count);
+ av_log(avctx, AV_LOG_FATAL, "Requested GPU %d, but only %d GPUs are available!\n", ctx->device, nb_devices);
return AVERROR(EINVAL);
}