summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2020-01-24 19:32:52 +0100
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2020-02-23 13:12:15 +0100
commit96fdc3d322c7bf083a1411879863e1717ff2fc32 (patch)
treece87c2cea832ca086b8a5af272f56d6b45ec43a5 /gst-libs
parent8c08ef31a5ce6c69ae0502b174ec591c0d0d8d2a (diff)
libs: surface: Add hints to allocation flags.
When creating surfaces it is possible to pass to VA hints of its usage, so the driver may do some optimizations. This commit adds the handling of encoding/decoding hints.
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/vaapi/gstvaapisurface.c23
-rw-r--r--gst-libs/gst/vaapi/gstvaapisurface.h5
2 files changed, 27 insertions, 1 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapisurface.c b/gst-libs/gst/vaapi/gstvaapisurface.c
index 24da248d..3e92e0ea 100644
--- a/gst-libs/gst/vaapi/gstvaapisurface.c
+++ b/gst-libs/gst/vaapi/gstvaapisurface.c
@@ -129,6 +129,21 @@ error_unsupported_chroma_type:
return FALSE;
}
+static guint
+get_usage_hint (guint alloc_flags)
+{
+ guint usage_hints = VA_SURFACE_ATTRIB_USAGE_HINT_GENERIC;
+
+ /* XXX(victor): So far, only media-driver uses hints for encoders
+ * and it doesn't test it as bitwise */
+ if (alloc_flags & GST_VAAPI_SURFACE_ALLOC_FLAG_HINT_DECODER)
+ usage_hints = VA_SURFACE_ATTRIB_USAGE_HINT_DECODER;
+ else if (alloc_flags & GST_VAAPI_SURFACE_ALLOC_FLAG_HINT_ENCODER)
+ usage_hints = VA_SURFACE_ATTRIB_USAGE_HINT_ENCODER;
+
+ return usage_hints;
+}
+
static gboolean
gst_vaapi_surface_init_full (GstVaapiSurface * surface,
const GstVideoInfo * vip, guint surface_allocation_flags)
@@ -139,7 +154,7 @@ gst_vaapi_surface_init_full (GstVaapiSurface * surface,
VAStatus status;
guint chroma_type, va_chroma_format, i;
const VAImageFormat *va_format;
- VASurfaceAttrib attribs[3], *attrib;
+ VASurfaceAttrib attribs[4], *attrib;
VASurfaceAttribExternalBuffers extbuf = { 0, };
gboolean extbuf_needed = FALSE;
@@ -182,6 +197,12 @@ gst_vaapi_surface_init_full (GstVaapiSurface * surface,
attrib->value.value.i = va_format->fourcc;
attrib++;
+ attrib->flags = VA_SURFACE_ATTRIB_SETTABLE;
+ attrib->type = VASurfaceAttribUsageHint;
+ attrib->value.type = VAGenericValueTypeInteger;
+ attrib->value.value.i = get_usage_hint (surface_allocation_flags);
+ attrib++;
+
if (extbuf_needed) {
attrib->flags = VA_SURFACE_ATTRIB_SETTABLE;
attrib->type = VASurfaceAttribMemoryType;
diff --git a/gst-libs/gst/vaapi/gstvaapisurface.h b/gst-libs/gst/vaapi/gstvaapisurface.h
index be70ce9f..68f99ff2 100644
--- a/gst-libs/gst/vaapi/gstvaapisurface.h
+++ b/gst-libs/gst/vaapi/gstvaapisurface.h
@@ -165,6 +165,9 @@ typedef enum
* the supplied strides information from #GstVideoInfo
* @GST_VAAPI_SURFACE_ALLOC_FLAG_FIXED_OFFSETS: force allocation with
* the supplied offsets information from #GstVideoInfo
+ * @GST_VAAPI_SURFACE_ALLOC_FLAG_HINT_DECODER: Surface used by video
+ * decoder
+ * @GST_VAAPI_SURFACE_ALLOC_FLAG_HINT_ENCODER: Surface used by encoder
*
* The set of optional allocation flags for gst_vaapi_surface_new_full().
*/
@@ -173,6 +176,8 @@ typedef enum
GST_VAAPI_SURFACE_ALLOC_FLAG_LINEAR_STORAGE = 1 << 0,
GST_VAAPI_SURFACE_ALLOC_FLAG_FIXED_STRIDES = 1 << 1,
GST_VAAPI_SURFACE_ALLOC_FLAG_FIXED_OFFSETS = 1 << 2,
+ GST_VAAPI_SURFACE_ALLOC_FLAG_HINT_DECODER = 1 << 3,
+ GST_VAAPI_SURFACE_ALLOC_FLAG_HINT_ENCODER = 1 << 4,
} GstVaapiSurfaceAllocFlags;
#define GST_VAAPI_SURFACE(obj) \