[FFmpeg-cvslog] cuvid: support AVCodecContext.hw_device_ctx API

wm4 git at videolan.org
Fri May 5 01:28:46 EEST 2017


ffmpeg | branch: master | wm4 <nfxjfg at googlemail.com> | Fri May  5 00:15:21 2017 +0200| [c0f17a905f3588bf61ba6d86a83c6835d431ed3d] | committer: wm4

cuvid: support AVCodecContext.hw_device_ctx API

This is a newer API that is intended for decoders like the cuvid
wrapper. Until now, the wrapper required to set an awkward
"incomplete" hw_frames_ctx to set the device. Now the device
can be set directly, and the user can get AV_PIX_FMT_CUDA output
for a specific device simply by setting hw_device_ctx.

This still does a dummy ff_get_format() call at init time, and should
be fully backward compatible.

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

 doc/APIchanges       |  5 +++++
 libavcodec/cuvid.c   | 14 +++++++++++---
 libavcodec/version.h |  2 +-
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index fcd3423d58..b9d7b8b569 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,11 @@ libavutil:     2015-08-28
 
 API changes, most recent first:
 
+2017-05-05 - xxxxxxxxxx - lavc 57.94.100 - avcodec.h
+  The cuvid decoders now support AVCodecContext.hw_device_ctx, which removes
+  the requirement to set an incomplete AVCodecContext.hw_frames_ctx only to
+  set the Cuda device handle.
+
 2017-04-11 - 8378466507 - lavu 55.61.100 - avstring.h
   Add av_strireplace().
 
diff --git a/libavcodec/cuvid.c b/libavcodec/cuvid.c
index 288083423e..3453003965 100644
--- a/libavcodec/cuvid.c
+++ b/libavcodec/cuvid.c
@@ -802,9 +802,17 @@ static av_cold int cuvid_decode_init(AVCodecContext *avctx)
             goto error;
         }
     } else {
-        ret = av_hwdevice_ctx_create(&ctx->hwdevice, AV_HWDEVICE_TYPE_CUDA, ctx->cu_gpu, NULL, 0);
-        if (ret < 0)
-            goto error;
+        if (avctx->hw_device_ctx) {
+            ctx->hwdevice = av_buffer_ref(avctx->hw_device_ctx);
+            if (!ctx->hwdevice) {
+                ret = AVERROR(ENOMEM);
+                goto error;
+            }
+        } else {
+            ret = av_hwdevice_ctx_create(&ctx->hwdevice, AV_HWDEVICE_TYPE_CUDA, ctx->cu_gpu, NULL, 0);
+            if (ret < 0)
+                goto error;
+        }
 
         ctx->hwframe = av_hwframe_ctx_alloc(ctx->hwdevice);
         if (!ctx->hwframe) {
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 46872b0562..a2def3f26b 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,7 +28,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR  57
-#define LIBAVCODEC_VERSION_MINOR  93
+#define LIBAVCODEC_VERSION_MINOR  94
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \



More information about the ffmpeg-cvslog mailing list