summaryrefslogtreecommitdiff
path: root/gst-libs/gst/video/video-overlay-composition.c
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim.muller@collabora.co.uk>2012-03-24 19:47:10 +0000
committerTim-Philipp Müller <tim.muller@collabora.co.uk>2012-03-25 11:27:24 +0100
commit32679e1826267a7b63a69bfbc7f0f4c9c6addb15 (patch)
treedcf98f81e26b7047c456941e8918f11490f55eae /gst-libs/gst/video/video-overlay-composition.c
parent9d1b331004bb1d6dba91eaea294af6adcadc29a3 (diff)
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
Diffstat (limited to 'gst-libs/gst/video/video-overlay-composition.c')
-rw-r--r--gst-libs/gst/video/video-overlay-composition.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/gst-libs/gst/video/video-overlay-composition.c b/gst-libs/gst/video/video-overlay-composition.c
index a1de051a4..f9f90c5bb 100644
--- a/gst-libs/gst/video/video-overlay-composition.c
+++ b/gst-libs/gst/video/video-overlay-composition.c
@@ -941,7 +941,7 @@ gst_video_overlay_rectangle_unpremultiply (GstBlendVideoFormatInfo * info)
}
-static gboolean
+static void
gst_video_overlay_rectangle_extract_alpha (GstVideoOverlayRectangle * rect)
{
guint8 *src, *dst;
@@ -954,30 +954,29 @@ gst_video_overlay_rectangle_extract_alpha (GstVideoOverlayRectangle * rect)
rect->initial_alpha = g_malloc (alpha_size);
src = GST_BUFFER_DATA (rect->pixels);
dst = rect->initial_alpha;
+ /* FIXME we're accessing possibly uninitialised bytes from the row padding */
while (offset < alpha_size) {
dst[offset] = src[offset * 4 + ARGB_A];
++offset;
}
- return TRUE;
}
-static gboolean
+static void
gst_video_overlay_rectangle_apply_global_alpha (GstVideoOverlayRectangle * rect,
float global_alpha)
{
guint8 *src, *dst;
guint offset = 0;
- g_return_val_if_fail (!(rect->applied_global_alpha != 1.0
- && rect->initial_alpha == NULL), FALSE);
+ g_assert (!(rect->applied_global_alpha != 1.0
+ && rect->initial_alpha == NULL));
if (global_alpha == rect->applied_global_alpha)
- return TRUE;
+ return;
- if (rect->initial_alpha == NULL &&
- !gst_video_overlay_rectangle_extract_alpha (rect))
- return FALSE;
+ if (rect->initial_alpha == NULL)
+ gst_video_overlay_rectangle_extract_alpha (rect);
src = rect->initial_alpha;
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;
- return TRUE;
}
static GstBuffer *
@@ -1112,17 +1110,18 @@ gst_video_overlay_rectangle_get_pixels_argb_internal (GstVideoOverlayRectangle *
GST_RECTANGLE_UNLOCK (rectangle);
done:
+
+ GST_RECTANGLE_LOCK (rectangle);
if (apply_global_alpha
&& scaled_rect->applied_global_alpha != rectangle->global_alpha) {
- if (!gst_video_overlay_rectangle_apply_global_alpha (scaled_rect,
- rectangle->global_alpha))
- return NULL; /* return original data? */
+ gst_video_overlay_rectangle_apply_global_alpha (scaled_rect,
+ rectangle->global_alpha);
gst_video_overlay_rectangle_set_global_alpha (scaled_rect,
rectangle->global_alpha);
} else if (revert_global_alpha && scaled_rect->applied_global_alpha != 1.0) {
- if (!gst_video_overlay_rectangle_apply_global_alpha (scaled_rect, 1.0))
- return NULL; /* return original data? */
+ gst_video_overlay_rectangle_apply_global_alpha (scaled_rect, 1.0);
}
+ GST_RECTANGLE_UNLOCK (rectangle);
*stride = scaled_rect->stride;
return scaled_rect->pixels;