It would reduce the boilerplate code users have to write.
---
 libavcodec/avcodec.h | 5 +++++
 libavcodec/utils.c   | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index df061c1..65c7da4 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2947,6 +2947,11 @@ typedef struct AVHWAccel {
     struct AVHWAccel *next;

     /**
+     * Allocate a custom buffer
+     */
+    int (*alloc_frame)(AVCodecContext *avctx, AVFrame *frame);
+
+    /**
      * Called at the beginning of each frame or field picture.
      *
      * Meaningful frame information (codec specific) is guaranteed to
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 95aaa6e..e7978a4 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -604,6 +604,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame 
*frame)

 int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
 {
+    const AVHWAccel *hwaccel = avctx->hwaccel;
     int override_dimensions = 1;
     int ret;

@@ -657,6 +658,9 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, 
int flags)
     if (ret < 0)
         return ret;

+    if (hwaccel && hwaccel->alloc_frame)
+        return hwaccel->alloc_frame(avctx, frame);
+
 #if FF_API_GET_BUFFER
 FF_DISABLE_DEPRECATION_WARNINGS
     /*
--
1.9.0

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

Reply via email to