[FFmpeg-cvslog] vda: Make output CVPixelBuffer format configurable

Stefano Pigozzi git at videolan.org
Wed May 13 22:43:04 CEST 2015


ffmpeg | branch: master | Stefano Pigozzi <stefano.pigozzi at gmail.com> | Sun May 10 21:32:59 2015 +0200| [e7c5e17d4fbd7c83fb331bf327e25ebd8e6a8623] | committer: Luca Barbato

vda: Make output CVPixelBuffer format configurable

This is useful for client programs to ask for nv12 surfaces instead of the
current default (uyvy), since those are more efficient to decode to.

Signed-off-by: Luca Barbato <lu_zero at gentoo.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e7c5e17d4fbd7c83fb331bf327e25ebd8e6a8623
---

 doc/APIchanges        |    3 +++
 libavcodec/vda.c      |   11 +++++++++--
 libavcodec/vda.h      |   17 +++++++++++++++++
 libavcodec/vda_h264.c |    2 +-
 libavcodec/version.h  |    4 ++--
 5 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 5934f45..5d39ec6 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil:     2014-08-09
 
 API changes, most recent first:
 
+2015-xx-xx - xxxxxxx - lavc 56.23.0
+  Add av_vda_default_init2.
+
 2015-xx-xx - xxxxxxx - lavu 54.12.0
   Add AV_LOG_TRACE for extremely verbose debugging.
 
diff --git a/libavcodec/vda.c b/libavcodec/vda.c
index f71fb16..eb4b998 100644
--- a/libavcodec/vda.c
+++ b/libavcodec/vda.c
@@ -28,15 +28,22 @@ AVVDAContext *av_vda_alloc_context(void)
 {
     AVVDAContext *ret = av_mallocz(sizeof(*ret));
 
-    if (ret)
+    if (ret) {
         ret->output_callback = ff_vda_output_callback;
+        ret->cv_pix_fmt_type = kCVPixelFormatType_422YpCbCr8;
+    }
 
     return ret;
 }
 
 int av_vda_default_init(AVCodecContext *avctx)
 {
-    avctx->hwaccel_context = av_vda_alloc_context();
+    return av_vda_default_init2(avctx, NULL);
+}
+
+int av_vda_default_init2(AVCodecContext *avctx, AVVDAContext *vdactx)
+{
+    avctx->hwaccel_context = vdactx ?: av_vda_alloc_context();
     if (!avctx->hwaccel_context)
         return AVERROR(ENOMEM);
     return ff_vda_default_init(avctx);
diff --git a/libavcodec/vda.h b/libavcodec/vda.h
index 9aa5d29..5e7228c 100644
--- a/libavcodec/vda.h
+++ b/libavcodec/vda.h
@@ -153,6 +153,12 @@ typedef struct AVVDAContext {
      * Set by av_vda_alloc_context().
      */
     VDADecoderOutputCallback output_callback;
+
+    /**
+     * CVPixelBuffer Format Type that VDA will use for decoded frames; set by
+     * the caller.
+     */
+    OSType cv_pix_fmt_type;
 } AVVDAContext;
 
 /**
@@ -181,6 +187,17 @@ AVVDAContext *av_vda_alloc_context(void);
 int av_vda_default_init(AVCodecContext *avctx);
 
 /**
+ * This is a convenience function that creates and sets up the VDA context using
+ * an internal implementation.
+ *
+ * @param avctx the corresponding codec context
+ * @param vdactx the VDA context to use
+ *
+ * @return >= 0 on success, a negative AVERROR code on failure
+ */
+int av_vda_default_init2(AVCodecContext *avctx, AVVDAContext *vdactx);
+
+/**
  * This function must be called to free the VDA context initialized with
  * av_vda_default_init().
  *
diff --git a/libavcodec/vda_h264.c b/libavcodec/vda_h264.c
index 3c0775b..0692f60 100644
--- a/libavcodec/vda_h264.c
+++ b/libavcodec/vda_h264.c
@@ -380,7 +380,7 @@ int ff_vda_default_init(AVCodecContext *avctx)
     CFMutableDictionaryRef buffer_attributes;
     CFMutableDictionaryRef io_surface_properties;
     CFNumberRef cv_pix_fmt;
-    int32_t fmt = 'avc1', pix_fmt = kCVPixelFormatType_422YpCbCr8;
+    int32_t fmt = 'avc1', pix_fmt = vda_ctx->cv_pix_fmt_type;
 
     // kCVPixelFormatType_420YpCbCr8Planar;
 
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 50c2b48..c478ca3 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,8 +29,8 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR 56
-#define LIBAVCODEC_VERSION_MINOR 23
-#define LIBAVCODEC_VERSION_MICRO  2
+#define LIBAVCODEC_VERSION_MINOR 24
+#define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list