From 089d9d9dba0fee231f2a71b6cd79cd105faa8383 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 11 Dec 2009 12:35:59 +0100 Subject: [PATCH] videomixer: Don't do floating point math in the inner processing loop for I420 blending --- gst/videomixer/blend_i420.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gst/videomixer/blend_i420.c b/gst/videomixer/blend_i420.c index 46acb70..fb672f6 100644 --- a/gst/videomixer/blend_i420.c +++ b/gst/videomixer/blend_i420.c @@ -190,6 +190,7 @@ gst_i420_do_blend (guint8 * src, guint8 * dest, gint dest_width, gdouble src_alpha) { int i, j; + gint b_alpha; /* If it's completely transparent... we just return */ if (G_UNLIKELY (src_alpha == 0.0)) { @@ -208,9 +209,11 @@ gst_i420_do_blend (guint8 * src, guint8 * dest, return; } + b_alpha = (gint) (src_alpha * 255); + for (i = 0; i < src_height; i++) { for (j = 0; j < src_width; j++) { - *dest = src_alpha * (*src) + (1. - src_alpha) * (*dest); + *dest = (b_alpha * (*src) + (255 - b_alpha) * (*dest)) >> 16; dest++; src++; } -- 2.7.4