]> git.sesse.net Git - ffmpeg/commitdiff
lavc: Add device context field to AVCodecContext
authorMark Thompson <sw@jkqxz.net>
Thu, 9 Feb 2017 00:23:36 +0000 (00:23 +0000)
committerMark Thompson <sw@jkqxz.net>
Mon, 13 Feb 2017 22:06:43 +0000 (22:06 +0000)
For use by codec implementations which can allocate frames internally.

doc/APIchanges
libavcodec/avcodec.h
libavcodec/utils.c
libavcodec/version.h

index 81e49c22b959fd343270ecb4158a8d125656af6b..d739895aa4207ae0f2fde9fe449022e66228c817 100644 (file)
@@ -15,6 +15,9 @@ libavutil:     2015-08-28
 
 API changes, most recent first:
 
+2017-02-13 - xxxxxxx - lavc 57.80.100 - avcodec.h
+  Add AVCodecContext.hw_device_ctx.
+
 2017-02-11 - xxxxxxx - lavu 55.47.100 - frame.h
   Add AVFrame.opaque_ref.
 
index 3e161ea10ef70ae5f39fb4ad0ae8a2a69b1e604f..5616fb01d6d666116ba7b717144b966d632f598d 100644 (file)
@@ -3536,7 +3536,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
@@ -3586,6 +3587,27 @@ typedef struct AVCodecContext {
      */
     int64_t max_pixels;
 
+    /**
+     * 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.
+     *
+     * This should be used if either the codec device does not require
+     * hardware frames or any that are used are to be 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.  When hw_frames_ctx is set in get_format() for a decoder, this
+     * field will be ignored while decoding the associated stream segment, but
+     * may again be used on a following one after another get_format() call.
+     *
+     * For both encoders and decoders this field should be set before
+     * avcodec_open2() is called and must not be written to thereafter.
+     *
+     * Note that some decoders may require this field to be set initially in
+     * order to support hw_frames_ctx at all - in that case, all frames
+     * contexts used must be created on the same device.
+     */
+    AVBufferRef *hw_device_ctx;
 } AVCodecContext;
 
 AVRational av_codec_get_pkt_timebase         (const AVCodecContext *avctx);
index f8ec4c1ae61113bd46b29d53da66c6710e52bafb..f4085bf7a79637588bc03bb4816375197eff4bf5 100644 (file)
@@ -3067,6 +3067,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);
index 5fb879404477ff996e270a17ae4fbd368c8309d2..49089db41410c04b43c6000f7dabc001e4b9ba84 100644 (file)
@@ -28,7 +28,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR  57
-#define LIBAVCODEC_VERSION_MINOR  79
+#define LIBAVCODEC_VERSION_MINOR  80
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \