Re: MMX speedup for Floyd Steinberg error diffusion
- From: Terje Mathisen <spamtrap@xxxxxxxxxx>
- Date: Tue, 13 May 2008 20:56:48 +0200
rep_movsd wrote:
On May 13, 11:07 am, Terje Mathisen <spamt...@xxxxxxxxxx> wrote:OK, here's the brute force way:Novosad, Stephan R. wrote:Terje wrote:
> To do a mathematically perfect job I would start with a 5:5:5 (32 K) or
> 4:4:4 (4 K) table, with each entry being the start of a list of all the
> possible palette entries for that entry:
I tried to implement that, but I just cant get how to initialize the
lists...
Can you explain how?
1. For each 4:4:4 (or 5:5:5) table entry calculate the closest palette color, assuming all the truncated bits are zero.
2. Do the same assuming 1111 bits got truncated.
You need to repeat this operation 8 times, for each possible combination of 0000/1111 on each of the three color axes.
On each iteration you note which entry was closest, most of the time this will be the same palette color, which should be written to the lookup table.
If, otoh, you end up with two or more candidates depending upon the value of the truncated bits, then you know that for this lookup value you need to check them all.
BTW, there's at least one possible bug here: If you have three palette colors _very_ close to each other along at least one color axis, then it is possible that the setup algorithm shown above would only locate the two outliers and not the one in the middle of them!
A q&d workaround would be to always generate a search list if multiple palette colors show a distance that's less than the truncated lookup table bits.
The next problem is how to make this usefully fast:
Instead of iterating multiple times over the entire lookup table, we can (as another poster suggested?) start by inserting each pal color into the proper lookup table slot (noting any collisions!), then for each of them fill the surrounding slots at distance 1, then 2, then 3, stopping as soon as you hit a previously filled entry (and change that entry to a list). This breaks if multiple pal colors map to the same initial lookup table slot, since you won't do any filling of the combined colors.
Terje
--
- <Terje.Mathisen@xxxxxxxxxxxxx>
"almost all programming can be viewed as an exercise in caching"
.
- Follow-Ups:
- Re: MMX speedup for Floyd Steinberg error diffusion
- From: Wolfgang Kern
- Re: MMX speedup for Floyd Steinberg error diffusion
- References:
- Re: MMX speedup for Floyd Steinberg error diffusion
- From: Novosad, Stephan R.
- Re: MMX speedup for Floyd Steinberg error diffusion
- From: Terje Mathisen
- Re: MMX speedup for Floyd Steinberg error diffusion
- From: rep_movsd
- Re: MMX speedup for Floyd Steinberg error diffusion
- Prev by Date: Re: MMX speedup for Floyd Steinberg error diffusion
- Next by Date: Re: MMX speedup for Floyd Steinberg error diffusion
- Previous by thread: Re: MMX speedup for Floyd Steinberg error diffusion
- Next by thread: Re: MMX speedup for Floyd Steinberg error diffusion
- Index(es):
Relevant Pages
|