Commit graph

215 commits

Author SHA1 Message Date
Guillaume Desmottes 76267ec55d omx: log the number of pending buffers when port is EOS 2019-09-04 10:41:46 +00:00
Guillaume Desmottes a7ef71dc80 omx: log when an output port is eos 2019-09-04 10:41:46 +00:00
George Kiagiadakis fbe0d07068 gstomx: remove gst_omx_buffer_set_omx_buf/get_omx_buf
They are no longer used anywhere
2019-04-25 09:09:42 +05:30
Julien Isorce 18927f33ee Fixes build with omx >= 1.2.0
gstomx.c:1405:10: error: ‘OMX_IndexParamCustomContentPipe’ undeclared (first use in this function)
    case OMX_IndexParamCustomContentPipe

Some enums have been deprecated in 1.2.0

https://gitlab.freedesktop.org/gstreamer/gst-omx/issues/27
2019-04-16 12:26:03 -07:00
Guillaume Desmottes 7d1b77b0c4 omx: disable OMX_API_TRACE code if gst debug is disabled
No need to create debug structs which won't be used as DEBUG macros are
no-op.
2019-03-26 15:15:21 +01:00
Guillaume Desmottes 01bf661d6e omx: log Get/SetParameter/Config calls
Extend OMX_API_TRACE by logging component configuration calls.
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 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
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
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 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 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 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 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 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 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 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
Guillaume Desmottes 021b66878a log_omx_performance: convert pointers to strings
G_TYPE_POINTER are not serialized in logs.

https://bugzilla.gnome.org/show_bug.cgi?id=794331
2018-04-06 13:39:42 +02:00
Nicolas Dufresne 32660fd294 omx: Free empty buffers list in use_dynamic_buffers
To indicate we are doing dynamic buffers importation, we pass
a list of NULL pointers, but we forgot to free that list.
2018-03-05 13:50:08 -05:00
Nicolas Dufresne 5eed1a7eb2 Revert "omx: wait for flush complete and buffers being released when flushing"
This reverts commit 4211e4c29a.
2018-03-02 11:06:08 -05:00
Guillaume Desmottes 2ca3cf5cfa omxvideodec: add hack to pass color format from caps to OMX decoder
This hack tries to pass as much information as possible from caps to the
decoder before it receives any buffer. These information can be used by
the OMX decoder to, for example, pre-allocate its internal buffers
before starting to decode and so reduce its initial latency.

This mechanism is currently supported by the zynqultrascaleplus decoder.

https://bugzilla.gnome.org/show_bug.cgi?id=792040
2018-01-30 09:23:59 +00:00
Guillaume Desmottes 0f702d0503 log failing OMX calls as errors
I find it confusing when debugging that OMX calls returning an error
where not logged as GST_LEVEL_ERROR making them harder to spot.
Fix this by introducing simple log macros checking the return value of
the OMX call and logging failures as errors.

https://bugzilla.gnome.org/show_bug.cgi?id=791069
2018-01-29 17:47:56 +00:00
Guillaume Desmottes 65cc312aa8 add OMX_PERFORMANCE debug category
Can be used to log buffers exchange between OMX and gst-omx to profile
performances of the OMX component.
Ideally this should be done using tracer hooks but it's currently not
possible to define custom hooks outside of core.

Use GST_DEBUG="OMX_PERFORMANCE:8" to enable it.
See also
https://github.com/gdesmott/gst-log-parser/blob/master/src/bin/omx-perf.rs
as a simple program consuming those logs to generate gnuplot files and
stats.

https://bugzilla.gnome.org/show_bug.cgi?id=791093
2018-01-29 17:16:35 +00:00
Guillaume Desmottes 9f87b987ef omxvideoenc: implement dmabuf import on zynqultrascaleplus
The Zynq UltraScale+ encoder implements a custom OMX extension to
directly import dmabuf saving the need of mapping input buffers.

This can be use with either 'v4l2src io-mode=dmabuf' or an OMX video
decoder upstream.

https://bugzilla.gnome.org/show_bug.cgi?id=792361
2018-01-29 15:21:02 +00:00
Guillaume Desmottes da07a647b8 omx: add API to implement dynamic buffers support
OMX 1.2.0 introduced a third way to manage buffers by allowing
components to only allocate buffers header during their initialization
and change their pBuffer pointer at runtime.
This new feature can save us a copy between GStreamer and OMX for each
input buffer.

This patch adds API to allocate and use such buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=787093
2017-12-14 09:00:02 +00:00
Guillaume Desmottes 4211e4c29a omx: wait for flush complete and buffers being released when flushing
As stated in the existing comment, 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).

https://bugzilla.gnome.org/show_bug.cgi?id=789475
2017-11-28 13:35:07 -05:00
Guillaume Desmottes 4c0a8a6d90 gst_omx_port_set_flushing: simplify waiting loop
No semantic change so far, I just made the 'while' end condition easier
to understand as a first step before changing it.
- move error/time out checks inside the loop to make it clearer on what
we are actually waiting for.
- group port->buffers checks together with parenthesis as they are part
of the same conceptual check: waiting for all buffers to be released.

https://bugzilla.gnome.org/show_bug.cgi?id=789475
2017-11-28 13:35:07 -05:00
Guillaume Desmottes 6d44c0add5 omx: fix build on rpi
The nTimeStamp field is a OMX_TICKS struct on the rpi so use the proper
macro to set it.
Fix build on the build which has been broken by
b3173144b7

