diff --git a/doc/APIchanges b/doc/APIchanges
index eb8e2351ba605c0e557c161c95ab77fd76ffb8c1..e2daed3aca90984a309934a64a459b4730dd91c7 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,10 @@ libavutil:     2015-08-28
 
 API changes, most recent first:
 
+2016-xx-xx - xxxxxxx - lavu 55.38.100 - hwcontext_vaapi.h
+  Add driver quirks field to VAAPI-specific hwdevice and enum with
+  members AV_VAAPI_DRIVER_QUIRK_* to represent its values.
+
 2016-11-10 - xxxxxxx - lavu 55.36.100 - pixfmt.h
   Add AV_PIX_FMT_GRAY12(LE/BE).
 
diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index cfa25bce62f5eb4e2de8d4f6540e15a97fdad8f4..95465507055b5731edc222e63cf8e6a3ebae5460 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:
diff --git a/libavutil/hwcontext_vaapi.h b/libavutil/hwcontext_vaapi.h
index 7fd1a36e8fbd0f4d8fcb4cf8ed32b0d46c2b6b38..8bd8031b9d8d741707841c001e599d766e8a10bd 100644
--- a/libavutil/hwcontext_vaapi.h
+++ b/libavutil/hwcontext_vaapi.h
@@ -33,6 +33,20 @@
  * with the data pointer set to a VASurfaceID.
  */
 
+enum {
+    /**
+     * The quirks field has been set by the user and should not be detected
+     * automatically by av_hwdevice_ctx_init().
+     */
+    AV_VAAPI_DRIVER_QUIRK_USER_SET = (1 << 0),
+    /**
+     * The driver does not destroy parameter buffers when they are used by
+     * vaRenderPicture().  Additional code will be required to destroy them
+     * separately afterwards.
+     */
+    AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS = (1 << 1),
+};
+
 /**
  * VAAPI connection details.
  *
@@ -43,6 +57,14 @@ typedef struct AVVAAPIDeviceContext {
      * The VADisplay handle, to be filled by the user.
      */
     VADisplay display;
+    /**
+     * Driver quirks to apply - this is filled by av_hwdevice_ctx_init(),
+     * with reference to a table of known drivers, unless the
+     * AV_VAAPI_DRIVER_QUIRK_USER_SET bit is already present.  The user
+     * may need to refer to this field when performing any later
+     * operations using VAAPI with the same VADisplay.
+     */
+    unsigned int driver_quirks;
 } AVVAAPIDeviceContext;
 
 /**
diff --git a/libavutil/version.h b/libavutil/version.h
index a49be1ac9b2d2c595398c58015e683db500810c4..81c51815a46d811c1ebf2003dbad943d266a4854 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  55
-#define LIBAVUTIL_VERSION_MINOR  37
+#define LIBAVUTIL_VERSION_MINOR  38
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \