Commit graph

9 commits

Author SHA1 Message Date
He Junyan
21f4c31a52 va: bufferpool: use release_buffer to clean the mem.
The current bufferpool wastes all pre-allocate buffers when the
buffer pool is actived.
The pool->priv->size is 0 for va buffer pool. And every time, the
reset_buffer() will clean all mem and make the buffer size 0, that
can cache the gst_buffer in the buffer pool.
But when the buffer pool is activing, the default_start() just
allocate the buffer and release_buffer() immediately, all the pre
allocated buffers and surfaces are destroyed because of
gst_buffer_get_size (buffer) != pool->priv->size.
We need to use release_buffer() to do the clean job at the pool
start time.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1686>
2020-10-15 12:02:29 +08: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
6a8fa67f42 va: pool: call parent's start() method
Without preallocating buffers and memories a deadlock in pool allocator is
highly probably since it might hit the case were buffer is returned to the pool
but their memories are still hold by a copy downstream, without other
preallocated buffers available.

This kind of a hack, where buffer_reset() follow the normal path if it's called
from start().

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
8f936baffe va: pool: fix log's object
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
e73b866fe0 va: pool: ignore size in config
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
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
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
f306b1e0fe va: pool: use gst_object_replace() for allocator
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
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