Commit graph

74 commits

Author SHA1 Message Date
Nicolas Dufresne de79830b05 glmemory: Add GstAllocationParams and alignment support
This implements support for GstAllocationParams and memory alignments.
The parameters where simply ignored which could lead to crash on
certain platform when used with libav and no luck.

https://bugzilla.gnome.org/show_bug.cgi?id=744246
2017-12-09 19:31:55 +00:00
Matthew Waters fba2a2093f glmemory: allow sharing between buffers
There was no real reason why the flag was set.  We should be able
to handle it.  Fixes last-sample handling on gl sinks
2017-12-09 19:31:55 +00:00
Vasilis Liaskovitis e10a2f8922 glmemory: Fix transfer_pbo memory leak
https://bugzilla.gnome.org/show_bug.cgi?id=744977
2017-12-09 19:31:55 +00:00
Mathieu Duponchelle 50ae80e0e6 gstglmemory: Remove now unused transfer_upload function. 2017-12-09 19:31:55 +00:00
Matthew Waters 2af5a108f1 glmemory: disable automatic pbo upload
until we can track where the data is/or is going to be.
2017-12-09 19:31:55 +00:00
Matthew Waters af023d7c95 glememory: only store and act on the map flags on first/last map/unmap
Anytime else, we have no idea how to match up map and unmaps.
We also don't know exactly how the calling code is using us.
Also fixes the case where we're trying to transfer while someone else
is accessing our data pointer or texture resulting in mismatched video
frames.

https://bugzilla.gnome.org/show_bug.cgi?id=744839
2017-12-09 19:31:55 +00:00
Edward Hervey f56c4c541a gl: Add/Update more debug statements
Where possible, use the _OBJECT variants in order to track better from
which object the debug statement is coming from

Define (and use) GST_CAT_DEFAULT where applicable

Use GST_PTR_FORMAT where applicable
2017-12-09 19:31:54 +00:00
Alessandro Decina c24f0f49a8 libgstgl: set user data and GDestroyNotify for wrapped textures 2017-12-09 19:31:54 +00:00
Matthew Waters c2149ec12c glmemory: add missing initilisation of tex_target when copying
fixes:

glcolorscale ! video/x-raw\(meta:GstVideoGLTextureUploadMeta\) !
glimagesink
2017-12-09 19:31:54 +00:00
Alessandro Decina 966cad27d7 gl: initial support for texture targets other than GL_TEXTURE_2D
Make GstGLMemory hold the texture target (tex_target) the texture it represents
(tex_id) is bound to. Modify gst_gl_memory_wrapped_texture and
gst_gl_download_perform_with_data to take the texture target as an argument.

This change is needed to support wrapping textures created outside libgstgl,
which might be bound to a target other than GL_TEXTURE_2D. For example on OSX
textures coming from VideoToolbox have target GL_TEXTURE_RECTANGLE.

With this change we still keep (and sometimes imply) GL_TEXTURE_2D as the
target of textures created with libgstgl.

API: modify GstGLMemory
API: modify gst_gl_memory_wrapped_texture
API: gst_gl_download_perform_with_data
2017-12-09 19:31:53 +00:00
Matthew Waters 3f52b33c7a glmemory: more compatibility defines for gles2 systems 2017-12-09 19:31:53 +00:00
Matthew Waters 03135a2238 glmemory: add some thread safety for gl operations 2017-12-09 19:31:53 +00:00
Matthew Waters d8cc4cfc47 glmemory: use pbo's for download
In order to use pbo's efficiently, the transfer operation has to
be separated from the use of the downloaded data which requires some
rearchitecturing around glcolorconvert/gldownload and elements
2017-12-09 19:31:53 +00:00
Matthew Waters e3d3049641 glmemory: use the correct size for the pbo
It was missing the GstVideoAlignment padding which could cause GL
errors related to overrunning the size of the pbo.
2017-12-09 19:31:52 +00:00
Matthew Waters aedfadd972 glmemory: remove spurious gst_video_info_align
That will be taken care of by the calling code (typically a bufferpool).
The GstVideoAlignment is purely informational to compute plane data sizes.
2017-12-09 19:31:52 +00:00
Matthew Waters 19fbe2afbc glmemory: offset the data pointer for upload for GstVideoAlignment
otherwise we attempt to read from the padding data
2017-12-09 19:31:52 +00:00
Matthew Waters a2af67aef0 glmemory: use pbo's for upload 2017-12-09 19:31:52 +00:00
Nicolas Dufresne a1e02726ee gl: Add support for GstVideoAlignment
This allow saving a copy with libav video decoders or decoders with
similar padding requirement.

