[cairo] rewriting libpixman
Jeff Muizelaar
jeff at infidigm.net
Sun Apr 1 21:05:32 PDT 2007
On Fri, Mar 30, 2007 at 07:26:59PM -0400, James Cloos wrote:
> >> The bit-copying "approximation" is exactly equivalent to
> >> multiplying by 255 and dividing by 31. There's no point in
> >> implementing both -- stick with the bit copy, since it's more
> >> efficient.
>
> Jeff> (x << 3) | (x >> 2) is not equivalent to (255*x + 15)/31
> Jeff> for x = {3, 7, 24, 28}
>
> As I recall from doing some analysis during the float thread, that
> should be multiplying by 256 and dividing by 31. Ie, always multiply
> by 2^${num_bits} and divide by ${Int_max} to get reversable conversions
> well centered w/in the sample resolution(s).
I'm confused by this. For example, (256*31+15)/31 gives 256 which
overflows..
-Jeff
More information about the cairo
mailing list