History

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.

Mark Thompson committed 10 years ago

Commit 4926fa91 parent 2ef87814 files · +66 −1Browse files

Unified · Split

4 files
  1. doc/APIchanges +4 −0
  2. libavutil/hwcontext_vaapi.c +39 −0
  3. libavutil/hwcontext_vaapi.h +22 −0
  4. libavutil/version.h +1 −1
doc/APIchanges+4−0
@@ -13,6 +13,10 @@ libavutil: 2015-08-28 · 12 unmodified lines
1313
1414 API changes, most recent first:
1515
16+2016-xx-xx - xxxxxxx - lavu 55.19.0 - hwcontext_vaapi.h
17+ Add driver quirks field to VAAPI-specific hwdevice and enum with
18+ members AV_VAAPI_DRIVER_QUIRK_* to represent its values.
19+
1620 2016-xx-xx - xxxxxxx - lavu 55.18.0 - pixdesc.h
1721 Add AV_PIX_FMT_P010(LE/BE).
1822
libavutil/hwcontext_vaapi.c+39−0
@@ -263,12 +263,25 @@ fail: · 262 unmodified lines
263263 return err;
264264 }
265265
266+static const struct {
267+ const char *friendly_name;
268+ const char *match_string;
269+ unsigned int quirks;
270+} vaapi_driver_quirks_table[] = {
271+ {
272+ "Intel i965 (Quick Sync)",
273+ "i965",
274+ AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS,
275+ },
276+};
277+
266278 static int vaapi_device_init(AVHWDeviceContext *hwdev)
267279 {
268280 VAAPIDeviceContext *ctx = hwdev->internal->priv;
269281 AVVAAPIDeviceContext *hwctx = hwdev->hwctx;
270282 VAImageFormat *image_list = NULL;
271283 VAStatus vas;
284+ const char *vendor_string;
272285 int err, i, image_count;
273286 enum AVPixelFormat pix_fmt;
274287 unsigned int fourcc;
@@ -310,6 +323,32 @@ static int vaapi_device_init(AVHWDeviceContext *hwdev) · 35 unmodified lines
310323 }
311324 }
312325
326+ if (hwctx->driver_quirks & AV_VAAPI_DRIVER_QUIRK_USER_SET) {
327+ av_log(hwdev, AV_LOG_VERBOSE, "Not detecting driver: "
328+ "quirks set by user.\n");
329+ } else {
330+ // Detect the driver in use and set quirk flags if necessary.
331+ vendor_string = vaQueryVendorString(hwctx->display);
332+ hwctx->driver_quirks = 0;
333+ if (vendor_string) {
334+ for (i = 0; i < FF_ARRAY_ELEMS(vaapi_driver_quirks_table); i++) {
335+ if (strstr(vendor_string,
336+ vaapi_driver_quirks_table[i].match_string)) {
337+ av_log(hwdev, AV_LOG_VERBOSE, "Matched \"%s\" as known "
338+ "driver \"%s\".\n", vendor_string,
339+ vaapi_driver_quirks_table[i].friendly_name);
340+ hwctx->driver_quirks |=
341+ vaapi_driver_quirks_table[i].quirks;
342+ break;
343+ }
344+ }
345+ if (!(i < FF_ARRAY_ELEMS(vaapi_driver_quirks_table))) {
346+ av_log(hwdev, AV_LOG_VERBOSE, "Unknown driver \"%s\", "
347+ "assuming standard behaviour.\n", vendor_string);
348+ }
349+ }
350+ }
351+
313352 av_free(image_list);
314353 return 0;
315354 fail:
libavutil/hwcontext_vaapi.h+22−0
@@ -33,6 +33,20 @@ · 32 unmodified lines
3333 * with the data pointer set to a VASurfaceID.
3434 */
3535
36+enum {
37+ /**
38+ * The quirks field has been set by the user and should not be detected
39+ * automatically by av_hwdevice_ctx_init().
40+ */
41+ AV_VAAPI_DRIVER_QUIRK_USER_SET = (1 << 0),
42+ /**
43+ * The driver does not destroy parameter buffers when they are used by
44+ * vaRenderPicture(). Additional code will be required to destroy them
45+ * separately afterwards.
46+ */
47+ AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS = (1 << 1),
48+};
49+
3650 /**
3751 * VAAPI connection details.
3852 *
@@ -43,6 +57,14 @@ typedef struct AVVAAPIDeviceContext { · 4 unmodified lines
4357 * The VADisplay handle, to be filled by the user.
4458 */
4559 VADisplay display;
60+ /**
61+ * Driver quirks to apply - this is filled by av_hwdevice_ctx_init(),
62+ * with reference to a table of known drivers, unless the
63+ * AV_VAAPI_DRIVER_QUIRK_USER_SET bit is already present. The user
64+ * may need to refer to this field when performing any later
65+ * operations using VAAPI with the same VADisplay.
66+ */
67+ unsigned int driver_quirks;
4668 } AVVAAPIDeviceContext;
4769
4870 /**
libavutil/version.h+1−1
@@ -54,7 +54,7 @@ · 53 unmodified lines
5454 */
5555
5656 #define LIBAVUTIL_VERSION_MAJOR 55
57−#define LIBAVUTIL_VERSION_MINOR 18
57+#define LIBAVUTIL_VERSION_MINOR 19
5858 #define LIBAVUTIL_VERSION_MICRO 0
5959
6060 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t