diff options
author | wm4 <wm4@nowhere> | 2017-01-13 13:35:31 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-01-13 13:35:31 +0100 |
commit | d9376fc86ffec26f134e89293a4342c4b99f0e5b (patch) | |
tree | 1324eb804aa3c834b6fb6c39f1685c351ce89b78 /video/vaapi.c | |
parent | b26ab4d08caeb487208271ac6f51c6e3f1c5e5e6 (diff) | |
download | mpv-d9376fc86ffec26f134e89293a4342c4b99f0e5b.tar.bz2 mpv-d9376fc86ffec26f134e89293a4342c4b99f0e5b.tar.xz |
vaapi: always create AVHWDeviceContext on init
For convenience. Since we still have code that works even if creating a
AVHWDeviceContext fails, failure is ignored. (Although currently, it
succeeds creation even with the stale/abandoned vdpau wrapper driver.)
Diffstat (limited to 'video/vaapi.c')
-rw-r--r-- | video/vaapi.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/video/vaapi.c b/video/vaapi.c index e71232db21..69c0163972 100644 --- a/video/vaapi.c +++ b/video/vaapi.c @@ -151,6 +151,21 @@ static void va_info_callback(const char *msg) va_message_callback(msg, MSGL_V); } +static void open_lavu_vaapi_device(struct mp_vaapi_ctx *ctx) +{ + ctx->av_device_ref = av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_VAAPI); + if (!ctx->av_device_ref) + return; + + AVHWDeviceContext *hwctx = (void *)ctx->av_device_ref->data; + AVVAAPIDeviceContext *vactx = hwctx->hwctx; + + vactx->display = ctx->display; + + if (av_hwdevice_ctx_init(ctx->av_device_ref) < 0) + av_buffer_unref(&ctx->av_device_ref); +} + struct mp_vaapi_ctx *va_initialize(VADisplay *display, struct mp_log *plog, bool probing) { @@ -189,6 +204,11 @@ struct mp_vaapi_ctx *va_initialize(VADisplay *display, struct mp_log *plog, va_get_formats(res); if (!res->image_formats) goto error; + + // For now, some code will still work even if libavutil fails on old crap + // libva drivers (such as the vdpau wraper). So don't error out on failure. + open_lavu_vaapi_device(res); + return res; error: |