glupload: make nvmm upload manner only consider system memory

The current _nvmm_upload_transform_caps() only simply apply
"memory:NVMM" to all input caps to transform the output caps.
This is not precise and may cause problem. For example, if the
input caps include:

  video/x-raw(memory:DMABuf), width=(int)1920, height=(int)1080, \
  interlace-mode=(string)progressive, multiview-mode=(string)mono, \
  framerate=(fraction)30/1, drm-format=(string)NV12:0x0100000000000002

it will be changed as

  video/x-raw(memory:GLMemory), width=(int)1920, height=(int)1080, \
  interlace-mode=(string)progressive, multiview-mode=(string)mono, \
  framerate=(fraction)30/1, drm-format=(string)NV12:0x0100000000000002

For GLMemory kind caps, no drm-format should appear.

So we should let it only transforms which it can recognize.

And in _nvmm_upload_accept(), we should only accept the "memory:NVMM"
feature in input caps.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3524>
This commit is contained in:
He Junyan 2023-05-25 14:27:57 +08:00 committed by GStreamer Marge Bot
parent 122ffa56ed
commit 094270322b

View file

@ -2658,13 +2658,22 @@ _nvmm_upload_transform_caps (gpointer impl, GstGLContext * context,
if (direction == GST_PAD_SINK) { if (direction == GST_PAD_SINK) {
GstCaps *tmp; GstCaps *tmp;
GstCapsFeatures *filter_features;
ret = filter_features =
_set_caps_features_with_passthrough (caps, gst_caps_features_from_string (GST_CAPS_FEATURE_MEMORY_NVMM);
if (!_filter_caps_with_features (caps, filter_features, &tmp)) {
gst_caps_features_free (filter_features);
gst_caps_features_free (passthrough);
return NULL;
}
gst_caps_features_free (filter_features);
ret = _set_caps_features_with_passthrough (tmp,
GST_CAPS_FEATURE_MEMORY_GL_MEMORY, passthrough); GST_CAPS_FEATURE_MEMORY_GL_MEMORY, passthrough);
gst_caps_unref (tmp);
tmp = tmp = _caps_intersect_texture_target (ret,
_caps_intersect_texture_target (ret,
1 << GST_GL_TEXTURE_TARGET_EXTERNAL_OES); 1 << GST_GL_TEXTURE_TARGET_EXTERNAL_OES);
gst_caps_unref (ret); gst_caps_unref (ret);
ret = tmp; ret = tmp;
@ -2700,6 +2709,7 @@ _nvmm_upload_accept (gpointer impl, GstBuffer * buffer, GstCaps * in_caps,
GstVideoInfo *out_info = &nvmm->out_info; GstVideoInfo *out_info = &nvmm->out_info;
GstVideoMeta *meta; GstVideoMeta *meta;
GstMapInfo in_map_info = GST_MAP_INFO_INIT; GstMapInfo in_map_info = GST_MAP_INFO_INIT;
GstCapsFeatures *features;
guint n_mem; guint n_mem;
guint i; guint i;
@ -2724,6 +2734,10 @@ _nvmm_upload_accept (gpointer impl, GstBuffer * buffer, GstCaps * in_caps,
"EGL_KHR_image_base")) "EGL_KHR_image_base"))
return FALSE; return FALSE;
features = gst_caps_get_features (in_caps, 0);
if (!gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_NVMM))
return FALSE;
if (!gst_buffer_map (buffer, &in_map_info, GST_MAP_READ)) { if (!gst_buffer_map (buffer, &in_map_info, GST_MAP_READ)) {
GST_DEBUG_OBJECT (nvmm->upload, "Failed to map readonly NvBuffer"); GST_DEBUG_OBJECT (nvmm->upload, "Failed to map readonly NvBuffer");
return FALSE; return FALSE;