From e008f62627e01a064db9f73f16fb3c2e9b198f3f Mon Sep 17 00:00:00 2001 From: reimar Date: Sat, 6 Feb 2010 19:18:09 +0000 Subject: [PATCH] Make mkalpha function simpler, faster and more correct. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30523 b3059339-0415-0410-9bf9-f77b7e298cf2 --- spudec.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/spudec.c b/spudec.c index 6241c99e0c..8be30e1e56 100644 --- a/spudec.c +++ b/spudec.c @@ -175,14 +175,9 @@ static inline int mkalpha(int i) { /* In mplayer's alpha planes, 0 is transparent, then 1 is nearly opaque upto 255 which is transparent */ - switch (i) { - case 0xf: - return 1; - case 0: - return 0; - default: - return (0xf - i) << 4; - } + // extend 4 -> 8 bit + i |= i << 4; + return (uint8_t)(-i); } /* Cut the sub to visible part */