Commit graph

3697 commits

Author SHA1 Message Date
Michael Olbrich
07aadb82fb libs: display: always call close_display()
All close_display() have their own checks for use_foreign_display and only
destroy locally created objects in that case.
Without this objects other than the actuall foreign display itself are
leaked.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/342>
2020-07-31 11:14:43 +02:00
He Junyan
5902e5bfdb video-format: Add the missing P012_LE into GST_VAAPI_FORMATS_ALL.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/373>
2020-07-31 08:38:10 +00: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
6ab488475a libs: decoder: fix a crash issue when get_surface_formats.
Some context does not report any valid format that we can support.
For example, the HEVC 444 12 bits decoder context, all the formats
it reports is not supported now, which make the formats list a NULL
array. We should check that pointer before we use it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/372>
2020-07-31 15:27:38 +08:00
He Junyan
7a9a99d0c4 libs: encoder: h265: choose the profile based on allowed list.
We can decide the profile in ensure_profile(), based on allowed list
passed by the encode. We also need to check whether the entrypoint is
available. Once it is decided, no need to check the hw entrypoint
them again.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/349>
2020-07-30 18:51:51 +08: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
65c8718f5e libs: display: Add a helper function to get profiles by codec.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/349>
2020-07-30 17:46:24 +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
He Junyan
579aa4cab1 libs: encoder: h265: No need to check hw_max_profile.
In h265, higher profile idc number does not mean better compression
performance and may be not compatible with the lower profile idc.
So, it is not suitable to find the heighest idc for hw to ensure the
compatibility.

On the other side, when the entrypoint of the selected profile is valid,
it means the hw really support this profile, no need to check it again.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/349>
2020-07-30 17:41:53 +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
7acc3c4db8 libs: profile: h265: Fix return value of from_codec_data_h265.
profile_from_codec_data_h265() returns wrong GstVaapiProfile for h265.
The codec data of caps contain the profile IDC, but the mapping between
profile IDC and GstVaapiProfile is wrong.

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
He Junyan
ed55dd8df1 libs: utils: vpx: Add utils vpx to handle VP8/9 misc things.
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
6022d97edf libs: display, context: handle broken jpeg decoder for i965 driver
JPEG decoding in i965 driver is pretty much broken, and the driver is
deprecated which mean authors only accept trivial fixes.

Surfaces for JPEG decoder context in i965 only handle IMC3[1] color
format which is not a common format in GStreamer. It can export it to
I420 at mapping raw bytes, but DMABuf exporting is problematic.

This patch artificially adds NV12 to the context format list when it's
JPEG decoder for i965 and force the usage of old VA-API for surface
creation without specifying color format. Also it artificially
disables the DMABuf announcement.

1. https://docs.microsoft.com/en-us/windows/win32/medfound/recommended-8-bit-yuv-formats-for-video-rendering#420-formats-16-bits-per-pixel

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/369>
2020-07-29 12:06:32 +02:00
Víctor Manuel Jáquez Leal
83d48837d2 libs: context: change function to internal code style
Instead of a getter the function `get_preferred_format()` to
`ensure_preferred_format()` which aligns to the code style.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/369>
2020-07-29 12:02:50 +02: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
525abc6d1e build: request libdrm >= 2.4.98 and fallback
Fixes: #270
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/367>
2020-07-28 12:55:27 +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
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
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
Víctor Manuel Jáquez Leal
e962069dbe vaapidecode: merge common profiles before setting size range
The synthetic profiles, such as H264 baseline, H265 intra, etc. are
added at the end of processing all available VA profiles. This
generated an non-optimal caps for negotiation, since the synthetic
profiles don't have frame size ranges.

This patch adds those possible synthetic profiles when the associated
profile is processed, with its frame size ranges.

Now allowed sink caps are simpler.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/363>
2020-07-23 19:29:19 +02:00
He Junyan
2da3314534 plugin: util: Add the missing DMA buffer input in template caps.
We pass the wrong parameter to gst_vaapi_build_caps_from_formats()
and lose the DMA feature in caps.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/362>
2020-07-21 22:07:49 +08: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
26afaab523 plugin: decode: correct ensure_allowed_sinkpad_caps's caps.
The decode allowed caps returned by ensure_allowed_sinkpad_caps()
contains all profiles of the whole VAAPI, like:
  image/jpeg, width=(int)[ 0, 1638 4 ], height=(int)[ 0, 16384 ];
  video/mpeg, mpegversion=(int)2, profile=(string){ simple, main },
  width=(int)[ 0, 2048 ], height=(int)[ 0, 2048 ]; video/x-h264,
  profile=(string){ main, high, constrained-baseline }, width=(int)[ 0,
  4096 ], height=(int)[ 0, 4096 ]; video/x-h264, profile=(string){
  constrained-high, progressive-high, baseline }; video/x-h265,
  profile=(string){ main, main-intra }, width=(int)[ 0, 8192 ],
  height=(int)[ 0, 8192 ]; video/x-vp8, width=(int)[ 0, 4096 ],
  height=(int)[ 0, 4096 ]; video/x-wmv, wmvversion=(int)3,
  format=(string)WVC1, profile=(string)advanced, width=(int)[ 0, 3840 ],
  height=(int)[ 0, 3840 ]; video/x-wmv, wmvversion=(int)3,
  profile=(string){ simple, main }, width=(int)[ 0, 3840 ],
  height=(int)[ 0, 3840 ]

Which is verbose and may have latent problems. It should only contains
the profiles belong to its codec type. For example, h265 should only
return:
  video/x-h265, profile=(string){ main, main-intra },
  width=(int)[ 0, 8192 ], height=(int)[ 0, 8192 ]

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/361>
2020-07-17 12:09:32 +08:00
Víctor Manuel Jáquez Leal
f1c44411f3 vaapidecodebin: don't force NV12 since P010_10LE is now possible
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/360>
2020-07-13 11:23:36 +02: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