MMX speedup for Floyd Steinberg error diffusion
- From: rep_movsd <spamtrap@xxxxxxxxxx>
- Date: Mon, 5 May 2008 04:04:14 -0700 (PDT)
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
.
- Follow-Ups:
- Re: MMX speedup for Floyd Steinberg error diffusion
- From: Maarten Kronenburg
- Re: MMX speedup for Floyd Steinberg error diffusion
- Prev by Date: Get the FAQs
- Next by Date: Having trouble posting?
- Previous by thread: Get the FAQs
- Next by thread: Re: MMX speedup for Floyd Steinberg error diffusion
- Index(es):
Relevant Pages
|