#### Archived

This topic is now archived and is closed to further replies.

# MMX Saturation in 16bpp

This topic is 6917 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi all! Im just finished with by 32bpp blitroutines using MMX. Saturation, Alphablending etc is pretty easy to do in 32bpp, but how can you get advantage of MMX using 16bpp? If anyone could give me a hint adding two pixles together in 16bpp with saturation and MMX I would be very grateful! Cheers / Tooon

##### Share on other sites
OK, will not packed word aremetic just make sure that
the word it self wont overflow? I need an algoritm wich adds each attribute of R,G,B so R cant for example be larger than 32, green 64 etc etc...

if we have the color (R=31, G=0, B=31) in a word, adding color (R=31,G=63,B=31) should result in (R=31, G=63, B=31).

In 32bpp each attribute is stored in a specific byte and has
a max value of 255, wich makes this procedure easy to accomplish (paddusb).

Don''t know if I should bother using MMX for this, or if it will just be as fast using "normal" asm methods.

/ Tooon

##### Share on other sites
Ah, I didn't read your post carefully enough. I couldn't think of an elegant way either. Here's my best guess.

You'll have to pardon quasi-MMX

[Assume 5 - 5 - 5 ]

movq MM0,[ESI]movq MM2,MM0movq MM3,MM0movq MM4,MM0and MM2, REDFILTERPSHRB MM3,5and MM3, REDFILTER //The green colorsPSHRB MM4, 10and MM4, REDFILTER //The blue colors

At this point, all the colors are low-bit-aligned in their word. Each register (MM2 - MM4) contains 4 pixels, each with a single color component.

Edited by - WMiller on May 10, 2000 5:02:32 PM

• 10
• 13
• 52
• 11
• 15