gl: Implement basetransform meta transform function
This makes sure we can pass through more metas correctly, e.g. GstVideoOverlayComposition meta. Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4422 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9004>
This commit is contained in:
parent
1c3bc57d00
commit
6072e54666
@ -390,6 +390,32 @@ gst_gl_color_balance_before_transform (GstBaseTransform * base, GstBuffer * buf)
|
||||
gst_object_sync_values (GST_OBJECT (balance), stream_time);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_color_balance_transform_meta (GstBaseTransform * bt,
|
||||
GstBuffer * outbuf, GstMeta * meta, GstBuffer * inbuf)
|
||||
{
|
||||
const GstMetaInfo *info = meta->info;
|
||||
gboolean should_copy = TRUE;
|
||||
const gchar *valid_tags[] = {
|
||||
GST_META_TAG_VIDEO_STR,
|
||||
GST_META_TAG_VIDEO_ORIENTATION_STR,
|
||||
GST_META_TAG_VIDEO_SIZE_STR,
|
||||
GST_META_TAG_VIDEO_COLORSPACE_STR,
|
||||
NULL
|
||||
};
|
||||
|
||||
should_copy = gst_meta_api_type_tags_contain_only (info->api, valid_tags);
|
||||
|
||||
/* Can't handle the tags in this meta, let the parent class handle it */
|
||||
if (!should_copy) {
|
||||
return GST_BASE_TRANSFORM_CLASS (parent_class)->transform_meta (bt,
|
||||
outbuf, meta, inbuf);
|
||||
}
|
||||
|
||||
/* No need to transform, we can safely copy this meta */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_color_balance_filter_texture (GstGLFilter * filter, GstGLMemory * in_tex,
|
||||
GstGLMemory * out_tex)
|
||||
@ -481,6 +507,7 @@ gst_gl_color_balance_class_init (GstGLColorBalanceClass * klass)
|
||||
trans_class->before_transform =
|
||||
GST_DEBUG_FUNCPTR (gst_gl_color_balance_before_transform);
|
||||
trans_class->transform_ip_on_passthrough = FALSE;
|
||||
trans_class->transform_meta = gst_gl_color_balance_transform_meta;
|
||||
|
||||
base_filter_class->gl_start =
|
||||
GST_DEBUG_FUNCPTR (gst_gl_color_balance_gl_start);
|
||||
|
@ -57,6 +57,9 @@ static GstFlowReturn gst_gl_color_convert_element_transform (GstBaseTransform *
|
||||
bt, GstBuffer * inbuf, GstBuffer * outbuf);
|
||||
static GstCaps *gst_gl_color_convert_element_fixate_caps (GstBaseTransform * bt,
|
||||
GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
|
||||
static gboolean
|
||||
gst_gl_color_convert_transform_meta (GstBaseTransform * bt,
|
||||
GstBuffer * outbuf, GstMeta * meta, GstBuffer * inbuf);
|
||||
static GstStateChangeReturn
|
||||
gst_gl_color_convert_element_change_state (GstElement * element,
|
||||
GstStateChange transition);
|
||||
@ -101,6 +104,7 @@ gst_gl_color_convert_element_class_init (GstGLColorConvertElementClass * klass)
|
||||
gst_gl_color_convert_element_prepare_output_buffer;
|
||||
bt_class->transform = gst_gl_color_convert_element_transform;
|
||||
bt_class->fixate_caps = gst_gl_color_convert_element_fixate_caps;
|
||||
bt_class->transform_meta = gst_gl_color_convert_transform_meta;
|
||||
|
||||
bt_class->passthrough_on_same_caps = TRUE;
|
||||
|
||||
@ -246,6 +250,31 @@ gst_gl_color_convert_element_transform (GstBaseTransform * bt,
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_color_convert_transform_meta (GstBaseTransform * bt,
|
||||
GstBuffer * outbuf, GstMeta * meta, GstBuffer * inbuf)
|
||||
{
|
||||
const GstMetaInfo *info = meta->info;
|
||||
gboolean should_copy = TRUE;
|
||||
const gchar *valid_tags[] = {
|
||||
GST_META_TAG_VIDEO_STR,
|
||||
GST_META_TAG_VIDEO_ORIENTATION_STR,
|
||||
GST_META_TAG_VIDEO_SIZE_STR,
|
||||
NULL
|
||||
};
|
||||
|
||||
should_copy = gst_meta_api_type_tags_contain_only (info->api, valid_tags);
|
||||
|
||||
/* Cant handle the tags in this meta, let the parent class handle it */
|
||||
if (!should_copy) {
|
||||
return GST_BASE_TRANSFORM_CLASS (parent_class)->transform_meta (bt,
|
||||
outbuf, meta, inbuf);
|
||||
}
|
||||
|
||||
/* No need to transform, we can safely copy this meta */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_gl_color_convert_element_fixate_caps (GstBaseTransform *
|
||||
bt, GstPadDirection direction, GstCaps * caps, GstCaps * othercaps)
|
||||
|
@ -75,6 +75,13 @@ static void gst_gl_colorscale_gl_stop (GstGLBaseFilter * base_filter);
|
||||
static gboolean gst_gl_colorscale_filter_texture (GstGLFilter * filter,
|
||||
GstGLMemory * in_tex, GstGLMemory * out_tex);
|
||||
|
||||
static gboolean
|
||||
gst_gl_colorscale_transform_meta (GstBaseTransform * trans,
|
||||
GstBuffer * outbuf, GstMeta * meta, GstBuffer * inbuf);
|
||||
|
||||
static GQuark _size_quark;
|
||||
static GQuark _scale_quark;
|
||||
|
||||
static void
|
||||
gst_gl_colorscale_class_init (GstGLColorscaleClass * klass)
|
||||
{
|
||||
@ -90,6 +97,9 @@ gst_gl_colorscale_class_init (GstGLColorscaleClass * klass)
|
||||
base_filter_class = GST_GL_BASE_FILTER_CLASS (klass);
|
||||
filter_class = GST_GL_FILTER_CLASS (klass);
|
||||
|
||||
_size_quark = g_quark_from_static_string (GST_META_TAG_VIDEO_SIZE_STR);
|
||||
_scale_quark = gst_video_meta_transform_scale_get_quark ();
|
||||
|
||||
gst_gl_filter_add_rgba_pad_templates (GST_GL_FILTER_CLASS (klass));
|
||||
|
||||
gobject_class->set_property = gst_gl_colorscale_set_property;
|
||||
@ -101,6 +111,8 @@ gst_gl_colorscale_class_init (GstGLColorscaleClass * klass)
|
||||
"Matthew Waters <matthew@centricular.com>");
|
||||
|
||||
basetransform_class->passthrough_on_same_caps = TRUE;
|
||||
basetransform_class->transform_meta =
|
||||
GST_DEBUG_FUNCPTR (gst_gl_colorscale_transform_meta);
|
||||
|
||||
base_filter_class->gl_start = GST_DEBUG_FUNCPTR (gst_gl_colorscale_gl_start);
|
||||
base_filter_class->gl_stop = GST_DEBUG_FUNCPTR (gst_gl_colorscale_gl_stop);
|
||||
@ -187,3 +199,40 @@ gst_gl_colorscale_filter_texture (GstGLFilter * filter, GstGLMemory * in_tex,
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_colorscale_transform_meta (GstBaseTransform * trans,
|
||||
GstBuffer * outbuf, GstMeta * meta, GstBuffer * inbuf)
|
||||
{
|
||||
GstGLColorscale *colorscale = GST_GL_COLORSCALE (trans);
|
||||
const GstMetaInfo *info = meta->info;
|
||||
gboolean should_copy = TRUE;
|
||||
const gchar *valid_tags[] = {
|
||||
GST_META_TAG_VIDEO_STR,
|
||||
GST_META_TAG_VIDEO_ORIENTATION_STR,
|
||||
GST_META_TAG_VIDEO_SIZE_STR,
|
||||
GST_META_TAG_VIDEO_COLORSPACE_STR,
|
||||
NULL
|
||||
};
|
||||
|
||||
should_copy = gst_meta_api_type_tags_contain_only (info->api, valid_tags);
|
||||
|
||||
/* Cant handle the tags in this meta, let the parent class handle it */
|
||||
if (!should_copy) {
|
||||
return GST_BASE_TRANSFORM_CLASS (parent_class)->transform_meta (trans,
|
||||
outbuf, meta, inbuf);
|
||||
}
|
||||
|
||||
/* This meta is size sensitive, try to transform it accordingly */
|
||||
if (gst_meta_api_type_has_tag (info->api, _size_quark)) {
|
||||
GstVideoMetaTransform trans =
|
||||
{ &colorscale->filter.in_info, &colorscale->filter.out_info };
|
||||
|
||||
if (info->transform_func)
|
||||
info->transform_func (outbuf, meta, inbuf, _scale_quark, &trans);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* No need to transform, we can safely copy this meta */
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1458,13 +1458,31 @@ static gboolean
|
||||
gst_gl_download_element_transform_meta (GstBaseTransform * bt,
|
||||
GstBuffer * outbuf, GstMeta * meta, GstBuffer * inbuf)
|
||||
{
|
||||
const GstMetaInfo *info = meta->info;
|
||||
gboolean should_copy = TRUE;
|
||||
const gchar *valid_tags[] = {
|
||||
GST_META_TAG_VIDEO_STR,
|
||||
GST_META_TAG_VIDEO_ORIENTATION_STR,
|
||||
GST_META_TAG_VIDEO_SIZE_STR,
|
||||
GST_META_TAG_VIDEO_COLORSPACE_STR,
|
||||
NULL
|
||||
};
|
||||
|
||||
if (g_type_is_a (meta->info->api, GST_GL_SYNC_META_API_TYPE)) {
|
||||
GST_LOG_OBJECT (bt, "not copying GstGLSyncMeta onto output buffer");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return GST_BASE_TRANSFORM_CLASS (parent_class)->transform_meta (bt, outbuf,
|
||||
meta, inbuf);
|
||||
should_copy = gst_meta_api_type_tags_contain_only (info->api, valid_tags);
|
||||
|
||||
/* Cant handle the tags in this meta, let the parent class handle it */
|
||||
if (!should_copy) {
|
||||
return GST_BASE_TRANSFORM_CLASS (parent_class)->transform_meta (bt,
|
||||
outbuf, meta, inbuf);
|
||||
}
|
||||
|
||||
/* No need to transform, we can safely copy this meta */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -60,6 +60,9 @@ static GstFlowReturn gst_gl_upload_element_transform (GstBaseTransform * bt,
|
||||
static gboolean gst_gl_upload_element_stop (GstBaseTransform * bt);
|
||||
static GstCaps *gst_gl_upload_element_fixate_caps (GstBaseTransform * bt,
|
||||
GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
|
||||
static gboolean
|
||||
gst_gl_upload_element_transform_meta (GstBaseTransform * bt,
|
||||
GstBuffer * outbuf, GstMeta * meta, GstBuffer * inbuf);
|
||||
static GstStateChangeReturn
|
||||
gst_gl_upload_element_change_state (GstElement * element,
|
||||
GstStateChange transition);
|
||||
@ -112,6 +115,7 @@ gst_gl_upload_element_class_init (GstGLUploadElementClass * klass)
|
||||
bt_class->transform = gst_gl_upload_element_transform;
|
||||
bt_class->stop = gst_gl_upload_element_stop;
|
||||
bt_class->fixate_caps = gst_gl_upload_element_fixate_caps;
|
||||
bt_class->transform_meta = gst_gl_upload_element_transform_meta;
|
||||
|
||||
element_class->change_state = gst_gl_upload_element_change_state;
|
||||
|
||||
@ -333,6 +337,32 @@ gst_gl_upload_element_transform (GstBaseTransform * bt, GstBuffer * buffer,
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_upload_element_transform_meta (GstBaseTransform * bt,
|
||||
GstBuffer * outbuf, GstMeta * meta, GstBuffer * inbuf)
|
||||
{
|
||||
const GstMetaInfo *info = meta->info;
|
||||
gboolean should_copy = TRUE;
|
||||
const gchar *valid_tags[] = {
|
||||
GST_META_TAG_VIDEO_STR,
|
||||
GST_META_TAG_VIDEO_ORIENTATION_STR,
|
||||
GST_META_TAG_VIDEO_SIZE_STR,
|
||||
GST_META_TAG_VIDEO_COLORSPACE_STR,
|
||||
NULL
|
||||
};
|
||||
|
||||
should_copy = gst_meta_api_type_tags_contain_only (info->api, valid_tags);
|
||||
|
||||
/* Can't handle the tags in this meta, let the parent class handle it */
|
||||
if (!should_copy) {
|
||||
return GST_BASE_TRANSFORM_CLASS (parent_class)->transform_meta (bt,
|
||||
outbuf, meta, inbuf);
|
||||
}
|
||||
|
||||
/* No need to transform, we can safely copy this meta */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_gl_upload_element_fixate_caps (GstBaseTransform * bt,
|
||||
GstPadDirection direction, GstCaps * caps, GstCaps * othercaps)
|
||||
|
Loading…
x
Reference in New Issue
Block a user