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

[Discuss: Should this be in av_vdpau_create_context() instead? That
seems mostly equivalent. In the latter case, av_vdpau_create_context()
would need an extra argument for the AVCodecContext pointer.]
---
 libavcodec/vdpau.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
index 0e33739..168a89c 100644
--- a/libavcodec/vdpau.c
+++ b/libavcodec/vdpau.c
@@ -68,8 +68,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;
 
 #if FF_API_DECODER_VDPAU
     if (hwctx->device == VDP_INVALID_HANDLE) {
@@ -79,6 +83,23 @@ int ff_vdpau_common_init(AVCodecContext *avctx, 
VdpDecoderProfile profile,
     }
 #endif
 
+    surface_query_caps = ff_vdpau_get_proc_address(avctx,
+                                 VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES);
+
+    status = surface_query_caps(hwctx->device, VDP_CHROMA_TYPE_420, &supported,
+                                &max_width, &max_height);
+    if (status != VDP_STATUS_OK || supported != VDP_TRUE ||
+        max_width < avctx->width || max_height < avctx->height)
+        return AVERROR(ENOTSUP);
+
+    decoder_query_caps = ff_vdpau_get_proc_address(avctx,
+                                       VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES);
+    status = decoder_query_caps(hwctx->device, profile, &supported, &max_level,
+                                &max_mb, &max_width, &max_height);
+    if (status != VDP_STATUS_OK || supported != VDP_TRUE || max_level < level
+     || max_width < avctx->width || max_height < avctx->height)
+        return AVERROR(ENOTSUP);
+
     create = ff_vdpau_get_proc_address(avctx, VDP_FUNC_ID_DECODER_CREATE);
 
     status = create(hwctx->device, profile, avctx->width, avctx->height,
-- 
1.8.1.5

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

Reply via email to