Commit graph

1004 commits

Author SHA1 Message Date
Nicolas Dufresne
4f6d788999 omxvideoenc: Add dynamic framerate support
Instead of going through a full reset, try and change the framerate
config on the encoder when only the framerate have change.
2019-01-25 00:47:45 +00:00
Tim-Philipp Müller
da512c2fdc Release 1.15.1 2019-01-17 02:38:29 +00:00
Varunkumar Allagadapa
09ad21b26c omxvideoenc: Add dynamic IDR insertion support on zynq
As the pi, the zynq has its own API to request keyframe.
2019-01-09 19:37:36 +00: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
Thibault Saunier
f17b12c4f9 Automatic update of common submodule
From ed78bee to 59cb678
2018-12-05 17:24:48 -03:00
Guillaume Desmottes
839fbfebab omx: fix OMX_EventBufferFlag OMX_API_TRACE struct
The GType was missing from the second field of the struct.
2018-11-26 10:41:53 +01:00
Matthew Waters
cc9df86514 Update git locations to gitlab 2018-11-05 05:43:43 +00:00
Guillaume Desmottes
6207459e0e omx: rename OMX_PERFORMANCE debug cat to OMX_API_TRACE
This debug category can now be used to track more OMX calls and events
so best to rename it to something more generic.

https://bugzilla.gnome.org/show_bug.cgi?id=797171
2018-09-26 09:20:41 +02:00
Guillaume Desmottes
3a16094ab3 omx: log OMX commands with OMX_PERFORMANCE debug category
It has been useful to have a clear raw and structured view of the gst
<-> OMX exchanges when debugging.

https://bugzilla.gnome.org/show_bug.cgi?id=797171
2018-09-19 10:52:25 +02:00
Guillaume Desmottes
68f18341f6 omx: factor out gst_omx_component_send_command()
No semantic change. I'm going to add extra debug in this function.

https://bugzilla.gnome.org/show_bug.cgi?id=797171
2018-09-19 10:52:25 +02:00
Guillaume Desmottes
9b1598e5ec omx: log OMX events with OMX_PERFORMANCE debug category
It has been useful to have a clear raw and structured view of the gst
<-> OMX exchanges when debugging.

https://bugzilla.gnome.org/show_bug.cgi?id=797171
2018-09-19 10:52:25 +02:00
Guillaume Desmottes
313deb4ecf omx: rename log_omx_performance() to log_omx_performance_buffer()
I'm about to log more things under this category

https://bugzilla.gnome.org/show_bug.cgi?id=797171
2018-09-19 10:52:25 +02:00
Nicolas Dufresne
a84badc5c4 omxvideoenc: Remove spurious locking
The method we call in the context of pushing a buffer are all thread
safe. Holding a lock would prevent input buffers from being queued while
pushing.

https://bugzilla.gnome.org/show_bug.cgi?id=715192
2018-09-10 17:09:11 -04:00
Nicolas Dufresne
d80504afcc omxvideoenc: Remove unneeded size check
We only enter this branch if nFilledLen > 0, there is not need
to check again.

https://bugzilla.gnome.org/show_bug.cgi?id=715192
2018-09-10 17:09:11 -04:00
Nicolas Dufresne
35abdd16d1 omxvideodec: Remove spurious unlock in error case
This was forgotton in previous patch. We no long hold the lock when goto
invalid_buffer is called.

https://bugzilla.gnome.org/show_bug.cgi?id=715192
2018-09-10 17:09:11 -04:00
Nicolas Dufresne
04e1f76b60 omxvideodec: don't hold the stream lock when trying to push a frame
The base class methods will lock this properly when needed, there seems
to be no need to lock it explicitly.

This allows the patch in gstvideodec for unlocking the stream lock
when pushing buffers out to work.

https://bugzilla.gnome.org/show_bug.cgi?id=715192
2018-08-31 17:42:07 -04:00
Guillaume Desmottes
f108eeafde omxvideodec: don't import OMX buffers from downstream
We already have code configuring the encoder stride and slice height
when receiving the first buffer from upstream.
We don't have an equivalent when the encoder is exporting its buffers to the
decoder.

There is no point adding it and making the code even more
complex as we wouldn't gain anything by exporting from the encoder to
the decoder. The dynamic buffer mode already ensures 0-copy between OMX
components.

https://bugzilla.gnome.org/show_bug.cgi?id=796918
2018-08-30 10:59:30 +02: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
34bc02e397 omx: allow gst_omx_port_acquire_buffer() to not wait for buffers
Will be needed to implement GST_BUFFER_POOL_ACQUIRE_FLAG_DONTWAIT.

https://bugzilla.gnome.org/show_bug.cgi?id=796918
2018-08-30 10:59:30 +02:00
Guillaume Desmottes
c89b54fe78 omxvideodec: don't import non-dmabuf when dec is in dmabuf mode
Fix 'omxh264dec ! videocrop' pipeline.

