From e55675b7ceb92286d539752c2c83939226304c7e Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 20 Jul 2017 12:56:37 +0200 Subject: [PATCH] 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 --- omx/gstomxvideodec.c | 18 +++++++++++++----- omx/gstomxvideoenc.c | 18 +++++++++++++----- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index b8c25cdfe6..1a1c3d7052 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -2133,6 +2133,15 @@ gst_omx_video_dec_disable (GstOMXVideoDec * self) return TRUE; } +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) { @@ -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 f60bbaa5b0..37fd4acfa5 100644 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -1120,6 +1120,15 @@ gst_omx_video_enc_configure_input_buffer (GstOMXVideoEnc * self, return TRUE; } +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) { @@ -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; }