From e3e158e81f0666b8fe66be9ce1cad63a535920e0 Mon Sep 17 00:00:00 2001 From: RĂ©mi Denis-Courmont Date: Sat, 4 Oct 2014 16:55:07 +0300 Subject: vdpau: add av_vdpau_bind_context() This function provides an explicit VDPAU device and VDPAU driver to libavcodec, so that the application is relieved from codec specifics and VdpDevice life cycle management. A stub flags parameter is added for future extension. For instance, it could be used to ignore codec level capabilities (if someone feels dangerous). Signed-off-by: Anton Khirnov --- libavcodec/vdpau.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'libavcodec/vdpau.c') diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c index c3a8a850ae..685309f1ff 100644 --- a/libavcodec/vdpau.c +++ b/libavcodec/vdpau.c @@ -78,6 +78,7 @@ int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile, vdctx->width = UINT32_MAX; vdctx->height = UINT32_MAX; + hwctx->reset = 0; if (hwctx->context.decoder != VDP_INVALID_HANDLE) { vdctx->decoder = hwctx->context.decoder; @@ -138,12 +139,13 @@ int ff_vdpau_common_uninit(AVCodecContext *avctx) static int ff_vdpau_common_reinit(AVCodecContext *avctx) { + VDPAUHWContext *hwctx = avctx->hwaccel_context; VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data; if (vdctx->device == VDP_INVALID_HANDLE) return 0; /* Decoder created by user */ if (avctx->coded_width == vdctx->width && - avctx->coded_height == vdctx->height) + avctx->coded_height == vdctx->height && !hwctx->reset) return 0; avctx->hwaccel->uninit(avctx); @@ -266,4 +268,22 @@ AVVDPAUContext *av_vdpau_alloc_context(void) return av_mallocz(sizeof(AVVDPAUContext)); } +int av_vdpau_bind_context(AVCodecContext *avctx, VdpDevice device, + VdpGetProcAddress *get_proc, unsigned flags) +{ + VDPAUHWContext *hwctx; + + if (av_reallocp(&avctx->hwaccel_context, sizeof(*hwctx))) + return AVERROR(ENOMEM); + + hwctx = avctx->hwaccel_context; + + memset(hwctx, 0, sizeof(*hwctx)); + hwctx->context.decoder = VDP_INVALID_HANDLE; + hwctx->device = device; + hwctx->get_proc_address = get_proc; + hwctx->reset = 1; + return 0; +} + /* @}*/ -- cgit v1.2.3