Since the VDPAU pixel format does not distinguish between different
VDPAU video surface chroma types, we need another way to pass this
data to the application.

Originally VDPAU in libavcodec only supported decoding to 8-bits YUV
with 4:2:0 chroma sampling. Correspondingly, applications assumed that
libavcodec expected VDP_CHROMA_TYPE_420 video surfaces for output.
However some of the new HEVC profiles proposed for addition to VDPAU
would require different depth and/or sampling:
http://lists.freedesktop.org/archives/vdpau/2014-July/000167.html
...as would lossless AVC profiles:
http://lists.freedesktop.org/archives/vdpau/2014-November/000241.html

To preserve backward binary compatibility with existing applications,
a new av_vdpau_bind_context() flag is introduced in a further change.
---
 doc/APIchanges       |  3 +++
 libavcodec/vdpau.c   | 25 +++++++++++++++++++++----
 libavcodec/vdpau.h   | 20 ++++++++++++++++++++
 libavcodec/version.h |  2 +-
 4 files changed, 45 insertions(+), 5 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 3d1b72f..066779a 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil:     2014-08-09
 
 API changes, most recent first:
 
+201x-xx-xx - xxxxxxx - lavc 56.7.0 - vdpau.h
+  Add av_vdpau_get_surface_parameters().
+
 2014-11-xx - xxxxxxx - lavf 56.06.3 - avformat.h
   Add AVFormatContext.avoid_negative_ts.
 
diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
index ccb3352..edf09f1 100644
--- a/libavcodec/vdpau.c
+++ b/libavcodec/vdpau.c
@@ -64,6 +64,21 @@ static int vdpau_error(VdpStatus status)
     }
 }
 
+int av_vdpau_get_surface_parameters(AVCodecContext *avctx, VdpChromaType *type,
+                                    uint32_t *width, uint32_t *height)
+{
+    /* XXX: only 8-bits YCbCr 4:2:0 is supported yet */
+    if (type)
+        *type = VDP_CHROMA_TYPE_420;
+    /* See <vdpau/vdpau.h> for per-type alignment constraints. */
+    if (width)
+        *width = (avctx->coded_width + 1) & ~1;
+    if (height)
+        *height = (avctx->coded_height + 3) & ~3;
+
+    return 0;
+}
+
 int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile,
                          int level)
 {
@@ -76,9 +91,9 @@ int ff_vdpau_common_init(AVCodecContext *avctx, 
VdpDecoderProfile profile,
     VdpStatus status;
     VdpBool supported;
     uint32_t max_level, max_mb, max_width, max_height;
-    /* See vdpau/vdpau.h for alignment constraints. */
-    uint32_t width  = (avctx->coded_width + 1) & ~1;
-    uint32_t height = (avctx->coded_height + 3) & ~3;
+    VdpChromaType type;
+    uint32_t width;
+    uint32_t height;
 
     vdctx->width            = UINT32_MAX;
     vdctx->height           = UINT32_MAX;
@@ -107,7 +122,9 @@ int ff_vdpau_common_init(AVCodecContext *avctx, 
VdpDecoderProfile profile,
     else
         surface_query_caps = func;
 
-    status = surface_query_caps(vdctx->device, VDP_CHROMA_TYPE_420, &supported,
+    av_vdpau_get_surface_parameters(avctx, &type, &width, &height);
+
+    status = surface_query_caps(vdctx->device, type, &supported,
                                 &max_width, &max_height);
     if (status != VDP_STATUS_OK)
         return vdpau_error(status);
diff --git a/libavcodec/vdpau.h b/libavcodec/vdpau.h
index 24c3b02..4e5c351 100644
--- a/libavcodec/vdpau.h
+++ b/libavcodec/vdpau.h
@@ -151,6 +151,26 @@ int av_vdpau_bind_context(AVCodecContext *avctx, VdpDevice 
device,
                           VdpGetProcAddress *get_proc_address, unsigned flags);
 
 /**
+ * Gets the parameters to create an adequate VDPAU video surface for the codec
+ * context using VDPAU hardware decoding acceleration.
+ *
+ * @note Behavior is undefined if the context was not successfully bound to a
+ * VDPAU device using av_vdpau_bind_context().
+ *
+ * @param avctx the codec context being used for decoding the stream
+ * @param type storage space for the VDPAU video surface chroma type
+ *              (or NULL to ignore)
+ * @param width storage space for the VDPAU video surface pixel width
+ *              (or NULL to ignore)
+ * @param height storage space for the VDPAU video surface pixel height
+ *              (or NULL to ignore)
+ *
+ * @return 0 on success, a negative AVERROR code on failure.
+ */
+int av_vdpau_get_surface_parameters(AVCodecContext *avctx, VdpChromaType *type,
+                                    uint32_t *width, uint32_t *height);
+
+/**
  * Allocate an AVVDPAUContext.
  *
  * @return Newly-allocated AVVDPAUContext or NULL on failure.
diff --git a/libavcodec/version.h b/libavcodec/version.h
index fd774a7..f51c9d7 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR 56
-#define LIBAVCODEC_VERSION_MINOR  6
+#define LIBAVCODEC_VERSION_MINOR  7
 #define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
2.1.3

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to