ffmpeg | branch: master | Timo Rothenpieler <[email protected]> | Wed Jan 
18 23:01:28 2017 +0100| [5403d90f32656719a766254d77bbe4411e473eed] | committer: 
Timo Rothenpieler

avcodec/nvenc: make gpu indices independend of supported capabilities

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5403d90f32656719a766254d77bbe4411e473eed
---

 libavcodec/nvenc.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 4ee99a9..27d1a2b 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);
     }
 

_______________________________________________
ffmpeg-cvslog mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

Reply via email to