mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-18 12:15:19 +00:00
egl: Fix direct dmabuf upload without DMABuf caps feature
The DMAbuf accept function was ensuring the in_dma_info values was valid if the in_caps have change. But the check was bogus since the in_caps was being modified without a pointer change. As a side effect, on the second accept call, the drm_fourcc was reset to 0, which cause the uploader to fallback. Fix this by ensuring we always have a valid dma_frm info directly in the set_caps() function. Also remove the bogus caps changed check and remove any modification to the info structure and always do that inner checks. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5461>
This commit is contained in:
parent
a869760199
commit
e00682a4c0
1 changed files with 21 additions and 38 deletions
|
@ -39,6 +39,9 @@
|
||||||
#if GST_GL_HAVE_DMABUF
|
#if GST_GL_HAVE_DMABUF
|
||||||
#include <gst/allocators/gstdmabuf.h>
|
#include <gst/allocators/gstdmabuf.h>
|
||||||
#include <libdrm/drm_fourcc.h>
|
#include <libdrm/drm_fourcc.h>
|
||||||
|
#else
|
||||||
|
/* to avoid ifdef in _gst_gl_upload_set_caps_unlocked() */
|
||||||
|
#define DRM_FORMAT_MOD_LINEAR 0ULL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if GST_GL_HAVE_VIV_DIRECTVIV
|
#if GST_GL_HAVE_VIV_DIRECTVIV
|
||||||
|
@ -607,7 +610,6 @@ struct DmabufUpload
|
||||||
GstGLTextureTarget target;
|
GstGLTextureTarget target;
|
||||||
GstVideoInfo out_info;
|
GstVideoInfo out_info;
|
||||||
/* only used for pointer comparison */
|
/* only used for pointer comparison */
|
||||||
gpointer in_caps;
|
|
||||||
gpointer out_caps;
|
gpointer out_caps;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1381,44 +1383,23 @@ _dma_buf_upload_accept (gpointer impl, GstBuffer * buffer, GstCaps * in_caps,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If caps changes from the last time, do more check. */
|
if (!gst_caps_features_contains (gst_caps_get_features (in_caps, 0),
|
||||||
if (in_caps != dmabuf->in_caps) {
|
GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY) &&
|
||||||
GstCapsFeatures *filter_features;
|
!gst_caps_features_contains (gst_caps_get_features (in_caps, 0),
|
||||||
|
GST_CAPS_FEATURE_MEMORY_DMABUF)) {
|
||||||
|
GST_DEBUG_OBJECT (dmabuf->upload,
|
||||||
|
"Not a DMABuf or SystemMemory caps %" GST_PTR_FORMAT, in_caps);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
filter_features =
|
if (dmabuf->direct && !gst_egl_image_check_dmabuf_direct_with_dma_drm
|
||||||
gst_caps_features_new (GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY, NULL);
|
(dmabuf->upload->context, in_info_drm, dmabuf->target)) {
|
||||||
if (_filter_caps_with_features (in_caps, filter_features, NULL)) {
|
GST_DEBUG_OBJECT (dmabuf->upload,
|
||||||
in_info_drm->drm_fourcc = gst_video_dma_drm_fourcc_from_format
|
"Direct mode does not support %" GST_FOURCC_FORMAT ":0x%016"
|
||||||
(GST_VIDEO_INFO_FORMAT (in_info));
|
G_GINT64_MODIFIER "x with target: %s",
|
||||||
in_info_drm->drm_modifier = DRM_FORMAT_MOD_LINEAR;
|
GST_FOURCC_ARGS (in_info_drm->drm_fourcc), in_info_drm->drm_modifier,
|
||||||
} else if (!gst_caps_features_contains (gst_caps_get_features (in_caps, 0),
|
gst_gl_texture_target_to_string (dmabuf->target));
|
||||||
GST_CAPS_FEATURE_MEMORY_DMABUF)) {
|
return FALSE;
|
||||||
gst_caps_features_free (filter_features);
|
|
||||||
GST_DEBUG_OBJECT (dmabuf->upload,
|
|
||||||
"Not a dma caps %" GST_PTR_FORMAT, in_caps);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
gst_caps_features_free (filter_features);
|
|
||||||
|
|
||||||
if (in_info_drm->drm_modifier == DRM_FORMAT_MOD_LINEAR) {
|
|
||||||
g_assert (GST_VIDEO_INFO_FORMAT (in_info) != GST_VIDEO_FORMAT_UNKNOWN);
|
|
||||||
g_assert (GST_VIDEO_INFO_FORMAT (in_info) != GST_VIDEO_FORMAT_ENCODED);
|
|
||||||
} else {
|
|
||||||
if (!gst_video_info_dma_drm_to_video_info (in_info_drm, in_info))
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dmabuf->direct && !gst_egl_image_check_dmabuf_direct_with_dma_drm
|
|
||||||
(dmabuf->upload->context, in_info_drm, dmabuf->target)) {
|
|
||||||
GST_DEBUG_OBJECT (dmabuf->upload,
|
|
||||||
"Direct mode does not support %" GST_FOURCC_FORMAT ":0x%016"
|
|
||||||
G_GINT64_MODIFIER "x with target: %s",
|
|
||||||
GST_FOURCC_ARGS (in_info_drm->drm_fourcc), in_info_drm->drm_modifier,
|
|
||||||
gst_gl_texture_target_to_string (dmabuf->target));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
dmabuf->in_caps = in_caps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
n_planes = GST_VIDEO_INFO_N_PLANES (in_info);
|
n_planes = GST_VIDEO_INFO_N_PLANES (in_info);
|
||||||
|
@ -3336,6 +3317,8 @@ _gst_gl_upload_set_caps_unlocked (GstGLUpload * upload, GstCaps * in_caps,
|
||||||
gst_video_info_dma_drm_from_caps (&upload->priv->in_info_drm, in_caps);
|
gst_video_info_dma_drm_from_caps (&upload->priv->in_info_drm, in_caps);
|
||||||
} else {
|
} else {
|
||||||
gst_video_info_from_caps (&upload->priv->in_info, in_caps);
|
gst_video_info_from_caps (&upload->priv->in_info, in_caps);
|
||||||
|
gst_video_info_dma_drm_from_video_info (&upload->priv->in_info_drm,
|
||||||
|
&upload->priv->in_info, DRM_FORMAT_MOD_LINEAR);
|
||||||
}
|
}
|
||||||
gst_video_info_from_caps (&upload->priv->out_info, out_caps);
|
gst_video_info_from_caps (&upload->priv->out_info, out_caps);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue