MMX speedup for Floyd Steinberg error diffusion



Hi

I recently implemented an animated GIF encoder to convert any video
into a GIF ( I know it doesnt seem really useful, but thats what the
client wanted ).

I implemented floyd steinberg error diffusion to improve quality of
the quantized output.

The code is in Visual C++ and I use 32 bpp pixels for ease in
processing.

The diffusion process takes up about 1/2 the time required to encode a
frame and it seems to be the right place to optimize.

Heres how the algorithm works - pseudocode

for each pixel in the image
{
palColor = Get color in palette thats nearest to current pixel
get signed difference between actual color and palette color for
R G and B components
add difference (with unsigned saturation) to surrounding pixels
with a weightage :
EAST -> 7/16
SOUTHWEST -> 5/16
SOUTH -> 3/16
SOUTHEAST -> 1/16
}


Now I thought I may be able to do this fast with MMX , subtracting the
3 r, g, b bytes at once ( I use 32 bpp pixels, but alpha channel is
ignored )

I can do a packed subtract to get the differences, but thereafter the
multiplication and shifting(for division by 16) seem to be impossible.

Moreover, how can one do a unsigned saturated addition of signed
difference values to the unsigned pixel values?

Any ideas anyone?

Vivek

.



Relevant Pages

  • Re: MMX speedup for Floyd Steinberg error diffusion
    ... I recently implemented an animated GIF encoder to convert any video ... add difference (with unsigned saturation) to surrounding pixels ... Then you copy and shift left and add/subtract, ...
    (comp.lang.asm.x86)
  • Re: Desperately needing direction with saving images under different compression/quality schemes
    ... KB's and open it in ms paint, then save it without making any changes ... further changes to pixels, maybe just a few bytes of changes in headers ... but thats it). ... background is not in image processing, i am not sure what these changes ...
    (sci.image.processing)
  • Re: HDTV a waste of money,
    ... should be, far enough away such that you cannot see the pixels, then ... Thats a good definition of appropriate viewing distance, ... I know cos I saw one in Dixons!! ...
    (uk.tech.digital-tv)
  • Re: HDTV a waste of money,
    ... should be, far enough away such that you cannot see the pixels, then ... Thats a good definition of appropriate viewing distance, ... Or a high definition picture which would allow them to sit much closer. ...
    (uk.tech.digital-tv)
  • Re: Masked Blitting of 232-bit BMP images.
    ... >> don't overwrite the destination,meaning don't touch the destination ... >> corresponding to those pixels. ... thats what I needed I guess. ...
    (microsoft.public.win32.programmer.gdi)