Commit graph

175 commits

Author SHA1 Message Date
He Junyan
805ff6346a va: vpp: Fix features lost in transform_caps().
When we transform the caps from the sink to src, or vice versa, the
"caps" passed to us may only contain parts of the features. Which
makes our vpp lose some feature in caps and get a negotiation error.
The correct way should be:
Cleaning the format and resolution of that caps, but adding all VA,
DMA features to it, making it a full feature caps. Then, clipping it
with the pad template.

fixes: #1551

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2081>
2021-03-17 10:25:11 +01:00
Víctor Manuel Jáquez Leal
191b6cf5d4 va: postproc: synchronize segment with stream time
This is required to use dynamic controllable parameters.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2082>
2021-03-16 06:30:06 +00:00
Víctor Manuel Jáquez Leal
c74b230579 va: postproc: only drop filters if they change
Currently, at every frame the filters array is recreated. This is not
optimal, since it should be only rebuilt if the VA filter's related
properties change. This patches does that by using a flag.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2078>
2021-03-15 06:10:27 +00:00
Víctor Manuel Jáquez Leal
0b2848fc32 va: postproc: update passthrough and reconfigure pads
Added helper function _update_passthrough() which will define and set
the pass-through mode of the filter, and it'll either reconfigure both
pads or it will just mark the src pad for renegotiation or nothing at
all.

There are cases where both pads have to be reconfigured (direction
changed, for example), other when just src pad has to (filters
updated) or none (changing to ready state).

The requirement of renegotiation depends on the need to enable/disable
its VA buffer pools.

This patch sets pass-through mode by default, so the buffer pools
aren't allocated if no filtering/direction operations are defined,
which is the correct behavior.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2074>
2021-03-12 12:34:46 +01:00
Víctor Manuel Jáquez Leal
f823124a39 va: postproc: mention the possibility of color balance
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2050>
2021-03-02 15:33:54 +00:00
Víctor Manuel Jáquez Leal
c191a1a5da va: vp8dec, vp9dec: only set NV12 color format for documentation
Mention in documentation only the most used output format in VA-API.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2050>
2021-03-02 15:33:54 +00:00
He Junyan
f7eb93e22b va: vpp: fix a wrong caps logic in vpp_transform_caps().
The current gst_va_vpp_transform_caps return such as:
  video/x-raw(memory:VAMemory), width=(int)[ 16, 16384 ], height=(int)[ 16, 16384 ],
  interlace-mode=(string)progressive, format=(string){ NV12, I420, YV12, YUY2, RGBA,
  BGRA, P010_10LE, ARGB, ABGR, VUYA }; video/x-raw(memory:DMABuf), width=(int)[ 16,
  16384 ], height=(int)[ 16, 16384 ], interlace-mode=(string)progressive, format=(string)
  { NV12, I420, YV12, YUY2, RGBA, BGRA, P010_10LE, ARGB, ABGR, VUYA }; video/x-raw,
  width=(int)[ 16, 16384 ], height=(int)[ 16, 16384 ], interlace-mode=(string)progressive,
  format=(string){ VUYA, GRAY8, NV12, NV21, YUY2, UYVY, YV12, I420, P010_10LE };
  video/x-raw(memory:VAMemory), width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ],
  interlace-mode=(string)progressive; video/x-raw(memory:DMABuf), width=(int)[ 1, 2147483647 ],
  height=(int)[ 1, 2147483647 ], interlace-mode=(string)progressive; video/x-raw, width=(int)
  [ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], interlace-mode=(string)progressive

Which is not correct. It mixes the template caps and the input query caps together.
The correct way should be: clip the template caps with the input caps(remove format
and rangify size). The correct answer should be:
  video/x-raw(memory:VAMemory), width=(int)[ 16, 16384 ], height=(int)[ 16, 16384 ], interlace
  -mode=(string)progressive, format=(string){ NV12, I420, YV12, YUY2, RGBA, BGRA, P010_10LE,
  ARGB, ABGR, VUYA }; video/x-raw(memory:DMABuf), width=(int)[ 16, 16384 ], height=(int)[ 16,
  16384 ], interlace-mode=(string)progressive, format=(string){ NV12, I420, YV12, YUY2, RGBA,
  BGRA, P010_10LE, ARGB, ABGR, VUYA }; video/x-raw, width=(int)[ 16, 16384 ], height=(int)[ 16,
  16384 ], interlace-mode=(string)progressive, format=(string){ VUYA, GRAY8, NV12, NV21, YUY2,
  UYVY, YV12, I420, P010_10LE }

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2045>
2021-03-01 16:43:29 +00:00
Víctor Manuel Jáquez Leal
a9211a5067 va: allocator: No need of fourcc to create surface.
In commits 430aa327 and a119a940 there are a regression since it is
possible to create surfaces without fourcc, only chroma (rtformat) is
required.

