From 92f0aa9bd80cad834183e4541328e709831e64f6 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Fri, 13 Mar 2015 10:25:35 +0000 Subject: [PATCH] gl: get the context from basemixer/basefilter --- ext/gl/effects/gstgleffectbulge.c | 2 +- ext/gl/effects/gstgleffectfisheye.c | 2 +- ext/gl/effects/gstgleffectglow.c | 8 ++--- ext/gl/effects/gstgleffectidentity.c | 2 +- ext/gl/effects/gstgleffectlumatocurve.c | 2 +- ext/gl/effects/gstgleffectmirror.c | 2 +- ext/gl/effects/gstgleffectrgbtocurve.c | 2 +- ext/gl/effects/gstgleffectsin.c | 2 +- ext/gl/effects/gstgleffectsquare.c | 2 +- ext/gl/effects/gstgleffectsqueeze.c | 2 +- ext/gl/effects/gstgleffectstretch.c | 2 +- ext/gl/effects/gstgleffecttunnel.c | 2 +- ext/gl/effects/gstgleffecttwirl.c | 4 +-- ext/gl/effects/gstgleffectxray.c | 14 ++++---- ext/gl/gstglbumper.c | 2 +- ext/gl/gstglcolorscale.c | 25 +++++++------- ext/gl/gstgldeinterlace.c | 24 ++++++-------- ext/gl/gstgldifferencematte.c | 37 ++++++++++----------- ext/gl/gstgleffects.c | 15 +++++---- ext/gl/gstglfilterapp.c | 9 +++--- ext/gl/gstglfilterblur.c | 24 +++++++------- ext/gl/gstglfiltercube.c | 19 +++++------ ext/gl/gstglfilterglass.c | 26 ++++++++------- ext/gl/gstglfilterlaplacian.c | 9 +++--- ext/gl/gstglfilterreflectedscreen.c | 2 +- ext/gl/gstglfiltershader.c | 11 ++++--- ext/gl/gstglfiltersobel.c | 30 +++++++++-------- ext/gl/gstglmixer.c | 7 ---- ext/gl/gstglmixer.h | 3 -- ext/gl/gstglmosaic.c | 17 +++++----- ext/gl/gstgloverlay.c | 38 ++++++++++++---------- ext/gl/gstgltransformation.c | 30 +++++++++-------- ext/gl/gstglvideomixer.c | 43 +++++++++++++------------ gst-libs/gst/gl/gstglfilter.c | 9 ------ gst-libs/gst/gl/gstglfilter.h | 14 +------- 35 files changed, 218 insertions(+), 224 deletions(-) diff --git a/ext/gl/effects/gstgleffectbulge.c b/ext/gl/effects/gstgleffectbulge.c index a59f276e79..75b9e2fc17 100644 --- a/ext/gl/effects/gstgleffectbulge.c +++ b/ext/gl/effects/gstgleffectbulge.c @@ -30,7 +30,7 @@ gst_gl_effects_bulge_callback (gint width, gint height, guint texture, GstGLShader *shader; GstGLEffects *effects = GST_GL_EFFECTS (data); GstGLFilter *filter = GST_GL_FILTER (effects); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "bulge0"); diff --git a/ext/gl/effects/gstgleffectfisheye.c b/ext/gl/effects/gstgleffectfisheye.c index 80456ff2da..524b65987e 100644 --- a/ext/gl/effects/gstgleffectfisheye.c +++ b/ext/gl/effects/gstgleffectfisheye.c @@ -30,7 +30,7 @@ gst_gl_effects_fisheye_callback (gint width, gint height, guint texture, GstGLShader *shader; GstGLEffects *effects = GST_GL_EFFECTS (data); GstGLFilter *filter = GST_GL_FILTER (effects); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "fisheye0"); diff --git a/ext/gl/effects/gstgleffectglow.c b/ext/gl/effects/gstgleffectglow.c index c3adeebc5a..4853fd91a3 100644 --- a/ext/gl/effects/gstgleffectglow.c +++ b/ext/gl/effects/gstgleffectglow.c @@ -33,7 +33,7 @@ gst_gl_effects_glow_step_one (gint width, gint height, guint texture, GstGLShader *shader; GstGLEffects *effects = GST_GL_EFFECTS (data); GstGLFilter *filter = GST_GL_FILTER (effects); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "glow0"); @@ -73,7 +73,7 @@ gst_gl_effects_glow_step_two (gint width, gint height, guint texture, GstGLShader *shader; GstGLEffects *effects = GST_GL_EFFECTS (data); GstGLFilter *filter = GST_GL_FILTER (effects); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "glow1"); @@ -120,7 +120,7 @@ gst_gl_effects_glow_step_three (gint width, gint height, guint texture, GstGLShader *shader; GstGLEffects *effects = GST_GL_EFFECTS (data); GstGLFilter *filter = GST_GL_FILTER (effects); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "glow2"); @@ -162,7 +162,7 @@ gst_gl_effects_glow_step_four (gint width, gint height, guint texture, GstGLShader *shader; GstGLEffects *effects = GST_GL_EFFECTS (data); GstGLFilter *filter = GST_GL_FILTER (effects); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "glow3"); diff --git a/ext/gl/effects/gstgleffectidentity.c b/ext/gl/effects/gstgleffectidentity.c index 4e1cb04965..eec357eb38 100644 --- a/ext/gl/effects/gstgleffectidentity.c +++ b/ext/gl/effects/gstgleffectidentity.c @@ -35,7 +35,7 @@ gst_gl_effects_identity_callback (gint width, gint height, guint texture, { GstGLEffects *effects = GST_GL_EFFECTS (data); GstGLFilter *filter = GST_GL_FILTER (effects); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; #if GST_GL_HAVE_OPENGL diff --git a/ext/gl/effects/gstgleffectlumatocurve.c b/ext/gl/effects/gstgleffectlumatocurve.c index 643e34bfc9..2ce1de37ff 100644 --- a/ext/gl/effects/gstgleffectlumatocurve.c +++ b/ext/gl/effects/gstgleffectlumatocurve.c @@ -31,7 +31,7 @@ gst_gl_effects_luma_to_curve (GstGLEffects * effects, { GstGLShader *shader; GstGLFilter *filter = GST_GL_FILTER (effects); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "lumamap0"); diff --git a/ext/gl/effects/gstgleffectmirror.c b/ext/gl/effects/gstgleffectmirror.c index 06c94730cd..1713d54a56 100644 --- a/ext/gl/effects/gstgleffectmirror.c +++ b/ext/gl/effects/gstgleffectmirror.c @@ -36,7 +36,7 @@ gst_gl_effects_mirror_callback (gint width, gint height, guint texture, GstGLShader *shader; GstGLFilter *filter = GST_GL_FILTER (data); GstGLEffects *effects = GST_GL_EFFECTS (filter); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "mirror0"); diff --git a/ext/gl/effects/gstgleffectrgbtocurve.c b/ext/gl/effects/gstgleffectrgbtocurve.c index 3e4dda684d..18b09050bd 100644 --- a/ext/gl/effects/gstgleffectrgbtocurve.c +++ b/ext/gl/effects/gstgleffectrgbtocurve.c @@ -31,7 +31,7 @@ gst_gl_effects_rgb_to_curve (GstGLEffects * effects, { GstGLShader *shader; GstGLFilter *filter = GST_GL_FILTER (effects); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "rgbmap0"); diff --git a/ext/gl/effects/gstgleffectsin.c b/ext/gl/effects/gstgleffectsin.c index 2a6c0514b3..8d6be5442a 100644 --- a/ext/gl/effects/gstgleffectsin.c +++ b/ext/gl/effects/gstgleffectsin.c @@ -30,7 +30,7 @@ gst_gl_effects_sin_callback (gint width, gint height, guint texture, GstGLShader *shader; GstGLEffects *effects = GST_GL_EFFECTS (data); GstGLFilter *filter = GST_GL_FILTER (effects); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "sin0"); diff --git a/ext/gl/effects/gstgleffectsquare.c b/ext/gl/effects/gstgleffectsquare.c index 7b4271e33c..b1619c06b6 100644 --- a/ext/gl/effects/gstgleffectsquare.c +++ b/ext/gl/effects/gstgleffectsquare.c @@ -30,7 +30,7 @@ gst_gl_effects_square_callback (gint width, gint height, guint texture, GstGLShader *shader; GstGLEffects *effects = GST_GL_EFFECTS (data); GstGLFilter *filter = GST_GL_FILTER (effects); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "square0"); diff --git a/ext/gl/effects/gstgleffectsqueeze.c b/ext/gl/effects/gstgleffectsqueeze.c index 6a723f8827..863157a743 100644 --- a/ext/gl/effects/gstgleffectsqueeze.c +++ b/ext/gl/effects/gstgleffectsqueeze.c @@ -36,7 +36,7 @@ gst_gl_effects_squeeze_callback (gint width, gint height, guint texture, GstGLShader *shader; GstGLFilter *filter = GST_GL_FILTER (data); GstGLEffects *effects = GST_GL_EFFECTS (data); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "squeeze0"); diff --git a/ext/gl/effects/gstgleffectstretch.c b/ext/gl/effects/gstgleffectstretch.c index 859f64efd7..206a097fd7 100644 --- a/ext/gl/effects/gstgleffectstretch.c +++ b/ext/gl/effects/gstgleffectstretch.c @@ -30,7 +30,7 @@ gst_gl_effects_stretch_callback (gint width, gint height, guint texture, GstGLShader *shader; GstGLEffects *effects = GST_GL_EFFECTS (data); GstGLFilter *filter = GST_GL_FILTER (effects); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "stretch0"); diff --git a/ext/gl/effects/gstgleffecttunnel.c b/ext/gl/effects/gstgleffecttunnel.c index 479434ae16..b547436d27 100644 --- a/ext/gl/effects/gstgleffecttunnel.c +++ b/ext/gl/effects/gstgleffecttunnel.c @@ -30,7 +30,7 @@ gst_gl_effects_tunnel_callback (gint width, gint height, guint texture, GstGLShader *shader; GstGLEffects *effects = GST_GL_EFFECTS (data); GstGLFilter *filter = GST_GL_FILTER (effects); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "tunnel0"); diff --git a/ext/gl/effects/gstgleffecttwirl.c b/ext/gl/effects/gstgleffecttwirl.c index 4a6d7494e8..3a9b3746f4 100644 --- a/ext/gl/effects/gstgleffecttwirl.c +++ b/ext/gl/effects/gstgleffecttwirl.c @@ -30,13 +30,13 @@ gst_gl_effects_twirl_callback (gint width, gint height, guint texture, GstGLShader *shader; GstGLEffects *effects = GST_GL_EFFECTS (data); GstGLFilter *filter = GST_GL_FILTER (effects); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "twirl0"); if (!shader) { - shader = gst_gl_shader_new (GST_GL_FILTER (effects)->context); + shader = gst_gl_shader_new (context); g_hash_table_insert (effects->shaderstable, (gchar *) "twirl0", shader); } diff --git a/ext/gl/effects/gstgleffectxray.c b/ext/gl/effects/gstgleffectxray.c index 6657a9bbcc..79aeca1314 100644 --- a/ext/gl/effects/gstgleffectxray.c +++ b/ext/gl/effects/gstgleffectxray.c @@ -45,7 +45,7 @@ gst_gl_effects_xray_step_two (gint width, gint height, guint texture, GstGLShader *shader; GstGLEffects *effects = GST_GL_EFFECTS (data); GstGLFilter *filter = GST_GL_FILTER (effects); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "xray1"); @@ -92,7 +92,7 @@ gst_gl_effects_xray_step_three (gint width, gint height, guint texture, GstGLShader *shader; GstGLEffects *effects = GST_GL_EFFECTS (data); GstGLFilter *filter = GST_GL_FILTER (effects); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "xray2"); @@ -135,7 +135,7 @@ gst_gl_effects_xray_desaturate (gint width, gint height, guint texture, GstGLShader *shader; GstGLEffects *effects = GST_GL_EFFECTS (data); GstGLFilter *filter = GST_GL_FILTER (effects); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "xray_desat"); @@ -175,7 +175,7 @@ gst_gl_effects_xray_sobel_hconv (gint width, gint height, guint texture, GstGLShader *shader; GstGLEffects *effects = GST_GL_EFFECTS (data); GstGLFilter *filter = GST_GL_FILTER (effects); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "xray_sob_hconv"); @@ -218,7 +218,7 @@ gst_gl_effects_xray_sobel_vconv (gint width, gint height, guint texture, GstGLShader *shader; GstGLEffects *effects = GST_GL_EFFECTS (data); GstGLFilter *filter = GST_GL_FILTER (effects); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "xray_sob_vconv"); @@ -261,7 +261,7 @@ gst_gl_effects_xray_sobel_length (gint width, gint height, guint texture, GstGLShader *shader; GstGLEffects *effects = GST_GL_EFFECTS (data); GstGLFilter *filter = GST_GL_FILTER (effects); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "xray_sob_len"); @@ -305,7 +305,7 @@ gst_gl_effects_xray_step_five (gint width, gint height, guint texture, GstGLShader *shader; GstGLEffects *effects = GST_GL_EFFECTS (data); GstGLFilter *filter = GST_GL_FILTER (effects); - GstGLContext *context = filter->context; + GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; shader = g_hash_table_lookup (effects->shaderstable, "xray4"); diff --git a/ext/gl/gstglbumper.c b/ext/gl/gstglbumper.c index 7673c9b429..a60944de74 100644 --- a/ext/gl/gstglbumper.c +++ b/ext/gl/gstglbumper.c @@ -297,7 +297,7 @@ gst_gl_bumper_class_init (GstGLBumperClass * klass) "Cyril Comparon , " "Julien Isorce "); - GST_GL_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL; + GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL; } static void diff --git a/ext/gl/gstglcolorscale.c b/ext/gl/gstglcolorscale.c index d41e32067e..fa22bf9a9b 100644 --- a/ext/gl/gstglcolorscale.c +++ b/ext/gl/gstglcolorscale.c @@ -104,7 +104,7 @@ gst_gl_colorscale_class_init (GstGLColorscaleClass * klass) filter_class->filter_texture = gst_gl_colorscale_filter_texture; basetransform_class->passthrough_on_same_caps = TRUE; - filter_class->supported_gl_api = + GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | GST_GL_API_GLES2; } @@ -156,13 +156,13 @@ gst_gl_colorscale_gen_gl_resources (GstGLFilter * filter) { GstGLColorscale *colorscale = GST_GL_COLORSCALE (filter); - if (gst_gl_context_get_gl_api (filter->context) & (GST_GL_API_GLES2 | - GST_GL_API_OPENGL3)) { - gst_gl_context_thread_add (filter->context, + if (gst_gl_context_get_gl_api (GST_GL_BASE_FILTER (filter)->context) & + (GST_GL_API_GLES2 | GST_GL_API_OPENGL3)) { + gst_gl_context_thread_add (GST_GL_BASE_FILTER (filter)->context, (GstGLContextThreadFunc) _compile_identity_shader, colorscale); if (!colorscale->shader) { - gst_gl_context_set_error (filter->context, + gst_gl_context_set_error (GST_GL_BASE_FILTER (filter)->context, "Failed to initialize identity shader"); GST_ELEMENT_ERROR (colorscale, RESOURCE, NOT_FOUND, ("%s", gst_gl_context_get_error ()), (NULL)); @@ -179,7 +179,8 @@ gst_gl_colorscale_del_gl_resources (GstGLFilter * filter) GstGLColorscale *colorscale = GST_GL_COLORSCALE (filter); if (colorscale->shader) { - gst_gl_context_del_shader (filter->context, colorscale->shader); + gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, + colorscale->shader); colorscale->shader = NULL; } } @@ -192,12 +193,13 @@ gst_gl_colorscale_filter_texture (GstGLFilter * filter, guint in_tex, colorscale = GST_GL_COLORSCALE (filter); - if (gst_gl_context_get_gl_api (filter->context) & (GST_GL_API_GLES2 | - GST_GL_API_OPENGL3)) + if (gst_gl_context_get_gl_api (GST_GL_BASE_FILTER (filter)->context) & + (GST_GL_API_GLES2 | GST_GL_API_OPENGL3)) gst_gl_filter_render_to_target_with_shader (filter, TRUE, in_tex, out_tex, colorscale->shader); - if (gst_gl_context_get_gl_api (filter->context) & GST_GL_API_OPENGL) + if (gst_gl_context_get_gl_api (GST_GL_BASE_FILTER (filter)->context) & + GST_GL_API_OPENGL) gst_gl_filter_render_to_target (filter, TRUE, in_tex, out_tex, gst_gl_colorscale_callback, colorscale); @@ -211,8 +213,9 @@ gst_gl_colorscale_callback (gint width, gint height, guint texture, GstGLFilter *filter = GST_GL_FILTER (stuff); #if GST_GL_HAVE_OPENGL - if (gst_gl_context_get_gl_api (filter->context) & GST_GL_API_OPENGL) { - const GstGLFuncs *gl = filter->context->gl_vtable; + if (gst_gl_context_get_gl_api (GST_GL_BASE_FILTER (filter)->context) & + GST_GL_API_OPENGL) { + const GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gl->MatrixMode (GL_PROJECTION); gl->LoadIdentity (); diff --git a/ext/gl/gstgldeinterlace.c b/ext/gl/gstgldeinterlace.c index 641759e63b..bf969f2dc4 100644 --- a/ext/gl/gstgldeinterlace.c +++ b/ext/gl/gstgldeinterlace.c @@ -169,7 +169,7 @@ gst_gl_deinterlace_class_init (GstGLDeinterlaceClass * klass) GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_deinterlace_init_shader; GST_GL_FILTER_CLASS (klass)->onReset = gst_gl_deinterlace_reset; - GST_GL_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL; + GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL; } static void @@ -185,13 +185,12 @@ gst_gl_deinterlace_reset (GstGLFilter * filter) { GstGLDeinterlace *deinterlace_filter = GST_GL_DEINTERLACE (filter); - if (deinterlace_filter->prev_buffer) { - gst_buffer_unref (deinterlace_filter->prev_buffer); - deinterlace_filter->prev_buffer = NULL; - } + gst_buffer_replace (&deinterlace_filter->prev_buffer, NULL); + //blocking call, wait the opengl thread has destroyed the shader if (deinterlace_filter->shader) - gst_gl_context_del_shader (filter->context, deinterlace_filter->shader); + gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, + deinterlace_filter->shader); deinterlace_filter->shader = NULL; } @@ -227,8 +226,8 @@ gst_gl_deinterlace_init_shader (GstGLFilter * filter) GstGLDeinterlace *deinterlace_filter = GST_GL_DEINTERLACE (filter); //blocking call, wait the opengl thread has compiled the shader - return gst_gl_context_gen_shader (filter->context, 0, greedyh_fragment_source, - &deinterlace_filter->shader); + return gst_gl_context_gen_shader (GST_GL_BASE_FILTER (filter)->context, 0, + greedyh_fragment_source, &deinterlace_filter->shader); } static gboolean @@ -252,10 +251,7 @@ gst_gl_deinterlace_filter (GstGLFilter * filter, GstBuffer * inbuf, gst_gl_filter_filter_texture (filter, inbuf, outbuf); - if (deinterlace_filter->prev_buffer) { - gst_buffer_unref (deinterlace_filter->prev_buffer); - } - deinterlace_filter->prev_buffer = gst_buffer_ref (filter->uploaded_buffer); + gst_buffer_replace (&deinterlace_filter->prev_buffer, inbuf); return TRUE; } @@ -267,7 +263,7 @@ gst_gl_deinterlace_callback (gint width, gint height, guint texture, { GstGLDeinterlace *deinterlace_filter = GST_GL_DEINTERLACE (stuff); GstGLFilter *filter = GST_GL_FILTER (stuff); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; guint temp; GLfloat verts[] = { -1.0, -1.0, @@ -294,7 +290,7 @@ gst_gl_deinterlace_callback (gint width, gint height, guint texture, gl->Enable (GL_TEXTURE_2D); if (G_UNLIKELY (deinterlace_filter->prev_tex == 0)) { - gst_gl_context_gen_texture (filter->context, + gst_gl_context_gen_texture (GST_GL_BASE_FILTER (filter)->context, &deinterlace_filter->prev_tex, GST_VIDEO_INFO_FORMAT (&filter->out_info), GST_VIDEO_INFO_WIDTH (&filter->out_info), diff --git a/ext/gl/gstgldifferencematte.c b/ext/gl/gstgldifferencematte.c index 31d29e9ff6..ce1b5130cc 100644 --- a/ext/gl/gstgldifferencematte.c +++ b/ext/gl/gstgldifferencematte.c @@ -81,7 +81,7 @@ static void gst_gl_differencematte_init_gl_resources (GstGLFilter * filter) { GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (filter); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gint i; for (i = 0; i < 4; i++) { @@ -95,12 +95,13 @@ gst_gl_differencematte_init_gl_resources (GstGLFilter * filter) 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->shader[i] = gst_gl_shader_new (filter->context); + differencematte->shader[i] = + gst_gl_shader_new (GST_GL_BASE_FILTER (filter)->context); } if (!gst_gl_shader_compile_and_check (differencematte->shader[0], difference_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) { - gst_gl_context_set_error (GST_GL_FILTER (differencematte)->context, + gst_gl_context_set_error (GST_GL_BASE_FILTER (differencematte)->context, "Failed to initialize difference shader"); GST_ELEMENT_ERROR (differencematte, RESOURCE, NOT_FOUND, ("%s", gst_gl_context_get_error ()), (NULL)); @@ -109,7 +110,7 @@ gst_gl_differencematte_init_gl_resources (GstGLFilter * filter) if (!gst_gl_shader_compile_and_check (differencematte->shader[1], hconv7_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) { - gst_gl_context_set_error (GST_GL_FILTER (differencematte)->context, + gst_gl_context_set_error (GST_GL_BASE_FILTER (differencematte)->context, "Failed to initialize hconv7 shader"); GST_ELEMENT_ERROR (differencematte, RESOURCE, NOT_FOUND, ("%s", gst_gl_context_get_error ()), (NULL)); @@ -118,7 +119,7 @@ gst_gl_differencematte_init_gl_resources (GstGLFilter * filter) if (!gst_gl_shader_compile_and_check (differencematte->shader[2], vconv7_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) { - gst_gl_context_set_error (GST_GL_FILTER (differencematte)->context, + gst_gl_context_set_error (GST_GL_BASE_FILTER (differencematte)->context, "Failed to initialize vconv7 shader"); GST_ELEMENT_ERROR (differencematte, RESOURCE, NOT_FOUND, ("%s", gst_gl_context_get_error ()), (NULL)); @@ -127,7 +128,7 @@ gst_gl_differencematte_init_gl_resources (GstGLFilter * filter) if (!gst_gl_shader_compile_and_check (differencematte->shader[3], texture_interp_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) { - gst_gl_context_set_error (GST_GL_FILTER (differencematte)->context, + gst_gl_context_set_error (GST_GL_BASE_FILTER (differencematte)->context, "Failed to initialize interp shader"); GST_ELEMENT_ERROR (differencematte, RESOURCE, NOT_FOUND, ("%s", gst_gl_context_get_error ()), (NULL)); @@ -140,7 +141,7 @@ static void gst_gl_differencematte_reset_gl_resources (GstGLFilter * filter) { GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (filter); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gint i; gl->DeleteTextures (1, &differencematte->savedbgtexture); @@ -194,7 +195,7 @@ gst_gl_differencematte_class_init (GstGLDifferenceMatteClass * klass) "Saves a background frame and replace it with a pixbuf", "Filippo Argiolas "); - GST_GL_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL; + GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL; } static void @@ -265,7 +266,7 @@ gst_gl_differencematte_save_texture (gint width, gint height, guint texture, gpointer stuff) { GstGLFilter *filter = GST_GL_FILTER (stuff); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gl->MatrixMode (GL_PROJECTION); gl->LoadIdentity (); @@ -278,7 +279,7 @@ init_pixbuf_texture (GstGLContext * context, gpointer data) { GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (data); GstGLFilter *filter = GST_GL_FILTER (data); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gl->DeleteTextures (1, &differencematte->newbgtexture); gl->GenTextures (1, &differencematte->newbgtexture); @@ -311,7 +312,7 @@ gst_gl_differencematte_diff (gint width, gint height, guint texture, { GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (stuff); GstGLFilter *filter = GST_GL_FILTER (stuff); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gl->MatrixMode (GL_PROJECTION); gl->LoadIdentity (); @@ -341,7 +342,7 @@ gst_gl_differencematte_hblur (gint width, gint height, guint texture, { GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (stuff); GstGLFilter *filter = GST_GL_FILTER (stuff); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gl->MatrixMode (GL_PROJECTION); gl->LoadIdentity (); @@ -368,7 +369,7 @@ gst_gl_differencematte_vblur (gint width, gint height, guint texture, { GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (stuff); GstGLFilter *filter = GST_GL_FILTER (stuff); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gl->MatrixMode (GL_PROJECTION); gl->LoadIdentity (); @@ -395,7 +396,7 @@ gst_gl_differencematte_interp (gint width, gint height, guint texture, { GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (stuff); GstGLFilter *filter = GST_GL_FILTER (stuff); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gl->MatrixMode (GL_PROJECTION); glLoadIdentity (); @@ -432,7 +433,7 @@ gst_gl_differencematte_identity (gint width, gint height, guint texture, { GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (stuff); GstGLFilter *filter = GST_GL_FILTER (differencematte); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gl->MatrixMode (GL_PROJECTION); gl->LoadIdentity (); @@ -454,8 +455,8 @@ gst_gl_differencematte_filter_texture (GstGLFilter * filter, guint in_tex, differencematte->pixbuf = NULL; /* if loader failed then context is turned off */ - gst_gl_context_thread_add (filter->context, init_pixbuf_texture, - differencematte); + gst_gl_context_thread_add (GST_GL_BASE_FILTER (filter)->context, + init_pixbuf_texture, differencematte); /* save current frame, needed to calculate difference between * this frame and next ones */ @@ -517,7 +518,7 @@ gst_gl_differencematte_loader (GstGLFilter * filter) guchar **rows = NULL; gint filler; - if (!filter->context) + if (!GST_GL_BASE_FILTER (filter)->context) return TRUE; if ((fp = fopen (differencematte->location, "rb")) == NULL) diff --git a/ext/gl/gstgleffects.c b/ext/gl/gstgleffects.c index dab8b32b3a..a85e624854 100644 --- a/ext/gl/gstgleffects.c +++ b/ext/gl/gstgleffects.c @@ -130,8 +130,8 @@ gst_gl_effects_effect_get_type (void) static void gst_gl_effects_set_effect (GstGLEffects * effects, gint effect_type) { - GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (effects); - GstGLContext *context = GST_GL_FILTER (effects)->context; + GstGLBaseFilterClass *filter_class = GST_GL_BASE_FILTER_GET_CLASS (effects); + GstGLContext *context = GST_GL_BASE_FILTER (effects)->context; switch (effect_type) { case GST_GL_EFFECT_IDENTITY: @@ -232,7 +232,7 @@ static void gst_gl_effects_init_gl_resources (GstGLFilter * filter) { GstGLEffects *effects = GST_GL_EFFECTS (filter); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gint i = 0; for (i = 0; i < NEEDED_TEXTURES; i++) { @@ -260,7 +260,7 @@ static void gst_gl_effects_reset_gl_resources (GstGLFilter * filter) { GstGLEffects *effects = GST_GL_EFFECTS (filter); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gint i = 0; for (i = 0; i < NEEDED_TEXTURES; i++) { @@ -313,7 +313,7 @@ gst_gl_effects_class_init (GstGLEffectsClass * klass) "GL Shading Language effects", "Filippo Argiolas "); - GST_GL_FILTER_CLASS (klass)->supported_gl_api = + GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL | GST_GL_API_GLES2 | GST_GL_API_OPENGL3; } @@ -349,7 +349,7 @@ gst_gl_effects_ghash_func_clean (gpointer key, gpointer value, gpointer data) GstGLFilter *filter = (GstGLFilter *) data; //blocking call, wait the opengl thread has destroyed the shader - gst_gl_context_del_shader (filter->context, shader); + gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, shader); value = NULL; } @@ -440,7 +440,8 @@ gst_gl_effects_filter_texture (GstGLFilter * filter, guint in_tex, effects->outtexture = out_tex; if (effects->horizontal_swap == TRUE) - gst_gl_context_thread_add (filter->context, set_horizontal_swap, effects); + gst_gl_context_thread_add (GST_GL_BASE_FILTER (filter)->context, + set_horizontal_swap, effects); effects->effect (effects); diff --git a/ext/gl/gstglfilterapp.c b/ext/gl/gstglfilterapp.c index 78be4f8c55..e347e28891 100644 --- a/ext/gl/gstglfilterapp.c +++ b/ext/gl/gstglfilterapp.c @@ -112,7 +112,7 @@ gst_gl_filter_app_class_init (GstGLFilterAppClass * klass) "Use client callbacks to define the scene", "Julien Isorce "); - GST_GL_FILTER_CLASS (klass)->supported_gl_api = + GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL | GST_GL_API_GLES2 | GST_GL_API_OPENGL3; } @@ -196,7 +196,7 @@ gst_gl_filter_app_filter_texture (GstGLFilter * filter, guint in_tex, cb.height = GST_VIDEO_INFO_HEIGHT (&filter->in_info); //blocking call, use a FBO - gst_gl_context_use_fbo_v2 (filter->context, + 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); @@ -217,8 +217,9 @@ gst_gl_filter_app_callback (gint width, gint height, guint texture, GstGLFilter *filter = GST_GL_FILTER (stuff); #if GST_GL_HAVE_OPENGL - if (gst_gl_context_get_gl_api (filter->context) & GST_GL_API_OPENGL) { - GstGLFuncs *gl = filter->context->gl_vtable; + if (gst_gl_context_get_gl_api (GST_GL_BASE_FILTER (filter)->context) & + GST_GL_API_OPENGL) { + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gl->MatrixMode (GL_PROJECTION); gl->LoadIdentity (); diff --git a/ext/gl/gstglfilterblur.c b/ext/gl/gstglfilterblur.c index ba7f4e443f..842a014103 100644 --- a/ext/gl/gstglfilterblur.c +++ b/ext/gl/gstglfilterblur.c @@ -67,7 +67,7 @@ static void gst_gl_filterblur_init_resources (GstGLFilter * filter) { GstGLFilterBlur *filterblur = GST_GL_FILTERBLUR (filter); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gl->GenTextures (1, &filterblur->midtexture); gl->BindTexture (GL_TEXTURE_2D, filterblur->midtexture); @@ -85,7 +85,7 @@ static void gst_gl_filterblur_reset_resources (GstGLFilter * filter) { GstGLFilterBlur *filterblur = GST_GL_FILTERBLUR (filter); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gl->DeleteTextures (1, &filterblur->midtexture); } @@ -115,7 +115,7 @@ gst_gl_filterblur_class_init (GstGLFilterBlurClass * klass) GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_filterblur_init_shader; GST_GL_FILTER_CLASS (klass)->onReset = gst_gl_filter_filterblur_reset; - GST_GL_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL; + GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL; } static void @@ -137,12 +137,14 @@ gst_gl_filter_filterblur_reset (GstGLFilter * filter) //blocking call, wait the opengl thread has destroyed the shader if (filterblur->shader0) - gst_gl_context_del_shader (filter->context, filterblur->shader0); + gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, + filterblur->shader0); filterblur->shader0 = NULL; //blocking call, wait the opengl thread has destroyed the shader if (filterblur->shader1) - gst_gl_context_del_shader (filter->context, filterblur->shader1); + gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, + filterblur->shader1); filterblur->shader1 = NULL; } @@ -178,13 +180,13 @@ gst_gl_filterblur_init_shader (GstGLFilter * filter) GstGLFilterBlur *blur_filter = GST_GL_FILTERBLUR (filter); //blocking call, wait the opengl thread has compiled the shader - if (!gst_gl_context_gen_shader (filter->context, 0, hconv7_fragment_source, - &blur_filter->shader0)) + if (!gst_gl_context_gen_shader (GST_GL_BASE_FILTER (filter)->context, 0, + hconv7_fragment_source, &blur_filter->shader0)) return FALSE; //blocking call, wait the opengl thread has compiled the shader - if (!gst_gl_context_gen_shader (filter->context, 0, vconv7_fragment_source, - &blur_filter->shader1)) + if (!gst_gl_context_gen_shader (GST_GL_BASE_FILTER (filter)->context, 0, + vconv7_fragment_source, &blur_filter->shader1)) return FALSE; return TRUE; @@ -211,7 +213,7 @@ gst_gl_filterblur_hcallback (gint width, gint height, guint texture, { GstGLFilter *filter = GST_GL_FILTER (stuff); GstGLFilterBlur *filterblur = GST_GL_FILTERBLUR (filter); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gl->MatrixMode (GL_PROJECTION); gl->LoadIdentity (); @@ -238,7 +240,7 @@ gst_gl_filterblur_vcallback (gint width, gint height, guint texture, { GstGLFilter *filter = GST_GL_FILTER (stuff); GstGLFilterBlur *filterblur = GST_GL_FILTERBLUR (filter); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gl->MatrixMode (GL_PROJECTION); gl->LoadIdentity (); diff --git a/ext/gl/gstglfiltercube.c b/ext/gl/gstglfiltercube.c index e7582419e5..518b295671 100644 --- a/ext/gl/gstglfiltercube.c +++ b/ext/gl/gstglfiltercube.c @@ -180,7 +180,7 @@ gst_gl_filter_cube_class_init (GstGLFilterCubeClass * klass) "Filter/Effect/Video", "Map input texture on the 6 cube faces", "Julien Isorce "); - GST_GL_FILTER_CLASS (klass)->supported_gl_api = + GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL | GST_GL_API_GLES2 | GST_GL_API_OPENGL3; } @@ -279,7 +279,7 @@ static void gst_gl_filter_cube_reset_gl (GstGLFilter * filter) { GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (filter); - const GstGLFuncs *gl = filter->context->gl_vtable; + const GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; if (cube_filter->vao) { gl->DeleteVertexArrays (1, &cube_filter->vao); @@ -299,7 +299,8 @@ gst_gl_filter_cube_reset (GstGLFilter * filter) /* blocking call, wait the opengl thread has destroyed the shader */ if (cube_filter->shader) - gst_gl_context_del_shader (filter->context, cube_filter->shader); + gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, + cube_filter->shader); cube_filter->shader = NULL; } @@ -309,8 +310,8 @@ gst_gl_filter_cube_init_shader (GstGLFilter * filter) GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (filter); /* blocking call, wait the opengl thread has compiled the shader */ - return gst_gl_context_gen_shader (filter->context, cube_v_src, cube_f_src, - &cube_filter->shader); + return gst_gl_context_gen_shader (GST_GL_BASE_FILTER (filter)->context, + cube_v_src, cube_f_src, &cube_filter->shader); } static gboolean @@ -322,7 +323,7 @@ gst_gl_filter_cube_filter_texture (GstGLFilter * filter, guint in_tex, cube_filter->in_tex = in_tex; /* blocking call, use a FBO */ - gst_gl_context_use_fbo_v2 (filter->context, + 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); @@ -369,7 +370,7 @@ static const GLfloat vertices[] = { static void _bind_buffer (GstGLFilterCube * cube_filter) { - const GstGLFuncs *gl = GST_GL_FILTER (cube_filter)->context->gl_vtable; + const GstGLFuncs *gl = GST_GL_BASE_FILTER (cube_filter)->context->gl_vtable; gl->BindBuffer (GL_ARRAY_BUFFER, cube_filter->vertex_buffer); @@ -394,7 +395,7 @@ _bind_buffer (GstGLFilterCube * cube_filter) static void _unbind_buffer (GstGLFilterCube * cube_filter) { - const GstGLFuncs *gl = GST_GL_FILTER (cube_filter)->context->gl_vtable; + const GstGLFuncs *gl = GST_GL_BASE_FILTER (cube_filter)->context->gl_vtable; gl->BindBuffer (GL_ARRAY_BUFFER, 0); @@ -407,7 +408,7 @@ _callback (gpointer stuff) { GstGLFilter *filter = GST_GL_FILTER (stuff); GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (filter); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; static GLfloat xrot = 0; static GLfloat yrot = 0; diff --git a/ext/gl/gstglfilterglass.c b/ext/gl/gstglfilterglass.c index f65be662e8..0fe109aa5f 100644 --- a/ext/gl/gstglfilterglass.c +++ b/ext/gl/gstglfilterglass.c @@ -163,7 +163,7 @@ gst_gl_filter_glass_class_init (GstGLFilterGlassClass * klass) GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_filter_glass_init_shader; GST_GL_FILTER_CLASS (klass)->onReset = gst_gl_filter_glass_reset; - GST_GL_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL; + GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL; } static void @@ -180,10 +180,11 @@ gst_gl_filter_glass_reset (GstGLFilter * filter) //blocking call, wait the opengl thread has destroyed the shader if (glass_filter->shader) - gst_gl_context_del_shader (filter->context, glass_filter->shader); + gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, + glass_filter->shader); glass_filter->shader = NULL; if (glass_filter->passthrough_shader) - gst_gl_context_del_shader (filter->context, + gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, glass_filter->passthrough_shader); glass_filter->passthrough_shader = NULL; } @@ -222,12 +223,13 @@ gst_gl_filter_glass_init_shader (GstGLFilter * filter) //blocking call, wait the opengl thread has compiled the shader ret = - gst_gl_context_gen_shader (filter->context, glass_vertex_source, - glass_fragment_source, &glass_filter->shader); + gst_gl_context_gen_shader (GST_GL_BASE_FILTER (filter)->context, + glass_vertex_source, glass_fragment_source, &glass_filter->shader); if (ret) ret = - gst_gl_context_gen_shader (filter->context, passthrough_vertex, - passthrough_fragment, &glass_filter->passthrough_shader); + gst_gl_context_gen_shader (GST_GL_BASE_FILTER (filter)->context, + passthrough_vertex, passthrough_fragment, + &glass_filter->passthrough_shader); return ret; } @@ -240,7 +242,7 @@ gst_gl_filter_glass_filter_texture (GstGLFilter * filter, guint in_tex, glass_filter->in_tex = in_tex; //blocking call, use a FBO - gst_gl_context_use_fbo_v2 (filter->context, + 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, @@ -262,7 +264,7 @@ static void gst_gl_filter_glass_draw_background_gradient (GstGLFilterGlass * glass) { GstGLFilter *filter = GST_GL_FILTER (glass); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; /* *INDENT-OFF* */ gfloat mesh[] = { @@ -303,7 +305,7 @@ gst_gl_filter_glass_draw_video_plane (GstGLFilter * filter, gfloat start_alpha, gfloat stop_alpha, gboolean reversed, gfloat rotation) { GstGLFilterGlass *glass_filter = GST_GL_FILTER_GLASS (filter); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gfloat topy = reversed ? center_y - 1.0f : center_y + 1.0f; gfloat bottomy = reversed ? center_y + 1.0f : center_y - 1.0f; @@ -358,7 +360,7 @@ gst_gl_filter_glass_callback (gpointer stuff) GstGLFilter *filter = GST_GL_FILTER (stuff); GstGLFilterGlass *glass_filter = GST_GL_FILTER_GLASS (stuff); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gint width = GST_VIDEO_INFO_WIDTH (&filter->out_info); gint height = GST_VIDEO_INFO_HEIGHT (&filter->out_info); @@ -401,7 +403,7 @@ gst_gl_filter_glass_callback (gpointer stuff) gst_gl_filter_glass_draw_video_plane (filter, width, height, texture, 0.0f, 0.0f, 1.0f, 1.0f, FALSE, rotation); - gst_gl_context_clear_shader (filter->context); + gst_gl_context_clear_shader (GST_GL_BASE_FILTER (filter)->context); gl->Disable (GL_TEXTURE_2D); gl->Disable (GL_BLEND); diff --git a/ext/gl/gstglfilterlaplacian.c b/ext/gl/gstglfilterlaplacian.c index 4dbcf7d3bf..da656bc6d7 100644 --- a/ext/gl/gstglfilterlaplacian.c +++ b/ext/gl/gstglfilterlaplacian.c @@ -120,7 +120,7 @@ gst_gl_filter_laplacian_class_init (GstGLFilterLaplacianClass * klass) GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_filter_laplacian_init_shader; GST_GL_FILTER_CLASS (klass)->onReset = gst_gl_filter_laplacian_reset; - GST_GL_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL; + GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL; } static void @@ -136,7 +136,8 @@ gst_gl_filter_laplacian_reset (GstGLFilter * filter) //blocking call, wait the opengl thread has destroyed the shader if (laplacian_filter->shader) - gst_gl_context_del_shader (filter->context, laplacian_filter->shader); + gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, + laplacian_filter->shader); laplacian_filter->shader = NULL; } @@ -172,7 +173,7 @@ gst_gl_filter_laplacian_init_shader (GstGLFilter * filter) GstGLFilterLaplacian *laplacian_filter = GST_GL_FILTER_LAPLACIAN (filter); //blocking call, wait the opengl thread has compiled the shader - return gst_gl_context_gen_shader (filter->context, 0, + return gst_gl_context_gen_shader (GST_GL_BASE_FILTER (filter)->context, 0, convolution_fragment_source, &laplacian_filter->shader); } @@ -197,7 +198,7 @@ gst_gl_filter_laplacian_callback (gint width, gint height, guint texture, { GstGLFilter *filter = GST_GL_FILTER (stuff); GstGLFilterLaplacian *laplacian_filter = GST_GL_FILTER_LAPLACIAN (filter); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gfloat kernel[9] = { 0.0, -1.0, 0.0, -1.0, 4.0, -1.0, diff --git a/ext/gl/gstglfilterreflectedscreen.c b/ext/gl/gstglfilterreflectedscreen.c index b0d5711102..bacb8f3af1 100644 --- a/ext/gl/gstglfilterreflectedscreen.c +++ b/ext/gl/gstglfilterreflectedscreen.c @@ -139,7 +139,7 @@ gst_gl_filter_reflected_screen_class_init (GstGLFilterReflectedScreenClass * "OpenGL Reflected Screen filter", "Filter/Effect/Video", "Reflected Screen Filter", "Pierre POUZOL "); - GST_GL_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL; + GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL; } static void diff --git a/ext/gl/gstglfiltershader.c b/ext/gl/gstglfiltershader.c index 77a597c45d..91c4cfb74b 100644 --- a/ext/gl/gstglfiltershader.c +++ b/ext/gl/gstglfiltershader.c @@ -150,7 +150,7 @@ gst_gl_filtershader_class_init (GstGLFilterShaderClass * klass) GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_filtershader_init_shader; GST_GL_FILTER_CLASS (klass)->onReset = gst_gl_filter_filtershader_reset; - GST_GL_FILTER_CLASS (klass)->supported_gl_api = + GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL | GST_GL_API_GLES2 | GST_GL_API_OPENGL3; } @@ -167,7 +167,8 @@ gst_gl_filter_filtershader_reset (GstGLFilter * filter) //blocking call, wait the opengl thread has destroyed the shader if (filtershader->shader0) - gst_gl_context_del_shader (filter->context, filtershader->shader0); + gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, + filtershader->shader0); filtershader->shader0 = NULL; } @@ -326,8 +327,8 @@ gst_gl_filtershader_init_shader (GstGLFilter * filter) return FALSE; //blocking call, wait the opengl thread has compiled the shader - if (!gst_gl_context_gen_shader (filter->context, text_vertex_shader, - hfilter_fragment_source, &filtershader->shader0)) + if (!gst_gl_context_gen_shader (GST_GL_BASE_FILTER (filter)->context, + text_vertex_shader, hfilter_fragment_source, &filtershader->shader0)) return FALSE; @@ -395,7 +396,7 @@ gst_gl_filtershader_hcallback (gint width, gint height, guint texture, { GstGLFilter *filter = GST_GL_FILTER (stuff); GstGLFilterShader *filtershader = GST_GL_FILTERSHADER (filter); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gst_gl_shader_use (filtershader->shader0); diff --git a/ext/gl/gstglfiltersobel.c b/ext/gl/gstglfiltersobel.c index 55e93b7924..f70b6d2939 100644 --- a/ext/gl/gstglfiltersobel.c +++ b/ext/gl/gstglfiltersobel.c @@ -71,7 +71,7 @@ static void gst_gl_filtersobel_init_resources (GstGLFilter * filter) { GstGLFilterSobel *filtersobel = GST_GL_FILTERSOBEL (filter); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; int i; for (i = 0; i < 2; i++) { @@ -92,7 +92,7 @@ static void gst_gl_filtersobel_reset_resources (GstGLFilter * filter) { GstGLFilterSobel *filtersobel = GST_GL_FILTERSOBEL (filter); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; int i; for (i = 0; i < 2; i++) { @@ -132,7 +132,7 @@ gst_gl_filtersobel_class_init (GstGLFilterSobelClass * klass) "Gstreamer OpenGL Sobel", "Filter/Effect/Video", "Sobel edge detection", "Filippo Argiolas "); - GST_GL_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL; + GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL; } static void @@ -154,19 +154,23 @@ gst_gl_filter_filtersobel_reset (GstGLFilter * filter) //blocking call, wait the opengl thread has destroyed the shader if (filtersobel->desat) - gst_gl_context_del_shader (filter->context, filtersobel->desat); + gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, + filtersobel->desat); filtersobel->desat = NULL; if (filtersobel->hconv) - gst_gl_context_del_shader (filter->context, filtersobel->hconv); + gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, + filtersobel->hconv); filtersobel->hconv = NULL; if (filtersobel->vconv) - gst_gl_context_del_shader (filter->context, filtersobel->vconv); + gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, + filtersobel->vconv); filtersobel->vconv = NULL; if (filtersobel->len) - gst_gl_context_del_shader (filter->context, filtersobel->len); + gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, + filtersobel->len); filtersobel->len = NULL; } @@ -210,16 +214,16 @@ gst_gl_filtersobel_init_shader (GstGLFilter * filter) //blocking call, wait the opengl thread has compiled the shader ret = - gst_gl_context_gen_shader (filter->context, 0, desaturate_fragment_source, - &filtersobel->desat); + gst_gl_context_gen_shader (GST_GL_BASE_FILTER (filter)->context, 0, + desaturate_fragment_source, &filtersobel->desat); ret &= - gst_gl_context_gen_shader (filter->context, 0, + gst_gl_context_gen_shader (GST_GL_BASE_FILTER (filter)->context, 0, sep_sobel_hconv3_fragment_source, &filtersobel->hconv); ret &= - gst_gl_context_gen_shader (filter->context, 0, + gst_gl_context_gen_shader (GST_GL_BASE_FILTER (filter)->context, 0, sep_sobel_vconv3_fragment_source, &filtersobel->vconv); ret &= - gst_gl_context_gen_shader (filter->context, 0, + gst_gl_context_gen_shader (GST_GL_BASE_FILTER (filter)->context, 0, sep_sobel_length_fragment_source, &filtersobel->len); return ret; @@ -250,7 +254,7 @@ gst_gl_filtersobel_length (gint width, gint height, guint texture, gpointer stuff) { GstGLFilter *filter = GST_GL_FILTER (stuff); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; GstGLFilterSobel *filtersobel = GST_GL_FILTERSOBEL (filter); glMatrixMode (GL_PROJECTION); diff --git a/ext/gl/gstglmixer.c b/ext/gl/gstglmixer.c index a1da5f4e63..20d858a15f 100644 --- a/ext/gl/gstglmixer.c +++ b/ext/gl/gstglmixer.c @@ -112,19 +112,14 @@ static gboolean _negotiated_caps (GstVideoAggregator * vagg, GstCaps * caps) { GstGLMixer *mix = GST_GL_MIXER (vagg); - GstGLMixerClass *mix_class = GST_GL_MIXER_GET_CLASS (mix); - GstGLBaseMixerClass *base_mix_class = GST_GL_BASE_MIXER_GET_CLASS (mix); gboolean ret; mix->priv->negotiated = TRUE; - base_mix_class->supported_gl_api = mix_class->supported_gl_api; gst_caps_replace (&mix->out_caps, caps); ret = GST_VIDEO_AGGREGATOR_CLASS (parent_class)->negotiated_caps (vagg, caps); - mix->context = GST_GL_BASE_MIXER (mix)->context; - return ret; } @@ -389,7 +384,6 @@ gst_gl_mixer_class_init (GstGLMixerClass * klass) g_type_class_ref (GST_TYPE_GL_MIXER_PAD); klass->set_caps = NULL; - klass->supported_gl_api = GST_GL_API_ANY; } static void @@ -537,7 +531,6 @@ gst_gl_mixer_decide_allocation (GstGLBaseMixer * base_mix, GstQuery * query) gst_query_parse_allocation (query, &caps, NULL); - mix->context = context; if (mixer_class->set_caps) mixer_class->set_caps (mix, caps); diff --git a/ext/gl/gstglmixer.h b/ext/gl/gstglmixer.h index 5b334750e4..01eed34f20 100644 --- a/ext/gl/gstglmixer.h +++ b/ext/gl/gstglmixer.h @@ -85,8 +85,6 @@ struct _GstGLMixer { GstGLBaseMixer vaggregator; - GstGLContext *context; - GPtrArray *array_buffers; GPtrArray *frames; @@ -101,7 +99,6 @@ struct _GstGLMixer struct _GstGLMixerClass { GstGLBaseMixerClass parent_class; - GstGLAPI supported_gl_api; GstGLMixerSetCaps set_caps; GstGLMixerReset reset; diff --git a/ext/gl/gstglmosaic.c b/ext/gl/gstglmosaic.c index e8daef9f6d..726674b4df 100644 --- a/ext/gl/gstglmosaic.c +++ b/ext/gl/gstglmosaic.c @@ -135,7 +135,7 @@ gst_gl_mosaic_class_init (GstGLMosaicClass * klass) GST_GL_MIXER_CLASS (klass)->reset = gst_gl_mosaic_reset; GST_GL_MIXER_CLASS (klass)->process_textures = gst_gl_mosaic_process_textures; - GST_GL_MIXER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL; + GST_GL_BASE_MIXER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL; } static void @@ -180,7 +180,8 @@ gst_gl_mosaic_reset (GstGLMixer * mixer) //blocking call, wait the opengl thread has destroyed the shader if (mosaic->shader) - gst_gl_context_del_shader (mixer->context, mosaic->shader); + gst_gl_context_del_shader (GST_GL_BASE_MIXER (mixer)->context, + mosaic->shader); mosaic->shader = NULL; } @@ -190,8 +191,8 @@ gst_gl_mosaic_init_shader (GstGLMixer * mixer, GstCaps * outcaps) GstGLMosaic *mosaic = GST_GL_MOSAIC (mixer); //blocking call, wait the opengl thread has compiled the shader - return gst_gl_context_gen_shader (mixer->context, mosaic_v_src, mosaic_f_src, - &mosaic->shader); + return gst_gl_context_gen_shader (GST_GL_BASE_MIXER (mixer)->context, + mosaic_v_src, mosaic_f_src, &mosaic->shader); } static gboolean @@ -203,7 +204,7 @@ gst_gl_mosaic_process_textures (GstGLMixer * mix, GPtrArray * frames, mosaic->input_frames = frames; //blocking call, use a FBO - gst_gl_context_use_fbo_v2 (mix->context, + 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); @@ -217,7 +218,7 @@ gst_gl_mosaic_callback (gpointer stuff) { GstGLMosaic *mosaic = GST_GL_MOSAIC (stuff); GstGLMixer *mixer = GST_GL_MIXER (mosaic); - GstGLFuncs *gl = mixer->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_MIXER (mixer)->context->gl_vtable; static GLfloat xrot = 0; static GLfloat yrot = 0; @@ -239,7 +240,7 @@ gst_gl_mosaic_callback (gpointer stuff) guint count = 0; - gst_gl_context_clear_shader (mixer->context); + gst_gl_context_clear_shader (GST_GL_BASE_MIXER (mixer)->context); gl->BindTexture (GL_TEXTURE_2D, 0); gl->Disable (GL_TEXTURE_2D); @@ -344,7 +345,7 @@ gst_gl_mosaic_callback (gpointer stuff) gl->Disable (GL_DEPTH_TEST); - gst_gl_context_clear_shader (mixer->context); + gst_gl_context_clear_shader (GST_GL_BASE_MIXER (mixer)->context); xrot += 0.6f; yrot += 0.4f; diff --git a/ext/gl/gstgloverlay.c b/ext/gl/gstgloverlay.c index 1371264af5..2dd53269f3 100644 --- a/ext/gl/gstgloverlay.c +++ b/ext/gl/gstgloverlay.c @@ -125,10 +125,11 @@ gst_gl_overlay_init_gl_resources (GstGLFilter * filter) GstGLOverlay *overlay = GST_GL_OVERLAY (filter); if (overlay->shader) - gst_gl_context_del_shader (filter->context, overlay->shader); + gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, + overlay->shader); - return gst_gl_context_gen_shader (filter->context, overlay_v_src, - overlay_f_src, &overlay->shader); + return gst_gl_context_gen_shader (GST_GL_BASE_FILTER (filter)->context, + overlay_v_src, overlay_f_src, &overlay->shader); } /* free resources that need a gl context */ @@ -136,10 +137,11 @@ static void gst_gl_overlay_reset_gl_resources (GstGLFilter * filter) { GstGLOverlay *overlay = GST_GL_OVERLAY (filter); - const GstGLFuncs *gl = filter->context->gl_vtable; + const GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; if (overlay->shader) { - gst_gl_context_del_shader (filter->context, overlay->shader); + gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, + overlay->shader); overlay->shader = NULL; } @@ -245,7 +247,7 @@ gst_gl_overlay_class_init (GstGLOverlayClass * klass) "Filippo Argiolas , " "Matthew Waters "); - GST_GL_FILTER_CLASS (klass)->supported_gl_api = + GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL | GST_GL_API_GLES2 | GST_GL_API_OPENGL3; } @@ -373,7 +375,7 @@ gst_gl_overlay_set_caps (GstGLFilter * filter, GstCaps * incaps, static void _unbind_buffer (GstGLOverlay * overlay) { - const GstGLFuncs *gl = GST_GL_FILTER (overlay)->context->gl_vtable; + const GstGLFuncs *gl = GST_GL_BASE_FILTER (overlay)->context->gl_vtable; gl->BindBuffer (GL_ARRAY_BUFFER, 0); @@ -384,7 +386,7 @@ _unbind_buffer (GstGLOverlay * overlay) static void _bind_buffer (GstGLOverlay * overlay, GLuint vbo) { - const GstGLFuncs *gl = GST_GL_FILTER (overlay)->context->gl_vtable; + const GstGLFuncs *gl = GST_GL_BASE_FILTER (overlay)->context->gl_vtable; gl->BindBuffer (GL_ARRAY_BUFFER, vbo); @@ -415,7 +417,7 @@ gst_gl_overlay_callback (gint width, gint height, guint texture, gpointer stuff) GstMapInfo map_info; guint image_tex; gboolean memory_mapped = FALSE; - const GstGLFuncs *gl = filter->context->gl_vtable; + const GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; GLushort indices[] = { 0, 1, 2, @@ -423,14 +425,16 @@ gst_gl_overlay_callback (gint width, gint height, guint texture, gpointer stuff) }; #if GST_GL_HAVE_OPENGL - if (gst_gl_context_get_gl_api (filter->context) & GST_GL_API_OPENGL) { + if (gst_gl_context_get_gl_api (GST_GL_BASE_FILTER (filter)->context) & + GST_GL_API_OPENGL) { gl->MatrixMode (GL_PROJECTION); gl->LoadIdentity (); } #endif - if (gst_gl_context_get_gl_api (filter->context) & GST_GL_API_OPENGL) + if (gst_gl_context_get_gl_api (GST_GL_BASE_FILTER (filter)->context) & + GST_GL_API_OPENGL) gl->Enable (GL_TEXTURE_2D); gl->ActiveTexture (GL_TEXTURE0); @@ -549,7 +553,7 @@ out: _unbind_buffer (overlay); } - gst_gl_context_clear_shader (filter->context); + gst_gl_context_clear_shader (GST_GL_BASE_FILTER (filter)->context); if (memory_mapped) gst_memory_unmap ((GstMemory *) overlay->image_memory, &map_info); @@ -643,8 +647,8 @@ gst_gl_overlay_load_jpeg (GstGLFilter * filter) gst_video_info_align (&v_info, &v_align); overlay->image_memory = - (GstGLMemory *) gst_gl_memory_alloc (filter->context, NULL, &v_info, 0, - &v_align); + (GstGLMemory *) gst_gl_memory_alloc (GST_GL_BASE_FILTER (filter)->context, + NULL, &v_info, 0, &v_align); if (!gst_memory_map ((GstMemory *) overlay->image_memory, &map_info, GST_MAP_WRITE)) { @@ -683,7 +687,7 @@ gst_gl_overlay_load_png (GstGLFilter * filter) png_byte magic[8]; gint n_read; - if (!filter->context) + if (!GST_GL_BASE_FILTER (filter)->context) return 1; if ((fp = fopen (overlay->location, "rb")) == NULL) @@ -744,8 +748,8 @@ gst_gl_overlay_load_png (GstGLFilter * filter) gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGBA, width, height); overlay->image_memory = - (GstGLMemory *) gst_gl_memory_alloc (filter->context, NULL, &v_info, 0, - NULL); + (GstGLMemory *) gst_gl_memory_alloc (GST_GL_BASE_FILTER (filter)->context, + NULL, &v_info, 0, NULL); if (!gst_memory_map ((GstMemory *) overlay->image_memory, &map_info, GST_MAP_WRITE)) { diff --git a/ext/gl/gstgltransformation.c b/ext/gl/gstgltransformation.c index 689a6cd5f9..f9273c71e9 100644 --- a/ext/gl/gstgltransformation.c +++ b/ext/gl/gstgltransformation.c @@ -205,7 +205,7 @@ gst_gl_transformation_class_init (GstGLTransformationClass * klass) "Filter/Effect/Video", "Transform video on the GPU", "Lubosz Sarnecki "); - GST_GL_FILTER_CLASS (klass)->supported_gl_api = + GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | GST_GL_API_GLES2; } @@ -393,7 +393,7 @@ static void gst_gl_transformation_reset_gl (GstGLFilter * filter) { GstGLTransformation *transformation = GST_GL_TRANSFORMATION (filter); - const GstGLFuncs *gl = filter->context->gl_vtable; + const GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; if (transformation->vao) { gl->DeleteVertexArrays (1, &transformation->vao); @@ -413,7 +413,8 @@ gst_gl_transformation_reset (GstGLFilter * filter) /* blocking call, wait until the opengl thread has destroyed the shader */ if (transformation->shader) - gst_gl_context_del_shader (filter->context, transformation->shader); + gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, + transformation->shader); transformation->shader = NULL; } @@ -422,10 +423,10 @@ gst_gl_transformation_init_shader (GstGLFilter * filter) { GstGLTransformation *transformation = GST_GL_TRANSFORMATION (filter); - if (gst_gl_context_get_gl_api (filter->context)) { + if (gst_gl_context_get_gl_api (GST_GL_BASE_FILTER (filter)->context)) { /* blocking call, wait until the opengl thread has compiled the shader */ - return gst_gl_context_gen_shader (filter->context, cube_v_src, cube_f_src, - &transformation->shader); + return gst_gl_context_gen_shader (GST_GL_BASE_FILTER (filter)->context, + cube_v_src, cube_f_src, &transformation->shader); } return TRUE; } @@ -439,7 +440,7 @@ gst_gl_transformation_filter_texture (GstGLFilter * filter, guint in_tex, transformation->in_tex = in_tex; /* blocking call, use a FBO */ - gst_gl_context_use_fbo_v2 (filter->context, + 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, @@ -452,7 +453,8 @@ gst_gl_transformation_filter_texture (GstGLFilter * filter, guint in_tex, static void _upload_vertices (GstGLTransformation * transformation) { - const GstGLFuncs *gl = GST_GL_FILTER (transformation)->context->gl_vtable; + const GstGLFuncs *gl = + GST_GL_BASE_FILTER (transformation)->context->gl_vtable; /* *INDENT-OFF* */ GLfloat vertices[] = { @@ -472,7 +474,8 @@ _upload_vertices (GstGLTransformation * transformation) static void _bind_buffer (GstGLTransformation * transformation) { - const GstGLFuncs *gl = GST_GL_FILTER (transformation)->context->gl_vtable; + const GstGLFuncs *gl = + GST_GL_BASE_FILTER (transformation)->context->gl_vtable; gl->BindBuffer (GL_ARRAY_BUFFER, transformation->vertex_buffer); @@ -491,7 +494,8 @@ _bind_buffer (GstGLTransformation * transformation) static void _unbind_buffer (GstGLTransformation * transformation) { - const GstGLFuncs *gl = GST_GL_FILTER (transformation)->context->gl_vtable; + const GstGLFuncs *gl = + GST_GL_BASE_FILTER (transformation)->context->gl_vtable; gl->BindBuffer (GL_ARRAY_BUFFER, 0); @@ -504,13 +508,13 @@ gst_gl_transformation_callback (gpointer stuff) { GstGLFilter *filter = GST_GL_FILTER (stuff); GstGLTransformation *transformation = GST_GL_TRANSFORMATION (filter); - GstGLFuncs *gl = filter->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; GLushort indices[] = { 0, 1, 2, 3, 0 }; GLfloat temp_matrix[16]; - gst_gl_context_clear_shader (filter->context); + gst_gl_context_clear_shader (GST_GL_BASE_FILTER (filter)->context); gl->BindTexture (GL_TEXTURE_2D, 0); gl->ClearColor (0.f, 0.f, 0.f, 1.f); @@ -563,6 +567,6 @@ gst_gl_transformation_callback (gpointer stuff) else _unbind_buffer (transformation); - gst_gl_context_clear_shader (filter->context); + gst_gl_context_clear_shader (GST_GL_BASE_FILTER (filter)->context); transformation->caps_change = FALSE; } diff --git a/ext/gl/gstglvideomixer.c b/ext/gl/gstglvideomixer.c index ad73404740..c399e924e1 100644 --- a/ext/gl/gstglvideomixer.c +++ b/ext/gl/gstglvideomixer.c @@ -577,7 +577,7 @@ gst_gl_video_mixer_class_init (GstGLVideoMixerClass * klass) agg_class->sinkpads_type = GST_TYPE_GL_VIDEO_MIXER_PAD; - GST_GL_MIXER_CLASS (klass)->supported_gl_api = + GST_GL_BASE_MIXER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | GST_GL_API_GLES2; } @@ -680,7 +680,7 @@ _update_caps (GstVideoAggregator * vagg, GstCaps * caps) static gboolean _reset_pad_gl (GstAggregator * agg, GstAggregatorPad * aggpad, gpointer udata) { - const GstGLFuncs *gl = GST_GL_MIXER (agg)->context->gl_vtable; + const GstGLFuncs *gl = GST_GL_BASE_MIXER (agg)->context->gl_vtable; GstGLVideoMixerPad *pad = GST_GL_VIDEO_MIXER_PAD (aggpad); if (pad->vertex_buffer) { @@ -694,7 +694,7 @@ _reset_pad_gl (GstAggregator * agg, GstAggregatorPad * aggpad, gpointer udata) static void _reset_gl (GstGLContext * context, GstGLVideoMixer * video_mixer) { - const GstGLFuncs *gl = GST_GL_MIXER (video_mixer)->context->gl_vtable; + const GstGLFuncs *gl = GST_GL_BASE_MIXER (video_mixer)->context->gl_vtable; if (video_mixer->vao) { gl->DeleteVertexArrays (1, &video_mixer->vao); @@ -713,16 +713,17 @@ gst_gl_video_mixer_reset (GstGLMixer * mixer) video_mixer->input_frames = NULL; if (video_mixer->shader) - gst_gl_context_del_shader (mixer->context, video_mixer->shader); + gst_gl_context_del_shader (GST_GL_BASE_MIXER (mixer)->context, + video_mixer->shader); video_mixer->shader = NULL; if (video_mixer->checker) - gst_gl_context_del_shader (mixer->context, video_mixer->checker); + gst_gl_context_del_shader (GST_GL_BASE_MIXER (mixer)->context, + video_mixer->checker); video_mixer->checker = NULL; - if (mixer->context) - gst_gl_context_thread_add (mixer->context, - (GstGLContextThreadFunc) _reset_gl, mixer); + gst_gl_context_thread_add (GST_GL_BASE_MIXER (mixer)->context, + (GstGLContextThreadFunc) _reset_gl, mixer); } static gboolean @@ -731,10 +732,11 @@ gst_gl_video_mixer_init_shader (GstGLMixer * mixer, GstCaps * outcaps) GstGLVideoMixer *video_mixer = GST_GL_VIDEO_MIXER (mixer); if (video_mixer->shader) - gst_gl_context_del_shader (mixer->context, video_mixer->shader); + gst_gl_context_del_shader (GST_GL_BASE_MIXER (mixer)->context, + video_mixer->shader); - return gst_gl_context_gen_shader (mixer->context, video_mixer_v_src, - video_mixer_f_src, &video_mixer->shader); + return gst_gl_context_gen_shader (GST_GL_BASE_MIXER (mixer)->context, + video_mixer_v_src, video_mixer_f_src, &video_mixer->shader); } static gboolean @@ -745,7 +747,7 @@ gst_gl_video_mixer_process_textures (GstGLMixer * mix, GPtrArray * frames, video_mixer->input_frames = frames; - gst_gl_context_use_fbo_v2 (mix->context, + 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, @@ -758,7 +760,7 @@ static gboolean _draw_checker_background (GstGLVideoMixer * video_mixer) { GstGLMixer *mixer = GST_GL_MIXER (video_mixer); - const GstGLFuncs *gl = mixer->context->gl_vtable; + const GstGLFuncs *gl = GST_GL_BASE_MIXER (mixer)->context->gl_vtable; gint attr_position_loc = 0; const GLushort indices[] = { @@ -775,8 +777,8 @@ _draw_checker_background (GstGLVideoMixer * video_mixer) /* *INDENT-ON* */ if (!video_mixer->checker) { - if (!gst_gl_context_gen_shader (mixer->context, checker_v_src, - checker_f_src, &video_mixer->checker)) + if (!gst_gl_context_gen_shader (GST_GL_BASE_MIXER (mixer)->context, + checker_v_src, checker_f_src, &video_mixer->checker)) return FALSE; } @@ -810,7 +812,7 @@ static gboolean _draw_background (GstGLVideoMixer * video_mixer) { GstGLMixer *mixer = GST_GL_MIXER (video_mixer); - const GstGLFuncs *gl = mixer->context->gl_vtable; + const GstGLFuncs *gl = GST_GL_BASE_MIXER (mixer)->context->gl_vtable; switch (video_mixer->background) { case GST_GL_VIDEO_MIXER_BACKGROUND_BLACK: @@ -841,7 +843,7 @@ gst_gl_video_mixer_callback (gpointer stuff) { GstGLVideoMixer *video_mixer = GST_GL_VIDEO_MIXER (stuff); GstGLMixer *mixer = GST_GL_MIXER (video_mixer); - GstGLFuncs *gl = mixer->context->gl_vtable; + GstGLFuncs *gl = GST_GL_BASE_MIXER (mixer)->context->gl_vtable; GLint attr_position_loc = 0; GLint attr_texture_loc = 0; @@ -857,9 +859,10 @@ gst_gl_video_mixer_callback (gpointer stuff) out_width = GST_VIDEO_INFO_WIDTH (&GST_VIDEO_AGGREGATOR (stuff)->info); out_height = GST_VIDEO_INFO_HEIGHT (&GST_VIDEO_AGGREGATOR (stuff)->info); - gst_gl_context_clear_shader (mixer->context); + gst_gl_context_clear_shader (GST_GL_BASE_MIXER (mixer)->context); gl->BindTexture (GL_TEXTURE_2D, 0); - if (gst_gl_context_get_gl_api (mixer->context) & GST_GL_API_OPENGL) + if (gst_gl_context_get_gl_api (GST_GL_BASE_MIXER (mixer)->context) & + GST_GL_API_OPENGL) gl->Disable (GL_TEXTURE_2D); gl->Disable (GL_DEPTH_TEST); @@ -986,5 +989,5 @@ gst_gl_video_mixer_callback (gpointer stuff) gl->Disable (GL_BLEND); - gst_gl_context_clear_shader (mixer->context); + gst_gl_context_clear_shader (GST_GL_BASE_MIXER (mixer)->context); } diff --git a/gst-libs/gst/gl/gstglfilter.c b/gst-libs/gst/gl/gstglfilter.c index cc07954ae6..886c5e9d23 100644 --- a/gst-libs/gst/gl/gstglfilter.c +++ b/gst-libs/gst/gl/gstglfilter.c @@ -199,8 +199,6 @@ gst_gl_filter_gl_start (GstGLBaseFilter * base_filter) gint out_width, out_height; GError *error = NULL; - filter->context = base_filter->context; - out_width = GST_VIDEO_INFO_WIDTH (&filter->out_info); out_height = GST_VIDEO_INFO_HEIGHT (&filter->out_info); @@ -696,13 +694,6 @@ gst_gl_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps, goto error; } - if (filter->out_caps && !gst_caps_is_equal (filter->out_caps, outcaps)) { - if (filter->upload) { - gst_object_unref (filter->upload); - filter->upload = NULL; - } - } - gst_caps_replace (&filter->out_caps, outcaps); GST_DEBUG ("set_caps %dx%d", GST_VIDEO_INFO_WIDTH (&filter->out_info), diff --git a/gst-libs/gst/gl/gstglfilter.h b/gst-libs/gst/gl/gstglfilter.h index e7e5b797d5..fcca30852e 100644 --- a/gst-libs/gst/gl/gstglfilter.h +++ b/gst-libs/gst/gl/gstglfilter.h @@ -58,9 +58,6 @@ struct _GstGLFilter { GstGLBaseFilter parent; - /* FIXME remove */ - GstGLContext *context; - GstBufferPool *pool; GstVideoInfo in_info; @@ -68,18 +65,10 @@ struct _GstGLFilter GstCaps *out_caps; + /* */ GLuint fbo; GLuint depthbuffer; - GstGLUpload *upload; - GstGLColorConvert *in_convert; - GstCaps *in_converted_caps; - - GstGLDownload *download; - - GstBuffer *uploaded_buffer; - - /* */ GLuint in_tex_id; GLuint out_tex_id; @@ -111,7 +100,6 @@ struct _GstGLFilter struct _GstGLFilterClass { GstGLBaseFilterClass parent_class; - GstGLAPI supported_gl_api; gboolean (*set_caps) (GstGLFilter* filter, GstCaps* incaps, GstCaps* outcaps); gboolean (*filter) (GstGLFilter *filter, GstBuffer *inbuf, GstBuffer *outbuf);