mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
gl: use GLMemory for accessing textures everywhere
This simplifies and consolidates a lot of duplicated code creating and modifying textures.
This commit is contained in:
parent
c7dd43f21a
commit
7f10822de4
23 changed files with 207 additions and 172 deletions
|
@ -258,8 +258,8 @@ gst_gl_color_balance_callback (gint width, gint height, guint tex_id,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_color_balance_filter_texture (GstGLFilter * filter, guint in_tex,
|
||||
guint out_tex)
|
||||
gst_gl_color_balance_filter_texture (GstGLFilter * filter, GstGLMemory * in_tex,
|
||||
GstGLMemory * out_tex)
|
||||
{
|
||||
gst_gl_filter_render_to_target (filter, TRUE, in_tex, out_tex,
|
||||
(GLCB) gst_gl_color_balance_callback, filter);
|
||||
|
|
|
@ -74,7 +74,7 @@ static gboolean gst_gl_colorscale_gl_start (GstGLBaseFilter * base_filter);
|
|||
static void gst_gl_colorscale_gl_stop (GstGLBaseFilter * base_filter);
|
||||
|
||||
static gboolean gst_gl_colorscale_filter_texture (GstGLFilter * filter,
|
||||
guint in_tex, guint out_tex);
|
||||
GstGLMemory * in_tex, GstGLMemory * out_tex);
|
||||
|
||||
static void
|
||||
gst_gl_colorscale_class_init (GstGLColorscaleClass * klass)
|
||||
|
@ -175,8 +175,8 @@ gst_gl_colorscale_gl_stop (GstGLBaseFilter * base_filter)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_colorscale_filter_texture (GstGLFilter * filter, guint in_tex,
|
||||
guint out_tex)
|
||||
gst_gl_colorscale_filter_texture (GstGLFilter * filter, GstGLMemory * in_tex,
|
||||
GstGLMemory * out_tex)
|
||||
{
|
||||
GstGLColorscale *colorscale = GST_GL_COLORSCALE (filter);
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ static gboolean gst_gl_deinterlace_init_fbo (GstGLFilter * filter);
|
|||
static gboolean gst_gl_deinterlace_filter (GstGLFilter * filter,
|
||||
GstBuffer * inbuf, GstBuffer * outbuf);
|
||||
static gboolean gst_gl_deinterlace_filter_texture (GstGLFilter * filter,
|
||||
guint in_tex, guint out_tex);
|
||||
GstGLMemory * in_tex, GstGLMemory * out_tex);
|
||||
static void gst_gl_deinterlace_vfir_callback (gint width, gint height,
|
||||
guint texture, gpointer stuff);
|
||||
static void gst_gl_deinterlace_greedyh_callback (gint width, gint height,
|
||||
|
@ -364,8 +364,8 @@ gst_gl_deinterlace_init_fbo (GstGLFilter * filter)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_deinterlace_filter_texture (GstGLFilter * filter, guint in_tex,
|
||||
guint out_tex)
|
||||
gst_gl_deinterlace_filter_texture (GstGLFilter * filter, GstGLMemory * in_tex,
|
||||
GstGLMemory * out_tex)
|
||||
{
|
||||
GstGLDeinterlace *deinterlace_filter = GST_GL_DEINTERLACE (filter);
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ static void gst_gl_differencematte_get_property (GObject * object,
|
|||
guint prop_id, GValue * value, GParamSpec * pspec);
|
||||
|
||||
static gboolean gst_gl_differencematte_filter_texture (GstGLFilter * filter,
|
||||
guint in_tex, guint out_tex);
|
||||
GstGLMemory * in_tex, GstGLMemory * out_tex);
|
||||
|
||||
static gboolean gst_gl_differencematte_loader (GstGLFilter * filter);
|
||||
|
||||
|
@ -79,22 +79,23 @@ gst_gl_differencematte_init_gl_resources (GstGLFilter * filter)
|
|||
{
|
||||
GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (filter);
|
||||
GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
|
||||
const GstGLFuncs *gl = context->gl_vtable;
|
||||
GstGLBaseMemoryAllocator *tex_alloc;
|
||||
GstGLAllocationParams *params;
|
||||
GError *error = NULL;
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
gl->GenTextures (1, &differencematte->midtexture[i]);
|
||||
gl->BindTexture (GL_TEXTURE_2D, differencematte->midtexture[i]);
|
||||
gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8,
|
||||
GST_VIDEO_INFO_WIDTH (&filter->out_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
|
||||
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
tex_alloc = (GstGLBaseMemoryAllocator *)
|
||||
gst_gl_memory_allocator_get_default (context);
|
||||
params =
|
||||
(GstGLAllocationParams *) gst_gl_video_allocation_params_new (context,
|
||||
NULL, &filter->out_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D,
|
||||
GST_VIDEO_GL_TEXTURE_TYPE_RGBA);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
differencematte->midtexture[i] =
|
||||
(GstGLMemory *) gst_gl_base_memory_alloc (tex_alloc, params);
|
||||
gst_gl_allocation_params_free (params);
|
||||
gst_object_unref (tex_alloc);
|
||||
|
||||
if (!(differencematte->identity_shader =
|
||||
gst_gl_shader_new_default (context, &error))) {
|
||||
|
@ -165,11 +166,18 @@ static void
|
|||
gst_gl_differencematte_reset_gl_resources (GstGLFilter * filter)
|
||||
{
|
||||
GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (filter);
|
||||
GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable;
|
||||
gint i;
|
||||
|
||||
gl->DeleteTextures (1, &differencematte->savedbgtexture);
|
||||
gl->DeleteTextures (1, &differencematte->newbgtexture);
|
||||
if (differencematte->savedbgtexture) {
|
||||
gst_memory_unref (GST_MEMORY_CAST (differencematte->savedbgtexture));
|
||||
differencematte->savedbgtexture = NULL;
|
||||
}
|
||||
|
||||
if (differencematte->newbgtexture) {
|
||||
gst_memory_unref (GST_MEMORY_CAST (differencematte->newbgtexture));
|
||||
differencematte->newbgtexture = NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (differencematte->identity_shader) {
|
||||
gst_object_unref (differencematte->identity_shader);
|
||||
|
@ -180,15 +188,14 @@ gst_gl_differencematte_reset_gl_resources (GstGLFilter * filter)
|
|||
gst_object_unref (differencematte->shader[i]);
|
||||
differencematte->shader[i] = NULL;
|
||||
}
|
||||
|
||||
if (differencematte->midtexture[i]) {
|
||||
gl->DeleteTextures (1, &differencematte->midtexture[i]);
|
||||
differencematte->midtexture[i] = 0;
|
||||
gst_memory_unref (GST_MEMORY_CAST (differencematte->midtexture[i]));
|
||||
differencematte->midtexture[i] = NULL;
|
||||
}
|
||||
}
|
||||
differencematte->location = NULL;
|
||||
differencematte->pixbuf = NULL;
|
||||
differencematte->savedbgtexture = 0;
|
||||
differencematte->newbgtexture = 0;
|
||||
differencematte->bg_has_changed = FALSE;
|
||||
}
|
||||
|
||||
|
@ -277,38 +284,39 @@ gst_gl_differencematte_get_property (GObject * object, guint prop_id,
|
|||
}
|
||||
|
||||
static void
|
||||
init_pixbuf_texture (GstGLContext * context, gpointer data)
|
||||
init_pixbuf_texture (GstGLDifferenceMatte * differencematte)
|
||||
{
|
||||
GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (data);
|
||||
GstGLFilter *filter = GST_GL_FILTER (data);
|
||||
const GstGLFuncs *gl = context->gl_vtable;
|
||||
guint internal_format =
|
||||
gst_gl_sized_gl_format_from_gl_format_type (context, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE);
|
||||
GstGLContext *context = GST_GL_BASE_FILTER (differencematte)->context;
|
||||
GstGLFilter *filter = GST_GL_FILTER (differencematte);
|
||||
GstGLBaseMemoryAllocator *tex_alloc;
|
||||
GstGLAllocationParams *params;
|
||||
GstVideoInfo v_info;
|
||||
|
||||
gl->DeleteTextures (1, &differencematte->newbgtexture);
|
||||
gl->GenTextures (1, &differencematte->newbgtexture);
|
||||
gl->BindTexture (GL_TEXTURE_2D, differencematte->newbgtexture);
|
||||
gl->TexImage2D (GL_TEXTURE_2D, 0, internal_format,
|
||||
(gint) differencematte->pbuf_width, (gint) differencematte->pbuf_height,
|
||||
0, GL_RGBA, GL_UNSIGNED_BYTE, differencematte->pixbuf);
|
||||
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
tex_alloc = (GstGLBaseMemoryAllocator *)
|
||||
gst_gl_memory_allocator_get_default (context);
|
||||
gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGBA,
|
||||
differencematte->pbuf_width, differencematte->pbuf_height);
|
||||
params =
|
||||
(GstGLAllocationParams *) gst_gl_video_allocation_params_new (context,
|
||||
NULL, &v_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D,
|
||||
GST_VIDEO_GL_TEXTURE_TYPE_RGBA);
|
||||
|
||||
if (differencematte->savedbgtexture == 0) {
|
||||
gl->GenTextures (1, &differencematte->savedbgtexture);
|
||||
gl->BindTexture (GL_TEXTURE_2D, differencematte->savedbgtexture);
|
||||
gl->TexImage2D (GL_TEXTURE_2D, 0, internal_format,
|
||||
GST_VIDEO_INFO_WIDTH (&filter->out_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
|
||||
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
differencematte->newbgtexture =
|
||||
(GstGLMemory *) gst_gl_base_memory_alloc (tex_alloc, params);
|
||||
gst_gl_allocation_params_free (params);
|
||||
|
||||
if (differencematte->savedbgtexture == NULL) {
|
||||
params =
|
||||
(GstGLAllocationParams *) gst_gl_video_allocation_params_new (context,
|
||||
NULL, &filter->out_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D,
|
||||
GST_VIDEO_GL_TEXTURE_TYPE_RGBA);
|
||||
|
||||
differencematte->savedbgtexture =
|
||||
(GstGLMemory *) gst_gl_base_memory_alloc (tex_alloc, params);
|
||||
gst_gl_allocation_params_free (params);
|
||||
}
|
||||
|
||||
gst_object_unref (tex_alloc);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -327,7 +335,7 @@ gst_gl_differencematte_diff (gint width, gint height, guint texture,
|
|||
gst_gl_shader_set_uniform_1i (differencematte->shader[0], "current", 0);
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE1);
|
||||
gl->BindTexture (GL_TEXTURE_2D, differencematte->savedbgtexture);
|
||||
gl->BindTexture (GL_TEXTURE_2D, differencematte->savedbgtexture->tex_id);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (differencematte->shader[0], "saved", 1);
|
||||
|
||||
|
@ -396,12 +404,12 @@ gst_gl_differencematte_interp (gint width, gint height, guint texture,
|
|||
gst_gl_shader_set_uniform_1i (differencematte->shader[3], "blend", 0);
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE1);
|
||||
gl->BindTexture (GL_TEXTURE_2D, differencematte->newbgtexture);
|
||||
gl->BindTexture (GL_TEXTURE_2D, differencematte->newbgtexture->tex_id);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (differencematte->shader[3], "base", 1);
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE2);
|
||||
gl->BindTexture (GL_TEXTURE_2D, differencematte->midtexture[2]);
|
||||
gl->BindTexture (GL_TEXTURE_2D, differencematte->midtexture[2]->tex_id);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (differencematte->shader[3], "alpha", 2);
|
||||
|
||||
|
@ -427,8 +435,8 @@ gst_gl_differencematte_identity (gint width, gint height, guint texture,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_differencematte_filter_texture (GstGLFilter * filter, guint in_tex,
|
||||
guint out_tex)
|
||||
gst_gl_differencematte_filter_texture (GstGLFilter * filter,
|
||||
GstGLMemory * in_tex, GstGLMemory * out_tex)
|
||||
{
|
||||
GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (filter);
|
||||
|
||||
|
@ -439,9 +447,7 @@ gst_gl_differencematte_filter_texture (GstGLFilter * filter, guint in_tex,
|
|||
if (!gst_gl_differencematte_loader (filter))
|
||||
differencematte->pixbuf = NULL;
|
||||
|
||||
/* if loader failed then context is turned off */
|
||||
gst_gl_context_thread_add (GST_GL_BASE_FILTER (filter)->context,
|
||||
init_pixbuf_texture, differencematte);
|
||||
init_pixbuf_texture (differencematte);
|
||||
|
||||
/* save current frame, needed to calculate difference between
|
||||
* this frame and next ones */
|
||||
|
@ -457,7 +463,7 @@ gst_gl_differencematte_filter_texture (GstGLFilter * filter, guint in_tex,
|
|||
differencematte->bg_has_changed = FALSE;
|
||||
}
|
||||
|
||||
if (differencematte->savedbgtexture != 0) {
|
||||
if (differencematte->savedbgtexture != NULL) {
|
||||
gst_gl_filter_render_to_target (filter, TRUE, in_tex,
|
||||
differencematte->midtexture[0], gst_gl_differencematte_diff,
|
||||
differencematte);
|
||||
|
|
|
@ -45,10 +45,10 @@ struct _GstGLDifferenceMatte
|
|||
|
||||
guchar *pixbuf;
|
||||
gint pbuf_width, pbuf_height;
|
||||
GLuint savedbgtexture;
|
||||
GLuint newbgtexture;
|
||||
GLuint midtexture[4];
|
||||
GLuint intexture;
|
||||
GstGLMemory *savedbgtexture;
|
||||
GstGLMemory *newbgtexture;
|
||||
GstGLMemory *midtexture[4];
|
||||
GstGLMemory *intexture;
|
||||
float kernel[7];
|
||||
};
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ static void gst_gl_effects_ghash_func_clean (gpointer key, gpointer value,
|
|||
gpointer data);
|
||||
|
||||
static gboolean gst_gl_effects_filter_texture (GstGLFilter * filter,
|
||||
guint in_tex, guint out_tex);
|
||||
GstGLMemory * in_tex, GstGLMemory * out_tex);
|
||||
static gboolean gst_gl_effects_filters_is_property_supported (const
|
||||
GstGLEffectsFilterDescriptor *, gint property);
|
||||
|
||||
|
@ -274,31 +274,27 @@ gst_gl_effects_init_gl_resources (GstGLFilter * filter)
|
|||
{
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (filter);
|
||||
GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
guint internal_format;
|
||||
gint i = 0;
|
||||
GstGLBaseMemoryAllocator *base_alloc;
|
||||
GstGLAllocationParams *params;
|
||||
gint i;
|
||||
|
||||
base_alloc = (GstGLBaseMemoryAllocator *)
|
||||
gst_gl_memory_allocator_get_default (context);
|
||||
params =
|
||||
(GstGLAllocationParams *) gst_gl_video_allocation_params_new (context,
|
||||
NULL, &filter->out_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D,
|
||||
GST_VIDEO_GL_TEXTURE_TYPE_RGBA);
|
||||
|
||||
for (i = 0; i < NEEDED_TEXTURES; i++) {
|
||||
if (effects->midtexture[i])
|
||||
gst_memory_unref (GST_MEMORY_CAST (effects->midtexture[i]));
|
||||
|
||||
if (effects->midtexture[i]) {
|
||||
gl->DeleteTextures (1, &effects->midtexture[i]);
|
||||
effects->midtexture[i] = 0;
|
||||
}
|
||||
|
||||
gl->GenTextures (1, &effects->midtexture[i]);
|
||||
gl->BindTexture (GL_TEXTURE_2D, effects->midtexture[i]);
|
||||
internal_format =
|
||||
gst_gl_sized_gl_format_from_gl_format_type (context, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE);
|
||||
gl->TexImage2D (GL_TEXTURE_2D, 0, internal_format,
|
||||
GST_VIDEO_INFO_WIDTH (&filter->out_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info), 0, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
NULL);
|
||||
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
effects->midtexture[i] =
|
||||
(GstGLMemory *) gst_gl_base_memory_alloc (base_alloc, params);
|
||||
}
|
||||
|
||||
gst_object_unref (base_alloc);
|
||||
gst_gl_allocation_params_free (params);
|
||||
}
|
||||
|
||||
/* free resources that need a gl context */
|
||||
|
@ -310,8 +306,7 @@ gst_gl_effects_reset_gl_resources (GstGLFilter * filter)
|
|||
gint i = 0;
|
||||
|
||||
for (i = 0; i < NEEDED_TEXTURES; i++) {
|
||||
gl->DeleteTextures (1, &effects->midtexture[i]);
|
||||
effects->midtexture[i] = 0;
|
||||
gst_memory_unref (GST_MEMORY_CAST (effects->midtexture[i]));
|
||||
}
|
||||
for (i = 0; i < GST_GL_EFFECTS_N_CURVES; i++) {
|
||||
gl->DeleteTextures (1, &effects->curve[i]);
|
||||
|
@ -396,10 +391,11 @@ gst_gl_effects_filter_class_init (GstGLEffectsClass * klass,
|
|||
}
|
||||
|
||||
static void
|
||||
set_horizontal_swap (GstGLContext * context, gpointer data)
|
||||
set_horizontal_swap (GstGLEffects * effects)
|
||||
{
|
||||
#if GST_GL_HAVE_OPENGL
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
GstGLContext *context = GST_GL_BASE_FILTER (effects)->context;
|
||||
const GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
if (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL) {
|
||||
const gfloat mirrormatrix[16] = {
|
||||
|
@ -527,8 +523,8 @@ gst_gl_effects_on_init_gl_context (GstGLFilter * filter)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_effects_filter_texture (GstGLFilter * filter, guint in_tex,
|
||||
guint out_tex)
|
||||
gst_gl_effects_filter_texture (GstGLFilter * filter, GstGLMemory * in_tex,
|
||||
GstGLMemory * out_tex)
|
||||
{
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (filter);
|
||||
|
||||
|
@ -536,8 +532,7 @@ gst_gl_effects_filter_texture (GstGLFilter * filter, guint in_tex,
|
|||
effects->outtexture = out_tex;
|
||||
|
||||
if (effects->horizontal_swap == TRUE)
|
||||
gst_gl_context_thread_add (GST_GL_BASE_FILTER (filter)->context,
|
||||
set_horizontal_swap, effects);
|
||||
set_horizontal_swap (effects);
|
||||
|
||||
effects->effect (effects);
|
||||
|
||||
|
|
|
@ -69,9 +69,9 @@ struct _GstGLEffects
|
|||
GstGLEffectProcessFunc effect;
|
||||
gint current_effect;
|
||||
|
||||
GLuint intexture;
|
||||
GLuint midtexture[NEEDED_TEXTURES];
|
||||
GLuint outtexture;
|
||||
GstGLMemory *intexture;
|
||||
GstGLMemory *midtexture[NEEDED_TEXTURES];
|
||||
GstGLMemory *outtexture;
|
||||
|
||||
GLuint curve[GST_GL_EFFECTS_N_CURVES];
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ static void gst_gl_filter_app_get_property (GObject * object, guint prop_id,
|
|||
static gboolean gst_gl_filter_app_set_caps (GstGLFilter * filter,
|
||||
GstCaps * incaps, GstCaps * outcaps);
|
||||
static gboolean gst_gl_filter_app_filter_texture (GstGLFilter * filter,
|
||||
guint in_tex, guint out_tex);
|
||||
GstGLMemory * in_tex, GstGLMemory * out_tex);
|
||||
|
||||
static gboolean gst_gl_filter_app_gl_start (GstGLBaseFilter * base_filter);
|
||||
static void gst_gl_filter_app_gl_stop (GstGLBaseFilter * base_filter);
|
||||
|
@ -200,9 +200,8 @@ struct glcb2
|
|||
{
|
||||
GLCB func;
|
||||
gpointer data;
|
||||
guint texture;
|
||||
guint width;
|
||||
guint height;
|
||||
GstGLMemory *in_tex;
|
||||
GstGLMemory *out_tex;
|
||||
};
|
||||
|
||||
/* convenience functions to simplify filter development */
|
||||
|
@ -211,27 +210,28 @@ _glcb2 (gpointer data)
|
|||
{
|
||||
struct glcb2 *cb = data;
|
||||
|
||||
cb->func (cb->width, cb->height, cb->texture, cb->data);
|
||||
cb->func (gst_gl_memory_get_texture_width (cb->in_tex),
|
||||
gst_gl_memory_get_texture_height (cb->in_tex), cb->in_tex->tex_id,
|
||||
cb->data);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_filter_app_filter_texture (GstGLFilter * filter, guint in_tex,
|
||||
guint out_tex)
|
||||
gst_gl_filter_app_filter_texture (GstGLFilter * filter, GstGLMemory * in_tex,
|
||||
GstGLMemory * out_tex)
|
||||
{
|
||||
GstGLFilterApp *app_filter = GST_GL_FILTER_APP (filter);
|
||||
struct glcb2 cb;
|
||||
|
||||
cb.func = (GLCB) _emit_draw_signal;
|
||||
cb.data = filter;
|
||||
cb.texture = in_tex;
|
||||
cb.width = GST_VIDEO_INFO_WIDTH (&filter->in_info);
|
||||
cb.height = GST_VIDEO_INFO_HEIGHT (&filter->in_info);
|
||||
cb.in_tex = in_tex;
|
||||
cb.out_tex = out_tex;
|
||||
|
||||
//blocking call, use a FBO
|
||||
gst_gl_context_use_fbo_v2 (GST_GL_BASE_FILTER (filter)->context,
|
||||
GST_VIDEO_INFO_WIDTH (&filter->out_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
|
||||
filter->fbo, filter->depthbuffer, out_tex, _glcb2, &cb);
|
||||
filter->fbo, filter->depthbuffer, out_tex->tex_id, _glcb2, &cb);
|
||||
|
||||
if (app_filter->default_draw) {
|
||||
gst_gl_filter_render_to_target_with_shader (filter, TRUE, in_tex, out_tex,
|
||||
|
|
|
@ -81,7 +81,7 @@ static void gst_gl_filter_cube_reset_gl (GstGLFilter * filter);
|
|||
static gboolean gst_gl_filter_cube_init_shader (GstGLFilter * filter);
|
||||
static void _callback (gpointer stuff);
|
||||
static gboolean gst_gl_filter_cube_filter_texture (GstGLFilter * filter,
|
||||
guint in_tex, guint out_tex);
|
||||
GstGLMemory * in_tex, GstGLMemory * out_tex);
|
||||
|
||||
/* vertex source */
|
||||
static const gchar *cube_v_src =
|
||||
|
@ -335,8 +335,8 @@ gst_gl_filter_cube_init_shader (GstGLFilter * filter)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_filter_cube_filter_texture (GstGLFilter * filter, guint in_tex,
|
||||
guint out_tex)
|
||||
gst_gl_filter_cube_filter_texture (GstGLFilter * filter, GstGLMemory * in_tex,
|
||||
GstGLMemory * out_tex)
|
||||
{
|
||||
GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (filter);
|
||||
|
||||
|
@ -346,7 +346,7 @@ gst_gl_filter_cube_filter_texture (GstGLFilter * filter, guint in_tex,
|
|||
gst_gl_context_use_fbo_v2 (GST_GL_BASE_FILTER (filter)->context,
|
||||
GST_VIDEO_INFO_WIDTH (&filter->out_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info), filter->fbo,
|
||||
filter->depthbuffer, out_tex, _callback, (gpointer) cube_filter);
|
||||
filter->depthbuffer, out_tex->tex_id, _callback, (gpointer) cube_filter);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -466,7 +466,7 @@ _callback (gpointer stuff)
|
|||
gst_gl_shader_use (cube_filter->shader);
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE0);
|
||||
gl->BindTexture (GL_TEXTURE_2D, cube_filter->in_tex);
|
||||
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);
|
||||
|
|
|
@ -40,6 +40,7 @@ struct _GstGLFilterCube
|
|||
GstGLFilter filter;
|
||||
|
||||
GstGLShader *shader;
|
||||
GstGLMemory *in_tex;
|
||||
|
||||
/* background color */
|
||||
gfloat red;
|
||||
|
@ -52,7 +53,6 @@ struct _GstGLFilterCube
|
|||
gdouble znear;
|
||||
gdouble zfar;
|
||||
|
||||
guint in_tex;
|
||||
GLuint vao;
|
||||
GLuint vbo_indices;
|
||||
GLuint vertex_buffer;
|
||||
|
|
|
@ -66,7 +66,7 @@ static gboolean gst_gl_filter_glass_reset (GstBaseTransform * trans);
|
|||
|
||||
static gboolean gst_gl_filter_glass_init_shader (GstGLFilter * filter);
|
||||
static gboolean gst_gl_filter_glass_filter_texture (GstGLFilter * filter,
|
||||
guint in_tex, guint out_tex);
|
||||
GstGLMemory * in_tex, GstGLMemory * out_tex);
|
||||
|
||||
static void gst_gl_filter_glass_draw_background_gradient ();
|
||||
static void gst_gl_filter_glass_draw_video_plane (GstGLFilter * filter,
|
||||
|
@ -238,17 +238,18 @@ gst_gl_filter_glass_init_shader (GstGLFilter * filter)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_filter_glass_filter_texture (GstGLFilter * filter, guint in_tex,
|
||||
guint out_tex)
|
||||
gst_gl_filter_glass_filter_texture (GstGLFilter * filter, GstGLMemory * in_tex,
|
||||
GstGLMemory * out_tex)
|
||||
{
|
||||
GstGLFilterGlass *glass_filter = GST_GL_FILTER_GLASS (filter);
|
||||
|
||||
glass_filter->in_tex = in_tex;
|
||||
|
||||
//blocking call, use a FBO
|
||||
gst_gl_context_use_fbo_v2 (GST_GL_BASE_FILTER (filter)->context,
|
||||
GST_VIDEO_INFO_WIDTH (&filter->out_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
|
||||
filter->fbo, filter->depthbuffer, out_tex,
|
||||
filter->fbo, filter->depthbuffer, out_tex->tex_id,
|
||||
gst_gl_filter_glass_callback, (gpointer) glass_filter);
|
||||
|
||||
return TRUE;
|
||||
|
@ -365,7 +366,7 @@ gst_gl_filter_glass_callback (gpointer stuff)
|
|||
|
||||
gint width = GST_VIDEO_INFO_WIDTH (&filter->out_info);
|
||||
gint height = GST_VIDEO_INFO_HEIGHT (&filter->out_info);
|
||||
guint texture = glass_filter->in_tex;
|
||||
guint texture = glass_filter->in_tex->tex_id;
|
||||
|
||||
if (start_time == 0)
|
||||
start_time = get_time ();
|
||||
|
|
|
@ -41,7 +41,8 @@ struct _GstGLFilterGlass
|
|||
GstGLShader *passthrough_shader;
|
||||
GstGLShader *shader;
|
||||
gint64 timestamp;
|
||||
guint in_tex;
|
||||
GstGLMemory *in_tex;
|
||||
GstGLMemory *out_tex;
|
||||
};
|
||||
|
||||
struct _GstGLFilterGlassClass
|
||||
|
|
|
@ -82,7 +82,7 @@ static void gst_gl_filtershader_gl_stop (GstGLBaseFilter * base);
|
|||
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);
|
||||
GstGLMemory * in_tex, GstGLMemory * out_tex);
|
||||
static void gst_gl_filtershader_hcallback (gint width, gint height,
|
||||
guint texture, gpointer stuff);
|
||||
|
||||
|
@ -313,8 +313,8 @@ gst_gl_filtershader_filter (GstGLFilter * filter, GstBuffer * inbuf,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_filtershader_filter_texture (GstGLFilter * filter, guint in_tex,
|
||||
guint out_tex)
|
||||
gst_gl_filtershader_filter_texture (GstGLFilter * filter, GstGLMemory * in_tex,
|
||||
GstGLMemory * out_tex)
|
||||
{
|
||||
GstGLFilterShader *filtershader = GST_GL_FILTERSHADER (filter);
|
||||
|
||||
|
|
|
@ -631,7 +631,7 @@ _upload_frames (GstAggregator * agg, GstAggregatorPad * agg_pad,
|
|||
gboolean
|
||||
gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
|
||||
{
|
||||
guint out_tex;
|
||||
GstGLMemory *out_tex;
|
||||
gboolean res = TRUE;
|
||||
GstVideoFrame out_frame;
|
||||
GstVideoAggregator *vagg = GST_VIDEO_AGGREGATOR (mix);
|
||||
|
@ -645,7 +645,7 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
out_tex = *(guint *) out_frame.data[0];
|
||||
out_tex = (GstGLMemory *) out_frame.map[0].memory;
|
||||
|
||||
if (!gst_aggregator_iterate_sinkpads (GST_AGGREGATOR (mix),
|
||||
(GstAggregatorPadForeachFunc) _upload_frames, NULL))
|
||||
|
|
|
@ -78,7 +78,7 @@ typedef gboolean (*GstGLMixerSetCaps) (GstGLMixer* mixer,
|
|||
GstCaps* outcaps);
|
||||
typedef void (*GstGLMixerReset) (GstGLMixer *mixer);
|
||||
typedef gboolean (*GstGLMixerProcessFunc) (GstGLMixer *mix, GstBuffer *outbuf);
|
||||
typedef gboolean (*GstGLMixerProcessTextures) (GstGLMixer *mix, guint out_tex);
|
||||
typedef gboolean (*GstGLMixerProcessTextures) (GstGLMixer *mix, GstGLMemory *out_tex);
|
||||
|
||||
struct _GstGLMixer
|
||||
{
|
||||
|
|
|
@ -70,7 +70,7 @@ static gboolean gst_gl_mosaic_init_shader (GstGLMixer * mixer,
|
|||
GstCaps * outcaps);
|
||||
|
||||
static gboolean gst_gl_mosaic_process_textures (GstGLMixer * mixer,
|
||||
guint out_tex);
|
||||
GstGLMemory * out_tex);
|
||||
static void gst_gl_mosaic_callback (gpointer stuff);
|
||||
|
||||
//vertex source
|
||||
|
@ -194,7 +194,7 @@ gst_gl_mosaic_init_shader (GstGLMixer * mixer, GstCaps * outcaps)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_mosaic_process_textures (GstGLMixer * mix, guint out_tex)
|
||||
gst_gl_mosaic_process_textures (GstGLMixer * mix, GstGLMemory * out_tex)
|
||||
{
|
||||
GstGLMosaic *mosaic = GST_GL_MOSAIC (mix);
|
||||
|
||||
|
@ -202,7 +202,8 @@ gst_gl_mosaic_process_textures (GstGLMixer * mix, guint out_tex)
|
|||
gst_gl_context_use_fbo_v2 (GST_GL_BASE_MIXER (mix)->context,
|
||||
GST_VIDEO_INFO_WIDTH (&GST_VIDEO_AGGREGATOR (mix)->info),
|
||||
GST_VIDEO_INFO_HEIGHT (&GST_VIDEO_AGGREGATOR (mix)->info), mix->fbo,
|
||||
mix->depthbuffer, out_tex, gst_gl_mosaic_callback, (gpointer) mosaic);
|
||||
mix->depthbuffer, out_tex->tex_id, gst_gl_mosaic_callback,
|
||||
(gpointer) mosaic);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ struct _GstGLMosaic
|
|||
GstGLMixer mixer;
|
||||
|
||||
GstGLShader *shader;
|
||||
GstGLMemory *out_tex;
|
||||
};
|
||||
|
||||
struct _GstGLMosaicClass
|
||||
|
|
|
@ -72,7 +72,7 @@ static void gst_gl_overlay_get_property (GObject * object, guint prop_id,
|
|||
static void gst_gl_overlay_before_transform (GstBaseTransform * trans,
|
||||
GstBuffer * outbuf);
|
||||
static gboolean gst_gl_overlay_filter_texture (GstGLFilter * filter,
|
||||
guint in_tex, guint out_tex);
|
||||
GstGLMemory * in_tex, GstGLMemory * out_tex);
|
||||
|
||||
static gboolean gst_gl_overlay_load_png (GstGLOverlay * overlay, FILE * fp);
|
||||
static gboolean gst_gl_overlay_load_jpeg (GstGLOverlay * overlay, FILE * fp);
|
||||
|
@ -624,8 +624,8 @@ out:
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_overlay_filter_texture (GstGLFilter * filter, guint in_tex,
|
||||
guint out_tex)
|
||||
gst_gl_overlay_filter_texture (GstGLFilter * filter, GstGLMemory * in_tex,
|
||||
GstGLMemory * out_tex)
|
||||
{
|
||||
GstGLOverlay *overlay = GST_GL_OVERLAY (filter);
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ gst_gl_transformation_prepare_output_buffer (GstBaseTransform * trans,
|
|||
static gboolean gst_gl_transformation_filter (GstGLFilter * filter,
|
||||
GstBuffer * inbuf, GstBuffer * outbuf);
|
||||
static gboolean gst_gl_transformation_filter_texture (GstGLFilter * filter,
|
||||
guint in_tex, guint out_tex);
|
||||
GstGLMemory * in_tex, GstGLMemory * out_tex);
|
||||
|
||||
static void
|
||||
gst_gl_transformation_class_init (GstGLTransformationClass * klass)
|
||||
|
@ -782,8 +782,8 @@ gst_gl_transformation_filter (GstGLFilter * filter,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_transformation_filter_texture (GstGLFilter * filter, guint in_tex,
|
||||
guint out_tex)
|
||||
gst_gl_transformation_filter_texture (GstGLFilter * filter,
|
||||
GstGLMemory * in_tex, GstGLMemory * out_tex)
|
||||
{
|
||||
GstGLTransformation *transformation = GST_GL_TRANSFORMATION (filter);
|
||||
|
||||
|
@ -794,7 +794,8 @@ gst_gl_transformation_filter_texture (GstGLFilter * filter, guint in_tex,
|
|||
GST_VIDEO_INFO_WIDTH (&filter->out_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
|
||||
filter->fbo, filter->depthbuffer,
|
||||
out_tex, gst_gl_transformation_callback, (gpointer) transformation);
|
||||
out_tex->tex_id, gst_gl_transformation_callback,
|
||||
(gpointer) transformation);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -874,7 +875,7 @@ gst_gl_transformation_callback (gpointer stuff)
|
|||
gst_gl_shader_use (transformation->shader);
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE0);
|
||||
gl->BindTexture (GL_TEXTURE_2D, transformation->in_tex);
|
||||
gl->BindTexture (GL_TEXTURE_2D, transformation->in_tex->tex_id);
|
||||
gst_gl_shader_set_uniform_1i (transformation->shader, "texture", 0);
|
||||
|
||||
graphene_matrix_to_float (&transformation->mvp_matrix, temp_matrix);
|
||||
|
|
|
@ -47,7 +47,8 @@ struct _GstGLTransformation
|
|||
GLint attr_position;
|
||||
GLint attr_texture;
|
||||
|
||||
guint in_tex;
|
||||
GstGLMemory *in_tex;
|
||||
GstGLMemory *out_tex;
|
||||
|
||||
gfloat xrotation;
|
||||
gfloat yrotation;
|
||||
|
|
|
@ -474,7 +474,7 @@ static gboolean gst_gl_video_mixer_init_shader (GstGLMixer * mixer,
|
|||
GstCaps * outcaps);
|
||||
|
||||
static gboolean gst_gl_video_mixer_process_textures (GstGLMixer * mixer,
|
||||
guint out_tex);
|
||||
GstGLMemory * out_tex);
|
||||
static void gst_gl_video_mixer_callback (gpointer stuff);
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
|
@ -1156,7 +1156,7 @@ gst_gl_video_mixer_init_shader (GstGLMixer * mixer, GstCaps * outcaps)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_video_mixer_process_textures (GstGLMixer * mix, guint out_tex)
|
||||
gst_gl_video_mixer_process_textures (GstGLMixer * mix, GstGLMemory * out_tex)
|
||||
{
|
||||
GstGLVideoMixer *video_mixer = GST_GL_VIDEO_MIXER (mix);
|
||||
|
||||
|
@ -1164,7 +1164,7 @@ gst_gl_video_mixer_process_textures (GstGLMixer * mix, guint out_tex)
|
|||
GST_VIDEO_INFO_WIDTH (&GST_VIDEO_AGGREGATOR (mix)->info),
|
||||
GST_VIDEO_INFO_HEIGHT (&GST_VIDEO_AGGREGATOR (mix)->info),
|
||||
mix->fbo, mix->depthbuffer,
|
||||
out_tex, gst_gl_video_mixer_callback, (gpointer) video_mixer);
|
||||
out_tex->tex_id, gst_gl_video_mixer_callback, (gpointer) video_mixer);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -78,7 +78,8 @@ enum
|
|||
#define gst_gl_filter_parent_class parent_class
|
||||
G_DEFINE_TYPE_WITH_CODE (GstGLFilter, gst_gl_filter, GST_TYPE_GL_BASE_FILTER,
|
||||
GST_DEBUG_CATEGORY_INIT (gst_gl_filter_debug, "glfilter", 0,
|
||||
"glfilter element"););
|
||||
"glfilter element");
|
||||
);
|
||||
|
||||
static void gst_gl_filter_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
|
@ -904,7 +905,7 @@ gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
|
|||
GstBuffer * outbuf)
|
||||
{
|
||||
GstGLFilterClass *filter_class;
|
||||
guint in_tex, out_tex;
|
||||
GstMemory *in_tex, *out_tex;
|
||||
GstVideoFrame gl_frame, out_frame;
|
||||
gboolean ret;
|
||||
|
||||
|
@ -916,7 +917,12 @@ gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
|
|||
goto inbuf_error;
|
||||
}
|
||||
|
||||
in_tex = *(guint *) gl_frame.data[0];
|
||||
in_tex = gl_frame.map[0].memory;
|
||||
if (!gst_is_gl_memory (in_tex)) {
|
||||
ret = FALSE;
|
||||
GST_ERROR_OBJECT (filter, "Input memory must be GstGLMemory");
|
||||
goto inbuf_error;
|
||||
}
|
||||
|
||||
if (!gst_video_frame_map (&out_frame, &filter->out_info, outbuf,
|
||||
GST_MAP_WRITE | GST_MAP_GL)) {
|
||||
|
@ -924,13 +930,17 @@ gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
|
|||
goto unmap_out_error;
|
||||
}
|
||||
|
||||
out_tex = *(guint *) out_frame.data[0];
|
||||
out_tex = out_frame.map[0].memory;
|
||||
g_return_val_if_fail (gst_is_gl_memory (out_tex), FALSE);
|
||||
|
||||
GST_DEBUG ("calling filter_texture with textures in:%i out:%i", in_tex,
|
||||
out_tex);
|
||||
GST_DEBUG ("calling filter_texture with textures in:%i out:%i",
|
||||
GST_GL_MEMORY_CAST (in_tex)->tex_id,
|
||||
GST_GL_MEMORY_CAST (out_tex)->tex_id);
|
||||
|
||||
g_assert (filter_class->filter_texture);
|
||||
ret = filter_class->filter_texture (filter, in_tex, out_tex);
|
||||
|
||||
ret = filter_class->filter_texture (filter, GST_GL_MEMORY_CAST (in_tex),
|
||||
GST_GL_MEMORY_CAST (out_tex));
|
||||
|
||||
gst_video_frame_unmap (&out_frame);
|
||||
unmap_out_error:
|
||||
|
@ -941,10 +951,19 @@ inbuf_error:
|
|||
}
|
||||
|
||||
static void
|
||||
_debug_marker (GstGLContext * context, GstGLFilter * filter)
|
||||
_filter_gl (GstGLContext * context, GstGLFilter * filter)
|
||||
{
|
||||
GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
|
||||
|
||||
gst_gl_insert_debug_marker (context,
|
||||
"processing in element %s", GST_OBJECT_NAME (filter));
|
||||
|
||||
if (filter_class->filter)
|
||||
filter->gl_result =
|
||||
filter_class->filter (filter, filter->inbuf, filter->outbuf);
|
||||
else
|
||||
filter->gl_result =
|
||||
gst_gl_filter_filter_texture (filter, filter->inbuf, filter->outbuf);
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
|
@ -967,12 +986,11 @@ gst_gl_filter_transform (GstBaseTransform * bt, GstBuffer * inbuf,
|
|||
if (in_sync_meta)
|
||||
gst_gl_sync_meta_wait (in_sync_meta, context);
|
||||
|
||||
gst_gl_context_thread_add (context, (GstGLContextThreadFunc) _debug_marker,
|
||||
filter->inbuf = inbuf;
|
||||
filter->outbuf = outbuf;
|
||||
gst_gl_context_thread_add (context, (GstGLContextThreadFunc) _filter_gl,
|
||||
filter);
|
||||
if (filter_class->filter)
|
||||
ret = filter_class->filter (filter, inbuf, outbuf);
|
||||
else
|
||||
ret = gst_gl_filter_filter_texture (filter, inbuf, outbuf);
|
||||
ret = filter->gl_result;
|
||||
|
||||
out_sync_meta = gst_buffer_get_gl_sync_meta (outbuf);
|
||||
if (out_sync_meta)
|
||||
|
@ -1014,7 +1032,7 @@ _glcb2 (gpointer data)
|
|||
*/
|
||||
void
|
||||
gst_gl_filter_render_to_target (GstGLFilter * filter, gboolean resize,
|
||||
GLuint input, GLuint target, GLCB func, gpointer data)
|
||||
GstGLMemory * input, GstGLMemory * output, GLCB func, gpointer data)
|
||||
{
|
||||
GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
|
||||
guint in_width, in_height, out_width, out_height;
|
||||
|
@ -1030,12 +1048,12 @@ gst_gl_filter_render_to_target (GstGLFilter * filter, gboolean resize,
|
|||
in_height = out_height;
|
||||
}
|
||||
|
||||
GST_LOG ("rendering to target. in %u, %ux%u out %u, %ux%u", input, in_width,
|
||||
in_height, target, out_width, out_height);
|
||||
GST_LOG ("rendering to target. in %u, %ux%u out %u, %ux%u", input->tex_id,
|
||||
in_width, in_height, output->tex_id, out_width, out_height);
|
||||
|
||||
cb.func = func;
|
||||
cb.data = data;
|
||||
cb.texture = input;
|
||||
cb.texture = input->tex_id;
|
||||
cb.width = in_width;
|
||||
cb.height = in_height;
|
||||
|
||||
|
@ -1110,13 +1128,14 @@ _draw_with_shader_cb (gint width, gint height, guint texture, gpointer stuff)
|
|||
* the shader, render input to a quad */
|
||||
void
|
||||
gst_gl_filter_render_to_target_with_shader (GstGLFilter * filter,
|
||||
gboolean resize, GLuint input, GLuint target, GstGLShader * shader)
|
||||
gboolean resize, GstGLMemory * input, GstGLMemory * output,
|
||||
GstGLShader * shader)
|
||||
{
|
||||
if (filter->default_shader != shader)
|
||||
filter->valid_attributes = FALSE;
|
||||
filter->default_shader = shader;
|
||||
|
||||
gst_gl_filter_render_to_target (filter, resize, input, target,
|
||||
gst_gl_filter_render_to_target (filter, resize, input, output,
|
||||
_draw_with_shader_cb, filter);
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,9 @@ struct _GstGLFilter
|
|||
/* <private> */
|
||||
GLuint fbo;
|
||||
GLuint depthbuffer;
|
||||
gboolean gl_result;
|
||||
GstBuffer *inbuf;
|
||||
GstBuffer *outbuf;
|
||||
|
||||
GstGLShader *default_shader;
|
||||
gboolean valid_attributes;
|
||||
|
@ -99,7 +102,7 @@ struct _GstGLFilterClass
|
|||
|
||||
gboolean (*set_caps) (GstGLFilter* filter, GstCaps* incaps, GstCaps* outcaps);
|
||||
gboolean (*filter) (GstGLFilter *filter, GstBuffer *inbuf, GstBuffer *outbuf);
|
||||
gboolean (*filter_texture) (GstGLFilter *filter, guint in_tex, guint out_tex);
|
||||
gboolean (*filter_texture) (GstGLFilter *filter, GstGLMemory *in_tex, GstGLMemory *out_tex);
|
||||
gboolean (*init_fbo) (GstGLFilter *filter);
|
||||
|
||||
GstCaps *(*transform_internal_caps) (GstGLFilter *filter,
|
||||
|
@ -113,13 +116,19 @@ struct _GstGLFilterClass
|
|||
gboolean gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
|
||||
GstBuffer * outbuf);
|
||||
|
||||
void gst_gl_filter_render_to_target (GstGLFilter *filter, gboolean resize, GLuint input,
|
||||
GLuint target, GLCB func, gpointer data);
|
||||
|
||||
void gst_gl_filter_render_to_target_with_shader (GstGLFilter * filter, gboolean resize,
|
||||
GLuint input, GLuint target, GstGLShader *shader);
|
||||
void gst_gl_filter_render_to_target (GstGLFilter *filter,
|
||||
gboolean resize,
|
||||
GstGLMemory * input,
|
||||
GstGLMemory * output,
|
||||
GLCB func,
|
||||
gpointer data);
|
||||
|
||||
void gst_gl_filter_draw_fullscreen_quad (GstGLFilter *filter);
|
||||
void gst_gl_filter_render_to_target_with_shader (GstGLFilter * filter,
|
||||
gboolean resize,
|
||||
GstGLMemory * input,
|
||||
GstGLMemory * output,
|
||||
GstGLShader *shader);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
Loading…
Reference in a new issue