mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-02 04:22:27 +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;
|
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);
|
typedef GType (*GGetTypeFunction) (void);
|
||||||
|
|
||||||
static const GGetTypeFunction types[] = {
|
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_is_enabled (GstOMXPort * port);
|
||||||
gboolean gst_omx_port_ensure_buffer_count_actual (GstOMXPort * port, guint extra);
|
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 */
|
/* OMX 1.2.0 dynamic allocation mode */
|
||||||
gboolean gst_omx_is_dynamic_allocation_supported (void);
|
gboolean gst_omx_is_dynamic_allocation_supported (void);
|
||||||
OMX_ERRORTYPE gst_omx_port_use_dynamic_buffers (GstOMXPort * port);
|
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);
|
self->dec_out_port = gst_omx_component_add_port (self->dec, out_port_index);
|
||||||
|
|
||||||
#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
|
#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
|
||||||
{
|
GST_DEBUG_OBJECT (self, "Configure decoder output to export dmabuf");
|
||||||
/* Configure OMX decoder to produce dmabuf */
|
self->dmabuf = gst_omx_port_set_dmabuf (self->dec_out_port, TRUE);
|
||||||
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;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!self->dec_in_port || !self->dec_out_port)
|
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
|
#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
|
||||||
if (gst_is_dmabuf_memory (gst_buffer_peek_memory (input, 0))) {
|
if (gst_is_dmabuf_memory (gst_buffer_peek_memory (input, 0))) {
|
||||||
if (self->input_allocation == GST_OMX_BUFFER_ALLOCATION_USE_BUFFER_DYNAMIC) {
|
if (self->input_allocation == GST_OMX_BUFFER_ALLOCATION_USE_BUFFER_DYNAMIC) {
|
||||||
OMX_ALG_PORT_PARAM_BUFFER_MODE buffer_mode;
|
GST_DEBUG_OBJECT (self, "Configure encoder input to import dmabuf");
|
||||||
OMX_ERRORTYPE err;
|
gst_omx_port_set_dmabuf (self->enc_in_port, TRUE);
|
||||||
|
|
||||||
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);
|
|
||||||
} else {
|
} else {
|
||||||
GST_DEBUG_OBJECT (self,
|
GST_DEBUG_OBJECT (self,
|
||||||
"Wrong input allocation mode (%d); dynamic buffers are required to use dmabuf import",
|
"Wrong input allocation mode (%d); dynamic buffers are required to use dmabuf import",
|
||||||
|
|
Loading…
Reference in a new issue