Commit graph

247 commits

Author SHA1 Message Date
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
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
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
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
0603e442ce omxvideodec/enc: delay allocation after the allocation query
Allocating OMX components buffers in set_format() is too early.
Doing it when receiving the first buffers will allow the element to use
the information from the allocation query and/or the first incoming
buffer to pick to best allocation mode.

Tested on raspberry pi with dynamic resolution changes on decoder and
encoder input.

https://bugzilla.gnome.org/show_bug.cgi?id=785967
2017-08-08 10:40:47 -04:00
Guillaume Desmottes
7916bd53ab omxvideodec: earlier return if downstream_flow_ret is not OK
There is no point to (re)start the src thread if, for example, we are
flushing.

https://bugzilla.gnome.org/show_bug.cgi?id=785967
2017-08-08 10:40:47 -04:00
Guillaume Desmottes
352184dd09 omxvideodec: factor out enable and disable code
No semantic change, just factor out the code enabling and disabling the
component to their own functions.

Makes the code easier to read as the set_format() method was already
pretty big. Will also allow us to easily change the enabling logic.

https://bugzilla.gnome.org/show_bug.cgi?id=785967
2017-08-08 10:40:47 -04:00
Julien Isorce
86d9a2c81c omxvideodec: make generic the OMX_UseEGLImage code path
Will be easier to maintain and to make enhancements.

Tested with Tizonia on Desktop.
Also tested with Bellagio to make sure it does not crash when
calling OMX_UseEGLImage and indeed it returns NotImplemented.
Then gst-omx fallback to OMX_UseBuffer if it can and so on.

Also tested on rpi to make sure there is no regression.

https://bugzilla.gnome.org/show_bug.cgi?id=784365
2017-08-01 10:18:21 +01:00
Nicolas Dufresne
64f7f781d8 omxvideodec: Fix segment seek
On segment seek, unlike EOS, we drain, but we cannot expect a flush
later to reset the decoder state. As a side effect, the decoder would
remain in EOS state and ignore any new incoming buffers.

To fix this, we call _flush() inside the _drain() function, and
_finish() becomes what _drain() was before. This way, for _finish() (the
    eos case) we only drain, for _drain() triggered by segment seek or new
caps, we also reset the decoder state so it's ready to accept buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=785237
2017-07-21 11:59:50 -04: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
Julien Isorce
1b7d0b8599 omxvideodec: handle IL 1.2 behavior for OMX_SetParameter
It triggers SettingsChanged on the other port and it is up to
the client to decide if it should lead to a port reconfiguration.

Settings are propagated to the other port for fields they have
in common. But this event is only triggered on the other port
if it actually change a setting.

https://bugzilla.gnome.org/show_bug.cgi?id=783976
2017-07-18 23:45:11 +01:00
Julien Isorce
af18e81fef omxvideodec: fix file permissions
Introduced by ebc9b4903c
2017-07-18 23:45:11 +01:00
Julien Isorce
7b114b131f omxvideodec: fix buffer leak when eglimage setup fails
Can happen if gst_buffer_pool_acquire_buffer succeeds but
gst_buffer_n_memory (buffer) is not exactly 1.

In theory this should not happen because the decoder requests
EGLImage(RGBA) but better to fix any leak on corner cases.

https://bugzilla.gnome.org/show_bug.cgi?id=784365
2017-07-17 17:11:34 +01:00
Julien Isorce
80c6dd46a1 omxvideodec: use OMX_UseBuffer
For example this allows the omx decoder to directly fill the
pixmaps coming from the video sink.

It only avoids a buffer copy when the decoder uses a pool provided
by a downstream element. So let's restrict this usage to situations
where the decoder decides to use a downstream buffer pool.

Tested with Tizonia/OMX.Aratelia.video_decoder.vp8
and with Bellagio/OMX.mesa.video_decoder.avc.

If it fails to setup buffers with OMX_UseBuffer the decoders
fallbacks to usual OMX_AllocateBuffer.

Also it allows to test on desktop the GstOMXBufferPool->other_pool
management which was previously only used in the OMX_UseEGLImage
case, i.e. on Rpi.

https://bugzilla.gnome.org/show_bug.cgi?id=784069
2017-07-12 16:36:03 +01:00
Sejun Park
ebc9b4903c omxvideodec: update local port_def after reopening the component
gst_omx_video_dec_open will only update GstOMXVideoDec->port->port_def.

Note that the component is reopen only if the flag
GST_OMX_HACK_NO_COMPONENT_RECONFIGURE is set.

https://bugzilla.gnome.org/show_bug.cgi?id=782418
2017-07-05 10:23:01 +01:00
Guillaume Desmottes
a3805116df omxvideodec: increase the minimum number of allocated buffers
Ensure that enough buffers are allocated by adding up component's own
minimal plus the number of buffers requested by downstream.
This should prevent buffers starvation problem if downstream elements
are holding some of the buffers they required.

Also simplify the check on the maximum on buffers. What we actually care
about is to make sure the pool can hold the minimum of required buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=784479
2017-07-03 11:05:24 -04:00
Sejun Park
d980af213b omxvideodec: Removed unreachable code
https://bugzilla.gnome.org/show_bug.cgi?id=782416
2017-05-10 11:54:44 +01:00
Jan Schmidt
7c829886ca omxvideodec: demote ERROR message
There's no need to warn about failing to negotiate EGL output
 - that can be perfectly normal.
2017-03-14 02:34:36 +11:00
Graham Leggett
a1e613dd89 omx*dec: Flush before we stop the srcpad loop
Flushing could otherwise hang if output port queue of pending buffers was empty

https://bugzilla.gnome.org/show_bug.cgi?id=774654
2016-12-19 10:52:16 +02:00
Matthew Waters
baaf404f2b videodecoder: remove use of EGLImage orientation
New code should use GstVideoTransformationMeta

(The defaults do the right thing here though).
2016-11-17 19:56:35 +11:00