Commit graph

111 commits

Author SHA1 Message Date
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
Víctor Manuel Jáquez Leal
892b6d3822 gstvaapivideomemory: allocator's image size getter
Add the method gst_allocator_get_vaapi_image_size() for the
GstVaapiVideoAllocator, which gets the size of the allocated images with the
current video info.

This method replaces the direct call to the allocator's image info when the
pool is configured.
2016-07-29 15:13:29 +02:00
Hyunjun Ko
d0ee0b4e72 plugins: update buffer pool size with new allocator's image size
Depends on media, video size is sometimes updated with new allocator.
It leads to dismatch between bufferpool's set size and real allocated buffer size.

In this case, it causes every buffer is freed during release in bufferpool,
which should be reused. This affects performance.

https://bugzilla.gnome.org/show_bug.cgi?id=769248
2016-07-29 13:46:52 +02:00
Víctor Manuel Jáquez Leal
604986749e plugins: add gst_vaapi_plugin_base_find_gl_context()
Using the GstContext mechanism, it is possible to find if the pipeline
shares a GstGLContext, even if we are not to negotiating GLTextureUpload
meta. This is interesting because we could negotiate system memory caps
feature, but enable DMABuf if the GstGLContext is EGL with some extensions.

https://bugzilla.gnome.org/show_bug.cgi?id=766206
2016-07-22 17:23:23 +02:00
Víctor Manuel Jáquez Leal
fabcb4dc06 plugins: remove gst_vaapi_plugin_base_driver_is_whitelisted()
Since nobody is calling gst_vaapi_plugin_base_driver_is_whitelisted(),
it is deleted.
2016-07-22 17:23:23 +02:00
Víctor Manuel Jáquez Leal
a9e7eac108 plugins: add gst_vaapi_driver_is_whitelisted()
Move some of the logic in gst_vaapi_plugin_base_driver_is_whitelisted() to a
new function gst_vaapi_driver_is_whitelisted(), in this way, it can be used
when registering the plugin's feature set with the test VA display.

https://bugzilla.gnome.org/show_bug.cgi?id=724352
2016-07-22 17:23:23 +02:00
Scott D Phillips
2e5367a23c plugins: retry pool config
if gst_buffer_pool_set_config returns FALSE, check the modified
config and retry set_config if the config is still acceptable.

Signed-off-by: Scott D Phillips <scott.d.phillips@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=766184
2016-06-14 17:25:58 +02:00
Víctor Manuel Jáquez Leal
f189af8dc5 plugins: remove precondition for decide_allocation()
There's no need to check for the display in the plugin object when
decide_allocation() vmethod is called, because the display will created or
re-created along the method execution.
2016-06-08 19:20:33 +02:00
Víctor Manuel Jáquez Leal
4c99077af4 plugins: avoid possible memory leaks
Get the pool config just before use it, to avoid a memory leak if the
allocator cannot be instantiated. Similarly, return FALSE if the configuration
cannot be set, avoid keep a not used allocator in the pool.
2016-06-08 19:20:33 +02:00
Víctor Manuel Jáquez Leal
8d7a0ae16c plugins: use GstParentBufferMeta
Instead of using the VASurface proxy's notify, which is internal gstvaapi API,
use the GStreamer's GstParentBufferMeta.

https://bugzilla.gnome.org/show_bug.cgi?id=765435
2016-06-08 10:19:01 +02:00
Víctor Manuel Jáquez Leal
8292acfdd4 plugins: cache VASurfaces from dmabufs
This patch avoids the creation of a VASurface each time a new input buffer is
processed, caching them in the input buffer itself.

https://bugzilla.gnome.org/show_bug.cgi?id=765435
2016-06-08 10:19:01 +02:00
Víctor Manuel Jáquez Leal
73d1228896 libs: change gst_vaapi_surface_new_with_dma_buf_handle()
Instead of passing the data already in GstVideoInfo, let's just pass the
GstVideoInfo structure.

https://bugzilla.gnome.org/show_bug.cgi?id=765435
2016-06-08 10:19:01 +02:00
Víctor Manuel Jáquez Leal
ad4c38b36f plugins: use an unique allocator per pad
Instead of instantiating an allocator per vaapivideobufferpool, only one
allocator is instantiated per element's pad and shared among future pools.
If the pad's caps changes, the allocator is reset.

https://bugzilla.gnome.org/show_bug.cgi?id=765435
2016-06-08 10:19:01 +02:00
Víctor Manuel Jáquez Leal
6c5b6232da vaapivideobufferpool: share options flag with pluginbase
Originally, vaapivideobufferpool has a set of boolean variables for the
buffer configuration options.

This pach changes these boolean variables for a single bitwise, just as
it is used in pluginbase. Hence, the internal enum was moved to
vaapivideobufferpool header.

https://bugzilla.gnome.org/show_bug.cgi?id=765435
2016-06-08 10:19:01 +02:00
Víctor Manuel Jáquez Leal
d0c72182a4 plugins: add gst_vaapi_plugin_base_create_pool()
This patch refactors the code in pluginbase in order to centralize the buffer
pool instantiation. As the buffer pool config may have different options, these
are gathered using a bitwise flag.

https://bugzilla.gnome.org/show_bug.cgi?id=765435
2016-06-08 10:19:01 +02:00
Víctor Manuel Jáquez Leal
50b2423a2b pluginbase negotiates allocator with bufferpool
Originally vaapivideobufferpool instantiates its own allocator regardless the
received configuration, and it relies in custom configuration options to
choose which kind of allocator instantiate.

This patch transfers the responsibility of the allocator instantiate to
vaapipluginbase and pass it to the vaapivideobufferpool through its
configuration.

* gst/vaapi/gstvaapipluginbase.c
  + set_dmabuf_allocator(): inserts a dmabuf allocator in the bufferpool
  + ensure_sinkpad_buffer_pool(): set a normal vaapi video allocator in
    bufferpool configuration
  + gst_vaapi_plugin_base_propose_allocation(): call set_dmabuf_allocator() if
    needed.
  + gst_vaapi_plugin_base_decide_allocation(): set a normal vaapi video
    allocator in bufferpool configuration
* gst/vaapi/gstvaapivideobufferpool.c
  + gst_vaapi_video_buffer_pool_set_config(): instead of instantiate the
    allocator, process the received one through its configuration.
* gst/vaapi/gstvaapivideobufferpool.h: removed
  GST_BUFFER_POOL_OPTION_DMABUF_MEMORY since it is not used anymore.
* gst/vaapi/gstvaapivideomemory.c
  + gst_vaapi_is_dmabuf_allocator(): new helper function to identify a dmabuf
    allocator with the vaapi qdata.

https://bugzilla.gnome.org/show_bug.cgi?id=765435
2016-06-08 10:19:01 +02:00
Víctor Manuel Jáquez Leal
3d9f8dd41f pluginutil: add gst_video_info_force_nv12_if_encoded()
This lines repeat a couple times in the code, so it would be better to put it
a helper function.

https://bugzilla.gnome.org/show_bug.cgi?id=765435
2016-06-08 10:19:01 +02:00
Víctor Manuel Jáquez Leal
101e31df83 plugins: remove unused header
Remove the include of gst/allocators/allocators.h since it is not used.
2016-05-25 12:36:12 +02:00
Víctor Manuel Jáquez Leal
789afaccfb plugins: add gst_vaapi_buffer_pool_caps_is_equal()
This is a helper function to improve the readability of
ensure_sinkpad_buffer_pool(). It makes clearer when the buffer pool needs to be
re-instantiated.
2016-05-24 16:50:41 +02:00
Víctor Manuel Jáquez Leal
2fc855b134 plugins: deactivate buffer pool before unref
This buffer pool may still be processing buffers when a caps renegotiation is
done. This one-liner patch deactivates the pool to drain it before it
de-allocation.
2016-05-24 16:50:41 +02:00
Víctor Manuel Jáquez Leal
b27ddd8036 plugins: no sinkpad bufferpool when decoder
Right now, the decoders create a buffer pool for their sink pad which is not
used at all, because the decoders have never proposed it to upstream.

This patch avoids the buffer pool instantiating when the element inherits from
the GstVideoDecoder class.
2016-05-24 16:50:39 +02:00
Víctor Manuel Jáquez Leal
c9f6006865 plugins: avoid to get/set pool config twice
This patch is a bit of optimization, since the bufferpool configuration is get
when the pool is created. Hence, we only need to request it when the pool from
the allocation query is reused.
2016-05-24 13:39:25 +02:00
Víctor Manuel Jáquez Leal
9667f0e472 plugins: destroy pool earlier if non-vaapi
If the offered pool in decide_allocation() vmethod doesn't have the
VAAPI_VIDEO_META option, it is destroyed immediatly and the pointer cleared,
so it could be created later.
2016-05-24 13:35:55 +02:00
Víctor Manuel Jáquez Leal
1f5ba28bd0 plugins: check for caps in query earlier
Check for caps as soon gst_query_parse_allocation() returns.
2016-05-24 10:33:18 +02:00
Víctor Manuel Jáquez Leal
f0d385ea4e plugins: remove unused variables
This variables stopped to be used since commit 001a5c63, which removed the
gstvaapiuploader.
2016-05-24 10:33:18 +02:00
Víctor Manuel Jáquez Leal
4800f48980 plugins: fix potential memleak from commit 9159328
If gst_video_info_from_caps() fails it is required to unref the instantiated
pool.
2016-05-23 18:47:46 +02:00