Commit graph

1336 commits

Author SHA1 Message Date
Víctor Manuel Jáquez Leal
e0a56f3391 Revert "vaapi: Demote vaapidecodebin to rank NONE."
This reverts commit 7a25c5d4ec.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/436>
2021-07-09 11:01:14 +02:00
He Junyan
677d1e0105 plugins: encode: fix a deadlock because of _drain()
We call gst_vaapiencode_drain() in gst_vaapiencode_change_state(),
whose context does not hold the stream lock of the encoder. The
current gst_vaapiencode_drain inside unlock/lock pair adds a extra
lock count to the stream lock of encoder and causes hang later.
We just remove the gst_vaapiencode_drain() and expand its logic
correctly according to the lock/unlock context.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/433>
2021-07-01 11:57:10 +00:00
Víctor Manuel Jáquez Leal
7a25c5d4ec vaapi: Demote vaapidecodebin to rank NONE.
One of the main reasons of vaapidecodebin was because it mitigated the
possible surface exhaustion. But that problem is currently
solved. Nowadays, vaapidecodebin brings more problems than it
solves. Thus this patch demotes vaapidecodebin to NONE rank while
bumping PRIMARY + 1 the most common decoders.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/426>
2021-05-21 09:36:26 +00:00
Víctor Manuel Jáquez Leal
b3d9c5bf80 plugins: Demote rank of vaapipostproc and vaapioverlay.
Since almost all video filters have rank NONE, these both elements
should be NONE too.

This is useful for autovideoconvert and other bins, and users might
force to use these by setting the environment variable
GST_PLUGIN_FEATURE_RANK.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/429>
2021-05-20 10:35:32 +02:00
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
He Junyan
18f530978b plugins: postproc: Fix a problem of propose_allocation when passthrough.
We should query the downstream element to answer a precise allocation
query when the passthrough mode is enabled.
The current way still decides the allocation by the postproc itself. The
pipeline such as:
  gst-launch-1.0 -v filesrc location=xxx.264 ! h264parse ! vaapih264dec ! \
  vaapipostproc ! fakevideosink silent=false sync=true
will lose some info such as the GST_VIDEO_META_API_TYPE.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/413>
2021-02-04 08:59:28 +00:00
Haihao Xiang
4ff4bcd725 libs: display: drm: support gst.vaapi.app.Display context for drm backend
Attributes for drm backend:
- va-display : ponter of VADisplay
- drm-device-fd : the DRM device file descriptor

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/409>
2021-01-29 14:08:42 +00:00
He Junyan
0a34b6882e libs: decoder: AV1: Add the av1 decoder support.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/191>
2021-01-06 00:08:01 +08: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
He Junyan
5bee089331 plugins: encode: unlock the stream lock before _flush()
The current encoder will hang when EOS comes. When we call the
gst_vaapi_encoder_encode_and_queue(), we should release the stream
lock, just like what we do in gst_vaapiencode_handle_frame().

The deadlock happens when: The input thread holding the stream lock
is using gst_vaapi_encoder_create_coded_buffer() to acquire a coded
buffer, while the output thread which holding the coded buffer resource
is acquiring the stream lock in _push_frame() to push the data to
down stream element.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/404>
2020-12-11 18:02:34 +00:00
He Junyan
eb9be73299 plugin: encode: vp9: Implement the set_config().
We store the allowed profiles list to encoder in set_config().

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/380>
2020-11-30 16:45:54 +00:00
He Junyan
33ef4ec817 plugin: encode: vp9: Add the profile into output caps.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/380>
2020-11-30 16:45:54 +00:00
He Junyan
d94b864428 libs: decoder: H265: Add MAIN_422_12 profile supporting.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/390>
2020-11-27 14:29:01 +00:00
He Junyan
8af9b46748 libs: decoder: H265: Add MAIN_444_12 profile supporting.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/390>
2020-11-27 14:29:01 +00:00
Víctor Manuel Jáquez Leal
27427c00c0 decoder: don't reply src caps query with allowed if pad is fixed
If the pad is already fixed the caps query have to be reply with the
current fixed caps. Otherwise the query has to be replied with the
autogeneratd src caps.

