]> git.sesse.net Git - ffmpeg/commitdiff
vda: Make output CVPixelBuffer format configurable
authorStefano Pigozzi <stefano.pigozzi@gmail.com>
Sun, 10 May 2015 19:32:59 +0000 (21:32 +0200)
committerLuca Barbato <lu_zero@gentoo.org>
Wed, 13 May 2015 15:39:37 +0000 (17:39 +0200)
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@gentoo.org>
doc/APIchanges
libavcodec/vda.c
libavcodec/vda.h
libavcodec/vda_h264.c
libavcodec/version.h

index 5934f4517f7650569413b19ed146ba01630a4d08..5d39ec64c235ec4ce67e142fe7ce9b791592024e 100644 (file)
@@ -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.
 
index f71fb164885e5d79af4e8479b55af70560191ad4..eb4b9982cb7397912a28b8973b524ed76933b293 100644 (file)
@@ -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);
index 9aa5d297fb768ac17ba8e2d07b2160c35cf5f4f5..5e7228c94e38aafa177ca587e54879daf1f6b5fa 100644 (file)
@@ -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;
 
 /**
@@ -180,6 +186,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().
index 3c0775b15a8b429c8b05a254bb5c0c876e2ab59f..0692f6080901bd9e1b0e6db8c84dd3c659e02479 100644 (file)
@@ -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;
 
index 50c2b48258e86d0f6d40ed571b181916e9d9b5d7..c478ca38d842aefdb98cefcdcba7e19403dce6ed 100644 (file)
@@ -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, \