mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
video: overlay-composition: some minor clean-ups
extract_alpha and apply_global alpha always return TRUE really, so just do away with the return value. Convert a g_return_if_fail() into a g_assert(), since this is only to check internal consistency and not a guard for public API. Add some locking. https://bugzilla.gnome.org/show_bug.cgi?id=668483
This commit is contained in:
parent
9d1b331004
commit
32679e1826
1 changed files with 14 additions and 15 deletions
|
@ -941,7 +941,7 @@ gst_video_overlay_rectangle_unpremultiply (GstBlendVideoFormatInfo * info)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
gst_video_overlay_rectangle_extract_alpha (GstVideoOverlayRectangle * rect)
|
gst_video_overlay_rectangle_extract_alpha (GstVideoOverlayRectangle * rect)
|
||||||
{
|
{
|
||||||
guint8 *src, *dst;
|
guint8 *src, *dst;
|
||||||
|
@ -954,30 +954,29 @@ gst_video_overlay_rectangle_extract_alpha (GstVideoOverlayRectangle * rect)
|
||||||
rect->initial_alpha = g_malloc (alpha_size);
|
rect->initial_alpha = g_malloc (alpha_size);
|
||||||
src = GST_BUFFER_DATA (rect->pixels);
|
src = GST_BUFFER_DATA (rect->pixels);
|
||||||
dst = rect->initial_alpha;
|
dst = rect->initial_alpha;
|
||||||
|
/* FIXME we're accessing possibly uninitialised bytes from the row padding */
|
||||||
while (offset < alpha_size) {
|
while (offset < alpha_size) {
|
||||||
dst[offset] = src[offset * 4 + ARGB_A];
|
dst[offset] = src[offset * 4 + ARGB_A];
|
||||||
++offset;
|
++offset;
|
||||||
}
|
}
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
gst_video_overlay_rectangle_apply_global_alpha (GstVideoOverlayRectangle * rect,
|
gst_video_overlay_rectangle_apply_global_alpha (GstVideoOverlayRectangle * rect,
|
||||||
float global_alpha)
|
float global_alpha)
|
||||||
{
|
{
|
||||||
guint8 *src, *dst;
|
guint8 *src, *dst;
|
||||||
guint offset = 0;
|
guint offset = 0;
|
||||||
|
|
||||||
g_return_val_if_fail (!(rect->applied_global_alpha != 1.0
|
g_assert (!(rect->applied_global_alpha != 1.0
|
||||||
&& rect->initial_alpha == NULL), FALSE);
|
&& rect->initial_alpha == NULL));
|
||||||
|
|
||||||
if (global_alpha == rect->applied_global_alpha)
|
if (global_alpha == rect->applied_global_alpha)
|
||||||
return TRUE;
|
return;
|
||||||
|
|
||||||
if (rect->initial_alpha == NULL &&
|
if (rect->initial_alpha == NULL)
|
||||||
!gst_video_overlay_rectangle_extract_alpha (rect))
|
gst_video_overlay_rectangle_extract_alpha (rect);
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
src = rect->initial_alpha;
|
src = rect->initial_alpha;
|
||||||
rect->pixels = gst_buffer_make_writable (rect->pixels);
|
rect->pixels = gst_buffer_make_writable (rect->pixels);
|
||||||
|
@ -1001,7 +1000,6 @@ gst_video_overlay_rectangle_apply_global_alpha (GstVideoOverlayRectangle * rect,
|
||||||
}
|
}
|
||||||
|
|
||||||
rect->applied_global_alpha = global_alpha;
|
rect->applied_global_alpha = global_alpha;
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstBuffer *
|
static GstBuffer *
|
||||||
|
@ -1112,17 +1110,18 @@ gst_video_overlay_rectangle_get_pixels_argb_internal (GstVideoOverlayRectangle *
|
||||||
GST_RECTANGLE_UNLOCK (rectangle);
|
GST_RECTANGLE_UNLOCK (rectangle);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
||||||
|
GST_RECTANGLE_LOCK (rectangle);
|
||||||
if (apply_global_alpha
|
if (apply_global_alpha
|
||||||
&& scaled_rect->applied_global_alpha != rectangle->global_alpha) {
|
&& scaled_rect->applied_global_alpha != rectangle->global_alpha) {
|
||||||
if (!gst_video_overlay_rectangle_apply_global_alpha (scaled_rect,
|
gst_video_overlay_rectangle_apply_global_alpha (scaled_rect,
|
||||||
rectangle->global_alpha))
|
rectangle->global_alpha);
|
||||||
return NULL; /* return original data? */
|
|
||||||
gst_video_overlay_rectangle_set_global_alpha (scaled_rect,
|
gst_video_overlay_rectangle_set_global_alpha (scaled_rect,
|
||||||
rectangle->global_alpha);
|
rectangle->global_alpha);
|
||||||
} else if (revert_global_alpha && scaled_rect->applied_global_alpha != 1.0) {
|
} else if (revert_global_alpha && scaled_rect->applied_global_alpha != 1.0) {
|
||||||
if (!gst_video_overlay_rectangle_apply_global_alpha (scaled_rect, 1.0))
|
gst_video_overlay_rectangle_apply_global_alpha (scaled_rect, 1.0);
|
||||||
return NULL; /* return original data? */
|
|
||||||
}
|
}
|
||||||
|
GST_RECTANGLE_UNLOCK (rectangle);
|
||||||
|
|
||||||
*stride = scaled_rect->stride;
|
*stride = scaled_rect->stride;
|
||||||
return scaled_rect->pixels;
|
return scaled_rect->pixels;
|
||||||
|
|
Loading…
Reference in a new issue