]> git.sesse.net Git - ffmpeg/commitdiff
lavc: add a field for passing AVHWFramesContext to encoders
authorAnton Khirnov <anton@khirnov.net>
Mon, 1 Feb 2016 14:39:50 +0000 (15:39 +0100)
committerAnton Khirnov <anton@khirnov.net>
Sun, 14 Feb 2016 21:29:52 +0000 (22:29 +0100)
doc/APIchanges
libavcodec/avcodec.h
libavcodec/utils.c
libavcodec/version.h

index d10cf98ad726bcbbdc7ac7c2944929debc8e5e86..b9a00087799e30086ab0ce1df47f1680b303d192 100644 (file)
@@ -13,6 +13,9 @@ libavutil:     2015-08-28
 
 API changes, most recent first:
 
+2016-xx-xx - lavc 57.13.0 - avcodec.h
+  Add AVCodecContext.hw_frames_ctx.
+
 2016-xx-xx - lavfi 6.2.0 - avfilter.h
   xxxxxxx avfilter.h - Add AVFilterLink.hw_frames_ctx.
   xxxxxxx buffersrc.h - Add AVBufferSrcParameters and functions for handling it.
index fe3366b2566196c1ff17ad109fe0d6e792548180..12458abd7865000b82cd13ceca3882bd4d81b9b5 100644 (file)
@@ -2979,6 +2979,18 @@ typedef struct AVCodecContext {
     AVPacketSideData *coded_side_data;
     int            nb_coded_side_data;
 
+    /**
+     * Encoding only.
+     *
+     * For hardware encoders configured to use a hwaccel pixel format, this
+     * field should be set by the caller to a reference to the AVHWFramesContext
+     * describing input frames. AVHWFramesContext.format must be equal to
+     * AVCodecContext.pix_fmt.
+     *
+     * This field should be set before avcodec_open2() is called and is
+     * afterwards owned and managed by libavcodec.
+     */
+    AVBufferRef *hw_frames_ctx;
 } AVCodecContext;
 
 /**
index e06ee664b5d64784ea2121d9026055514ed62939..94ec1e80479c4c304cdcad21cf3072349f8e4713 100644 (file)
@@ -32,6 +32,7 @@
 #include "libavutil/channel_layout.h"
 #include "libavutil/crc.h"
 #include "libavutil/frame.h"
+#include "libavutil/hwcontext.h"
 #include "libavutil/internal.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/pixdesc.h"
@@ -1059,6 +1060,16 @@ FF_ENABLE_DEPRECATION_WARNINGS
                    avctx->time_base.den);
             goto free_and_end;
         }
+
+        if (avctx->hw_frames_ctx) {
+            AVHWFramesContext *frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
+            if (frames_ctx->format != avctx->pix_fmt) {
+                av_log(avctx, AV_LOG_ERROR,
+                       "Mismatching AVCodecContext.pix_fmt and AVHWFramesContext.format\n");
+                ret = AVERROR(EINVAL);
+                goto free_and_end;
+            }
+        }
     }
 
     if (avctx->codec->init && !(avctx->active_thread_type & FF_THREAD_FRAME)) {
@@ -1639,6 +1650,8 @@ av_cold int avcodec_close(AVCodecContext *avctx)
     av_freep(&avctx->coded_side_data);
     avctx->nb_coded_side_data = 0;
 
+    av_buffer_unref(&avctx->hw_frames_ctx);
+
     if (avctx->priv_data && avctx->codec && avctx->codec->priv_class)
         av_opt_free(avctx->priv_data);
     av_opt_free(avctx);
index 9c40c7956bd1872b81801105c78ccdcc8351987d..18d2754661301c5edf28fbd70a39c3042dc73d16 100644 (file)
@@ -29,7 +29,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR 57
-#define LIBAVCODEC_VERSION_MINOR 12
+#define LIBAVCODEC_VERSION_MINOR 13
 #define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \