mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
gl: Remove format info in glcolorconvert's transform_caps function instead of on every caller
... and let glmixer actually transform the caps it is supposed to transform instead of inventing new caps.
This commit is contained in:
parent
86d1280f2c
commit
cb59ace574
5 changed files with 52 additions and 184 deletions
|
@ -785,42 +785,6 @@ gst_glimage_sink_get_times (GstBaseSink * bsink, GstBuffer * buf,
|
|||
}
|
||||
}
|
||||
|
||||
/* copies the given caps */
|
||||
static GstCaps *
|
||||
gst_glimage_sink_caps_remove_format_info (GstCaps * caps)
|
||||
{
|
||||
GstStructure *st;
|
||||
GstCapsFeatures *f;
|
||||
gint i, n;
|
||||
GstCaps *res;
|
||||
|
||||
res = gst_caps_new_empty ();
|
||||
|
||||
n = gst_caps_get_size (caps);
|
||||
for (i = 0; i < n; i++) {
|
||||
st = gst_caps_get_structure (caps, i);
|
||||
f = gst_caps_get_features (caps, i);
|
||||
|
||||
/* If this is already expressed by the existing caps
|
||||
* skip this structure */
|
||||
if (i > 0 && gst_caps_is_subset_structure_full (res, st, f))
|
||||
continue;
|
||||
|
||||
st = gst_structure_copy (st);
|
||||
/* Only remove format info for the cases when we can actually convert */
|
||||
if (!gst_caps_features_is_any (f)
|
||||
&& gst_caps_features_is_equal (f,
|
||||
GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY))
|
||||
gst_structure_remove_fields (st, "format", "colorimetry", "chroma-site",
|
||||
NULL);
|
||||
gst_structure_remove_fields (st, "width", "height", NULL);
|
||||
|
||||
gst_caps_append_structure_full (res, st, gst_caps_features_copy (f));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_glimage_sink_get_caps (GstBaseSink * bsink, GstCaps * filter)
|
||||
{
|
||||
|
@ -830,11 +794,6 @@ gst_glimage_sink_get_caps (GstBaseSink * bsink, GstCaps * filter)
|
|||
|
||||
tmp = gst_caps_from_string ("video/x-raw(memory:GLMemory),format=RGBA");
|
||||
|
||||
result = gst_glimage_sink_caps_remove_format_info (tmp);
|
||||
gst_caps_unref (tmp);
|
||||
tmp = result;
|
||||
GST_DEBUG_OBJECT (bsink, "remove format returned caps %" GST_PTR_FORMAT, tmp);
|
||||
|
||||
result =
|
||||
gst_gl_color_convert_transform_caps (gl_sink->context, GST_PAD_SRC, tmp,
|
||||
NULL);
|
||||
|
|
|
@ -326,60 +326,17 @@ gst_gl_mixer_set_caps_features (const GstCaps * caps,
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* copies the given caps */
|
||||
static GstCaps *
|
||||
gst_gl_mixer_caps_remove_format_info (GstCaps * caps)
|
||||
{
|
||||
GstStructure *st;
|
||||
GstCapsFeatures *f;
|
||||
gint i, n;
|
||||
GstCaps *res;
|
||||
|
||||
res = gst_caps_new_empty ();
|
||||
|
||||
n = gst_caps_get_size (caps);
|
||||
for (i = 0; i < n; i++) {
|
||||
st = gst_caps_get_structure (caps, i);
|
||||
f = gst_caps_get_features (caps, i);
|
||||
|
||||
/* If this is already expressed by the existing caps
|
||||
* skip this structure */
|
||||
if (i > 0 && gst_caps_is_subset_structure_full (res, st, f))
|
||||
continue;
|
||||
|
||||
st = gst_structure_copy (st);
|
||||
/* Only remove format info for the cases when we can actually convert */
|
||||
if (!gst_caps_features_is_any (f)
|
||||
&& gst_caps_features_is_equal (f,
|
||||
GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY))
|
||||
gst_structure_remove_fields (st, "format", "colorimetry", "chroma-site",
|
||||
NULL);
|
||||
gst_structure_remove_fields (st, "width", "height", NULL);
|
||||
|
||||
gst_caps_append_structure_full (res, st, gst_caps_features_copy (f));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GstCaps *
|
||||
gst_gl_mixer_update_caps (GstGLMixer * mix, GstCaps * caps)
|
||||
{
|
||||
GstCaps *result, *tmp, *gl_caps;
|
||||
|
||||
gl_caps = gst_caps_from_string ("video/x-raw(memory:GLMemory),format=RGBA");
|
||||
GstCaps *result, *tmp;
|
||||
|
||||
result =
|
||||
gst_gl_color_convert_transform_caps (mix->context, GST_PAD_SRC, gl_caps,
|
||||
gst_gl_color_convert_transform_caps (mix->context, GST_PAD_SRC, caps,
|
||||
NULL);
|
||||
tmp = result;
|
||||
GST_DEBUG_OBJECT (mix, "convert returned caps %" GST_PTR_FORMAT, tmp);
|
||||
|
||||
result = gst_gl_mixer_caps_remove_format_info (tmp);
|
||||
gst_caps_unref (tmp);
|
||||
tmp = result;
|
||||
GST_DEBUG_OBJECT (mix, "remove format returned caps %" GST_PTR_FORMAT, tmp);
|
||||
|
||||
result = gst_gl_upload_transform_caps (mix->context, GST_PAD_SRC, tmp, NULL);
|
||||
gst_caps_unref (tmp);
|
||||
tmp = result;
|
||||
|
@ -740,10 +697,6 @@ gst_gl_mixer_query_caps (GstPad * pad, GstAggregator * agg, GstQuery * query)
|
|||
NULL);
|
||||
retcaps = gst_caps_merge (gl_caps, retcaps);
|
||||
gst_caps_unref (current_caps);
|
||||
current_caps = retcaps;
|
||||
|
||||
retcaps = gst_gl_mixer_caps_remove_format_info (current_caps);
|
||||
gst_caps_unref (current_caps);
|
||||
|
||||
if (filter) {
|
||||
current_caps =
|
||||
|
|
|
@ -468,42 +468,6 @@ wrong_caps:
|
|||
}
|
||||
}
|
||||
|
||||
/* copies the given caps */
|
||||
static GstCaps *
|
||||
gst_gl_test_src_caps_remove_format_info (GstCaps * caps)
|
||||
{
|
||||
GstStructure *st;
|
||||
GstCapsFeatures *f;
|
||||
gint i, n;
|
||||
GstCaps *res;
|
||||
|
||||
res = gst_caps_new_empty ();
|
||||
|
||||
n = gst_caps_get_size (caps);
|
||||
for (i = 0; i < n; i++) {
|
||||
st = gst_caps_get_structure (caps, i);
|
||||
f = gst_caps_get_features (caps, i);
|
||||
|
||||
/* If this is already expressed by the existing caps
|
||||
* skip this structure */
|
||||
if (i > 0 && gst_caps_is_subset_structure_full (res, st, f))
|
||||
continue;
|
||||
|
||||
st = gst_structure_copy (st);
|
||||
/* Only remove format info for the cases when we can actually convert */
|
||||
if (!gst_caps_features_is_any (f)
|
||||
&& gst_caps_features_is_equal (f,
|
||||
GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY))
|
||||
gst_structure_remove_fields (st, "format", "colorimetry", "chroma-site",
|
||||
NULL);
|
||||
gst_structure_remove_fields (st, "width", "height", NULL);
|
||||
|
||||
gst_caps_append_structure_full (res, st, gst_caps_features_copy (f));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_gl_test_src_set_caps_features (const GstCaps * caps,
|
||||
const gchar * feature_name)
|
||||
|
@ -517,32 +481,26 @@ static GstCaps *
|
|||
gst_gl_test_src_getcaps (GstBaseSrc * bsrc, GstCaps * filter)
|
||||
{
|
||||
GstGLTestSrc *src = GST_GL_TEST_SRC (bsrc);
|
||||
GstCaps *tmp = NULL;
|
||||
GstCaps *tmp;
|
||||
GstCaps *result = NULL;
|
||||
GstCaps *gl_caps;
|
||||
GstCaps *caps =
|
||||
gst_caps_from_string ("video/x-raw(memory:GLMemory),format=RGBA");
|
||||
|
||||
tmp = gst_gl_test_src_caps_remove_format_info (caps);
|
||||
GST_DEBUG_OBJECT (bsrc, "remove format returned caps %" GST_PTR_FORMAT, tmp);
|
||||
|
||||
gl_caps =
|
||||
gst_caps_merge (gst_gl_test_src_set_caps_features (tmp,
|
||||
gst_caps_merge (gst_gl_test_src_set_caps_features (caps,
|
||||
GST_CAPS_FEATURE_MEMORY_GL_MEMORY),
|
||||
gst_gl_test_src_set_caps_features (tmp,
|
||||
gst_gl_test_src_set_caps_features (caps,
|
||||
GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META));
|
||||
result =
|
||||
gst_gl_download_transform_caps (src->context, GST_PAD_SINK, tmp, NULL);
|
||||
gst_gl_download_transform_caps (src->context, GST_PAD_SINK, caps, NULL);
|
||||
result = gst_caps_merge (gl_caps, result);
|
||||
|
||||
gst_caps_unref (tmp);
|
||||
tmp = result;
|
||||
GST_DEBUG_OBJECT (bsrc, "transfer returned caps %" GST_PTR_FORMAT, tmp);
|
||||
GST_DEBUG_OBJECT (bsrc, "transfer returned caps %" GST_PTR_FORMAT, result);
|
||||
|
||||
if (filter) {
|
||||
result = gst_caps_intersect_full (filter, tmp, GST_CAPS_INTERSECT_FIRST);
|
||||
gst_caps_unref (tmp);
|
||||
} else {
|
||||
tmp = gst_caps_intersect_full (filter, result, GST_CAPS_INTERSECT_FIRST);
|
||||
gst_caps_unref (result);
|
||||
result = tmp;
|
||||
}
|
||||
|
||||
|
|
|
@ -634,6 +634,39 @@ gst_gl_color_convert_set_caps (GstGLColorConvert * convert,
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* copies the given caps */
|
||||
static GstCaps *
|
||||
gst_gl_color_convert_caps_remove_format_info (GstCaps * caps)
|
||||
{
|
||||
GstStructure *st;
|
||||
GstCapsFeatures *f;
|
||||
gint i, n;
|
||||
GstCaps *res;
|
||||
|
||||
res = gst_caps_new_empty ();
|
||||
|
||||
n = gst_caps_get_size (caps);
|
||||
for (i = 0; i < n; i++) {
|
||||
st = gst_caps_get_structure (caps, i);
|
||||
f = gst_caps_get_features (caps, i);
|
||||
|
||||
/* If this is already expressed by the existing caps
|
||||
* skip this structure */
|
||||
if (i > 0 && gst_caps_is_subset_structure_full (res, st, f))
|
||||
continue;
|
||||
|
||||
st = gst_structure_copy (st);
|
||||
gst_structure_remove_fields (st, "format", "colorimetry", "chroma-site",
|
||||
NULL);
|
||||
gst_structure_remove_fields (st, "width", "height", NULL);
|
||||
|
||||
gst_caps_append_structure_full (res, st,
|
||||
gst_caps_features_new (GST_CAPS_FEATURE_MEMORY_GL_MEMORY, NULL));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GstCaps *
|
||||
gst_gl_color_convert_transform_caps (GstGLContext * convert,
|
||||
GstPadDirection direction, GstCaps * caps, GstCaps * filter)
|
||||
|
@ -644,11 +677,17 @@ gst_gl_color_convert_transform_caps (GstGLContext * convert,
|
|||
gst_caps_from_string (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
|
||||
(GST_CAPS_FEATURE_MEMORY_GL_MEMORY, GST_GL_COLOR_CONVERT_FORMATS));
|
||||
|
||||
if (filter) {
|
||||
result = gst_caps_intersect_full (filter, templ, GST_CAPS_INTERSECT_FIRST);
|
||||
caps = gst_gl_color_convert_caps_remove_format_info (caps);
|
||||
result = gst_caps_intersect (caps, templ);
|
||||
gst_caps_unref (caps);
|
||||
gst_caps_unref (templ);
|
||||
} else {
|
||||
result = templ;
|
||||
|
||||
if (filter) {
|
||||
GstCaps *tmp;
|
||||
|
||||
tmp = gst_caps_intersect_full (filter, result, GST_CAPS_INTERSECT_FIRST);
|
||||
gst_caps_unref (result);
|
||||
result = tmp;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -715,42 +715,6 @@ gst_gl_filter_set_caps_features (const GstCaps * caps,
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* copies the given caps */
|
||||
static GstCaps *
|
||||
gst_gl_filter_caps_remove_format_info (GstCaps * caps)
|
||||
{
|
||||
GstStructure *st;
|
||||
GstCapsFeatures *f;
|
||||
gint i, n;
|
||||
GstCaps *res;
|
||||
|
||||
res = gst_caps_new_empty ();
|
||||
|
||||
n = gst_caps_get_size (caps);
|
||||
for (i = 0; i < n; i++) {
|
||||
st = gst_caps_get_structure (caps, i);
|
||||
f = gst_caps_get_features (caps, i);
|
||||
|
||||
/* If this is already expressed by the existing caps
|
||||
* skip this structure */
|
||||
if (i > 0 && gst_caps_is_subset_structure_full (res, st, f))
|
||||
continue;
|
||||
|
||||
st = gst_structure_copy (st);
|
||||
/* Only remove format info for the cases when we can actually convert */
|
||||
if (!gst_caps_features_is_any (f)
|
||||
&& gst_caps_features_is_equal (f,
|
||||
GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY))
|
||||
gst_structure_remove_fields (st, "format", "colorimetry", "chroma-site",
|
||||
NULL);
|
||||
gst_structure_remove_fields (st, "width", "height", NULL);
|
||||
|
||||
gst_caps_append_structure_full (res, st, gst_caps_features_copy (f));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_gl_filter_transform_caps (GstBaseTransform * bt,
|
||||
GstPadDirection direction, GstCaps * caps, GstCaps * filter_caps)
|
||||
|
@ -789,11 +753,6 @@ gst_gl_filter_transform_caps (GstBaseTransform * bt,
|
|||
tmp = result;
|
||||
GST_DEBUG_OBJECT (bt, "transfer returned caps %" GST_PTR_FORMAT, tmp);
|
||||
|
||||
result = gst_gl_filter_caps_remove_format_info (tmp);
|
||||
gst_caps_unref (tmp);
|
||||
tmp = result;
|
||||
GST_DEBUG_OBJECT (bt, "remove format returned caps %" GST_PTR_FORMAT, tmp);
|
||||
|
||||
if (direction == GST_PAD_SRC) {
|
||||
result =
|
||||
gst_gl_color_convert_transform_caps (filter->context, direction, tmp,
|
||||
|
|
Loading…
Reference in a new issue