This path fix this by falling back to the normal caps query processing
if the pad is already fixed. Otherwise it will fetch the allowed src
pad caps.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/397>
2020-09-20 10:02:16 +02:00
He Junyan
6305acc9d3 plugins: decode: fix a DMA caps typo in ensure_allowed_srcpad_caps.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/392>
2020-09-15 00:11:30 +08:00
Marc Leeman
629154642f vaapisink: when updating the caps, reset rotation
When an element upstream changes settings (e.g. crop), new caps are sent
to vaapisink. When vaapisink was rotating the image, it needs to
re-evaluate if the sink needs to rotate the image.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/389>
2020-09-09 16:51:54 +00:00
He Junyan
5c21736903 plugin: decode: Fix two mem leaks because of caps.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/385>
2020-08-17 19:27:11 +08:00
He Junyan
3540dcf4d9 plugin: allocator: No need to ref allocator when create mem.
We do not need to ref the allocator when creating GstVaapiVideoMemory
kind memory, and then release it in _free(). The framework already
does it for us.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/383>
2020-08-16 01:57:15 +08:00
Víctor Manuel Jáquez Leal
ae6d4f3969 vaapiencode: h264: ignore level without breaking negotiation
Since commit 9f627ef2 if the user sets level in the encoder src caps
the caps negotiation is rejected.

But since the same commit the same encoder set the autoconfigured
level in caps. Some change in the base class might fixed the operation
order so now the caps are set and later negotiated.

This patch removes the level check.

Fixes: #273
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/382>
2020-08-14 11:08:54 +00: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
a50b466fc7 vaapidecode: expose raw src caps with same chroma
The try-and-error approach for getting the possible image formats from
a surface has brought several problems in different drivers, from
crashes to drop in performance.

Instead of that we change the algorithm to determine the possible
image formats based in the surface chroma: only those available image
formats with same chroma are exposed as possible raw caps.

Do this is important to avoid performance degrading in raw sinks
which doesn't handle NV12 but it does YV12 or I420.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/381>
2020-08-12 17:50:50 +02:00
Víctor Manuel Jáquez Leal
3e9a6f80aa build: update for gl pkg-config file split
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/378>
2020-08-07 17:30:21 +02:00
Hyunjun Ko
a362d99e9e libs: window: implements gst_vaapi_window_set_render_rectangle
Implements new vmethod gst_vaapi_window_set_render_rectangle,
which is doing set the information of the rendered rectangle set by
user.
This is necessary on wayland at least to get exact information of
external surface.

And vaapisink calls this when gst_video_overlay_set_render_rectangle is
called.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/342>
2020-07-31 14:02:33 +02:00
Hyunjun Ko
a5f37a21ec vaapisink: implements gst_vaapisink_wayland_create_window_from_handle()
Implements gst_vaapisink_wayland_create_window_from_handle() to support
using external wl_surface.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/342>
2020-07-31 14:02:33 +02:00
Víctor Manuel Jáquez Leal
99ac072673 plugins: add gst_vaapi_caps_set_width_and_height_range()
This utility function is called internally by
gst_vaapi_build_caps_from_formats() and can be used outside.

This function sets frame size and framerates ranges.

Also gst_vaapi_build_caps_from_formats() is simplified.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/374>
2020-07-31 10:14:34 +02:00
He Junyan
2bb6e8c813 plugins: encode: h265: set all allowed profiles to encoder.
We should collect all allowed profiles and pass them to the inside
encoder, rather than just calculate the max profile idc.
The allowed profiles should also be supported by the HW.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/349>
2020-07-30 17:48:03 +08:00
He Junyan
38db4bc15e plugins: encode: h265: collect all allowed profiles to encoder.
We should collect all allowed profiles and pass them to the inside
encoder, rather than just calculate the max profile idc.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/349>
2020-07-30 17:45:39 +08:00
He Junyan
3554f06235 libs: encoder: h265: modify set_max_profile to set_allowed_profiles.
In h265, bigger profile idc may not be compatible with the small profile
idc. And more important, there are multi profiles with the same profile
idc. Such as main-422-10, main-444 and main-444-10, they all have profile
idc 4.
So recording the max profile idc is not enough, the encoder needs to know
all allowed profiles when deciding the real profile.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/349>
2020-07-30 17:42:49 +08:00
Víctor Manuel Jáquez Leal
daecc5bfa1 vaapipostproc: early return if fixate srcpad caps fails
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/371>
2020-07-29 16:59:06 +00:00
Víctor Manuel Jáquez Leal
80b1e53ccc vaapipluginutil: simplify gst_vaapi_find_preferred_caps_feature()
Generalize the way how the preferred color format is chosen. Also
use new GStreamre API as syntatic sugar.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/370>
2020-07-29 16:41:58 +00:00
He Junyan
cf3b0120cb libs: profile: Use get_codec_from_caps to get codec type.
There is no need to get a profile from the caps and then convert
that profile into codec type. We can get the codec type by caps's
name easily.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/358>
2020-07-29 16:17:35 +00:00
He Junyan
35c3de234c plugins: encode: vp9: Implement vp9's allowed_profiles() func.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/188>
2020-07-29 15:41:40 +00:00
He Junyan
b86489eb8c plugin: util: rename h26x_encoder_get_profiles_from_caps().
Change its name to encoder_get_profiles_from_caps(). Other codecs such
as VP9 also needs to use this function.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/188>
2020-07-29 15:41:40 +00:00
Víctor Manuel Jáquez Leal
ecd1ca81a7 vaapidecode: always merge profile caps in sink caps
This commit fixes a regression of e962069d, where if the profile's
caps doesn't have a caps profile, it's ignored.

