static void gst_gl_bumper_reset (GstGLFilter * filter);
static gboolean gst_gl_bumper_init_shader (GstGLFilter * filter);
-static gboolean gst_gl_bumper_filter (GstGLFilter * filter,
- GstBuffer * inbuf, GstBuffer * outbuf);
+static gboolean gst_gl_bumper_filter_texture (GstGLFilter * filter,
+ guint in_tex, guint out_tex);
static void gst_gl_bumper_callback (gint width, gint height, guint texture,
gpointer stuff);
gobject_class->set_property = gst_gl_bumper_set_property;
gobject_class->get_property = gst_gl_bumper_get_property;
- GST_GL_FILTER_CLASS (klass)->filter = gst_gl_bumper_filter;
+ GST_GL_FILTER_CLASS (klass)->filter_texture = gst_gl_bumper_filter_texture;
GST_GL_FILTER_CLASS (klass)->display_init_cb = gst_gl_bumper_init_resources;
GST_GL_FILTER_CLASS (klass)->display_reset_cb = gst_gl_bumper_reset_resources;
GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_bumper_init_shader;
}
static gboolean
-gst_gl_bumper_filter (GstGLFilter * filter, GstBuffer * inbuf,
- GstBuffer * outbuf)
+gst_gl_bumper_filter_texture (GstGLFilter * filter, guint in_tex, guint out_tex)
{
- GstGLMeta *in_gl_meta, *out_gl_meta;
- GstVideoMeta *in_v_meta;
gpointer bumper_filter = GST_GL_BUMPER (filter);
- in_gl_meta = gst_buffer_get_gl_meta (inbuf);
- out_gl_meta = gst_buffer_get_gl_meta (outbuf);
- in_v_meta = gst_buffer_get_video_meta (inbuf);
-
//blocking call, use a FBO
- gst_gl_display_use_fbo (filter->display, filter->width, filter->height,
- filter->fbo, filter->depthbuffer, out_gl_meta->memory->tex_id,
- gst_gl_bumper_callback, in_v_meta->width, in_v_meta->height,
- in_gl_meta->memory->tex_id, 45,
- (gdouble) filter->width / (gdouble) filter->height, 0.1, 50,
+ gst_gl_display_use_fbo (filter->display,
+ GST_VIDEO_INFO_WIDTH (&filter->out_info),
+ GST_VIDEO_INFO_HEIGHT (&filter->out_info),
+ filter->fbo, filter->depthbuffer, out_tex, gst_gl_bumper_callback,
+ GST_VIDEO_INFO_WIDTH (&filter->in_info),
+ GST_VIDEO_INFO_HEIGHT (&filter->in_info),
+ in_tex, 45,
+ (gdouble) GST_VIDEO_INFO_WIDTH (&filter->out_info) /
+ (gdouble) GST_VIDEO_INFO_HEIGHT (&filter->out_info), 0.1, 50,
GST_GL_DISPLAY_PROJECTION_PERSPECTIVE, bumper_filter);
return TRUE;
static void gst_gl_differencematte_init_resources (GstGLFilter * filter);
static void gst_gl_differencematte_reset_resources (GstGLFilter * filter);
-static gboolean gst_gl_differencematte_filter (GstGLFilter * filter,
- GstBuffer * inbuf, GstBuffer * outbuf);
+static gboolean gst_gl_differencematte_filter_texture (GstGLFilter * filter,
+ guint in_tex, guint out_tex);
static gboolean gst_gl_differencematte_loader (GstGLFilter * filter);
glGenTextures (1, &differencematte->midtexture[i]);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, differencematte->midtexture[i]);
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
- filter->width, filter->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ GST_VIDEO_INFO_WIDTH (&filter->out_info),
+ GST_VIDEO_INFO_HEIGHT (&filter->out_info),
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
gobject_class->set_property = gst_gl_differencematte_set_property;
gobject_class->get_property = gst_gl_differencematte_get_property;
- GST_GL_FILTER_CLASS (klass)->filter = gst_gl_differencematte_filter;
+ GST_GL_FILTER_CLASS (klass)->filter_texture =
+ gst_gl_differencematte_filter_texture;
GST_GL_FILTER_CLASS (klass)->display_init_cb =
gst_gl_differencematte_init_gl_resources;
GST_GL_FILTER_CLASS (klass)->display_reset_cb =
glTexCoord2f (0.0, 0.0);
glVertex2f (-1.0, -1.0);
- glTexCoord2f ((gfloat) filter->width, 0.0);
+ glTexCoord2f ((gfloat) GST_VIDEO_INFO_WIDTH (&filter->out_info), 0.0);
glVertex2f (1.0, -1.0);
- glTexCoord2f ((gfloat) filter->width, (gfloat) filter->height);
+ glTexCoord2f ((gfloat) GST_VIDEO_INFO_WIDTH (&filter->out_info),
+ (gfloat) GST_VIDEO_INFO_HEIGHT (&filter->out_info));
glVertex2f (1.0, 1.0);
- glTexCoord2f (0.0, (gfloat) filter->height);
+ glTexCoord2f (0.0, (gfloat) GST_VIDEO_INFO_HEIGHT (&filter->out_info));
glVertex2f (-1.0, 1.0);
glEnd ();
glGenTextures (1, &differencematte->savedbgtexture);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, differencematte->savedbgtexture);
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
- filter->width, filter->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ GST_VIDEO_INFO_WIDTH (&filter->out_info),
+ GST_VIDEO_INFO_HEIGHT (&filter->out_info),
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
"base_height", (gfloat) differencematte->pbuf_height);
gst_gl_shader_set_uniform_1f (differencematte->shader[3],
- "final_width", (gfloat) filter->width);
+ "final_width", (gfloat) GST_VIDEO_INFO_WIDTH (&filter->out_info));
gst_gl_shader_set_uniform_1f (differencematte->shader[3],
- "final_height", (gfloat) filter->height);
+ "final_height", (gfloat) GST_VIDEO_INFO_HEIGHT (&filter->out_info));
glActiveTexture (GL_TEXTURE2);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
}
static gboolean
-gst_gl_differencematte_filter (GstGLFilter * filter, GstBuffer * inbuf,
- GstBuffer * outbuf)
+gst_gl_differencematte_filter_texture (GstGLFilter * filter, guint in_tex,
+ guint out_tex)
{
GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (filter);
- GstGLMeta *in_meta, *out_meta;
- in_meta = gst_buffer_get_gl_meta (inbuf);
- out_meta = gst_buffer_get_gl_meta (outbuf);
-
- if (!in_meta || !out_meta) {
- GST_ERROR ("A Buffer does not contain required GstGLMeta");
- return FALSE;
- }
-
- differencematte->intexture = in_meta->memory->tex_id;
+ differencematte->intexture = in_tex;
if (differencematte->bg_has_changed && (differencematte->location != NULL)) {
/* save current frame, needed to calculate difference between
* this frame and next ones */
- gst_gl_filter_render_to_target (filter, in_meta->memory->tex_id,
+ gst_gl_filter_render_to_target (filter, in_tex,
differencematte->savedbgtexture,
gst_gl_differencematte_save_texture, differencematte);
}
if (differencematte->savedbgtexture != 0) {
- gst_gl_filter_render_to_target (filter,
- in_meta->memory->tex_id,
- differencematte->midtexture[0],
- gst_gl_differencematte_diff, differencematte);
- gst_gl_filter_render_to_target (filter,
- differencematte->midtexture[0],
- differencematte->midtexture[1],
- gst_gl_differencematte_hblur, differencematte);
- gst_gl_filter_render_to_target (filter,
- differencematte->midtexture[1],
- differencematte->midtexture[2],
- gst_gl_differencematte_vblur, differencematte);
- gst_gl_filter_render_to_target (filter,
- in_meta->memory->tex_id,
- out_meta->memory->tex_id, gst_gl_differencematte_interp,
+ gst_gl_filter_render_to_target (filter, in_tex,
+ differencematte->midtexture[0], gst_gl_differencematte_diff,
differencematte);
- } else {
- gst_gl_filter_render_to_target (filter,
- in_meta->memory->tex_id,
- out_meta->memory->tex_id, gst_gl_differencematte_identity,
+ gst_gl_filter_render_to_target (filter, differencematte->midtexture[0],
+ differencematte->midtexture[1], gst_gl_differencematte_hblur,
+ differencematte);
+ gst_gl_filter_render_to_target (filter, differencematte->midtexture[1],
+ differencematte->midtexture[2], gst_gl_differencematte_vblur,
differencematte);
+ gst_gl_filter_render_to_target (filter, in_tex, out_tex,
+ gst_gl_differencematte_interp, differencematte);
+ } else {
+ gst_gl_filter_render_to_target (filter, in_tex, out_tex,
+ gst_gl_differencematte_identity, differencematte);
}
return TRUE;
static void gst_gl_effects_ghash_func_clean (gpointer key, gpointer value,
gpointer data);
-static gboolean gst_gl_effects_filter (GstGLFilter * filter,
- GstBuffer * inbuf, GstBuffer * outbuf);
+static gboolean gst_gl_effects_filter_texture (GstGLFilter * filter,
+ guint in_tex, guint out_tex);
/* dont' forget to edit the following when a new effect is added */
typedef enum
glGenTextures (1, &effects->midtexture[i]);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, effects->midtexture[i]);
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
- filter->width, filter->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ GST_VIDEO_INFO_WIDTH (&filter->out_info),
+ GST_VIDEO_INFO_HEIGHT (&filter->out_info),
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
gobject_class->set_property = gst_gl_effects_set_property;
gobject_class->get_property = gst_gl_effects_get_property;
- GST_GL_FILTER_CLASS (klass)->filter = gst_gl_effects_filter;
+ GST_GL_FILTER_CLASS (klass)->filter_texture = gst_gl_effects_filter_texture;
GST_GL_FILTER_CLASS (klass)->display_init_cb =
gst_gl_effects_init_gl_resources;
GST_GL_FILTER_CLASS (klass)->display_reset_cb =
glTexCoord2f (0.0, 0.0);
glVertex2f (-1.0, -1.0);
- glTexCoord2f ((gfloat) filter->width, 0.0);
+ glTexCoord2f ((gfloat) GST_VIDEO_INFO_WIDTH (&filter->out_info), 0.0);
glVertex2f (1.0, -1.0);
- glTexCoord2f ((gfloat) filter->width, (gfloat) filter->height);
+ glTexCoord2f ((gfloat) GST_VIDEO_INFO_WIDTH (&filter->out_info),
+ (gfloat) GST_VIDEO_INFO_HEIGHT (&filter->out_info));
glVertex2f (1.0, 1.0);
- glTexCoord2f (0.0, (gfloat) filter->height);
+ glTexCoord2f (0.0, (gfloat) GST_VIDEO_INFO_HEIGHT (&filter->out_info));
glVertex2f (-1.0, 1.0);
glEnd ();
}
static gboolean
-gst_gl_effects_filter (GstGLFilter * filter, GstBuffer * inbuf,
- GstBuffer * outbuf)
+gst_gl_effects_filter_texture (GstGLFilter * filter, guint in_tex,
+ guint out_tex)
{
GstGLEffects *effects = GST_GL_EFFECTS (filter);
- GstGLMeta *in_gl_meta, *out_gl_meta;
- in_gl_meta = gst_buffer_get_gl_meta (inbuf);
- out_gl_meta = gst_buffer_get_gl_meta (outbuf);
-
- if (!in_gl_meta || !out_gl_meta) {
- GST_ERROR ("buffers do not contain required GstGLMeta");
- return FALSE;
- }
-
- effects->intexture = in_gl_meta->memory->tex_id;
- effects->outtexture = out_gl_meta->memory->tex_id;
+ effects->intexture = in_tex;
+ effects->outtexture = out_tex;
if (effects->horizontal_swap == TRUE)
gst_gl_display_thread_add (filter->display, set_horizontal_swap, effects);
static gboolean gst_gl_filter_app_set_caps (GstGLFilter * filter,
GstCaps * incaps, GstCaps * outcaps);
-static gboolean gst_gl_filter_app_filter (GstGLFilter * filter,
- GstBuffer * inbuf, GstBuffer * outbuf);
+static gboolean gst_gl_filter_app_filter_texture (GstGLFilter * filter,
+ guint in_tex, guint out_tex);
static void gst_gl_filter_app_callback (gint width, gint height, guint texture,
gpointer stuff);
gobject_class->get_property = gst_gl_filter_app_get_property;
GST_GL_FILTER_CLASS (klass)->set_caps = gst_gl_filter_app_set_caps;
- GST_GL_FILTER_CLASS (klass)->filter = gst_gl_filter_app_filter;
+ GST_GL_FILTER_CLASS (klass)->filter_texture =
+ gst_gl_filter_app_filter_texture;
g_object_class_install_property (gobject_class, PROP_CLIENT_RESHAPE_CALLBACK,
g_param_spec_pointer ("client-reshape-callback",
}
static gboolean
-gst_gl_filter_app_filter (GstGLFilter * filter, GstBuffer * inbuf,
- GstBuffer * outbuf)
+gst_gl_filter_app_filter_texture (GstGLFilter * filter, guint in_tex,
+ guint out_tex)
{
GstGLFilterApp *app_filter = GST_GL_FILTER_APP (filter);
- GstGLMeta *in_meta, *out_meta;
- GstVideoMeta *in_v_meta;
-
- in_meta = gst_buffer_get_gl_meta (inbuf);
- out_meta = gst_buffer_get_gl_meta (outbuf);
- in_v_meta = gst_buffer_get_video_meta (inbuf);
-
- if (!in_meta || !out_meta || !in_v_meta) {
- GST_ERROR ("A Buffer does not contain required GstGLMeta or GstVideoMeta");
- return FALSE;
- }
if (app_filter->clientDrawCallback) {
//blocking call, use a FBO
- gst_gl_display_use_fbo (filter->display, filter->width, filter->height,
- filter->fbo, filter->depthbuffer, out_meta->memory->tex_id,
- app_filter->clientDrawCallback, in_v_meta->width, in_v_meta->height,
- in_meta->memory->tex_id, 45,
- (gfloat) filter->width / (gfloat) filter->height,
+ gst_gl_display_use_fbo (filter->display,
+ GST_VIDEO_INFO_WIDTH (&filter->out_info),
+ GST_VIDEO_INFO_HEIGHT (&filter->out_info),
+ filter->fbo, filter->depthbuffer, out_tex,
+ app_filter->clientDrawCallback,
+ GST_VIDEO_INFO_WIDTH (&filter->in_info),
+ GST_VIDEO_INFO_HEIGHT (&filter->in_info),
+ in_tex, 45,
+ (gfloat) GST_VIDEO_INFO_WIDTH (&filter->out_info) /
+ (gfloat) GST_VIDEO_INFO_HEIGHT (&filter->out_info),
0.1, 100, GST_GL_DISPLAY_PROJECTION_PERSPECTIVE,
app_filter->client_data);
}
//default
else {
//blocking call, use a FBO
- gst_gl_display_use_fbo (filter->display, filter->width, filter->height,
- filter->fbo, filter->depthbuffer, out_meta->memory->tex_id,
- gst_gl_filter_app_callback, in_v_meta->width, in_v_meta->height,
- in_meta->memory->tex_id, 0, filter->width, 0, filter->height,
- GST_GL_DISPLAY_PROJECTION_ORTHO2D, NULL);
+ gst_gl_filter_render_to_target (filter, in_tex, out_tex,
+ gst_gl_filter_app_callback, NULL);
}
return TRUE;
static void gst_gl_filter_filterblur_reset (GstGLFilter * filter);
static gboolean gst_gl_filterblur_init_shader (GstGLFilter * filter);
-static gboolean gst_gl_filterblur_filter (GstGLFilter * filter,
- GstBuffer * inbuf, GstBuffer * outbuf);
+static gboolean gst_gl_filterblur_filter_texture (GstGLFilter * filter,
+ guint in_tex, guint out_tex);
static void gst_gl_filterblur_hcallback (gint width, gint height, guint texture,
gpointer stuff);
static void gst_gl_filterblur_vcallback (gint width, gint height, guint texture,
glGenTextures (1, &filterblur->midtexture);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, filterblur->midtexture);
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
- filter->width, filter->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ GST_VIDEO_INFO_WIDTH (&filter->out_info),
+ GST_VIDEO_INFO_HEIGHT (&filter->out_info),
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
"Filter/Effect", "Blur with 9x9 separable convolution",
"Filippo Argiolas <filippo.argiolas@gmail.com>");
- GST_GL_FILTER_CLASS (klass)->filter = gst_gl_filterblur_filter;
+ GST_GL_FILTER_CLASS (klass)->filter_texture =
+ gst_gl_filterblur_filter_texture;
GST_GL_FILTER_CLASS (klass)->display_init_cb =
gst_gl_filterblur_init_resources;
GST_GL_FILTER_CLASS (klass)->display_reset_cb =
}
static gboolean
-gst_gl_filterblur_filter (GstGLFilter * filter, GstBuffer * inbuf,
- GstBuffer * outbuf)
+gst_gl_filterblur_filter_texture (GstGLFilter * filter, guint in_tex,
+ guint out_tex)
{
GstGLFilterBlur *filterblur = GST_GL_FILTERBLUR (filter);
- GstGLMeta *in_meta, *out_meta;
- in_meta = gst_buffer_get_gl_meta (inbuf);
- out_meta = gst_buffer_get_gl_meta (outbuf);
-
- if (!in_meta || !out_meta) {
- GST_WARNING ("A buffer did not contain required GstGLMeta");
- return FALSE;
- }
-
- gst_gl_filter_render_to_target (filter, in_meta->memory->tex_id,
+ gst_gl_filter_render_to_target (filter, in_tex,
filterblur->midtexture, gst_gl_filterblur_hcallback, filterblur);
gst_gl_filter_render_to_target (filter, filterblur->midtexture,
- out_meta->memory->tex_id, gst_gl_filterblur_vcallback, filterblur);
+ out_tex, gst_gl_filterblur_vcallback, filterblur);
return TRUE;
}
static void gst_gl_filter_cube_reset (GstGLFilter * filter);
static gboolean gst_gl_filter_cube_init_shader (GstGLFilter * filter);
#endif
-static gboolean gst_gl_filter_cube_filter (GstGLFilter * filter,
- GstBuffer * inbuf, GstBuffer * outbuf);
+static gboolean gst_gl_filter_cube_filter_texture (GstGLFilter * filter,
+ guint in_tex, guint out_tex);
static void gst_gl_filter_cube_callback (gint width, gint height, guint texture,
gpointer stuff);
GST_GL_FILTER_CLASS (klass)->onReset = gst_gl_filter_cube_reset;
#endif
GST_GL_FILTER_CLASS (klass)->set_caps = gst_gl_filter_cube_set_caps;
- GST_GL_FILTER_CLASS (klass)->filter = gst_gl_filter_cube_filter;
+ GST_GL_FILTER_CLASS (klass)->filter_texture =
+ gst_gl_filter_cube_filter_texture;
g_object_class_install_property (gobject_class, PROP_RED,
g_param_spec_float ("red", "Red", "Background red color",
GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (filter);
if (cube_filter->aspect == 0)
- cube_filter->aspect = (gdouble) filter->width / (gdouble) filter->height;
+ cube_filter->aspect = (gdouble) GST_VIDEO_INFO_WIDTH (&filter->out_info) /
+ (gdouble) GST_VIDEO_INFO_HEIGHT (&filter->out_info);
return TRUE;
}
#endif
static gboolean
-gst_gl_filter_cube_filter (GstGLFilter * filter, GstBuffer * inbuf,
- GstBuffer * outbuf)
+gst_gl_filter_cube_filter_texture (GstGLFilter * filter, guint in_tex,
+ guint out_tex)
{
GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (filter);
- GstGLMeta *in_meta, *out_meta;
- GstVideoMeta *in_v_meta;
- in_meta = gst_buffer_get_gl_meta (inbuf);
- out_meta = gst_buffer_get_gl_meta (outbuf);
- in_v_meta = gst_buffer_get_video_meta (inbuf);
-
- if (!in_meta || !in_v_meta || !out_meta) {
- GST_WARNING ("A buffer does not contain required GstGLMeta"
- " or GstVideoMeta");
- return FALSE;
- }
//blocking call, use a FBO
- gst_gl_display_use_fbo (filter->display, filter->width, filter->height,
- filter->fbo, filter->depthbuffer, out_meta->memory->tex_id,
- gst_gl_filter_cube_callback, in_v_meta->width, in_v_meta->height,
- in_meta->memory->tex_id, cube_filter->fovy, cube_filter->aspect,
+ gst_gl_display_use_fbo (filter->display,
+ GST_VIDEO_INFO_WIDTH (&filter->out_info),
+ GST_VIDEO_INFO_HEIGHT (&filter->out_info),
+ filter->fbo, filter->depthbuffer, out_tex,
+ gst_gl_filter_cube_callback,
+ GST_VIDEO_INFO_WIDTH (&filter->in_info),
+ GST_VIDEO_INFO_HEIGHT (&filter->in_info),
+ in_tex, cube_filter->fovy, cube_filter->aspect,
cube_filter->znear, cube_filter->zfar,
GST_GL_DISPLAY_PROJECTION_PERSPECTIVE, (gpointer) cube_filter);
static void gst_gl_filter_glass_reset (GstGLFilter * filter);
static gboolean gst_gl_filter_glass_init_shader (GstGLFilter * filter);
-static gboolean gst_gl_filter_glass_filter (GstGLFilter * filter,
- GstBuffer * inbuf, GstBuffer * outbuf);
+static gboolean gst_gl_filter_glass_filter_texture (GstGLFilter * filter,
+ guint in_tex, guint out_tex);
static void gst_gl_filter_glass_draw_background_gradient ();
static void gst_gl_filter_glass_draw_video_plane (GstGLFilter * filter,
"Filter/Effect", "Glass Filter",
"Julien Isorce <julien.isorce@gmail.com>");
- GST_GL_FILTER_CLASS (klass)->filter = gst_gl_filter_glass_filter;
+ GST_GL_FILTER_CLASS (klass)->filter_texture =
+ gst_gl_filter_glass_filter_texture;
GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_filter_glass_init_shader;
GST_GL_FILTER_CLASS (klass)->onReset = gst_gl_filter_glass_reset;
}
}
static gboolean
-gst_gl_filter_glass_filter (GstGLFilter * filter, GstBuffer * inbuf,
- GstBuffer * outbuf)
+gst_gl_filter_glass_filter_texture (GstGLFilter * filter, guint in_tex,
+ guint out_tex)
{
gpointer glass_filter = GST_GL_FILTER_GLASS (filter);
- GstGLMeta *in_meta, *out_meta;
- GstVideoMeta *in_v_meta;
- GST_GL_FILTER_GLASS (glass_filter)->timestamp = GST_BUFFER_TIMESTAMP (inbuf);
-
- in_meta = gst_buffer_get_gl_meta (inbuf);
- out_meta = gst_buffer_get_gl_meta (outbuf);
- in_v_meta = gst_buffer_get_video_meta (inbuf);
-
- if (!in_meta || !out_meta || !in_v_meta) {
- GST_WARNING ("A buffer does not contain required GstGLMeta "
- "or GstVideoMeta");
- return FALSE;
- }
//blocking call, use a FBO
- gst_gl_display_use_fbo (filter->display, filter->width, filter->height,
- filter->fbo, filter->depthbuffer, out_meta->memory->tex_id,
- gst_gl_filter_glass_callback, in_v_meta->width, in_v_meta->height,
- in_meta->memory->tex_id, 80,
- (gdouble) filter->width / (gdouble) filter->height, 1.0, 5000.0,
+ gst_gl_display_use_fbo (filter->display,
+ GST_VIDEO_INFO_WIDTH (&filter->out_info),
+ GST_VIDEO_INFO_HEIGHT (&filter->out_info),
+ filter->fbo, filter->depthbuffer, out_tex,
+ gst_gl_filter_glass_callback,
+ GST_VIDEO_INFO_WIDTH (&filter->in_info),
+ GST_VIDEO_INFO_HEIGHT (&filter->in_info),
+ in_tex, 80, (gdouble) GST_VIDEO_INFO_WIDTH (&filter->out_info) /
+ (gdouble) GST_VIDEO_INFO_HEIGHT (&filter->out_info), 1.0, 5000.0,
GST_GL_DISPLAY_PROJECTION_PERSPECTIVE, (gpointer) glass_filter);
return TRUE;
static void gst_gl_filter_laplacian_reset (GstGLFilter * filter);
static gboolean gst_gl_filter_laplacian_init_shader (GstGLFilter * filter);
-static gboolean gst_gl_filter_laplacian_filter (GstGLFilter * filter,
- GstBuffer * inbuf, GstBuffer * outbuf);
+static gboolean gst_gl_filter_laplacian_filter_texture (GstGLFilter * filter,
+ guint in_tex, guint out_tex);
static void gst_gl_filter_laplacian_callback (gint width, gint height,
guint texture, gpointer stuff);
"Laplacian Convolution Demo Filter",
"Filippo Argiolas <filippo.argiolas@gmail.com>");
- GST_GL_FILTER_CLASS (klass)->filter = gst_gl_filter_laplacian_filter;
+ GST_GL_FILTER_CLASS (klass)->filter_texture =
+ gst_gl_filter_laplacian_filter_texture;
GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_filter_laplacian_init_shader;
GST_GL_FILTER_CLASS (klass)->onReset = gst_gl_filter_laplacian_reset;
}
}
static gboolean
-gst_gl_filter_laplacian_filter (GstGLFilter * filter, GstBuffer * inbuf,
- GstBuffer * outbuf)
+gst_gl_filter_laplacian_filter_texture (GstGLFilter * filter, guint in_tex,
+ guint out_tex)
{
gpointer laplacian_filter = GST_GL_FILTER_LAPLACIAN (filter);
- GstGLMeta *in_meta, *out_meta;
- GstVideoMeta *in_v_meta;
- in_meta = gst_buffer_get_gl_meta (inbuf);
- out_meta = gst_buffer_get_gl_meta (outbuf);
- in_v_meta = gst_buffer_get_video_meta (inbuf);
- if (!in_meta || !out_meta || !in_v_meta) {
- GST_WARNING ("A buffer does not contain required GstGLMeta"
- " or GstVideoMeta");
- return FALSE;
- }
//blocking call, use a FBO
- gst_gl_display_use_fbo (filter->display, filter->width, filter->height,
- filter->fbo, filter->depthbuffer, out_meta->memory->tex_id,
- gst_gl_filter_laplacian_callback, in_v_meta->width, in_v_meta->height,
- in_meta->memory->tex_id, 0, filter->width, 0, filter->height,
- GST_GL_DISPLAY_PROJECTION_ORTHO2D, laplacian_filter);
+ gst_gl_filter_render_to_target (filter, in_tex, out_tex,
+ gst_gl_filter_laplacian_callback, laplacian_filter);
return TRUE;
}
static void gst_gl_filter_reflected_screen_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec);
-static gboolean gst_gl_filter_reflected_screen_filter (GstGLFilter * filter,
- GstBuffer * inbuf, GstBuffer * outbuf);
+static gboolean gst_gl_filter_reflected_screen_filter_texture (GstGLFilter *
+ filter, guint in_tex, guint out_tex);
static void gst_gl_filter_reflected_screen_draw_background ();
static void gst_gl_filter_reflected_screen_draw_floor ();
gobject_class->set_property = gst_gl_filter_reflected_screen_set_property;
gobject_class->get_property = gst_gl_filter_reflected_screen_get_property;
- GST_GL_FILTER_CLASS (klass)->filter = gst_gl_filter_reflected_screen_filter;
+ GST_GL_FILTER_CLASS (klass)->filter_texture =
+ gst_gl_filter_reflected_screen_filter_texture;
g_object_class_install_property (gobject_class, PROP_ACTIVE_GRAPHIC_MODE,
g_param_spec_boolean ("active-graphic-mode",
}
static gboolean
-gst_gl_filter_reflected_screen_filter (GstGLFilter * filter,
- GstBuffer * inbuf, GstBuffer * outbuf)
+gst_gl_filter_reflected_screen_filter_texture (GstGLFilter * filter,
+ guint in_tex, guint out_tex)
{
GstGLFilterReflectedScreen *reflected_screen_filter =
GST_GL_FILTER_REFLECTED_SCREEN (filter);
- GstGLMeta *in_meta, *out_meta;
- GstVideoMeta *in_v_meta;
- if (reflected_screen_filter->aspect == 0.0)
- reflected_screen_filter->aspect =
- (gfloat) (filter->width) / (gfloat) (filter->height);
-
- in_meta = gst_buffer_get_gl_meta (inbuf);
- out_meta = gst_buffer_get_gl_meta (outbuf);
- in_v_meta = gst_buffer_get_video_meta (inbuf);
-
- if (!in_meta || !out_meta || !in_v_meta) {
- GST_WARNING ("A buffer does not contain required GstGLMeta or"
- " GstVideoMeta");
- return FALSE;
- }
//blocking call, use a FBO
- gst_gl_display_use_fbo (filter->display, filter->width, filter->height,
- filter->fbo, filter->depthbuffer, out_meta->memory->tex_id,
- gst_gl_filter_reflected_screen_callback, in_v_meta->width,
- in_v_meta->height, in_meta->memory->tex_id,
+ gst_gl_display_use_fbo (filter->display,
+ GST_VIDEO_INFO_WIDTH (&filter->out_info),
+ GST_VIDEO_INFO_HEIGHT (&filter->out_info),
+ filter->fbo, filter->depthbuffer, out_tex,
+ gst_gl_filter_reflected_screen_callback,
+ GST_VIDEO_INFO_WIDTH (&filter->in_info),
+ GST_VIDEO_INFO_HEIGHT (&filter->in_info), in_tex,
reflected_screen_filter->fovy, reflected_screen_filter->aspect,
reflected_screen_filter->znear, reflected_screen_filter->zfar,
GST_GL_DISPLAY_PROJECTION_PERSPECTIVE,
static void gst_gl_filtershader_load_shader (char *filename, char **storage);
static void gst_gl_filtershader_load_variables (char *filename, char **storage);
static gboolean gst_gl_filtershader_init_shader (GstGLFilter * filter);
-static gboolean gst_gl_filtershader_filter (GstGLFilter * filter,
- GstBuffer * inbuf, GstBuffer * outbuf);
+static gboolean gst_gl_filtershader_filter_texture (GstGLFilter * filter,
+ guint in_tex, guint out_tex);
static void gst_gl_filtershader_hcallback (gint width, gint height,
guint texture, gpointer stuff);
gst_gl_filtershader_init_resources (GstGLFilter * filter)
{
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
- filter->width, filter->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ GST_VIDEO_INFO_WIDTH (&filter->out_info),
+ GST_VIDEO_INFO_HEIGHT (&filter->out_info),
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
"OpenGL fragment shader filter", "Filter/Effect",
"Load GLSL fragment shader from file", "<luc.deschenaux@freesurf.ch>");
- GST_GL_FILTER_CLASS (klass)->filter = gst_gl_filtershader_filter;
+ GST_GL_FILTER_CLASS (klass)->filter_texture =
+ gst_gl_filtershader_filter_texture;
GST_GL_FILTER_CLASS (klass)->display_init_cb =
gst_gl_filtershader_init_resources;
GST_GL_FILTER_CLASS (klass)->display_reset_cb =
gst_gl_shadervariables_parse (shader, variables, 0);
}
-
static gboolean
gst_gl_filtershader_init_shader (GstGLFilter * filter)
{
}
static gboolean
-gst_gl_filtershader_filter (GstGLFilter * filter, GstBuffer * inbuf,
- GstBuffer * outbuf)
+gst_gl_filtershader_filter_texture (GstGLFilter * filter, guint in_tex,
+ guint out_tex)
{
GstGLFilterShader *filtershader = GST_GL_FILTERSHADER (filter);
- GstGLMeta *in_meta, *out_meta;
-
- in_meta = gst_buffer_get_gl_meta (inbuf);
- out_meta = gst_buffer_get_gl_meta (outbuf);
-
- if (!in_meta || !out_meta) {
- GST_ERROR ("A buffer does not contain required GstGLMeta");
- return FALSE;
- }
-
- if (!filtershader->compiled) {
- gst_gl_filtershader_init_shader (filter);
- }
- gst_gl_filter_render_to_target (filter, in_meta->memory->tex_id,
- out_meta->memory->tex_id, gst_gl_filtershader_hcallback, filtershader);
+ gst_gl_filter_render_to_target (filter, in_tex, out_tex,
+ gst_gl_filtershader_hcallback, filtershader);
return TRUE;
}
static void gst_gl_filter_filtersobel_reset (GstGLFilter * filter);
static gboolean gst_gl_filtersobel_init_shader (GstGLFilter * filter);
-static gboolean gst_gl_filtersobel_filter (GstGLFilter * filter,
- GstBuffer * inbuf, GstBuffer * outbuf);
+static gboolean gst_gl_filtersobel_filter_texture (GstGLFilter * filter,
+ guint in_tex, guint out_tex);
static void gst_gl_filtersobel_length (gint width, gint height, guint texture,
gpointer stuff);
glGenTextures (1, &filtersobel->midtexture[i]);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, filtersobel->midtexture[i]);
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
- filter->width, filter->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ GST_VIDEO_INFO_WIDTH (&filter->out_info),
+ GST_VIDEO_INFO_HEIGHT (&filter->out_info),
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
gobject_class->set_property = gst_gl_filtersobel_set_property;
gobject_class->get_property = gst_gl_filtersobel_get_property;
- GST_GL_FILTER_CLASS (klass)->filter = gst_gl_filtersobel_filter;
+ GST_GL_FILTER_CLASS (klass)->filter_texture =
+ gst_gl_filtersobel_filter_texture;
GST_GL_FILTER_CLASS (klass)->display_init_cb =
gst_gl_filtersobel_init_resources;
GST_GL_FILTER_CLASS (klass)->display_reset_cb =
}
static gboolean
-gst_gl_filtersobel_filter (GstGLFilter * filter, GstBuffer * inbuf,
- GstBuffer * outbuf)
+gst_gl_filtersobel_filter_texture (GstGLFilter * filter, guint in_tex,
+ guint out_tex)
{
GstGLFilterSobel *filtersobel = GST_GL_FILTERSOBEL (filter);
- GstGLMeta *in_meta, *out_meta;
- in_meta = gst_buffer_get_gl_meta (inbuf);
- out_meta = gst_buffer_get_gl_meta (outbuf);
- if (!in_meta || !out_meta) {
- GST_WARNING ("A buffer does not contain required GstGLMeta");
- return FALSE;
- }
-
- gst_gl_filter_render_to_target_with_shader (filter, in_meta->memory->tex_id,
+ gst_gl_filter_render_to_target_with_shader (filter, in_tex,
filtersobel->midtexture[0], filtersobel->desat);
gst_gl_filter_render_to_target_with_shader (filter,
filtersobel->midtexture[0], filtersobel->midtexture[1],
filtersobel->midtexture[1], filtersobel->midtexture[0],
filtersobel->vconv);
gst_gl_filter_render_to_target (filter, filtersobel->midtexture[0],
- out_meta->memory->tex_id, gst_gl_filtersobel_length, filtersobel);
+ out_tex, gst_gl_filtersobel_length, filtersobel);
return TRUE;
}
static void gst_gl_overlay_init_resources (GstGLFilter * filter);
static void gst_gl_overlay_reset_resources (GstGLFilter * filter);
-static gboolean gst_gl_overlay_filter (GstGLFilter * filter,
- GstBuffer * inbuf, GstBuffer * outbuf);
+static gboolean gst_gl_overlay_filter_texture (GstGLFilter * filter,
+ guint in_tex, guint out_tex);
static gint gst_gl_overlay_load_png (GstGLFilter * filter);
static gint gst_gl_overlay_load_jpeg (GstGLFilter * filter);
gobject_class->get_property = gst_gl_overlay_get_property;
GST_GL_FILTER_CLASS (klass)->set_caps = gst_gl_overlay_set_caps;
- GST_GL_FILTER_CLASS (klass)->filter = gst_gl_overlay_filter;
+ GST_GL_FILTER_CLASS (klass)->filter_texture = gst_gl_overlay_filter_texture;
GST_GL_FILTER_CLASS (klass)->display_init_cb =
gst_gl_overlay_init_gl_resources;
GST_GL_FILTER_CLASS (klass)->display_reset_cb =
}
static gboolean
-gst_gl_overlay_filter (GstGLFilter * filter, GstBuffer * inbuf,
- GstBuffer * outbuf)
+gst_gl_overlay_filter_texture (GstGLFilter * filter, guint in_tex,
+ guint out_tex)
{
GstGLOverlay *overlay = GST_GL_OVERLAY (filter);
- GstGLMeta *in_meta, *out_meta;
-
- in_meta = gst_buffer_get_gl_meta (inbuf);
- out_meta = gst_buffer_get_gl_meta (outbuf);
-
- if (!in_meta || !out_meta) {
- GST_ERROR ("A Buffer does not contain required GstGLMeta");
- return FALSE;
- }
if (overlay->pbuf_has_changed && (overlay->location != NULL)) {
if ((overlay->type_file = gst_gl_overlay_load_png (filter)) == 0)
overlay->pbuf_has_changed = FALSE;
}
- gst_gl_filter_render_to_target (filter, in_meta->memory->tex_id,
- out_meta->memory->tex_id, gst_gl_overlay_callback, overlay);
+ gst_gl_filter_render_to_target (filter, in_tex, out_tex,
+ gst_gl_overlay_callback, overlay);
return TRUE;
}