From: Rémi Denis-Courmont <[email protected]>

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

Until now, VDPAU in libavcodec has only supported decoding to
8-bits YUV 4:2:0 and applications were responsible for matching the
codec profile, so selecting the chroma type was on the application
side. (In practice, application hard-coded VDP_CHROMA_TYPE_420.)

[Discuss: Should there be a helper to allocate a surface? Note that
getting the chroma type is necessary regardless. At least VLC wants to
know the chroma type earlier than it allocates the first surface.]
---
 libavcodec/vdpau.c |  6 ++++++
 libavcodec/vdpau.h | 10 ++++++++++
 2 files changed, 16 insertions(+)

diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
index 581f2d9..0e33739 100644
--- a/libavcodec/vdpau.c
+++ b/libavcodec/vdpau.c
@@ -57,6 +57,12 @@ static void *ff_vdpau_get_proc_address(AVCodecContext 
*avctx, VdpFuncId id)
     return ret;
 }
 
+VdpChromaType av_vdpau_get_chroma_type(AVCodecContext *avctx)
+{
+    /* So far only YUV 4:2:0 8-bits is supported by any profile */
+    return VDP_CHROMA_TYPE_420;
+}
+
 int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile,
                          uint32_t level, uint32_t surfaces)
 {
diff --git a/libavcodec/vdpau.h b/libavcodec/vdpau.h
index 4a99834..5cbdb27 100644
--- a/libavcodec/vdpau.h
+++ b/libavcodec/vdpau.h
@@ -150,6 +150,16 @@ typedef struct AVVDPAUContext {
 AVVDPAUContext *av_vdpau_create_context(VdpDevice device,
                                         VdpGetProcAddress *get_proc_address);
 
+/**
+ * Gets the proper VDPAU video surface chroma type to supply to a codec
+ * context using VDPAU hardware decoding acceleration.
+ *
+ * @note Behaviour is undefined if the contex is not using VDPAU.
+ *
+ * @return VDPAU chroma type of video surfaces (cannot fail)
+ */
+VdpChromaType av_vdpau_get_chroma_type(AVCodecContext *avctx);
+
 #if FF_API_DECODER_VDPAU
 /**
  * Allocate an AVVDPAUContext.
-- 
1.8.1.5

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

Reply via email to