Commit graph

18 commits

Author SHA1 Message Date
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