diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2018-03-21 12:43:33 +0100 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2018-08-30 10:59:30 +0200 |
commit | f0964dfbdb6075cb0281206af7cd4186565c38df (patch) | |
tree | d591e2802aaaaff94cd3bdd9468aefb295ecd896 | |
parent | 40ae47df5e6668231ce6d48c8ba83c2eb1790521 (diff) | |
download | gst-omx-f0964dfbdb6075cb0281206af7cd4186565c38df.tar.gz |
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
-rw-r--r-- | omx/gstomx.c | 32 | ||||
-rw-r--r-- | omx/gstomx.h | 2 | ||||
-rw-r--r-- | omx/gstomxvideodec.c | 22 | ||||
-rw-r--r-- | omx/gstomxvideoenc.c | 18 |
4 files changed, 38 insertions, 36 deletions
diff --git a/omx/gstomx.c b/omx/gstomx.c index 8ed336b..2583889 100644 --- a/omx/gstomx.c +++ b/omx/gstomx.c @@ -2591,6 +2591,38 @@ gst_omx_port_ensure_buffer_count_actual (GstOMXPort * port, guint extra) return TRUE; } +gboolean +gst_omx_port_set_dmabuf (GstOMXPort * port, gboolean dmabuf) +{ +#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS + OMX_ALG_PORT_PARAM_BUFFER_MODE buffer_mode; + OMX_ERRORTYPE err; + + GST_OMX_INIT_STRUCT (&buffer_mode); + buffer_mode.nPortIndex = port->index; + + if (dmabuf) + buffer_mode.eMode = OMX_ALG_BUF_DMA; + else + buffer_mode.eMode = OMX_ALG_BUF_NORMAL; + + err = + gst_omx_component_set_parameter (port->comp, + (OMX_INDEXTYPE) OMX_ALG_IndexPortParamBufferMode, &buffer_mode); + if (err != OMX_ErrorNone) { + GST_WARNING_OBJECT (port->comp->parent, + "Failed to set port %d in %sdmabuf mode: %s (0x%08x)", + port->index, dmabuf ? "" : "non-", gst_omx_error_to_string (err), err); + return FALSE; + } + + return TRUE; +#else + /* dmabuf not supported for this platform */ + return FALSE; +#endif +} + typedef GType (*GGetTypeFunction) (void); static const GGetTypeFunction types[] = { diff --git a/omx/gstomx.h b/omx/gstomx.h index eab7b7d..075cfd6 100644 --- a/omx/gstomx.h +++ b/omx/gstomx.h @@ -457,6 +457,8 @@ OMX_ERRORTYPE gst_omx_port_wait_enabled (GstOMXPort * port, GstClockTime tim gboolean gst_omx_port_is_enabled (GstOMXPort * port); gboolean gst_omx_port_ensure_buffer_count_actual (GstOMXPort * port, guint extra); +gboolean gst_omx_port_set_dmabuf (GstOMXPort * port, gboolean dmabuf); + /* OMX 1.2.0 dynamic allocation mode */ gboolean gst_omx_is_dynamic_allocation_supported (void); OMX_ERRORTYPE gst_omx_port_use_dynamic_buffers (GstOMXPort * port); diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index 989d185..70e01f6 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -303,26 +303,8 @@ gst_omx_video_dec_open (GstVideoDecoder * decoder) self->dec_out_port = gst_omx_component_add_port (self->dec, out_port_index); #ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS - { - /* Configure OMX decoder to produce dmabuf */ - OMX_ALG_PORT_PARAM_BUFFER_MODE buffer_mode; - OMX_ERRORTYPE err; - - GST_OMX_INIT_STRUCT (&buffer_mode); - buffer_mode.nPortIndex = self->dec_out_port->index; - buffer_mode.eMode = OMX_ALG_BUF_DMA; - - GST_DEBUG_OBJECT (self, "Configure decoder to produce dmabuf"); - - err = - gst_omx_component_set_parameter (self->dec, - (OMX_INDEXTYPE) OMX_ALG_IndexPortParamBufferMode, &buffer_mode); - if (err != OMX_ErrorNone) - GST_WARNING_OBJECT (self, "Failed to set output buffer mode: %s (0x%08x)", - gst_omx_error_to_string (err), err); - else - self->dmabuf = TRUE; - } + GST_DEBUG_OBJECT (self, "Configure decoder output to export dmabuf"); + self->dmabuf = gst_omx_port_set_dmabuf (self->dec_out_port, TRUE); #endif if (!self->dec_in_port || !self->dec_out_port) diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index 287e003..314e98d 100644 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -2009,22 +2009,8 @@ gst_omx_video_enc_enable (GstOMXVideoEnc * self, GstBuffer * input) #ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS if (gst_is_dmabuf_memory (gst_buffer_peek_memory (input, 0))) { if (self->input_allocation == GST_OMX_BUFFER_ALLOCATION_USE_BUFFER_DYNAMIC) { - OMX_ALG_PORT_PARAM_BUFFER_MODE buffer_mode; - OMX_ERRORTYPE err; - - GST_OMX_INIT_STRUCT (&buffer_mode); - buffer_mode.nPortIndex = self->enc_in_port->index; - buffer_mode.eMode = OMX_ALG_BUF_DMA; - - GST_DEBUG_OBJECT (self, "Configure encoder to import dmabuf"); - - err = - gst_omx_component_set_parameter (self->enc, - (OMX_INDEXTYPE) OMX_ALG_IndexPortParamBufferMode, &buffer_mode); - if (err != OMX_ErrorNone) - GST_WARNING_OBJECT (self, - "Failed to set output buffer mode: %s (0x%08x)", - gst_omx_error_to_string (err), err); + GST_DEBUG_OBJECT (self, "Configure encoder input to import dmabuf"); + gst_omx_port_set_dmabuf (self->enc_in_port, TRUE); } else { GST_DEBUG_OBJECT (self, "Wrong input allocation mode (%d); dynamic buffers are required to use dmabuf import", |