Commit graph

162 commits

Author SHA1 Message Date
Matthew Waters
d270654c48 gst: don't use volatile to mean atomic
volatile is not sufficient to provide atomic guarantees and real atomics
should be used instead.  GCC 11 has started warning about using volatile
with atomic operations.

https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719

Discovered in https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/868

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/418>
2021-03-19 19:03:54 +11:00
Víctor Manuel Jáquez Leal
a16849b4ed vaapi: use gst_clear_object instead of g_clear_object
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/406>
2020-12-12 10:38:17 +01:00
Víctor Manuel Jáquez Leal
089ef59c37 plugins: remove gst_vaapi_plugin_base_get_allowed_srcpad_raw_caps()
Since nobody uses it, just remove it.

Thus extract_allowed_surface_formats() is refactored to attend only
gst_vaapi_plugin_base_get_allowed_sinkpad_raw_caps().

Now a surface is created when the image chorma is different from the
previous one. And if the driver has the quirk, it outputs all the
supported image formats without trying them.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/381>
2020-08-12 18:48:59 +02:00
Víctor Manuel Jáquez Leal
d8f0e1b01f plugins: use VA allocator by default on raw caps
Instead of using dmabuf allocator in source pad, when raw video caps
are negotiated, it uses VA allocator as before, since it is stable
in more use cases, for example transcoding, and more backend drivers.

Dmabuf allocator is only used when dmabuf caps feature is negotiated.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/352>
2020-07-08 11:17:38 +00:00
He Junyan
72c4a161c0 plugins: pluginbase: Do not destroy display when _close()
When the element's state changes to NULL, it can still receive
queries, such as the image formats. The display is needed in such
queries but not well protected for MT safe.
For example, ensure_allowed_raw_caps() may still use the display
while it is disposed by gst_vaapi_plugin_base_close() because of
the state change.

We can keep the display until the element is destroyed. When the
state changes to NULL, and then changes to PAUSED again, the display
can be correctly set(if type changes), or leave untouched.

Fix: #260
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/343>
2020-06-11 18:32:58 +08:00
Víctor Manuel Jáquez Leal
ee3d4c3206 libs: display: driver quirks mechanism
This mechanism comes from ffmpeg vaapi implementation, where they have
their own quirks.

A specific driver is identified by a substring present in the vendor
string. If that substring is found, a set of bitwise flags are store.
These flags can be accessed through the function
gst_vaapi_display_has_driver_quirks().

The purpose for this first quirks is to disable the put image try for
AMD Gallium driver (see [1]).

1. https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/merge_requests/72
2020-01-24 12:21:59 +00:00
U. Artie Eoff
894c1da6c7 plugins: base: add GstVideoAggregator subclass support 2020-01-06 19:56:10 +00:00
U. Artie Eoff
18d1c75d1a plugins: base: do not reset can_dmabuf
Don't reset the can_dmabuf field.  This restores the
close/reset logic that existed prior to commit
ca2942176b in regards to
dmabuf support.

Plugins only call gst_vaapi_plugin_base_set_srcpad_can_dmabuf
once during startup, but may need to reset the other private
fields multiple times during negotiation.  Thus, can_dmabuf
should be exempt from the resets.

Fixes #208
2019-12-20 06:38:42 -08:00
He Junyan
608ce681e5 libs: surface: port to GstMiniObject
GstVaapiMiniObject and GstVaapiObject are deprecated.

This is the first step to remove them by porting GstVaapiSurface as
a GstMiniBuffer descendant.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2019-12-20 05:01:08 +00:00
He Junyan
d56824c05c libs: image: port to GstMiniObject base class
GstVaapiMiniObject and GstVaapiObject are deprecrated. This is the
first step to remove them, by porting GstVaapiImage as a
GstMiniObject.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2019-12-20 05:01:07 +00:00
U. Artie Eoff
b1bab9a317 plugins: base: add GstPad param to internal helper functions
The base plugin public API function implementations determine
which pad should be passed to the internal helper functions.
Currently, only the base plugin static sinkpad and static
srcpad are supported/used.  However, this change enables future
API functions to be added that can accept a pad (i.e. request pad)
from an element subclass (e.g. a GstVideoAggregator subclass).
2019-12-11 21:27:48 +00:00
U. Artie Eoff
ca2942176b plugins: base: manage pad-specific data in a single struct
Define a struct (GstVaapiPadPrivate) to encapsulate the
pad-specific data (i.e. buffer pool, allocator, info,
caps, etc.).

Add an interface to retrieve the data struct for a given
pad.

Finally, update the base plugin to use the data struct
throughout the implementation.

This will enable us to easily extend the base plugin in the
future to allow for N-to-1 pad subclasses (e.g. overlay/
composite).
2019-12-11 21:27:48 +00:00
U. Artie Eoff
a6dfb6e5be plugins: remove last negotiated video info if caps are same
If the allocation caps and negotiated caps are the same,
then ensure any previously negotiated video info is also
removed.  This can occur when multi-resolution video
decoding returns to it's original resolution.

