hwcontext_vaapi: add a quirk for the missing MemoryType attribute

Message ID 1475311460-4624-1-git-send-email-anton@khirnov.net
State Committed
Commit 2124711b950b03c582a119c75f52a87acc32d6ec
Headers show

Commit Message

Anton Khirnov Oct. 1, 2016, 8:44 a.m.
The Intel binary iHD driver does not support the
VASurfaceAttribMemoryType, so surface allocation will fail when using
it.
---
 doc/APIchanges              | 3 +++
 libavutil/hwcontext_vaapi.c | 8 +++++++-
 libavutil/hwcontext_vaapi.h | 6 ++++++
 libavutil/version.h         | 2 +-
 4 files changed, 17 insertions(+), 2 deletions(-)

Comments

Mark Thompson Oct. 1, 2016, 1:57 p.m. | #1
On 01/10/16 09:44, Anton Khirnov wrote:
> The Intel binary iHD driver does not support the
> VASurfaceAttribMemoryType, so surface allocation will fail when using
> it.
> ---
>  doc/APIchanges              | 3 +++
>  libavutil/hwcontext_vaapi.c | 8 +++++++-
>  libavutil/hwcontext_vaapi.h | 6 ++++++
>  libavutil/version.h         | 2 +-
>  4 files changed, 17 insertions(+), 2 deletions(-)

Ok.  (Can't harm anything.)

- Mark
Luca Barbato Oct. 1, 2016, 6:44 p.m. | #2
On 01/10/16 10:44, Anton Khirnov wrote:
> The Intel binary iHD driver does not support the
> VASurfaceAttribMemoryType, so surface allocation will fail when using
> it.
> ---
>  doc/APIchanges              | 3 +++
>  libavutil/hwcontext_vaapi.c | 8 +++++++-
>  libavutil/hwcontext_vaapi.h | 6 ++++++
>  libavutil/version.h         | 2 +-
>  4 files changed, 17 insertions(+), 2 deletions(-)
> 

Sounds good.

Patch

diff --git a/doc/APIchanges b/doc/APIchanges
index 6fd3959..655783e 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@  libavutil:     2015-08-28
 
 API changes, most recent first:
 
+2016-xx-xx - xxxxxxx - lavu 55.23.0 - hwcontext_vaapi.h
+  Add AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE.
+
 2016-xx-xx - xxxxxxx - lavf 57.08.0 - avio.h
   Add AVIO_SEEKABLE_TIME flag.
 
diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index bba0c4d..cd7d43e 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -273,6 +273,11 @@  static const struct {
         "i965",
         AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS,
     },
+    {
+        "Intel iHD",
+        "ubit",
+        AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE,
+    },
 };
 
 static int vaapi_device_init(AVHWDeviceContext *hwdev)
@@ -447,7 +452,8 @@  static int vaapi_frames_init(AVHWFramesContext *hwfc)
     }
 
     if (!hwfc->pool) {
-        int need_memory_type = 1, need_pixel_format = 1;
+        int need_memory_type = !(hwctx->driver_quirks & AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE);
+        int need_pixel_format = 1;
         for (i = 0; i < avfc->nb_attributes; i++) {
             if (ctx->attributes[i].type == VASurfaceAttribMemoryType)
                 need_memory_type  = 0;
diff --git a/libavutil/hwcontext_vaapi.h b/libavutil/hwcontext_vaapi.h
index 0ac4caa..9f1e78a 100644
--- a/libavutil/hwcontext_vaapi.h
+++ b/libavutil/hwcontext_vaapi.h
@@ -45,6 +45,12 @@  enum {
      * separately afterwards.
      */
     AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS = (1 << 1),
+
+    /**
+     * The driver does not support the VASurfaceAttribMemoryType attribute,
+     * so the surface allocation code will not try to use it.
+     */
+    AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE = (1 << 2),
 };
 
 /**
diff --git a/libavutil/version.h b/libavutil/version.h
index f05e72c..73de00e 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -54,7 +54,7 @@ 
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 55
-#define LIBAVUTIL_VERSION_MINOR 22
+#define LIBAVUTIL_VERSION_MINOR 23
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \