Commit graph

749 commits

Author SHA1 Message Date
Matthew Waters
9cfd5e5d04 gl/filter: fixup passthrough bufferpool
In a pipeline like so:
  videotestsrc ! gleffects ! videoconvert ! sink
gleffects was simply passing the videoconvert bufferpool to videotestsrc
and not creating a glbufferpool. videobufferpool would then fail
to allocate from the glallocator.
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
Matthew Waters
51fdeef98b gl/eglimage: add eglimage context feature
Allows us to selectively use EGLImages only when available

https://bugzilla.gnome.org/show_bug.cgi?id=728234
2017-12-09 19:31:41 +00:00
Matthew Waters
166d7b505c gl/context: add generic feature checking
At the moment it simply delegates to the subclass.
2017-12-09 19:31:40 +00:00
Sebastian Dröge
9fd7e34fee glcontext: Add more assertions to make sure that everything sets the GError during context creation if something fails 2017-12-09 19:31:40 +00:00
Matthew Waters
9172cb8839 gl/download: update to be similar to the glupload semantics 2017-12-09 19:31:40 +00:00
Matthew Waters
5efb69304a gl/colorconvert: fix up alpha clobbering
Previously it would only work if the alpha value was in the last
component (RGBx, BGRx).  Now it works wherever the alpha value may
be (xRGB, xBGR, etc).
2017-12-09 19:31:40 +00:00
Nicolas Dufresne
b4a0a26ddd glfilter: Fix building without EGL support
This fixes the OSX build and any builds with --disable-egl. That issue
was introduced in "glfilter: rewrite transform_caps to preserve caps fields".

https://bugzilla.gnome.org/show_bug.cgi?id=729861
2017-12-09 19:31:40 +00:00
Julien Isorce
a7156df9f4 glfilter: rewrite transform_caps to preserve caps fields
https://bugzilla.gnome.org/show_bug.cgi?id=729861
2017-12-09 19:31:40 +00:00
Matthew Waters
07b6bfeaa7 gl/colorconvert: use the texture scaling from the gl memory
The colorconvert values were not being used at all.

https://bugzilla.gnome.org/show_bug.cgi?id=729896
2017-12-09 19:31:40 +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
Nicolas Dufresne
030fc8b7d0 glupload: Ensure we still have a texture after upload_set_format()
gst_gl_upload_set_format() resets the upload, hence the texture.
So we need to ensure we have a texture after this call when
uploading.
2017-12-09 19:31:40 +00:00
Nicolas Dufresne
b70edbff15 glupload: Correctly update the video info from video meta
Using gst_video_info_set_format() isn't complete when updating
a video info from video meta.
2017-12-09 19:31:40 +00:00
Nicolas Dufresne
2f705ac9ca glupload: Correctly update video info in upload fallback
When the upload accelerated method fails, we fallback to an upload,
but the video info was not correctly updated.
2017-12-09 19:31:40 +00:00
Julien Isorce
c16ab9e66b gl/upload: set out_tex after reset, not before
Fix a regression introduced recently with the lazy init.
It was happening when calling gst_video_gl_texture_upload_meta_upload
from an aplication. So not using gst_gl_upload_perform_with_buffer.
2017-12-09 19:31:40 +00:00
Matthew Waters
5cdfd51172 gl/upload: update the video info on mapping a video frame
The buffer should contain the most specific data on how the data is
formatted.  We should use this information.

https://bugzilla.gnome.org/show_bug.cgi?id=729896
2017-12-09 19:31:40 +00:00
Matthew Waters
480784e368 gl/convert: clobber alpha channel when needed
Needed in the conversion from padded RGB formats to formats with an
alpha channel.  e.g. BGRx -> ABGR, etc

https://bugzilla.gnome.org/show_bug.cgi?id=729742
2017-12-09 19:31:40 +00:00
Matthew Waters
59c388abca gl/upload: avoid performing color conversion when there is no need
One such example is when the buffer contains GstGLMemory in the
RGBA format

