summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2009-12-24 21:59:09 (GMT)
committerWim Taymans <wim@metal.(none)>2009-12-24 21:59:09 (GMT)
commit4f9ded77422bc4a8721c0a9305aab81717486fb1 (patch)
tree20415717d388058d67e00c64cf54748828a97532
parent0620797a18b3cf72a69b64d25332ef0be719f223 (diff)
videomixer: scale and clamp
Scale and clamp to the max alpha values.
-rw-r--r--gst/videomixer/blend_ayuv.c8
-rw-r--r--gst/videomixer/blend_bgra.c6
-rw-r--r--gst/videomixer/blend_i420.c2
-rw-r--r--gst/videomixer/blend_rgb.c2
4 files changed, 9 insertions, 9 deletions
diff --git a/gst/videomixer/blend_ayuv.c b/gst/videomixer/blend_ayuv.c
index e86b3be..af5f174 100644
--- a/gst/videomixer/blend_ayuv.c
+++ b/gst/videomixer/blend_ayuv.c
@@ -185,7 +185,7 @@ gst_videomixer_blend_ayuv_ayuv (guint8 * src, gint xpos, gint ypos,
gint src_width, gint src_height, gdouble src_alpha,
guint8 * dest, gint dest_width, gint dest_height)
{
- gint alpha, b_alpha;
+ gint alpha, s_alpha;
gint i, j;
gint src_stride, dest_stride;
gint src_add, dest_add;
@@ -194,7 +194,7 @@ gst_videomixer_blend_ayuv_ayuv (guint8 * src, gint xpos, gint ypos,
src_stride = src_width * 4;
dest_stride = dest_width * 4;
- b_alpha = (gint) (src_alpha * 255);
+ s_alpha = CLAMP ((gint) (src_alpha * 256), 0, 256);
/* adjust src pointers for negative sizes */
if (xpos < 0) {
@@ -222,7 +222,7 @@ gst_videomixer_blend_ayuv_ayuv (guint8 * src, gint xpos, gint ypos,
for (i = 0; i < src_height; i++) {
for (j = 0; j < src_width; j++) {
- alpha = (src[0] * b_alpha) >> 8;
+ alpha = (src[0] * s_alpha) >> 8;
BLEND_MODE (dest[1], dest[2], dest[3], src[1], src[2], src[3],
alpha, Y, U, V);
dest[0] = 0xff;
@@ -254,7 +254,7 @@ gst_videomixer_blend_ayuv_ayuv_mmx (guint8 * src, gint xpos, gint ypos,
src_stride = src_width * 4;
dest_stride = dest_width * 4;
- b_alpha = (gint) (src_alpha * 255);
+ b_alpha = CLAMP ((gint) (src_alpha * 255), 0, 255);
/* adjust src pointers for negative sizes */
if (xpos < 0) {
diff --git a/gst/videomixer/blend_bgra.c b/gst/videomixer/blend_bgra.c
index 279a179..8636e0a 100644
--- a/gst/videomixer/blend_bgra.c
+++ b/gst/videomixer/blend_bgra.c
@@ -32,7 +32,7 @@ gst_videomixer_blend_##name##_##name (guint8 * src, gint xpos, gint ypos, \
gint src_width, gint src_height, gdouble src_alpha, \
guint8 * dest, gint dest_width, gint dest_height) \
{ \
- gint alpha, b_alpha; \
+ gint alpha, s_alpha; \
gint i, j; \
gint src_stride, dest_stride; \
gint src_add, dest_add; \
@@ -41,7 +41,7 @@ gst_videomixer_blend_##name##_##name (guint8 * src, gint xpos, gint ypos, \
src_stride = src_width * 4; \
dest_stride = dest_width * 4; \
\
- b_alpha = (gint) (src_alpha * 255); \
+ s_alpha = CLAMP ((gint) (src_alpha * 256), 0, 256); \
\
/* adjust src pointers for negative sizes */ \
if (xpos < 0) { \
@@ -69,7 +69,7 @@ gst_videomixer_blend_##name##_##name (guint8 * src, gint xpos, gint ypos, \
\
for (i = 0; i < src_height; i++) { \
for (j = 0; j < src_width; j++) { \
- alpha = (src[a] * b_alpha) >> 8; \
+ alpha = (src[a] * s_alpha) >> 8; \
BLEND_MODE (dest[b], dest[g], dest[r], src[b], src[g], src[r], \
B, G, R, alpha); \
dest[b] = B; \
diff --git a/gst/videomixer/blend_i420.c b/gst/videomixer/blend_i420.c
index d9412a0..dcf55f3 100644
--- a/gst/videomixer/blend_i420.c
+++ b/gst/videomixer/blend_i420.c
@@ -209,7 +209,7 @@ gst_i420_do_blend (guint8 * src, guint8 * dest,
return;
}
- b_alpha = (gint) (src_alpha * 255);
+ b_alpha = CLAMP ((gint) (src_alpha * 255), 0, 255);
for (i = 0; i < src_height; i++) {
for (j = 0; j < src_width; j++) {
diff --git a/gst/videomixer/blend_rgb.c b/gst/videomixer/blend_rgb.c
index 9a7a39c..d6a2451 100644
--- a/gst/videomixer/blend_rgb.c
+++ b/gst/videomixer/blend_rgb.c
@@ -45,7 +45,7 @@ gst_videomixer_blend_##name##_##name (guint8 * src, gint xpos, gint ypos, \
src_stride = GST_ROUND_UP_4 (src_width * bpp); \
dest_stride = GST_ROUND_UP_4 (dest_width * bpp); \
\
- b_alpha = (gint) (src_alpha * 255); \
+ b_alpha = CLAMP ((gint) (src_alpha * 255), 0, 255); \
\
/* adjust src pointers for negative sizes */ \
if (xpos < 0) { \