mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
shapewipe: Move chain function error cases at the end of the function and add useful debug output
This commit is contained in:
parent
8d213d51f6
commit
d875dce9bb
1 changed files with 47 additions and 38 deletions
|
@ -751,7 +751,7 @@ gst_shape_wipe_do_qos (GstShapeWipe * self, GstClockTime timestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CREATE_AYUV_FUNCTIONS(depth, shift) \
|
#define CREATE_AYUV_FUNCTIONS(depth, shift) \
|
||||||
static GstFlowReturn \
|
static void \
|
||||||
gst_shape_wipe_blend_ayuv_##depth (GstShapeWipe * self, GstBuffer * inbuf, \
|
gst_shape_wipe_blend_ayuv_##depth (GstShapeWipe * self, GstBuffer * inbuf, \
|
||||||
GstBuffer * maskbuf, GstBuffer * outbuf) \
|
GstBuffer * maskbuf, GstBuffer * outbuf) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -813,15 +813,13 @@ gst_shape_wipe_blend_ayuv_##depth (GstShapeWipe * self, GstBuffer * inbuf, \
|
||||||
} \
|
} \
|
||||||
mask += mask_increment; \
|
mask += mask_increment; \
|
||||||
} \
|
} \
|
||||||
\
|
|
||||||
return GST_FLOW_OK; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CREATE_AYUV_FUNCTIONS (16, 0);
|
CREATE_AYUV_FUNCTIONS (16, 0);
|
||||||
CREATE_AYUV_FUNCTIONS (8, 8);
|
CREATE_AYUV_FUNCTIONS (8, 8);
|
||||||
|
|
||||||
#define CREATE_ARGB_FUNCTIONS(depth, name, shift, a, r, g, b) \
|
#define CREATE_ARGB_FUNCTIONS(depth, name, shift, a, r, g, b) \
|
||||||
static GstFlowReturn \
|
static void \
|
||||||
gst_shape_wipe_blend_##name##_##depth (GstShapeWipe * self, GstBuffer * inbuf, \
|
gst_shape_wipe_blend_##name##_##depth (GstShapeWipe * self, GstBuffer * inbuf, \
|
||||||
GstBuffer * maskbuf, GstBuffer * outbuf) \
|
GstBuffer * maskbuf, GstBuffer * outbuf) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -883,8 +881,6 @@ gst_shape_wipe_blend_##name##_##depth (GstShapeWipe * self, GstBuffer * inbuf, \
|
||||||
} \
|
} \
|
||||||
mask += mask_increment; \
|
mask += mask_increment; \
|
||||||
} \
|
} \
|
||||||
\
|
|
||||||
return GST_FLOW_OK; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CREATE_ARGB_FUNCTIONS (16, argb, 0, 0, 1, 2, 3);
|
CREATE_ARGB_FUNCTIONS (16, argb, 0, 0, 1, 2, 3);
|
||||||
|
@ -903,7 +899,7 @@ gst_shape_wipe_video_sink_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
gboolean new_outbuf = FALSE;
|
gboolean new_outbuf = FALSE;
|
||||||
|
|
||||||
if (G_UNLIKELY (self->fmt == GST_VIDEO_FORMAT_UNKNOWN))
|
if (G_UNLIKELY (self->fmt == GST_VIDEO_FORMAT_UNKNOWN))
|
||||||
return GST_FLOW_NOT_NEGOTIATED;
|
goto not_negotiated;
|
||||||
|
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
timestamp =
|
timestamp =
|
||||||
|
@ -917,41 +913,31 @@ gst_shape_wipe_video_sink_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
GST_TIME_ARGS (timestamp), self->mask_position);
|
GST_TIME_ARGS (timestamp), self->mask_position);
|
||||||
|
|
||||||
g_mutex_lock (self->mask_mutex);
|
g_mutex_lock (self->mask_mutex);
|
||||||
if (self->shutdown) {
|
if (self->shutdown)
|
||||||
gst_buffer_unref (buffer);
|
goto shutdown;
|
||||||
return GST_FLOW_WRONG_STATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!self->mask)
|
if (!self->mask)
|
||||||
g_cond_wait (self->mask_cond, self->mask_mutex);
|
g_cond_wait (self->mask_cond, self->mask_mutex);
|
||||||
|
|
||||||
if (self->mask == NULL) {
|
if (self->mask == NULL || self->shutdown) {
|
||||||
g_mutex_unlock (self->mask_mutex);
|
goto shutdown;
|
||||||
gst_buffer_unref (buffer);
|
|
||||||
return GST_FLOW_WRONG_STATE;
|
|
||||||
} else {
|
} else {
|
||||||
mask = gst_buffer_ref (self->mask);
|
mask = gst_buffer_ref (self->mask);
|
||||||
}
|
}
|
||||||
g_mutex_unlock (self->mask_mutex);
|
g_mutex_unlock (self->mask_mutex);
|
||||||
|
|
||||||
if (!gst_shape_wipe_do_qos (self, GST_BUFFER_TIMESTAMP (buffer))) {
|
if (!gst_shape_wipe_do_qos (self, GST_BUFFER_TIMESTAMP (buffer)))
|
||||||
gst_buffer_unref (buffer);
|
goto qos;
|
||||||
gst_buffer_unref (mask);
|
|
||||||
return GST_FLOW_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Try to blend inplace, if it's not possible
|
/* Try to blend inplace, if it's not possible
|
||||||
* get a new buffer from downstream.
|
* get a new buffer from downstream. */
|
||||||
*/
|
|
||||||
if (!gst_buffer_is_writable (buffer)) {
|
if (!gst_buffer_is_writable (buffer)) {
|
||||||
ret =
|
ret =
|
||||||
gst_pad_alloc_buffer_and_set_caps (self->srcpad, GST_BUFFER_OFFSET_NONE,
|
gst_pad_alloc_buffer_and_set_caps (self->srcpad, GST_BUFFER_OFFSET_NONE,
|
||||||
GST_BUFFER_SIZE (buffer), GST_PAD_CAPS (self->srcpad), &outbuf);
|
GST_BUFFER_SIZE (buffer), GST_PAD_CAPS (self->srcpad), &outbuf);
|
||||||
if (G_UNLIKELY (ret != GST_FLOW_OK)) {
|
if (G_UNLIKELY (ret != GST_FLOW_OK))
|
||||||
gst_buffer_unref (buffer);
|
goto alloc_failed;
|
||||||
gst_buffer_unref (mask);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
gst_buffer_copy_metadata (outbuf, buffer, GST_BUFFER_COPY_ALL);
|
gst_buffer_copy_metadata (outbuf, buffer, GST_BUFFER_COPY_ALL);
|
||||||
new_outbuf = TRUE;
|
new_outbuf = TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -959,17 +945,17 @@ gst_shape_wipe_video_sink_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->fmt == GST_VIDEO_FORMAT_AYUV && self->mask_bpp == 16)
|
if (self->fmt == GST_VIDEO_FORMAT_AYUV && self->mask_bpp == 16)
|
||||||
ret = gst_shape_wipe_blend_ayuv_16 (self, buffer, mask, outbuf);
|
gst_shape_wipe_blend_ayuv_16 (self, buffer, mask, outbuf);
|
||||||
else if (self->fmt == GST_VIDEO_FORMAT_AYUV)
|
else if (self->fmt == GST_VIDEO_FORMAT_AYUV)
|
||||||
ret = gst_shape_wipe_blend_ayuv_8 (self, buffer, mask, outbuf);
|
gst_shape_wipe_blend_ayuv_8 (self, buffer, mask, outbuf);
|
||||||
else if (self->fmt == GST_VIDEO_FORMAT_ARGB && self->mask_bpp == 16)
|
else if (self->fmt == GST_VIDEO_FORMAT_ARGB && self->mask_bpp == 16)
|
||||||
ret = gst_shape_wipe_blend_argb_16 (self, buffer, mask, outbuf);
|
gst_shape_wipe_blend_argb_16 (self, buffer, mask, outbuf);
|
||||||
else if (self->fmt == GST_VIDEO_FORMAT_ARGB)
|
else if (self->fmt == GST_VIDEO_FORMAT_ARGB)
|
||||||
ret = gst_shape_wipe_blend_argb_8 (self, buffer, mask, outbuf);
|
gst_shape_wipe_blend_argb_8 (self, buffer, mask, outbuf);
|
||||||
else if (self->fmt == GST_VIDEO_FORMAT_BGRA && self->mask_bpp == 16)
|
else if (self->fmt == GST_VIDEO_FORMAT_BGRA && self->mask_bpp == 16)
|
||||||
ret = gst_shape_wipe_blend_bgra_16 (self, buffer, mask, outbuf);
|
gst_shape_wipe_blend_bgra_16 (self, buffer, mask, outbuf);
|
||||||
else if (self->fmt == GST_VIDEO_FORMAT_BGRA)
|
else if (self->fmt == GST_VIDEO_FORMAT_BGRA)
|
||||||
ret = gst_shape_wipe_blend_bgra_8 (self, buffer, mask, outbuf);
|
gst_shape_wipe_blend_bgra_8 (self, buffer, mask, outbuf);
|
||||||
else
|
else
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
|
|
||||||
|
@ -977,12 +963,35 @@ gst_shape_wipe_video_sink_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
if (new_outbuf)
|
if (new_outbuf)
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
if (ret != GST_FLOW_OK) {
|
|
||||||
gst_buffer_unref (outbuf);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = gst_pad_push (self->srcpad, outbuf);
|
ret = gst_pad_push (self->srcpad, outbuf);
|
||||||
|
if (G_UNLIKELY (ret != GST_FLOW_OK))
|
||||||
|
goto push_failed;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
/* Errors */
|
||||||
|
not_negotiated:
|
||||||
|
GST_ERROR_OBJECT (self, "No valid caps yet");
|
||||||
|
gst_buffer_unref (buffer);
|
||||||
|
return GST_FLOW_NOT_NEGOTIATED;
|
||||||
|
shutdown:
|
||||||
|
GST_DEBUG_OBJECT (self, "Shutting down");
|
||||||
|
gst_buffer_unref (buffer);
|
||||||
|
return GST_FLOW_WRONG_STATE;
|
||||||
|
qos:
|
||||||
|
GST_DEBUG_OBJECT (self, "Dropping buffer because of QoS");
|
||||||
|
gst_buffer_unref (buffer);
|
||||||
|
gst_buffer_unref (mask);
|
||||||
|
return GST_FLOW_OK;
|
||||||
|
alloc_failed:
|
||||||
|
GST_ERROR_OBJECT (self, "Buffer allocation from downstream failed: %s",
|
||||||
|
gst_flow_get_name (ret));
|
||||||
|
gst_buffer_unref (buffer);
|
||||||
|
gst_buffer_unref (mask);
|
||||||
|
return ret;
|
||||||
|
push_failed:
|
||||||
|
GST_ERROR_OBJECT (self, "Pushing buffer downstream failed: %s",
|
||||||
|
gst_flow_get_name (ret));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue