---
 libavcodec/vdpau.c          | 38 ++++++++++++++++++++++++++++++--------
 libavcodec/vdpau_h264.c     |  2 +-
 libavcodec/vdpau_internal.h |  3 ++-
 libavcodec/vdpau_mpeg12.c   |  6 ++++--
 libavcodec/vdpau_mpeg4.c    |  6 ++++--
 libavcodec/vdpau_vc1.c      |  3 ++-
 6 files changed, 43 insertions(+), 15 deletions(-)

diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
index 8d9a649..463e600 100644
--- a/libavcodec/vdpau.c
+++ b/libavcodec/vdpau.c
@@ -67,20 +67,38 @@ 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;
+    VdpChromaType t = VDP_CHROMA_TYPE_420;
+    uint32_t w = avctx->coded_width;
+    uint32_t h = avctx->coded_height;
+
     /* See <vdpau/vdpau.h> for per-type alignment constraints. */
+    switch (t)
+    {
+    case VDP_CHROMA_TYPE_420:
+        w = (w + 1) & ~1;
+        h = (h + 3) & ~3;
+        break;
+    case VDP_CHROMA_TYPE_422:
+        w = (w + 1) & ~1;
+        h = (h + 1) & ~1;
+        break;
+    case VDP_CHROMA_TYPE_444:
+        h = (h + 1) & ~1;
+        break;
+    }
+
+    if (type)
+        *type = t;
     if (width)
-        *width = (avctx->coded_width + 1) & ~1;
+        *width = w;
     if (height)
-        *height = (avctx->coded_height + 3) & ~3;
+        *height = h;
 
     return 0;
 }
 
 int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile,
-                         int level)
+                         int level, VdpChromaType type)
 {
     VDPAUHWContext *hwctx = avctx->hwaccel_context;
     VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
@@ -91,10 +109,10 @@ int ff_vdpau_common_init(AVCodecContext *avctx, 
VdpDecoderProfile profile,
     VdpStatus status;
     VdpBool supported;
     uint32_t max_level, max_mb, max_width, max_height;
-    VdpChromaType type;
     uint32_t width;
     uint32_t height;
 
+    vdctx->chroma_type      = type;
     vdctx->width            = UINT32_MAX;
     vdctx->height           = UINT32_MAX;
     hwctx->reset            = 0;
@@ -114,6 +132,10 @@ int ff_vdpau_common_init(AVCodecContext *avctx, 
VdpDecoderProfile profile,
     else if (level < 0)
         return AVERROR(ENOTSUP);
 
+    if (!(hwctx->flags & AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH) &&
+        type != VDP_CHROMA_TYPE_420)
+        return AVERROR(ENOSYS);
+
     status = vdctx->get_proc_address(vdctx->device,
                                      
VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES,
                                      &func);
@@ -122,7 +144,7 @@ int ff_vdpau_common_init(AVCodecContext *avctx, 
VdpDecoderProfile profile,
     else
         surface_query_caps = func;
 
-    av_vdpau_get_surface_parameters(avctx, &type, &width, &height);
+    av_vdpau_get_surface_parameters(avctx, NULL, &width, &height);
 
     status = surface_query_caps(vdctx->device, type, &supported,
                                 &max_width, &max_height);
diff --git a/libavcodec/vdpau_h264.c b/libavcodec/vdpau_h264.c
index 5ed1fff..6774882 100644
--- a/libavcodec/vdpau_h264.c
+++ b/libavcodec/vdpau_h264.c
@@ -235,7 +235,7 @@ static int vdpau_h264_init(AVCodecContext *avctx)
     if ((avctx->profile & FF_PROFILE_H264_INTRA) && avctx->level == 11)
         level = VDP_DECODER_LEVEL_H264_1b;
 
-    return ff_vdpau_common_init(avctx, profile, level);
+    return ff_vdpau_common_init(avctx, profile, level, VDP_CHROMA_TYPE_420);
 }
 
 AVHWAccel ff_h264_vdpau_hwaccel = {
diff --git a/libavcodec/vdpau_internal.h b/libavcodec/vdpau_internal.h
index 16493b0..bcdeb90 100644
--- a/libavcodec/vdpau_internal.h
+++ b/libavcodec/vdpau_internal.h
@@ -77,6 +77,7 @@ typedef struct VDPAUContext {
      */
     VdpDecoderRender *render;
 
+    VdpChromaType chroma_type;
     uint32_t width;
     uint32_t height;
 } VDPAUContext;
@@ -104,7 +105,7 @@ struct vdpau_picture_context {
 };
 
 int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile,
-                         int level);
+                         int level, VdpChromaType type);
 int ff_vdpau_common_uninit(AVCodecContext *avctx);
 
 int ff_vdpau_common_start_frame(struct vdpau_picture_context *pic,
diff --git a/libavcodec/vdpau_mpeg12.c b/libavcodec/vdpau_mpeg12.c
index 421abe9..bafe83c 100644
--- a/libavcodec/vdpau_mpeg12.c
+++ b/libavcodec/vdpau_mpeg12.c
@@ -98,7 +98,8 @@ static int vdpau_mpeg_decode_slice(AVCodecContext *avctx,
 static int vdpau_mpeg1_init(AVCodecContext *avctx)
 {
     return ff_vdpau_common_init(avctx, VDP_DECODER_PROFILE_MPEG1,
-                                VDP_DECODER_LEVEL_MPEG1_NA);
+                                VDP_DECODER_LEVEL_MPEG1_NA,
+                                VDP_CHROMA_TYPE_420);
 }
 
 AVHWAccel ff_mpeg1_vdpau_hwaccel = {
@@ -132,7 +133,8 @@ static int vdpau_mpeg2_init(AVCodecContext *avctx)
         return AVERROR(EINVAL);
     }
 
-    return ff_vdpau_common_init(avctx, profile, VDP_DECODER_LEVEL_MPEG2_HL);
+    return ff_vdpau_common_init(avctx, profile, VDP_DECODER_LEVEL_MPEG2_HL,
+                                VDP_CHROMA_TYPE_420);
 }
 
 AVHWAccel ff_mpeg2_vdpau_hwaccel = {
diff --git a/libavcodec/vdpau_mpeg4.c b/libavcodec/vdpau_mpeg4.c
index 978456a..b5cbc9b 100644
--- a/libavcodec/vdpau_mpeg4.c
+++ b/libavcodec/vdpau_mpeg4.c
@@ -92,7 +92,8 @@ static int vdpau_mpeg4_decode_slice(av_unused AVCodecContext 
*avctx,
 static int vdpau_h263_init(AVCodecContext *avctx)
 {
     return ff_vdpau_common_init(avctx, VDP_DECODER_PROFILE_MPEG4_PART2_ASP,
-                                VDP_DECODER_LEVEL_MPEG4_PART2_ASP_L5);
+                                VDP_DECODER_LEVEL_MPEG4_PART2_ASP_L5,
+                                VDP_CHROMA_TYPE_420);
 }
 
 AVHWAccel ff_h263_vdpau_hwaccel = {
@@ -126,7 +127,8 @@ static int vdpau_mpeg4_init(AVCodecContext *avctx)
         return AVERROR(ENOTSUP);
     }
 
-    return ff_vdpau_common_init(avctx, profile, avctx->level);
+    return ff_vdpau_common_init(avctx, profile, avctx->level,
+                                VDP_CHROMA_TYPE_420);
 }
 
 AVHWAccel ff_mpeg4_vdpau_hwaccel = {
diff --git a/libavcodec/vdpau_vc1.c b/libavcodec/vdpau_vc1.c
index 4f87c52..ec015b8 100644
--- a/libavcodec/vdpau_vc1.c
+++ b/libavcodec/vdpau_vc1.c
@@ -127,7 +127,8 @@ static int vdpau_vc1_init(AVCodecContext *avctx)
         return AVERROR(ENOTSUP);
     }
 
-    return ff_vdpau_common_init(avctx, profile, avctx->level);
+    return ff_vdpau_common_init(avctx, profile, avctx->level,
+                                VDP_CHROMA_TYPE_420);
 }
 
 #if CONFIG_WMV3_VDPAU_HWACCEL
-- 
2.1.3

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

Reply via email to