After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 785980 - gst_gl_get_affine_transformation_meta_as_ndc (_ext) should use column major matrix
gst_gl_get_affine_transformation_meta_as_ndc (_ext) should use column major m...
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
1.12.2
Other Linux
: Normal normal
: 1.13.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-08-08 02:02 UTC by Yuji Kuwabara
Modified: 2017-08-23 06:39 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Yuji Kuwabara 2017-08-08 02:02:31 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.
Comment 1 Yuji Kuwabara 2017-08-08 04:24:59 UTC
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,
*/
};
------------------------------------------------------
Comment 2 Matthew Waters (ystreet00) 2017-08-16 13:57:11 UTC
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.
Comment 3 Yuji Kuwabara 2017-08-16 22:10:31 UTC
Thanks to comment.
I confused object coordinate with NDC.
Comment 4 Matthew Waters (ystreet00) 2017-08-23 06:39:38 UTC
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