diff options
| author | Yuqing Zhu <carol.zhu@nxp.com> | 2016-07-05 17:29:08 +0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-07-20 10:28:45 +0100 |
| commit | e1eca35850bec208115ef5d8d727e1f0ce561b48 (patch) | |
| tree | 769923399ab190d17e60f2e6b27872b73160c374 | |
| parent | b0d66a77c7e480a31fba278337cbb51e0ca72708 (diff) | |
| download | poky-e1eca35850bec208115ef5d8d727e1f0ce561b48.tar.gz | |
gstreamer1.0-plugins-bad: Enable gldeinterlace on OpenGL ES
Enable gldeinterlace on OpenGL ES to improve performance.
(From OE-Core rev: 0b6c21fd4e4094c0462a4dd4b29f56cdc6e7a769)
Signed-off-by: Yuqing Zhu <carol.zhu@nxp.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2 files changed, 635 insertions, 0 deletions
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad/0002-glplugin-enable-gldeinterlace-on-OpenGL-ES.patch b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad/0002-glplugin-enable-gldeinterlace-on-OpenGL-ES.patch new file mode 100755 index 0000000000..51f4eb4b39 --- /dev/null +++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad/0002-glplugin-enable-gldeinterlace-on-OpenGL-ES.patch | |||
| @@ -0,0 +1,634 @@ | |||
| 1 | From 8a0e97f7e672301cc76e394855e8c7a3448b0249 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Haihua Hu <jared.hu@nxp.com> | ||
| 3 | Date: Fri, 8 Apr 2016 16:47:15 +0800 | ||
| 4 | Subject: [PATCH 4/6] [glplugin] enable gldeinterlace on OpenGL ES | ||
| 5 | MIME-Version: 1.0 | ||
| 6 | Content-Type: text/plain; charset=UTF-8 | ||
| 7 | Content-Transfer-Encoding: 8bit | ||
| 8 | |||
| 9 | 1.Porting the exist deinterlace shader and OpenGL callback | ||
| 10 | to be compatible with OpenGL ES. | ||
| 11 | 2.Add a our blur vertical shader to gldeinterlace. | ||
| 12 | 3.Add a property named “method” to let user choose which | ||
| 13 | deinterlace function to use. Default to choose blur vertical | ||
| 14 | method for better performance. | ||
| 15 | |||
| 16 | Upstream-Status: Backport [1.9.1] | ||
| 17 | |||
| 18 | https://bugzilla.gnome.org/show_bug.cgi?id=764873 | ||
| 19 | |||
| 20 | Signed-off-by: Haihua Hu <jared.hu@nxp.com> | ||
| 21 | --- | ||
| 22 | ext/gl/Makefile.am | 4 +- | ||
| 23 | ext/gl/gstgldeinterlace.c | 344 +++++++++++++++++++++++++++++++++++----------- | ||
| 24 | ext/gl/gstgldeinterlace.h | 6 +- | ||
| 25 | ext/gl/gstopengl.c | 13 +- | ||
| 26 | 4 files changed, 275 insertions(+), 92 deletions(-) | ||
| 27 | |||
| 28 | diff --git a/ext/gl/Makefile.am b/ext/gl/Makefile.am | ||
| 29 | index 5d55f54..46419a7 100644 | ||
| 30 | --- a/ext/gl/Makefile.am | ||
| 31 | +++ b/ext/gl/Makefile.am | ||
| 32 | @@ -40,6 +40,7 @@ libgstopengl_la_SOURCES = \ | ||
| 33 | gstglfilterapp.c \ | ||
| 34 | gstglviewconvert.c \ | ||
| 35 | gstglstereosplit.c \ | ||
| 36 | + gstgldeinterlace.c \ | ||
| 37 | gstglstereomix.c | ||
| 38 | |||
| 39 | noinst_HEADERS = \ | ||
| 40 | @@ -63,20 +64,19 @@ noinst_HEADERS = \ | ||
| 41 | gstglfilterapp.h \ | ||
| 42 | gstglstereosplit.h \ | ||
| 43 | gstglstereomix.h \ | ||
| 44 | + gstgldeinterlace.h \ | ||
| 45 | gstglviewconvert.h | ||
| 46 | |||
| 47 | # full opengl required | ||
| 48 | if USE_OPENGL | ||
| 49 | libgstopengl_la_SOURCES += \ | ||
| 50 | gstglfilterglass.c \ | ||
| 51 | - gstgldeinterlace.c \ | ||
| 52 | gltestsrc.c \ | ||
| 53 | gstgltestsrc.c \ | ||
| 54 | gstglmosaic.c | ||
| 55 | |||
| 56 | noinst_HEADERS += \ | ||
| 57 | gstglfilterglass.h \ | ||
| 58 | - gstgldeinterlace.h \ | ||
| 59 | gltestsrc.h \ | ||
| 60 | gstgltestsrc.h \ | ||
| 61 | gstglmosaic.h \ | ||
| 62 | diff --git a/ext/gl/gstgldeinterlace.c b/ext/gl/gstgldeinterlace.c | ||
| 63 | index bd0eff0..c1250dc 100644 | ||
| 64 | --- a/ext/gl/gstgldeinterlace.c | ||
| 65 | +++ b/ext/gl/gstgldeinterlace.c | ||
| 66 | @@ -43,7 +43,8 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT); | ||
| 67 | |||
| 68 | enum | ||
| 69 | { | ||
| 70 | - PROP_0 | ||
| 71 | + PROP_0, | ||
| 72 | + PROP_METHOD | ||
| 73 | }; | ||
| 74 | |||
| 75 | #define DEBUG_INIT \ | ||
| 76 | @@ -57,17 +58,23 @@ static void gst_gl_deinterlace_set_property (GObject * object, | ||
| 77 | static void gst_gl_deinterlace_get_property (GObject * object, | ||
| 78 | guint prop_id, GValue * value, GParamSpec * pspec); | ||
| 79 | |||
| 80 | +static gboolean gst_gl_deinterlace_start (GstBaseTransform * trans); | ||
| 81 | static gboolean gst_gl_deinterlace_reset (GstBaseTransform * trans); | ||
| 82 | -static gboolean gst_gl_deinterlace_init_shader (GstGLFilter * filter); | ||
| 83 | +static gboolean gst_gl_deinterlace_init_fbo (GstGLFilter * filter); | ||
| 84 | static gboolean gst_gl_deinterlace_filter (GstGLFilter * filter, | ||
| 85 | GstBuffer * inbuf, GstBuffer * outbuf); | ||
| 86 | static gboolean gst_gl_deinterlace_filter_texture (GstGLFilter * filter, | ||
| 87 | guint in_tex, guint out_tex); | ||
| 88 | -static void gst_gl_deinterlace_callback (gint width, gint height, | ||
| 89 | +static void gst_gl_deinterlace_vfir_callback (gint width, gint height, | ||
| 90 | + guint texture, gpointer stuff); | ||
| 91 | +static void gst_gl_deinterlace_greedyh_callback (gint width, gint height, | ||
| 92 | guint texture, gpointer stuff); | ||
| 93 | |||
| 94 | /* *INDENT-OFF* */ | ||
| 95 | static const gchar *greedyh_fragment_source = | ||
| 96 | + "#ifdef GL_ES\n" | ||
| 97 | + "precision mediump float;\n" | ||
| 98 | + "#endif\n" | ||
| 99 | "uniform sampler2D tex;\n" | ||
| 100 | "uniform sampler2D tex_prev;\n" | ||
| 101 | "uniform float max_comb;\n" | ||
| 102 | @@ -75,35 +82,35 @@ static const gchar *greedyh_fragment_source = | ||
| 103 | "uniform float motion_sense;\n" | ||
| 104 | "uniform float width;\n" | ||
| 105 | "uniform float height;\n" | ||
| 106 | + "varying vec2 v_texcoord;\n" | ||
| 107 | |||
| 108 | "void main () {\n" | ||
| 109 | - " vec2 texcoord = gl_TexCoord[0].xy;\n" | ||
| 110 | - " if (int(mod(texcoord.y * height, 2.0)) == 0) {\n" | ||
| 111 | - " gl_FragColor = vec4(texture2D(tex_prev, texcoord).rgb, 1.0);\n" | ||
| 112 | + " if (int(mod(v_texcoord.y * height, 2.0)) == 0) {\n" | ||
| 113 | + " gl_FragColor = vec4(texture2D(tex_prev, v_texcoord).rgb, 1.0);\n" | ||
| 114 | " } else {\n" | ||
| 115 | " vec2 texcoord_L1_a1, texcoord_L3_a1, texcoord_L1, texcoord_L3, texcoord_L1_1, texcoord_L3_1;\n" | ||
| 116 | " vec3 L1_a1, L3_a1, L1, L3, L1_1, L3_1;\n" | ||
| 117 | |||
| 118 | - " texcoord_L1 = vec2(texcoord.x, texcoord.y - 1.0 / height);\n" | ||
| 119 | - " texcoord_L3 = vec2(texcoord.x, texcoord.y + 1.0 / height);\n" | ||
| 120 | + " texcoord_L1 = vec2(v_texcoord.x, v_texcoord.y - 1.0 / height);\n" | ||
| 121 | + " texcoord_L3 = vec2(v_texcoord.x, v_texcoord.y + 1.0 / height);\n" | ||
| 122 | " L1 = texture2D(tex_prev, texcoord_L1).rgb;\n" | ||
| 123 | " L3 = texture2D(tex_prev, texcoord_L3).rgb;\n" | ||
| 124 | - " if (texcoord.x == 1.0 && texcoord.y == 1.0) {\n" | ||
| 125 | + " if (v_texcoord.x == 1.0 && v_texcoord.y == 1.0) {\n" | ||
| 126 | " L1_1 = L1;\n" | ||
| 127 | " L3_1 = L3;\n" | ||
| 128 | " } else {\n" | ||
| 129 | - " texcoord_L1_1 = vec2(texcoord.x + 1.0 / width, texcoord.y - 1.0 / height);\n" | ||
| 130 | - " texcoord_L3_1 = vec2(texcoord.x + 1.0 / width, texcoord.y + 1.0 / height);\n" | ||
| 131 | + " texcoord_L1_1 = vec2(v_texcoord.x + 1.0 / width, v_texcoord.y - 1.0 / height);\n" | ||
| 132 | + " texcoord_L3_1 = vec2(v_texcoord.x + 1.0 / width, v_texcoord.y + 1.0 / height);\n" | ||
| 133 | " L1_1 = texture2D(tex_prev, texcoord_L1_1).rgb;\n" | ||
| 134 | " L3_1 = texture2D(tex_prev, texcoord_L3_1).rgb;\n" | ||
| 135 | " }\n" | ||
| 136 | |||
| 137 | - " if (int(ceil(texcoord.x + texcoord.y)) == 0) {\n" | ||
| 138 | + " if (int(ceil(v_texcoord.x + v_texcoord.y)) == 0) {\n" | ||
| 139 | " L1_a1 = L1;\n" | ||
| 140 | " L3_a1 = L3;\n" | ||
| 141 | " } else {\n" | ||
| 142 | - " texcoord_L1_a1 = vec2(texcoord.x - 1.0 / width, texcoord.y - 1.0 / height);\n" | ||
| 143 | - " texcoord_L3_a1 = vec2(texcoord.x - 1.0 / width, texcoord.y + 1.0 / height);\n" | ||
| 144 | + " texcoord_L1_a1 = vec2(v_texcoord.x - 1.0 / width, v_texcoord.y - 1.0 / height);\n" | ||
| 145 | + " texcoord_L3_a1 = vec2(v_texcoord.x - 1.0 / width, v_texcoord.y + 1.0 / height);\n" | ||
| 146 | " L1_a1 = texture2D(tex_prev, texcoord_L1_a1).rgb;\n" | ||
| 147 | " L3_a1 = texture2D(tex_prev, texcoord_L3_a1).rgb;\n" | ||
| 148 | " }\n" | ||
| 149 | @@ -113,8 +120,8 @@ static const gchar *greedyh_fragment_source = | ||
| 150 | " vec3 avg_1 = (L1_1 + L3_1) / 2.0;\n" | ||
| 151 | " vec3 avg_s = (avg_a1 + avg_1) / 2.0;\n" | ||
| 152 | " vec3 avg_sc = (avg_s + avg) / 2.0;\n" | ||
| 153 | - " vec3 L2 = texture2D(tex, texcoord).rgb;\n" | ||
| 154 | - " vec3 LP2 = texture2D(tex_prev, texcoord).rgb;\n" | ||
| 155 | + " vec3 L2 = texture2D(tex, v_texcoord).rgb;\n" | ||
| 156 | + " vec3 LP2 = texture2D(tex_prev, v_texcoord).rgb;\n" | ||
| 157 | " vec3 best;\n" | ||
| 158 | " if (abs(L2.r - avg_sc.r) < abs(LP2.r - avg_sc.r)) {\n" | ||
| 159 | " best.r = L2.r;\n" " } else {\n" | ||
| 160 | @@ -144,8 +151,87 @@ static const gchar *greedyh_fragment_source = | ||
| 161 | " gl_FragColor = vec4(last, 1.0);\n" | ||
| 162 | " }\n" | ||
| 163 | "}\n"; | ||
| 164 | + | ||
| 165 | +const gchar *vfir_fragment_source = | ||
| 166 | + "#ifdef GL_ES\n" | ||
| 167 | + "precision mediump float;\n" | ||
| 168 | + "#endif\n" | ||
| 169 | + "uniform sampler2D tex;\n" | ||
| 170 | + "uniform float width;\n" | ||
| 171 | + "uniform float height;\n" | ||
| 172 | + "varying vec2 v_texcoord;\n" | ||
| 173 | + "void main()\n" | ||
| 174 | + "{\n" | ||
| 175 | + " vec2 topcoord, botcoord;\n" | ||
| 176 | + " vec4 cur_color, top_color, bot_color;\n" | ||
| 177 | + " topcoord.x = v_texcoord.x;\n" | ||
| 178 | + " botcoord.x = v_texcoord.x;\n" | ||
| 179 | + " if (v_texcoord.y == 0.0 || v_texcoord.y == 1.0) {\n" | ||
| 180 | + " topcoord.y = v_texcoord.y ;\n" | ||
| 181 | + " botcoord.y = v_texcoord.y ;\n" | ||
| 182 | + " }\n" | ||
| 183 | + " else {\n" | ||
| 184 | + " topcoord.y = v_texcoord.y - 1.0/height;\n" | ||
| 185 | + " botcoord.y = v_texcoord.y + 1.0/height;\n" | ||
| 186 | + " }\n" | ||
| 187 | + " cur_color = texture2D(tex, v_texcoord);\n" | ||
| 188 | + " top_color = texture2D(tex, topcoord);\n" | ||
| 189 | + " bot_color = texture2D(tex, botcoord);\n" | ||
| 190 | + " gl_FragColor = 0.5*cur_color + 0.25*top_color + 0.25*bot_color;\n" | ||
| 191 | + "}"; | ||
| 192 | /* *INDENT-ON* */ | ||
| 193 | |||
| 194 | +/* dont' forget to edit the following when a new method is added */ | ||
| 195 | +typedef enum | ||
| 196 | +{ | ||
| 197 | + GST_GL_DEINTERLACE_VFIR, | ||
| 198 | + GST_GL_DEINTERLACE_GREEDYH | ||
| 199 | +} GstGLDeinterlaceMethod; | ||
| 200 | + | ||
| 201 | +static const GEnumValue * | ||
| 202 | +gst_gl_deinterlace_get_methods (void) | ||
| 203 | +{ | ||
| 204 | + static const GEnumValue method_types[] = { | ||
| 205 | + {GST_GL_DEINTERLACE_VFIR, "Blur Vertical", "vfir"}, | ||
| 206 | + {GST_GL_DEINTERLACE_GREEDYH, "Motion Adaptive: Advanced Detection", | ||
| 207 | + "greedhy"}, | ||
| 208 | + {0, NULL, NULL} | ||
| 209 | + }; | ||
| 210 | + return method_types; | ||
| 211 | +} | ||
| 212 | + | ||
| 213 | +#define GST_TYPE_GL_DEINTERLACE_METHODS (gst_gl_deinterlace_method_get_type ()) | ||
| 214 | +static GType | ||
| 215 | +gst_gl_deinterlace_method_get_type (void) | ||
| 216 | +{ | ||
| 217 | + static GType gl_deinterlace_method_type = 0; | ||
| 218 | + if (!gl_deinterlace_method_type) { | ||
| 219 | + gl_deinterlace_method_type = | ||
| 220 | + g_enum_register_static ("GstGLDeinterlaceMethod", | ||
| 221 | + gst_gl_deinterlace_get_methods ()); | ||
| 222 | + } | ||
| 223 | + return gl_deinterlace_method_type; | ||
| 224 | +} | ||
| 225 | + | ||
| 226 | +static void | ||
| 227 | +gst_gl_deinterlace_set_method (GstGLDeinterlace * deinterlace, | ||
| 228 | + guint method_types) | ||
| 229 | +{ | ||
| 230 | + switch (method_types) { | ||
| 231 | + case GST_GL_DEINTERLACE_VFIR: | ||
| 232 | + deinterlace->deinterlacefunc = gst_gl_deinterlace_vfir_callback; | ||
| 233 | + deinterlace->current_method = method_types; | ||
| 234 | + break; | ||
| 235 | + case GST_GL_DEINTERLACE_GREEDYH: | ||
| 236 | + deinterlace->deinterlacefunc = gst_gl_deinterlace_greedyh_callback; | ||
| 237 | + deinterlace->current_method = method_types; | ||
| 238 | + break; | ||
| 239 | + default: | ||
| 240 | + g_assert_not_reached (); | ||
| 241 | + break; | ||
| 242 | + } | ||
| 243 | +} | ||
| 244 | + | ||
| 245 | static void | ||
| 246 | gst_gl_deinterlace_class_init (GstGLDeinterlaceClass * klass) | ||
| 247 | { | ||
| 248 | @@ -163,25 +249,60 @@ gst_gl_deinterlace_class_init (GstGLDeinterlaceClass * klass) | ||
| 249 | "Deinterlacing based on fragment shaders", | ||
| 250 | "Julien Isorce <julien.isorce@mail.com>"); | ||
| 251 | |||
| 252 | + g_object_class_install_property (gobject_class, | ||
| 253 | + PROP_METHOD, | ||
| 254 | + g_param_spec_enum ("method", | ||
| 255 | + "Deinterlace Method", | ||
| 256 | + "Select which deinterlace method apply to GL video texture", | ||
| 257 | + GST_TYPE_GL_DEINTERLACE_METHODS, | ||
| 258 | + GST_GL_DEINTERLACE_VFIR, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); | ||
| 259 | + | ||
| 260 | + GST_BASE_TRANSFORM_CLASS (klass)->start = gst_gl_deinterlace_start; | ||
| 261 | GST_BASE_TRANSFORM_CLASS (klass)->stop = gst_gl_deinterlace_reset; | ||
| 262 | |||
| 263 | GST_GL_FILTER_CLASS (klass)->filter = gst_gl_deinterlace_filter; | ||
| 264 | GST_GL_FILTER_CLASS (klass)->filter_texture = | ||
| 265 | gst_gl_deinterlace_filter_texture; | ||
| 266 | - GST_GL_FILTER_CLASS (klass)->init_fbo = gst_gl_deinterlace_init_shader; | ||
| 267 | + GST_GL_FILTER_CLASS (klass)->init_fbo = gst_gl_deinterlace_init_fbo; | ||
| 268 | |||
| 269 | - GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL; | ||
| 270 | + GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = | ||
| 271 | + GST_GL_API_OPENGL | GST_GL_API_GLES2 | GST_GL_API_OPENGL3; | ||
| 272 | } | ||
| 273 | |||
| 274 | static void | ||
| 275 | gst_gl_deinterlace_init (GstGLDeinterlace * filter) | ||
| 276 | { | ||
| 277 | - filter->shader = NULL; | ||
| 278 | + filter->shaderstable = NULL; | ||
| 279 | + filter->deinterlacefunc = gst_gl_deinterlace_vfir_callback; | ||
| 280 | + filter->current_method = GST_GL_DEINTERLACE_VFIR; | ||
| 281 | filter->prev_buffer = NULL; | ||
| 282 | filter->prev_tex = 0; | ||
| 283 | } | ||
| 284 | |||
| 285 | static gboolean | ||
| 286 | +gst_gl_deinterlace_start (GstBaseTransform * trans) | ||
| 287 | +{ | ||
| 288 | + GstGLDeinterlace *deinterlace_filter = GST_GL_DEINTERLACE (trans); | ||
| 289 | + | ||
| 290 | + deinterlace_filter->shaderstable = g_hash_table_new (g_str_hash, g_str_equal); | ||
| 291 | + | ||
| 292 | + return GST_BASE_TRANSFORM_CLASS (parent_class)->start (trans); | ||
| 293 | +} | ||
| 294 | + | ||
| 295 | +static void | ||
| 296 | +gst_gl_deinterlace_ghash_func_clean (gpointer key, gpointer value, | ||
| 297 | + gpointer data) | ||
| 298 | +{ | ||
| 299 | + GstGLShader *shader = (GstGLShader *) value; | ||
| 300 | + GstGLFilter *filter = (GstGLFilter *) data; | ||
| 301 | + | ||
| 302 | + //blocking call, wait the opengl thread has destroyed the shader | ||
| 303 | + gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, shader); | ||
| 304 | + | ||
| 305 | + value = NULL; | ||
| 306 | +} | ||
| 307 | + | ||
| 308 | +static gboolean | ||
| 309 | gst_gl_deinterlace_reset (GstBaseTransform * trans) | ||
| 310 | { | ||
| 311 | GstGLDeinterlace *deinterlace_filter = GST_GL_DEINTERLACE (trans); | ||
| 312 | @@ -189,10 +310,17 @@ gst_gl_deinterlace_reset (GstBaseTransform * trans) | ||
| 313 | gst_buffer_replace (&deinterlace_filter->prev_buffer, NULL); | ||
| 314 | |||
| 315 | //blocking call, wait the opengl thread has destroyed the shader | ||
| 316 | - if (deinterlace_filter->shader) | ||
| 317 | - gst_gl_context_del_shader (GST_GL_BASE_FILTER (trans)->context, | ||
| 318 | - deinterlace_filter->shader); | ||
| 319 | - deinterlace_filter->shader = NULL; | ||
| 320 | + if (deinterlace_filter->shaderstable) { | ||
| 321 | + /* release shaders in the gl thread */ | ||
| 322 | + g_hash_table_foreach (deinterlace_filter->shaderstable, | ||
| 323 | + gst_gl_deinterlace_ghash_func_clean, deinterlace_filter); | ||
| 324 | + | ||
| 325 | + /* clean the htable without calling values destructors | ||
| 326 | + * because shaders have been released in the glthread | ||
| 327 | + * through the foreach func */ | ||
| 328 | + g_hash_table_unref (deinterlace_filter->shaderstable); | ||
| 329 | + deinterlace_filter->shaderstable = NULL; | ||
| 330 | + } | ||
| 331 | |||
| 332 | return GST_BASE_TRANSFORM_CLASS (parent_class)->stop (trans); | ||
| 333 | } | ||
| 334 | @@ -201,9 +329,12 @@ static void | ||
| 335 | gst_gl_deinterlace_set_property (GObject * object, guint prop_id, | ||
| 336 | const GValue * value, GParamSpec * pspec) | ||
| 337 | { | ||
| 338 | - //GstGLDeinterlace *filter = GST_GL_DEINTERLACE (object); | ||
| 339 | + GstGLDeinterlace *filter = GST_GL_DEINTERLACE (object); | ||
| 340 | |||
| 341 | switch (prop_id) { | ||
| 342 | + case PROP_METHOD: | ||
| 343 | + gst_gl_deinterlace_set_method (filter, g_value_get_enum (value)); | ||
| 344 | + break; | ||
| 345 | default: | ||
| 346 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||
| 347 | break; | ||
| 348 | @@ -214,9 +345,12 @@ static void | ||
| 349 | gst_gl_deinterlace_get_property (GObject * object, guint prop_id, | ||
| 350 | GValue * value, GParamSpec * pspec) | ||
| 351 | { | ||
| 352 | - //GstGLDeinterlace *filter = GST_GL_DEINTERLACE (object); | ||
| 353 | + GstGLDeinterlace *filter = GST_GL_DEINTERLACE (object); | ||
| 354 | |||
| 355 | switch (prop_id) { | ||
| 356 | + case PROP_METHOD: | ||
| 357 | + g_value_set_enum (value, filter->current_method); | ||
| 358 | + break; | ||
| 359 | default: | ||
| 360 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||
| 361 | break; | ||
| 362 | @@ -224,13 +358,9 @@ gst_gl_deinterlace_get_property (GObject * object, guint prop_id, | ||
| 363 | } | ||
| 364 | |||
| 365 | static gboolean | ||
| 366 | -gst_gl_deinterlace_init_shader (GstGLFilter * filter) | ||
| 367 | +gst_gl_deinterlace_init_fbo (GstGLFilter * filter) | ||
| 368 | { | ||
| 369 | - GstGLDeinterlace *deinterlace_filter = GST_GL_DEINTERLACE (filter); | ||
| 370 | - | ||
| 371 | - //blocking call, wait the opengl thread has compiled the shader | ||
| 372 | - return gst_gl_context_gen_shader (GST_GL_BASE_FILTER (filter)->context, 0, | ||
| 373 | - greedyh_fragment_source, &deinterlace_filter->shader); | ||
| 374 | + return TRUE; | ||
| 375 | } | ||
| 376 | |||
| 377 | static gboolean | ||
| 378 | @@ -241,7 +371,7 @@ gst_gl_deinterlace_filter_texture (GstGLFilter * filter, guint in_tex, | ||
| 379 | |||
| 380 | //blocking call, use a FBO | ||
| 381 | gst_gl_filter_render_to_target (filter, TRUE, in_tex, out_tex, | ||
| 382 | - gst_gl_deinterlace_callback, deinterlace_filter); | ||
| 383 | + deinterlace_filter->deinterlacefunc, deinterlace_filter); | ||
| 384 | |||
| 385 | return TRUE; | ||
| 386 | } | ||
| 387 | @@ -259,36 +389,104 @@ gst_gl_deinterlace_filter (GstGLFilter * filter, GstBuffer * inbuf, | ||
| 388 | return TRUE; | ||
| 389 | } | ||
| 390 | |||
| 391 | -//opengl scene, params: input texture (not the output filter->texture) | ||
| 392 | +static GstGLShader * | ||
| 393 | +gst_gl_deinterlace_get_fragment_shader (GstGLFilter * filter, | ||
| 394 | + const gchar * shader_name, const gchar * shader_source) | ||
| 395 | +{ | ||
| 396 | + GstGLShader *shader = NULL; | ||
| 397 | + GstGLDeinterlace *deinterlace_filter = GST_GL_DEINTERLACE (filter); | ||
| 398 | + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; | ||
| 399 | + | ||
| 400 | + shader = g_hash_table_lookup (deinterlace_filter->shaderstable, shader_name); | ||
| 401 | + | ||
| 402 | + if (!shader) { | ||
| 403 | + GError *error = NULL; | ||
| 404 | + | ||
| 405 | + if (!(shader = gst_gl_shader_new_link_with_stages (context, &error, | ||
| 406 | + gst_glsl_stage_new_default_vertex (context), | ||
| 407 | + gst_glsl_stage_new_with_string (context, GL_FRAGMENT_SHADER, | ||
| 408 | + GST_GLSL_VERSION_NONE, | ||
| 409 | + GST_GLSL_PROFILE_ES | GST_GLSL_PROFILE_COMPATIBILITY, | ||
| 410 | + shader_source), NULL))) { | ||
| 411 | + GST_ELEMENT_ERROR (deinterlace_filter, RESOURCE, NOT_FOUND, | ||
| 412 | + ("Failed to initialize %s shader", shader_name), (NULL)); | ||
| 413 | + } | ||
| 414 | + | ||
| 415 | + filter->draw_attr_position_loc = | ||
| 416 | + gst_gl_shader_get_attribute_location (shader, "a_position"); | ||
| 417 | + filter->draw_attr_texture_loc = | ||
| 418 | + gst_gl_shader_get_attribute_location (shader, "a_texcoord"); | ||
| 419 | + } | ||
| 420 | + | ||
| 421 | + g_hash_table_insert (deinterlace_filter->shaderstable, (gchar *) shader_name, | ||
| 422 | + shader); | ||
| 423 | + | ||
| 424 | + return shader; | ||
| 425 | +} | ||
| 426 | + | ||
| 427 | static void | ||
| 428 | -gst_gl_deinterlace_callback (gint width, gint height, guint texture, | ||
| 429 | +gst_gl_deinterlace_vfir_callback (gint width, gint height, guint texture, | ||
| 430 | gpointer stuff) | ||
| 431 | { | ||
| 432 | - GstGLDeinterlace *deinterlace_filter = GST_GL_DEINTERLACE (stuff); | ||
| 433 | + GstGLShader *shader; | ||
| 434 | GstGLFilter *filter = GST_GL_FILTER (stuff); | ||
| 435 | - GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; | ||
| 436 | + GstGLDeinterlace *deinterlace_filter = GST_GL_DEINTERLACE (filter); | ||
| 437 | + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; | ||
| 438 | + GstGLFuncs *gl = context->gl_vtable; | ||
| 439 | + | ||
| 440 | + shader = gst_gl_deinterlace_get_fragment_shader (deinterlace_filter, "vfir", | ||
| 441 | + vfir_fragment_source); | ||
| 442 | + | ||
| 443 | + if (!shader) | ||
| 444 | + return; | ||
| 445 | + | ||
| 446 | +#if GST_GL_HAVE_OPENGL | ||
| 447 | + if (USING_OPENGL (context)) { | ||
| 448 | + gl->MatrixMode (GL_PROJECTION); | ||
| 449 | + gl->LoadIdentity (); | ||
| 450 | + } | ||
| 451 | +#endif | ||
| 452 | + | ||
| 453 | + gst_gl_shader_use (shader); | ||
| 454 | + | ||
| 455 | + gl->ActiveTexture (GL_TEXTURE0); | ||
| 456 | + gl->BindTexture (GL_TEXTURE_2D, texture); | ||
| 457 | + | ||
| 458 | + gst_gl_shader_set_uniform_1i (shader, "tex", 0); | ||
| 459 | + gst_gl_shader_set_uniform_1f (shader, "width", | ||
| 460 | + GST_VIDEO_INFO_WIDTH (&filter->out_info)); | ||
| 461 | + gst_gl_shader_set_uniform_1f (shader, "height", | ||
| 462 | + GST_VIDEO_INFO_HEIGHT (&filter->out_info)); | ||
| 463 | + | ||
| 464 | + gst_gl_filter_draw_texture (filter, texture, width, height); | ||
| 465 | +} | ||
| 466 | + | ||
| 467 | +static void | ||
| 468 | +gst_gl_deinterlace_greedyh_callback (gint width, gint height, guint texture, | ||
| 469 | + gpointer stuff) | ||
| 470 | +{ | ||
| 471 | + GstGLShader *shader; | ||
| 472 | + GstGLFilter *filter = GST_GL_FILTER (stuff); | ||
| 473 | + GstGLDeinterlace *deinterlace_filter = GST_GL_DEINTERLACE (filter); | ||
| 474 | + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; | ||
| 475 | + GstGLFuncs *gl = context->gl_vtable; | ||
| 476 | guint temp; | ||
| 477 | |||
| 478 | - GLfloat verts[] = { -1.0, -1.0, | ||
| 479 | - 1.0, -1.0, | ||
| 480 | - 1.0, 1.0, | ||
| 481 | - -1.0, 1.0 | ||
| 482 | - }; | ||
| 483 | - GLfloat texcoords0[] = { 0.0f, 0.0f, | ||
| 484 | - 1.0f, 0.0f, | ||
| 485 | - 1.0f, 1.0f, | ||
| 486 | - 0.0f, 1.0f | ||
| 487 | - }; | ||
| 488 | - GLfloat texcoords1[] = { 0.0f, 0.0f, | ||
| 489 | - 1.0f, 0.0f, | ||
| 490 | - 1.0f, 1.0f, | ||
| 491 | - 0.0f, 1.0f | ||
| 492 | - }; | ||
| 493 | + shader = | ||
| 494 | + gst_gl_deinterlace_get_fragment_shader (deinterlace_filter, "greedhy", | ||
| 495 | + greedyh_fragment_source); | ||
| 496 | |||
| 497 | - gl->MatrixMode (GL_PROJECTION); | ||
| 498 | - gl->LoadIdentity (); | ||
| 499 | + if (!shader) | ||
| 500 | + return; | ||
| 501 | |||
| 502 | - gst_gl_shader_use (deinterlace_filter->shader); | ||
| 503 | +#if GST_GL_HAVE_OPENGL | ||
| 504 | + if (USING_OPENGL (context)) { | ||
| 505 | + gl->MatrixMode (GL_PROJECTION); | ||
| 506 | + gl->LoadIdentity (); | ||
| 507 | + } | ||
| 508 | +#endif | ||
| 509 | + | ||
| 510 | + gst_gl_shader_use (shader); | ||
| 511 | |||
| 512 | if (G_UNLIKELY (deinterlace_filter->prev_tex == 0)) { | ||
| 513 | gst_gl_context_gen_texture (GST_GL_BASE_FILTER (filter)->context, | ||
| 514 | @@ -298,44 +496,24 @@ gst_gl_deinterlace_callback (gint width, gint height, guint texture, | ||
| 515 | GST_VIDEO_INFO_HEIGHT (&filter->out_info)); | ||
| 516 | } else { | ||
| 517 | gl->ActiveTexture (GL_TEXTURE1); | ||
| 518 | - gst_gl_shader_set_uniform_1i (deinterlace_filter->shader, "tex_prev", 1); | ||
| 519 | + gst_gl_shader_set_uniform_1i (shader, "tex_prev", 1); | ||
| 520 | gl->BindTexture (GL_TEXTURE_2D, deinterlace_filter->prev_tex); | ||
| 521 | } | ||
| 522 | |||
| 523 | gl->ActiveTexture (GL_TEXTURE0); | ||
| 524 | - gst_gl_shader_set_uniform_1i (deinterlace_filter->shader, "tex", 0); | ||
| 525 | + gl->BindTexture (GL_TEXTURE_2D, texture); | ||
| 526 | |||
| 527 | - gst_gl_shader_set_uniform_1f (deinterlace_filter->shader, "max_comb", | ||
| 528 | - 5.0f / 255.0f); | ||
| 529 | - gst_gl_shader_set_uniform_1f (deinterlace_filter->shader, "motion_threshold", | ||
| 530 | - 25.0f / 255.0f); | ||
| 531 | - gst_gl_shader_set_uniform_1f (deinterlace_filter->shader, "motion_sense", | ||
| 532 | - 30.0f / 255.0f); | ||
| 533 | + gst_gl_shader_set_uniform_1i (shader, "tex", 0); | ||
| 534 | + gst_gl_shader_set_uniform_1f (shader, "max_comb", 5.0f / 255.0f); | ||
| 535 | + gst_gl_shader_set_uniform_1f (shader, "motion_threshold", 25.0f / 255.0f); | ||
| 536 | + gst_gl_shader_set_uniform_1f (shader, "motion_sense", 30.0f / 255.0f); | ||
| 537 | |||
| 538 | - gst_gl_shader_set_uniform_1f (deinterlace_filter->shader, "width", | ||
| 539 | + gst_gl_shader_set_uniform_1f (shader, "width", | ||
| 540 | GST_VIDEO_INFO_WIDTH (&filter->out_info)); | ||
| 541 | - gst_gl_shader_set_uniform_1f (deinterlace_filter->shader, "height", | ||
| 542 | + gst_gl_shader_set_uniform_1f (shader, "height", | ||
| 543 | GST_VIDEO_INFO_HEIGHT (&filter->out_info)); | ||
| 544 | |||
| 545 | - gl->ClientActiveTexture (GL_TEXTURE0); | ||
| 546 | - | ||
| 547 | - gl->EnableClientState (GL_TEXTURE_COORD_ARRAY); | ||
| 548 | - gl->EnableClientState (GL_VERTEX_ARRAY); | ||
| 549 | - | ||
| 550 | - gl->VertexPointer (2, GL_FLOAT, 0, &verts); | ||
| 551 | - gl->TexCoordPointer (2, GL_FLOAT, 0, &texcoords0); | ||
| 552 | - | ||
| 553 | - gl->ClientActiveTexture (GL_TEXTURE1); | ||
| 554 | - gl->EnableClientState (GL_TEXTURE_COORD_ARRAY); | ||
| 555 | - gl->TexCoordPointer (2, GL_FLOAT, 0, &texcoords1); | ||
| 556 | - | ||
| 557 | - gl->DrawArrays (GL_TRIANGLE_FAN, 0, 4); | ||
| 558 | - | ||
| 559 | - gl->DisableClientState (GL_VERTEX_ARRAY); | ||
| 560 | - gl->DisableClientState (GL_TEXTURE_COORD_ARRAY); | ||
| 561 | - | ||
| 562 | - gl->ClientActiveTexture (GL_TEXTURE0); | ||
| 563 | - gl->DisableClientState (GL_TEXTURE_COORD_ARRAY); | ||
| 564 | + gst_gl_filter_draw_texture (filter, texture, width, height); | ||
| 565 | |||
| 566 | if (texture == filter->in_tex_id) { | ||
| 567 | temp = filter->in_tex_id; | ||
| 568 | diff --git a/ext/gl/gstgldeinterlace.h b/ext/gl/gstgldeinterlace.h | ||
| 569 | index a81a2e7..58a9c0c 100644 | ||
| 570 | --- a/ext/gl/gstgldeinterlace.h | ||
| 571 | +++ b/ext/gl/gstgldeinterlace.h | ||
| 572 | @@ -38,9 +38,13 @@ typedef struct _GstGLDeinterlaceClass GstGLDeinterlaceClass; | ||
| 573 | struct _GstGLDeinterlace | ||
| 574 | { | ||
| 575 | GstGLFilter filter; | ||
| 576 | - GstGLShader *shader; | ||
| 577 | + | ||
| 578 | + GLCB deinterlacefunc; | ||
| 579 | + GHashTable *shaderstable; | ||
| 580 | GstBuffer *prev_buffer; | ||
| 581 | guint prev_tex; | ||
| 582 | + | ||
| 583 | + gint current_method; | ||
| 584 | }; | ||
| 585 | |||
| 586 | struct _GstGLDeinterlaceClass | ||
| 587 | diff --git a/ext/gl/gstopengl.c b/ext/gl/gstopengl.c | ||
| 588 | index 50676c4..135862a 100644 | ||
| 589 | --- a/ext/gl/gstopengl.c | ||
| 590 | +++ b/ext/gl/gstopengl.c | ||
| 591 | @@ -62,6 +62,7 @@ | ||
| 592 | #include "gstglstereosplit.h" | ||
| 593 | #include "gstglstereomix.h" | ||
| 594 | #include "gstglviewconvert.h" | ||
| 595 | +#include "gstgldeinterlace.h" | ||
| 596 | |||
| 597 | #if HAVE_GRAPHENE | ||
| 598 | #include "gstgltransformation.h" | ||
| 599 | @@ -77,7 +78,6 @@ | ||
| 600 | #include "gstgltestsrc.h" | ||
| 601 | #include "gstglfilterglass.h" | ||
| 602 | /* #include "gstglfilterreflectedscreen.h" */ | ||
| 603 | -#include "gstgldeinterlace.h" | ||
| 604 | #include "gstglmosaic.h" | ||
| 605 | #if HAVE_PNG | ||
| 606 | #include "gstgldifferencematte.h" | ||
| 607 | @@ -226,6 +226,12 @@ plugin_init (GstPlugin * plugin) | ||
| 608 | GST_RANK_NONE, GST_TYPE_GL_STEREO_MIX)) { | ||
| 609 | return FALSE; | ||
| 610 | } | ||
| 611 | + | ||
| 612 | + if (!gst_element_register (plugin, "gldeinterlace", | ||
| 613 | + GST_RANK_NONE, GST_TYPE_GL_DEINTERLACE)) { | ||
| 614 | + return FALSE; | ||
| 615 | + } | ||
| 616 | + | ||
| 617 | #if HAVE_JPEG | ||
| 618 | #if HAVE_PNG | ||
| 619 | if (!gst_element_register (plugin, "gloverlay", | ||
| 620 | @@ -250,11 +256,6 @@ plugin_init (GstPlugin * plugin) | ||
| 621 | return FALSE; | ||
| 622 | } | ||
| 623 | #endif | ||
| 624 | - if (!gst_element_register (plugin, "gldeinterlace", | ||
| 625 | - GST_RANK_NONE, GST_TYPE_GL_DEINTERLACE)) { | ||
| 626 | - return FALSE; | ||
| 627 | - } | ||
| 628 | - | ||
| 629 | if (!gst_element_register (plugin, "glmosaic", | ||
| 630 | GST_RANK_NONE, GST_TYPE_GL_MOSAIC)) { | ||
| 631 | return FALSE; | ||
| 632 | -- | ||
| 633 | 1.9.1 | ||
| 634 | |||
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.8.2.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.8.2.bb index c7d67f854c..7cd14c73be 100644 --- a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.8.2.bb +++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.8.2.bb | |||
| @@ -12,6 +12,7 @@ SRC_URI = " \ | |||
| 12 | file://avoid-including-sys-poll.h-directly.patch \ | 12 | file://avoid-including-sys-poll.h-directly.patch \ |
| 13 | file://ensure-valid-sentinels-for-gst_structure_get-etc.patch \ | 13 | file://ensure-valid-sentinels-for-gst_structure_get-etc.patch \ |
| 14 | file://0001-gstreamer-gl.pc.in-don-t-append-GL_CFLAGS-to-CFLAGS.patch \ | 14 | file://0001-gstreamer-gl.pc.in-don-t-append-GL_CFLAGS-to-CFLAGS.patch \ |
| 15 | file://0002-glplugin-enable-gldeinterlace-on-OpenGL-ES.patch \ | ||
| 15 | " | 16 | " |
| 16 | SRC_URI[md5sum] = "83abc2e70684e7b195f18ca2992ef6e8" | 17 | SRC_URI[md5sum] = "83abc2e70684e7b195f18ca2992ef6e8" |
| 17 | SRC_URI[sha256sum] = "d7995317530c8773ec088f94d9320909d41da61996b801ebacce9a56af493f97" | 18 | SRC_URI[sha256sum] = "d7995317530c8773ec088f94d9320909d41da61996b801ebacce9a56af493f97" |
