---
libavcodec/avcodec.h | 20 ++++++++++++++++++++
libavcodec/utils.c | 3 +++
2 files changed, 23 insertions(+)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 8083111..79aa3b7 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -35,6 +35,7 @@
#include "libavutil/cpu.h"
#include "libavutil/dict.h"
#include "libavutil/frame.h"
+#include "libavutil/hwframe.h"
#include "libavutil/log.h"
#include "libavutil/pixfmt.h"
#include "libavutil/rational.h"
@@ -2996,6 +2997,23 @@ typedef struct AVCodecContext {
AVPacketSideData *coded_side_data;
int nb_coded_side_data;
+ /**
+ * Hwaccel decoding only. If the internal get_buffer2() implementation gets
+ * used to allocate hardware frames (either because the caller did not
+ * override get_buffer2() or because the custom get_buffer2() calls
+ * avcodec_default_get_buffer2()) then this callback needs to be set by the
+ * caller at latest in get_format().
+ *
+ * This callback will be used as the free() callback in creating an
+ * AVHWFramesContext that will be attached to the allocated frames.
+ */
+ void (*hwframe_ctx_free)(AVHWFramesContext *ctx);
+
+ /**
+ * See the hwframe_ctx_free documentation for details. This field will be
+ * used as the user_opaque field in the AVHWFramesContext.
+ */
+ void *hwframe_ctx_opaque;
} AVCodecContext;
/**
@@ -3231,6 +3249,8 @@ typedef struct AVHWAccel {
*/
int (*uninit)(AVCodecContext *avctx);
+ int (*get_buffer)(AVCodecContext *avctx, AVFrame *frame);
+
/**
* Size of the private data to allocate in
* AVCodecInternal.hwaccel_priv_data.
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 29ba85f..620b3e6 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -512,6 +512,9 @@ int avcodec_default_get_buffer2(AVCodecContext *avctx,
AVFrame *frame, int flags
{
int ret;
+ if (avctx->hwaccel && avctx->hwaccel->get_buffer)
+ return avctx->hwaccel->get_buffer(avctx, frame);
+
if ((ret = update_frame_pool(avctx, frame)) < 0)
return ret;
--
2.0.0
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel