Commit graph

775 commits

Author SHA1 Message Date
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
2643ae980a vaapivideobufferpool: keep only current video info
Instead of keeping old and new GstVideoInfo video structure, we only keep one,
the current one, the negotiated. The old one is not needed at all.

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
2562cd51be pluginutil: add gst_video_info_changed() helper
This function is shared among different elements, so let factorized it.

https://bugzilla.gnome.org/show_bug.cgi?id=765435
2016-06-08 10:19:01 +02:00
Hyunjun Ko
08ee0f9e78 vaapipostproc: Add colorimetry attributes to src caps
https://bugzilla.gnome.org/show_bug.cgi?id=766596
2016-06-08 10:17:02 +02:00
Hyunjun Ko
1e52269b89 vaapidecode: remove chroma-site and colorimetry from src caps
https://bugzilla.gnome.org/show_bug.cgi?id=766596
2016-06-08 10:17:02 +02:00
Scott D Phillips
4791e9f2ea vaapipostproc: add postproc_lock to protect data members
Add a mutex to postproc to protect concurrent access to data members.
Previously set_caps() could release the allowed_srcpad_caps while
transform_caps was in the middle of using it.

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

https://bugzilla.gnome.org/show_bug.cgi?id=766940
2016-06-08 10:03:59 +02:00
Sreerenj Balachandran
4464d81b6a Add vp9 encode element to "vaapi" plugin
https://bugzilla.gnome.org/show_bug.cgi?id=766048
2016-05-30 11:24:14 +03: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
9f46a94d2a vaapivideobufferpool: remove GL_TEXTURE_UPLOAD_META
Since gstreamer-vaapi is coupled with gstreamer releases, there is no need to
keep compatibility definition.

This patch removes the definition of
GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META since it is in
gst-plugins-base version 1.2.2
2016-05-25 11:04:53 +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
21b184284b vaapivideobufferpool: split caps validation
When validating the caps from bufferpool config, this patch distinguishes the
error from no caps received (NULL) from the invalid caps (cannot be converted
into GstVideoInfo structure).
2016-05-24 10:33:18 +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
Víctor Manuel Jáquez Leal
9da69fa3a2 vaapipostproc: handle if gst_video_info_from_caps() fails
Return FALSE is the received caps cannot be transformed into a GstVideoInfo
structure.
2016-05-23 18:04:47 +02:00
Víctor Manuel Jáquez Leal
9159328434 plugins: handle if gst_video_info_from_caps() fails
Let's play safe and return error if, somehow, the received caps are wrong.
2016-05-23 17:55:35 +02:00
Víctor Manuel Jáquez Leal
6d8b7056cc plugins: relate errors to instance
Use GST_{ERROR,WARNING}_OBJECT instead of GST_{ERROR,WARNING}, thus the logs
will show the name of the vaapipluginbase instance that failed.

Also, the code-style is fixed, where some error labels need to be surrounded
by braces.
2016-05-23 17:47:36 +02:00
Víctor Manuel Jáquez Leal
4dd2464060 plugins: use GstVideoInfo accessors
Instead of access to GstVideInfo members directly, use their accessors
macros. This patch makes more resistance to future changes in GStreamer core.
2016-05-20 21:01:02 +02:00
Víctor Manuel Jáquez Leal
d69917ecca remove spurious gst_video_info_init()
gst_video_info_set_format() and gst_video_info_from_caps() call, internally,
gst_video_info_init(), hence it is not required to call it before them. This
patch removes these spurious calls.
2016-05-20 19:33:39 +02:00
Víctor Manuel Jáquez Leal
35f6ce964d vaapipluginbase: code-style: rename goto label
The error labels have error_ prefix, but this one.
2016-05-20 19:22:41 +02:00
Víctor Manuel Jáquez Leal
3f61394cb0 vaapivideomemory: use allocator custom alloc flag
Instead of a dummy alloc() vmethod, the allocator instance set the flag
GST_ALLOCATOR_FLAG_CUSTOM_ALLOC, which is used by the framework to avoid call
gst_allocator_alloc() on the allocator.
2016-05-19 16:38:40 +02:00
Víctor Manuel Jáquez Leal
1769da4957 vaapivideobufferpool: relate errors to instance
Use GST_ERROR_OBJECT instead of GST_ERROR, thus the logs will show the name of
the vaapivideobufferpool instance that failed.
2016-05-19 13:21:37 +02:00
Víctor Manuel Jáquez Leal
5341d9ae9f plugins: remove gst_vaapi_plugin_base_set_pool_config()
This function helper make sense for GStreamer 1.2, but it is not helpful for
greater version since the validation is already done in the API implementation.
Thus, it is removed.
2016-05-19 12:54:38 +02:00
Sreerenj Balachandran
36e2346fc7 gstvaapipluginbase: Fix typo in doc 2016-05-18 17:05:03 +03:00
Víctor Manuel Jáquez Leal
7baacda91c vaapipostproc: negotiate frame size fixation
Refactor _fixate_frame_size(). Now, instead of fixating the frame size only
using the sink caps, also it use the next capsfilter.

This code is a shameless copy of gst_video_scale_fixate_caps() from
https://cgit.freedesktop.org/gstreamer/gst-plugins-base/tree/gst/videoscale/gstvideoscale.c?id=1.8.1#n634

https://bugzilla.gnome.org/show_bug.cgi?id=758548
2016-05-09 16:57:17 +02:00
Scott D Phillips
4d1b11ed03 vaapipostproc: don't use GstVideoInfo for src caps
Instead of using gst_video_info_to_caps () to generated the fixed src caps,
this patch enables the first step for caps negotiation with a possible
following caps filter.

_get_preferred_caps() will traverse the possible src caps looking for the one
wit the preferred feature and the preferred color format. Then the color
format, the frame size and the frame rate are fixated.

https://bugzilla.gnome.org/show_bug.cgi?id=758548
2016-05-09 16:57:02 +02:00
Víctor Manuel Jáquez Leal
1901e2231b vaapipostproc: move gst_vaapipostproc_fixate_srccaps()
Move gst_vaapipostproc_fixate_srccaps() to gstvaapiposptprocutil.

No functional changes.

https://bugzilla.gnome.org/show_bug.cgi?id=758548
2016-05-09 16:56:10 +02:00
Víctor Manuel Jáquez Leal
d9b09b623e vaapipostproc: simplify code
Change a convoluted snippet to find the preferred color format in the peer
caps.

https://bugzilla.gnome.org/show_bug.cgi?id=758548
2016-05-09 16:56:10 +02:00
Víctor Manuel Jáquez Leal
bde3b072da vaapipostproc: use othercaps for preferred caps
Instead of the allowed_srcpad_caps variable, this patch uses the othercaps
from fixate_caps() vmethod to find the preferred caps feature and color
format.

https://bugzilla.gnome.org/show_bug.cgi?id=758548
2016-05-09 16:56:10 +02:00
Scott D Phillips
8de7faafdc vaapipostproc: add fixate_caps() vmethod
Instead of fixating the srcpad caps in transform_caps() vmethod, this patch
implements the fixate_caps() vmethod and moves code around.

https://bugzilla.gnome.org/show_bug.cgi?id=758548
2016-05-09 16:55:53 +02:00
Víctor Manuel Jáquez Leal
606d166b56 vaapipostproc: set early properties restrictions
When running transform_caps() vmethod, returning the srcpad caps, the caps are
early restricted to the element properties set: width, height, format and
force keep aspect.

A new file was added gstvaapipostprocutil.{c,h} where the utilities functions
are stored.

https://bugzilla.gnome.org/show_bug.cgi?id=758548
2016-05-09 14:56:03 +02:00
Víctor Manuel Jáquez Leal
54a2d9fb77 vaapipostproc: log the caps transformation
https://bugzilla.gnome.org/show_bug.cgi?id=758548
2016-05-09 14:56:03 +02:00
Víctor Manuel Jáquez Leal
ebf0d94534 vaapipostproc: no GLTextureUpload in sinkpad
As the vaapipostproc does not process frames with the VideoGLTextureUpload
meta, the feature is removed from the sink pad template.

https://bugzilla.gnome.org/show_bug.cgi?id=765931
2016-05-09 14:55:38 +02:00
Julien Isorce
240fc0f726 vaapibufferpool: do not create texture upload meta if dmabuf
https://bugzilla.gnome.org/show_bug.cgi?id=755072
2016-05-09 12:53:21 +01:00
Víctor Manuel Jáquez Leal
4f30d28ff0 plugin: fix macro processor check
Instead of #ifdef it should be used #if becasuse USE_GST_GL_HELPERS is always
defined in config.h, but it would be 0 or 1 depending on the configure output.

https://bugzilla.gnome.org/show_bug.cgi?id=765702
2016-04-29 13:15:01 +02:00
Julien Isorce
910bacc55c vaapipostproc: already have a surface proxy if dmabuf
https://bugzilla.gnome.org/show_bug.cgi?id=755072
2016-04-26 16:05:50 +01:00
Julien Isorce
8a443f0a18 various gst-indent 2016-04-25 22:22:56 +02:00
Víctor Manuel Jáquez Leal
53851b0e73 vaapidecode: search driver in whitelist
If the backend driver vendor string is not in a white-list, and the
environment variable GST_VAAPI_ALL_DRIVERS is not set either, the decoder will
change it state from NULL to READY, hence the auto-plug mechanism will look
for another decoder.

This patch assumes the GstContext has already being shared along the pipeline
and the element has a valid GstVaapiDisplay instance.

https://bugzilla.gnome.org/show_bug.cgi?id=764673
2016-04-22 17:25:00 +02:00
Víctor Manuel Jáquez Leal
bccdda84b7 plugins: rework set_context() vmethod definition
In bug 757598 was added the set_context() vmethod chain up in
GstVaapiPluginBase. But it is buggy, since the parent_class address is
assigned to the last element which called gst_vaapi_plugin_base_class_init().

No error has shown up since none of the element's base classes redefined
set_context() vmethod from GstElement, so always the correct function was
called. Still this code is wrong and this patch make it right.

Since set_context() is the same code, a macro is used to implement that code
in all the gst-vaapi elements.

https://bugzilla.gnome.org/show_bug.cgi?id=765368
2016-04-22 17:18:18 +02:00
Víctor Manuel Jáquez Leal
e519f2ea79 vaapipostproc: resize if negotiated and allocation caps are different
Since commit 859a2b2, in vaapidecode, allocation query can be different from
the negotiated caps.

When connecting the vaapidecoder to the vaapipostprocessor, the last one will
resize the frame to the negotiated, if and only if, some other parameter is
activated to avoid the passthrough. If it is not, the surface won't be mapped
into a image. If not, the image won't be resized and the output buffer would be
mapped.

This patch will break the passthrough if the allocation query is different
from the negotiation caps, forcing the resizing.

https://bugzilla.gnome.org/show_bug.cgi?id=765095
2016-04-22 17:07:53 +02:00
Víctor Manuel Jáquez Leal
23a9a7291a vaapidecode: improve code readability
No functional changes.
2016-04-18 19:07:55 +02:00