]> code.ossystems Code Review - meta-freescale.git/blob
f126f17ab22ba6ed85b199aa042bb36a59907027
[meta-freescale.git] /
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
5
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.
8
9 Upstream-Status: Inappropriate [i.MX specific]
10
11 Signed-off-by: Haihua Hu <b55597@freescale.com>
12
13 Conflicts:
14         gst-libs/gst/gl/gstglcolorconvert.c
15 ---
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(-)
20
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");
27      );
28  
29 +enum
30 +{
31 +  GL_COLOR_CONVERT_PROP_0,
32 +  GL_COLOR_CONVERT_PROP_DISABLE_PASSTHROUGH
33 +};
34 +
35 +#define DISABLE_PASSTHROUGH_DAFAULT FALSE
36 +
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);
43  
44 +static void gst_gl_color_convert_set_property (GObject *object,
45 +    guint prop_id,
46 +    const GValue *value,
47 +    GParamSpec *pspec);
48 +static void gst_gl_color_convert_get_property (GObject *object,
49 +    guint prop_id,
50 +    GValue *value,
51 +    GParamSpec *pspec);
52 +
53  static GstStaticPadTemplate gst_gl_color_convert_element_src_pad_template =
54  GST_STATIC_PAD_TEMPLATE ("src",
55      GST_PAD_SRC,
56 @@ -89,6 +106,10 @@ gst_gl_color_convert_element_class_init (GstGLColorConvertElementClass * klass)
57  {
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);
61 +
62 +  object_class->set_property = gst_gl_color_convert_set_property;
63 +  object_class->get_property = gst_gl_color_convert_get_property;
64  
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);
70  
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));
77 +
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)
82  {
83    gst_base_transform_set_prefer_passthrough (GST_BASE_TRANSFORM (convert),
84        TRUE);
85 +  convert->disable_passthrough = FALSE;
86 +}
87 +
88 +static void
89 +gst_gl_color_convert_set_property (GObject *object,
90 +    guint prop_id,
91 +    const GValue *value,
92 +    GParamSpec *pspec)
93 +{
94 +  GstGLColorConvertElement *convert = GST_GL_COLOR_CONVERT_ELEMENT (object);
95 +  switch (prop_id) {
96 +    case GL_COLOR_CONVERT_PROP_DISABLE_PASSTHROUGH:
97 +      convert->disable_passthrough = g_value_get_boolean (value);
98 +      break;
99 +    default:
100 +      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
101 +      break;
102 +  }
103 +}
104 +
105 +static void
106 +gst_gl_color_convert_get_property (GObject *object,
107 +    guint prop_id,
108 +    GValue *value,
109 +    GParamSpec *pspec)
110 +{
111 +  GstGLColorConvertElement *convert = GST_GL_COLOR_CONVERT_ELEMENT (object);
112 +  switch (prop_id) {
113 +    case GL_COLOR_CONVERT_PROP_DISABLE_PASSTHROUGH:
114 +      g_value_set_boolean (value, convert->disable_passthrough);
115 +      break;
116 +    default:
117 +      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
118 +      break;
119 +  }
120  }
121  
122  static gboolean
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);
126  
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);
132 +  }
133 +
134    return TRUE;
135  }
136  
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;
143    GstCaps *in_caps;
144    GstCaps *out_caps;
145 +  gboolean disable_passthrough;
146  };
147  
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;
156  
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().*/
161 +
162 +  //convert->passthrough = passthrough;
163  #ifndef GST_DISABLE_GST_DEBUG
164    if (G_UNLIKELY (convert->passthrough))
165      GST_DEBUG_OBJECT (convert,
166 -- 
167 1.9.1
168