https://bugzilla.gnome.org/show_bug.cgi?id=789052
2017-10-19 16:23:01 +02:00
Guillaume Desmottes b3173144b7 omx: also reset nTimeStamp when re-using buffers
Some OMX implementations may check if the timestamp of the output buffers
they receive is actually not set.

https://bugzilla.gnome.org/show_bug.cgi?id=788711
2017-10-11 13:51:55 -04:00
Guillaume Desmottes 514699594d omx: factor out gst_omx_buffer_reset()
https://bugzilla.gnome.org/show_bug.cgi?id=788711
2017-10-11 13:51:55 -04:00
Guillaume Desmottes 3a0e4bc35d add gst_omx_buffer_flags_to_string()
Make debug logs more readable so users don't have to manually figure out
the meaning of flags.

https://bugzilla.gnome.org/show_bug.cgi?id=788767
2017-10-11 13:49:30 -04:00
Guillaume Desmottes 5751001ddc omxh265dec: add H265 decoder
Add HEVC decoder for the zynqultrascaleplus platform.

I used the H264 decoder code as a template.

https://bugzilla.gnome.org/show_bug.cgi?id=785434
2017-09-06 14:50:18 -04:00
Guillaume Desmottes cf9f1903db omxh265enc: add H265 encoder
The OMX spec doesn't support HEVC but the OMX stack of the
zynqultrascaleplus adds it as a custom extension.
It uses the same API as the one of Android's OMX stack.

I used the H264 encoder code as a template.

https://bugzilla.gnome.org/show_bug.cgi?id=785434
2017-09-06 14:50:18 -04:00
Guillaume Desmottes 318ef5b357 omx: display states as string if changing failed
Improve the error message by displaying the states in their string
representation rather than their numerical value.

https://bugzilla.gnome.org/show_bug.cgi?id=787235
2017-09-04 08:46:07 +01:00
Guillaume Desmottes 7a0949b750 omx: also reset nFilledLen before calling OMX_FillThisBuffer()
The spec states that the buffer passed to OMX_FillThisBuffer() needs to be
empty. Some implementation may check it actually is by checking its
nFilledLen field, so best to reset it as well.

https://bugzilla.gnome.org/show_bug.cgi?id=785623
2017-08-01 11:26:11 -04:00
Satya Prakash Gupta 5e6c3f170f omx: Possible Memory leak in gst_caps_from_string
https://bugzilla.gnome.org/show_bug.cgi?id=784978
2017-07-17 16:46:29 +03:00
Julien Isorce e60ac7e1c0 omx: do not always print an error if OMX_{UseBuffer,EGLImage} fails
Let the caller decide to print an error. Because it can be part of
a normal trial path.

https://bugzilla.gnome.org/show_bug.cgi?id=784069
2017-07-12 16:26:36 +01:00
Julien Isorce 02d493e859 omx: add gstomxmp3enc
Initial support and only tested with the software based
encoder OMX.Aratelia.audio_encoder.mp3 from Tizonia which
internally uses libmp3lame.

https://bugzilla.gnome.org/show_bug.cgi?id=782988
2017-07-12 14:29:44 +01:00
Guillaume Desmottes 0aa4c9db4e h264dec: add hack to pass profile and level to OMX
This information can be useful to zynqultrascaleplus decoders. They may
use this information to reduce startup latency by configuring itself
before receiving the first frames.

We also have a custom OMX extension allowing the decoder to report the
latency. The profile/level information helps it reporting a more
accurate latency earlier.

https://bugzilla.gnome.org/show_bug.cgi?id=783114
2017-07-11 11:57:50 -04:00
Gurkirpal Singh 065878a5d4 omx: always ignore OMX_ErrorPortUnpopulated
It is safe to ignore it always. Tizonia notifies this error to pass
some khronos conformance tests. Problem is that gst-omx saves this
error in comp->last_error and then gst_omx_port_set_enabled early
error out which fails the pipeline.

https://bugzilla.gnome.org/show_bug.cgi?id=782800
2017-07-05 17:27:27 -04:00
Gurkirpal Singh fc1a8229b0 omx: guard some omx enums with IL version
Some enums that existed in 1.1.2 just do not exit in 1.2.0
See https://www.khronos.org/registry/OpenMAX-IL/specs/OpenMAX_IL_1_2_0_Specification_redline.pdf

https://bugzilla.gnome.org/show_bug.cgi?id=782800
2017-07-05 17:27:27 -04:00
Julien Isorce 1c8f069e42 omx: allow 0 feature
Previously the omx plugin was blacklisted if GST_OMX_CONFIG_DIR
points to an invalid path or if the gstomx.conf contains 0 valid
component.
Problem is that once the plugin is blacklisted, a rescan is not
triggered upon changes of the env var or the gstomx.conf file
despite being setup with gst_plugin_add_dependency.

This also makes it more consistent with other plugins that auto
generate features. For example gst-{ffmeg,libav}, gstreamer-vaapi,
v4l2 video dec.

To clarify the diff, the plugin_init func will return TRUE even if
g_key_file_get_groups returns 0 element and even if
g_key_file_load_from_dirs fails.

https://bugzilla.gnome.org/show_bug.cgi?id=782867
2017-05-21 15:40:11 +01:00