Mercurial > vba-linux
diff src/filters/scanline.cpp @ 1:f9f4f1b99eed
importing src directory
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:31:27 -0600 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/filters/scanline.cpp Sat Mar 03 10:31:27 2012 -0600 1.3 @@ -0,0 +1,225 @@ 1.4 +#include "../Port.h" 1.5 + 1.6 +extern u32 RGB_LOW_BITS_MASK; 1.7 + 1.8 +void Scanlines(u8 *srcPtr, u32 srcPitch, u8 *, 1.9 + u8 *dstPtr, u32 dstPitch, int width, int height) 1.10 +{ 1.11 + u8 *nextLine, *finish; 1.12 + 1.13 + nextLine = dstPtr + dstPitch; 1.14 + 1.15 + do 1.16 + { 1.17 + u32 *bP = (u32 *) srcPtr; 1.18 + u32 *dP = (u32 *) dstPtr; 1.19 + u32 *nL = (u32 *) nextLine; 1.20 + u32 currentPixel; 1.21 + u32 nextPixel; 1.22 + 1.23 + finish = (u8 *) bP + ((width + 2) << 1); 1.24 + nextPixel = *bP++; 1.25 + 1.26 + do 1.27 + { 1.28 + currentPixel = nextPixel; 1.29 + nextPixel = *bP++; 1.30 + u32 colorA, colorB; 1.31 + 1.32 +#ifdef WORDS_BIGENDIAN 1.33 + colorA = currentPixel >> 16; 1.34 + colorB = currentPixel & 0xffff; 1.35 +#else 1.36 + colorA = currentPixel & 0xffff; 1.37 + colorB = currentPixel >> 16; 1.38 +#endif 1.39 + 1.40 + *(dP) = colorA | colorA << 16; 1.41 + *(nL) = 0; 1.42 + 1.43 +#ifdef WORDS_BIGENDIAN 1.44 + colorA = nextPixel >> 16; 1.45 +#else 1.46 + colorA = nextPixel & 0xffff; 1.47 +#endif 1.48 + 1.49 + *(dP + 1) = colorB | (colorB << 16); 1.50 + *(nL + 1) = 0; 1.51 + 1.52 + dP += 2; 1.53 + nL += 2; 1.54 + } 1.55 + while ((u8 *) bP < finish); 1.56 + 1.57 + srcPtr += srcPitch; 1.58 + dstPtr += dstPitch << 1; 1.59 + nextLine += dstPitch << 1; 1.60 + } 1.61 + while (--height); 1.62 +} 1.63 + 1.64 +void Scanlines32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, 1.65 + u8 *dstPtr, u32 dstPitch, int width, int height) 1.66 +{ 1.67 + u8 *nextLine, *finish; 1.68 + 1.69 + nextLine = dstPtr + dstPitch; 1.70 + 1.71 + do 1.72 + { 1.73 + u32 *bP = (u32 *) srcPtr; 1.74 + u32 *dP = (u32 *) dstPtr; 1.75 + u32 *nL = (u32 *) nextLine; 1.76 + u32 currentPixel; 1.77 + u32 nextPixel; 1.78 + 1.79 + finish = (u8 *) bP + ((width + 1) << 2); 1.80 + nextPixel = *bP++; 1.81 + 1.82 + do 1.83 + { 1.84 + currentPixel = nextPixel; 1.85 + nextPixel = *bP++; 1.86 + 1.87 + u32 colorA, colorB; 1.88 + 1.89 + colorA = currentPixel; 1.90 + colorB = nextPixel; 1.91 + 1.92 + *(dP) = colorA; 1.93 + *(dP + 1) = colorA; 1.94 + *(nL) = 0; 1.95 + *(nL + 1) = 0; 1.96 + 1.97 + *(dP + 2) = colorB; 1.98 + *(dP + 3) = colorB; 1.99 + *(nL + 2) = 0; 1.100 + *(nL + 3) = 0; 1.101 + 1.102 + nextPixel = *bP++; 1.103 + 1.104 + dP += 4; 1.105 + nL += 4; 1.106 + } 1.107 + while ((u8 *) bP < finish); 1.108 + 1.109 + srcPtr += srcPitch; 1.110 + dstPtr += dstPitch << 1; 1.111 + nextLine += dstPitch << 1; 1.112 + } 1.113 + while (--height); 1.114 +} 1.115 + 1.116 +void ScanlinesTV(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, 1.117 + u8 *dstPtr, u32 dstPitch, int width, int height) 1.118 +{ 1.119 + u8 *nextLine, *finish; 1.120 + u32 colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16)); 1.121 + 1.122 + nextLine = dstPtr + dstPitch; 1.123 + 1.124 + do 1.125 + { 1.126 + u32 *bP = (u32 *) srcPtr; 1.127 + u32 *dP = (u32 *) dstPtr; 1.128 + u32 *nL = (u32 *) nextLine; 1.129 + u32 currentPixel; 1.130 + u32 nextPixel; 1.131 + 1.132 + finish = (u8 *) bP + ((width + 2) << 1); 1.133 + nextPixel = *bP++; 1.134 + 1.135 + do 1.136 + { 1.137 + currentPixel = nextPixel; 1.138 + nextPixel = *bP++; 1.139 + 1.140 + u32 colorA, colorB; 1.141 + 1.142 +#ifdef WORDS_BIGENDIAN 1.143 + colorA = currentPixel >> 16; 1.144 + colorB = currentPixel & 0xFFFF; 1.145 +#else 1.146 + colorA = currentPixel & 0xFFFF; 1.147 + colorB = currentPixel >> 16; 1.148 +#endif 1.149 + 1.150 + *(dP) = colorA = colorA | ((((colorA & colorMask) >> 1) + 1.151 + ((colorB & colorMask) >> 1))) << 16; 1.152 + colorA = ((colorA & colorMask) >> 1); 1.153 + colorA += ((colorA & colorMask) >> 1); 1.154 + *(nL) = colorA; 1.155 + 1.156 + colorA = nextPixel & 0xFFFF; 1.157 + 1.158 + *(dP + 1) = colorB = colorB | ((((colorA & colorMask) >> 1) + 1.159 + ((colorB & colorMask) >> 1))) << 16; 1.160 + colorB = ((colorB & colorMask) >> 1); 1.161 + colorB += ((colorB & colorMask) >> 1); 1.162 + 1.163 + *(nL + 1) = colorB; 1.164 + 1.165 + dP += 2; 1.166 + nL += 2; 1.167 + } 1.168 + while ((u8 *) bP < finish); 1.169 + 1.170 + srcPtr += srcPitch; 1.171 + dstPtr += dstPitch << 1; 1.172 + nextLine += dstPitch << 1; 1.173 + } 1.174 + while (--height); 1.175 +} 1.176 + 1.177 +void ScanlinesTV32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, 1.178 + u8 *dstPtr, u32 dstPitch, int width, int height) 1.179 +{ 1.180 + u8 *nextLine, *finish; 1.181 + u32 colorMask = ~RGB_LOW_BITS_MASK; 1.182 + 1.183 + nextLine = dstPtr + dstPitch; 1.184 + 1.185 + do 1.186 + { 1.187 + u32 *bP = (u32 *) srcPtr; 1.188 + u32 *dP = (u32 *) dstPtr; 1.189 + u32 *nL = (u32 *) nextLine; 1.190 + u32 currentPixel; 1.191 + u32 nextPixel; 1.192 + 1.193 + finish = (u8 *) bP + ((width + 1) << 2); 1.194 + nextPixel = *bP++; 1.195 + 1.196 + do 1.197 + { 1.198 + currentPixel = nextPixel; 1.199 + nextPixel = *bP++; 1.200 + 1.201 + u32 colorA, colorB, temp; 1.202 + 1.203 + colorA = currentPixel; 1.204 + colorB = nextPixel; 1.205 + 1.206 + *(dP) = colorA; 1.207 + *(dP + 1) = temp = ((colorA & colorMask) >> 1) + 1.208 + ((colorB & colorMask) >> 1); 1.209 + temp = ((temp & colorMask) >> 1); 1.210 + temp += ((temp & colorMask) >> 1); 1.211 + colorA = ((colorA & colorMask) >> 1); 1.212 + colorA += ((colorA & colorMask) >> 1); 1.213 + 1.214 + *(nL) = colorA; 1.215 + *(nL + 1) = temp; 1.216 + 1.217 + dP += 2; 1.218 + nL += 2; 1.219 + } 1.220 + while ((u8 *) bP < finish); 1.221 + 1.222 + srcPtr += srcPitch; 1.223 + dstPtr += dstPitch << 1; 1.224 + nextLine += dstPitch << 1; 1.225 + } 1.226 + while (--height); 1.227 +} 1.228 +