No semantic change. I also made the debug message a bit clearer.
https://bugzilla.gnome.org/show_bug.cgi?id=796918
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[] = {
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);
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)
#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",