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);
+ }
+}
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
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__ */
#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))