changeset 28188:06dbef90389e

Simplify and comment spudec bilinear scaling code
author reimar
date Thu, 01 Jan 2009 11:33:46 +0000
parents 54c35115639c
children dd53119e77c8
files spudec.c
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/spudec.c	Thu Jan 01 11:23:32 2009 +0000
+++ b/spudec.c	Thu Jan 01 11:33:46 2009 +0000
@@ -737,9 +737,10 @@
   spu->scaled_image[scaled] = (color[0] * scale[0] + color[1] * scale[1] + color[2] * scale[2] + color[3] * scale[3])>>24;
   spu->scaled_aimage[scaled] = (scale[0] + scale[1] + scale[2] + scale[3]) >> 16;
   if (spu->scaled_aimage[scaled]){
-    spu->scaled_aimage[scaled] = 256 - spu->scaled_aimage[scaled];
-    if(spu->scaled_aimage[scaled] + spu->scaled_image[scaled] > 255)
-      spu->scaled_image[scaled] = 256 - spu->scaled_aimage[scaled];
+    // ensure that MPlayer's simplified alpha-blending can not overflow
+    spu->scaled_image[scaled] = FFMIN(spu->scaled_image[scaled], spu->scaled_aimage[scaled]);
+    // convert to MPlayer-style alpha
+    spu->scaled_aimage[scaled] = -spu->scaled_aimage[scaled];
   }
 }