Commit graph

1909 commits

Author SHA1 Message Date
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
Michael Olbrich
afe49e9fdb libs: window: wayland: use dmabuf protocol if available
Currently vaGetSurfaceBufferWl() is used to create wayland buffers.
Unfortunately this is not implemented by the 'media-driver' and Mesa VA-API
drivers. And the implementation provided by 'intel-vaapi-driver' is not
compatible with a Wayland server that uses the iris Mesa driver.

So create the Wayland buffers manually with the zwp_linux_dmabuf_v1 wayland
protocol. Formats and modifiers supported by the Wayland server are taken
into account. If necessary, VPP is enabled to convert the buffer into a
supported format.

Fall back to vaGetSurfaceBufferWl() if creating buffers via dambuf protocol
fails.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/346>
2020-07-27 15:02:19 +00:00
Michael Olbrich
72d32a91d2 libs: window: allow choosing the format for the vpp pool
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/346>
2020-07-27 15:02:19 +00:00
Michael Olbrich
856b9d5980 video-format: add DRM formats to the mapping table
This will be needed for the DMABuf protocol support to map DRM formats to
vaapi and gstreamer formats.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/346>
2020-07-27 15:02:19 +00:00
Michael Olbrich
bef64a6420 libs: display: wayland: add basic dmabuf protocol support
This is just the basic infrastructure. Hook up the interface and collect
all supported formats.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/346>
2020-07-27 15:02:19 +00:00
Michael Olbrich
9ccb0c57fa libs: window: wayland: wait for configure before committing the first buffer
Committing the first buffer for a surface must not be done before
ack_configure() has been sent for the xdg_surface.

With weston, the commit will fail with "error 3: xdg_surface has never been
configured".

Wait in gst_vaapi_window_wayland_show() until configure is done to avoid
this.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/346>
2020-07-27 15:02:19 +00:00
He Junyan
a73e6b7dac libs: encoder: h265: set no P frame automatically.
The double reference lists may be required by drivers and there should
be no P frames in the of stream. The old way of converting P frames to
B frames is by setting `low-delay-b` property, which is unconvenient
and has bad user experience, since most of the users do not know when
to set this property, and if it is not set correctly, the encoding
pipeline fails or even hangs on some platforms. VA driver now provides
a attribute to query whether both reference lists must be un-NULL for
a profile/entrypoint pair.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/284>
2020-07-27 16:38:38 +02:00
He Junyan
ee7677211a libs: encoder: h265: Deprecate the low-delay-b property.
In HEVC, P and B definitions are different from AVC: P frames have
just one reference list and so 1 MV, while B frames have two reference
lists and so 2 MVs. No matter B or P, ist reference lists can contain
forward/backward reference. So P and B can both have bi-directions
dependency, the difference is just their reference list
number (i.e. MV number). This is different from the AVC.

The *low delay b mode* refers to a special HEVC mode, in which the
stream just contain I and B frames, without P frames, and all B frames
only have forward direction dependencies (i.e. all inter frames have 2
reference lists but no backward reference in both lists).  This is
similar to AVC I/P mode, but changing the P to the forward dependent
B.

The `low-delay-b` property is now just used to simply convert all P
frames to B frames when driver does not support P frames (so both
reference lists have the same references frames). This is a little
different from the meaning of low delay b mode (the two ref lists may
have the different reference frames). And the driver now can report
whether it supports P frames correctly, so there is no need to use
this property and deprecate it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/284>
2020-07-27 16:32:49 +02:00
He Junyan
f82850c6d3 libs: decoder: H265: Add MAIN_12 profile supporting.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/359>
2020-07-20 16:26:32 +00:00
He Junyan
7d3a19bace video-format: Add P012_LE format.
It can be used as HEVC YUV_4:2:0 12bits stream's decoder output, and
also can be used as the input format for encoding HEVC YUV_4:2:0 12bits
stream.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/359>
2020-07-20 16:26:32 +00:00
He Junyan
b1832223ff libs: profile: The VP9 profiles' name should be just "0,1,2,3"
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/357>
2020-07-12 20:34:31 +08:00
Víctor Manuel Jáquez Leal
2a93455137 vaapidecode: Remove NO_SURFACE error handling
Since surfaces are not bounded to decoding context it makes no sense
to keep the surface semaphore. This patch removes the handling of
this error.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/353>
2020-07-09 18:13:48 +02:00
He Junyan
ac3e8c7c40 libs: decoder: context: remove surfaces binding from context.
The vaCreateContext do not need to specify the surfaces for the
context creation now. So we do not need to bind any surface to the
context anymore. Surfaces should be the resource belong to display
and just be used in encoder/decoder context.

The previous manner has big limitation for decoder. The context's
surface number is decided by dpb size. All the surfaces in dpb will
be attached to a gstbuffer and be pushed to down stream, and the
decoder need to wait down stream free the surface and go on if not
enough surface available. For more and more use cases, this causes
deadlock. For example,

gst-launch-1.0 filesrc location=a.h264 ! h264parse ! vaapih264dec
! x264enc ! filesink location=./output.h264

will cause deadlock and make the whole pipeline hang.
the x264enc encoder need to cache more than dpb size surfaces.

The best solution is seperating the surfaces number and the dpb size.
dpb and dpb size shoule be virtual concepts maintained by the decoder.
And let the surfaces_pool in context maintain the re-use of all surfaces.

For encoder, the situation is better, all the surfaces are just used
as reference frame and no need to be pushed to down stream. We can
just reserve and set the capacity of the surfaces_pool to meet the
request.

Fix: #147
Fix: #88

Co-Author: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/353>
2020-07-09 16:06:23 +00:00
Víctor Manuel Jáquez Leal
b387081a4d libs: decoder: h264, h265: in context at least 16 reference surfaces
Registering only stream's DBP size number of surfaces for decoding VA
surfaces brings issues for certain streams. This change register all
possible number of reference surfaces in a stream, which is 16.

Fixes: #94
2020-07-07 17:47:23 +02:00
He Junyan
0932a450d3 libs: encoder: h265: init tier to GST_VAAPI_TIER_H265_UNKNOWN.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/350>
2020-07-05 14:00:39 +00:00
He Junyan
70800a8319 libs: encoder: h265: fix a bug to get get_profile_tier_level.
0 is a valid value for h265 tier.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/350>
2020-07-05 14:00:39 +00:00
He Junyan
abea5e81c8 libs: encoder: h265: no need to check the high compression tune.
The h265 encoder just support tune mode:
  (0): none             - None
  (3): low-power        - Low power mode
So, no need to check and set the high compression parameters.

And by the way, the current ensure_tuning_high_compression manner
of choosing the hightest profile idc as the best compression profile
is not correct. Unlike h264, in h265 the higher profile idc number
does not mean it has more compression tools, and so it has better
compression performance. It may even be un-compatible with the lower
profile idc. For example, the SCREEN_CONTENT_CODING profile with idc
9 is not compatible with 3D_MAIN profile with idc 8.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/348>
2020-07-03 15:28:40 +00:00
Tim-Philipp Müller
bf7d4bda49 Update plugin docs and add more plugins
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/344>
2020-06-19 15:21:56 +01:00
Michael Olbrich
4b2f7a188d libs: wayland: display: only handle the first output
Right now, all outputs are handled. The means that the registry object for
all but the last are leaked. As a result the sizes are not used correctly.

With two outputs, at first the mode and physical size of the second output
are used. If the first output changes the mode, then the physical size of
the second output is used in combination with the resolution of the first
output. The resulting pixel aspect ratio is incorrect.

