summaryrefslogtreecommitdiffstats
path: root/gst/shapewipe
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2009-05-29 21:07:26 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2009-05-29 21:07:26 +0200
commit01b8bacd1b1d1c0793db475fb593cb705143e981 (patch)
tree90f6aeb8bd428923772fa2f11235b33752f0ca5d /gst/shapewipe
parent332dae71981747841370a239b3b557d5ecb1afb9 (diff)
downloadgst-plugins-bad-01b8bacd1b1d1c0793db475fb593cb705143e981.tar.gz
gst-plugins-bad-01b8bacd1b1d1c0793db475fb593cb705143e981.tar.bz2
gst-plugins-bad-01b8bacd1b1d1c0793db475fb593cb705143e981.zip
shapewipe: Adjust border to still have everything transparent at 1.0 and the other way around
Diffstat (limited to 'gst/shapewipe')
-rw-r--r--gst/shapewipe/gstshapewipe.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/gst/shapewipe/gstshapewipe.c b/gst/shapewipe/gstshapewipe.c
index 69155990..ec33f0a7 100644
--- a/gst/shapewipe/gstshapewipe.c
+++ b/gst/shapewipe/gstshapewipe.c
@@ -556,14 +556,24 @@ gst_shape_wipe_blend_16 (GstShapeWipe * self, GstBuffer * inbuf,
guint i, j;
guint mask_increment = GST_ROUND_UP_2 (self->width) - self->width;
gfloat position = self->mask_position;
- gfloat low = MAX (0.0, position - (self->mask_border / 2.0));
- gfloat high = MIN (1.0, position + (self->mask_border / 2.0));
+ gfloat low = position - (self->mask_border / 2.0f);
+ gfloat high = position + (self->mask_border / 2.0f);
+
+ if (low < 0.0f) {
+ high = 0.0f;
+ low = 0.0f;
+ }
+
+ if (high > 1.0f) {
+ low = 1.0f;
+ high = 1.0f;
+ }
for (i = 0; i < self->height; i++) {
for (j = 0; j < self->width; j++) {
- gfloat in = *mask / 65535.0;
+ gfloat in = *mask / 65535.0f;
- if (in <= low) {
+ if (in < low) {
output[0] = 0x00; /* A */
output[1] = 0x00; /* Y */
output[2] = 0x80; /* U */
@@ -574,7 +584,7 @@ gst_shape_wipe_blend_16 (GstShapeWipe * self, GstBuffer * inbuf,
output[2] = input[2]; /* U */
output[3] = input[3]; /* V */
} else {
- gfloat val = 255 * ((in - low) / (high - low));
+ gfloat val = 255.0f * ((in - low) / (high - low));
output[0] = CLAMP (val, 0, 255); /* A */
output[1] = input[1]; /* Y */
@@ -602,14 +612,24 @@ gst_shape_wipe_blend_8 (GstShapeWipe * self, GstBuffer * inbuf,
guint i, j;
guint mask_increment = GST_ROUND_UP_4 (self->width) - self->width;
gfloat position = self->mask_position;
- gfloat low = MAX (0.0, position - (self->mask_border / 2.0));
- gfloat high = MIN (1.0, position + (self->mask_border / 2.0));
+ gfloat low = position - (self->mask_border / 2.0f);
+ gfloat high = position + (self->mask_border / 2.0f);
+
+ if (low < 0.0f) {
+ high = 0.0f;
+ low = 0.0f;
+ }
+
+ if (high > 1.0f) {
+ low = 1.0f;
+ high = 1.0f;
+ }
for (i = 0; i < self->height; i++) {
for (j = 0; j < self->width; j++) {
- gfloat in = *mask / 255.0;
+ gfloat in = *mask / 255.0f;
- if (in <= low) {
+ if (in < low) {
output[0] = 0x00; /* A */
output[1] = 0x00; /* Y */
output[2] = 0x80; /* U */
@@ -620,7 +640,7 @@ gst_shape_wipe_blend_8 (GstShapeWipe * self, GstBuffer * inbuf,
output[2] = input[2]; /* U */
output[3] = input[3]; /* V */
} else {
- gfloat val = 255 * ((in - low) / (high - low));
+ gfloat val = 255.0f * ((in - low) / (high - low));
output[0] = CLAMP (val, 0, 255); /* A */
output[1] = input[1]; /* Y */