mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 19:21:06 +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>
|
||||
<type name="VaDisplay" c:type="GstVaDisplay*"/>
|
||||
</parameter>
|
||||
<parameter name="info" transfer-ownership="none">
|
||||
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c">a #GstVideoInfo</doc>
|
||||
<type name="GstVideo.VideoInfo" c:type="GstVideoInfo*"/>
|
||||
</parameter>
|
||||
<parameter name="drm_info" transfer-ownership="none">
|
||||
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c">a #GstVideoInfoDmaDrm</doc>
|
||||
<type name="GstVideo.VideoInfoDmaDrm" c:type="GstVideoInfoDmaDrm*"/>
|
||||
</parameter>
|
||||
<parameter name="mem" transfer-ownership="none">
|
||||
<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 "vasurfaceimage.h"
|
||||
|
||||
#ifndef DRM_FORMAT_INVALID
|
||||
#define DRM_FORMAT_INVALID 0
|
||||
#endif
|
||||
|
||||
#define GST_CAT_DEFAULT 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:
|
||||
* @display: a #GstVaDisplay
|
||||
* @info: a #GstVideoInfo
|
||||
* @drm_info: a #GstVideoInfoDmaDrm
|
||||
* @mem: (array fixed-size=4) (element-type GstMemory): Memories. One
|
||||
* per plane.
|
||||
* @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 */
|
||||
gboolean
|
||||
gst_va_dmabuf_memories_setup (GstVaDisplay * display, GstVideoInfo * info,
|
||||
GstMemory * mem[GST_VIDEO_MAX_PLANES], uintptr_t fds[GST_VIDEO_MAX_PLANES],
|
||||
gsize offset[GST_VIDEO_MAX_PLANES], guint usage_hint)
|
||||
gst_va_dmabuf_memories_setup (GstVaDisplay * display,
|
||||
GstVideoInfoDmaDrm * drm_info, GstMemory * mem[GST_VIDEO_MAX_PLANES],
|
||||
uintptr_t fds[GST_VIDEO_MAX_PLANES], gsize offset[GST_VIDEO_MAX_PLANES],
|
||||
guint usage_hint)
|
||||
{
|
||||
GstVideoFormat format;
|
||||
GstVaBufferSurface *buf;
|
||||
GstVideoInfo *info = &drm_info->vinfo;
|
||||
/* *INDENT-OFF* */
|
||||
VADRMPRIMESurfaceDescriptor desc = {
|
||||
.width = GST_VIDEO_INFO_WIDTH (info),
|
||||
|
@ -1085,7 +1091,8 @@ gst_va_dmabuf_memories_setup (GstVaDisplay * display, GstVideoInfo * info,
|
|||
};
|
||||
/* *INDENT-ON* */
|
||||
VASurfaceID surface;
|
||||
guint32 fourcc, rt_format;
|
||||
guint32 fourcc, rt_format, drm_fourcc;
|
||||
guint64 drm_modifier;
|
||||
guint i, j, prev, n_planes;
|
||||
gboolean ret;
|
||||
|
||||
|
@ -1093,10 +1100,17 @@ gst_va_dmabuf_memories_setup (GstVaDisplay * display, GstVideoInfo * 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)
|
||||
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);
|
||||
if (rt_format == 0)
|
||||
return FALSE;
|
||||
|
@ -1105,10 +1119,12 @@ gst_va_dmabuf_memories_setup (GstVaDisplay * display, GstVideoInfo * info,
|
|||
if (fourcc == 0)
|
||||
return FALSE;
|
||||
|
||||
drm_modifier = (drm_info->drm_modifier == DRM_FORMAT_MOD_INVALID) ?
|
||||
DRM_FORMAT_MOD_LINEAR : drm_info->drm_modifier;
|
||||
|
||||
desc.fourcc = fourcc;
|
||||
desc.layers[0].num_planes = n_planes;
|
||||
/* FIXME: use GstVideoInfoDmaDrm */
|
||||
desc.layers[0].drm_format = gst_va_drm_fourcc_from_video_format (format);
|
||||
desc.layers[0].drm_format = drm_fourcc;
|
||||
|
||||
for (i = j = 0; i < n_planes; 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].size = _get_fd_size (fds[i]);
|
||||
/* FIXME: use GstVideoInfoDmaDrm */
|
||||
desc.objects[j].drm_format_modifier = DRM_FORMAT_MOD_LINEAR;
|
||||
desc.objects[j].drm_format_modifier = drm_modifier;
|
||||
|
||||
desc.layers[0].object_index[i] = j;
|
||||
j++;
|
||||
|
|
|
@ -58,7 +58,7 @@ gboolean gst_va_dmabuf_allocator_get_format (GstAllocator * alloca
|
|||
|
||||
GST_VA_API
|
||||
gboolean gst_va_dmabuf_memories_setup (GstVaDisplay * display,
|
||||
GstVideoInfo * info,
|
||||
GstVideoInfoDmaDrm * drm_info,
|
||||
GstMemory * mem[GST_VIDEO_MAX_PLANES],
|
||||
uintptr_t fds[GST_VIDEO_MAX_PLANES],
|
||||
gsize offset[GST_VIDEO_MAX_PLANES],
|
||||
|
|
|
@ -40,25 +40,28 @@ _try_import_dmabuf_unlocked (GstVaBufferImporter * importer, GstBuffer * inbuf)
|
|||
{
|
||||
GstVideoMeta *meta;
|
||||
GstVideoInfo in_info = *importer->in_info;
|
||||
GstVideoInfoDmaDrm drm_info;
|
||||
GstMemory *mems[GST_VIDEO_MAX_PLANES];
|
||||
guint i, n_mem, n_planes, usage_hint;
|
||||
gsize offset[GST_VIDEO_MAX_PLANES];
|
||||
uintptr_t fd[GST_VIDEO_MAX_PLANES];
|
||||
gsize plane_size[GST_VIDEO_MAX_PLANES];
|
||||
GstVideoAlignment align = { 0, };
|
||||
|
||||
n_planes = GST_VIDEO_INFO_N_PLANES (&in_info);
|
||||
n_mem = gst_buffer_n_memory (inbuf);
|
||||
meta = gst_buffer_get_video_meta (inbuf);
|
||||
GstVideoFormat format;
|
||||
|
||||
/* This will eliminate most non-dmabuf out there */
|
||||
if (!gst_is_dmabuf_memory (gst_buffer_peek_memory (inbuf, 0)))
|
||||
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 */
|
||||
if (n_mem > n_planes)
|
||||
return FALSE;
|
||||
|
||||
meta = gst_buffer_get_video_meta (inbuf);
|
||||
|
||||
/* Update video info importerd on video meta */
|
||||
if (meta) {
|
||||
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,
|
||||
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 */
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue