]> code.ossystems Code Review - meta-freescale.git/blob
aac204d137c78efb2c6ae07835e843159379a8bb
[meta-freescale.git] /
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
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 Signed-off-by: Lyon Wang <lyon.wang@freescale.com>
17 ---
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(-)
22
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");
29      );
30  
31 +enum
32 +{
33 +  GL_COLOR_CONVERT_PROP_0,
34 +  GL_COLOR_CONVERT_PROP_DISABLE_PASSTHROUGH
35 +};
36 +
37 +#define DISABLE_PASSTHROUGH_DAFAULT FALSE
38 +
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);
45  
46 +static void gst_gl_color_convert_set_property (GObject *object,
47 +    guint prop_id,
48 +    const GValue *value,
49 +    GParamSpec *pspec);
50 +static void gst_gl_color_convert_get_property (GObject *object,
51 +    guint prop_id,
52 +    GValue *value,
53 +    GParamSpec *pspec);
54 +
55  static GstStaticPadTemplate gst_gl_color_convert_element_src_pad_template =
56  GST_STATIC_PAD_TEMPLATE ("src",
57      GST_PAD_SRC,
58 @@ -89,6 +106,10 @@ gst_gl_color_convert_element_class_init (GstGLColorConvertElementClass * klass)
59  {
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);
63 +
64 +  object_class->set_property = gst_gl_color_convert_set_property;
65 +  object_class->get_property = gst_gl_color_convert_get_property;
66  
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));
72  
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));
79 +
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)
84  {
85    gst_base_transform_set_prefer_passthrough (GST_BASE_TRANSFORM (convert),
86        TRUE);
87 +  convert->disable_passthrough = FALSE;
88 +}
89 +
90 +static void
91 +gst_gl_color_convert_set_property (GObject *object,
92 +    guint prop_id,
93 +    const GValue *value,
94 +    GParamSpec *pspec)
95 +{
96 +  GstGLColorConvertElement *convert = GST_GL_COLOR_CONVERT_ELEMENT (object);
97 +  switch (prop_id) {
98 +    case GL_COLOR_CONVERT_PROP_DISABLE_PASSTHROUGH:
99 +      convert->disable_passthrough = g_value_get_boolean (value);
100 +      break;
101 +    default:
102 +      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
103 +      break;
104 +  }
105 +}
106 +
107 +static void
108 +gst_gl_color_convert_get_property (GObject *object,
109 +    guint prop_id,
110 +    GValue *value,
111 +    GParamSpec *pspec)
112 +{
113 +  GstGLColorConvertElement *convert = GST_GL_COLOR_CONVERT_ELEMENT (object);
114 +  switch (prop_id) {
115 +    case GL_COLOR_CONVERT_PROP_DISABLE_PASSTHROUGH:
116 +      g_value_set_boolean (value, convert->disable_passthrough);
117 +      break;
118 +    default:
119 +      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
120 +      break;
121 +  }
122  }
123  
124  static gboolean
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);
128  
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);
134 +  }
135 +
136    return TRUE;
137  }
138  
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;
145    GstCaps *in_caps;
146    GstCaps *out_caps;
147 +  gboolean disable_passthrough;
148  };
149  
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;
158  
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().*/
163 +
164 +  //convert->passthrough = passthrough;
165  #ifndef GST_DISABLE_GST_DEBUG
166    if (G_UNLIKELY (convert->passthrough))
167      GST_DEBUG_OBJECT (convert,
168 -- 
169 1.9.1
170