https://bugzilla.gnome.org/show_bug.cgi?id=729278
2017-12-09 19:31:40 +00:00
Matthew Waters
ae283ec9da gl/colorconvert: choose the right alpha component for AYUV -> RGBA 2017-12-09 19:31:40 +00:00
Matthew Waters
9fffa2cbc6 gl/upload: update the respective state when we cache textures/data 2017-12-09 19:31:40 +00:00
Matthew Waters
484ae5a8c5 gl/upload: cache the textures that we are using 2017-12-09 19:31:40 +00:00
Matthew Waters
a64efacd0e gl/upload: avoid recreating the GLMemory struct for output textures 2017-12-09 19:31:40 +00:00
Nicolas Dufresne
5c8acc21fe gl: Fix some of the error handling 2017-12-09 19:31:40 +00:00
Nicolas Dufresne
94aa3ea228 glupload: Update GstVideoInfo after the buffer is mapped
gst_video_frame_map() will store an updated video info base
on the video meta. In order to have the right stride and offset
we should update that video info accordingly.
2017-12-09 19:31:40 +00:00
Sebastian Dröge
43866270ef gl: Fix memory leak
CID #1212171
2017-12-09 19:31:40 +00:00
Matthew Waters
f213321083 gl/colorconvert: preserve alpha in AYUV <-> RGBA conversions
https://bugzilla.gnome.org/show_bug.cgi?id=729743
2017-12-09 19:31:40 +00:00
Matthew Waters
977c326c59 gl/colorconvert: implement lazy init 2017-12-09 19:31:40 +00:00
Julien Isorce
17ba668c7a gl/upload: set initted to TRUE when _init_upload succeeded 2017-12-09 19:31:40 +00:00
Sebastian Dröge
228eccdbdf gldisplay: Use GST_STR_NULL() for printing possibly NULL strings and print all variables we use
Fixes compiler warning about set but not used platform_choice variable
among other things.
2017-12-09 19:31:40 +00:00
Matthew Waters
83c2b906d1 gl/upload: fix compilation on OS X 2017-12-09 19:31:40 +00:00
Matthew Waters
862df41b2d gl/upload: fail propoerly if init fails 2017-12-09 19:31:39 +00:00
Matthew Waters
857200ff40 gl: make all GObjects inherit from GstObject
Aids memory leak debugging with GST_TRACE=mem-live
2017-12-09 19:31:39 +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
cda89d7ce0 gl/upload: add get_format method
Simply retreives the format set by init_format
2017-12-09 19:31:39 +00:00
Matthew Waters
6e5494d729 gl/filter: attempt to passthrough the pool if the caps are the same
Reduces the number of glbufferpool instances required for >=2
consecutive GL elements in a pipeline.
2017-12-09 19:31:39 +00:00
Matthew Waters
6872ad5ff5 gl/filter: always initialize the upload object 2017-12-09 19:31:39 +00:00
Matthew Waters
8fd450b941 gl: advertise GstGLMemory usage in the caps as capsfeatures
https://bugzilla.gnome.org/show_bug.cgi?id=729658
2017-12-09 19:31:39 +00:00
Matthew Waters
90bf46484d gl/display: avoid endless recursion for cocoa 2017-12-09 19:31:39 +00:00
Julien Isorce
d7c5444447 gl: do not allocate the target texture of an EGLImage
The target texture of an EGLImage is the texture bind just
before calling glEGLImageTargetTexture2D.

As we currently only support a gl texture as the source of an EGLImage
the gl texture is actually already allocated when creating the eglimage.

I also see some cases where it fails to upload an eglimage when
glTexImage2D is called on the target.
2017-12-09 19:31:39 +00:00
Julien Isorce
4bc96ae4cd gl: allow to avoid calling glTexImage2D(w, h, NULL) when generating a texture
Just pass 0 as width or height to gst_gl_context_gen_texture.
2017-12-09 19:31:39 +00:00
Julien Isorce
88864ea2cc gl: no need to initialize a frame buffer object to upload an eglimage
Fix https://bugzilla.gnome.org/show_bug.cgi?id=729588
2017-12-09 19:31:39 +00:00
Julien Isorce
bcc633ed2c gl: use GST_CAT_ERROR instead of GST_ERROR_OBJECT
It fixes segault when GST_DEBUG is at least level 1 and eglCreateImage fails
2017-12-09 19:31:39 +00:00
Julien Isorce
dd1c2b4c4c gl: delete texture used with GstVideoGLTextureUploadMeta 2017-12-09 19:31:39 +00:00
Julien Isorce
4b0e037fa4 gl: use gst_gl_context_gen_shader helper instead of duplicating code 2017-12-09 19:31:39 +00:00
Matthew Waters
59592f9bfc gl/display: clean up pre gstglcontext api and struct fields
https://bugzilla.gnome.org/show_bug.cgi?id=729551
2017-12-09 19:31:39 +00:00
Matthew Waters
f6ed9a685b gl/display: add get_handle_type
https://bugzilla.gnome.org/show_bug.cgi?id=729551
2017-12-09 19:31:39 +00:00
Matthew Waters
c5a11aa448 gl/display: avoid opening the X11 display on systems with Cocoa (OS X)
https://bugzilla.gnome.org/show_bug.cgi?id=729551
2017-12-09 19:31:39 +00:00
Matthew Waters
6a2f2088e9 gl/window: fix string length check for eagl 2017-12-09 19:31:39 +00:00
Matthew Waters
320ceef471 gl/display: check the correct env variable for choosing an egl display
GST_GL_WINDOW is used for window system specific choices.
An EGLDisplay can be created from window systems with egl support by using
eglGetDisplay().

https://bugzilla.gnome.org/show_bug.cgi?id=729551
2017-12-09 19:31:39 +00:00
Edward Hervey
47a4be4721 gl/cocoa: Use OBJCFLAGS where needed
Should fix usage of c-compiler-only flags with an objective-c compiler
2017-12-09 19:31:39 +00:00
Matthew Waters
bf9c8544e3 gl: use the bufferpool's upload when available
Avoids duplicating GL resources

https://bugzilla.gnome.org/show_bug.cgi?id=728872
2017-12-09 19:31:39 +00:00
Julien Isorce
2fed41dc30 gl: show internal cocoa window on top of others
Useful when your OSX terminal is fullscreen

https://bugzilla.gnome.org/show_bug.cgi?id=728127
2017-12-09 19:31:39 +00:00
Matthew Waters
db544c3c1f gl/pool: init the upload object on start
Theoretically, set_config could be called multiple times
2017-12-09 19:31:38 +00:00
Sebastian Dröge
8c56e1bba7 gl: Try harder to load symbols from the correct place
This commit makes the loading of the GModules threadsafe, and
always first tries to load the symbol for the GL library that
is selected for the current context. Only then it falls back
to looking into the current module (NULL), and only as a last
resort the context specific function (e.g. eglGetProcAddress())
is called.

Also add configure parameters to select the names of the library
modules instead of using the defaults, and let the defaults be
independent of the G_MODULE_SUFFIX.

https://bugzilla.gnome.org/show_bug.cgi?id=728753
2017-12-09 19:31:38 +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
Matthew Waters
8638a5638c gl/mem: pad the public struct 2017-12-09 19:31:38 +00:00
Nicolas Dufresne
1e8fc49203 gl: no need to provide full lib path to load symbols
- Make gstgl work on Mali
- Keep it work on RPI
- fallback to NULL name module if fails with usual lib name

https://bugzilla.gnome.org/show_bug.cgi?id=728753
2017-12-09 19:31:38 +00:00
Julien Isorce
cebcc837de gl: add convenient functions to setup default vertex and fragment shaders
Most of our 2D filters use the same simple vertex shader.
Also define the default fragment shader as the identity.

