diff options
author | Jan Schmidt <jan@centricular.com> | 2018-02-27 18:28:16 +1100 |
---|---|---|
committer | Jan Schmidt <jan@centricular.com> | 2018-03-01 02:14:07 +1100 |
commit | f15f60a062f2093d430fa2d6264a571b301bb7d7 (patch) | |
tree | 3c015f5b4d000c78707bf038b862ff55523558a8 | |
parent | fae7f790be0b3ae61800712b496e2870c6c5f06f (diff) |
glfilter: Support non-2D texture targets
Allow for sub-classes to change pad templates to
support other texture targets, and bind input textures
accordingly.
When setting the caps, also store the texture target.
By default, glfilter only reports 2D texture targets
in the default caps, but sub-classes can change that
and it would be nice if they could easily find out
which texture targets were negotiated.
This adds 2 fields to the public struct, but since
it's unreleased -base API, it's not an ABI break.
-rw-r--r-- | gst-libs/gst/gl/gstglfilter.c | 33 | ||||
-rw-r--r-- | gst-libs/gst/gl/gstglfilter.h | 4 |
2 files changed, 35 insertions, 2 deletions
diff --git a/gst-libs/gst/gl/gstglfilter.c b/gst-libs/gst/gl/gstglfilter.c index 5c9e140fd..bd2bc2c5e 100644 --- a/gst-libs/gst/gl/gstglfilter.c +++ b/gst-libs/gst/gl/gstglfilter.c @@ -731,6 +731,7 @@ gst_gl_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps, { GstGLFilter *filter; GstGLFilterClass *filter_class; + GstGLTextureTarget from_target, to_target; filter = GST_GL_FILTER (bt); filter_class = GST_GL_FILTER_GET_CLASS (filter); @@ -740,12 +741,38 @@ gst_gl_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps, if (!gst_video_info_from_caps (&filter->out_info, outcaps)) goto wrong_caps; + { + GstStructure *in_s = gst_caps_get_structure (incaps, 0); + GstStructure *out_s = gst_caps_get_structure (outcaps, 0); + + if (gst_structure_has_field_typed (in_s, "texture-target", G_TYPE_STRING)) + from_target = + gst_gl_texture_target_from_string (gst_structure_get_string (in_s, + "texture-target")); + else + from_target = GST_GL_TEXTURE_TARGET_2D; + + if (gst_structure_has_field_typed (out_s, "texture-target", G_TYPE_STRING)) + to_target = + gst_gl_texture_target_from_string (gst_structure_get_string (out_s, + "texture-target")); + else + to_target = GST_GL_TEXTURE_TARGET_2D; + + if (to_target == GST_GL_TEXTURE_TARGET_NONE + || from_target == GST_GL_TEXTURE_TARGET_NONE) + /* invalid caps */ + goto wrong_caps; + } + if (filter_class->set_caps) { if (!filter_class->set_caps (filter, incaps, outcaps)) goto error; } gst_caps_replace (&filter->out_caps, outcaps); + filter->in_texture_target = from_target; + filter->out_texture_target = to_target; GST_DEBUG_OBJECT (filter, "set_caps %dx%d in %" GST_PTR_FORMAT " out %" GST_PTR_FORMAT, @@ -758,7 +785,7 @@ gst_gl_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps, /* ERRORS */ wrong_caps: { - GST_WARNING ("Wrong caps"); + GST_WARNING ("Wrong caps - could not understand input or output caps"); return FALSE; } error: @@ -1076,6 +1103,7 @@ _draw_with_shader_cb (GstGLFilter * filter, GstGLMemory * in_tex, { GstGLContext *context = GST_GL_BASE_FILTER (filter)->context; GstGLFuncs *gl = context->gl_vtable; + guint gl_target; #if GST_GL_HAVE_OPENGL if (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL) { @@ -1086,9 +1114,10 @@ _draw_with_shader_cb (GstGLFilter * filter, GstGLMemory * in_tex, _get_attributes (filter); gst_gl_shader_use (filter->default_shader); + gl_target = gst_gl_texture_target_to_gl (filter->in_texture_target); gl->ActiveTexture (GL_TEXTURE1); - gl->BindTexture (GL_TEXTURE_2D, gst_gl_memory_get_texture_id (in_tex)); + gl->BindTexture (gl_target, gst_gl_memory_get_texture_id (in_tex)); gst_gl_shader_set_uniform_1i (filter->default_shader, "tex", 1); gst_gl_shader_set_uniform_1f (filter->default_shader, "width", diff --git a/gst-libs/gst/gl/gstglfilter.h b/gst-libs/gst/gl/gstglfilter.h index fc1928b9d..138053d4b 100644 --- a/gst-libs/gst/gl/gstglfilter.h +++ b/gst-libs/gst/gl/gstglfilter.h @@ -56,6 +56,8 @@ typedef gboolean (*GstGLFilterRenderFunc) (GstGLFilter * filter, GstGLMemory * i * @parent: parent #GstGLBaseFilter * @in_info: the video info for input buffers * @out_info: the video info for output buffers + * @in_texture_target: The texture target of the input buffers (usually 2D) + * @out_texture_target: The texture target of the output buffers (usually 2D) * @out_caps: the output #GstCaps * @fbo: #GstGLFramebuffer object used for transformations */ @@ -65,6 +67,8 @@ struct _GstGLFilter GstVideoInfo in_info; GstVideoInfo out_info; + GstGLTextureTarget in_texture_target; + GstGLTextureTarget out_texture_target; GstCaps *out_caps; |