Fixes #170
2019-06-10 21:28:13 -07:00
Haihao Xiang
920b1ec7a8 vaapi: bump the minimum vaapi version requirement to 0.39.0
And reduce unnecessary API version and structures check as well.

https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/issues/108
2019-01-07 17:46:42 +00:00
He Junyan
7663fa263c plugins: Add more check for allowed raw caps.
The gst_vaapi_plugin_base_get_allowed_raw_caps is used for both sink
pad and src pad, which cause some bugs. For sink pad, we need to verify
vaPutImage() while for the src pad we need to verify vaGetImage().
For vaapidecoderXXX kind of plugins, the case is more complex. We need
to verify whether the decoded result(in some surface, NV12 format most
of the time) can be vaGetImage to some raw image format. Add more check
to fix all these problems.

https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/issues/123

Signed-off-by: He Junyan <junyan.he@hotmail.com>
2018-12-24 10:46:23 +00:00
He Junyan
176bbce975 plugins: modify image check of extract_allowed_surface_formats.
The extract_allowed_surface_formats function just check whether
we can support some kind of surface/image format pair. We just
need to create a surface, create an image with the same video-format
and putImage from image to surface. All these operations success,
that kind of video-format is supported.
The old manner do not work for some kind of video-format. For example,
the RGBA kind of format will create a NV12 surface and RGBA image,
and the putImage will fail because the format is not same. And so
the RGBA format is not supported but actually it is supported.
2018-11-27 15:11:51 +00:00
Wangfei
619abbdeb4 libs: dec: h265: add 422 chroma format support.
Add main-422-10 profile which support 422 chroma format stream.
Currently, this feature is only supported by media-driver in Icelake.

https://bugzilla.gnome.org/show_bug.cgi?id=797143
2018-09-27 11:55:04 +02:00
Víctor Manuel Jáquez Leal
6ccd5d6fb2 libs: display: remove gst_vaapi_display_ref()
Replace it with gst_object_ref()

https://bugzilla.gnome.org/show_bug.cgi?id=796470
2018-06-14 16:41:00 +02:00
Víctor Manuel Jáquez Leal
fb1c4c52cc libs: display: remove gst_vaapi_display_unref()
Use gst_object_unref() instead.

https://bugzilla.gnome.org/show_bug.cgi?id=796470
2018-06-14 16:41:00 +02:00
Víctor Manuel Jáquez Leal
59579a9cb3 plugin: remove custom GstGL context handling
Instead of using our own context handling for looking for GstGL
parameters (display, context and other context), this patch changes
the logic to use the utility function offered by GstGL.

https://bugzilla.gnome.org/show_bug.cgi?id=793643
2018-04-26 19:37:54 +02:00
Víctor Manuel Jáquez Leal
86bf89d16d plugins: GstGL API must use the member variables
This commit basically is a revert of commits 8092537 and fc1c415

https://bugzilla.gnome.org/show_bug.cgi?id=793643
2018-04-26 19:37:54 +02:00
Hyunjun Ko
b9c38a295b plugins: pass members as parameters of gst_gl_ensure_element_data()
The parameters of gst_gl_ensure_element_data() have to be not
local variable since they are going to be used to see if they're
set in gst_element_set_context() inside the API.

This is basically a revert of commit 3d56306c

https://bugzilla.gnome.org/show_bug.cgi?id=793643
2018-04-26 19:35:49 +02:00
Víctor Manuel Jáquez Leal
ba28c6cff2 plugins: copy input buffer metas
When importing buffers to a VA-base buffer, it is required to copy
the metas in the original buffer, otherwise information will be
lost, such as GstVideoRegionOfInterestMeta.

https://bugzilla.gnome.org/show_bug.cgi?id=768248
2018-02-27 10:02:14 -06:00
Víctor Manuel Jáquez Leal
2c36610748 plugins: add gst_vaapi_copy_va_buffer()
This helper function aims to copy buffers with VA memory to dumb
buffers, when GstVideoMeta is not available dowstream.

https://bugzilla.gnome.org/show_bug.cgi?id=785054
2018-02-20 10:57:12 -06:00
Víctor Manuel Jáquez Leal
5842e9cf87 plugins: add COPY_OUTPUT_FRAME flag
This patch add the member copy_output_frame and set it TRUE when
when downstream didn't request GstVideoMeta API, the caps are raw
and the internal allocator is the VA-API one.

https://bugzilla.gnome.org/show_bug.cgi?id=785054
2018-02-20 10:57:12 -06:00
Víctor Manuel Jáquez Leal
f0fd2aeb04 plugins: store the first downstream allocator if available
The allocator will be required if we need to allocate a buffer
to store the frame with the expected strides.

https://bugzilla.gnome.org/show_bug.cgi?id=785054
2018-02-20 10:57:12 -06:00
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