For use by codec implementations which can allocate frames internally.
---
Now with explicit prohibition on the user reading either field.


 doc/APIchanges       |  3 +++
 libavcodec/avcodec.h | 23 ++++++++++++++++++++++-
 libavcodec/decode.c  |  1 +
 libavcodec/utils.c   |  1 +
 libavcodec/version.h |  2 +-
 5 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index c161618d9..694058574 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil:     2015-08-28
 
 API changes, most recent first:
 
+2017-xx-xx - xxxxxxx - lavc 57.34.0 - avcodec.h
+  Add AVCodecContext.hw_device_ctx.
+
 2017-02-01 - xxxxxxx - lavc - avcodec.h
   Deprecate AVCodecContext.refcounted_frames. This was useful for deprecated
   API only (avcodec_decode_video2/avcodec_decode_audio4). The new decode APIs
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 8d8fa594a..5c3ce59b1 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3093,7 +3093,8 @@ typedef struct AVCodecContext {
     /**
      * A reference to the AVHWFramesContext describing the input (for encoding)
      * or output (decoding) frames. The reference is set by the caller and
-     * afterwards owned (and freed) by libavcodec.
+     * afterwards owned (and freed) by libavcodec - it should never be read by
+     * the caller after being set.
      *
      * - decoding: This field should be set by the caller from the get_format()
      *             callback. The previous reference (if any) will always be
@@ -3139,6 +3140,26 @@ typedef struct AVCodecContext {
      * (with the display dimensions being determined by the crop_* fields).
      */
     int apply_cropping;
+
+    /**
+     * A reference to the AVHWDeviceContext describing the device which will
+     * be used by a hardware encoder/decoder.  The reference is set by the
+     * caller and afterwards owned (and freed) by libavcodec - it should never
+     * be read by the caller after being set.
+     *
+     * This should only be used if either the codec device does not require
+     * hardware frames or any that are used are allocated internally by
+     * libavcodec.  If the user wishes to supply any of the frames used as
+     * encoder input or decoder output then hw_frames_ctx should be used
+     * instead.
+     *
+     * - decoding: This field should be set by the caller from the get_format()
+     *             callback.  The previous reference (if any) will always be
+     *             unreffed by libavcodec before the get_format() call.
+     *
+     * - encoding: This field should be set before avcodec_open2() is called.
+     */
+    AVBufferRef *hw_device_ctx;
 } AVCodecContext;
 
 /**
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index f4088cdae..a20b84bd3 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -785,6 +785,7 @@ int ff_get_format(AVCodecContext *avctx, const enum 
AVPixelFormat *fmt)
         avctx->hwaccel = NULL;
 
         av_buffer_unref(&avctx->hw_frames_ctx);
+        av_buffer_unref(&avctx->hw_device_ctx);
 
         ret = avctx->get_format(avctx, choices);
 
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 2978109a2..1d316bd03 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -801,6 +801,7 @@ av_cold int avcodec_close(AVCodecContext *avctx)
     avctx->nb_coded_side_data = 0;
 
     av_buffer_unref(&avctx->hw_frames_ctx);
+    av_buffer_unref(&avctx->hw_device_ctx);
 
     if (avctx->priv_data && avctx->codec && avctx->codec->priv_class)
         av_opt_free(avctx->priv_data);
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 2ade539c6..a6eda6a69 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 33
+#define LIBAVCODEC_VERSION_MINOR 34
 #define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
2.11.0

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to