https://bugzilla.gnome.org/show_bug.cgi?id=740900
2017-12-09 19:31:52 +00:00
Nicolas Dufresne 45ac36ca26 glmemory: Handle upload/download flags from map
Problem was that if buffer was mapped READWRITE (state of buffers from
libav right now), mapping it READ/GL will not upload. This is because the
flag is only set when the buffer is unmapped. We can fix this by setting
the flags in map. This result in already mapped buffer that get mapped
to be read in GL will be uploaded. The problem is that if the write
mapper makes modification afterward, the modification will never get
uploaded.

https://bugzilla.gnome.org/show_bug.cgi?id=740900
2017-12-09 19:31:52 +00:00
Nicolas Dufresne 197e8de6e6 glmemory: Handle custom stride with OPENGL3
https://bugzilla.gnome.org/show_bug.cgi?id=740900
2017-12-09 19:31:52 +00:00
Sebastian Dröge 5b13dca0ce glmemory: Handle failure of memory allocation gracefully 2017-12-09 19:31:50 +00:00
Sebastian Dröge 47a8242399 glmemory: Use g_try_malloc() in the appropriate places
g_malloc() aborts if allocation fails, it's pointless to check against NULL
afterwards. That's why g_try_malloc() exists.
2017-12-09 19:31:50 +00:00
Wang Xin-yu (王昕宇) 77682a51e6 glcolorconvert: support RGB16/BGR16 video format upload
https://bugzilla.gnome.org/show_bug.cgi?id=738842
2017-12-09 19:31:48 +00:00
Matthew Waters 5c7b5e0210 glmemory: unset the opposite corresponding transfer flags when mapped with write
fixes consistency with consecutive gst_memory_map()'s with
flags & GST_MAP_WRITE
2017-12-09 19:31:47 +00:00
Matthew Waters a793bda9b4 glmemory: add debug line for freeing textures 2017-12-09 19:31:46 +00:00
Matthew Waters 9426c0793e glmemory: use the plane offsets to compute the size of the data pointer
Certain elements expect that there be a certain number of lines
that they can write into.  e.g. for odd heights, I420, YV12, NV12,
NV21 (and others) Y lines are expected to have exactly twice the
number of U/UV lines.

https://bugzilla.gnome.org/show_bug.cgi?id=733717
2017-12-09 19:31:45 +00:00
Matthew Waters c216799b20 glmemory: use GstVideoInfo everywhere
Simplifies a lot of the calling code

https://bugzilla.gnome.org/show_bug.cgi?id=733717
2017-12-09 19:31:45 +00:00
Matthew Waters 2b82b78ef5 glmemory: reenable the texture_rg support for !eagl
The GST_GL_HAVE_PLATFORM_EAGL is always defined we need to compare
against the value instead.
2017-12-09 19:31:44 +00:00
Sebastian Dröge f6ae4ab243 eagl: Disable usage of R and RG textures on iOS
They don't work currently and just render zeroes, while the
fallback code path with LUM and LUM_ALPHA textures still works.

https://bugzilla.gnome.org/show_bug.cgi?id=732390
2017-12-09 19:31:44 +00:00
Matthew Waters ea8c49f106 glmemory: remove uneeded gl api ifdefs 2017-12-09 19:31:42 +00:00
Matthew Waters 4a8b31afd6 glfeature: remove GST_GL_API_GLES3
instead check the gl version using gst_gl_context_check_gl_version()
2017-12-09 19:31:42 +00:00
Matthew Waters ee04a6e6eb gl/memory: allocate the correct memory size
and avoid wasting resources we will never need

