summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2017-07-20 12:56:37 +0200
committerJulien Isorce <jisorce@oblong.com>2017-12-14 09:00:27 +0000
commite55675b7ceb92286d539752c2c83939226304c7e (patch)
tree435f1209bcb9c6e98d2f6b75b5d8c6487dc1c54d
parentda07a647b8ee0dbbf59f667e778c7b6b51a5cd7e (diff)
downloadgst-omx-e55675b7ceb92286d539752c2c83939226304c7e.tar.gz
omxvideoenc/dec: factor out input buffer allocation
No semantic change so far. I'm going to add an alternate way to allocate input buffers. https://bugzilla.gnome.org/show_bug.cgi?id=787093
-rw-r--r--omx/gstomxvideodec.c18
-rw-r--r--omx/gstomxvideoenc.c18
2 files changed, 26 insertions, 10 deletions
diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c
index b8c25cd..1a1c3d7 100644
--- a/omx/gstomxvideodec.c
+++ b/omx/gstomxvideodec.c
@@ -2134,6 +2134,15 @@ gst_omx_video_dec_disable (GstOMXVideoDec * self)
}
static gboolean
+gst_omx_video_dec_allocate_in_buffers (GstOMXVideoDec * self)
+{
+ if (gst_omx_port_allocate_buffers (self->dec_in_port) != OMX_ErrorNone)
+ return FALSE;
+
+ return TRUE;
+}
+
+static gboolean
gst_omx_video_dec_enable (GstOMXVideoDec * self)
{
GstOMXVideoDecClass *klass = GST_OMX_VIDEO_DEC_GET_CLASS (self);
@@ -2143,7 +2152,7 @@ gst_omx_video_dec_enable (GstOMXVideoDec * self)
if (self->disabled) {
if (gst_omx_port_set_enabled (self->dec_in_port, TRUE) != OMX_ErrorNone)
return FALSE;
- if (gst_omx_port_allocate_buffers (self->dec_in_port) != OMX_ErrorNone)
+ if (!gst_omx_video_dec_allocate_in_buffers (self))
return FALSE;
if ((klass->cdata.hacks & GST_OMX_HACK_NO_DISABLE_OUTPORT)) {
@@ -2180,7 +2189,7 @@ gst_omx_video_dec_enable (GstOMXVideoDec * self)
return FALSE;
/* Need to allocate buffers to reach Idle state */
- if (gst_omx_port_allocate_buffers (self->dec_in_port) != OMX_ErrorNone)
+ if (!gst_omx_video_dec_allocate_in_buffers (self))
return FALSE;
} else {
if (gst_omx_component_set_state (self->dec,
@@ -2188,7 +2197,7 @@ gst_omx_video_dec_enable (GstOMXVideoDec * self)
return FALSE;
/* Need to allocate buffers to reach Idle state */
- if (gst_omx_port_allocate_buffers (self->dec_in_port) != OMX_ErrorNone)
+ if (!gst_omx_video_dec_allocate_in_buffers (self))
return FALSE;
if (gst_omx_port_allocate_buffers (self->dec_out_port) != OMX_ErrorNone)
return FALSE;
@@ -2511,8 +2520,7 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder,
goto reconfigure_error;
}
- err = gst_omx_port_allocate_buffers (port);
- if (err != OMX_ErrorNone) {
+ if (!gst_omx_video_dec_allocate_in_buffers (self)) {
GST_VIDEO_DECODER_STREAM_LOCK (self);
goto reconfigure_error;
}
diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c
index f60bbaa..37fd4ac 100644
--- a/omx/gstomxvideoenc.c
+++ b/omx/gstomxvideoenc.c
@@ -1121,6 +1121,15 @@ gst_omx_video_enc_configure_input_buffer (GstOMXVideoEnc * self,
}
static gboolean
+gst_omx_video_enc_allocate_in_buffers (GstOMXVideoEnc * self)
+{
+ if (gst_omx_port_allocate_buffers (self->enc_in_port) != OMX_ErrorNone)
+ return FALSE;
+
+ return TRUE;
+}
+
+static gboolean
gst_omx_video_enc_enable (GstOMXVideoEnc * self, GstBuffer * input)
{
GstOMXVideoEncClass *klass;
@@ -1134,7 +1143,7 @@ gst_omx_video_enc_enable (GstOMXVideoEnc * self, GstBuffer * input)
if (self->disabled) {
if (gst_omx_port_set_enabled (self->enc_in_port, TRUE) != OMX_ErrorNone)
return FALSE;
- if (gst_omx_port_allocate_buffers (self->enc_in_port) != OMX_ErrorNone)
+ if (!gst_omx_video_enc_allocate_in_buffers (self))
return FALSE;
if ((klass->cdata.hacks & GST_OMX_HACK_NO_DISABLE_OUTPORT)) {
@@ -1168,7 +1177,7 @@ gst_omx_video_enc_enable (GstOMXVideoEnc * self, GstBuffer * input)
return FALSE;
/* Need to allocate buffers to reach Idle state */
- if (gst_omx_port_allocate_buffers (self->enc_in_port) != OMX_ErrorNone)
+ if (!gst_omx_video_enc_allocate_in_buffers (self))
return FALSE;
} else {
if (gst_omx_component_set_state (self->enc,
@@ -1176,7 +1185,7 @@ gst_omx_video_enc_enable (GstOMXVideoEnc * self, GstBuffer * input)
return FALSE;
/* Need to allocate buffers to reach Idle state */
- if (gst_omx_port_allocate_buffers (self->enc_in_port) != OMX_ErrorNone)
+ if (!gst_omx_video_enc_allocate_in_buffers (self))
return FALSE;
if (gst_omx_port_allocate_buffers (self->enc_out_port) != OMX_ErrorNone)
return FALSE;
@@ -1664,8 +1673,7 @@ gst_omx_video_enc_handle_frame (GstVideoEncoder * encoder,
goto reconfigure_error;
}
- err = gst_omx_port_allocate_buffers (port);
- if (err != OMX_ErrorNone) {
+ if (!gst_omx_video_enc_allocate_in_buffers (self)) {
GST_VIDEO_ENCODER_STREAM_LOCK (self);
goto reconfigure_error;
}