Quoting Sven Neumann ([EMAIL PROTECTED]):
> Hi,
> 
> Felix recently suggested a change to SET_ALPHA_PIXEL_RGB32 in 
> DirectFB/src/gfx/generic/generic.h) that resulted in a  nice 
> performance improvement and that we are now using. I tried to 
> do the same optimization to SET_ALPHA_PIXEL_RGB16 today and
> here's what I have come up with:
> 
> #define SET_ALPHA_PIXEL_RGB16(d,r,g,b,a) \
>      if (a) {\
>           if (a == 0xFF) {\
>                *(d) = (((r)&0xf8) << 8) | (((g)&0xfc) << 3) | (((b)&0xf8) >> 3);\
>           }\
>           else {\
>                __u32 pixel;\
>                __u8  s=((a)>>2)+1;\
>              __u8 s1=(64-s);\
>                \
>                pixel = *(d);\
>              pixel = (((((pixel & 0x0000f81f) * s1) + ((((r)<<8) | ((b)>>3)) * s)) & 
>0x003e07c0) + \
>                       ((((pixel & 0x000007e0) * s1) +  (((g)<<3)             * s)) & 
>0x0001f800)) >> 6; \
>                *(d) = pixel;\
>           }\
>      }
> 
> This code is indeed faster (>15%), but the output is not perfect 
> (red bits seem to pollute the blue bits somehow). I have stared at 
> this code for too long and can't find what I'm doing wrong here. 
> Perhaps someone out there has an idea?

Red and blue channel have 5 bit, the green channel has 6 bit.
You have to treat them in a different way.
You made s have 6 bit, you also need one with 5 bit for red and blue channel.
The green then has to be shifted 6 to the right (as you already do),
but the red and blue have to shifted 5 to the right after being multiplied
by the 5 bit s.

-- 
Denis Oliver Kropp
( convergence           )
( integrated media gmbh )


-- 
Info:  To unsubscribe send a mail to [EMAIL PROTECTED] with 
"unsubscribe directfb-dev" as subject.

Reply via email to