summaryrefslogtreecommitdiff
path: root/libavcodec/vdpau.c
diff options
context:
space:
mode:
authorRĂ©mi Denis-Courmont <remi@remlab.net>2014-10-04 16:55:08 +0300
committerAnton Khirnov <anton@khirnov.net>2014-10-06 06:20:40 +0000
commitbef067f88c74190cdf7e76d12f02e12e069974aa (patch)
tree50f1ee2183cf0e14cd19e8f2981e6627e9745734 /libavcodec/vdpau.c
parente3e158e81f0666b8fe66be9ce1cad63a535920e0 (diff)
vdpau: check video surface and decoder capabilities
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavcodec/vdpau.c')
-rw-r--r--libavcodec/vdpau.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
index 685309f1ff..44eef20ab2 100644
--- a/libavcodec/vdpau.c
+++ b/libavcodec/vdpau.c
@@ -69,9 +69,13 @@ int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile,
{
VDPAUHWContext *hwctx = avctx->hwaccel_context;
VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
+ VdpVideoSurfaceQueryCapabilities *surface_query_caps;
+ VdpDecoderQueryCapabilities *decoder_query_caps;
VdpDecoderCreate *create;
void *func;
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;
@@ -90,6 +94,42 @@ int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile,
vdctx->device = hwctx->device;
vdctx->get_proc_address = hwctx->get_proc_address;
+ if (level < 0)
+ return AVERROR(ENOTSUP);
+
+ status = vdctx->get_proc_address(vdctx->device,
+ VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES,
+ &func);
+ if (status != VDP_STATUS_OK)
+ return vdpau_error(status);
+ else
+ surface_query_caps = func;
+
+ status = surface_query_caps(vdctx->device, VDP_CHROMA_TYPE_420, &supported,
+ &max_width, &max_height);
+ if (status != VDP_STATUS_OK)
+ return vdpau_error(status);
+ if (supported != VDP_TRUE ||
+ max_width < width || max_height < height)
+ return AVERROR(ENOTSUP);
+
+ status = vdctx->get_proc_address(vdctx->device,
+ VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES,
+ &func);
+ if (status != VDP_STATUS_OK)
+ return vdpau_error(status);
+ else
+ decoder_query_caps = func;
+
+ status = decoder_query_caps(vdctx->device, profile, &supported, &max_level,
+ &max_mb, &max_width, &max_height);
+ if (status != VDP_STATUS_OK)
+ return vdpau_error(status);
+
+ if (supported != VDP_TRUE || max_level < level ||
+ max_width < width || max_height < height)
+ return AVERROR(ENOTSUP);
+
status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_CREATE,
&func);
if (status != VDP_STATUS_OK)