Commit graph

3748 commits

Author SHA1 Message Date
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 5997093ba1 libs: encoder: H264: Fix one assert in get_pending_reordered().
gst_vaapi_encoder_h264_get_pending_reordered() does not consider the
case for HIERARCHICAL_B mode. The pipeline:

gst-launch-1.0  videotestsrc num-buffers=48 ! vaapih264enc prediction-type=2 \
keyframe-period=32 ! fakesink

get a assert:

ERROR:../gst-libs/gst/vaapi/gstvaapiencoder_h264.c:1996:reflist1_init_hierarchical_b:
assertion failed: (count != 0)

The last few B frames are not fetched in correct order when HIERARCHICAL_B
is enabled.

We also fix a latent bug for normal mode. The g_queue_pop_tail() of B frames
make the last several frames encoded in reverse order. The NAL of last few
frames come in reverse order in the bit stream, though it can still output
the correct image.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/405>
2020-12-09 01:26:26 +08:00
He Junyan dfc730165c libs: encoder: H265: Add screen content coding extensions support.
In scc mode, the I frame can ref to itself and it needs the L0 reference
list enabled. So we should set the I frame to P_SLICE type. We do not need
to change the ref_pic_list0/1 passed to VA driver, just need to enable the
VAEncPictureParameterBufferHEVC->pps_curr_pic_ref_enabled_flag to notify
the driver consider the current frame as reference. For bits conformance,
the NumRpsCurrTempList0 should be incremented by one to include the current
picture as the reference frame. We manually do it when packing the slice header.

Command line like:
gst-launch-1.0  videotestsrc num-buffers=10 ! \
capsfilter caps=video/x-raw,format=NV12, framerate=30/1,width=640,height=360 ! \
vaapih265enc ! capsfilter caps=video/x-h265,profile="{ (string)screen-extended-main }" ! \
filesink location=out.265
Can be used to specify that the encoder should use SCC profiles.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/379>
2020-12-06 23:37:56 +08: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 1725e47700 libs: encoder: vp9: no need to ensure_hw_profile.
Once we decide the profile and can get the valid entrypoint for
that profile, hw must already support this profile/entrypoint pair.
No need to check it again in set_context_info().

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/380>
2020-11-30 16:45:54 +00:00
He Junyan a639528217 libs: encoder: vp9: Improve the manner to decide the profile.
We should decide the VP9 encoder's profile based on the chroma and
depth of the input format, then make sure it is included in the
allowed list.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/380>
2020-11-30 16:45:54 +00:00
He Junyan ff829c660b libs: util: vpx: add get_chroma_format_idc for VP9
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/380>
2020-11-30 16:45:54 +00:00
He Junyan 973b879f95 libs: encoder: vp9: Add allowed_profiles.
We need the allowed_profiles to store the allowed profiles in down
stream's caps.
Command line like:
  vaapivp9enc ! capsfilter caps=video/x-vp9,profile="{ (string)1, \
    (string)3 }"
We need to store GST_VAAPI_PROFILE_VP9_1 and GST_VAAPI_PROFILE_VP9_3
in this list.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/380>
2020-11-30 16:45:54 +00:00
He Junyan ba58557c14 libs: decoder: H265: Fix a typo in scc reference setting.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/402>
2020-11-30 18:00:38 +08: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 ec68ec518b video-format: Add Y212_LE format.
It can be used as HEVC YUV_4:2:2 12bits stream's decoder output, and
also can be used as the input format for encoding HEVC YUV_4:2:2 12bits
stream.

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
He Junyan 92b30ffa1a video-format: Add Y412_LE format.
It can be used as HEVC YUV_4:4:4 12bits stream's decoder output, and
also can be used as the input format for encoding HEVC YUV_4:4:4 12bits
stream.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/390>
2020-11-27 14:29:01 +00:00
He Junyan ed9a708397 libs: decoder: h265: fill missing predictor_palette_size field.
The predictor_palette_size of VAPictureParameterBufferHEVCScc is
forgotten and need to be filled when streams have palettes.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/396>
2020-11-15 12:39:22 +00:00
He Junyan d72f818029 libs: utils: h265: Use get_profile_from_sps to get profile.
We now use gst_h265_get_profile_from_sps() to replace the old way
of gst_h265_profile_tier_level_get_profile() to get more precise
profile. The new function consider the unstandard cases and give
a more suitable profile decision.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/395>
2020-10-30 07:24:44 +00:00
Víctor Manuel Jáquez Leal 865a46b193 libs: decoder: vp9: 0xff segment pred probs if no temporal update
According to the spec (6.2.11 Segmentation params syntax)
segmentation_pred_prob[i] ast to be 0xff if not temporal_update.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/400>
2020-10-19 16:45:35 +02:00
Víctor Manuel Jáquez Leal 08b4aaa7fa libs: decoder: vp9: avoid reference rewriting
The removed code set all the reference frames to the current frame it is a key
one, but later, all the reference frames were rewritten with the decoded picture
buffers or VA_INVALID_SURFACE if they were not available.