https://bugzilla.gnome.org/show_bug.cgi?id=730703
2017-12-09 19:31:41 +00:00
Matthew Waters 146c666ba2 gl/memory: provide compatability defines
fixes build on android/OS X
2017-12-09 19:31:41 +00:00
Matthew Waters b3d9563d6b gl/memory: RGBA/UNSIGNED_BYTE only format supported by ReadPixels GLES2
Error out in case we attempt to read with any other invalid format.
2017-12-09 19:31:41 +00:00
Matthew Waters b3df031908 gl/memory: generate textures with a sized internal format
Required in order to generate RG and RED textured with GLES3.
2017-12-09 19:31:41 +00:00
Matthew Waters 132a233f7b gl/memory: implement GL_EXT_texture_rg support
Which is used by default over the Luminance formats due to it
being color renderable with fbos (and deprecation/removal with
GL 3.x).

https://bugzilla.gnome.org/show_bug.cgi?id=729750
https://bugzilla.gnome.org/show_bug.cgi?id=704222
https://bugzilla.gnome.org/show_bug.cgi?id=728890
2017-12-09 19:31:41 +00:00
Matthew Waters 313dfbb500 gl/upload: switch the 'master' texture for YUY2, UYVY
From d4bcef3204 on, using a RGBA
texture to hold the data causes the glmemory to have half width
and a scaling of [2, 1].  Using a LA texture solves this problem
however cannot be attached to the framebuffer for copying into
a RGBA texture.  Which will be solved by moving to EXT_texture_rg.

https://bugzilla.gnome.org/show_bug.cgi?id=728890
2017-12-09 19:31:41 +00:00
Nicolas Dufresne 157607989a glmemory: Fix handling of stride with alignement larger then 8
Setting a scaled factor for X coordinate is not enough as the indexer
will still think stride is shorter and will not fully skip it. Instead,
update width, so the lines are as expected. Combined with the scale, it
will hide the cropped portion.

https://bugzilla.gnome.org/show_bug.cgi?id=729896
2017-12-09 19:31:40 +00:00
Matthew Waters 6c1a4e30c4 gl/upload: implement lazy init
Rename init_format to set_format
2017-12-09 19:31:39 +00:00
Matthew Waters 33091ff6a5 gl/mem: implement texture copying between formats with strides properly
Previously, we used the width to determine the amount of data to be
copied using pbos.  This, makes it allocate enough data for the
the strides as well.
2017-12-09 19:31:38 +00:00
Nicolas Dufresne 4372ba8999 glmemory: User g_slice_new0 to ensure fully initilized structure
The pbo pointer not being initialized would trigger a use of unitilialized variable
in valgrind.
2017-12-09 19:31:37 +00:00
Vincent Penquerc'h c728fd3b8d gl: prevent division by 0 on unsupported texture type
Coverity 1199697
2017-12-09 19:31:37 +00:00
Matthew Waters 6c73fa0b5f gl/mem: cache the stride/unpack length for upload 2017-12-09 19:31:36 +00:00
Matthew Waters 94371dc204 gl/mem: provide defines for tokens not defined in GLES2/ancient platforms 2017-12-09 19:31:36 +00:00
Matthew Waters 30c6efc432 gl/mem: allocate the memory per plane
This patch provides the basic infrastructure required for this.
Upload and Download has been ported to this.

Has the nice effect of allowing GstGLMemory to be our
refcounted texture object for any texture type (not just RGBA).

Should not lose any features/video formats.
2017-12-09 19:31:36 +00:00
Matthew Waters a20a5d36e2 gl: pass video info's by reference 2017-12-09 19:31:35 +00:00
Matthew Waters e225af3e0d gl: silence all the compiler warnings 2017-12-09 19:31:34 +00:00
Matthew Waters d233bb66a9 [876/906] glmem: use GstVideoInfo for format configuration
Allows use of strides
2017-12-09 19:31:33 +00:00
Matthew Waters 2eb7938db9 [873/906] upload: use GstVideoInfo for choosing the format 2017-12-09 19:31:33 +00:00
Matthew Waters 89a203abe3 [865/906] glmem: report successful copy to the caller 2017-12-09 19:31:33 +00:00