GNOME Bugzilla – Bug 785980
gst_gl_get_affine_transformation_meta_as_ndc (_ext) should use column major matrix
Last modified: 2017-08-23 06:39:38 UTC
In gstvideoaffinetransformationmeta.h , it is stated as: ------------------------------------------------------ * @matrix: the column-major 4x4 transformation matrix * * are assumed to have an origin at (0.5, 0.5, 0.5) in a left-handed coordinate ------------------------------------------------------ In gstglimagesink.c , it is passed to gst_gl_get_affine_transformation_meta_as_ndc_ext (af_meta, matrix); In gstglutils.c , gst_gl_get_affine_transformation_meta_as_ndc_ext() uses constant matrix, from_ndc_matrix[] and to_ndc_matrix[] . I think those constant matrices also should be column major. In addition, I think z axis should be inverted. ------------------------------------------------------ static const gfloat from_ndc_matrix[] = { // column major, Right Hand -> Left Hand 0.5f, 0.0f, 0.0, 0.0f, 0.0f, 0.5f, 0.0, 0.0f, 0.0f, 0.0f, -0.5, 0.0f, 0.5f, 0.5f, 0.5, 1.0f, /* 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[] = { // column major, Left Hand -> Right Hand 2.0f, 0.0f, 0.0, 0.0f, 0.0f, 2.0f, 0.0, 0.0f, 0.0f, 0.0f, -2.0, 0.0f, -1.0f, -1.0f, -1.0, 1.0f, /* 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, */ }; ------------------------------------------------------ I hope experts verify this point.
Sorry, one correction, ------------------------------------------------------ static const gfloat to_ndc_matrix[] = { // column major, Left Hand -> Right Hand 2.0f, 0.0f, 0.0, 0.0f, 0.0f, 2.0f, 0.0, 0.0f, 0.0f, 0.0f, -2.0, 0.0f, -1.0f, -1.0f, 1.0, 1.0f, /* 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, */ }; ------------------------------------------------------
You are correct for the column major thing (which requires reversing all the matrix multiplications (once our matrix multiplication is correct :( )) however inverting the z-axis is not necessary. NDC is also a left-handed coordinate system so there's no need to invert any axes.
Thanks to comment. I confused object coordinate with NDC.
commit d8bc42fb3017a160042f7bd22fcf2aa563f428a2 Author: Matthew Waters <matthew@centricular.com> Date: Thu Aug 17 13:46:04 2017 +1000 glutils: fix matrix operations everywhere - correct the matrix multiplication - Use column-major matrices - reverse order of matrix multiplications https://bugzilla.gnome.org/show_bug.cgi?id=785980