Re: [Gimp-developer] [Patch] Speed up blending code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



   From: Daniel Egger <de@xxxxxxxxxx>
   Date: Sun, 27 Feb 2005 16:03:14 +0100

   this is my suggested patch for getting the speeds improvements
   as mentioned in the other thread by having a thread-local PRNG
   initialized with a seed from the still existing blend tool local
   RNG.

   It looks bigger than it is because I took the liberty to remove
   the nasty special casing on the existence of the RNG inside the
   innermost loop because we now have it outside already.

   There seems to be more room for obvious optimisations in the
   loops. Also I would recommend splitting the two cases into
   two separate functions to make the code easier to read, and
   remove more conditionals.

   PS: If this is okay, I'd do exactly the same for the gray
   blending stuff...

In addition to being very slow, this will also yield noisy results.
There are a lot of dither algorithms that are both much faster and
yield better results.  While you may not need full-blown
Floyd-Steinberg or EvenTone dithering for this purpose (and they're
hard to use in a multi-threaded fashion), a simple dither matrix is
fast, free of most artifacts, trivial to parallelize (you're only
reading from the matrix, so no serialization is necessary), and
reasonably low noise.

In Gutenprint we have several precomputed matrices, designed for 1:1,
2:1, and 4:1 aspect ratios.  You would need only a 1:1 ratio matrix.
Also, our matrices are large (about 64K elements each, since they need
16 bit resolution), but you wouldn't need anything that big.  There's
a very simple iterated matrix that can generate any desired power of 2
matrix size (which makes for even faster lookup), but it does suffer
from patterning.  That may not matter for this purpose, since the
steps are very small.

We use the same matrix for all color channels, but offset the starting
address for each channel to decorrelate the channels.

Let me know if you're interested.

-- 
Robert Krawitz                                     <rlk@xxxxxxxxxxxx>

Tall Clubs International  --  http://www.tall.org/ or 1-888-IM-TALL-2
Member of the League for Programming Freedom -- mail lpf@xxxxxxxxxxxx
Project lead for Gimp Print   --    http://gimp-print.sourceforge.net

"Linux doesn't dictate how I work, I dictate how Linux works."
--Eric Crampton

[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux