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
15 15
16API changes, most recent first:16API changes, most recent first:
17 17
182016-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
182016-11-10 - xxxxxxx - lavu 55.36.100 - pixfmt.h222016-11-10 - xxxxxxx - lavu 55.36.100 - pixfmt.h
19 Add AV_PIX_FMT_GRAY12(LE/BE).23 Add AV_PIX_FMT_GRAY12(LE/BE).
20 24
libavutil/hwcontext_vaapi.c+39−0
@@ -265,12 +265,25 @@ fail: · 264 unmodified lines
265 return err;265 return err;
266}266}
267 267
268static 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
268static int vaapi_device_init(AVHWDeviceContext *hwdev)280static int vaapi_device_init(AVHWDeviceContext *hwdev)
269{281{
270 VAAPIDeviceContext *ctx = hwdev->internal->priv;282 VAAPIDeviceContext *ctx = hwdev->internal->priv;
271 AVVAAPIDeviceContext *hwctx = hwdev->hwctx;283 AVVAAPIDeviceContext *hwctx = hwdev->hwctx;
272 VAImageFormat *image_list = NULL;284 VAImageFormat *image_list = NULL;
273 VAStatus vas;285 VAStatus vas;
286 const char *vendor_string;
274 int err, i, image_count;287 int err, i, image_count;
275 enum AVPixelFormat pix_fmt;288 enum AVPixelFormat pix_fmt;
276 unsigned int fourcc;289 unsigned int fourcc;
@@ -312,6 +325,32 @@ static int vaapi_device_init(AVHWDeviceContext *hwdev) · 35 unmodified lines
312 }325 }
313 }326 }
314 327
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
315 av_free(image_list);354 av_free(image_list);
316 return 0;355 return 0;
317fail:356fail:
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
@@ -79,7 +79,7 @@ · 78 unmodified lines
79 */79 */
80 80
81#define LIBAVUTIL_VERSION_MAJOR 5581#define LIBAVUTIL_VERSION_MAJOR 55
82#define LIBAVUTIL_VERSION_MINOR 3782#define LIBAVUTIL_VERSION_MINOR 38
83#define LIBAVUTIL_VERSION_MICRO 10083#define LIBAVUTIL_VERSION_MICRO 100
84 84
85#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \85#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