This regression is shown on radeonsi driver with certain color
formats.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2035>
2021-02-25 12:05:19 +00:00
Víctor Manuel Jáquez Leal
87fe2e321e va: vpp: implement GstColorBalance interface
And modify multiple-vpp example to use it with -r parameter.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2033>
2021-02-25 11:22:53 +00:00
Víctor Manuel Jáquez Leal
5b117045e0 va: filter: add controllable and mutable playing to GParamFlags
Add controllable and mutable playgin to common GParamFlags.

Also use this common flags to video-direction

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2033>
2021-02-25 11:22:53 +00:00
He Junyan
e15be4cf0f VA: Add the vaav1dec element as the av1 decoder.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1636>
2021-02-23 13:53:43 +08:00
He Junyan
a119a940e4 VA: Add the aux surface for gst buffer used by decoder.
The AV1 codec needs to support the film grain feature. When the film
grain feature is enabled, we need two surfaces as the output of the
decoded picture, one without film grain effect and the other one with
it. The first one acts as the reference and is needed for later pictures'
reconstruction, and the second one is the real display output.
So we need to attach another aux surface to the gst buffer/mem and make
that aux surface as the target of vaBeginPicture.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1636>
2021-02-23 13:52:50 +08:00
He Junyan
e40e78a793 VA: Add a helper function of decoder_add_slice_buffer_with_n_params.
Some codecs such as AV1 needs several parameters associated with one
slice. It may have multi tiles within one slice and each tile needs
its description parameter.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1636>
2021-02-23 13:51:00 +08:00
He Junyan
430aa327a8 va: allocator: replace assert with error log in va alloc.
We should print error log rather than assert when the forcc or
the rt_format of va allocator is unrecognized.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1636>
2021-02-23 13:47:29 +08:00
Víctor Manuel Jáquez Leal
2696a2795d va: filter, vpp: process colorimetry
A new filter method were added: gst_va_filter_set_formats(). In this
way the input & output GstVideoInfo are processed only once per stream
negotiation, and not per frame.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2023>
2021-02-20 17:03:43 +00:00
Víctor Manuel Jáquez Leal
d4682fa136 va: filter: check if filter is open on set_orientation()
Because the method requires pipeline_caps is filled.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2023>
2021-02-20 17:03:43 +00:00
Víctor Manuel Jáquez Leal
812973fb6b va: filter: human readable background color
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2023>
2021-02-20 17:03:43 +00:00
Víctor Manuel Jáquez Leal
c6c71c0c0c va: filter: fail immediately if vaBeginPicture() fails
There's no need to try vaRenderPicture() if vaBeginPicture() failed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2023>
2021-02-20 17:03:43 +00:00
Víctor Manuel Jáquez Leal
b7988b4de8 va: filter: destroy pipeline buffer after destroying filters
In 6ae24948 the pipeline buffer destroy were removing assuming it
wasn't required. Nonetheless, debugging the code it looks like a
buffer leak in iHD driver since the ID of the buffer kept increasing.

The difference now is that first the filter buffers are destroy first
and later the pipeline buffer.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2023>
2021-02-20 17:03:43 +00:00
He Junyan
2e9a096282 va: vpp: Add raw buffer copy when needed.
Just like the decoder, the vapostproc also needs to copy the output
buffer to raw buffer if downstream elements only supports raw caps
and does not support the video meta.

The pipeline like:
  gst-launch-1.0 filesrc location=xxxx ! h264parse ! vah264dec ! \
  vapostproc ! capsfilter caps=video/x-raw,width=55,height=128 ! \
  filesink location=xxx
needs this logic to dump the data correctly.

fixes: #1523

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2026>
2021-02-19 23:12:29 +08:00
Víctor Manuel Jáquez Leal
7a47a7b4c4 va: allocator: set workaround only for i965 driver
In commit 117453b9 a i965 driver workaround was added for all drivers, because
at that time we didn't have a driver implementation API.

Now there's one. This patch set the workaround only for the i965 driver.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2021>
2021-02-17 12:51:05 +00:00
Víctor Manuel Jáquez Leal
3be9a1baa0 va: allocator: MT-safe queue & dequeue dmabuf-based memories
One problem that va dmabuf allocator had is when preparing a buffer from
dmabuf memories in the allocator pool, specially when a buffer is composed by
several memories. This memories have to be by certain number and in certain
order.

This patch stores the number of memories and their address in order when a
dmabuf-based buffer is created and when preparing a buffer, it is reconstructed
with this info.

Finally, instead of pushing the memories as soon as they are unrefed, they are
hold until GstVaBufferSurface's ref_mems_count reaches zero (all the memories
related with that buffer/surface are unrefed). Until that happen, all the
memories are pushed back into the queue, locked, assuring that all the memories
related with a single buffer (with the same surface) remain contiguous, so the
buffer reconstruction is assured.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2013>
2021-02-17 09:10:37 +01:00
Víctor Manuel Jáquez Leal
21ce99b209 va: pool, allocator: free memories at bufferpool's stop()
This patch frees the memories in the allocator's pool after the bufferpool frees
all its buffers, sync'ing them at stop() vmethod.

By doing it, the current logic in flush_start() is not valid, so the vmethod is removed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2013>
2021-02-17 09:10:37 +01:00
Víctor Manuel Jáquez Leal
0ec17904e1 va: allocator: remove unused public functions
Deleted the public functions:

gst_va_dmabuf_allocator_wait_for_memory()
gst_va_allocator_wait_for_memory()

And all the support for wait, cond in allocator's pool.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2013>
2021-02-17 09:10:37 +01:00
Víctor Manuel Jáquez Leal
1ee9b202a6 va: pool: simplify the logic
Instead of removing memories from buffers at reset_buffer()/release_buffer() the
bufferpool operation is kept as originally designed, still the allocator pool is
used too. Thus, this patch restores the buffer size configuration while removing
release_buffer(), reset_buffer() and acquire_buffer() vmethods overloads.

Then, when the bufferpool base class decides to discard a buffer, the VA
surface-based memory is returned to the allocator pool when its last reference
is freed, and later reused if a new buffer is allocated again.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2013>
2021-02-17 09:10:37 +01:00
Víctor Manuel Jáquez Leal
8deec238cb va: pool: use allocator pool at alloc()
Check if the allocator pool has memories available before creating a
new one, but only iif pool is not starting.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2013>
2021-02-17 09:10:37 +01:00
Víctor Manuel Jáquez Leal
800a49e8de va: allocator: log buffer at dmabuf setup and prepare
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2013>
2021-02-17 09:10:37 +01:00
Seungha Yang
b00b1654f3 vah265dec: Don't need to pass picture structure to VA
This code came from gstvaapidecoder_h265 implementation
but picture structure is always GST_VAAPI_PICTURE_STRUCTURE_FRAME.
Moreover, in theory, VA doesn't need to know picture structure for
decoding HEVC stream.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2008>
2021-02-09 16:19:41 +00:00
He Junyan
188e01ca44 va: vpp: Make the global lock only to DMA buffer's import.
The normal gst_va_buffer_get_surface does not need a global lock.
Too big lock may make the performance lower.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2009>
2021-02-09 15:07:19 +08:00
Víctor Manuel Jáquez Leal
03847b65ca va: allocator: log dmabuf and surface at pool push or pop
In order to keep track of the dmabuf fds and surfaces numbers log messages are
added at memory_release() (queue push) and prepare_buffer() (queue pop).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1999>
2021-02-05 21:25:20 +01:00
Víctor Manuel Jáquez Leal
64cca0f791 va: h265dec: fix HVC1 stream format name
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1999>
2021-02-05 21:25:20 +01:00
Víctor Manuel Jáquez Leal
43cb1b5dcf va: basedec: refactor context query
Context query is handled either by source and sink queries. This patch
factors-out its handling in a common utility function.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1999>
2021-02-05 21:25:20 +01:00
Víctor Manuel Jáquez Leal
532b20cf05 va: filter: use a common GParamFlags definition
Instead of repeating the same code along gst_va_filter_install_properties()

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1999>
2021-02-05 21:24:02 +01:00
Víctor Manuel Jáquez Leal
5e78c4bafc va: h264dec: remove spurious if validation
The first if checks for caps, thus else doesn't need to recheck for the
opposite.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1999>
2021-02-05 21:24:02 +01:00
Víctor Manuel Jáquez Leal
688ade3cfc va: vpp: fix frame copy
There were two problems with frame copy:

