mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
glutils: privatise matrix multiplication/videoaffinetransformation retrieval
This commit is contained in:
parent
4315a4b54d
commit
4de388278a
7 changed files with 66 additions and 9 deletions
|
@ -1624,8 +1624,6 @@ gst_gl_get_plane_start
|
||||||
gst_gl_value_get_texture_target_mask
|
gst_gl_value_get_texture_target_mask
|
||||||
gst_gl_value_set_texture_target
|
gst_gl_value_set_texture_target
|
||||||
gst_gl_value_set_texture_target_from_mask
|
gst_gl_value_set_texture_target_from_mask
|
||||||
gst_gl_get_affine_transformation_meta_as_ndc
|
|
||||||
gst_gl_multiply_matrix4
|
|
||||||
gst_gl_check_extension
|
gst_gl_check_extension
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
|
|
|
@ -105,3 +105,63 @@ gst_gl_context_gen_shader (GstGLContext * context, const gchar * vert_src,
|
||||||
|
|
||||||
return *shader != NULL;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,9 @@ G_BEGIN_DECLS
|
||||||
gboolean gst_gl_context_gen_shader (GstGLContext * context,
|
gboolean gst_gl_context_gen_shader (GstGLContext * context,
|
||||||
const gchar * shader_vertex_source,
|
const gchar * shader_vertex_source,
|
||||||
const gchar * shader_fragment_source, GstGLShader ** shader);
|
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
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -722,7 +722,7 @@ static const gfloat to_ndc_matrix[] = {
|
||||||
0.0f, 0.0f, 0.0, 1.0f,
|
0.0f, 0.0f, 0.0, 1.0f,
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
static void
|
||||||
gst_gl_multiply_matrix4 (const gfloat * a, const gfloat * b, gfloat * result)
|
gst_gl_multiply_matrix4 (const gfloat * a, const gfloat * b, gfloat * result)
|
||||||
{
|
{
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
|
|
|
@ -56,12 +56,6 @@ gboolean gst_gl_value_set_texture_target (GValue * value, GstGLTextureTarget tar
|
||||||
GST_EXPORT
|
GST_EXPORT
|
||||||
GstGLTextureTarget gst_gl_value_get_texture_target_mask (const GValue * value);
|
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
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_GL_UTILS_H__ */
|
#endif /* __GST_GL_UTILS_H__ */
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
gboolean gst_gl_run_query (GstElement * element, GstQuery * query, GstPadDirection direction);
|
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
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
#include "gstglviewconvert.h"
|
#include "gstglviewconvert.h"
|
||||||
#include "gstglsl_private.h"
|
#include "gstglsl_private.h"
|
||||||
|
#include "gstglutils_private.h"
|
||||||
#include <gst/video/gstvideoaffinetransformationmeta.h>
|
#include <gst/video/gstvideoaffinetransformationmeta.h>
|
||||||
|
|
||||||
#define USING_OPENGL(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL, 1, 0))
|
#define USING_OPENGL(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL, 1, 0))
|
||||||
|
|
Loading…
Reference in a new issue