Commits on Source (3)
-
The orientation matrix applies a 2D affine transform, so a 3x3 matrix is sufficient.
b7db3881 -
The transform matrix provided by Android is 4x4: <https://developer.android.com/reference/android/graphics/SurfaceTexture#getTransformMatrix(float%5B%5D)> However, the third column is never used, since the input vector is in the form (s, t, 0, 1). Similarly, the third row is never used either, since only the two first coordinates of the output vector are kept. Using a 3x3 matrix simplifies the product with other 3x3 matrices. Note: in theory, a 3x2 matrix would be sufficient, but use a square matrix for wider compatibility with all OpenGL versions.
9d00bf29 -
The TransformMatrix is provided by Android to apply its internal coordinates transformations to sample the texture at the correct location, so it must be applied last, after the orientation/crop from the picture_t. The fact that their internal transform is exposed as an explicit matrix is an arbitrary design choice from Android. Instead they could have exposed a GLSL function "android_texture2D(vec2 coords)": vec2 tex_coords = TexCoordsMap * OrientationMatrix * pic_coords; vec4 texel = android_texture2D(tex_coords); In that case, it is obvious that their transform would be applied last. Refs <https://developer.android.com/reference/android/graphics/SurfaceTexture#getTransformMatrix(float%5B%5D)>
fd8a4fd8
Showing
- modules/video_output/opengl/interop.h 3 additions, 3 deletionsmodules/video_output/opengl/interop.h
- modules/video_output/opengl/interop_android.c 41 additions, 1 deletionmodules/video_output/opengl/interop_android.c
- modules/video_output/opengl/sampler.c 28 additions, 32 deletionsmodules/video_output/opengl/sampler.c