1 /* 2 * GStreamer 3 * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public 16 * License along with this library; if not, write to the 17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef __GST_GL_EFFECTS_H__ 22 #define __GST_GL_EFFECTS_H__ 23 24 #include <gst/gl/gstglfilter.h> 25 #include <gst/gl/gstglfuncs.h> 26 27 #include "effects/gstgleffectssources.h" 28 29 G_BEGIN_DECLS 30 31 #define GST_TYPE_GL_EFFECTS (gst_gl_effects_get_type()) 32 #define GST_GL_EFFECTS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_GL_EFFECTS,GstGLEffects)) 33 #define GST_IS_GL_EFFECTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_GL_EFFECTS)) 34 #define GST_GL_EFFECTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) , GST_TYPE_GL_EFFECTS,GstGLEffectsClass)) 35 #define GST_IS_GL_EFFECTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) , GST_TYPE_GL_EFFECTS)) 36 #define GST_GL_EFFECTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) , GST_TYPE_GL_EFFECTS,GstGLEffectsClass)) 37 38 #define USING_OPENGL(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL, 1, 0)) 39 #define USING_OPENGL3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL3, 3, 1)) 40 #define USING_GLES(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES, 1, 0)) 41 #define USING_GLES2(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 2, 0)) 42 #define USING_GLES3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0)) 43 44 typedef struct _GstGLEffects GstGLEffects; 45 typedef struct _GstGLEffectsClass GstGLEffectsClass; 46 47 typedef struct { 48 gint effect; 49 guint supported_properties; 50 const gchar *filter_name; 51 const gchar *filter_longname; 52 } GstGLEffectsFilterDescriptor; 53 54 typedef void (* GstGLEffectProcessFunc) (GstGLEffects *effects); 55 56 #define NEEDED_TEXTURES 5 57 58 enum { 59 GST_GL_EFFECTS_CURVE_HEAT, 60 GST_GL_EFFECTS_CURVE_SEPIA, 61 GST_GL_EFFECTS_CURVE_XPRO, 62 GST_GL_EFFECTS_CURVE_LUMA_XPRO, 63 GST_GL_EFFECTS_CURVE_XRAY, 64 GST_GL_EFFECTS_N_CURVES 65 }; 66 67 struct _GstGLEffects 68 { 69 GstGLFilter filter; 70 71 GstGLEffectProcessFunc effect; 72 gint current_effect; 73 74 GstGLMemory *intexture; 75 GstGLMemory *midtexture[NEEDED_TEXTURES]; 76 GstGLMemory *outtexture; 77 78 GLuint curve[GST_GL_EFFECTS_N_CURVES]; 79 80 GHashTable *shaderstable; 81 82 gboolean horizontal_swap; /* switch left to right */ 83 gboolean invert; /* colours */ 84 }; 85 86 struct _GstGLEffectsClass 87 { 88 GstGLFilterClass filter_class; 89 const GstGLEffectsFilterDescriptor *filter_descriptor; 90 }; 91 92 GType gst_gl_effects_get_type (void); 93 gboolean gst_gl_effects_register_filters (GstPlugin *, GstRank); 94 GstGLShader* gst_gl_effects_get_fragment_shader (GstGLEffects *effects, 95 const gchar * shader_name, const gchar * shader_source_gles2); 96 97 void gst_gl_effects_identity (GstGLEffects *effects); 98 void gst_gl_effects_mirror (GstGLEffects *effects); 99 void gst_gl_effects_squeeze (GstGLEffects *effects); 100 void gst_gl_effects_stretch (GstGLEffects *effects); 101 void gst_gl_effects_tunnel (GstGLEffects *effects); 102 void gst_gl_effects_fisheye (GstGLEffects *effects); 103 void gst_gl_effects_twirl (GstGLEffects *effects); 104 void gst_gl_effects_bulge (GstGLEffects *effects); 105 void gst_gl_effects_square (GstGLEffects *effects); 106 void gst_gl_effects_heat (GstGLEffects *effects); 107 void gst_gl_effects_sepia (GstGLEffects *effects); 108 void gst_gl_effects_xpro (GstGLEffects *effects); 109 void gst_gl_effects_xray (GstGLEffects *effects); 110 void gst_gl_effects_luma_xpro (GstGLEffects *effects); 111 void gst_gl_effects_sin (GstGLEffects *effects); 112 void gst_gl_effects_glow (GstGLEffects *effects); 113 void gst_gl_effects_sobel (GstGLEffects *effects); 114 void gst_gl_effects_blur (GstGLEffects *effects); 115 void gst_gl_effects_laplacian (GstGLEffects *effects); 116 117 G_END_DECLS 118 119 #endif /*__GST_GL_EFFECTS_H__ */ 120