https://bugzilla.gnome.org/show_bug.cgi?id=796918
2018-08-30 10:59:30 +02:00
Guillaume Desmottes
be5ec66a84 omxvideodec: factor out gst_omx_try_importing_buffer()
No semantic change, just make the code clearer and improve debug output.

https://bugzilla.gnome.org/show_bug.cgi?id=796918
2018-08-30 10:59:30 +02:00
Guillaume Desmottes
7d8a314dff omxvideodec: fix gst_video_info_from_caps() caps assertion
The "use buffers" code path uses gst_video_info_from_caps() which is
asserting if caps is NULL (because pool was rejected).

https://bugzilla.gnome.org/show_bug.cgi?id=796918
2018-08-30 10:59:30 +02:00
Guillaume Desmottes
9ed1c2e75e omxvideodec: fix pool caps reference stealing
gst_buffer_pool_config_get_params() doesn't ref the returning caps;
so gst_caps_replace() was unreffing the reference owned by the pool.

https://bugzilla.gnome.org/show_bug.cgi?id=796918
2018-08-30 10:59:30 +02:00
Guillaume Desmottes
0996019c07 omxvideodec: prevent timeout when shutting down because of pending out buffers
The OMX transition state to Loaded won't be complete until all buffers
have been freed. There is no point waiting, and timeout, if we know that
output buffers haven't been freed yet.

The typical scenario is output buffers being still used downstream
and being freed later when released back to the pool.

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
8efa0951ff turn GstOMXComponent to a GstMiniObject
Will use it for refcounting.

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
d2f7e21ab9 omx: call gst_omx_buffer_unmap() when handling BUFFER_DONE
When using a input buffer pool, the buffer may be released to the pool when
gst_omx_buffer_unmap() is called. We need to have buf->used unset at
this point as the pool may use it to check the status of the pool.

{Empty,Fill}BufferDone is called from OMX internal threads while
messages are handled from gst elements' thread. Best to do all this
when handling the message so we don't mess with OMX threads and keep
the original thread/logic split.

https://bugzilla.gnome.org/show_bug.cgi?id=796918
2018-08-30 10:59:30 +02:00
Guillaume Desmottes
3b92b22554 omxvideo{enc,dec}: stop calling shutdown() in change_state
This is no longer needed since we implemented close() vfuncs as the
encoder/decoder base class already take care of calling close() (which
is calling shutdown()) in its own change_state implementation.

We also move the shut down of the component from PAUSED_TO_READY to READY_TO_NULL.
By doing so upstream will have already deactivated the pool from the
encoder and so won't be preventing the OMX state change as the buffers
will all be released.

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
092788a968 omxvideoenc: factor out gst_omx_video_enc_set_to_idle()
No semantic change. We'll have to use this when the input pool is
activated so we can allocate buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=796918
2018-08-30 10:59:30 +02:00
Guillaume Desmottes
7d3b0cd1e8 omxvideoenc: factor out gst_omx_video_enc_deallocate_in_buffers()
Will add extra code when adding input buffer pool.

https://bugzilla.gnome.org/show_bug.cgi?id=796918
2018-08-30 10:59:30 +02:00
Guillaume Desmottes
998bfbb906 omx: add pBuffer to OMX_PERFORMANCE logs
Can be useful to check the fd being passed when using dmabuf.

https://bugzilla.gnome.org/show_bug.cgi?id=796918
2018-08-30 10:59:30 +02:00
Guillaume Desmottes
f0964dfbdb omx: factor out gst_omx_port_set_dmabuf()
No semantic change. I also made the debug message a bit clearer.

https://bugzilla.gnome.org/show_bug.cgi?id=796918
2018-08-30 10:59:30 +02:00
Guillaume Desmottes
40ae47df5e omx: wait for flush complete and buffers being released when flushing
When flusing we should wait for OMX to send the flush command complete event
AND all ports being released.
We were stopping as soon as one of those condition was met.

Fix a race between FillThisBufferDone/EmptyBufferDone and the flush
EventCmdComplete messages. The OMX implementation is supposed to release
its buffers before posting the EventCmdComplete event but the ordering
isn't guaranteed as the FillThisBufferDone/EmptyBufferDone and
EventHandler callbacks can be called from different threads (cf 2.7
'Thread Safety' in the spec).

Only wait for buffers currently used by OMX as some buffers may not be
in the pending queue because they are held downstream.

https://bugzilla.gnome.org/show_bug.cgi?id=789475
2018-08-29 12:18:39 -04:00
Guillaume Desmottes
3d55051da3 omx: factor out should_wait_until_flushed()
No semantic change. Makes the code easier to understand and I'm about to
change the waiting condition.

https://bugzilla.gnome.org/show_bug.cgi?id=789475
2018-08-29 12:18:39 -04:00
Guillaume Desmottes
626a481e01 omxvideoenc: pause component when flushing
As stated in the spec ("6.1.3 Seek Event Sequence") we should pause
before flushing.
We were pausing the decoder but not the encoder so I just aligned the
two code paths.

