Commit cdbb261d authored by Tim-Philipp Müller's avatar Tim-Philipp Müller 🐠

Move OpenGL library and plugin from -bad

Merge branch 'opengl-move'

https://bugzilla.gnome.org/show_bug.cgi?id=754094
parents 5affe09c 8f0bf85c
plugin_LTLIBRARIES = libgstopengl.la
libgstopengl_la_SOURCES = \
gstopengl.c \
gstglbasemixer.c \
gstgluploadelement.c \
gstgldownloadelement.c \
gstglcolorconvertelement.c \
gstglfilterbin.c \
gstglmixerbin.c \
gstglsinkbin.c \
gstglsrcbin.c \
gstglimagesink.c \
gstglfiltercube.c \
gstgleffects.c \
effects/gstgleffectscurves.c \
effects/gstgleffectssources.c \
effects/gstgleffectidentity.c \
effects/gstgleffectmirror.c \
effects/gstgleffectsqueeze.c \
effects/gstgleffectstretch.c \
effects/gstgleffectfisheye.c \
effects/gstgleffecttwirl.c \
effects/gstgleffectbulge.c \
effects/gstgleffecttunnel.c \
effects/gstgleffectsquare.c \
effects/gstgleffectlumatocurve.c \
effects/gstgleffectrgbtocurve.c \
effects/gstgleffectsin.c \
effects/gstgleffectxray.c \
effects/gstgleffectglow.c \
effects/gstgleffectblur.c \
effects/gstgleffectsobel.c \
effects/gstgleffectlaplacian.c \
gstglcolorscale.c \
gstglcolorbalance.c \
gstglmixer.c \
gstglvideomixer.c \
gstglfiltershader.c \
gstglfilterapp.c \
gstglviewconvert.c \
gstglstereosplit.c \
gstgldeinterlace.c \
gstglstereomix.c \
gltestsrc.c \
gstgltestsrc.c \
gstglutils.c
noinst_HEADERS = \
gstglbasemixer.h \
gstgluploadelement.h \
gstgldownloadelement.h \
gstglcolorconvertelement.h \
gstglfilterbin.h \
gstglmixerbin.h \
gstglsinkbin.h \
gstglsrcbin.h \
gstglimagesink.h \
gstglfiltercube.h \
gstgleffects.h \
effects/gstgleffectssources.h \
gstglcolorscale.h \
gstglcolorbalance.h \
gstglmixer.h \
gstglvideomixer.h \
gstglfiltershader.h \
gstglfilterapp.h \
gstglstereosplit.h \
gstglstereomix.h \
gstgldeinterlace.h \
gstglviewconvert.h \
gltestsrc.h \
gstgltestsrc.h \
gstglutils.h
# full opengl required
if USE_OPENGL
libgstopengl_la_SOURCES += \
gstglfilterglass.c \
gstglmosaic.c
noinst_HEADERS += \
gstglfilterglass.h \
gstglmosaic.h \
effects/gstgleffectscurves.h \
effects/gstgleffectlumatocurve.h
if HAVE_PNG
libgstopengl_la_SOURCES += \
gstgldifferencematte.c
noinst_HEADERS += \
gstgldifferencematte.h
endif
endif
if HAVE_GRAPHENE
libgstopengl_la_SOURCES += \
gstgltransformation.c \
gstglvideoflip.c
noinst_HEADERS += \
gstgltransformation.h \
gstglvideoflip.h
endif
if HAVE_JPEG
if HAVE_PNG
libgstopengl_la_SOURCES += \
gstgloverlay.c
noinst_HEADERS += \
gstgloverlay.h
endif
endif
if HAVE_WINDOW_COCOA
libgstopengl_la_SOURCES += \
caopengllayersink.m
noinst_HEADERS += \
caopengllayersink.h
endif
libgstopengl_la_OBJCFLAGS = \
-I$(top_srcdir)/gst-libs \
-I$(top_builddir)/gst-libs \
-fobjc-arc \
$(GST_OBJCFLAGS) \
$(GST_BASE_CFLAGS) \
$(GST_PLUGINS_BASE_CFLAGS) \
$(GST_CONTROLLER_CFLAGS) \
$(GL_OBJCFLAGS)
# check order of CFLAGS and LIBS, shouldn't the order be the other way around
# (like in AM_CFLAGS)?
libgstopengl_la_CFLAGS = \
-I$(top_srcdir)/gst-libs \
-I$(top_builddir)/gst-libs \
$(GST_CFLAGS) \
$(GST_BASE_CFLAGS) \
$(GST_PLUGINS_BASE_CFLAGS) \
$(GST_CONTROLLER_CFLAGS) \
$(GL_CFLAGS) \
$(LIBPNG_CFLAGS) \
$(GRAPHENE_CFLAGS)
libgstopengl_la_LIBADD = \
$(top_builddir)/gst-libs/gst/gl/libgstgl-$(GST_API_VERSION).la \
$(top_builddir)/gst-libs/gst/video/libgstbadvideo-$(GST_API_VERSION).la \
$(GST_BASE_LIBS) \
$(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_API_VERSION) \
-lgstpbutils-$(GST_API_VERSION) \
$(GST_CONTROLLER_LIBS) \
$(GL_LIBS) \
$(LIBPNG_LIBS) \
$(JPEG_LIBS) \
$(LIBM) \
$(GRAPHENE_LIBS)
libgstopengl_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstopengl_la_LIBTOOLFLAGS = --tag=CC
/*
* GStreamer
* Copyright (C) 2015 Matthew Waters <matthew@centricular.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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __CA_OPENGL_LAYER_SINK_H__
#define __CA_OPENGL_LAYER_SINK_H__
#include <gst/gst.h>
#include <gst/video/gstvideosink.h>
#include <gst/video/video.h>
#include <gst/gl/gl.h>
#include <gst/gl/gstglfuncs.h>
#include <gst/gl/cocoa/gstglcaopengllayer.h>
G_BEGIN_DECLS
#define GST_TYPE_CA_OPENGL_LAYER_SINK \
(gst_ca_opengl_layer_sink_get_type())
#define GST_CA_OPENGL_LAYER_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CA_OPENGL_LAYER_SINK,GstCAOpenGLLayerSink))
#define GST_CA_OPENGL_LAYER_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CA_OPENGL_LAYER_SINK,GstCAOpenGLLayerSinkClass))
#define GST_IS_CA_OPENGL_LAYER_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CA_OPENGL_LAYER_SINK))
#define GST_IS_CA_OPENGL_LAYER_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CA_OPENGL_LAYER_SINK))
typedef struct _GstCAOpenGLLayerSink GstCAOpenGLLayerSink;
typedef struct _GstCAOpenGLLayerSinkClass GstCAOpenGLLayerSinkClass;
struct _GstCAOpenGLLayerSink
{
GstVideoSink video_sink;
/* caps */
GstVideoInfo info;
GstCaps *gl_caps;
/* gl state */
GstGLDisplay *display;
GstGLContext *other_context;
GstGLContext *context;
guint next_tex;
GstBuffer *next_buffer;
GstBuffer *next_sync;
gpointer layer;
gboolean keep_aspect_ratio;
/* avoid replacing the stored_buffer while drawing */
GMutex drawing_lock;
GstBuffer *stored_buffer;
GstBuffer *stored_sync;
GLuint redisplay_texture;
gboolean caps_change;
guint window_width;
guint window_height;
/* gl state */
GstGLShader *redisplay_shader;
GLuint vao;
GLuint vertex_buffer;
GLuint vbo_indices;
GLint attr_position;
GLint attr_texture;
};
struct _GstCAOpenGLLayerSinkClass
{
GstVideoSinkClass video_sink_class;
};
GType gst_ca_opengl_layer_sink_get_type(void);
GType gst_ca_opengl_layer_sink_bin_get_type (void);
G_END_DECLS
#endif /* __CA_OPENGL_LAYER_SINK__ */
This diff is collapsed.
/*
* GStreamer
* Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
* Copyright (C) 2015 Michał Dębski <debski.mi.zd@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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "../gstgleffects.h"
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;
}
void
gst_gl_effects_blur (GstGLEffects * effects)
{
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLShader *shader;
shader = gst_gl_effects_get_fragment_shader (effects, "hconv0",
hconv7_fragment_source_gles2);
gst_gl_shader_use (shader);
gst_gl_shader_set_uniform_1f (shader, "gauss_width",
GST_VIDEO_INFO_WIDTH (&filter->in_info));
gst_gl_shader_set_uniform_1fv (shader, "kernel", 7,
gst_gl_effects_blur_kernel ());
gst_gl_filter_render_to_target_with_shader (filter, effects->intexture,
effects->midtexture[0], shader);
shader = gst_gl_effects_get_fragment_shader (effects, "vconv0",
vconv7_fragment_source_gles2);
gst_gl_shader_use (shader);
gst_gl_shader_set_uniform_1f (shader, "gauss_height",
GST_VIDEO_INFO_HEIGHT (&filter->in_info));
gst_gl_shader_set_uniform_1fv (shader, "kernel", 7,
gst_gl_effects_blur_kernel ());
gst_gl_filter_render_to_target_with_shader (filter, effects->midtexture[0],
effects->outtexture, shader);
}
/*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "../gstgleffects.h"
void
gst_gl_effects_bulge (GstGLEffects * effects)
{
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLShader *shader;
shader = gst_gl_effects_get_fragment_shader (effects, "bulge",
bulge_fragment_source_gles2);
gst_gl_filter_render_to_target_with_shader (filter, effects->intexture,
effects->outtexture, shader);
}
/*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "../gstgleffects.h"
void
gst_gl_effects_fisheye (GstGLEffects * effects)
{
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLShader *shader;
shader = gst_gl_effects_get_fragment_shader (effects, "fisheye",
fisheye_fragment_source_gles2);
gst_gl_filter_render_to_target_with_shader (filter, effects->intexture,
effects->outtexture, shader);
}
/*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "../gstgleffects.h"
static gboolean kernel_ready = FALSE;
static float gauss_kernel[7];
void
gst_gl_effects_glow (GstGLEffects * effects)
{
const GstGLFuncs *gl = GST_GL_BASE_FILTER (effects)->context->gl_vtable;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLShader *shader;
if (!kernel_ready) {
fill_gaussian_kernel (gauss_kernel, 7, 10.0);
kernel_ready = TRUE;
}
/* threshold */
shader = gst_gl_effects_get_fragment_shader (effects, "luma_threshold",
luma_threshold_fragment_source_gles2);
gst_gl_filter_render_to_target_with_shader (filter, effects->intexture,
effects->midtexture[0], shader);
/* blur */
shader = gst_gl_effects_get_fragment_shader (effects, "hconv7",
hconv7_fragment_source_gles2);
gst_gl_shader_use (shader);
gst_gl_shader_set_uniform_1fv (shader, "kernel", 7, gauss_kernel);
gst_gl_shader_set_uniform_1f (shader, "gauss_width",
GST_VIDEO_INFO_WIDTH (&filter->out_info));
gst_gl_filter_render_to_target_with_shader (filter, effects->midtexture[0],
effects->midtexture[1], shader);
shader = gst_gl_effects_get_fragment_shader (effects, "vconv7",
vconv7_fragment_source_gles2);
gst_gl_shader_use (shader);
gst_gl_shader_set_uniform_1fv (shader, "kernel", 7, gauss_kernel);
gst_gl_shader_set_uniform_1f (shader, "gauss_height",
GST_VIDEO_INFO_HEIGHT (&filter->out_info));
gst_gl_filter_render_to_target_with_shader (filter, effects->midtexture[1],
effects->midtexture[2], shader);
/* add blurred luma to intexture */
shader = gst_gl_effects_get_fragment_shader (effects, "sum",
sum_fragment_source_gles2);
gst_gl_shader_use (shader);
gl->ActiveTexture (GL_TEXTURE2);
gl->BindTexture (GL_TEXTURE_2D,
gst_gl_memory_get_texture_id (effects->intexture));
gst_gl_shader_set_uniform_1f (shader, "alpha", 1.0f);
gst_gl_shader_set_uniform_1i (shader, "base", 2);
gl->ActiveTexture (GL_TEXTURE1);
gl->BindTexture (GL_TEXTURE_2D,
gst_gl_memory_get_texture_id (effects->midtexture[2]));
gst_gl_shader_set_uniform_1f (shader, "beta", (gfloat) 1 / 3.5f);
gst_gl_shader_set_uniform_1i (shader, "blend", 1);
gst_gl_filter_render_to_target_with_shader (filter, effects->midtexture[2],
effects->outtexture, shader);
}
/*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "../gstgleffects.h"
void
gst_gl_effects_identity (GstGLEffects * effects)
{
GstGLContext *context = GST_GL_BASE_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLShader *shader;
shader = g_hash_table_lookup (effects->shaderstable, "identity0");
if (!shader) {
GError *error = NULL;
if (!(shader = gst_gl_shader_new_default (context, &error))) {
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
("Failed to initialize identity shader: %s", error->message), (NULL));
return;
}
g_hash_table_insert (effects->shaderstable, (gchar *) "identity0", shader);
}
gst_gl_shader_use (shader);
gst_gl_filter_render_to_target_with_shader (filter, effects->intexture,
effects->outtexture, shader);
}
/*
* GStreamer
* Copyright (C) 2008-2010 Filippo Argiolas <filippo.argiolas@gmail.com>
* Copyright (C) 2015 Michał Dębski <debski.mi.zd@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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "../gstgleffects.h"
static gfloat kernel[9] = {
0.0, -1.0, 0.0,
-1.0, 4.0, -1.0,
0.0, -1.0, 0.0
};
void
gst_gl_effects_laplacian (GstGLEffects * effects)
{
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLShader *shader;
shader = gst_gl_effects_get_fragment_shader (effects, "conv0",
conv9_fragment_source_gles2);
gst_gl_shader_use (shader);
gst_gl_shader_set_uniform_1f (shader, "height",
GST_VIDEO_INFO_HEIGHT (&filter->in_info));
gst_gl_shader_set_uniform_1f (shader, "width",
GST_VIDEO_INFO_WIDTH (&filter->in_info));
gst_gl_shader_set_uniform_1fv (shader, "kernel", 9, kernel);
gst_gl_shader_set_uniform_1i (shader, "invert", effects->invert);
gst_gl_filter_render_to_target_with_shader (filter, effects->intexture,
effects->outtexture, shader);
}