• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * GStreamer
3  * Copyright (C) 2008-2010 Filippo Argiolas <filippo.argiolas@gmail.com>
4  * Copyright (C) 2015 Michał Dębski <debski.mi.zd@gmail.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25 
26 #include "../gstgleffects.h"
27 
28 static gfloat kernel[9] = {
29   0.0, -1.0, 0.0,
30   -1.0, 4.0, -1.0,
31   0.0, -1.0, 0.0
32 };
33 
34 void
gst_gl_effects_laplacian(GstGLEffects * effects)35 gst_gl_effects_laplacian (GstGLEffects * effects)
36 {
37   GstGLFilter *filter = GST_GL_FILTER (effects);
38   GstGLShader *shader;
39 
40   shader = gst_gl_effects_get_fragment_shader (effects, "conv0",
41       conv9_fragment_source_gles2);
42   gst_gl_shader_use (shader);
43   gst_gl_shader_set_uniform_1f (shader, "height",
44       GST_VIDEO_INFO_HEIGHT (&filter->in_info));
45   gst_gl_shader_set_uniform_1f (shader, "width",
46       GST_VIDEO_INFO_WIDTH (&filter->in_info));
47   gst_gl_shader_set_uniform_1fv (shader, "kernel", 9, kernel);
48   gst_gl_shader_set_uniform_1i (shader, "invert", effects->invert);
49 
50   gst_gl_filter_render_to_target_with_shader (filter, effects->intexture,
51       effects->outtexture, shader);
52 }
53