mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-22 17:51:16 +00:00
vaallocator: use GstVideoInfoDmaDrm for dmabuf setup
Instead of guessing the DRM format and modifier, pass a DRM video info to gst_va_dmabuf_memories_setup(). Still, it checks for the DRM parameters in DRM info, if they are not available, as in the case of V4L2 buffers, the part of the video info is used. This is an API breakage, but since the plugin is still in stage, it's still allowed. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5264>
This commit is contained in:
parent
d1210d6dc0
commit
7c0227145c
4 changed files with 43 additions and 20 deletions
|
@ -1016,10 +1016,9 @@ VASurfaceID and it's attached into every @mem.</doc>
|
||||||
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c">a #GstVaDisplay</doc>
|
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c">a #GstVaDisplay</doc>
|
||||||
<type name="VaDisplay" c:type="GstVaDisplay*"/>
|
<type name="VaDisplay" c:type="GstVaDisplay*"/>
|
||||||
</parameter>
|
</parameter>
|
||||||
<parameter name="info" transfer-ownership="none">
|
<parameter name="drm_info" transfer-ownership="none">
|
||||||
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c">a #GstVideoInfo</doc>
|
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c">a #GstVideoInfoDmaDrm</doc>
|
||||||
<type name="GstVideo.VideoInfo" c:type="GstVideoInfo*"/>
|
<type name="GstVideo.VideoInfoDmaDrm" c:type="GstVideoInfoDmaDrm*"/>
|
||||||
</parameter>
|
|
||||||
</parameter>
|
</parameter>
|
||||||
<parameter name="mem" transfer-ownership="none">
|
<parameter name="mem" transfer-ownership="none">
|
||||||
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c">Memories. One
|
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c">Memories. One
|
||||||
|
|
|
@ -46,6 +46,10 @@
|
||||||
#include "gstvavideoformat.h"
|
#include "gstvavideoformat.h"
|
||||||
#include "vasurfaceimage.h"
|
#include "vasurfaceimage.h"
|
||||||
|
|
||||||
|
#ifndef DRM_FORMAT_INVALID
|
||||||
|
#define DRM_FORMAT_INVALID 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#define GST_CAT_DEFAULT gst_va_memory_debug
|
#define GST_CAT_DEFAULT gst_va_memory_debug
|
||||||
GST_DEBUG_CATEGORY (gst_va_memory_debug);
|
GST_DEBUG_CATEGORY (gst_va_memory_debug);
|
||||||
|
|
||||||
|
@ -1051,7 +1055,7 @@ _is_fd_repeated (uintptr_t fds[GST_VIDEO_MAX_PLANES], guint cur, guint * prev)
|
||||||
/**
|
/**
|
||||||
* gst_va_dmabuf_memories_setup:
|
* gst_va_dmabuf_memories_setup:
|
||||||
* @display: a #GstVaDisplay
|
* @display: a #GstVaDisplay
|
||||||
* @info: a #GstVideoInfo
|
* @drm_info: a #GstVideoInfoDmaDrm
|
||||||
* @mem: (array fixed-size=4) (element-type GstMemory): Memories. One
|
* @mem: (array fixed-size=4) (element-type GstMemory): Memories. One
|
||||||
* per plane.
|
* per plane.
|
||||||
* @fds: (array fixed-size=4) (element-type uintptr_t): array of
|
* @fds: (array fixed-size=4) (element-type uintptr_t): array of
|
||||||
|
@ -1070,12 +1074,14 @@ _is_fd_repeated (uintptr_t fds[GST_VIDEO_MAX_PLANES], guint cur, guint * prev)
|
||||||
*/
|
*/
|
||||||
/* XXX: use a surface pool to control the created surfaces */
|
/* XXX: use a surface pool to control the created surfaces */
|
||||||
gboolean
|
gboolean
|
||||||
gst_va_dmabuf_memories_setup (GstVaDisplay * display, GstVideoInfo * info,
|
gst_va_dmabuf_memories_setup (GstVaDisplay * display,
|
||||||
GstMemory * mem[GST_VIDEO_MAX_PLANES], uintptr_t fds[GST_VIDEO_MAX_PLANES],
|
GstVideoInfoDmaDrm * drm_info, GstMemory * mem[GST_VIDEO_MAX_PLANES],
|
||||||
gsize offset[GST_VIDEO_MAX_PLANES], guint usage_hint)
|
uintptr_t fds[GST_VIDEO_MAX_PLANES], gsize offset[GST_VIDEO_MAX_PLANES],
|
||||||
|
guint usage_hint)
|
||||||
{
|
{
|
||||||
GstVideoFormat format;
|
GstVideoFormat format;
|
||||||
GstVaBufferSurface *buf;
|
GstVaBufferSurface *buf;
|
||||||
|
GstVideoInfo *info = &drm_info->vinfo;
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
VADRMPRIMESurfaceDescriptor desc = {
|
VADRMPRIMESurfaceDescriptor desc = {
|
||||||
.width = GST_VIDEO_INFO_WIDTH (info),
|
.width = GST_VIDEO_INFO_WIDTH (info),
|
||||||
|
@ -1085,7 +1091,8 @@ gst_va_dmabuf_memories_setup (GstVaDisplay * display, GstVideoInfo * info,
|
||||||
};
|
};
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
VASurfaceID surface;
|
VASurfaceID surface;
|
||||||
guint32 fourcc, rt_format;
|
guint32 fourcc, rt_format, drm_fourcc;
|
||||||
|
guint64 drm_modifier;
|
||||||
guint i, j, prev, n_planes;
|
guint i, j, prev, n_planes;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
|
@ -1093,10 +1100,17 @@ gst_va_dmabuf_memories_setup (GstVaDisplay * display, GstVideoInfo * info,
|
||||||
|
|
||||||
n_planes = GST_VIDEO_INFO_N_PLANES (info);
|
n_planes = GST_VIDEO_INFO_N_PLANES (info);
|
||||||
|
|
||||||
format = GST_VIDEO_INFO_FORMAT (info);
|
format = (drm_info->drm_fourcc == DRM_FORMAT_INVALID) ?
|
||||||
|
GST_VIDEO_INFO_FORMAT (info) :
|
||||||
|
gst_va_video_format_from_drm_fourcc (drm_info->drm_fourcc);
|
||||||
if (format == GST_VIDEO_FORMAT_UNKNOWN)
|
if (format == GST_VIDEO_FORMAT_UNKNOWN)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
drm_fourcc = (drm_info->drm_fourcc == DRM_FORMAT_INVALID) ?
|
||||||
|
gst_va_drm_fourcc_from_video_format (format) : drm_info->drm_fourcc;
|
||||||
|
if (drm_fourcc == 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
rt_format = gst_va_chroma_from_video_format (format);
|
rt_format = gst_va_chroma_from_video_format (format);
|
||||||
if (rt_format == 0)
|
if (rt_format == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1105,10 +1119,12 @@ gst_va_dmabuf_memories_setup (GstVaDisplay * display, GstVideoInfo * info,
|
||||||
if (fourcc == 0)
|
if (fourcc == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
drm_modifier = (drm_info->drm_modifier == DRM_FORMAT_MOD_INVALID) ?
|
||||||
|
DRM_FORMAT_MOD_LINEAR : drm_info->drm_modifier;
|
||||||
|
|
||||||
desc.fourcc = fourcc;
|
desc.fourcc = fourcc;
|
||||||
desc.layers[0].num_planes = n_planes;
|
desc.layers[0].num_planes = n_planes;
|
||||||
/* FIXME: use GstVideoInfoDmaDrm */
|
desc.layers[0].drm_format = drm_fourcc;
|
||||||
desc.layers[0].drm_format = gst_va_drm_fourcc_from_video_format (format);
|
|
||||||
|
|
||||||
for (i = j = 0; i < n_planes; i++) {
|
for (i = j = 0; i < n_planes; i++) {
|
||||||
desc.layers[0].pitch[i] = GST_VIDEO_INFO_PLANE_STRIDE (info, i);
|
desc.layers[0].pitch[i] = GST_VIDEO_INFO_PLANE_STRIDE (info, i);
|
||||||
|
@ -1121,8 +1137,7 @@ gst_va_dmabuf_memories_setup (GstVaDisplay * display, GstVideoInfo * info,
|
||||||
|
|
||||||
desc.objects[j].fd = fds[i];
|
desc.objects[j].fd = fds[i];
|
||||||
desc.objects[j].size = _get_fd_size (fds[i]);
|
desc.objects[j].size = _get_fd_size (fds[i]);
|
||||||
/* FIXME: use GstVideoInfoDmaDrm */
|
desc.objects[j].drm_format_modifier = drm_modifier;
|
||||||
desc.objects[j].drm_format_modifier = DRM_FORMAT_MOD_LINEAR;
|
|
||||||
|
|
||||||
desc.layers[0].object_index[i] = j;
|
desc.layers[0].object_index[i] = j;
|
||||||
j++;
|
j++;
|
||||||
|
|
|
@ -58,7 +58,7 @@ gboolean gst_va_dmabuf_allocator_get_format (GstAllocator * alloca
|
||||||
|
|
||||||
GST_VA_API
|
GST_VA_API
|
||||||
gboolean gst_va_dmabuf_memories_setup (GstVaDisplay * display,
|
gboolean gst_va_dmabuf_memories_setup (GstVaDisplay * display,
|
||||||
GstVideoInfo * info,
|
GstVideoInfoDmaDrm * drm_info,
|
||||||
GstMemory * mem[GST_VIDEO_MAX_PLANES],
|
GstMemory * mem[GST_VIDEO_MAX_PLANES],
|
||||||
uintptr_t fds[GST_VIDEO_MAX_PLANES],
|
uintptr_t fds[GST_VIDEO_MAX_PLANES],
|
||||||
gsize offset[GST_VIDEO_MAX_PLANES],
|
gsize offset[GST_VIDEO_MAX_PLANES],
|
||||||
|
|
|
@ -40,25 +40,28 @@ _try_import_dmabuf_unlocked (GstVaBufferImporter * importer, GstBuffer * inbuf)
|
||||||
{
|
{
|
||||||
GstVideoMeta *meta;
|
GstVideoMeta *meta;
|
||||||
GstVideoInfo in_info = *importer->in_info;
|
GstVideoInfo in_info = *importer->in_info;
|
||||||
|
GstVideoInfoDmaDrm drm_info;
|
||||||
GstMemory *mems[GST_VIDEO_MAX_PLANES];
|
GstMemory *mems[GST_VIDEO_MAX_PLANES];
|
||||||
guint i, n_mem, n_planes, usage_hint;
|
guint i, n_mem, n_planes, usage_hint;
|
||||||
gsize offset[GST_VIDEO_MAX_PLANES];
|
gsize offset[GST_VIDEO_MAX_PLANES];
|
||||||
uintptr_t fd[GST_VIDEO_MAX_PLANES];
|
uintptr_t fd[GST_VIDEO_MAX_PLANES];
|
||||||
gsize plane_size[GST_VIDEO_MAX_PLANES];
|
gsize plane_size[GST_VIDEO_MAX_PLANES];
|
||||||
GstVideoAlignment align = { 0, };
|
GstVideoAlignment align = { 0, };
|
||||||
|
GstVideoFormat format;
|
||||||
n_planes = GST_VIDEO_INFO_N_PLANES (&in_info);
|
|
||||||
n_mem = gst_buffer_n_memory (inbuf);
|
|
||||||
meta = gst_buffer_get_video_meta (inbuf);
|
|
||||||
|
|
||||||
/* This will eliminate most non-dmabuf out there */
|
/* This will eliminate most non-dmabuf out there */
|
||||||
if (!gst_is_dmabuf_memory (gst_buffer_peek_memory (inbuf, 0)))
|
if (!gst_is_dmabuf_memory (gst_buffer_peek_memory (inbuf, 0)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
n_mem = gst_buffer_n_memory (inbuf);
|
||||||
|
n_planes = GST_VIDEO_INFO_N_PLANES (&in_info);
|
||||||
|
|
||||||
/* We cannot have multiple dmabuf per plane */
|
/* We cannot have multiple dmabuf per plane */
|
||||||
if (n_mem > n_planes)
|
if (n_mem > n_planes)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
meta = gst_buffer_get_video_meta (inbuf);
|
||||||
|
|
||||||
/* Update video info importerd on video meta */
|
/* Update video info importerd on video meta */
|
||||||
if (meta) {
|
if (meta) {
|
||||||
GST_VIDEO_INFO_WIDTH (&in_info) = meta->width;
|
GST_VIDEO_INFO_WIDTH (&in_info) = meta->width;
|
||||||
|
@ -101,8 +104,14 @@ _try_import_dmabuf_unlocked (GstVaBufferImporter * importer, GstBuffer * inbuf)
|
||||||
usage_hint = va_get_surface_usage_hint (importer->display,
|
usage_hint = va_get_surface_usage_hint (importer->display,
|
||||||
importer->entrypoint, GST_PAD_SINK, TRUE);
|
importer->entrypoint, GST_PAD_SINK, TRUE);
|
||||||
|
|
||||||
|
/* FIXME(victor): don't assume the modifier */
|
||||||
|
format = GST_VIDEO_INFO_FORMAT (&in_info);
|
||||||
|
drm_info.drm_fourcc = gst_va_drm_fourcc_from_video_format (format);
|
||||||
|
drm_info.drm_modifier = DRM_FORMAT_MOD_LINEAR;
|
||||||
|
drm_info.vinfo = in_info;
|
||||||
|
|
||||||
/* Now create a VASurfaceID for the buffer */
|
/* Now create a VASurfaceID for the buffer */
|
||||||
return gst_va_dmabuf_memories_setup (importer->display, &in_info, mems, fd,
|
return gst_va_dmabuf_memories_setup (importer->display, &drm_info, mems, fd,
|
||||||
offset, usage_hint);
|
offset, usage_hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue