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. (cherry picked from commit 4926fa9a4aa03f3b751f52e900b9efb87fea0591)

Mark Thompson committed 10 years ago

Commit a8d51bb1 parent 25012c54 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
@@ -15,6 +15,10 @@ libavutil: 2015-08-28 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2016-xx-xx - xxxxxxx - lavu 55.38.100 - hwcontext_vaapi.h
19+ Add driver quirks field to VAAPI-specific hwdevice and enum with
20+ members AV_VAAPI_DRIVER_QUIRK_* to represent its values.
21+
1822 2016-11-10 - xxxxxxx - lavu 55.36.100 - pixfmt.h
1923 Add AV_PIX_FMT_GRAY12(LE/BE).
2024
libavutil/hwcontext_vaapi.c+39−0
@@ -265,12 +265,25 @@ fail: · 264 unmodified lines
265265 return err;
266266 }
267267
268+static const struct {
269+ const char *friendly_name;
270+ const char *match_string;
271+ unsigned int quirks;
272+} vaapi_driver_quirks_table[] = {
273+ {
274+ "Intel i965 (Quick Sync)",
275+ "i965",
276+ AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS,
277+ },
278+};
279+
268280 static int vaapi_device_init(AVHWDeviceContext *hwdev)
269281 {
270282 VAAPIDeviceContext *ctx = hwdev->internal->priv;
271283 AVVAAPIDeviceContext *hwctx = hwdev->hwctx;
272284 VAImageFormat *image_list = NULL;
273285 VAStatus vas;
286+ const char *vendor_string;
274287 int err, i, image_count;
275288 enum AVPixelFormat pix_fmt;
276289 unsigned int fourcc;
@@ -312,6 +325,32 @@ static int vaapi_device_init(AVHWDeviceContext *hwdev) · 35 unmodified lines
312325 }
313326 }
314327
328+ if (hwctx->driver_quirks & AV_VAAPI_DRIVER_QUIRK_USER_SET) {
329+ av_log(hwdev, AV_LOG_VERBOSE, "Not detecting driver: "
330+ "quirks set by user.\n");
331+ } else {
332+ // Detect the driver in use and set quirk flags if necessary.
333+ vendor_string = vaQueryVendorString(hwctx->display);
334+ hwctx->driver_quirks = 0;
335+ if (vendor_string) {
336+ for (i = 0; i < FF_ARRAY_ELEMS(vaapi_driver_quirks_table); i++) {
337+ if (strstr(vendor_string,
338+ vaapi_driver_quirks_table[i].match_string)) {
339+ av_log(hwdev, AV_LOG_VERBOSE, "Matched \"%s\" as known "
340+ "driver \"%s\".\n", vendor_string,
341+ vaapi_driver_quirks_table[i].friendly_name);
342+ hwctx->driver_quirks |=
343+ vaapi_driver_quirks_table[i].quirks;
344+ break;
345+ }
346+ }
347+ if (!(i < FF_ARRAY_ELEMS(vaapi_driver_quirks_table))) {
348+ av_log(hwdev, AV_LOG_VERBOSE, "Unknown driver \"%s\", "
349+ "assuming standard behaviour.\n", vendor_string);
350+ }
351+ }
352+ }
353+
315354 av_free(image_list);
316355 return 0;
317356 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
@@ -79,7 +79,7 @@ · 78 unmodified lines
7979 */
8080
8181 #define LIBAVUTIL_VERSION_MAJOR 55
82−#define LIBAVUTIL_VERSION_MINOR 37
82+#define LIBAVUTIL_VERSION_MINOR 38
8383 #define LIBAVUTIL_VERSION_MICRO 100
8484
8585 #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