Commit graph

29 commits

Author SHA1 Message Date
He Junyan e577ca140f va: allocator: Add a helper function to update the image info.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1698>
2020-10-27 14:18:06 +00:00
He Junyan 16ff523575 va: allocator: Decide the allocator's parameters when set_format().
Moving the parameters testing and setting from the allocator_alloc_full()
to the allocator_try(). The allocator_alloc_full() will be called every
time when we need to allocate a new memory. But all these parameters such
as the surface and the image format, rt_format, etc, are unchanged during
the whole allocator lifetime. Just setting them in set_format() is enough.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1698>
2020-10-27 14:18:06 +00:00
Víctor Manuel Jáquez Leal fbbf9c629a va: allocator: add _set_format() and _get_format()
Since allocators keep an available memory queue to reuse, video format and usage
hint are now persistant while allocator's memories are around.

This patch adds _set_format() and _get_format() for both VA allocators.

_set_format() validates if given format can be used or reused. If no allocated
surface previously it creates a dummy one to fetch its offsets and
strides. Updated info is returned to callee.

GstVaPool uses _set_format() at config to verify the allocator capacity and to
get the surfaces offsets and strides, which are going to be used by the video
meta.

Allocator extracted caps are compared with caps from config and if they have
different strides or offsets, force_videometa is set.

A new bufferpool method gst_va_pool_requires_video_meta() is added return the
value of force_videometa. This value is checked in order to know if decoders
need to copy the surface if downstream doesn't announce video meta support.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1667>
2020-10-09 16:34:57 +02:00
Víctor Manuel Jáquez Leal 26ee5b1e4e va: allocator: remove noisy log message
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1667>
2020-10-09 16:34:57 +02:00
Víctor Manuel Jáquez Leal 9254045b3e va: allocator: add a todo for dmabuf_memories_setup()
It would be nice to add a surface pool for this type of surface allocation in
order to have a better control of them.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1667>
2020-10-09 16:34:56 +02:00
Víctor Manuel Jáquez Leal a299dff9d4 va: allocator: add a surface counter
Every time a new surface is created the counter increases by one, and when it is
destroyed (or will be destroyed in case of GstVaAllocator), the counter is
decreased. Then, at allocator dispose, it is warning if the counter is not zero.

This counter will be also used to check if the allocator can change its
configuration if the counter is zero or can not.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1667>
2020-10-09 16:34:56 +02:00
Víctor Manuel Jáquez Leal 30281af83f va: allocator: remove GstVideoInfo from GstVaBufferSurface
Don't store it them anymore since it is related with the negotiated stream and
not the concrete buffer.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1667>
2020-10-09 16:34:56 +02:00
Víctor Manuel Jáquez Leal 67eb0a9440 va: remove GstVideoInfo parameter from _get_surface() functions
There shouldn't be need to retrieve GstVideoInfo per buffer or memory since it
is the same for all the negotiated stream.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1667>
2020-10-09 16:34:56 +02:00
Víctor Manuel Jáquez Leal dcc4557dd6 va: allocator: refactor flush methods for both allocators
Since the logic is the same, it can be generalized in a single common
function.

Also the methods run the common function with a lock and signal the
buffers' conditional.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1626>
2020-10-04 18:42:51 +00:00
Víctor Manuel Jáquez Leal 37fa6df57d va: allocator: refactor GstVaDmabufAllocator
Move code down to group it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1626>
2020-10-04 18:42:51 +00:00
Víctor Manuel Jáquez Leal 9c56c1b3e8 va: allocator: refactor GstVaBuffersurface
Move code up and add namespace to methods, and renaming
_creating_buffer_surface() to the canonical
gst_va_buffer_surface_new()

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1626>
2020-10-04 18:42:51 +00:00
Víctor Manuel Jáquez Leal 734e2a74c4 va: implement pooled allocators
1. Allocators don't implement memory free() methods since all the memories will
   implement dispose() returning FALSE
2. Memory/miniobject dispose() will act as memory release, enqueueing the
   release memory
3. A new allocator's method prepare_buffer() which queries the released memory
   queue and will add the requiered memories to the buffer.
4. Allocators added a GCond to synchronize dispose() and prepare_buffer()
5. A new allocator's method flush() which will free for real the memories.

While the bufferpool will

1. Remove all the memories at reset_buffer()
2. Implement acquire_buffer() calling allocator's prepare_buffer()
3. Implement flush_start() calling allocator's flush()
4. start() is disabled since it pre-allocs buffers but also calls
   our reset_buffer() which will drop the memories and later the
   buffers are ditched, something we don't want. This approach avoids
   buffer pre-allocation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1626>
2020-10-04 18:42:51 +00:00
Víctor Manuel Jáquez Leal d6f9cfc159 va: allocator: user gst_clear_object() for _buffer_surface_unref()
Event if this function is only used by gst_va_dmabuf_memories_setup(), it might
get reused later by GstVaDmabufAllocator's functions. This change makes the
function less fragile.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1626>
2020-10-04 18:42:51 +00:00
Víctor Manuel Jáquez Leal 10b3250175 va: allocator: renamed gst_va_dmabuf_memory_release()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1626>
2020-10-04 18:42:51 +00:00
Víctor Manuel Jáquez Leal 1617dcbe9e va: allocator: renamed available_mems queue
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1626>
2020-10-04 18:42:51 +00:00
Víctor Manuel Jáquez Leal 303b1ea350 va: allocator: rename gst_va_dmabuf_allocator_setup_buffer()
Since it's related with GstVaDmabufAllocator.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1626>
2020-10-04 18:42:51 +00:00
Víctor Manuel Jáquez Leal bb586b227f va: allocator: calculated surface frame internally
Instead of using gst_buffer_get_size() just add the memory sizes reported by
exported fd.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1626>
2020-10-04 18:42:51 +00:00
Víctor Manuel Jáquez Leal 864f0c2ede va: allocator: make GstVaMemory shareable
Renamed the first variable member of GstVaMemory from parent to mem in
order to avoid confusion with GstMemory's parent.

When freeing the structure, memory's parent is check in order to
decide if surfaces has to be destroyed or not, since only the parent
class have to destroy it.

Removed GST_MEMORY_FLAG_NO_SHARE in memory initialization, since it is
deprecated.

Implemented allocator's share virtual method which creates a new
shallow GstVaMemory structure based on the passed one which will be
it's parent.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1626>
2020-10-04 18:42:51 +00:00
Víctor Manuel Jáquez Leal 0b6d8e73ec va: allocator: remove copy method for GstVaMemory
Since the memory has to be shareable. That will be address in the next
commits.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1626>
2020-10-04 18:42:51 +00:00
Víctor Manuel Jáquez Leal 43b950b252 va: allocator: remove va allocator mem_is_span() vmethod
Since it is the default by base class.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1626>
2020-10-04 18:42:51 +00:00
Víctor Manuel Jáquez Leal 117453b947 va: allocator: export composed layer for YUY2 and UYVY
This is a result of an error reported by i965 driver which only can
export composed layer for these formats. This seems to work too with
iHD. These formats are not exposed as native surfaces in Gallium.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1529>
2020-09-23 18:19:22 +02:00
Víctor Manuel Jáquez Leal a4e535d5c1 va: allocator: add gst_va_dmabuf_buffer_setup()
This function will take an array of DMABuf GstMemory and an array of
fd, and create a VASurfaceID with those fds. Later that VASurfaceID is
attached to each DMABuf through GstVaBufferSurface.

In order to free the surface GstVaBufferSurface now have GstVaDisplay
member, and _buffer_surface_unref() were added.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1529>
2020-09-23 18:19:22 +02:00
Víctor Manuel Jáquez Leal 6ac4e79b21 va: allocator: try to get VASurfaceID from every DMABuf allocator
Relax the check of the allocator type, because now the qdata can be
attached for other DMABuf allocators.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1529>
2020-09-23 18:19:22 +02:00
Víctor Manuel Jáquez Leal 20e493981b va: allocator: try to create surface without fourcc but chroma only
There are, in VPP, surfaces that doesn't support 4:2:2 fourccs but it
supports the chroma. So this patch gives that opportunity to the
driver.

This patch also simplifiies
gst_va_video_surface_format_from_image_format() to just an iterator
for surfaces available formats.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1529>
2020-09-23 18:19:22 +02:00
Víctor Manuel Jáquez Leal 482a7d7d7e va: allocator: create surfaces with VASurfaceAttribExternalBuffers
Add a new parameter to _create_surfaces(): a pointer to
VASurfaceAttribExternalBuffers.

If it's defined the memory type is changed to DRM_PRIME, also a new item is
added to the VASurfaceAttrib array with
VASurfaceAttribExternalBufferDescriptor.

Also, the VASurfaceAttrib for pixel format is not mandatory anymore. If fourcc
parameter is 0, is not added in the array, relying on the chroma. This is
useful when creating surfaces for uploading or downloading images.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1529>
2020-09-23 18:19:22 +02:00
Víctor Manuel Jáquez Leal 7c696b67be va: allocator: remove parameter from _create_buffer_surface()
Don't the allocator to _create_buffer_surface() since it's not used.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1516>
2020-08-24 19:35:57 +00:00
Víctor Manuel Jáquez Leal 62dacfd89a va: allocator: support for GST_MAP_VA map flag
This flag will return the VASurface value at mapping
2020-08-03 19:33:01 +02:00
Víctor Manuel Jáquez Leal d3ef3d562a va: allocator: get a surface format from a image format
For the allocator to create surfaces with the correct chroma an
fourcc, it should use a surface format, not necessarily the negotiated
format.

Instead of the previous arbitrary extra formats list, the decoder
extracts the valid pixel formats from the given VA config, and pass
that list to the allocator which stores it (full transfer).

Then, when the allocator allocates a new surface, it looks for a
surface color format chroma-compatible with the negotiated image color
format.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1483>
2020-08-03 15:54:45 +00:00
Víctor Manuel Jáquez Leal 79d11c2022 va: VA-API H.264 decoder and infrastructure
New plugin with an element for H.264 decoding with VA-API. This novel
approach, different from gstreamer-vaapi, uses gstcodecs library for
state handling.

The code is expected to looks cleaner because it uses VA-API without
further layers or wrappers.

* It uses the first supported DRM device as default VA display (other
  displays will be supported through user's GstContext)
* Requires libva >= 1.6
* No multiview/stereo profiles neither interlaced streams because
  gstcodecs doesn't handle them yet
* It is incompatible with gstreamer-vaapi
* Even if memory:VAMemory is exposed, it is not handled yet by any
  other element
* Caps templates are generated dynamically querying VAAPI, but YV12
  and I420 are added for system memory caps because they seem to be
  supported for all the drivers when downloading frames onto main
  memory, as they are used by xvimagesink and others, avoiding color
  conversion.
* Surfaces aren't bounded to context, so they can grow beyond the DBP
  size, allowing smooth reverse playback.
* There isn't yet error handling and recovery.
* 10-bit H.264 streams aren't supported by libva.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1379>
2020-06-28 11:47:35 +02:00