1 From 67d11594e693b60797c2bae1bcfa4e8bafcf4c9a Mon Sep 17 00:00:00 2001
2 From: Haihua Hu <b55597@freescale.com>
3 Date: Thu, 25 Feb 2016 13:53:20 +0800
4 Subject: [PATCH 17/18] glcolorconvert: convert YUV to RGB use directviv
6 Add a property "disable_passthrough" in glcolorconvert for enable/disable passthrough.
7 When need convert YUV to RGB with directviv, set it to be TRUE.
9 Upstream-Status: Inappropriate [i.MX specific]
11 Signed-off-by: Haihua Hu <b55597@freescale.com>
14 gst-libs/gst/gl/gstglcolorconvert.c
16 Signed-off-by: Lyon Wang <lyon.wang@freescale.com>
18 ext/gl/gstglcolorconvertelement.c | 70 +++++++++++++++++++++++++++++++++++++
19 ext/gl/gstglcolorconvertelement.h | 1 +
20 gst-libs/gst/gl/gstglcolorconvert.c | 6 +++-
21 3 files changed, 76 insertions(+), 1 deletion(-)
23 diff --git a/ext/gl/gstglcolorconvertelement.c b/ext/gl/gstglcolorconvertelement.c
24 index bd4fbeb..9108b0a 100644
25 --- a/ext/gl/gstglcolorconvertelement.c
26 +++ b/ext/gl/gstglcolorconvertelement.c
27 @@ -35,6 +35,14 @@ G_DEFINE_TYPE_WITH_CODE (GstGLColorConvertElement, gst_gl_color_convert_element,
28 "glconvertelement", 0, "convert");
33 + GL_COLOR_CONVERT_PROP_0,
34 + GL_COLOR_CONVERT_PROP_DISABLE_PASSTHROUGH
37 +#define DISABLE_PASSTHROUGH_DAFAULT FALSE
39 static gboolean gst_gl_color_convert_element_set_caps (GstBaseTransform * bt,
40 GstCaps * in_caps, GstCaps * out_caps);
41 static GstCaps *gst_gl_color_convert_element_transform_caps (GstBaseTransform *
42 @@ -54,6 +62,15 @@ static GstFlowReturn gst_gl_color_convert_element_transform (GstBaseTransform *
43 static GstCaps *gst_gl_color_convert_element_fixate_caps (GstBaseTransform *
44 bt, GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
46 +static void gst_gl_color_convert_set_property (GObject *object,
48 + const GValue *value,
50 +static void gst_gl_color_convert_get_property (GObject *object,
55 static GstStaticPadTemplate gst_gl_color_convert_element_src_pad_template =
56 GST_STATIC_PAD_TEMPLATE ("src",
58 @@ -89,6 +106,10 @@ gst_gl_color_convert_element_class_init (GstGLColorConvertElementClass * klass)
60 GstBaseTransformClass *bt_class = GST_BASE_TRANSFORM_CLASS (klass);
61 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
62 + GObjectClass *object_class = G_OBJECT_CLASS (klass);
64 + object_class->set_property = gst_gl_color_convert_set_property;
65 + object_class->get_property = gst_gl_color_convert_get_property;
67 bt_class->transform_caps = gst_gl_color_convert_element_transform_caps;
68 bt_class->set_caps = gst_gl_color_convert_element_set_caps;
69 @@ -110,6 +131,13 @@ gst_gl_color_convert_element_class_init (GstGLColorConvertElementClass * klass)
70 gst_static_pad_template_get
71 (&gst_gl_color_convert_element_sink_pad_template));
73 + g_object_class_install_property (object_class, GL_COLOR_CONVERT_PROP_DISABLE_PASSTHROUGH,
74 + g_param_spec_boolean ("disable_passthrough",
75 + "Disable passthrough",
76 + "Disable passthrough mode",
77 + DISABLE_PASSTHROUGH_DAFAULT,
78 + G_PARAM_READWRITE));
80 gst_element_class_set_metadata (element_class,
81 "OpenGL color converter", "Filter/Converter/Video",
82 "Converts between color spaces using OpenGL shaders",
83 @@ -121,6 +149,41 @@ gst_gl_color_convert_element_init (GstGLColorConvertElement * convert)
85 gst_base_transform_set_prefer_passthrough (GST_BASE_TRANSFORM (convert),
87 + convert->disable_passthrough = FALSE;
91 +gst_gl_color_convert_set_property (GObject *object,
93 + const GValue *value,
96 + GstGLColorConvertElement *convert = GST_GL_COLOR_CONVERT_ELEMENT (object);
98 + case GL_COLOR_CONVERT_PROP_DISABLE_PASSTHROUGH:
99 + convert->disable_passthrough = g_value_get_boolean (value);
102 + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
108 +gst_gl_color_convert_get_property (GObject *object,
113 + GstGLColorConvertElement *convert = GST_GL_COLOR_CONVERT_ELEMENT (object);
115 + case GL_COLOR_CONVERT_PROP_DISABLE_PASSTHROUGH:
116 + g_value_set_boolean (value, convert->disable_passthrough);
119 + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
125 @@ -135,6 +198,13 @@ gst_gl_color_convert_element_set_caps (GstBaseTransform * bt,
126 if (convert->convert)
127 gst_gl_color_convert_set_caps (convert->convert, in_caps, out_caps);
129 + if(gst_base_transform_is_passthrough (bt) && convert->disable_passthrough){
130 + /* if in passthrough mode and disable_passthrough is set to true,
131 + * set passthrough to FALSE*/
132 + GST_DEBUG_OBJECT(convert, "Disable passthrough mode");
133 + gst_base_transform_set_passthrough(bt, FALSE);
139 diff --git a/ext/gl/gstglcolorconvertelement.h b/ext/gl/gstglcolorconvertelement.h
140 index 2a0dd1d..5cdbd3a 100644
141 --- a/ext/gl/gstglcolorconvertelement.h
142 +++ b/ext/gl/gstglcolorconvertelement.h
143 @@ -47,6 +47,7 @@ struct _GstGLColorConvertElement
144 GstGLColorConvert *convert;
147 + gboolean disable_passthrough;
150 struct _GstGLColorConvertElementClass
151 diff --git a/gst-libs/gst/gl/gstglcolorconvert.c b/gst-libs/gst/gl/gstglcolorconvert.c
152 index eb3b4a8..4ed947e 100644
153 --- a/gst-libs/gst/gl/gstglcolorconvert.c
154 +++ b/gst-libs/gst/gl/gstglcolorconvert.c
155 @@ -700,7 +700,11 @@ _gst_gl_color_convert_set_caps_unlocked (GstGLColorConvert * convert,
156 convert->priv->to_texture_target = to_target;
157 convert->initted = FALSE;
159 - convert->passthrough = passthrough;
160 + /* We may disable passthrough via an external property
161 + * By the way, when glconvertelement is in passthrough mode,
162 + * the plugin will not call gst_gl_color_convert_perform().*/
164 + //convert->passthrough = passthrough;
165 #ifndef GST_DISABLE_GST_DEBUG
166 if (G_UNLIKELY (convert->passthrough))
167 GST_DEBUG_OBJECT (convert,