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
13 13
14API changes, most recent first:14API changes, most recent first:
15 15
162016-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
162016-xx-xx - xxxxxxx - lavu 55.18.0 - pixdesc.h202016-xx-xx - xxxxxxx - lavu 55.18.0 - pixdesc.h
17 Add AV_PIX_FMT_P010(LE/BE).21 Add AV_PIX_FMT_P010(LE/BE).
18 22
libavutil/hwcontext_vaapi.c+39−0
@@ -263,12 +263,25 @@ fail: · 262 unmodified lines
263 return err;263 return err;
264}264}
265 265
266static 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
266static int vaapi_device_init(AVHWDeviceContext *hwdev)278static int vaapi_device_init(AVHWDeviceContext *hwdev)
267{279{
268 VAAPIDeviceContext *ctx = hwdev->internal->priv;280 VAAPIDeviceContext *ctx = hwdev->internal->priv;
269 AVVAAPIDeviceContext *hwctx = hwdev->hwctx;281 AVVAAPIDeviceContext *hwctx = hwdev->hwctx;
270 VAImageFormat *image_list = NULL;282 VAImageFormat *image_list = NULL;
271 VAStatus vas;283 VAStatus vas;
284 const char *vendor_string;
272 int err, i, image_count;285 int err, i, image_count;
273 enum AVPixelFormat pix_fmt;286 enum AVPixelFormat pix_fmt;
274 unsigned int fourcc;287 unsigned int fourcc;
@@ -310,6 +323,32 @@ static int vaapi_device_init(AVHWDeviceContext *hwdev) · 35 unmodified lines
310 }323 }
311 }324 }
312 325
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
313 av_free(image_list);352 av_free(image_list);
314 return 0;353 return 0;
315fail:354fail:
libavutil/hwcontext_vaapi.h+22−0
@@ -33,6 +33,20 @@ · 32 unmodified lines
33 * with the data pointer set to a VASurfaceID.33 * with the data pointer set to a VASurfaceID.
34 */34 */
35 35
36enum {
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
36/**50/**
37 * VAAPI connection details.51 * VAAPI connection details.
38 *52 *
@@ -43,6 +57,14 @@ typedef struct AVVAAPIDeviceContext { · 4 unmodified lines
43 * The VADisplay handle, to be filled by the user.57 * The VADisplay handle, to be filled by the user.
44 */58 */
45 VADisplay display;59 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;
46} AVVAAPIDeviceContext;68} AVVAAPIDeviceContext;
47 69
48/**70/**
libavutil/version.h+1−1
@@ -54,7 +54,7 @@ · 53 unmodified lines
54 */54 */
55 55
56#define LIBAVUTIL_VERSION_MAJOR 5556#define LIBAVUTIL_VERSION_MAJOR 55
57#define LIBAVUTIL_VERSION_MINOR 1857#define LIBAVUTIL_VERSION_MINOR 19
58#define LIBAVUTIL_VERSION_MICRO 058#define LIBAVUTIL_VERSION_MICRO 0
59 59
60#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \60#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