1. The input video info are from the format color, not form the allocated VA
surface, it's needed to update the sink video info according with the
allocator's data.

2. The parameters of `gst_video_frame_copy()` were backwards.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2007>
2021-02-05 18:54:25 +01:00
Víctor Manuel Jáquez Leal
bcbe620006 va: vpp: request video and alignment metas for src pool
This is for the pool used when importing raw video frames to surfaces.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2007>
2021-02-05 18:54:25 +01:00
Víctor Manuel Jáquez Leal
f7aafa74ab va: vpp: transform_size() must return FALSE
transform_size() basetransform vmethod is used when there's no output buffer
pool and allocates a system memory buffer. With VA this cannot be allowed, since
it needs VASurfaces to process.

Thus transform_size() is not required, but to play safe let's return FALSE.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2007>
2021-02-05 18:54:25 +01:00
Víctor Manuel Jáquez Leal
47a808a4b3 va: vpp: copy input buffer flags and timestamps
Strictly speaking right now it's not required do this copy, but let's play safe
and assume in the future this metadata might be required while doing the
postprocessing.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2007>
2021-02-05 18:54:25 +01:00
Víctor Manuel Jáquez Leal
4c7218d7ae va: vpp: handle context query
Previously vapostproc didn't communicate its context through query mechanism,
which is required for context sharing. This patch completes this missing bits.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2007>
2021-02-05 18:52:56 +01:00
Víctor Manuel Jáquez Leal
da363a20fe va: vpp: don't copy color, size or orientation video metas
If they are processed by the element.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2007>
2021-02-05 18:52:56 +01:00
Víctor Manuel Jáquez Leal
a29b56008a va: vpp: don't break passthrough if no color balance required
The function `_add_filter_cb_buffer()` returned TRUE if no color balance filter
are required, but that's is wrong, since it will break the passthrough. This
patch return FALSE which is the correct value for the situation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2007>
2021-02-05 18:52:56 +01:00
Víctor Manuel Jáquez Leal
b6e8741c29 va: vpp: use gst_clear_caps()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2007>
2021-02-05 18:52:23 +01:00
Víctor Manuel Jáquez Leal
6ae2494887 va: filter: don't destroy pipeline buffer
This was only required by i915 driver before libva-2.0 because it didn't
conform.

Also changes the way _destroy_filters() is called, now inside a locked block, so
it must not lock in it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2006>
2021-02-05 16:54:07 +01:00
Víctor Manuel Jáquez Leal
599e16fde8 va: filter: lock member variables access
While gst_va_filter_open() and gst_va_filter_close() remain non-thread-safe, the
other API calls that modify member variables are locked.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2005>
2021-02-04 11:12:37 +01:00
Haihao Xiang
956d6e8ff7 va: sort the device queue
If so, the elements will be registered per drm node in order of
renderD128, renderD129, ... etc, an element with constant name will be
registered on renderD128 on a hardware with multiple drm nodes.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1988>
2021-02-02 10:28:04 +08:00
Víctor Manuel Jáquez Leal
8a8688c639 va: filter: fix assignation to proper variable
Fix the result of a wrong copy&paste

Fixes: #1501
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1976>
2021-01-22 09:38:27 +01:00
He Junyan
0158849145 va: Fix some gst_object_unref error because the pointer is NULL.
!1957 introduces some error of gst_object_unref for NULL pointer.
Fixes all of them.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1959>
2021-01-17 14:00:50 +08:00
He Junyan
82c0f90197 va: Make the caps pointer operation atomic in vadecoder.
The vadecoder's srcpad_caps and sinkpad_caps pointers are outside of the
mutex protection. Just make all operation for them atomic.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1957>
2021-01-15 20:40:21 +08:00
He Junyan
6b1e1924fd va: Fix a latent race condition in vabasedec.
The vabasedec's display and decoder are created/destroyed between
the gst_va_base_dec_open/close pair. All the data and event handling
functions are between this pair and so the accessing to these pointers
are safe. But the query function can be called anytime. So we need to:
1. Make these pointers operation in open/close and query atomic.
2. Hold an extra ref during query function to avoid it destroyed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1957>
2021-01-15 20:40:10 +08:00
Seungha Yang
98eebf3322 va: allocator: Fix deadlock caused by double lock
Trivial bug fix for deadlock

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1949>
2021-01-12 21:28:04 +09:00