Basically, all this time the first reference frame assignment has been ignored,
and it's not described by the spec, and this patch removes that code.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/400>
2020-10-19 13:42:53 +02: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
Tim-Philipp Müller 0818af088b ci: include template from gst-ci master branch again 2020-09-08 17:31:02 +01:00
Tim-Philipp Müller ff5b204561 Back to development 2020-09-08 16:59:07 +01:00
Tim-Philipp Müller de6fb60929 Release 1.18.0 2020-09-08 00:09:52 +01:00
Sebastian Dröge 69fbe8c84c Update for gst_video_transfer_function_*() function renaming
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/391>
2020-09-07 12:50:11 +03:00
Víctor Manuel Jáquez Leal f822366f92 Revert "libs: decoder: h264, h265: in context at least 16 reference surfaces"
This reverts commit b387081a4d as discussed in
b387081a4d
2020-08-22 12:57:54 +02:00
Tim-Philipp Müller 0320e7a3b6 Release 1.17.90 2020-08-20 16:16:25 +01:00
Víctor Manuel Jáquez Leal c080ee6dc9 libs: surface: egl: guard memory type
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/384>
2020-08-18 08:11:27 +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 7a3b25884c libs: egl: surface: export EGLImage as DMABuf if GEM not supported
This code path is used when frames are rendered as textures through
GstVideoGLTextureUploadMeta with EGL, mainly under Wayland.

Originally the EGLImage was exported as GEM, which was handled by
Intel drivers, but Gallium ones cannot create VA surfaces from
GEM buffers, only DMABuf.

This patch checks the memory types supported by VA driver to choose
the render the EGLImages from GEM or DMABuf, because GEM is still
better where supported.

DMABuf is well handled either by intel-vaapi-driver and gallium.

Fixes: #137
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/122>
2020-08-14 12:43:20 +02:00
Víctor Manuel Jáquez Leal 992d9e3a20 libs: filter: gst_vaapi_filter_get_memory_types()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/122>
2020-08-14 12:31:37 +02: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
He Junyan 30290115af libs: util: h265: use common parser API to get vaapi profiles.
We can reuse H265 parser's API to recognize the correct profile and
then just need to convert them to VAAPI profiles.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/356>
2020-08-08 19:28:15 +08: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
Xu Guangxin 34b1d195b7 h264dec: mark remaining frames as unreference before exec_picture_refs_modification
8.2.4.2 required this. Some clips will crash if we do not fill the reference list like this.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/376>
2020-08-06 14:13:56 +08:00
He Junyan 55769a16c7 libs: encoder: H265: Enable Main 12 profile support.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/375>
2020-08-06 00:21:50 +08:00
He Junyan 6e97062d35 video format: Fix P012_LE's chrome type typo.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/375>
2020-08-06 00:21:36 +08:00
Jordan Petridis 89580cc230 gstvaapiminiobject.c: fix clang 10 warnings
the typesystem checks in g_atomic_pointer_compare_and_exchange
seem to trigger some false positives with clang 10

similar to gstreamer!584

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/377>
2020-08-04 21:15:01 +03:00
Michael Olbrich 887ba40e65 libs: window: wayland: destroy all wayland buffers during finalize
Some buffers and the associated FrameState state may still be pending at
that point. If the wayland connection is shared, then messages for the
buffer may still arrive. However, the associated event queue is already
deleted. So the result is a crash.

With a private connection the associated memory is leaked instead.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/342>
2020-07-31 14:02:34 +02:00
Michael Olbrich d11ba513bb test: vaapicontext: fix draw callback with multiple videos
The callback is called for both windows. So make sure that
gst_video_overlay_set_render_rectangle() is called for the correct one.
Otherwise, the left video will be randomly moved behind the right video.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/342>
2020-07-31 14:02:33 +02:00
Michael Olbrich 24be7b8aae test: vaapicontext: support wayland display
On Wayland, The whole gtk window is one Wayland surface. So
gtk_widget_get_window() must be called on the top-level widget.
For any other widget the following gdk_window_ensure_native() may create a
new top-level Wayland surface that is never visible.

As a result, the coordinates passed to
gst_video_overlay_set_render_rectangle() must be relativ to the top-level
window. Otherwise the video is placed incorrectly.

Original-Patch-By: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
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 283fceac0b test: vaapicontext: use playbin to test files
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 672b2dd991 test: vaapicontext: add PLAY and NULL buttons
They only appear when only one sink is instanciated and their purpose
is to test the NULL-PLAY use case in context sharing.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/342>
2020-07-31 14:02:33 +02:00
Michael Olbrich 9eb25ab849 libs: wayland: update the opaque region in set_render_rect
gst_vaapi_window_wayland_set_render_rect() may be called from an arbitrary
thread. That thread may be responsible for making the window visible.

At that point another thread will block in gst_vaapi_window_wayland_sync()
because the frame callback will not be called until the window is visible.

If that happens, then acquiring the display lock in
gst_vaapi_window_wayland_set_render_rect() would result in a deadlock.

Cache the size of the opaque rectangle separately and create the opaque
region right before applying it to the surface.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/342>
2020-07-31 14:02:33 +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
Michael Olbrich 40364c2c09 libs: wayland: implement video overlay API
The Wayland sub-surfaces API is used to embed the video into an application
window.

See Appendix A. Wayland Protocol Specification as the following.

"""
The aim of sub-surfaces is to offload some of the compositing work
within a window from clients to the compositor. A prime example is
a video player with decorations and video in separate wl_surface
objects.

This should allow the compositor to pass YUV video buffer processing to
dedicated overlay hardware when possible.
"""

Added new method gst_vaapi_window_wayland_new_with_surface()

Original-Patch-By: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
                   Zhao Halley <halley.zhao@intel.com>
                   changzhix.wei@intel.com
                   Hyunjun Ko <zzoon@igalia.com>

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/342>
2020-07-31 14:02:33 +02:00