[FFmpeg-cvslog] avcodec/nvenc: support external context in sw mode

Timo Rothenpieler git at videolan.org
Sun May 7 15:14:27 EEST 2017


ffmpeg | branch: master | Timo Rothenpieler <timo at rothenpieler.org> | Sun May  7 13:35:25 2017 +0200| [dad6f44bbd578ba386ef8fdce55f88b4df21fdf6] | committer: Timo Rothenpieler

avcodec/nvenc: support external context in sw mode

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

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

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 00766c25d0..ab04a936af 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -400,16 +400,21 @@ static av_cold int nvenc_setup_device(AVCodecContext *avctx)
         return AVERROR_BUG;
     }
 
-    if (avctx->pix_fmt == AV_PIX_FMT_CUDA) {
+    if (avctx->pix_fmt == AV_PIX_FMT_CUDA || avctx->hw_frames_ctx || avctx->hw_device_ctx) {
         AVHWFramesContext   *frames_ctx;
+        AVHWDeviceContext   *hwdev_ctx;
         AVCUDADeviceContext *device_hwctx;
         int ret;
 
-        if (!avctx->hw_frames_ctx)
+        if (avctx->hw_frames_ctx) {
+            frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
+            device_hwctx = frames_ctx->device_ctx->hwctx;
+        } else if (avctx->hw_device_ctx) {
+            hwdev_ctx = (AVHWDeviceContext*)avctx->hw_device_ctx->data;
+            device_hwctx = hwdev_ctx->hwctx;
+        } else {
             return AVERROR(EINVAL);
-
-        frames_ctx   = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
-        device_hwctx = frames_ctx->device_ctx->hwctx;
+        }
 
         ctx->cu_context = device_hwctx->cuda_ctx;
 



More information about the ffmpeg-cvslog mailing list