summaryrefslogtreecommitdiffstats
path: root/gst/videomixer
diff options
context:
space:
mode:
authorEdward Hervey <bilboed@bilboed.com>2009-06-30 12:43:04 +0200
committerEdward Hervey <bilboed@bilboed.com>2009-07-10 14:37:13 +0200
commitb02949faeb1d85582c8a42450f83b80cd81329b8 (patch)
tree88c95fd8a5fb267495cfc77979f9bfa4248a3a3e /gst/videomixer
parent3c88249d48870b826fd89d287ee6d46b284c4f45 (diff)
videomixer: I420 mode: Add fast path for 0.0 and 1.0 alpha
If the source alpha is 0.0, we take nothing. If the source alpha is 1.0, we overwrite everything.
Diffstat (limited to 'gst/videomixer')
-rw-r--r--gst/videomixer/blend_i420.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gst/videomixer/blend_i420.c b/gst/videomixer/blend_i420.c
index e24d0ad4..015f9a10 100644
--- a/gst/videomixer/blend_i420.c
+++ b/gst/videomixer/blend_i420.c
@@ -190,6 +190,24 @@ gst_i420_do_blend (guint8 * src, guint8 * dest,
gint dest_width, gdouble src_alpha)
{
int i, j;
+
+ /* If it's completely transparent... we just return */
+ if (G_UNLIKELY (src_alpha == 0.0)) {
+ GST_INFO ("Fast copy (alpha == 0.0)");
+ return;
+ }
+
+ /* If it's completely opaque, we do a fast copy */
+ if (G_UNLIKELY (src_alpha == 1.0)) {
+ GST_INFO ("Fast copy (alpha == 1.0)");
+ for (i = 0; i < src_height; i++) {
+ memcpy (dest, src, src_width);
+ src += src_stride;
+ dest += dest_stride;
+ }
+ return;
+ }
+
for (i = 0; i < src_height; i++) {
for (j = 0; j < src_width; j++) {
*dest = src_alpha * (*src) + (1. - src_alpha) * (*dest);