[Gllug] Faster maths?
salsaman
salsaman at xs4all.nl
Fri Mar 9 16:25:58 UTC 2007
Richard Jones wrote:
>On Thu, Mar 08, 2007 at 11:11:26PM +0000, Adrian McMenamin wrote:
>
>
>>I have some perl which indexes and dithers a PNG image to a 256 colour
>>palette.
>>
>>The indexing is pretty fast - a 59K (compressed) PNG image on a 4000
>>BogoMIPS machine in about a second.
>>
>>But I turn on dithering it takes half an hour!!
>>
>>The bottleneck appears to be calculating the distance of a point in
>>colourspace (ie the original colour + diffused error) from any point in
>>the palette (to find the closest match).
>>
>>I don't use sqrt - just compare square with square (and save a match so
>>don't have to do the same lookup twice).
>>
>>
>
>There's a fast, high-quality implementation of this algorithm in the
>source code to xv. Unfortunately it has a non-free license ...
>
>Rich.
>
>
>
Well, I already posted one algorithm you could use: 3d cube mapping. But
if you want to ignore that and calculate the inverse sqrt quickly, use
the hack from ID software:
http://www.codemaestro.com/reviews/review00000105.html
Gabriel.
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list