diff options
author | RĂ©mi Denis-Courmont <remi@remlab.net> | 2014-10-04 16:55:07 +0300 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2014-10-06 06:20:40 +0000 |
commit | e3e158e81f0666b8fe66be9ce1cad63a535920e0 (patch) | |
tree | 6fdef8ebf681dc7adb60ed733a48089c24569441 /libavcodec/vdpau.c | |
parent | 502cde409ca5ee97ef70c2cdede88b9101746ff6 (diff) | |
download | ffmpeg-e3e158e81f0666b8fe66be9ce1cad63a535920e0.tar.gz |
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 <anton@khirnov.net>
Diffstat (limited to 'libavcodec/vdpau.c')
-rw-r--r-- | libavcodec/vdpau.c | 22 |
1 files changed, 21 insertions, 1 deletions
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; +} + /* @}*/ |