From a8d51bb42474b1641f45b5b3815864ea323a3e59 Mon Sep 17 00:00:00 2001 From: Mark Thompson Date: Sun, 12 Jun 2016 17:20:25 +0100 Subject: hwcontext_vaapi: Add driver quirks to the hwdevice The driver being used is detected inside av_hwdevice_ctx_init() and the quirks field then set from a table of known device. If this behaviour is unwanted, the user can also set the quirks field manually. Also adds the Intel i965 driver quirk (it does not destroy parameter buffers used in a call to vaRenderPicture()) and detects that driver to set it. (cherry picked from commit 4926fa9a4aa03f3b751f52e900b9efb87fea0591) --- libavutil/hwcontext_vaapi.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'libavutil/hwcontext_vaapi.c') diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index cfa25bce62..9546550705 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -265,12 +265,25 @@ fail: return err; } +static const struct { + const char *friendly_name; + const char *match_string; + unsigned int quirks; +} vaapi_driver_quirks_table[] = { + { + "Intel i965 (Quick Sync)", + "i965", + AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS, + }, +}; + static int vaapi_device_init(AVHWDeviceContext *hwdev) { VAAPIDeviceContext *ctx = hwdev->internal->priv; AVVAAPIDeviceContext *hwctx = hwdev->hwctx; VAImageFormat *image_list = NULL; VAStatus vas; + const char *vendor_string; int err, i, image_count; enum AVPixelFormat pix_fmt; unsigned int fourcc; @@ -312,6 +325,32 @@ static int vaapi_device_init(AVHWDeviceContext *hwdev) } } + if (hwctx->driver_quirks & AV_VAAPI_DRIVER_QUIRK_USER_SET) { + av_log(hwdev, AV_LOG_VERBOSE, "Not detecting driver: " + "quirks set by user.\n"); + } else { + // Detect the driver in use and set quirk flags if necessary. + vendor_string = vaQueryVendorString(hwctx->display); + hwctx->driver_quirks = 0; + if (vendor_string) { + for (i = 0; i < FF_ARRAY_ELEMS(vaapi_driver_quirks_table); i++) { + if (strstr(vendor_string, + vaapi_driver_quirks_table[i].match_string)) { + av_log(hwdev, AV_LOG_VERBOSE, "Matched \"%s\" as known " + "driver \"%s\".\n", vendor_string, + vaapi_driver_quirks_table[i].friendly_name); + hwctx->driver_quirks |= + vaapi_driver_quirks_table[i].quirks; + break; + } + } + if (!(i < FF_ARRAY_ELEMS(vaapi_driver_quirks_table))) { + av_log(hwdev, AV_LOG_VERBOSE, "Unknown driver \"%s\", " + "assuming standard behaviour.\n", vendor_string); + } + } + } + av_free(image_list); return 0; fail: -- cgit v1.2.3