[FFmpeg-devel] [RFC/PATCH 3/8] hwaccel: add init/close methods

Felipe Contreras felipe.contreras
Mon Sep 6 00:15:30 CEST 2010


Will be needed by tidsp.

Signed-off-by: Felipe Contreras <felipe.contreras at gmail.com>
---
 libavcodec/avcodec.h |    3 +++
 libavcodec/utils.c   |    8 ++++++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 9353210..828f1a5 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2851,6 +2851,9 @@ typedef struct AVHWAccel {
      * AVCodecContext.release_buffer().
      */
     int priv_data_size;
+
+    int (*init)(AVCodecContext *avctx);
+    int (*close)(AVCodecContext *avctx);
 } AVHWAccel;
 
 /**
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index f13b271..b08bd56 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -517,6 +517,12 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
             goto free_and_end;
         }
     }
+    if (avctx->hwaccel && avctx->hwaccel->init) {
+        ret = avctx->hwaccel->init(avctx);
+        if (ret < 0)
+            goto free_and_end;
+    }
+
     ret=0;
 end:
     entangled_thread_counter--;
@@ -725,6 +731,8 @@ av_cold int avcodec_close(AVCodecContext *avctx)
 
     if (HAVE_THREADS && avctx->thread_opaque)
         avcodec_thread_free(avctx);
+    if (avctx->hwaccel && avctx->hwaccel->close)
+        avctx->hwaccel->close(avctx);
     if (avctx->codec && avctx->codec->close)
         avctx->codec->close(avctx);
     avcodec_default_free_buffers(avctx);
-- 
1.7.2.2




More information about the ffmpeg-devel mailing list