Re: MMX speedup for Floyd Steinberg error diffusion



Jim Leonard wrote:
On May 8, 11:00 am, Terje Mathisen <spamt...@xxxxxxxxxx> wrote:
How does it handle the corner/edge cases?

I.e. the last pixel on a scan line has no down-right neighbor, the first
pixel has no down-left and the last scanline has nothing below at all!

The "off-screen" pixels as ignored, because they do not contribute to
the error information distributed to the visible pixels. A dumb but
easy way to implement this without conditional branches every
iteration (to check if you are operating on off-screen pixels) is to
operate on a bitmap that has a 1-pixel border around the right/left/
bottom sides.

OK, that's fast at least. :-)

Anyway, to speed up the dithering stage I would use MMX/SSE and work on
multiple lines in parallel, keeping the intermediate results in
registers until we're finished with them.

I don't see how you'd implement that, because the very top-left pixel
can conceivably promote enough error, distributed downward, to affect
the bottom-right pixel...

Sure, but that's no problem: The SIMD registers works as a rectangular cache block around the current pixel, avoiding the need to write to memory between the multiple updates to each surrounding pixel.

You do need to keep one extra line in a register, just to accumulate the error terms from the line above.

Terje

--
- <Terje.Mathisen@xxxxxxxxxxxxx>
"almost all programming can be viewed as an exercise in caching"

.



Relevant Pages

  • Re: ASCII + X
    ... I did not like the brightened bottom line to be ... My change was to shift the capital M one pixel right. ... also increase the margin on the LHS to match that larger right hand ... I do like the darkening effect. ...
    (rec.games.roguelike.development)
  • Re: Adobe Photoshop CS2 9.0, Free Turorial?
    ... this will add 1 pixel to the canvas and leave your image in the middle. ... You can then add a new bottom most layer and fill it with any color you want the ... How do people have sticker cut out nice and perfect? ...
    (rec.games.pinball)
  • Re: mouse dissapears off screen when moved right
    ... for that one line of pixels on the right or single pixel on the bottom. ... > show the 1 pixel portion of the cursor by default. ... >>>pointer is hidden off the screen. ...
    (microsoft.public.windowsxp.hardware)
  • Re: ASCII + X
    ... I did the right hand side of the main screen box one pixel inside as ... I did not like the brightened bottom line to be ... in that mock up only the stat window has the new dark borders. ...
    (rec.games.roguelike.development)
  • How to Tell When Man Page Changes?
    ... I like to read lengthy man pages off dead trees instead of pixels. ... paper copy is from FreeBSD 4.6, and has a date of September 25, 1999. ... most recent pixel copy from FreeBSD-STABLE says FreeBSD 4.8, ... Is the date at the bottom of the page supposed to be the date of last ...
    (freebsd-questions)