summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Waters <matthew@centricular.com>2017-01-13 11:06:39 +1100
committerMatthew Waters <matthew@centricular.com>2017-01-13 11:20:51 +1100
commit4de388278a0430eae4eb7612d83f5084e48dad62 (patch)
treedcc723fe1f2b442d642ec8397dee2295ecfc41a4
parent4315a4b54d9c830d9380e3d5c9413601f9a136fe (diff)
downloadgstreamer-plugins-bad-4de388278a0430eae4eb7612d83f5084e48dad62.tar.gz
glutils: privatise matrix multiplication/videoaffinetransformation retrieval
-rw-r--r--docs/libs/gst-plugins-bad-libs-sections.txt2
-rw-r--r--ext/gl/gstglutils.c60
-rw-r--r--ext/gl/gstglutils.h3
-rw-r--r--gst-libs/gst/gl/gstglutils.c2
-rw-r--r--gst-libs/gst/gl/gstglutils.h6
-rw-r--r--gst-libs/gst/gl/gstglutils_private.h1
-rw-r--r--gst-libs/gst/gl/gstglviewconvert.c1
7 files changed, 66 insertions, 9 deletions
diff --git a/docs/libs/gst-plugins-bad-libs-sections.txt b/docs/libs/gst-plugins-bad-libs-sections.txt
index f9d391330..be58d5f06 100644
--- a/docs/libs/gst-plugins-bad-libs-sections.txt
+++ b/docs/libs/gst-plugins-bad-libs-sections.txt
@@ -1624,8 +1624,6 @@ gst_gl_get_plane_start
gst_gl_value_get_texture_target_mask
gst_gl_value_set_texture_target
gst_gl_value_set_texture_target_from_mask
-gst_gl_get_affine_transformation_meta_as_ndc
-gst_gl_multiply_matrix4
gst_gl_check_extension
</SECTION>
diff --git a/ext/gl/gstglutils.c b/ext/gl/gstglutils.c
index ca5e8ab06..224923c15 100644
--- a/ext/gl/gstglutils.c
+++ b/ext/gl/gstglutils.c
@@ -105,3 +105,63 @@ gst_gl_context_gen_shader (GstGLContext * context, const gchar * vert_src,
return *shader != NULL;
}
+
+static const gfloat identity_matrix[] = {
+ 1.0f, 0.0f, 0.0, 0.0f,
+ 0.0f, 1.0f, 0.0, 0.0f,
+ 0.0f, 0.0f, 1.0, 0.0f,
+ 0.0f, 0.0f, 0.0, 1.0f,
+};
+
+static const gfloat from_ndc_matrix[] = {
+ 0.5f, 0.0f, 0.0, 0.5f,
+ 0.0f, 0.5f, 0.0, 0.5f,
+ 0.0f, 0.0f, 0.5, 0.5f,
+ 0.0f, 0.0f, 0.0, 1.0f,
+};
+
+static const gfloat to_ndc_matrix[] = {
+ 2.0f, 0.0f, 0.0, -1.0f,
+ 0.0f, 2.0f, 0.0, -1.0f,
+ 0.0f, 0.0f, 2.0, -1.0f,
+ 0.0f, 0.0f, 0.0, 1.0f,
+};
+
+void
+gst_gl_multiply_matrix4 (const gfloat * a, const gfloat * b, gfloat * result)
+{
+ int i, j, k;
+ gfloat tmp[16] = { 0.0f };
+
+ if (!a || !b || !result)
+ return;
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ for (k = 0; k < 4; k++) {
+ tmp[i + (j * 4)] += a[i + (k * 4)] * b[k + (j * 4)];
+ }
+ }
+ }
+
+ for (i = 0; i < 16; i++)
+ result[i] = tmp[i];
+}
+
+void
+gst_gl_get_affine_transformation_meta_as_ndc (GstVideoAffineTransformationMeta *
+ meta, gfloat * matrix)
+{
+ if (!meta) {
+ int i;
+
+ for (i = 0; i < 16; i++) {
+ matrix[i] = identity_matrix[i];
+ }
+ } else {
+ gfloat tmp[16] = { 0.0f };
+
+ gst_gl_multiply_matrix4 (from_ndc_matrix, meta->matrix, tmp);
+ gst_gl_multiply_matrix4 (tmp, to_ndc_matrix, matrix);
+ }
+}
diff --git a/ext/gl/gstglutils.h b/ext/gl/gstglutils.h
index ee7d4c698..5c9de83d6 100644
--- a/ext/gl/gstglutils.h
+++ b/ext/gl/gstglutils.h
@@ -28,6 +28,9 @@ G_BEGIN_DECLS
gboolean gst_gl_context_gen_shader (GstGLContext * context,
const gchar * shader_vertex_source,
const gchar * shader_fragment_source, GstGLShader ** shader);
+void gst_gl_multiply_matrix4 (const gfloat * a, const gfloat * b, gfloat * result);
+void gst_gl_get_affine_transformation_meta_as_ndc (GstVideoAffineTransformationMeta *
+ meta, gfloat * matrix);
G_END_DECLS
diff --git a/gst-libs/gst/gl/gstglutils.c b/gst-libs/gst/gl/gstglutils.c
index b41ed8f4f..fb1915650 100644
--- a/gst-libs/gst/gl/gstglutils.c
+++ b/gst-libs/gst/gl/gstglutils.c
@@ -722,7 +722,7 @@ static const gfloat to_ndc_matrix[] = {
0.0f, 0.0f, 0.0, 1.0f,
};
-void
+static void
gst_gl_multiply_matrix4 (const gfloat * a, const gfloat * b, gfloat * result)
{
int i, j, k;
diff --git a/gst-libs/gst/gl/gstglutils.h b/gst-libs/gst/gl/gstglutils.h
index e1207aafa..4139302c2 100644
--- a/gst-libs/gst/gl/gstglutils.h
+++ b/gst-libs/gst/gl/gstglutils.h
@@ -56,12 +56,6 @@ gboolean gst_gl_value_set_texture_target (GValue * value, GstGLTextureTarget tar
GST_EXPORT
GstGLTextureTarget gst_gl_value_get_texture_target_mask (const GValue * value);
-GST_EXPORT
-void gst_gl_multiply_matrix4 (const gfloat * a, const gfloat * b, gfloat * result);
-GST_EXPORT
-void gst_gl_get_affine_transformation_meta_as_ndc (GstVideoAffineTransformationMeta *
- meta, gfloat * matrix);
-
G_END_DECLS
#endif /* __GST_GL_UTILS_H__ */
diff --git a/gst-libs/gst/gl/gstglutils_private.h b/gst-libs/gst/gl/gstglutils_private.h
index 9321d8d7a..008fcc6dc 100644
--- a/gst-libs/gst/gl/gstglutils_private.h
+++ b/gst-libs/gst/gl/gstglutils_private.h
@@ -26,6 +26,7 @@
G_BEGIN_DECLS
gboolean gst_gl_run_query (GstElement * element, GstQuery * query, GstPadDirection direction);
+void gst_gl_get_affine_transformation_meta_as_ndc (GstVideoAffineTransformationMeta * meta, gfloat * matrix);
G_END_DECLS
diff --git a/gst-libs/gst/gl/gstglviewconvert.c b/gst-libs/gst/gl/gstglviewconvert.c
index 11a98f2ae..64c64f7ed 100644
--- a/gst-libs/gst/gl/gstglviewconvert.c
+++ b/gst-libs/gst/gl/gstglviewconvert.c
@@ -34,6 +34,7 @@
#include "gstglviewconvert.h"
#include "gstglsl_private.h"
+#include "gstglutils_private.h"
#include <gst/video/gstvideoaffinetransformationmeta.h>
#define USING_OPENGL(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL, 1, 0))