This patch add a conditional jump if the caps doesn't have a profile
field to merge it.

Fixes: #271
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/368>
2020-07-29 09:10:22 +02:00
Víctor Manuel Jáquez Leal
7c2f5f1dd8 vaapidecode: dma caps only use reported color format
This fix pipelines without vaapipostproc after vaapi decoder, such as

gst-launch-1.0 filesrc location=~/file.mp4 ! parsebin ! vaapih264dec ! glimagesink

On EGL platforms, so DMABuf is used.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/366>
2020-07-27 19:34:46 +02:00
Víctor Manuel Jáquez Leal
88f3b6b44d vaapidecode: use allowed srcpad caps for caps query
Instead of using just the template caps use the current allowed
srcpad caps, which is created considering the current decoder
context.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/366>
2020-07-27 19:32:00 +02:00
Víctor Manuel Jáquez Leal
634fefab5d vaapidecode: build allowed srcpad caps from va context
Instead of generating allowed srcpad caps with generic information,
now it takes the size an formats limits from the decoder's context.

This is possible since srcpad caps are generated after the internal
decoder is created.

The patch replaces gst_vaapi_decoder_get_surface_formats() with
gst_vaapi_decoder_get_suface_attributes().

From these attributes, formats are only used for VASurface memory
caps feature. For system memory caps feature, the old
gst_vaapi_plugin_get_allowed_srcpad_caps() is still used, since
i965 jpeg decoder cannot deliver mappable format for gstreamer.
And for the other caps features (dmabuf and texture upload) the
same static list are used.

This patch also adds DMABuf caps feature only if the context
supports that memory type. Nonetheless, we keep the pre-defined
formats since they are the subset of common derive formats formats
supported either by amd/gallium and both intel drivers, since,
when exporting the fd through vaAcquireBufferHandle()/
vaReleaseBufferHandle(), the formats of the derivable image cannot
be retriebable from the driver. Later we'll use the attribute
formats for the DMABuf feature too, when the code be ported to
vaExportSurfaceHandle().

Finally, the allowed srcpad caps are removed if the internal decoder
is destroyed, since context attribues will change.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/366>
2020-07-27 19:32:00 +02:00
Víctor Manuel Jáquez Leal
f04dd7f331 vaapidecode: reorder src caps template
Since negotiation depends on caps order, first is VA, then DMABuf,
later GLUploadTexture (deprecated) and finally raw.

Also, for decoders, the possible available color formats for DMABuf
is extended to all the possible VA color formats.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/366>
2020-07-27 19:01:54 +02:00
Marc Leeman
5b05e28a55 postproc: reconfigure after changing cropping values
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/365>
2020-07-24 17:09:19 +02:00
He Junyan
e911c1ff02 plugin: encode: Add static caps for template documentation.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
2020-07-23 20:30:45 +02:00
He Junyan
f7e0303b9c plugin: encode: vp9: Use the dynamically built src template caps.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
2020-07-23 20:30:45 +02:00
He Junyan
f3540c101c plugin: encode: vp8: Use the dynamically built src template caps.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
2020-07-23 20:30:45 +02:00
He Junyan
adff28f8d2 plugin: encode: jpeg: Use the dynamically built src template caps.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
2020-07-23 20:30:45 +02:00
He Junyan
f321c1b84d plugin: encode: mpeg2: Use the dynamically built src template caps.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
2020-07-23 20:30:45 +02:00
He Junyan
95706691bd plugin: encode: h265: Use the dynamically built src template caps.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
2020-07-23 20:30:45 +02:00
He Junyan
47fec28895 plugin: encode: h264: Use the dynamically built src template caps.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
2020-07-23 20:30:45 +02:00
He Junyan
e260e9cd90 plugin: encode: Store the coded caps in type's init data.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
2020-07-23 20:29:05 +02:00
He Junyan
53d5302cde plugin: util: add helper function build_template_coded_caps_by_codec()
Like build_template_raw_caps_by_codec(), this function can detect and
build the caps for specified codec based on the query of the profiles.
The result is coded caps such as video/x-h265, video/x-h264. The result
can be used as the template of encode's src or decode's sink.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
2020-07-23 20:29:04 +02:00
He Junyan
617dba3869 plugins: utils: rename build_template_caps_by_codec.
Rename the function build_template_caps_by_codec() to the name of
build_template_raw_caps_by_codec(). It can be used to collect all
raw video formats for encode's sink and decode's src.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
2020-07-23 20:27:00 +02:00