Mercurial > vba-clojure
view src/filters/scanline.cpp @ 453:8dc38aac21c7
removed all overlapping notes.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Thu, 03 May 2012 07:01:42 -0500 |
parents | f9f4f1b99eed |
children |
line wrap: on
line source
1 #include "../Port.h"3 extern u32 RGB_LOW_BITS_MASK;5 void Scanlines(u8 *srcPtr, u32 srcPitch, u8 *,6 u8 *dstPtr, u32 dstPitch, int width, int height)7 {8 u8 *nextLine, *finish;10 nextLine = dstPtr + dstPitch;12 do13 {14 u32 *bP = (u32 *) srcPtr;15 u32 *dP = (u32 *) dstPtr;16 u32 *nL = (u32 *) nextLine;17 u32 currentPixel;18 u32 nextPixel;20 finish = (u8 *) bP + ((width + 2) << 1);21 nextPixel = *bP++;23 do24 {25 currentPixel = nextPixel;26 nextPixel = *bP++;27 u32 colorA, colorB;29 #ifdef WORDS_BIGENDIAN30 colorA = currentPixel >> 16;31 colorB = currentPixel & 0xffff;32 #else33 colorA = currentPixel & 0xffff;34 colorB = currentPixel >> 16;35 #endif37 *(dP) = colorA | colorA << 16;38 *(nL) = 0;40 #ifdef WORDS_BIGENDIAN41 colorA = nextPixel >> 16;42 #else43 colorA = nextPixel & 0xffff;44 #endif46 *(dP + 1) = colorB | (colorB << 16);47 *(nL + 1) = 0;49 dP += 2;50 nL += 2;51 }52 while ((u8 *) bP < finish);54 srcPtr += srcPitch;55 dstPtr += dstPitch << 1;56 nextLine += dstPitch << 1;57 }58 while (--height);59 }61 void Scanlines32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,62 u8 *dstPtr, u32 dstPitch, int width, int height)63 {64 u8 *nextLine, *finish;66 nextLine = dstPtr + dstPitch;68 do69 {70 u32 *bP = (u32 *) srcPtr;71 u32 *dP = (u32 *) dstPtr;72 u32 *nL = (u32 *) nextLine;73 u32 currentPixel;74 u32 nextPixel;76 finish = (u8 *) bP + ((width + 1) << 2);77 nextPixel = *bP++;79 do80 {81 currentPixel = nextPixel;82 nextPixel = *bP++;84 u32 colorA, colorB;86 colorA = currentPixel;87 colorB = nextPixel;89 *(dP) = colorA;90 *(dP + 1) = colorA;91 *(nL) = 0;92 *(nL + 1) = 0;94 *(dP + 2) = colorB;95 *(dP + 3) = colorB;96 *(nL + 2) = 0;97 *(nL + 3) = 0;99 nextPixel = *bP++;101 dP += 4;102 nL += 4;103 }104 while ((u8 *) bP < finish);106 srcPtr += srcPitch;107 dstPtr += dstPitch << 1;108 nextLine += dstPitch << 1;109 }110 while (--height);111 }113 void ScanlinesTV(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,114 u8 *dstPtr, u32 dstPitch, int width, int height)115 {116 u8 *nextLine, *finish;117 u32 colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16));119 nextLine = dstPtr + dstPitch;121 do122 {123 u32 *bP = (u32 *) srcPtr;124 u32 *dP = (u32 *) dstPtr;125 u32 *nL = (u32 *) nextLine;126 u32 currentPixel;127 u32 nextPixel;129 finish = (u8 *) bP + ((width + 2) << 1);130 nextPixel = *bP++;132 do133 {134 currentPixel = nextPixel;135 nextPixel = *bP++;137 u32 colorA, colorB;139 #ifdef WORDS_BIGENDIAN140 colorA = currentPixel >> 16;141 colorB = currentPixel & 0xFFFF;142 #else143 colorA = currentPixel & 0xFFFF;144 colorB = currentPixel >> 16;145 #endif147 *(dP) = colorA = colorA | ((((colorA & colorMask) >> 1) +148 ((colorB & colorMask) >> 1))) << 16;149 colorA = ((colorA & colorMask) >> 1);150 colorA += ((colorA & colorMask) >> 1);151 *(nL) = colorA;153 colorA = nextPixel & 0xFFFF;155 *(dP + 1) = colorB = colorB | ((((colorA & colorMask) >> 1) +156 ((colorB & colorMask) >> 1))) << 16;157 colorB = ((colorB & colorMask) >> 1);158 colorB += ((colorB & colorMask) >> 1);160 *(nL + 1) = colorB;162 dP += 2;163 nL += 2;164 }165 while ((u8 *) bP < finish);167 srcPtr += srcPitch;168 dstPtr += dstPitch << 1;169 nextLine += dstPitch << 1;170 }171 while (--height);172 }174 void ScanlinesTV32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,175 u8 *dstPtr, u32 dstPitch, int width, int height)176 {177 u8 *nextLine, *finish;178 u32 colorMask = ~RGB_LOW_BITS_MASK;180 nextLine = dstPtr + dstPitch;182 do183 {184 u32 *bP = (u32 *) srcPtr;185 u32 *dP = (u32 *) dstPtr;186 u32 *nL = (u32 *) nextLine;187 u32 currentPixel;188 u32 nextPixel;190 finish = (u8 *) bP + ((width + 1) << 2);191 nextPixel = *bP++;193 do194 {195 currentPixel = nextPixel;196 nextPixel = *bP++;198 u32 colorA, colorB, temp;200 colorA = currentPixel;201 colorB = nextPixel;203 *(dP) = colorA;204 *(dP + 1) = temp = ((colorA & colorMask) >> 1) +205 ((colorB & colorMask) >> 1);206 temp = ((temp & colorMask) >> 1);207 temp += ((temp & colorMask) >> 1);208 colorA = ((colorA & colorMask) >> 1);209 colorA += ((colorA & colorMask) >> 1);211 *(nL) = colorA;212 *(nL + 1) = temp;214 dP += 2;215 nL += 2;216 }217 while ((u8 *) bP < finish);219 srcPtr += srcPitch;220 dstPtr += dstPitch << 1;221 nextLine += dstPitch << 1;222 }223 while (--height);224 }