[158/906] still working on mergin gstgleffects, add mirror effect. reorganize source tree.
This commit is contained in:
parent
fd192ec957
commit
7bbdcce721
@ -12,7 +12,6 @@ libgstopengl_la_SOURCES = \
|
||||
gstglupload.h \
|
||||
gstgldownload.c \
|
||||
gstgldownload.h \
|
||||
gstgleffects.c \
|
||||
gstglfilterblur.c \
|
||||
gstglfiltercube.c \
|
||||
gstglfiltercube.h \
|
||||
@ -25,7 +24,12 @@ libgstopengl_la_SOURCES = \
|
||||
gltestsrc.c \
|
||||
gltestsrc.h \
|
||||
gstgltestsrc.c \
|
||||
gstgltestsrc.h
|
||||
gstgltestsrc.h \
|
||||
gstgleffects.c \
|
||||
effects/gstgleffects.h \
|
||||
effects/gstgleffectsources.h \
|
||||
effects/gstgleffectmirror.c
|
||||
|
||||
|
||||
# check order of CFLAGS and LIBS, shouldn't the order be the other way around
|
||||
# (like in AM_CFLAGS)?
|
||||
|
73
gst/gl/effects/gstgleffectmirror.c
Normal file
73
gst/gl/effects/gstgleffectmirror.c
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* GStreamer
|
||||
* Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "gstgleffects.h"
|
||||
#include "gstgleffectssources.h"
|
||||
|
||||
static void
|
||||
gst_gl_effects_mirror_callback (gint width, gint height, guint texture, gpointer data)
|
||||
{
|
||||
GstGLEffects* effects = GST_GL_EFFECTS (data);
|
||||
|
||||
GstGLShader *shader;
|
||||
gfloat tex_size[2];
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "mirror0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
g_hash_table_insert (effects->shaderstable, "mirror0", shader);
|
||||
}
|
||||
|
||||
g_return_if_fail (
|
||||
gst_gl_shader_compile_and_check (shader, mirror_fragment_source,
|
||||
GST_GL_SHADER_FRAGMENT_SOURCE));
|
||||
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
|
||||
gst_gl_shader_use (shader);
|
||||
|
||||
glActiveTexture (GL_TEXTURE0);
|
||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
|
||||
|
||||
tex_size[0] = GST_GL_FILTER(effects)->width / 2.0;
|
||||
tex_size[1] = GST_GL_FILTER(effects)->height / 2.0;
|
||||
|
||||
gst_gl_shader_set_uniform_1f (shader, "width", tex_size[0]);
|
||||
gst_gl_shader_set_uniform_1f (shader, "height", tex_size[1]);
|
||||
|
||||
gst_gl_effects_draw_texture (effects, texture);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_effects_mirror (GstGLEffects *effects) {
|
||||
GstGLFilter *filter = GST_GL_FILTER (effects);
|
||||
|
||||
gst_gl_filter_render_to_target (filter, effects->intexture, effects->outtexture,
|
||||
gst_gl_effects_mirror_callback, effects);
|
||||
}
|
73
gst/gl/effects/gstgleffects.h
Normal file
73
gst/gl/effects/gstgleffects.h
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* GStreamer
|
||||
* Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GST_GL_EFFECTS_H__
|
||||
#define __GST_GL_EFFECTS_H__
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <gstglfilter.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_GL_EFFECTS (gst_gl_effects_get_type())
|
||||
#define GST_GL_EFFECTS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_GL_EFFECTS,GstGLEffects))
|
||||
#define GST_IS_GL_EFFECTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_GL_EFFECTS))
|
||||
#define GST_GL_EFFECTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) , GST_TYPE_GL_EFFECTS,GstGLEffectsClass))
|
||||
#define GST_IS_GL_EFFECTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) , GST_TYPE_GL_EFFECTS))
|
||||
#define GST_GL_EFFECTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) , GST_TYPE_GL_EFFECTS,GstGLEffectsClass))
|
||||
|
||||
typedef struct _GstGLEffects GstGLEffects;
|
||||
typedef struct _GstGLEffectsClass GstGLEffectsClass;
|
||||
|
||||
typedef void (* GstGLEffectProcessFunc) (GstGLEffects *effects);
|
||||
|
||||
#define NEEDED_TEXTURES 10
|
||||
|
||||
struct _GstGLEffects
|
||||
{
|
||||
GstGLFilter filter;
|
||||
|
||||
GstGLEffectProcessFunc effect;
|
||||
gint current_effect;
|
||||
|
||||
GLuint intexture;
|
||||
GLuint midtexture[NEEDED_TEXTURES];
|
||||
GLuint outtexture;
|
||||
|
||||
GHashTable *shaderstable;
|
||||
};
|
||||
|
||||
struct _GstGLEffectsClass
|
||||
{
|
||||
GstGLFilterClass filter_class;
|
||||
};
|
||||
|
||||
GType gst_gl_effects_get_type (void);
|
||||
|
||||
void gst_gl_effects_draw_texture (GstGLEffects * effects, GLuint tex);
|
||||
|
||||
void gst_gl_effects_mirror (GstGLEffects *effects);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /*__GST_GL_EFFECTS_H__ */
|
40
gst/gl/effects/gstgleffectssources.h
Normal file
40
gst/gl/effects/gstgleffectssources.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* GStreamer
|
||||
* Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GST_GL_EFFECTS_SOURCES_H__
|
||||
#define __GST_GL_EFFECTS_SOURCES_H__
|
||||
|
||||
/* Mirror effect */
|
||||
static const gchar *mirror_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform float width, height;"
|
||||
"void main () {"
|
||||
" vec2 tex_size = vec2 (width, height);"
|
||||
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
||||
" vec2 normcoord;"
|
||||
" normcoord = texturecoord / tex_size - 1.0;"
|
||||
" normcoord.x *= sign (normcoord.x);"
|
||||
" texturecoord = (normcoord + 1.0) * tex_size;"
|
||||
" vec4 color = texture2DRect (tex, texturecoord); "
|
||||
" gl_FragColor = color * gl_Color;"
|
||||
"}";
|
||||
|
||||
#endif /* __GST_GL_EFFECTS_SOURCES_H__ */
|
@ -18,13 +18,7 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <gstglfilter.h>
|
||||
//#include "effects/shadersources.h"
|
||||
//#include "effects/textures.h"
|
||||
#include "effects/gstgleffects.h"
|
||||
|
||||
#define GST_TYPE_GL_EFFECTS (gst_gl_effects_get_type())
|
||||
#define GST_GL_EFFECTS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_GL_EFFECTS,GstGLEffects))
|
||||
@ -33,53 +27,12 @@
|
||||
#define GST_IS_GL_EFFECTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) , GST_TYPE_GL_EFFECTS))
|
||||
#define GST_GL_EFFECTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) , GST_TYPE_GL_EFFECTS,GstGLEffectsClass))
|
||||
|
||||
typedef struct _GstGLEffects GstGLEffects;
|
||||
typedef struct _GstGLEffectsClass GstGLEffectsClass;
|
||||
|
||||
typedef enum {
|
||||
GST_GL_EFFECT_IDENTITY,
|
||||
GST_GL_EFFECT_SQUEEZE,
|
||||
GST_GL_EFFECT_STRETCH,
|
||||
GST_GL_EFFECT_TUNNEL,
|
||||
GST_GL_EFFECT_FISHEYE,
|
||||
GST_GL_EFFECT_TWIRL,
|
||||
GST_GL_EFFECT_BULGE,
|
||||
GST_GL_EFFECT_SQUARE,
|
||||
GST_GL_EFFECT_MIRROR,
|
||||
GST_GL_EFFECT_HEAT,
|
||||
GST_GL_EFFECT_SEPIA,
|
||||
GST_GL_EFFECT_CROSS,
|
||||
GST_GL_EFFECT_GLOW,
|
||||
GST_GL_EFFECT_EMBOSS,
|
||||
GST_GL_EFFECT_BACKGROUND,
|
||||
GST_GL_EFFECT_TEST,
|
||||
GST_GL_N_EFFECTS
|
||||
} GstGLEffectsEffect;
|
||||
|
||||
#define NEEDED_TEXTURES 10
|
||||
|
||||
typedef void (* GstGLEffectProcessFunc) (GstGLEffects *effects);
|
||||
|
||||
struct _GstGLEffects
|
||||
{
|
||||
GstGLFilter filter;
|
||||
|
||||
GstGLEffectProcessFunc effect;
|
||||
|
||||
GLuint intexture;
|
||||
GLuint midtexture[NEEDED_TEXTURES];
|
||||
GLuint outtexture;
|
||||
|
||||
GHashTable *shaderstable;
|
||||
};
|
||||
|
||||
struct _GstGLEffectsClass
|
||||
{
|
||||
GstGLFilterClass filter_class;
|
||||
};
|
||||
|
||||
GType gst_gl_effects_get_type (void);
|
||||
|
||||
#define GST_CAT_DEFAULT gst_gl_effects_debug
|
||||
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
||||
|
||||
@ -93,7 +46,6 @@ static void gst_gl_effects_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
static void gst_gl_effects_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec);
|
||||
static void gst_gl_effects_draw_texture (GstGLEffects * effects, GLuint tex);
|
||||
|
||||
static void gst_gl_effects_init_resources (GstGLFilter* filter);
|
||||
static void gst_gl_effects_reset_resources (GstGLFilter* filter);
|
||||
@ -108,21 +60,7 @@ gst_gl_effects_effect_get_type (void)
|
||||
static GType gl_effects_effect_type = 0;
|
||||
static const GEnumValue effect_types [] = {
|
||||
{ GST_GL_EFFECT_IDENTITY, "Do nothing Effect", "identity" },
|
||||
{ GST_GL_EFFECT_SQUEEZE, "Squeeze Effect", "squeeze" },
|
||||
{ GST_GL_EFFECT_STRETCH, "Stretch Effect", "stretch" },
|
||||
{ GST_GL_EFFECT_FISHEYE, "FishEye Effect", "fisheye" },
|
||||
{ GST_GL_EFFECT_TWIRL, "Twirl Effect", "twirl" },
|
||||
{ GST_GL_EFFECT_BULGE, "Bulge Effect", "bulge" },
|
||||
{ GST_GL_EFFECT_TUNNEL, "Light Tunnel Effect", "tunnel" },
|
||||
{ GST_GL_EFFECT_SQUARE, "Square Effect", "square" },
|
||||
{ GST_GL_EFFECT_MIRROR, "Mirror Effect", "mirror" },
|
||||
{ GST_GL_EFFECT_HEAT, "Heat Signature Effect", "heat" },
|
||||
{ GST_GL_EFFECT_SEPIA, "Sepia Tone Effect", "sepia" },
|
||||
{ GST_GL_EFFECT_CROSS, "Cross Processing Effect", "cross" },
|
||||
{ GST_GL_EFFECT_GLOW, "Glow Lighting Effect", "glow" },
|
||||
{ GST_GL_EFFECT_EMBOSS, "Emboss Convolution Effect", "emboss" },
|
||||
{ GST_GL_EFFECT_BACKGROUND, "Difference Matte Effect", "background" },
|
||||
{ GST_GL_EFFECT_TEST, "Test Effect", "test" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
@ -209,7 +147,7 @@ gst_gl_effects_class_init (GstGLEffectsClass * klass)
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
gst_gl_effects_draw_texture (GstGLEffects * effects, GLuint tex)
|
||||
{
|
||||
GstGLFilter *filter = GST_GL_FILTER (effects);
|
||||
@ -287,16 +225,35 @@ gst_gl_effects_reset_resources (GstGLFilter* filter)
|
||||
effects->shaderstable = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_effects_set_effect (GstGLEffects *effects, gint effect_type) {
|
||||
|
||||
switch (effect_type) {
|
||||
case GST_GL_EFFECT_IDENTITY:
|
||||
effects->effect = (GstGLEffectProcessFunc) gst_gl_effects_identity;
|
||||
break;
|
||||
case GST_GL_EFFECT_MIRROR:
|
||||
effects->effect = (GstGLEffectProcessFunc) gst_gl_effects_mirror;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
effects->current_effect = effect_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_effects_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
/* GstGLEffects *effects = GST_GL_EFFECTS (object); */
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (object);
|
||||
|
||||
switch (prop_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
case PROP_EFFECT:
|
||||
gst_gl_effects_set_effect (effects, g_value_get_enum (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -304,11 +261,11 @@ static void
|
||||
gst_gl_effects_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
//GstGLEffects *effects = GST_GL_EFFECTS (object);
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_EFFECT:
|
||||
//gst_gl_effects_set_effect (effects, g_value_get_enum (value));
|
||||
g_value_set_enum (value, effects->current_effect);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
Loading…
x
Reference in New Issue
Block a user