rlm@1: #include "../Port.h" rlm@1: rlm@1: extern u32 RGB_LOW_BITS_MASK; rlm@1: rlm@1: void MotionBlur(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, rlm@1: u8 *dstPtr, u32 dstPitch, int width, int height) rlm@1: { rlm@1: u8 *nextLine, *finish; rlm@1: u32 colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16)); rlm@1: u32 lowPixelMask = RGB_LOW_BITS_MASK; rlm@1: rlm@1: nextLine = dstPtr + dstPitch; rlm@1: rlm@1: do rlm@1: { rlm@1: u32 *bP = (u32 *) srcPtr; rlm@1: u32 *xP = (u32 *) deltaPtr; rlm@1: u32 *dP = (u32 *) dstPtr; rlm@1: u32 *nL = (u32 *) nextLine; rlm@1: u32 currentPixel; rlm@1: u32 nextPixel; rlm@1: u32 currentDelta; rlm@1: u32 nextDelta; rlm@1: rlm@1: finish = (u8 *) bP + ((width + 2) << 1); rlm@1: nextPixel = *bP++; rlm@1: nextDelta = *xP++; rlm@1: rlm@1: do rlm@1: { rlm@1: currentPixel = nextPixel; rlm@1: currentDelta = nextDelta; rlm@1: nextPixel = *bP++; rlm@1: nextDelta = *xP++; rlm@1: rlm@1: if (currentPixel != currentDelta) rlm@1: { rlm@1: u32 colorA, product, colorB; rlm@1: rlm@1: *(xP - 2) = currentPixel; rlm@1: #ifdef WORDS_BIGENDIAN rlm@1: colorA = currentPixel >> 16; rlm@1: colorB = currentDelta >> 16; rlm@1: #else rlm@1: colorA = currentPixel & 0xffff; rlm@1: colorB = currentDelta & 0xffff; rlm@1: #endif rlm@1: rlm@1: product = ((((colorA & colorMask) >> 1) + rlm@1: ((colorB & colorMask) >> 1) + rlm@1: (colorA & colorB & lowPixelMask))); rlm@1: rlm@1: *(dP) = product | product << 16; rlm@1: *(nL) = product | product << 16; rlm@1: rlm@1: #ifdef WORDS_BIGENDIAN rlm@1: colorA = (currentPixel & 0xffff); rlm@1: colorB = (currentDelta & 0xffff); rlm@1: #else rlm@1: colorA = currentPixel >> 16; rlm@1: colorB = currentDelta >> 16; rlm@1: #endif rlm@1: product = ((((colorA & colorMask) >> 1) + rlm@1: ((colorB & colorMask) >> 1) + rlm@1: (colorA & colorB & lowPixelMask))); rlm@1: rlm@1: *(dP + 1) = product | product << 16; rlm@1: *(nL + 1) = product | product << 16; rlm@1: } rlm@1: else rlm@1: { rlm@1: u32 colorA, product; rlm@1: rlm@1: *(xP - 2) = currentPixel; rlm@1: #ifdef WORDS_BIGENDIAN rlm@1: colorA = currentPixel >> 16; rlm@1: #else rlm@1: colorA = currentPixel & 0xffff; rlm@1: #endif rlm@1: rlm@1: product = colorA; rlm@1: rlm@1: *(dP) = product | product << 16; rlm@1: *(nL) = product | product << 16; rlm@1: #ifdef WORDS_BIGENDIAN rlm@1: colorA = (currentPixel & 0xffff); rlm@1: #else rlm@1: colorA = currentPixel >> 16; rlm@1: #endif rlm@1: product = colorA; rlm@1: rlm@1: *(dP + 1) = product | product << 16; rlm@1: *(nL + 1) = product | product << 16; rlm@1: } rlm@1: rlm@1: dP += 2; rlm@1: nL += 2; rlm@1: } rlm@1: while ((u8 *) bP < finish); rlm@1: rlm@1: deltaPtr += srcPitch; rlm@1: srcPtr += srcPitch; rlm@1: dstPtr += dstPitch << 1; rlm@1: nextLine += dstPitch << 1; rlm@1: } rlm@1: while (--height); rlm@1: } rlm@1: rlm@1: void MotionBlur32(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, rlm@1: u8 *dstPtr, u32 dstPitch, int width, int height) rlm@1: { rlm@1: u8 *nextLine, *finish; rlm@1: u32 colorMask = ~RGB_LOW_BITS_MASK; rlm@1: u32 lowPixelMask = RGB_LOW_BITS_MASK; rlm@1: rlm@1: nextLine = dstPtr + dstPitch; rlm@1: rlm@1: do rlm@1: { rlm@1: u32 *bP = (u32 *) srcPtr; rlm@1: u32 *xP = (u32 *) deltaPtr; rlm@1: u32 *dP = (u32 *) dstPtr; rlm@1: u32 *nL = (u32 *) nextLine; rlm@1: u32 currentPixel; rlm@1: u32 nextPixel; rlm@1: u32 currentDelta; rlm@1: u32 nextDelta; rlm@1: rlm@1: finish = (u8 *) bP + ((width + 1) << 2); rlm@1: nextPixel = *bP++; rlm@1: nextDelta = *xP++; rlm@1: rlm@1: do rlm@1: { rlm@1: currentPixel = nextPixel; rlm@1: currentDelta = nextDelta; rlm@1: nextPixel = *bP++; rlm@1: nextDelta = *xP++; rlm@1: rlm@1: u32 colorA, product, colorB; rlm@1: rlm@1: *(xP - 2) = currentPixel; rlm@1: colorA = currentPixel; rlm@1: colorB = currentDelta; rlm@1: rlm@1: product = ((((colorA & colorMask) >> 1) + rlm@1: ((colorB & colorMask) >> 1) + rlm@1: (colorA & colorB & lowPixelMask))); rlm@1: rlm@1: *(dP) = product; rlm@1: *(dP + 1) = product; rlm@1: *(nL) = product; rlm@1: *(nL + 1) = product; rlm@1: rlm@1: *(xP - 1) = nextPixel; rlm@1: rlm@1: colorA = nextPixel; rlm@1: colorB = nextDelta; rlm@1: rlm@1: product = ((((colorA & colorMask) >> 1) + rlm@1: ((colorB & colorMask) >> 1) + rlm@1: (colorA & colorB & lowPixelMask))); rlm@1: rlm@1: *(dP + 2) = product; rlm@1: *(dP + 3) = product; rlm@1: *(nL + 2) = product; rlm@1: *(nL + 3) = product; rlm@1: rlm@1: nextPixel = *bP++; rlm@1: nextDelta = *xP++; rlm@1: rlm@1: dP += 4; rlm@1: nL += 4; rlm@1: } rlm@1: while ((u8 *) bP < finish); rlm@1: rlm@1: deltaPtr += srcPitch; rlm@1: srcPtr += srcPitch; rlm@1: dstPtr += dstPitch << 1; rlm@1: nextLine += dstPitch << 1; rlm@1: } rlm@1: while (--height); rlm@1: }