https://bugzilla.gnome.org/show_bug.cgi?id=797038
2018-08-28 15:52:14 +02:00
Guillaume Desmottes
a863893842 omxvideoenc: fix vertical padding in NV16 formats
My previous patch to calculate the vertical padding was always halfing
the height of the chroma plane which is incorrect for NV16 formats.

https://bugzilla.gnome.org/show_bug.cgi?id=796749
2018-07-13 09:54:48 +02:00
Guillaume Desmottes
1e9d7a6a23 omxvideoenc: include vertical padding in nFilledLen when copying
According to the OMX spec (3.1.3.7.1) nFilledLen is meant to include any
padding. We use to include the horizontal one (stride) but not the
vertical one if nSliceHeight is bigger than the actual height.

The calculated nFilledLen was wrong as it didn't include the padding
between planes.

https://bugzilla.gnome.org/show_bug.cgi?id=796749
2018-07-05 16:08:03 +02:00
Guillaume Desmottes
c8969b0dbe omxvideoenc: implement decide_allocation
Increase the number of output buffers by the number of buffers requested
downstream.
Prevent buffers starvation if downstream is going to use dynamic buffer
mode on its input.

https://bugzilla.gnome.org/show_bug.cgi?id=795746
2018-06-08 09:53:01 +02:00
Guillaume Desmottes
431eac07bf omxvideodec: implement propose_allocation
Tell upstream about how many buffer we plan to use so they can adjust
their own number of buffers accordingly if needed.

Same logic as the existing gst_omx_video_enc_propose_allocation().

https://bugzilla.gnome.org/show_bug.cgi?id=795746
2018-06-08 09:53:01 +02:00
Guillaume Desmottes
84483f3d7a omxvideoenc: always signal drain cond when stopping streaming loop
Similar change as the one I just did in omxvideodec.

https://bugzilla.gnome.org/show_bug.cgi?id=796207
2018-06-08 09:47:32 +02:00
Guillaume Desmottes
fd108f4278 omxvideodec: always signal drain cond when stopping streaming loop
If for some reason something goes wrong and we stop the streaming loop
we may end up with other threads still waiting on the drain cond.
No more buffers will be produced by the component so they were waiting
forever.

Fix this by always signalling this cond when stopping the streaming
loop.

https://bugzilla.gnome.org/show_bug.cgi?id=796207
2018-06-08 09:47:32 +02:00
Guillaume Desmottes
798bbc9acf omxvideoenc: factor out gst_omx_video_enc_pause_loop()
No semantic change. I'm going to use it in more failure cases.

https://bugzilla.gnome.org/show_bug.cgi?id=796207
2018-06-08 09:47:32 +02:00
Guillaume Desmottes
2b48338d68 zynqultrascaleplus: enable 'ensure-buffer-count-actual' hack
https://bugzilla.gnome.org/show_bug.cgi?id=791211
2018-06-08 09:44:49 +02:00
Guillaume Desmottes
9a8e863862 omxvideodec/enc: add hack updating nBufferCountActual before allocating
The OMX specs states that the nBufferCountActual of a port has to default
to its nBufferCountMin. If we don't change nBufferCountActual we purely rely
on this default. But in some cases, OMX may change nBufferCountMin before we
allocate buffers. Like for example when configuring the input ports with the
actual format, it may decrease the number of minimal buffers required.
This method checks this and update nBufferCountActual if needed so we'll use
less buffers than the worst case in such scenarios.

SetParameter() needs to be called when the port is either disabled or
the component in the Loaded state.

Don't do this for the decoder output as
gst_omx_video_dec_allocate_output_buffers() already check
nBufferCountMin when computing the number of output buffers.

On some platform, like rpi, the default nBufferCountActual is much
higher than nBufferCountMin so only enable this using a specific gst-omx
hack.

https://bugzilla.gnome.org/show_bug.cgi?id=791211
2018-06-08 09:44:49 +02:00
Guillaume Desmottes
338ff34e5e omxvidee{enc,dec}: refresh input port definition after setting format
Setting the input format and the associated encoder/decoder settings
may also affect the nBufferCountMin of the input port.
Refresh the input port so we'll use up to date values in propose/decide
allocation.

https://bugzilla.gnome.org/show_bug.cgi?id=796445
2018-06-08 09:38:57 +02:00
Guillaume Desmottes
3498f81d1f omx: always consider component in 'invalid' state when an error occured
gst_omx_component_get_state() used to early return if there was no
pending state change. So if the component raised an error it wasn't
considered in the invalid state until the next requested state change.

Fix this by checking first if we received an error.

https://bugzilla.gnome.org/show_bug.cgi?id=795874
2018-06-08 09:36:56 +02:00
Matthew Waters
ebcadd9984 meson: Update option names to omit 'with_omx' prefixes
Companion commit to:
https://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=4fb02fc85b70be631f5331b2547e5dc61ef7a43a
https://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=1e1a5d658e4a031535c44823fd398d3052ca2000
etc...
2018-05-25 01:35:58 +10:00