Commit graph

270 commits

Author SHA1 Message Date
Thibault Saunier b7d9115a05 Move files from gst-omx into the "subprojects/gst-omx/" subdir 2021-09-24 16:15:01 -03:00
Guillaume Desmottes 503db0f1af omxvideodec: fix OMX flags on header buffer
The header (SPS/PPS) buffer should have the CODECONFIG flag

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-omx/-/merge_requests/49>
2021-07-09 15:15:12 +02:00
Guillaume Desmottes 006e0636fd omxvideodec: allow to start decoder on HEADER buffer
If the headers are sent in their own buffer
it won't have the SYNC_FRAME flag but we still
do want to start decoding rather than dropping it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-omx/-/merge_requests/49>
2021-07-09 15:13:36 +02:00
Nicolas Dufresne aa99c5387f omxh26xdec: videodecoder support subframe
Use of subframe API from videodecoder base class.
This subframe allows to decode subframe instead of
waiting for a whole frame.
The subframe uses the same frame over the whole
subframe passing process and will wait
for a signal to know the last subframe.
In this implementation it will use
GST_VIDEO_BUFFER_FLAG_MARKER as the
end of batch of subframes.

This implement subframe mode negotation for the Zynq based on caps
negotation. This mode can be combined with low-latency mode, in order to
reach the lowest possible latency (assuming the stream is within the
low-latency constraints for the HW).

... ! video/x-h264,alignment=nal ! omxh264dec ! ...

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-omx/-/merge_requests/49>
2021-07-09 15:13:27 +02:00
Guillaume Desmottes 9192ad0eeb omxvideodec: support interlace-mode=interleaved input
interlace-mode=alternate is a special case of interlace-mode=interleaved
where the fields are split using two different buffers.

The Zynq decoder always produces alternate content and we
used to assume that upstream will set interlace-mode=alternate in its
caps as well.
This is no longer the case as h265parse is now setting
alternate-mode=interleaved on alternate content to not break compat with
elements not supporting alternate.
As a result the decoder now accept both 'interleaved' and 'alternate' on
its input and ensures that its ouput has interlace-mode=alternate.

Needed to fix https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/issues/825

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-omx/-/merge_requests/72>
2020-10-05 12:38:18 +02:00
Guillaume Desmottes d3c2a7c8d1 omxvideoenc: remove unsupported formats from caps template
Our encoder implementation actually supports a small subset of the
formats supported by the decoder. Those are the formats for which we
have a copy path in gst_omx_video_enc_fill_buffer() and which are not
filtered out in filter_supported_formats().
2020-04-10 11:53:23 +02:00
Guillaume Desmottes c2ddd4c710 omxvideodec: add support of alternate interlace mode on zynq 2020-02-27 04:05:48 +00:00
Guillaume Desmottes f14f5d9f70 omxvideo{enc,dec}: use GST_VIDEO_INFO_FIELD_HEIGHT()
Does not change anything for now but will be needed when we'll support
interlace-mode=alternate as the fields will have half the frame height.
2020-02-27 04:05:48 +00:00
Guillaume Desmottes 55ea6d017f omxvideodec: fix dmabuf import
When importing dmabuf, UseBuffer() has to be called with the fd as
pBuffer rather than the mapped address of the buffer.
2019-09-02 09:47:54 +05:30
Guillaume Desmottes a160160419 omxvideodec: log supported caps by the decoder
Can be useful when debugging to check the caps supported by the decoder
before filtering.
2019-08-05 13:43:44 +05:30
Guillaume Desmottes cfeeb15b1e omxvideo: add debug infos to find_nearest_frame()
Those debug infos have proved to be very helpful when debugging
timestamp issues. They are often linked to gst-omx picking the wrong
frame when trying to map from OMX.
2019-06-17 09:17:14 +05:30
Shinya Saito a7ecda85b6 omxvideodec: Deactivate negotiated pool when output own buffer
If decoder outputs internal buffer and not use OMX_UseBuffer,
downstream bufferpool should be stopped.
2019-06-07 10:00:15 +00:00
Guillaume Desmottes 6feac3ed26 omxvideodec: add debug if proposed pool can't provide enough buffers
We were silently ignoring the pool which was pretty confusing when
debugging.
2019-03-26 15:15:21 +01:00
Guillaume Desmottes 9ff4dc533f omxvideo: use GST_VIDEO_CAPS_MAKE() for template caps
Simplify the code and so we advertise the formats actually supported by
gst-omx.
2019-01-25 23:48:11 +00:00
Nicolas Dufresne aff131dcee omxvideodec: Remove duplicated QoS code
The 'finish' function do the exact same check / drop, there is no
need to duplicate this here.
2019-01-25 00:50:06 +00:00
Nicolas Dufresne 4159ca2bc5 omxvideodec: Remove dead code
The omxvideodec base class have a totally unused prepare_frame() vritual
function, remove it.
2019-01-25 00:50:06 +00: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
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 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 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 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 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 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 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 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 f706f3b73b omxvideodec: pass a GstOMXBufferMode to gst_omx_buffer_pool_new()
The output_mode is supposed to be a GstOMXBufferMode, not a boolean.
2018-05-04 13:20:55 +02:00
Guillaume Desmottes e1a149f3d5 omxvideoenc/dec: fix handling of component enabling failing
- Report the error from OMX if any (OMX_EventError)
- If not report the failing to the application (GST_ELEMENT_ERROR)
- return GST_FLOW_ERROR rather than FALSE
- don't leak @frame

https://bugzilla.gnome.org/show_bug.cgi?id=795352
2018-04-18 14:01:39 +02:00
Nicolas Dufresne fb455242e9 omxvideodec: Don't drop the frame on empty payload
This otherwise may lead to "No reference frame found" warning.
2018-03-05 13:50:08 -05:00
Nicolas Dufresne 4bc3b6e567 omxvideodec: Fix CodecState leak 2018-03-05 13:46:56 -05: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 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 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
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 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
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
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