Commit f15f60a0 authored by Jan Schmidt's avatar Jan Schmidt

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.
parent fae7f790
......@@ -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",
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment