Commit graph

136 commits

Author SHA1 Message Date
Víctor Manuel Jáquez Leal
448105578b plugins: handle vaapi allocator in allocation query
In propose_allocation() if the numer of allocation params is zero, the
system's allocator is added first, and lastly the native VA-API
allocator.

In decide_allocation(), the allocations params in query are travered,
looking for a native VA-API allocator. If it is found, it is reused as
src pad allocator. Otherwise, a new allocator is instantiated and
appended in the query.

https://bugzilla.gnome.org/show_bug.cgi?id=789476
2018-02-08 09:57:28 +01:00
Víctor Manuel Jáquez Leal
6efce291f6 plugins: re-using buffer pool breaks renegotiation
at propose_allocation() we should not reuse the proposed buffer,
because it could break renegotiation.

https://bugzilla.gnome.org/show_bug.cgi?id=792620
2018-01-17 22:07:36 +01:00
Víctor Manuel Jáquez Leal
9933dcb218 plugins: use g_clear_object() to unref sinkpad_buffer_pool
https://bugzilla.gnome.org/show_bug.cgi?id=792620
2018-01-17 22:07:35 +01:00
Víctor Manuel Jáquez Leal
8688e81d42 plugins: remove dmabuf-import hack
Remove the hack to check if an upstream element has enabled the
property io-mode enabled as dmabuf-import.

https://bugzilla.gnome.org/show_bug.cgi?id=792034
2018-01-16 19:27:27 +01:00
Víctor Manuel Jáquez Leal
8f5933cd80 vaapivideocontext: only vaapisink process app context
gst.vaapi.app.Display context is made for applications that will
provide the VA display and the native display to used by the
pipeline, when are using vaapisink as overlay. There are no use
case for encoders, decoders, neither for the postprocessor.

In the case of the vaapisink, it shall query for gst.vaapi.Display
upstream first, and then, if there is no reply,
gst.vaapi.app.Display context will be posted in the bus for the
application. If the application replies, a GstVaapiDisplay object
is instantiated given the context info, otherwise a
GstVaapiDisplay is created with the normal algorithm to guess the
graphics platform. Either way, the instantiated GstVaapiDisplay
is propagated among the pipeline and the have-message bus message.

Also only vaapisink will process the gst.vaapi.app.Display, if
and only if, it doesn't have a display already set. This is
caused because if vaapisink is in a bin (playsink, for example)
the need-context is posted twice, leading to an error state.

https://bugzilla.gnome.org/show_bug.cgi?id=790999
2017-12-01 23:11:11 +01:00
Víctor Manuel Jáquez Leal
8092537763 plugins: centralize assignation of GL objects
Add plugin_set_gst_gl() where the GstGL objects are assigned.

https://bugzilla.gnome.org/show_bug.cgi?id=773453
2017-11-01 11:27:36 +01:00
Víctor Manuel Jáquez Leal
3d56306c37 plugins: set GL objects if ensured
Only set the GL display and GL other context if they are ensured.

https://bugzilla.gnome.org/show_bug.cgi?id=773453
2017-11-01 11:27:36 +01:00
Víctor Manuel Jáquez Leal
fc1c415515 plugins: set GL objects if context is handled
Only set the GL display and GL other context if they are extracted
correctly from the gstreamer's context.

https://bugzilla.gnome.org/show_bug.cgi?id=773453
2017-11-01 11:27:36 +01:00
Víctor Manuel Jáquez Leal
4866e4c452 plugins: fix memory leak when GL context is created
When the GL display and context are created inside an VAAPI element
the created GL context is leaked.

https://bugzilla.gnome.org/show_bug.cgi?id=773453
2017-11-01 11:27:36 +01:00
Víctor Manuel Jáquez Leal
72362e1063 plugins: direct rendering on memory:VASurface
As buffers negotiated with memory:VASurface caps feature can also be
mapped, they can also be configured to use VA derived images, in other
words "direct rendering".

Also, because of the changes in dmabuf allocator as default allocator,
the code for configuring the direct rendering was not clear.

This patch cleans up the code and enables direct rendering when the
environment variable GST_VAAPI_ENABLE_DIRECT_RENDERING is defined,
even then the memory:VASurface cap feature is negotiated.

https://bugzilla.gnome.org/show_bug.cgi?id=786054
2017-10-31 18:26:42 +01:00
Víctor Manuel Jáquez Leal
0a36a707ba plugins: only dmabuf on srcpad if downstream
Set if source pad can handle dmabuf only if the GstGL context comes
from downstream.

It is possible to know that at two moments:

1\ In the case of GstGLTextureUpload caps feature is negotiated and
   downstream pool reports back gst.gl.GstGLContext.

2\ When GstGLContext is found as GstContext from dowstream.

https://bugzilla.gnome.org/show_bug.cgi?id=788503
2017-10-20 16:36:04 +02:00
Víctor Manuel Jáquez Leal
998e79ced6 plugins: add gst_vaapi_plugin_base_set_srcpad_can_dmabuf()
This patch refactors the code by adding the function
vaapi_plugin_base_set_srcpad_can_dmabuf(), it determines if the passed
GstGLContext can handle dmabuf-based buffers.

The function is exposed publicly since it is intended to be used later
at GstVaapiDisplay instantiation.

https://bugzilla.gnome.org/show_bug.cgi?id=788503
2017-10-20 16:36:04 +02:00
Nicolas Dufresne
2039eb882e Request minimum buffer even if need_pool is FALSE
When tee is used, it will not request a pool, but still it wants to
know how many buffers are required.

https://bugzilla.gnome.org/show_bug.cgi?id=730758
2017-09-06 14:21:31 -04:00
Víctor Manuel Jáquez Leal
5f64d6df6c plugins: check gst_gl_ensure_element_data() return value
Refactor gst_vaapi_plugin_base_create_gl_context() in order to check
the return value of gst_gl_ensure_element_data(). The result is a code
bit cleaner.
2017-08-01 18:10:50 +02:00
Víctor Manuel Jáquez Leal
b6863e64b5 vaapipluginbase: force dmabuf allocator if DMABuf caps feature
Instantiate all dmabuf allocator for src pad buffer pool if the
src caps ask for memory:DMABuf feature.

https://bugzilla.gnome.org/show_bug.cgi?id=755072
2017-06-23 18:44:42 +02:00
Víctor Manuel Jáquez Leal
f578515988 vaapipluginbase: dmabuf memory map trial for raw caps
Only push dmabuf-based buffers with raw caps if gst_memory_map()
succeeds. Otherwise, use the the vaapi surfaces allocator.

https://bugzilla.gnome.org/show_bug.cgi?id=755072
https://bugzilla.gnome.org/show_bug.cgi?id=774649

Original-patch-by: Julien Isorce <j.isorce@samsung.com>
2017-06-23 18:44:42 +02:00
Víctor Manuel Jáquez Leal
05a41009f2 plugins: update buffer size with the one reported by allocator
There is a regression in 7a206923, since the buffer pool ditches all
the buffers generated by them because the pool config size is
different of the buffer's size.

Test pipeline:

  gst-launch-1.0 filesrc location=big_buck_bunny_1080p_h264.mov \
      ! qtdemux ! vaapih264dec ! vaapipostproc ! xvimagesink    \
      --gst-debug=GST_PERFORMANCE:5

The allocator may update the buffer size according to the VA surface
properties. In order to do this, the video info is modified when the
allocator is created, which reports through the allocation info the
updated size, and set it to the pool config.
2017-06-23 17:49:38 +02:00
Víctor Manuel Jáquez Leal
7a20692364 plugins: distinguish allocation and negotiation caps
The vaapi video decoders might have different allocation caps from
the negotiation caps, thus the GstVideoMeta shall use the negotiation
caps, not the allocation caps.

This was done before reusing gst_allocator_get_vaapi_video_info(),
storing there the negotiation caps if they differ from the allocation
ones, but this strategy felt short when the allocator had to be reset
in the vaapi buffer pool, since we need both.

This patch adds gst_allocator_set_vaapi_negotiated_video_info() and
gst_allocator_get_vaapi_negotiated_video_info() to store the
negotiated video info in the allocator, and distinguish it from
the allocation video info.

https://bugzilla.gnome.org/show_bug.cgi?id=783599
2017-06-12 18:41:14 +02:00
Víctor Manuel Jáquez Leal
24af97a7d1 plugins: enable direct rendering with envvar
Direct rendering (use vaDeriveImage rather than vaPutImage) has better
performance in some Intel platforms (Haswell, for example) but in others
(Skylake) is the opposite.

In order to have some control, the patch enables the direct rendering
through the environment variable GST_VAAPI_ENABLE_DIRECT_RENDERING.

Also it seems to generating some problems with gallium/radeon backend.
See bug #779642.

https://bugzilla.gnome.org/show_bug.cgi?id=775848
2017-04-12 20:39:06 +02:00
Víctor Manuel Jáquez Leal
025d5ce33e plugins: fix build when gcc
In commit a8e482f9 we added a function without parameters, but gcc
doesn't like that.
2017-02-09 12:49:44 +01:00
Julien Isorce
a8e482f93f plugins: use linear storage if not the same device
When dmabuf is negotiated downstream and decoding and rendering are
not done on the same device, the layout has to be linear in order for
the memory to be shared accross devices, since each device has its
own way to do tiling.

Right now this code is rather just a to-do comment, since we are not
fetching the device ids.

https://bugzilla.gnome.org/show_bug.cgi?id=755072
2017-02-09 11:24:08 +01:00
Víctor Manuel Jáquez Leal
50242eaaf7 plugins: decoder can negotiate dmabuf downstream 2017-02-03 17:11:20 +01:00
Víctor Manuel Jáquez Leal
aa20508bcf plugins: enable DMAbuf allocator to downstream
If the negotiated caps are raw caps and downstream supports the
EGL_EXT_image_dma_buf_import extension, then the created allocator
is the DMAbuf, configured to downstream.

At this moment, the only element which can push dmabuf-based buffers
to downstream, is vaapipostproc.
2017-02-02 20:33:36 +01:00
Víctor Manuel Jáquez Leal
37b7743934 plugins: check if negotiate dmabuf with downstream
In order to enable, in the future, dmabuf-based buffers, the vaapi base
plugin needs to check if downstream can import dmabuf buffers.

This patch checks if downstream can handle dmabuf, by introspecting the
shared GL context. If the GL context is EGL/GLES2 and have the extension
EGL_EXT_image_dma_buf_import, then dmabuf can be negotiated.

Original-patch-by: Julien Isorce <j.isorce@samsung.com>
2017-02-02 20:33:36 +01:00
Julien Isorce
fbed3c3366 vaapivideomemory: add direction to dmabuf allocator
Add GstPadDirection param to gst_vaapi_dmabuf_allocator_new(), thus
we later could do different thing when the allocated memory is for
upstream or dowstream, as required by VA-API.

https://bugzilla.gnome.org/show_bug.cgi?id=755072
2017-02-02 20:33:36 +01:00
Víctor Manuel Jáquez Leal
0968ce468d plugins: create a GL context on certain conditions
If a GstVaapiDisplay is not found in the GStreamer context sharing,
then VAAPI elements look for a local GstGLContext in gst context
sharing mechanism ('gst.gl.local.context').

If this GstGLContext not found either then, only the VAAPI decoders
and the VAAPI post-processor, will try to instantiate a new
GstGLContext.

If a valid GstGLContext is received, then a new GstVaapiDisplay will
be instantiated with the platform, API and windowing specified by the
instantiated GstGLContext.

Original-Patch-By: Matt Fischer <matt.fischer@garmin.com>

https://bugzilla.gnome.org/show_bug.cgi?id=777409
2017-01-27 11:27:35 +01:00
Víctor Manuel Jáquez Leal
7fd41c4263 plugins: avoid log flood when activating pool
Every time a new buffer is allocated, the pool is activated. This
doesn't impact in performance since gst_buffer_pool_set_active()
checks the current state of the pool. Nonetheless it logs out a
message if the state is the same, and it floods the logging subsystem
if it is enabled.

To avoid this log flooding first the pool state is checked before
changing it.
2017-01-18 17:25:44 +01:00
Hyunjun Ko
bca2b1680b plugins: provide at least two buffers in sink pool
Adds two buffers as the default value of minimum buffer.

This would be used when creating and proposing vaapi bufferpool for
sink pad, hence the upstream element will keep, at least, these two
buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=775203

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
2017-01-10 13:42:34 +01:00
Víctor Manuel Jáquez Leal
3fccc83278 plugins: destroy source pad allocator and pool
First, deactivate source pad pool when the out caps change, and if so,
destroy texture map, the source pad allocator and pool only if the
new caps are different from the ones already set.
2016-11-24 13:24:08 +01:00
Víctor Manuel Jáquez Leal
8953126374 plugins: don't destroy sink pad allocator
Don't destroy sink pad allocator at _set_caps() because it will be done at
ensure_sinkpad_buffer_pool() if it is required.
2016-11-24 13:24:08 +01:00
Víctor Manuel Jáquez Leal
ec364858b1 plugins: first validate the out caps
When calling _set_caps() first validate the out caps before doing
anything else.
2016-11-24 13:20:40 +01:00
Víctor Manuel Jáquez Leal
d799bb3041 plugins: update the src pad allocator video info
Update the size, stride and offset of the source pad allocator video
info, so the pool could set the correct GstVideoMeta

https://bugzilla.gnome.org/show_bug.cgi?id=774782
2016-11-21 16:37:36 +01:00
Víctor Manuel Jáquez Leal
ac18e0479f plugins: use early return without goto
https://bugzilla.gnome.org/show_bug.cgi?id=774782
2016-11-21 16:37:36 +01:00
Víctor Manuel Jáquez Leal
acefc7e384 plugins: add allocator to allocation query
This patch adds the created allocator to the allocation query either
in decide_allocation() and propose_allocation() vmehtods.

With it, there's no need to set the modified allocator's size in the
pool configuration.

https://bugzilla.gnome.org/show_bug.cgi?id=774782
2016-11-21 16:37:36 +01:00
Víctor Manuel Jáquez Leal
1f190e49c4 plugins: set negotiation caps in src allocator
When the allocator is created, it stores the allocation caps. But sometimes
the "allocation caps" may be different from the "negotiation caps".

In this case, the allocator should store the negotiation caps since they
are the ones used for frame mapping with GstVideoMeta.

When vaapispostproc is used, this is not a problem since the element is assume
to resize. But when using a vaapi decoder only, with a software renderer, it
fails in this case.

https://bugzilla.gnome.org/show_bug.cgi?id=773323
2016-11-04 13:44:29 +01:00
Víctor Manuel Jáquez Leal
e9ba11a733 plugins: remove set_sinkpad_dmabuf_allocator()
Since when the sink pad allocator is created, it is decided if the required
one is vaapi allocator or dmabuf allocator, there is no need to force its set
again.
2016-11-03 13:01:50 +01:00
Víctor Manuel Jáquez Leal
9d5875df67 plugins: ensure display when getting raw caps
When running gst-discoverer-1.0, in certain media, vaapipostroc is stopped
meanwhile it is transforming caps. The problem is that stop() calls
gst_vaapi_plugin_base_close(), which nullifies the element's va display, but
the va display is used in tranform_caps() when it is extracting the possible
format conversions. This display disappearing generates warning messages.

This patch holds a local reference of va display at ensure_allowed_raw_caps()
hence it doesn't go away meanwhile it is used, even if the
gst_vaapi_plugin_base_close() is called in other thread.

https://bugzilla.gnome.org/show_bug.cgi?id=773593
2016-11-03 12:59:22 +01:00
Víctor Manuel Jáquez Leal
3578716a4f plugins: update GstGL deprecated symbol
GST_GL_TYPE_CONTEXT was deprecated. Now it is GST_TYPE_GL_CONTEXT.
2016-11-03 09:31:17 +01:00
Víctor Manuel Jáquez Leal
202110bded plugins: direct render when raw video
Enable the direct rendering with linear surfaces if the negotiated src caps
are video/x-raw without features.

Pass also the caps, since they are needed to know the requested caps features.
2016-11-03 08:38:35 +01:00
Víctor Manuel Jáquez Leal
faebca3383 plugins: move src allocator error to instantiator
Just as we did in ensure_sinkpad_allocator(), let's move the error message
into the ensure_srcpad_allocator() from the caller,
gst_vaapi_plugin_base_decide_allocation()
2016-11-03 08:37:51 +01:00
Víctor Manuel Jáquez Leal
02f16e82e9 plugins: enable direct upload if raw video
Enable the direct upload with linear surfaces if the negotiated sink caps are
video/x-raw without features.
2016-11-03 08:35:29 +01:00
Víctor Manuel Jáquez Leal
e0d73d613e plugins: receive caps in ensure_sinkpad_allocator()
Instead of receiving the GstVideoInfo structure as parameter, get the original
GstCaps from ensure_sinkpad_buffer_pool(), in this way we could decide better
which allocator instantiate.
2016-11-03 08:35:29 +01:00
Víctor Manuel Jáquez Leal
e988298782 vaapivideomemory: set direct rendering at run-time
The way to experiment with the direct rendering is through and internal
compiler pre-processor flag.

The current change set enables a way to specified at run-time, as a flag
passed to the allocator at instanciation time.
2016-11-03 08:35:28 +01:00
Víctor Manuel Jáquez Leal
242e801818 plugins: log the GstVaapiDisplay name
Now that GstVaapiDisplay is descendant of GstObject, it has a human-friendly
name. Log it instead of the memory address.
2016-11-03 08:27:57 +01:00
Víctor Manuel Jáquez Leal
4f4e0a8f36 plugins: simplify code
Merge two lines of variable declarations.

https://bugzilla.gnome.org/show_bug.cgi?id=773497
2016-10-25 19:04:31 +02:00
Hyunjun Ko
5a4540e654 plugins: reset textures at negotiation/shutdown
When caps reconfiguration is called, the new downstream frame size might be
different. Thus, if the downstream caps change,the display's texture map is
reset.

In addition, during pipeline shutdown, textures in texture map have to be
released, since each one have a reference to the GstVaapiDisplay object, which
is a dangerous circular reference.

https://bugzilla.gnome.org/show_bug.cgi?id=769293

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
2016-09-22 17:01:59 +02:00
Hyunjun Ko
de233c137f plugins: set allocator's image size to sinkpad bufferpool
Otherwise the buffer is always ditched by the bufferpool, losing performance.

https://bugzilla.gnome.org/show_bug.cgi?id=771035
2016-09-08 17:09:55 +02:00
Víctor Manuel Jáquez Leal
020cb8badb plugins: check dmabuf-import for sink pad allocator
Check earlier if upstream video source has activated the dmabuf-import
io-mode (hack to disappear soon), thus we can avoid the re-assignation of a
new allocator.
2016-07-29 15:54:50 +02:00
Víctor Manuel Jáquez Leal
773eea0db0 plugins: reset allocators if video info changed
If the frame size or format, change, the allocators are reset, so a new ones
can be created with the new video info.
2016-07-29 15:54:50 +02:00
Víctor Manuel Jáquez Leal
01b5ed3edb plugins: remove sink pad allocator if caps change
If the negotiated sinkpad caps change, destroy the assignated allocator,
because it is not valid anymore.
2016-07-29 15:25:09 +02:00