Avoid duplicating the same vertex and fragment shader text.
2017-12-09 19:31:38 +00:00
Philippe Normand
95290346c6 gl: add missing G_BEGIN/END_DECLS in utils header 2017-12-09 19:31:38 +00:00
Jan Schmidt
cf018389e1 gl: Reduce noisy Info level output to LOG 2017-12-09 19:31:38 +00:00
Julien Isorce
391661b626 gl: use gst_gl_platform_from_string because we support gl shareList on all platforms 2017-12-09 19:31:38 +00:00
Julien Isorce
c441afdc6b glfilter: only warn when other_context attribute is set
Fix false positive
2017-12-09 19:31:38 +00:00
Julien Isorce
959aae65c0 gl: fix string literal warning
warning: format not a string literal, argument types not checked [-Wformat-nonliteral]
2017-12-09 19:31:38 +00:00
Nicolas Dufresne
801f11e36b gl/x11: Removed unused variable 2017-12-09 19:31:37 +00:00
Sebastian Dröge
8f156591e5 gl/x11: Get rid of unneeded second display connection and do everything from the main loop 2017-12-09 19:31:37 +00:00
Sebastian Dröge
a0a133288e gl/x11: Block rendering until swapbuffers is called and don't go via X11 events as unneeded indirection
This should fix QoS problems, where basesink believed it was rendering with
20FPS but actually we were just queueing up X11 Expose events and only once
in a while something was rendered.
2017-12-09 19:31:37 +00:00
Julien Isorce
c9d2f8ee94 gl/rpi: do not scale to full screen
Having a 640x360 movie being scaled to 1900x1200 does not look nice
2017-12-09 19:31:37 +00:00
Julien Isorce
7a77d435c1 gl/rpi: change dispmanx attributes of existing element instead of creating a new one
I was lucky that:
e1 = vc_dispmanx_element_add ()
eglCreateWindowSurface (e1)
vc_dispmanx_element_remove (e1)
e2 = vc_dispmanx_element_add ()

resulted in having e2 equal to e1. And also having the egl surface
that does not allocate its buffers before the first draw.
2017-12-09 19:31:37 +00:00
Julien Isorce
33a60e238c gl/rpi: ensure the dispmanx element to be opaque
So that we ensure it does not get alpha composited with other
dispmanx elements like the desktop.
2017-12-09 19:31:37 +00:00
Julien Isorce
2cd72a49ec gl/cocoa: pass a NSView to set_window_handle instead of a NSWindow
Fix backwards compatibility

https://bugzilla.gnome.org/show_bug.cgi?id=728451
2017-12-09 19:31:37 +00:00
Julien Isorce
9db9834128 gl/cocoa: only draw once the window has been resized
It avoids to draw the first frame with an incorrect view port.
2017-12-09 19:31:37 +00:00
Julien Isorce
545bed3c7a gl/cocoa: set the view to use for drawing by the context
It avoids to draw to an invalid buffer.
Withtout this the default frame buffer is undefined:
glBindFramebuffer (GL_FRAMEBUFFER, 0)

Visually you could see some white frames at the beginning
when lunching videotestsrc ! glimagesink

With OpenGL Profiler from XCode you could see some
GL_INVALID_FRAMEBUFFER_OPERATION for the first frames
2017-12-09 19:31:37 +00:00
Julien Isorce
e4b832db90 gl: fix declaration-definition mismatch for _init_upload 2017-12-09 19:31:37 +00:00
Julien Isorce
213590c79c gl/bufferpool: do not reset upload when set_config does not change the caps
With videotestsrc ! glimagesink it was reset 3 times
2017-12-09 19:31:37 +00:00
Julien Isorce
bc52c7bb00 gl: use #ifdef instead of #if for __APPLE__
warning: "__APPLE__" is not defined [-Wundef]

with gcc version 4.7.2 20120731 (prerelease)
    (crosstool-NG linaro-1.13.1+bzr2458 - Linaro GCC 2012.08)
2017-12-09 19:31:37 +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
Jan Schmidt
c891eedb79 glcolorconvert: Fix bt709 conversion matrices.
Fix the sign on one entry in the bt.709 YUV->RGB conversion
matrix, and the corresponding inverse matrix. Fixes really
wrong colouring of some videos.
2017-12-09 19:31:37 +00:00
Julien Isorce
d539fd4a54 gl: allow to include GLES/gl.h
https://bugzilla.gnome.org/show_bug.cgi?id=703343
2017-12-09 19:31:37 +00:00
Sebastian Dröge
2843ca2066 gl/eagl: Fix compilation 2017-12-09 19:31:37 +00:00
Sebastian Dröge
a6f5b079d8 gl/eagl: Notify the window's resize callback about surface dimension changes
https://bugzilla.gnome.org/show_bug.cgi?id=728107
2017-12-09 19:31:37 +00:00
Sebastian Dröge
d462e7f6df gl/eagl: Remove spurious private struct pointer 2017-12-09 19:31:37 +00:00
Sebastian Dröge
6fb0f1d1c7 gl/android: Notify the window's resize callback about surface dimension changes
https://bugzilla.gnome.org/show_bug.cgi?id=728107
2017-12-09 19:31:37 +00:00
Matthew Waters
175ca3f7b0 gl/context: output available extensions 2017-12-09 19:31:36 +00:00
Matthew Waters
1460d22e92 gl/context: provide get_gl_version 2017-12-09 19:31:36 +00:00
Julien Isorce
9062658bc7 gl/color: restore viewport dimensions when fbo done
Regression introduced by 95abfda139.
It caused to display the wrong frame size when resizing the window.
2017-12-09 19:31:36 +00:00
Sebastian Dröge
b83d2df47d gl: Import QuartzCore/QuartzCore.h for CAEAGLLayer on older iOS versions 2017-12-09 19:31:36 +00:00
Sebastian Dröge
3770d2a406 gl: Add support for iOS EAGL platform
https://bugzilla.gnome.org/show_bug.cgi?id=703341
2017-12-09 19:31:36 +00:00
Julien Isorce
9d396a2495 gl/cocoa: make gst_gl_window_cocoa_send_message_async re-entrant
Backends that use g_main_context_invoke are re-entrant.

Il allows to call two nested gst_gl_context_thread_add.
ex: init_upload / init_colorconvert
2017-12-09 19:31:36 +00:00
Julien Isorce
3819fbef46 gl/cocoa: fix NSAutoreleasePool initialization 2017-12-09 19:31:36 +00:00
Julien Isorce
08cce2cd5b gl/cocoa: ensure to call NSApplication:sharedApplication in the main thread
"(NSApplication *)sharedApplication This method also makes a connection
to the window server and completes other initialization"
The implicit thing which is not mentioned is that it required
to be called in the main thread.

Fix a regression introduces by 82b7c915bb
When using with gst-launch, it was not possible to click on the close
cross of the window anymore which is a bit anoying and also because
it's was possible before.

Prior to this commit the GstGLContextCocoaClass was initialized
in the main thread because gst_gl_context_new was called in the
state change function from going from ready to paused.

From this commit this call is done from the streaming thread.
So that the call to [NSApplication sharedApplication];
was not done in the main thread anymore.

We now ensure that by assuming there is a GMainLoop running.
It's for debugging purpose so that's ok to do that. Also
note we already do this assumtion to run app itereations.

The regression had no consequence on the cocoa/videooverlay example
(that should be moved from gst-plugins-gl to -bad) because the
application is responsible for that necessary call.
2017-12-09 19:31:36 +00:00
Julien Isorce
e7dc1d787e gl/color: fix warning type qualifiers ignored
i686-apple-darwin11-llvm-gcc-4.2
"warning: type qualifiers ignored on function return type"
2017-12-09 19:31:36 +00:00
Matthew Waters
a321fa998a gl/color: remove if statement with no effect
Coverity 1199698
2017-12-09 19:31:36 +00:00
Matthew Waters
92c243be62 gl/color: pass large value by reference
Coverity 1199700
2017-12-09 19:31:36 +00:00
Matthew Waters
6c73fa0b5f gl/mem: cache the stride/unpack length for upload 2017-12-09 19:31:36 +00:00
Matthew Waters
1ce0c5356f gl/color: explicitly map the buffers we are copying into
Otherwise it may not be downloaded at all.
2017-12-09 19:31:36 +00:00
Matthew Waters
50ff50c10e gl/color: cache the temporary textures 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
7c77c31afd gl: fixup incorrect number of arguments 2017-12-09 19:31:36 +00:00
Matthew Waters
12ecf507b8 gl: fix incorrect usage of g_return_if_fail 2017-12-09 19:31:36 +00:00