---
 libavcodec/vdpau.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
index 6eecfbb..0b19edf 100644
--- a/libavcodec/vdpau.c
+++ b/libavcodec/vdpau.c
@@ -81,8 +81,12 @@ int ff_vdpau_common_init(AVCodecContext *avctx, 
VdpDecoderProfile profile,
 {
     AVVDPAUContext *hwctx = avctx->hwaccel_context;
     struct vdpau_context *vdctx = avctx->internal->hwaccel_priv_data;
+    VdpVideoSurfaceQueryCapabilities *surface_query_caps;
+    VdpDecoderQueryCapabilities *decoder_query_caps;
     VdpDecoderCreate *create;
     VdpStatus status;
+    VdpBool supported;
+    uint32_t max_level, max_mb, max_width, max_height;
     uint32_t width  = (avctx->coded_width + 1) & ~1;
     uint32_t height = (avctx->coded_height + 3) & ~3;
 
@@ -98,6 +102,38 @@ int ff_vdpau_common_init(AVCodecContext *avctx, 
VdpDecoderProfile profile,
         return 0; /* Decoder created by user */
     }
 
+    if (level < 0)
+        return AVERROR(ENOTSUP);
+
+    surface_query_caps =
+        ff_vdpau_get_proc_address(avctx,
+                                  
VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES);
+    if (surface_query_caps == NULL)
+        return AVERROR(ENOSYS);
+
+    status = surface_query_caps(vdctx->device, VDP_CHROMA_TYPE_420, &supported,
+                                &max_width, &max_height);
+    if (status != VDP_STATUS_OK)
+        return ff_vdpau_error(status);
+    if (supported != VDP_TRUE ||
+        max_width < width || max_height < height)
+        return AVERROR(ENOTSUP);
+
+    decoder_query_caps =
+        ff_vdpau_get_proc_address(avctx,
+                                  VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES);
+    if (decoder_query_caps == NULL)
+        return AVERROR(ENOSYS);
+
+    status = decoder_query_caps(vdctx->device, profile, &supported, &max_level,
+                                &max_mb, &max_width, &max_height);
+    if (status != VDP_STATUS_OK)
+        return ff_vdpau_error(status);
+
+    if (supported != VDP_TRUE || max_level < level ||
+        max_width < width || max_height < height)
+        return AVERROR(ENOTSUP);
+
     create = ff_vdpau_get_proc_address(avctx, VDP_FUNC_ID_DECODER_CREATE);
     vdctx->render = ff_vdpau_get_proc_address(avctx,
                                               VDP_FUNC_ID_DECODER_RENDER);
-- 
1.8.1.5

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

Reply via email to