summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Waters <ystreet00@gmail.com>2014-05-13 10:53:19 +1000
committerNicolas Dufresne <nicolas.dufresne@collabora.com>2014-05-13 11:44:06 -0400
commit1e90a68aec966d6a56e839db1cf759716b5583d8 (patch)
treeb2a5594784015cedc6af7dcdb7b2feb411d99e63
parentd4bcef3204709159713ff1630978ecac0bd91dc9 (diff)
downloadgstreamer-plugins-bad-1e90a68aec966d6a56e839db1cf759716b5583d8.tar.gz
gl/colorconvert: use the texture scaling from the gl memory
The colorconvert values were not being used at all. https://bugzilla.gnome.org/show_bug.cgi?id=729896
-rw-r--r--docs/libs/gst-plugins-bad-libs-sections.txt1
-rw-r--r--gst-libs/gst/gl/gstglcolorconvert.c73
-rw-r--r--gst-libs/gst/gl/gstglcolorconvert.h3
3 files changed, 14 insertions, 63 deletions
diff --git a/docs/libs/gst-plugins-bad-libs-sections.txt b/docs/libs/gst-plugins-bad-libs-sections.txt
index a1d015ea3..a3492d2c6 100644
--- a/docs/libs/gst-plugins-bad-libs-sections.txt
+++ b/docs/libs/gst-plugins-bad-libs-sections.txt
@@ -711,7 +711,6 @@ GstGLColorConvert
GstGLColorConvertClass
gst_gl_color_convert_new
gst_gl_color_convert_init_format
-gst_gl_color_convert_set_texture_scaling
gst_gl_color_convert_perform
<SUBSECTION Standard>
GstGLColorConvertPrivate
diff --git a/gst-libs/gst/gl/gstglcolorconvert.c b/gst-libs/gst/gl/gstglcolorconvert.c
index c13b6a0af..643bbff39 100644
--- a/gst-libs/gst/gl/gstglcolorconvert.c
+++ b/gst-libs/gst/gl/gstglcolorconvert.c
@@ -349,7 +349,6 @@ struct ConvertInfo
gint out_n_textures;
gchar *frag_prog;
const gchar *shader_tex_names[GST_VIDEO_MAX_PLANES];
- gfloat shader_scaling[GST_VIDEO_MAX_PLANES][2];
gfloat *cms_offset;
gfloat *cms_coeff1; /* r,y */
gfloat *cms_coeff2; /* g,u */
@@ -543,30 +542,6 @@ gst_gl_color_convert_perform (GstGLColorConvert * convert,
return ret;
}
-/**
- * gst_gl_color_convert_set_texture_scaling:
- * @convert: a #GstGLColorConvert
- * @scaling: array of texture scaling coefficients stored in width, height
- * order per texture being converted.
- *
- * Scales the input textures by the given amount. Useful for performing stride
- * scaling in a shader on OpenGL platforms that do not support
- * GL_PIXEL_[UN]PACK_LENGTH such as GL|ES 2.0.
- */
-void
-gst_gl_color_convert_set_texture_scaling (GstGLColorConvert * convert,
- gfloat scaling[GST_VIDEO_MAX_PLANES][2])
-{
- guint i;
-
- g_return_if_fail (convert != NULL);
-
- for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
- convert->priv->convert_info.shader_scaling[i][0] = scaling[i][0];
- convert->priv->convert_info.shader_scaling[i][1] = scaling[i][1];
- }
-}
-
static gboolean
_gst_gl_color_convert_perform_unlocked (GstGLColorConvert * convert,
GstGLMemory * in_tex[GST_VIDEO_MAX_PLANES],
@@ -708,8 +683,6 @@ _RGB_to_RGB (GstGLColorConvert * convert)
info->frag_prog = g_strdup_printf (frag_REORDER, alpha, pixel_order[0],
pixel_order[1], pixel_order[2], pixel_order[3]);
info->shader_tex_names[0] = "tex";
- info->shader_scaling[0][0] = 1.0f;
- info->shader_scaling[0][1] = 1.0f;
}
static void
@@ -722,13 +695,6 @@ _YUV_to_RGB (GstGLColorConvert * convert)
info->out_n_textures = 1;
- info->shader_scaling[0][0] = 1.0f;
- info->shader_scaling[0][1] = 1.0f;
- info->shader_scaling[1][0] = 1.0f;
- info->shader_scaling[1][1] = 1.0f;
- info->shader_scaling[2][0] = 1.0f;
- info->shader_scaling[2][1] = 1.0f;
-
switch (GST_VIDEO_INFO_FORMAT (&convert->in_info)) {
case GST_VIDEO_FORMAT_AYUV:
info->frag_prog = g_strdup_printf (frag_AYUV_to_RGB, pixel_order[0],
@@ -830,13 +796,6 @@ _RGB_to_YUV (GstGLColorConvert * convert)
info->shader_tex_names[0] = "tex";
- info->shader_scaling[0][0] = 1.0f;
- info->shader_scaling[0][1] = 1.0f;
- info->shader_scaling[1][0] = 1.0f;
- info->shader_scaling[1][1] = 1.0f;
- info->shader_scaling[2][0] = 1.0f;
- info->shader_scaling[2][1] = 1.0f;
-
switch (GST_VIDEO_INFO_FORMAT (&convert->out_info)) {
case GST_VIDEO_FORMAT_AYUV:
alpha = _is_RGBx (in_format) ? "1.0" : "texel.a";
@@ -901,12 +860,6 @@ _RGB_to_GRAY (GstGLColorConvert * convert)
info->in_n_textures = 1;
info->out_n_textures = 1;
info->shader_tex_names[0] = "tex";
- info->shader_scaling[0][0] = 1.0f;
- info->shader_scaling[0][1] = 1.0f;
- info->shader_scaling[1][0] = 1.0f;
- info->shader_scaling[1][1] = 1.0f;
- info->shader_scaling[2][0] = 1.0f;
- info->shader_scaling[2][1] = 1.0f;
if (_is_RGBx (in_format))
alpha = "t.a = 1.0";
@@ -932,12 +885,6 @@ _GRAY_to_RGB (GstGLColorConvert * convert)
info->in_n_textures = 1;
info->out_n_textures = 1;
info->shader_tex_names[0] = "tex";
- info->shader_scaling[0][0] = 1.0f;
- info->shader_scaling[0][1] = 1.0f;
- info->shader_scaling[1][0] = 1.0f;
- info->shader_scaling[1][1] = 1.0f;
- info->shader_scaling[2][0] = 1.0f;
- info->shader_scaling[2][1] = 1.0f;
switch (GST_VIDEO_INFO_FORMAT (&convert->in_info)) {
case GST_VIDEO_FORMAT_GRAY8:
@@ -1049,15 +996,9 @@ _init_convert (GstGLColorConvert * convert)
}
for (i = info->in_n_textures; i >= 0; i--) {
- gchar *scale_name = g_strdup_printf ("tex_scale%u", i);
-
if (info->shader_tex_names[i])
gst_gl_shader_set_uniform_1i (convert->shader, info->shader_tex_names[i],
i);
- gst_gl_shader_set_uniform_2fv (convert->shader, scale_name, 1,
- info->shader_scaling[i]);
-
- g_free (scale_name);
}
gst_gl_shader_set_uniform_1f (convert->shader, "width",
@@ -1334,11 +1275,20 @@ _do_convert_draw (GstGLContext * context, GstGLColorConvert * convert)
gl->EnableVertexAttribArray (convert->shader_attr_texture_loc);
if (convert->priv->scratch) {
+ gchar *scale_name = g_strdup_printf ("tex_scale%u", c_info->in_n_textures);
+
gl->ActiveTexture (GL_TEXTURE0 + c_info->in_n_textures);
gl->BindTexture (GL_TEXTURE_2D, convert->priv->scratch->tex_id);
+
+ gst_gl_shader_set_uniform_2fv (convert->shader, scale_name, 1,
+ convert->priv->scratch->tex_scaling);
+
+ g_free (scale_name);
}
for (i = c_info->in_n_textures - 1; i >= 0; i--) {
+ gchar *scale_name = g_strdup_printf ("tex_scale%u", i);
+
gl->ActiveTexture (GL_TEXTURE0 + i);
gl->BindTexture (GL_TEXTURE_2D, convert->in_tex[i]->tex_id);
@@ -1346,6 +1296,11 @@ _do_convert_draw (GstGLContext * context, GstGLColorConvert * convert)
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);
+
+ gst_gl_shader_set_uniform_2fv (convert->shader, scale_name, 1,
+ convert->in_tex[i]->tex_scaling);
+
+ g_free (scale_name);
}
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
diff --git a/gst-libs/gst/gl/gstglcolorconvert.h b/gst-libs/gst/gl/gstglcolorconvert.h
index 44f68c63c..976653d40 100644
--- a/gst-libs/gst/gl/gstglcolorconvert.h
+++ b/gst-libs/gst/gl/gstglcolorconvert.h
@@ -105,9 +105,6 @@ void gst_gl_color_convert_set_format (GstGLColorConvert * convert,
GstVideoInfo * in_info,
GstVideoInfo * out_info);
-void gst_gl_color_convert_set_texture_scaling (GstGLColorConvert * convert,
- gfloat scaling[GST_VIDEO_MAX_PLANES][2]);
-
gboolean gst_gl_color_convert_perform (GstGLColorConvert * convert,
GstGLMemory * in_tex[GST_VIDEO_MAX_PLANES],
GstGLMemory * out_tex[GST_VIDEO_MAX_PLANES]);