summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2009-12-24 21:50:31 (GMT)
committerWim Taymans <wim@metal.(none)>2009-12-24 21:50:31 (GMT)
commit0620797a18b3cf72a69b64d25332ef0be719f223 (patch)
treed9372946fd35414432add18292fa90d3f2e19788
parenta65240d1c148599e431bf2f0892dfaa507e73ae6 (diff)
alpha: scale and clamp alpha to its full extend
Convert the alpha value to 0->255 when setting and to 0->256 when using as a scaling factor. This makes sure we can reach the full opacity value of 0xff in all cases.
-rw-r--r--gst/alpha/gstalpha.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/gst/alpha/gstalpha.c b/gst/alpha/gstalpha.c
index 01bcbde..6aa1f8a 100644
--- a/gst/alpha/gstalpha.c
+++ b/gst/alpha/gstalpha.c
@@ -210,6 +210,7 @@ gst_alpha_base_init (gpointer g_class)
GST_DEBUG_CATEGORY_INIT (gst_alpha_debug, "alpha", 0,
"alpha - Element for adding alpha channel to streams");
}
+
static void
gst_alpha_class_init (GstAlphaClass * klass)
{
@@ -347,6 +348,7 @@ gst_alpha_set_property (GObject * object, guint prop_id,
break;
}
}
+
static void
gst_alpha_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
@@ -470,12 +472,12 @@ static void
gst_alpha_set_ayuv (guint8 * src, guint8 * dest, gint width, gint height,
gdouble alpha)
{
- gint b_alpha = (gint) (alpha * 255);
+ gint s_alpha = CLAMP ((gint) (alpha * 256), 0, 256);
gint y, x;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
- *dest++ = (*src++ * b_alpha) >> 8;
+ *dest++ = (*src++ * s_alpha) >> 8;
*dest++ = *src++;
*dest++ = *src++;
*dest++ = *src++;
@@ -487,7 +489,7 @@ static void
gst_alpha_set_i420 (guint8 * src, guint8 * dest, gint width, gint height,
gdouble alpha)
{
- gint b_alpha = (gint) (alpha * 255);
+ gint b_alpha = CLAMP ((gint) (alpha * 255), 0, 255);
guint8 *srcY;
guint8 *srcU;
guint8 *srcV;