mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 15:18:21 +00:00
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
This commit is contained in:
parent
40ae47df5e
commit
f0964dfbdb
4 changed files with 38 additions and 36 deletions
32
omx/gstomx.c
32
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[] = {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue