1 From 64718397e93087ffe37ad3209535ef84e15854aa 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 16/26] 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 ext/gl/gstglcolorconvertelement.c | 70 +++++++++++++++++++++++++++++++++++++
17 ext/gl/gstglcolorconvertelement.h | 1 +
18 gst-libs/gst/gl/gstglcolorconvert.c | 6 +++-
19 3 files changed, 76 insertions(+), 1 deletion(-)
21 diff --git a/ext/gl/gstglcolorconvertelement.c b/ext/gl/gstglcolorconvertelement.c
22 index 642b494..5e26f84 100644
23 --- a/ext/gl/gstglcolorconvertelement.c
24 +++ b/ext/gl/gstglcolorconvertelement.c
25 @@ -35,6 +35,14 @@ G_DEFINE_TYPE_WITH_CODE (GstGLColorConvertElement, gst_gl_color_convert_element,
26 "glconvertelement", 0, "convert");
31 + GL_COLOR_CONVERT_PROP_0,
32 + GL_COLOR_CONVERT_PROP_DISABLE_PASSTHROUGH
35 +#define DISABLE_PASSTHROUGH_DAFAULT FALSE
37 static gboolean gst_gl_color_convert_element_set_caps (GstBaseTransform * bt,
38 GstCaps * in_caps, GstCaps * out_caps);
39 static GstCaps *gst_gl_color_convert_element_transform_caps (GstBaseTransform *
40 @@ -54,6 +62,15 @@ static GstFlowReturn gst_gl_color_convert_element_transform (GstBaseTransform *
41 static GstCaps *gst_gl_color_convert_element_fixate_caps (GstBaseTransform *
42 bt, GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
44 +static void gst_gl_color_convert_set_property (GObject *object,
46 + const GValue *value,
48 +static void gst_gl_color_convert_get_property (GObject *object,
53 static GstStaticPadTemplate gst_gl_color_convert_element_src_pad_template =
54 GST_STATIC_PAD_TEMPLATE ("src",
56 @@ -89,6 +106,10 @@ gst_gl_color_convert_element_class_init (GstGLColorConvertElementClass * klass)
58 GstBaseTransformClass *bt_class = GST_BASE_TRANSFORM_CLASS (klass);
59 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
60 + GObjectClass *object_class = G_OBJECT_CLASS (klass);
62 + object_class->set_property = gst_gl_color_convert_set_property;
63 + object_class->get_property = gst_gl_color_convert_get_property;
65 bt_class->transform_caps = gst_gl_color_convert_element_transform_caps;
66 bt_class->set_caps = gst_gl_color_convert_element_set_caps;
67 @@ -108,6 +129,13 @@ gst_gl_color_convert_element_class_init (GstGLColorConvertElementClass * klass)
68 gst_element_class_add_static_pad_template (element_class,
69 &gst_gl_color_convert_element_sink_pad_template);
71 + g_object_class_install_property (object_class, GL_COLOR_CONVERT_PROP_DISABLE_PASSTHROUGH,
72 + g_param_spec_boolean ("disable_passthrough",
73 + "Disable passthrough",
74 + "Disable passthrough mode",
75 + DISABLE_PASSTHROUGH_DAFAULT,
76 + G_PARAM_READWRITE));
78 gst_element_class_set_metadata (element_class,
79 "OpenGL color converter", "Filter/Converter/Video",
80 "Converts between color spaces using OpenGL shaders",
81 @@ -119,6 +147,41 @@ gst_gl_color_convert_element_init (GstGLColorConvertElement * convert)
83 gst_base_transform_set_prefer_passthrough (GST_BASE_TRANSFORM (convert),
85 + convert->disable_passthrough = FALSE;
89 +gst_gl_color_convert_set_property (GObject *object,
91 + const GValue *value,
94 + GstGLColorConvertElement *convert = GST_GL_COLOR_CONVERT_ELEMENT (object);
96 + case GL_COLOR_CONVERT_PROP_DISABLE_PASSTHROUGH:
97 + convert->disable_passthrough = g_value_get_boolean (value);
100 + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
106 +gst_gl_color_convert_get_property (GObject *object,
111 + GstGLColorConvertElement *convert = GST_GL_COLOR_CONVERT_ELEMENT (object);
113 + case GL_COLOR_CONVERT_PROP_DISABLE_PASSTHROUGH:
114 + g_value_set_boolean (value, convert->disable_passthrough);
117 + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
123 @@ -133,6 +196,13 @@ gst_gl_color_convert_element_set_caps (GstBaseTransform * bt,
124 if (convert->convert)
125 gst_gl_color_convert_set_caps (convert->convert, in_caps, out_caps);
127 + if(gst_base_transform_is_passthrough (bt) && convert->disable_passthrough){
128 + /* if in passthrough mode and disable_passthrough is set to true,
129 + * set passthrough to FALSE*/
130 + GST_DEBUG_OBJECT(convert, "Disable passthrough mode");
131 + gst_base_transform_set_passthrough(bt, FALSE);
137 diff --git a/ext/gl/gstglcolorconvertelement.h b/ext/gl/gstglcolorconvertelement.h
138 index 2a0dd1d..5cdbd3a 100644
139 --- a/ext/gl/gstglcolorconvertelement.h
140 +++ b/ext/gl/gstglcolorconvertelement.h
141 @@ -47,6 +47,7 @@ struct _GstGLColorConvertElement
142 GstGLColorConvert *convert;
145 + gboolean disable_passthrough;
148 struct _GstGLColorConvertElementClass
149 diff --git a/gst-libs/gst/gl/gstglcolorconvert.c b/gst-libs/gst/gl/gstglcolorconvert.c
150 index 908a53e..4f072f5 100644
151 --- a/gst-libs/gst/gl/gstglcolorconvert.c
152 +++ b/gst-libs/gst/gl/gstglcolorconvert.c
153 @@ -710,7 +710,11 @@ _gst_gl_color_convert_set_caps_unlocked (GstGLColorConvert * convert,
154 convert->priv->to_texture_target = to_target;
155 convert->initted = FALSE;
157 - convert->passthrough = passthrough;
158 + /* We may disable passthrough via an external property
159 + * By the way, when glconvertelement is in passthrough mode,
160 + * the plugin will not call gst_gl_color_convert_perform().*/
162 + //convert->passthrough = passthrough;
163 #ifndef GST_DISABLE_GST_DEBUG
164 if (G_UNLIKELY (convert->passthrough))
165 GST_DEBUG_OBJECT (convert,