Commit graph

22 commits

Author SHA1 Message Date
Guillaume Desmottes 7cd929bc87 omxbufferpool: fix dmabuf import
When importing dmabuf from downstream, we want the allocator to be in
OTHER_POOL mode despite output_mode being DMABUF.
So check first if other_pool is set before checking for pool's
output_mode.
2019-09-02 09:47:51 +05:30
George Kiagiadakis 783e58fc48 omxbufferpool: refactor to allow memory sharing
One big restriction of the OMX buffer pool has always been
that the GstMemory objects were flagged with NO_SHARE.
This was because the buffer pool needed to be sure that when
a buffer returned to the pool, it would be safe to release the
OMX buffer back to OpenMAX.

With this change, this is no longer a restriction. What this
commit introduces is a new allocator that allows us to track
the GstMemory objects independently. Now, when a buffer returns
to the pool, it is not necessary for the memory to be released
as well. We simply track the memory's ref count in the allocator
and we return the OMX buffer back when the memory's ref count
drops to 0.

The reason for doing this is to allow implementing zero-copy
transfers in situations where we may need to copy or map a
certain region of the buffer. For instance, omxh264enc ! h264parse
should be possible to be zero-copy by using an OMX buffer pool
between them.
2019-04-25 09:09:40 +05:30
Guillaume Desmottes 3018ea5843 omxbufferpool: fix memory mapping with offset
gst_memory_map() is already adding the offset to the mapped pointer.
Doing it in the memory implementation was resulting in the offset being
accounted twice.

It doesn't matter yet as we are only creating memory without offset for
now but it will once we'll start sharing OMX memories.
2019-04-23 15:32:05 +05:30
Guillaume Desmottes b53c91d9ef omxbufferpool: don't use CAT_PERFORMANCE if pool will copy
This was the single place where this category was used in gst-omx so
most users, including me, are generally not turning it and were missing this
important information from logs.

The copying code uses gst_video_frame_copy() which is already logging
with CAT_PERFORMANCE so we can still have this information when using
only this debug category.
2019-03-26 15:15:21 +01:00
Guillaume Desmottes 9dc359d0c1 omxbufferpool: fix race when releasing input buffers
If buffers were released from the pool while
gst_omx_video_enc_handle_frame() was waiting for new buffers,
gst_omx_port_acquire_buffer() was never awaken as the buffers weren't
released through OMX's messaging system.

GQueue isn't thread safe so also protect it with the lock mutex.
2019-01-08 16:04:31 +01:00
Guillaume Desmottes 3828d9769c omxbufferpool: fix early input buffer release
We used to track the 'allocating' status on the pool. It is used while
allocating so output buffers aren't passed right away to OMX and input
ones are not re-added to the pending queue.

This was causing a bug when exporting buffers to v4l2src. On start
v4l2src acquires a buffer, read its stride and release it right away.
As no buffer was received by the encoder element at this point, 'allocating'
was still on TRUE and so the the buffer wasn't put back to the pending
queue and, as result, no longer available to the pool.

Fix this by checking the active status of the pool instead of manually
tracking it down. The pool is considered as active at the very end of
the activation process so we're good when buffers are released during
the activation.
2018-12-21 17:16:31 +01:00
Guillaume Desmottes 7be54ad091 omxvideoenc: implement dmabuf export on input buffers
Propose pool upstream so input buffers can be allocated by the port and
exported as dmabuf.

The actual OMX buffers are allocated when the pool is activated, so we
don't end up doing useless allocations if the pool isn't used.

https://bugzilla.gnome.org/show_bug.cgi?id=796918
2018-08-30 10:59:30 +02:00
Guillaume Desmottes 86a6703d91 omxbufferpool: reference the OMX component
Now that the pool is responsible of freeing the OMX buffers, we need to
ensure that the OMX component stay alive while the pool is as we rely on
the component to free the buffers.
The GstOMXPort is owned by the component so no need to ref this one.

https://bugzilla.gnome.org/show_bug.cgi?id=796918
2018-08-30 10:59:30 +02:00
Guillaume Desmottes 7b6be347a6 omxbufferpool: deallocate OMX buffers when stopping
The pool is stopped when all the buffers have been released. Deallocate
when stopping so we are sure that the buffers aren't still used by
another element.