There seems to be no way to determine on which output the window is shown,
so just use the first one to get consistent results.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/341>
2020-06-17 14:56:18 +00:00
Víctor Manuel Jáquez Leal
1c5f32b5cd libs: context: use correct printing modifier
GstVaapiID is an alias of gsize, thus its modifier is platform
dependant.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/340>
2020-06-09 21:25:40 +02:00
Mathieu Duponchelle
e6e377c720 plugins: uddate gst_type_mark_as_plugin_api() calls 2020-06-06 00:42:46 +02:00
He Junyan
854fdcb695 libs: encoder: h265: Enable tile in VA command.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/294>
2020-06-05 19:28:20 +08:00
He Junyan
cefd1a665f libs: encoder: h265: Add ensure_tile to calculate tiles.
We need consider tiles and slices together, separate tiles uniformly
and then assign slices uniformly to each tiles.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/294>
2020-06-05 19:28:12 +08:00
He Junyan
32db615685 libs: display: add a quirk for iHD driver tile encoding.
The iHD driver has a requirement that one slice can not span tiles
when tile is enabled, which is not required by hevc spec.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/294>
2020-06-05 19:28:06 +08:00
He Junyan
dbed28d419 libs: encoder: h265: Add tile info to bitstream.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/294>
2020-06-05 19:28:01 +08:00
He Junyan
71db357284 libs: encoder: h265: promote level if tile is enabled.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/294>
2020-06-05 19:27:42 +08:00
He Junyan
812c9fdea7 libs: encoder: h265: Add num-tile-cols/rows properties.
These properties are used for support of tile encoding. We just
support uniform mode of tile encoding, that is, separating picture
equally by (num-tile-cols X num-tile-rows).
According to HEVC spec A1, the max number of tiles in column is 20
and in rows is 22, so add two constant definitions.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/294>
2020-06-05 19:27:36 +08:00
He Junyan
bc1c97c755 libs: encoder: h265: extract slice creation from add_slice_headers
extract slice creation details from add_slice_headers, and let the
add_slice_headers just focuses on calculating slice start address
and CTU number.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/294>
2020-06-05 19:27:26 +08:00
He Junyan
6c76e81cb6 libs: encoder: Add a helper function to check the tile support.
Encoding by tiles separation now is a very common feature for all
relative new codecs, such as HEVC, AV1, and VP9. Just make this
check as a common helper function of the encoder base class.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/294>
2020-06-05 19:27:11 +08:00
He Junyan
85bc355019 libs: decoder: H265: Add SCC_MAIN_444_10 profile support.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/311>
2020-06-05 09:51:19 +00:00
He Junyan
5f92699a4b libs: decoder: update reference list for SCC.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/311>
2020-06-05 09:51:19 +00:00
He Junyan
c956d91807 libs: decoder: H265: Fill picture and slice SCC parameters.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/311>
2020-06-05 09:51:19 +00:00
He Junyan
1d9b2cab42 libs: util: H265: recognize the SCC profiles.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/311>
2020-06-05 09:51:19 +00:00
He Junyan
9067d902e2 libs: profile: Add screen extended main/main10/main444 define.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/311>
2020-06-05 09:51:19 +00:00
He Junyan
8486f82d98 libs: encoder: h265: Add support for MAIN 4:2:2 10 profile.
Using YUY2 as the input of the encoder can generate main 4:2:2 bit
streams and using Y210 as the input of the encoder can generate main
4:2:2 10 bit streams.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/334>
2020-06-05 08:42:35 +00:00
He Junyan
5c67bdaf63 libs: encoder: h265: Use correct index for SubWidthC and SubHeightC.
We need to use the chroma_format_idc as the index for getting the
SubWidthC and SubHeightC values as the spec 6.1(table 6-1) defines.
The wrong SubWidthC or SubHeightC make us calculate a wrong right
or bottom offset for crop size and generate garbage in output.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/334>
2020-06-05 08:42:35 +00:00
He Junyan
a2063083a5 libs: encoder: h265: Fix chrome idc for 444 10 bits
GST_VAAPI_CHROMA_TYPE_YUV444_10BPP should also set chroma_format_idc
to 3 as GST_VAAPI_CHROMA_TYPE_YUV444 does.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/334>
2020-06-05 08:42:35 +00:00
Thibault Saunier
31d85bfb65 Use gst_type_mark_as_plugin_api() for all non-element plugin types 2020-06-03 17:37:48 -04:00
He Junyan
e41c6bd298 libs: delete all gstvaapiobject related files.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/331>
2020-05-27 15:08:28 +08:00
He Junyan
2515d4dd2f libs: surface: return fail immediately if can not create subpicture
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/331>
2020-05-27 15:08:11 +08:00
He Junyan
6333c85316 libs: subpicture: Make subpicture a standard GstMiniObject.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/331>
2020-05-27 15:08:00 +08:00
He Junyan
3df1018b02 libs: decoder: h264: Add ref flags for splited field.
When split one frame into fields, the second field should also
copy the reference flags.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/333>
2020-05-26 07:40:26 +00:00
Víctor Manuel Jáquez Leal
593f6650ef libs: decoder: h264: disallow multiple slice group
As far as we know there are no VAAPI drivers supporting FMO, which
migth be used in baseline streams.

This commit is a continuation of
https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/328

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/332>
2020-05-25 16:01:44 +02:00
Víctor Manuel Jáquez Leal
e68fece3e6 vaapidecoder: h264: remove baseline as constrained property
From now on always the baseline is going to be treated as constrained without
need of setting a property.

Since the property was added along the development cycle (1.17 / commit
866a9f06) and never released, we assume that it is safe to remove it.

Fixes: #252
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/328>
2020-05-21 13:10:57 +02:00
Haihao Xiang
20ce08aa23 vaapiencoder_h264: set direct_spatial_mv_pred_flag to true by default
This flag is set to true by default in both MediaSDK and FFmpeg-vaapi,
so let's align this plugin with other libraries / softwares.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/329>
2020-05-21 13:51:57 +08:00
Víctor Manuel Jáquez Leal
ab475c22d5 libs: use array_unref() rather than array_free()
It is more convinience and thread-safe.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/325>
2020-05-16 20:29:34 +00:00
He Junyan
2b1809e9d3 libs: video-format: add a helper function of get_formats_by_chroma.
The function iterates all supported video formats and returns the
formats belong to the specified chroma type.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/315>
2020-05-16 19:58:15 +00:00
Víctor Manuel Jáquez Leal
5d56ce6927 libs: texture: remove unused headers include
This is continuation of
https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/317

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/324>
2020-05-16 21:05:20 +02:00
Víctor Manuel Jáquez Leal
e20d06e64d libs: removed duplicated function declarations
Some headers had duplicated inlined function declaration. This was
for gtkdoc, but now GStreamer uses hotdoc and the internal library
documentation is not generated. So let's remove these extra lines.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/323>
2020-05-16 20:01:59 +02:00
He Junyan
f20bd8bfd1 libs: texture: Make texture a standard GstMiniObject.
We store GstVaapiTextureGLX and GstVaapiTextureEGL's private data in
the qdata of miniobject and avoid extending the base texture class.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/317>
2020-05-16 19:18:46 +02:00