From 7166fd3863f5eae7bf7c22278c1c028dd3ef84cd Mon Sep 17 00:00:00 2001 From: He Junyan Date: Wed, 22 Feb 2023 16:25:32 +0800 Subject: [PATCH] va: Extend the va_create_surfaces() function to accept modifiers Part-of: --- .../gst-libs/gst/va/gstvaallocator.c | 19 +++++++-------- .../gst-libs/gst/va/vasurfaceimage.c | 23 +++++++++++++++---- .../gst-libs/gst/va/vasurfaceimage.h | 2 ++ 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c index f648e80338..5c37c2127e 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c @@ -589,8 +589,8 @@ gst_va_dmabuf_allocator_setup_buffer_full (GstAllocator * allocator, if (!va_create_surfaces (self->display, rt_format, fourcc, GST_VIDEO_INFO_WIDTH (&self->info), - GST_VIDEO_INFO_HEIGHT (&self->info), self->usage_hint, extbuf, - &surface, 1)) + GST_VIDEO_INFO_HEIGHT (&self->info), self->usage_hint, NULL, 1, + extbuf, &surface, 1)) return FALSE; /* workaround for missing layered dmabuf formats in i965 */ @@ -1040,7 +1040,8 @@ gst_va_dmabuf_memories_setup (GstVaDisplay * display, GstVideoInfo * info, } ret = va_create_surfaces (display, rt_format, ext_buf.pixel_format, - ext_buf.width, ext_buf.height, usage_hint, &ext_buf, &surface, 1); + ext_buf.width, ext_buf.height, usage_hint, NULL, 0, &ext_buf, &surface, + 1); if (!ret) return FALSE; @@ -1236,7 +1237,7 @@ _update_image_info (GstVaAllocator * va_allocator) if (!va_create_surfaces (va_allocator->display, va_allocator->rt_format, va_allocator->fourcc, GST_VIDEO_INFO_WIDTH (&va_allocator->info), GST_VIDEO_INFO_HEIGHT (&va_allocator->info), va_allocator->usage_hint, - NULL, &surface, 1)) { + NULL, 0, NULL, &surface, 1)) { GST_ERROR_OBJECT (va_allocator, "Failed to create a test surface"); return FALSE; } @@ -1599,7 +1600,7 @@ gst_va_allocator_alloc (GstAllocator * allocator) if (!va_create_surfaces (self->display, self->rt_format, self->fourcc, GST_VIDEO_INFO_WIDTH (&self->info), - GST_VIDEO_INFO_HEIGHT (&self->info), self->usage_hint, NULL, + GST_VIDEO_INFO_HEIGHT (&self->info), self->usage_hint, NULL, 0, NULL, &surface, 1)) return NULL; @@ -2066,8 +2067,8 @@ gst_va_buffer_create_aux_surface (GstBuffer * buffer) display = self->display; if (!va_create_surfaces (self->display, rt_format, fourcc, GST_VIDEO_INFO_WIDTH (&self->info), - GST_VIDEO_INFO_HEIGHT (&self->info), self->usage_hint, NULL, - &surface, 1)) + GST_VIDEO_INFO_HEIGHT (&self->info), self->usage_hint, NULL, 0, + NULL, &surface, 1)) return FALSE; } else if (GST_IS_VA_ALLOCATOR (mem->allocator)) { GstVaAllocator *self = GST_VA_ALLOCATOR (mem->allocator); @@ -2081,8 +2082,8 @@ gst_va_buffer_create_aux_surface (GstBuffer * buffer) format = GST_VIDEO_INFO_FORMAT (&self->info); if (!va_create_surfaces (self->display, self->rt_format, self->fourcc, GST_VIDEO_INFO_WIDTH (&self->info), - GST_VIDEO_INFO_HEIGHT (&self->info), self->usage_hint, NULL, - &surface, 1)) + GST_VIDEO_INFO_HEIGHT (&self->info), self->usage_hint, NULL, 0, + NULL, &surface, 1)) return FALSE; } else { g_assert_not_reached (); diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/va/vasurfaceimage.c b/subprojects/gst-plugins-bad/gst-libs/gst/va/vasurfaceimage.c index 85f6d6a2c6..307aff56e8 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/va/vasurfaceimage.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/vasurfaceimage.c @@ -50,13 +50,13 @@ va_destroy_surfaces (GstVaDisplay * display, VASurfaceID * surfaces, gboolean va_create_surfaces (GstVaDisplay * display, guint rt_format, guint fourcc, - guint width, guint height, gint usage_hint, - VASurfaceAttribExternalBuffers * ext_buf, VASurfaceID * surfaces, - guint num_surfaces) + guint width, guint height, gint usage_hint, guint64 * modifiers, + guint num_modifiers, VASurfaceAttribExternalBuffers * ext_buf, + VASurfaceID * surfaces, guint num_surfaces) { VADisplay dpy = gst_va_display_get_va_dpy (display); /* *INDENT-OFF* */ - VASurfaceAttrib attrs[5] = { + VASurfaceAttrib attrs[6] = { { .type = VASurfaceAttribUsageHint, .flags = VA_SURFACE_ATTRIB_SETTABLE, @@ -72,6 +72,10 @@ va_create_surfaces (GstVaDisplay * display, guint rt_format, guint fourcc, : VA_SURFACE_ATTRIB_MEM_TYPE_VA, }, }; + VADRMFormatModifierList modifier_list = { + .num_modifiers = num_modifiers, + .modifiers = modifiers, + }; /* *INDENT-ON* */ VAStatus status; guint num_attrs = 2; @@ -100,6 +104,17 @@ va_create_surfaces (GstVaDisplay * display, guint rt_format, guint fourcc, /* *INDENT-ON* */ } + if (num_modifiers > 0 && modifiers) { + /* *INDENT-OFF* */ + attrs[num_attrs++] = (VASurfaceAttrib) { + .type = VASurfaceAttribDRMFormatModifiers, + .flags = VA_SURFACE_ATTRIB_SETTABLE, + .value.type = VAGenericValueTypePointer, + .value.value.p = &modifier_list, + }; + /* *INDENT-ON* */ + } + status = vaCreateSurfaces (dpy, rt_format, width, height, surfaces, num_surfaces, attrs, num_attrs); if (status != VA_STATUS_SUCCESS) { diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/va/vasurfaceimage.h b/subprojects/gst-plugins-bad/gst-libs/gst/va/vasurfaceimage.h index 18f88f757a..bd109cdf31 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/va/vasurfaceimage.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/vasurfaceimage.h @@ -32,6 +32,8 @@ gboolean va_create_surfaces (GstVaDisplay * displa guint rt_format, guint fourcc, guint width, guint height, gint usage_hint, + guint64 * modifiers, + guint num_modifiers, VASurfaceAttribExternalBuffers * ext_buf, VASurfaceID * surfaces, guint num_surfaces);