https://bugzilla.gnome.org/show_bug.cgi?id=796918
2018-08-30 10:59:30 +02:00
Guillaume Desmottes 457e1b9a5e omx: factor out gst_omx_buffer_get/set_omx_buf()
Move the qdata code to helper functions as I'm going to need them in
omxvideoenc to implement dmabuf export.

https://bugzilla.gnome.org/show_bug.cgi?id=796918
2018-08-30 10:59:30 +02:00
Guillaume Desmottes ea2df994f3 add support for NV12_10LE32 and NV16_10LE32 on zynqultrascaleplus
The encoder and decoder on zynqultrascaleplus support these new 10 bits
format.

https://bugzilla.gnome.org/show_bug.cgi?id=793694
2018-02-28 08:32:26 -05:00
Guillaume Desmottes 412df8c74f omxbufferpool: add PERFORMANCE DEBUG message when copying output frames
I spent quiet some time figuring out why performance of my pipeline were
terrible. Turned out it was because of output frames being copied
because of stride/offset mismatch.

Add a PERFORMANCE DEBUG message to make it easier to spot and debug from logs.

https://bugzilla.gnome.org/show_bug.cgi?id=793637
2018-02-21 11:22:05 +00:00
Guillaume Desmottes 136714c6ed omxvideodec: add dmabuf support for output
The zynqultrascaleplus OMX implementation has a custom extension
allowing decoders to output dmabuf and so avoid buffers copy between OMX
and GStreamer.

Make use of this extension when built on the zynqultrascaleplus. The
buffer pool code should be re-usable for other platforms as well.

https://bugzilla.gnome.org/show_bug.cgi?id=784847
2017-07-18 23:46:46 +01:00
Sebastian Dröge 4593f434a0 omxbufferpool: Copy buffers if the stride does not match and we can't use video meta
https://bugzilla.gnome.org/show_bug.cgi?id=731672
2014-06-24 15:11:53 +02:00
Sebastian Dröge af38fe7dce omxbufferpool: Fix format string compiler warning 2014-06-24 13:02:13 +02:00
Michal Lazo 326e15ca85 omxbufferpool: Initialize debug category 2014-06-24 13:01:48 +02:00
Sebastian Dröge 03c54e7c0f omxbufferpool: Properly convert OMX alignment to GStreamer alignment
GStreamer uses a bitmask for the alignment while OMX uses the
alignment itself. Let's convert.

https://bugzilla.gnome.org/show_bug.cgi?id=710564
2014-06-24 12:42:22 +02:00
Aurélien Zanelli 1b6879921c omxvideodec: add support of more color format
Add support for ABGR, ARGB, RGB16, BGR16, YUY2, UYVY, YVYU, GRAY8 and
NV16 color format.
2014-04-15 15:09:24 +01:00
Aurélien Zanelli 6834d2e0b3 omxbufferpool: make video stride and offset calculation easier
It will be easier to support more color format.
2014-04-15 15:09:23 +01:00
Josep Torra 100e9f998d omxbufferpool: return buffers to the pool instead of freeing them
We have to return the buffers back to the pool in when stopping to
not mess with the GstBufferPool accounting.
The OMX buffers will be freed when those won't be in charge of the
pool in the chained up call to 'stop'.
Fixes segfaults on finalize and pool not being properly deactivated.

https://bugzilla.gnome.org/show_bug.cgi?id=726337
2014-03-24 18:20:51 +00:00
Julien Isorce e8ca74c6f8 omxbufferpool: fix memory leak if used on output port
When using GstOMXBufferPool on an output port, it internally uses
a GPtrArray to manage the GstBuffers instead of the default queue
from the GstBufferPool base class.

In this case GstBufferPool::default_free_buffer is not called when
the pool is stopped. Because the queue is empty. So explicitely
call gst_omx_buffer_pool_free_buffer on each buffer contained in
the GPtrArray.

https://bugzilla.gnome.org/show_bug.cgi?id=726337
2014-03-17 18:02:51 +00:00
Christian König 325c90f99d omxvideodec: separate the buffer pool from the decoder
https://bugzilla.gnome.org/show_bug.cgi?id=726025
2014-03-12 12:42:03 +01:00