changeset 32226:808e9d7eef5d

vf_ass: skip alpha blending for pixels where alpha is zero. On a test case, it speeds up the blending of about 9%.
author cigaes
date Sat, 18 Sep 2010 19:13:03 +0000
parents 8ebdc8466b2f
children bc13646041dd
files libmpcodecs/vf_ass.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vf_ass.c	Sat Sep 18 17:40:14 2010 +0000
+++ b/libmpcodecs/vf_ass.c	Sat Sep 18 19:13:03 2010 +0000
@@ -317,7 +317,10 @@
     dstv = vf->priv->planes[2] + dst_x + dst_y * vf->priv->outw;
     for (i = 0; i < bitmap_h; ++i) {
         for (j = 0; j < bitmap_w; ++j) {
-            unsigned k = ((unsigned) src[j]) * opacity / 255;
+            unsigned k = src[j];
+            if (!k)
+                continue;
+            k = k * opacity / 255;
             dsty[j] = (k * y + (255 - k) * dsty[j]) / 255;
             dstu[j] = (k * u + (255 - k) * dstu[j]) / 255;
             dstv[j] = (k * v + (255 - k) * dstv[j]) / 255;