#include "../gstgleffects.h"
+static gpointer
+init_kernel (gpointer data)
+{
+ float *kernel = g_malloc (sizeof (gfloat) * 9);
+ fill_gaussian_kernel (kernel, 7, 3.f);
+ return kernel;
+}
+
static float *
gst_gl_effects_blur_kernel (void)
{
/* gaussian kernel (well, actually vector), size 9, standard
* deviation 3.0 */
/* FIXME: make this a runtime property */
- static gfloat *kernel = NULL;
- if (G_UNLIKELY (NULL == kernel)) {
- /* 3x3 matrix */
- kernel = g_malloc (sizeof (gfloat) * 9);
- fill_gaussian_kernel (kernel, 7, 3.f);
- }
- return kernel;
+ static GOnce my_once = G_ONCE_INIT;
+
+ g_once (&my_once, init_kernel, NULL);
+ return my_once.retval;
}
void
if (bumper_filter->shader)
gst_gl_context_del_shader (filter->context, bumper_filter->shader);
bumper_filter->shader = NULL;
+ bumper_filter->xrot = 0.0;
+ bumper_filter->yrot = 0.0;
+ bumper_filter->zrot = 0.0;
}
static void
static void
gst_gl_bumper_callback (gint width, gint height, guint texture, gpointer stuff)
{
- static GLfloat xrot = 0;
- static GLfloat yrot = 0;
- static GLfloat zrot = 0;
-
GstGLFuncs *gl;
GstGLBumper *bumper = GST_GL_BUMPER (stuff);
GstGLContext *context = GST_GL_FILTER (bumper)->context;
gst_gl_shader_set_uniform_1i (bumper->shader, "texture0", 0);
gl->BindTexture (GL_TEXTURE_2D, texture);
- gl->Rotatef (xrot, 1.0f, 0.0f, 0.0f);
- gl->Rotatef (yrot, 0.0f, 1.0f, 0.0f);
- gl->Rotatef (zrot, 0.0f, 0.0f, 1.0f);
+ gl->Rotatef (bumper->xrot, 1.0f, 0.0f, 0.0f);
+ gl->Rotatef (bumper->yrot, 0.0f, 1.0f, 0.0f);
+ gl->Rotatef (bumper->zrot, 0.0f, 0.0f, 1.0f);
gl->EnableVertexAttribArray (locTangent);
gl->Disable (GL_LIGHTING);
gl->Disable (GL_COLOR_MATERIAL);
- xrot += 1.0f;
- yrot += 0.9f;
- zrot += 0.6f;
+ bumper->xrot += 1.0f;
+ bumper->yrot += 0.9f;
+ bumper->zrot += 0.6f;
}
gint bumpmap_width;
gint bumpmap_height;
gchar *location;
+ GLfloat xrot, yrot, zrot;
};
struct _GstGLBumperClass
gchar *frag_str;
gboolean ret;
+ cube_filter->xrot = 0.0;
+ cube_filter->yrot = 0.0;
+ cube_filter->zrot = 0.0;
+
frag_str =
g_strdup_printf ("%s%s",
gst_gl_shader_string_get_highest_precision (context,
GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (filter);
GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable;
- static GLfloat xrot = 0;
- static GLfloat yrot = 0;
- static GLfloat zrot = 0;
-
const GLfloat matrix[] = {
0.5f, 0.0f, 0.0f, 0.0f,
0.0f, 0.5f, 0.0f, 0.0f,
gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_2D, cube_filter->in_tex->tex_id);
gst_gl_shader_set_uniform_1i (cube_filter->shader, "s_texture", 0);
- gst_gl_shader_set_uniform_1f (cube_filter->shader, "xrot_degree", xrot);
- gst_gl_shader_set_uniform_1f (cube_filter->shader, "yrot_degree", yrot);
- gst_gl_shader_set_uniform_1f (cube_filter->shader, "zrot_degree", zrot);
+ gst_gl_shader_set_uniform_1f (cube_filter->shader, "xrot_degree",
+ cube_filter->xrot);
+ gst_gl_shader_set_uniform_1f (cube_filter->shader, "yrot_degree",
+ cube_filter->yrot);
+ gst_gl_shader_set_uniform_1f (cube_filter->shader, "zrot_degree",
+ cube_filter->zrot);
gst_gl_shader_set_uniform_matrix_4fv (cube_filter->shader, "u_matrix", 1,
GL_FALSE, matrix);
gl->Disable (GL_DEPTH_TEST);
- xrot += 0.3f;
- yrot += 0.2f;
- zrot += 0.4f;
+ cube_filter->xrot += 0.3f;
+ cube_filter->yrot += 0.2f;
+ cube_filter->zrot += 0.4f;
return TRUE;
}
GLuint vertex_buffer;
GLint attr_position;
GLint attr_texture;
+
+ GLfloat xrot, yrot, zrot;
};
struct _GstGLFilterCubeClass
gst_object_unref (glass_filter->passthrough_shader);
glass_filter->passthrough_shader = NULL;
+ glass_filter->start_time = 0;
+
return GST_BASE_TRANSFORM_CLASS (parent_class)->stop (trans);
}
static gint64
get_time (void)
{
- static GTimeVal val;
- g_get_current_time (&val);
-
- return (val.tv_sec * G_USEC_PER_SEC) + val.tv_usec;
+ return g_get_real_time ();
}
static void
static gboolean
gst_gl_filter_glass_callback (gpointer stuff)
{
- static gint64 start_time = 0;
gfloat rotation;
GstGLFilter *filter = GST_GL_FILTER (stuff);
gint height = GST_VIDEO_INFO_HEIGHT (&filter->out_info);
guint texture = glass_filter->in_tex->tex_id;
- if (start_time == 0)
- start_time = get_time ();
+ if (glass_filter->start_time == 0)
+ glass_filter->start_time = get_time ();
else {
gint64 time_left =
- (glass_filter->timestamp / 1000) - (get_time () - start_time);
+ (glass_filter->timestamp / 1000) - (get_time () -
+ glass_filter->start_time);
time_left -= 1000000 / 25;
if (time_left > 2000) {
GST_LOG ("escape");
gst_gl_filter_glass_draw_background_gradient (glass_filter);
//Rotation
- if (start_time != 0) {
- gint64 time_passed = get_time () - start_time;
+ if (glass_filter->start_time != 0) {
+ gint64 time_passed = get_time () - glass_filter->start_time;
rotation = sin (time_passed / 1200000.0) * 45.0f;
} else {
rotation = 0.0f;
gint64 timestamp;
GstGLMemory *in_tex;
GstGLMemory *out_tex;
+ gint64 start_time;
};
struct _GstGLFilterGlassClass
mosaic->attr_position_loc = -1;
mosaic->attr_texture_loc = -1;
+ mosaic->xrot = 0.0;
+ mosaic->yrot = 0.0;
+ mosaic->zrot = 0.0;
}
static gboolean
GstGLFuncs *gl = GST_GL_BASE_MIXER (mixer)->context->gl_vtable;
GList *walk;
- static GLfloat xrot = 0;
- static GLfloat yrot = 0;
- static GLfloat zrot = 0;
-
const GLfloat matrix[] = {
0.5f, 0.0f, 0.0f, 0.0f,
0.0f, 0.5f, 0.0f, 0.0f,
}
gst_gl_shader_set_uniform_1i (mosaic->shader, "s_texture", 0);
- gst_gl_shader_set_uniform_1f (mosaic->shader, "xrot_degree", xrot);
- gst_gl_shader_set_uniform_1f (mosaic->shader, "yrot_degree", yrot);
- gst_gl_shader_set_uniform_1f (mosaic->shader, "zrot_degree", zrot);
+ gst_gl_shader_set_uniform_1f (mosaic->shader, "xrot_degree", mosaic->xrot);
+ gst_gl_shader_set_uniform_1f (mosaic->shader, "yrot_degree", mosaic->yrot);
+ gst_gl_shader_set_uniform_1f (mosaic->shader, "zrot_degree", mosaic->zrot);
gst_gl_shader_set_uniform_matrix_4fv (mosaic->shader, "u_matrix", 1,
GL_FALSE, matrix);
gst_gl_context_clear_shader (GST_GL_BASE_MIXER (mixer)->context);
- xrot += 0.6f;
- yrot += 0.4f;
- zrot += 0.8f;
+ mosaic->xrot += 0.6f;
+ mosaic->yrot += 0.4f;
+ mosaic->zrot += 0.8f;
return TRUE;
}
gint attr_position_loc;
gint attr_texture_loc;
GstGLMemory *out_tex;
+ GLfloat xrot, yrot, zrot;
};
struct _GstGLMosaicClass