changeset 9110:7924a60d833b

This is a simple patch to change the alpha blending code in bmovl to use integers instead of floating point. It speeds it up by about 400% meaning that it's now possible to apply alpha blending to a whole 1024x768 image on my 1266MHz PIII. Jonas Jensen <jbj@knef.dk>
author arpi
date Sun, 26 Jan 2003 17:42:24 +0000
parents 09841407f2ec
children 0f3f6ad5fcde
files libmpcodecs/vf_bmovl.c
diffstat 1 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vf_bmovl.c	Sun Jan 26 16:36:06 2003 +0000
+++ b/libmpcodecs/vf_bmovl.c	Sun Jan 26 17:42:24 2003 +0000
@@ -395,11 +395,20 @@
 						dmpi->planes[2][pos] = vf->priv->bitmap.v[pos];
 					}
 				} else { // Alphablended pixel
-					dmpi->planes[0][pos] = (dmpi->planes[0][pos]*(1.0-(alpha/255.0))) + (vf->priv->bitmap.y[pos]*(alpha/255.0));
+					dmpi->planes[0][pos] = 
+						((255 - alpha) * (int)dmpi->planes[0][pos] + 
+						alpha * (int)vf->priv->bitmap.y[pos]) >> 8;
+					
 					if ((ypos%2) && (xpos%2)) {
 						pos = ( (ypos/2) * dmpi->stride[1] ) + (xpos/2);
-						dmpi->planes[1][pos] = (dmpi->planes[1][pos]*(1.0-(alpha/255.0))) + (vf->priv->bitmap.u[pos]*(alpha/255.0));
-						dmpi->planes[2][pos] = (dmpi->planes[2][pos]*(1.0-(alpha/255.0))) + (vf->priv->bitmap.v[pos]*(alpha/255.0));
+
+						dmpi->planes[1][pos] = 
+							((255 - alpha) * (int)dmpi->planes[1][pos] + 
+							alpha * (int)vf->priv->bitmap.u[pos]) >> 8;
+						
+						dmpi->planes[2][pos] = 
+							((255 - alpha) * (int)dmpi->planes[2][pos] + 
+							alpha * (int)vf->priv->bitmap.v[pos]) >> 8;
 					}
 			    }
 			} // for xpos