From eec88a965106d66e1b327b9bc15a114b6b0f262e Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Thu, 20 Jul 2017 09:43:19 +0100 Subject: 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 --- omx/gstomxaudiodec.c | 25 ++++++++++++++++++------- omx/gstomxaudioenc.c | 25 ++++++++++++++++++------- omx/gstomxvideodec.c | 25 ++++++++++++++++++------- omx/gstomxvideoenc.c | 25 ++++++++++++++++++------- 4 files changed, 72 insertions(+), 28 deletions(-) diff --git a/omx/gstomxaudiodec.c b/omx/gstomxaudiodec.c index 8b8e121..d482391 100644 --- a/omx/gstomxaudiodec.c +++ b/omx/gstomxaudiodec.c @@ -843,23 +843,34 @@ gst_omx_audio_dec_set_format (GstAudioDecoder * decoder, GstCaps * caps) return FALSE; needs_disable = FALSE; } else { + /* Disabling at the same time input port and output port is only + * required when a buffer is shared between the ports. This cannot + * be the case for a decoder because its input and output buffers + * are of different nature. So let's disable ports sequencially. + * Starting from IL 1.2.0, this point has been clarified. + * OMX_SendCommand will return an error if the IL client attempts to + * call it when there is already an on-going command being processed. + * The exception is for buffer sharing above and the event + * OMX_EventPortNeedsDisable will be sent to request disabling the + * other port at the same time. */ if (gst_omx_port_set_enabled (self->dec_in_port, FALSE) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_set_enabled (out_port, FALSE) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_wait_buffers_released (self->dec_in_port, 5 * GST_SECOND) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_wait_buffers_released (out_port, - 1 * GST_SECOND) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_deallocate_buffers (self->dec_in_port) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_deallocate_buffers (self->dec_out_port) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_wait_enabled (self->dec_in_port, 1 * GST_SECOND) != OMX_ErrorNone) return FALSE; + + if (gst_omx_port_set_enabled (out_port, FALSE) != OMX_ErrorNone) + return FALSE; + if (gst_omx_port_wait_buffers_released (out_port, + 1 * GST_SECOND) != OMX_ErrorNone) + return FALSE; + if (gst_omx_port_deallocate_buffers (out_port) != OMX_ErrorNone) + return FALSE; if (gst_omx_port_wait_enabled (out_port, 1 * GST_SECOND) != OMX_ErrorNone) return FALSE; } diff --git a/omx/gstomxaudioenc.c b/omx/gstomxaudioenc.c index a03eccc..f9c2581 100644 --- a/omx/gstomxaudioenc.c +++ b/omx/gstomxaudioenc.c @@ -694,23 +694,34 @@ gst_omx_audio_enc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info) /* The local port_def is now obsolete so get it again. */ gst_omx_port_get_port_definition (self->enc_in_port, &port_def); } else { + /* Disabling at the same time input port and output port is only + * required when a buffer is shared between the ports. This cannot + * be the case for a encoder because its input and output buffers + * are of different nature. So let's disable ports sequencially. + * Starting from IL 1.2.0, this point has been clarified. + * OMX_SendCommand will return an error if the IL client attempts to + * call it when there is already an on-going command being processed. + * The exception is for buffer sharing above and the event + * OMX_EventPortNeedsDisable will be sent to request disabling the + * other port at the same time. */ if (gst_omx_port_set_enabled (self->enc_in_port, FALSE) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_set_enabled (self->enc_out_port, FALSE) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_wait_buffers_released (self->enc_in_port, 5 * GST_SECOND) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_wait_buffers_released (self->enc_out_port, - 1 * GST_SECOND) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_deallocate_buffers (self->enc_in_port) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_deallocate_buffers (self->enc_out_port) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_wait_enabled (self->enc_in_port, 1 * GST_SECOND) != OMX_ErrorNone) return FALSE; + + if (gst_omx_port_set_enabled (self->enc_out_port, FALSE) != OMX_ErrorNone) + return FALSE; + if (gst_omx_port_wait_buffers_released (self->enc_out_port, + 1 * GST_SECOND) != OMX_ErrorNone) + return FALSE; + if (gst_omx_port_deallocate_buffers (self->enc_out_port) != OMX_ErrorNone) + return FALSE; if (gst_omx_port_wait_enabled (self->enc_out_port, 1 * GST_SECOND) != OMX_ErrorNone) return FALSE; diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index 290e5a3..b0178b1 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -2053,23 +2053,34 @@ gst_omx_video_dec_disable (GstOMXVideoDec * self) } #endif + /* Disabling at the same time input port and output port is only + * required when a buffer is shared between the ports. This cannot + * be the case for a decoder because its input and output buffers + * are of different nature. So let's disable ports sequencially. + * Starting from IL 1.2.0, this point has been clarified. + * OMX_SendCommand will return an error if the IL client attempts to + * call it when there is already an on-going command being processed. + * The exception is for buffer sharing above and the event + * OMX_EventPortNeedsDisable will be sent to request disabling the + * other port at the same time. */ if (gst_omx_port_set_enabled (self->dec_in_port, FALSE) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_set_enabled (out_port, FALSE) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_wait_buffers_released (self->dec_in_port, 5 * GST_SECOND) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_wait_buffers_released (out_port, - 1 * GST_SECOND) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_deallocate_buffers (self->dec_in_port) != OMX_ErrorNone) return FALSE; - if (gst_omx_video_dec_deallocate_output_buffers (self) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_wait_enabled (self->dec_in_port, 1 * GST_SECOND) != OMX_ErrorNone) return FALSE; + + if (gst_omx_port_set_enabled (out_port, FALSE) != OMX_ErrorNone) + return FALSE; + if (gst_omx_port_wait_buffers_released (out_port, + 1 * GST_SECOND) != OMX_ErrorNone) + return FALSE; + if (gst_omx_video_dec_deallocate_output_buffers (self) != OMX_ErrorNone) + return FALSE; if (gst_omx_port_wait_enabled (out_port, 1 * GST_SECOND) != OMX_ErrorNone) return FALSE; diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index 3172903..2fc31b8 100644 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -1003,23 +1003,34 @@ gst_omx_video_enc_disable (GstOMXVideoEnc * self) /* The decoder is returned to initial state */ self->disabled = FALSE; } else { + /* Disabling at the same time input port and output port is only + * required when a buffer is shared between the ports. This cannot + * be the case for a encoder because its input and output buffers + * are of different nature. So let's disable ports sequencially. + * Starting from IL 1.2.0, this point has been clarified. + * OMX_SendCommand will return an error if the IL client attempts to + * call it when there is already an on-going command being processed. + * The exception is for buffer sharing above and the event + * OMX_EventPortNeedsDisable will be sent to request disabling the + * other port at the same time. */ if (gst_omx_port_set_enabled (self->enc_in_port, FALSE) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_set_enabled (self->enc_out_port, FALSE) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_wait_buffers_released (self->enc_in_port, 5 * GST_SECOND) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_wait_buffers_released (self->enc_out_port, - 1 * GST_SECOND) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_deallocate_buffers (self->enc_in_port) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_deallocate_buffers (self->enc_out_port) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_wait_enabled (self->enc_in_port, 1 * GST_SECOND) != OMX_ErrorNone) return FALSE; + + if (gst_omx_port_set_enabled (self->enc_out_port, FALSE) != OMX_ErrorNone) + return FALSE; + if (gst_omx_port_wait_buffers_released (self->enc_out_port, + 1 * GST_SECOND) != OMX_ErrorNone) + return FALSE; + if (gst_omx_port_deallocate_buffers (self->enc_out_port) != OMX_ErrorNone) + return FALSE; if (gst_omx_port_wait_enabled (self->enc_out_port, 1 * GST_SECOND) != OMX_ErrorNone) return FALSE; -- cgit v1.2.1