rlm@1: #include "../Port.h" rlm@1: rlm@1: void Simple2x16(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: rlm@1: nextLine = dstPtr + dstPitch; rlm@1: rlm@1: do rlm@1: { rlm@1: u32 *bP = (u32 *) srcPtr; rlm@1: u32 *dP = (u32 *) dstPtr; rlm@1: u32 *nL = (u32 *) nextLine; rlm@1: u32 currentPixel; rlm@1: rlm@1: finish = (u8 *) bP + ((width + 2) << 1); rlm@1: currentPixel = *bP++; rlm@1: rlm@1: do rlm@1: { rlm@1: #ifdef WORDS_BIGENDIAN rlm@1: u32 color = currentPixel >> 16; rlm@1: #else rlm@1: u32 color = currentPixel & 0xffff; rlm@1: #endif rlm@1: rlm@1: color = color | (color << 16); rlm@1: rlm@1: *(dP) = color; rlm@1: *(nL) = color; rlm@1: rlm@1: #ifdef WORDS_BIGENDIAN rlm@1: color = currentPixel & 0xffff; rlm@1: #else rlm@1: color = currentPixel >> 16; rlm@1: #endif rlm@1: color = color | (color << 16); rlm@1: *(dP + 1) = color; rlm@1: *(nL + 1) = color; rlm@1: rlm@1: currentPixel = *bP++; rlm@1: rlm@1: dP += 2; rlm@1: nL += 2; rlm@1: } rlm@1: while ((u8 *) bP < finish); rlm@1: 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 Simple2x32(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: rlm@1: nextLine = dstPtr + dstPitch; rlm@1: rlm@1: do rlm@1: { rlm@1: u32 *bP = (u32 *) srcPtr; rlm@1: u32 *dP = (u32 *) dstPtr; rlm@1: u32 *nL = (u32 *) nextLine; rlm@1: u32 currentPixel; rlm@1: rlm@1: finish = (u8 *) bP + ((width + 1) << 2); rlm@1: currentPixel = *bP++; rlm@1: rlm@1: do rlm@1: { rlm@1: u32 color = currentPixel; rlm@1: rlm@1: *(dP) = color; rlm@1: *(dP + 1) = color; rlm@1: *(nL) = color; rlm@1: *(nL + 1) = color; rlm@1: rlm@1: currentPixel = *bP++; rlm@1: rlm@1: dP += 2; rlm@1: nL += 2; rlm@1: } rlm@1: while ((u8 *) bP < finish); rlm@1: 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: #if 0 rlm@1: // generic Simple Nx magnification filter rlm@1: template rlm@1: void SimpleNx(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, rlm@1: u8 *dstPtr, u32 dstPitch, int width, int height) rlm@1: { rlm@1: srcPitch = srcPitch / sizeof(ColorType) - width; rlm@1: u32 dstNextP = dstPitch / sizeof(ColorType); rlm@1: u32 dstNextL = (dstNextP - width) * magnification; // skip to the next magnificated 'line' rlm@1: dstNextP -= magnification; rlm@1: rlm@1: u32 offset = (dstPitch + sizeof(ColorType)) * magnification - dstPitch; rlm@1: rlm@1: ColorType *src = (ColorType *)srcPtr; rlm@1: ColorType *dst = (ColorType *)dstPtr; rlm@1: rlm@1: do // per src line rlm@1: { rlm@1: u8 *finishP = (u8 *)dst + offset; rlm@1: for (int x = 0; x < width; ++x) // per pixel in line rlm@1: { rlm@1: ColorType col = *src; rlm@1: ColorType *dst2 = dst; rlm@1: u8 * finishM = (u8 *)(dst + magnification); rlm@1: do // dst magnificated pixel rlm@1: { rlm@1: do rlm@1: { rlm@1: *dst2 = col; rlm@1: } rlm@1: while ((u8 *)++dst2 < finishM); rlm@1: dst2 += dstNextP; rlm@1: finishM += dstPitch; rlm@1: } rlm@1: while ((u8 *)dst2 < finishP); rlm@1: rlm@1: ++src; rlm@1: dst += magnification; rlm@1: finishP += magnification * sizeof(ColorType); rlm@1: } rlm@1: src += srcPitch; rlm@1: dst += dstNextL; rlm@1: } rlm@1: while (--height); rlm@1: } rlm@1: rlm@1: #else rlm@1: rlm@1: // generic Simple Nx magnification filter rlm@1: template rlm@1: void SimpleNx(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, rlm@1: u8 *dstPtr, u32 dstPitch, int width, int height) rlm@1: { rlm@1: srcPitch = srcPitch / sizeof(ColorType) - width; rlm@1: dstPitch /= sizeof(ColorType); rlm@1: u32 dstBlank = (dstPitch - width) * magnification; // skip to the next magnificated 'line' rlm@1: dstPitch -= magnification; rlm@1: rlm@1: ColorType *src = (ColorType *)srcPtr; rlm@1: ColorType *dst = (ColorType *)dstPtr; rlm@1: rlm@1: do // per src line rlm@1: { rlm@1: for (int x = 0; x < width; ++x) // per pixel in src line rlm@1: { rlm@1: ColorType col = *src; rlm@1: ColorType *dst2 = dst; rlm@1: for (int dy = 0; dy < magnification; ++dy) // dst magnificated pixel rlm@1: { rlm@1: for (int dx = 0; dx < magnification; ++dx) rlm@1: { rlm@1: *dst2 = col; rlm@1: ++dst2; rlm@1: } rlm@1: dst2 += dstPitch; rlm@1: } rlm@1: rlm@1: ++src; rlm@1: dst += magnification; rlm@1: } rlm@1: src += srcPitch; rlm@1: dst += dstBlank; rlm@1: } rlm@1: while (--height); rlm@1: } rlm@1: rlm@1: #endif rlm@1: rlm@1: typedef void (*SimpleNxFP)(u8 *, u32, u8 *, u8 *, u32, int, int); rlm@1: rlm@1: SimpleNxFP Simple3x16 = SimpleNx<3, u16>; rlm@1: SimpleNxFP Simple3x32 = SimpleNx<3, u32>; rlm@1: SimpleNxFP Simple4x16 = SimpleNx<4, u16>; rlm@1: SimpleNxFP Simple4x32 = SimpleNx<4, u32>;