[mmx]简单的饱和运算问题。。
// 计算亮度的MMX实现 { BYTE liangdu = 50; BYTE a = 100; // 0x64 BYTE r = 110; // 0x6E BYTE g = 120; // 0x78 BYTE b = 130; // 0x82 UINT srcPixel = 0x646E7882 UINT outPixel = 0; // 0xAARRGGBB:0x323C4650 __asm { movd mm0, b movd mm1, g movd mm2, r movd mm3, a punpcklbw mm0, mm1 ; mm0:0xggbb punpcklbw mm2, mm3 ; mm2:0xaarr punpcklwd mm0, mm2 ; mm0:0xaarrggbb movd mm4, liangdu ; mm4:0x亮 punpcklbw mm4, mm4 ; mm4:0x亮亮 punpcklwd mm4, mm4 ; mm4:0x亮亮亮亮 psubusb mm0, mm4 ; 将mm0和mm4按字节进行饱和减 movd dword ptr[outPixel], mm0 ; 拷贝结果 EMMS } }