Commit graph

690 commits

Author SHA1 Message Date
Guillaume Desmottes
13a43757f5 meson: simplify OMX extensions detection
We are now always checking which files are present or not, even when using our
internal copy of OMX, rather than hardcoding the ones present in it.

https://bugzilla.gnome.org/show_bug.cgi?id=792043
2018-01-30 11:54:37 +00:00
Nicolas Dufresne
f0469c99d2 Revert "meson: use include_directories() with external OMX headers path"
This reverts commit 9d37a92a61.
2018-01-30 11:54:24 +00:00
Guillaume Desmottes
8bd2b1f550 omxh265enc: add some encoding properties
constrained-intra-prediction and loop-filter-mode.
Those map standard OMX settings.

https://bugzilla.gnome.org/show_bug.cgi?id=792528
2018-01-30 11:51:10 +00:00
Guillaume Desmottes
74376fea2d omxh264enc: add some encoding properties
entropy-mode, constrained-intra-prediction and loop-filter-mode.
Those map standard OMX settings.

https://bugzilla.gnome.org/show_bug.cgi?id=792528
2018-01-30 11:51:10 +00:00
Guillaume Desmottes
e3396210d2 omxvideoenc: add zynqultrascaleplus specific properties
https://bugzilla.gnome.org/show_bug.cgi?id=792528
2018-01-30 11:51:10 +00:00
Guillaume Desmottes
d14b9ffa64 omxvideoenc: document unit of target-bitrate property
nTargetBitrate and nEncodeBitrate are defined in bits per second in the
OMX spec.

https://bugzilla.gnome.org/show_bug.cgi?id=792528
2018-01-30 11:51:10 +00:00
Guillaume Desmottes
52de8eaca0 omxvideodec: add internal-entropy-buffers property on zynqultrascaleplus
Custom property to control the number of internal buffers used in the
decoder to smooth out entropy decoding performance.

https://bugzilla.gnome.org/show_bug.cgi?id=792528
2018-01-30 11:51:10 +00:00
Guillaume Desmottes
9d37a92a61 meson: use include_directories() with external OMX headers path
It seems cleaner to use the proper meson tools to include this path
rather than manually tweak the build flags.

This also allows us to simplify the OMX extensions detection code. We
are now always checking which files are present, even when using our
internal copy of OMX, rather than hardcoding the ones present in it.

https://bugzilla.gnome.org/show_bug.cgi?id=792043
2018-01-30 11:10:38 +00:00
Guillaume Desmottes
6c57d06ee1 omxvideoenc: expose chroma format and bit depth in output caps
As we added in the parser (bgo#792039) expose the chroma and bit
depth information in output caps.

https://bugzilla.gnome.org/show_bug.cgi?id=792040
2018-01-30 09:23:59 +00:00
Guillaume Desmottes
1990580d79 omxvideoenc: factor out get_output_caps()
No semantic change so far.

https://bugzilla.gnome.org/show_bug.cgi?id=792040
2018-01-30 09:23:59 +00: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
0c5bbbb6ca omxvideoenc: drop late input frames if QoS is enabled
Make use of the new GstVideoEncoder QoS API to drop late input frames. This may
help a live pipeline to catch up if it's being late and all frames end up
being dropped at the sink.

https://bugzilla.gnome.org/show_bug.cgi?id=792783
2018-01-22 17:04:27 +00:00
Guillaume Desmottes
5fa96cab7b omxvideoenc: early return in fill_buffer() if something goes wrong
If something goes wrong while trying to manually copy the input buffer,
the 'break' was moving us out of the 'for' loop but not out of the switch block.
So we ended up calling gst_video_frame_unmap() a second time (raising
assertions) and returning TRUE rather than FALSE.

Reproduced with a WIP zynqultrascaleplus OMX branch reporting wrong
buffer sizes and so triggering this bug.

https://bugzilla.gnome.org/show_bug.cgi?id=792167
2018-01-07 14:20:56 +00:00
Julien Isorce
6810878193 omxvideodec: ignore very little variations of the framerate
If less than 1%.

The dynamic format change should not happen when the
resolution does not change and when only the framerate
changes but very slightly, i.e. from 50000/1677=29.81
to 89/3=29.66 so a "percentage change" of less than 1%
(i.e. 100*(29.81-29.66)/29.66 = 0.50 < 1 ). In that case
just ignore it to avoid unnecessary renegotiation.

https://bugzilla.gnome.org/show_bug.cgi?id=759043
2017-12-14 09:20:49 +00:00
Guillaume Desmottes
7048134fa9 omxvideodec: use dynamic buffer mode on input if possible
Prevent from copying the input buffers between GStreamer and OMX.

Tested on zynqultrascaleplus and rpi (without dynamic buffers).

https://bugzilla.gnome.org/show_bug.cgi?id=787093
2017-12-14 09:00:35 +00:00
Guillaume Desmottes
533ee7fadc omxvideoenc: use dynamic buffer mode on input if possible
If the OMX component supports dynamic buffer mode and the input buffers
are properly aligned avoid copying each input frame between OMX and
GStreamer.

Tested on zynqultrascaleplus and rpi (without dynamic buffers).

https://bugzilla.gnome.org/show_bug.cgi?id=787093
2017-12-14 09:00:31 +00:00
Guillaume Desmottes
e55675b7ce omxvideoenc/dec: factor out input buffer allocation
No semantic change so far. I'm going to add an alternate way to allocate
input buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=787093
2017-12-14 09:00:27 +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
Julien Isorce
6600a520a5 omxvideodec: consolidate the decision to try UseBuffer
The tee element can call gst_query_add_allocation_pool with pool as NULL.
Checking nth > 0 is not enough so we need to verify if there is a pool.

https://bugzilla.gnome.org/show_bug.cgi?id=730758
https://bugzilla.gnome.org/show_bug.cgi?id=784069
2017-12-13 12:14:48 +00:00
Julien Isorce
0d2d695eff gstomxvideodec: fix framerate overflow
Some live streams can set the framerate to 50000/1677 (=29.81).

GstVideoInfo.fps_n << 16 is wrong if the fps_n is 50000
(i.e. greater than 32767).

https://bugzilla.gnome.org/show_bug.cgi?id=759043
2017-12-13 10:12:05 +00:00
Guillaume Desmottes
56654cced5 omxvideodec: retrieve OMX_IndexParamVideoPortFormat before setting it
The usual pattern when setting OMX params is to first get the struct
param, override the values we want to set and then set the updated
param.
We were not doing this with OMX_IndexParamVideoPortFormat and so were
resetting some fields such as OMX_VIDEO_PARAM_PORTFORMATTYPE.xFramerate

https://bugzilla.gnome.org/show_bug.cgi?id=790979
2017-11-29 12:41:37 -05:00
Julien Isorce
6364463918 omxaacenc: also set 'profile' if mpegversion is 4
Like done by gst_codec_utils_aac_caps_set_level_and_profile
which is called by avenc_aac, ffaac and voaacenc.

https://bugzilla.gnome.org/show_bug.cgi?id=735208
2017-11-29 16:13:24 +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
a4c18ff243 zynqultrascaleplus: add support for extra AVC levels
The Zynqultrascaleplus has support for extra AVC levels not defined in
the OMX spec as a customer extension.

https://bugzilla.gnome.org/show_bug.cgi?id=790758
2017-11-23 11:39:33 -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
62b96b6e14 omxvideodec: remove redundant debug message
We have already a debug message right after.

https://bugzilla.gnome.org/show_bug.cgi?id=789058
2017-10-19 16:20:10 +02:00
Guillaume Desmottes
2da61ef2bf omxh265: fix enum casting when using Allegro HEVC extensions
Allegro's HEVC implementation defines a superset of the profiles and
enums from the Android implementation.
Properly cast to fix -Wenum-conversion warnings from clang.

https://bugzilla.gnome.org/show_bug.cgi?id=789057
2017-10-19 16:19:16 +02:00
Guillaume Desmottes
cc0e3c8320 properly cast extension enums
OMX's allow 3rds party to define extensions using their own enums
(like OMX_VIDEO_CODINGEXTTYPE) and to be used as the general
ones (like OMX_VIDEO_CODINGTYPE).
Properly cast those to fix -Wenum-conversion warnings from some
compilers such as clang.

https://bugzilla.gnome.org/show_bug.cgi?id=789057
2017-10-19 16:19:16 +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
Ponnam Srinivas
8556596862 h263enc: fix caps leak in error code path
https://bugzilla.gnome.org/show_bug.cgi?id=788245
2017-09-28 13:24:07 +03:00
Ponnam Srinivas
1f36637434 omxh264enc: fix caps leak
https://bugzilla.gnome.org/show_bug.cgi?id=787711
2017-09-22 11:53:01 +03:00
Ponnam Srinivas
27cd61a21a omxh265enc: fix caps leak
https://bugzilla.gnome.org/show_bug.cgi?id=787714
2017-09-21 20:48:50 -04:00
Guillaume Desmottes
1bc6976b7b omxvideodec: log info about frame before releasing it
gst_video_decoder_release_frame() takes ownership of the frame and will
destroy it. So we should no longer use it after calling it.

https://bugzilla.gnome.org/show_bug.cgi?id=787628
2017-09-14 17:39:06 +01: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
79df3b0e8e omxvideoenc: use caps from query in propose_allocation
Prevent crash by not deferencing a NULL pointer if self->input_state
isn't defined when propose_allocation() is called.

https://bugzilla.gnome.org/show_bug.cgi?id=786442
2017-09-06 09:15:31 -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
Julien Isorce
054d5da46e omxvideodec: EGLDisplay is not indirectly defined by gstgl headers inclusion
Just use gpointer as done in GstGL to not include
EGL/egl.h just for EGLDisplay.

https://bugzilla.gnome.org/show_bug.cgi?id=784779
2017-08-22 10:29:05 +01:00
Julien Isorce
bb3778a1ac omxvideodec: remove wrong SettingsChanged ack
Partially revert 1b7d0b8:
  omxvideodec: handle IL 1.2 behavior for OMX_SetParameter

It turned out it was a problem in the decoder which was
not updating some local variables upon SetParameter.

https://bugzilla.gnome.org/show_bug.cgi?id=783976
2017-08-17 14:08:24 +01:00
Julien Isorce
eec88a9651 omx{audio,video}{dec,enc}: sequentially disable ports because buffers are not shared
For the history, the parallel disable port has been introduced by:
"00be69f omxvideodec: Disable output port when setting a new format"
and then replicated to videoenc, audiodec and audioenc.

This is only required to do 'parallel' if buffers are shared between ports.
But for decoders and encoders the input and output buffer are of different
nature by definition (bitstream vs images). So they cannot be shared.

Also starting from IL 1.2.0 it is written in the spec that the parallel
disable is not allowed and will return an error. Except when buffers are
shared.

Again here we know in advance that they are not shared so let's always
do a sequential disable.

Tested on Desktop, rpi and zynqultrascaleplus.

https://bugzilla.gnome.org/show_bug.cgi?id=786348
2017-08-17 14:01:27 +01:00
Guillaume Desmottes
6d2082003a omxvideodec: use the decoder API to set latency
https://bugzilla.gnome.org/show_bug.cgi?id=785125
2017-08-10 13:58:31 -04:00
Guillaume Desmottes
f2b0b66e39 omxvideoenc/dec: declare latency on zynqultrascaleplus
The OMX specification doesn't provide any API to expose the latency
introduced by encoders and decoders. We implemented this as a custom
extension as declaring the latency is needed for live pipelines like
video conferencing.

https://bugzilla.gnome.org/show_bug.cgi?id=785125
2017-08-09 17:01:15 -04:00
Guillaume Desmottes
0ee8213ab2 omxvideoenc: adjust stride and slice height from input
Use the stride and slice height information from the first buffer meta
data to adjust the settings of the input port.
This will ensure that the OMX input buffers match the GStreamer ones
and so will save us from having to copy line-by-line each one.

This is also the first step to allow the OMX encoder to receive dmabuf.

Tested on rpi and zynqultrascaleplus.

https://bugzilla.gnome.org/show_bug.cgi?id=785967
2017-08-08 10:40:47 -04:00
Guillaume Desmottes
07e80c9425 omxvideoenc: delay buffer configuration until component is enabled
No significant change for now. Just delay the input port configuration
of the buffer size related fields (stride, slice height, buffer size)
until the component is activated.
This will allow us to use the actual stride/height of the first input
and so avoid the buffer copying code path in most cases.

Tested on rpi and zynqultrascaleplus.

https://bugzilla.gnome.org/show_bug.cgi?id=785967
2017-08-08 10:40:47 -04:00