Mercurial > vba-clojure
comparison 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 |
comparison
equal
deleted
inserted
replaced
0:8ced16adf2e1 | 1:f9f4f1b99eed |
---|---|
1 #include "../Port.h" | |
2 | |
3 extern u32 RGB_LOW_BITS_MASK; | |
4 | |
5 void Scanlines(u8 *srcPtr, u32 srcPitch, u8 *, | |
6 u8 *dstPtr, u32 dstPitch, int width, int height) | |
7 { | |
8 u8 *nextLine, *finish; | |
9 | |
10 nextLine = dstPtr + dstPitch; | |
11 | |
12 do | |
13 { | |
14 u32 *bP = (u32 *) srcPtr; | |
15 u32 *dP = (u32 *) dstPtr; | |
16 u32 *nL = (u32 *) nextLine; | |
17 u32 currentPixel; | |
18 u32 nextPixel; | |
19 | |
20 finish = (u8 *) bP + ((width + 2) << 1); | |
21 nextPixel = *bP++; | |
22 | |
23 do | |
24 { | |
25 currentPixel = nextPixel; | |
26 nextPixel = *bP++; | |
27 u32 colorA, colorB; | |
28 | |
29 #ifdef WORDS_BIGENDIAN | |
30 colorA = currentPixel >> 16; | |
31 colorB = currentPixel & 0xffff; | |
32 #else | |
33 colorA = currentPixel & 0xffff; | |
34 colorB = currentPixel >> 16; | |
35 #endif | |
36 | |
37 *(dP) = colorA | colorA << 16; | |
38 *(nL) = 0; | |
39 | |
40 #ifdef WORDS_BIGENDIAN | |
41 colorA = nextPixel >> 16; | |
42 #else | |
43 colorA = nextPixel & 0xffff; | |
44 #endif | |
45 | |
46 *(dP + 1) = colorB | (colorB << 16); | |
47 *(nL + 1) = 0; | |
48 | |
49 dP += 2; | |
50 nL += 2; | |
51 } | |
52 while ((u8 *) bP < finish); | |
53 | |
54 srcPtr += srcPitch; | |
55 dstPtr += dstPitch << 1; | |
56 nextLine += dstPitch << 1; | |
57 } | |
58 while (--height); | |
59 } | |
60 | |
61 void Scanlines32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, | |
62 u8 *dstPtr, u32 dstPitch, int width, int height) | |
63 { | |
64 u8 *nextLine, *finish; | |
65 | |
66 nextLine = dstPtr + dstPitch; | |
67 | |
68 do | |
69 { | |
70 u32 *bP = (u32 *) srcPtr; | |
71 u32 *dP = (u32 *) dstPtr; | |
72 u32 *nL = (u32 *) nextLine; | |
73 u32 currentPixel; | |
74 u32 nextPixel; | |
75 | |
76 finish = (u8 *) bP + ((width + 1) << 2); | |
77 nextPixel = *bP++; | |
78 | |
79 do | |
80 { | |
81 currentPixel = nextPixel; | |
82 nextPixel = *bP++; | |
83 | |
84 u32 colorA, colorB; | |
85 | |
86 colorA = currentPixel; | |
87 colorB = nextPixel; | |
88 | |
89 *(dP) = colorA; | |
90 *(dP + 1) = colorA; | |
91 *(nL) = 0; | |
92 *(nL + 1) = 0; | |
93 | |
94 *(dP + 2) = colorB; | |
95 *(dP + 3) = colorB; | |
96 *(nL + 2) = 0; | |
97 *(nL + 3) = 0; | |
98 | |
99 nextPixel = *bP++; | |
100 | |
101 dP += 4; | |
102 nL += 4; | |
103 } | |
104 while ((u8 *) bP < finish); | |
105 | |
106 srcPtr += srcPitch; | |
107 dstPtr += dstPitch << 1; | |
108 nextLine += dstPitch << 1; | |
109 } | |
110 while (--height); | |
111 } | |
112 | |
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)); | |
118 | |
119 nextLine = dstPtr + dstPitch; | |
120 | |
121 do | |
122 { | |
123 u32 *bP = (u32 *) srcPtr; | |
124 u32 *dP = (u32 *) dstPtr; | |
125 u32 *nL = (u32 *) nextLine; | |
126 u32 currentPixel; | |
127 u32 nextPixel; | |
128 | |
129 finish = (u8 *) bP + ((width + 2) << 1); | |
130 nextPixel = *bP++; | |
131 | |
132 do | |
133 { | |
134 currentPixel = nextPixel; | |
135 nextPixel = *bP++; | |
136 | |
137 u32 colorA, colorB; | |
138 | |
139 #ifdef WORDS_BIGENDIAN | |
140 colorA = currentPixel >> 16; | |
141 colorB = currentPixel & 0xFFFF; | |
142 #else | |
143 colorA = currentPixel & 0xFFFF; | |
144 colorB = currentPixel >> 16; | |
145 #endif | |
146 | |
147 *(dP) = colorA = colorA | ((((colorA & colorMask) >> 1) + | |
148 ((colorB & colorMask) >> 1))) << 16; | |
149 colorA = ((colorA & colorMask) >> 1); | |
150 colorA += ((colorA & colorMask) >> 1); | |
151 *(nL) = colorA; | |
152 | |
153 colorA = nextPixel & 0xFFFF; | |
154 | |
155 *(dP + 1) = colorB = colorB | ((((colorA & colorMask) >> 1) + | |
156 ((colorB & colorMask) >> 1))) << 16; | |
157 colorB = ((colorB & colorMask) >> 1); | |
158 colorB += ((colorB & colorMask) >> 1); | |
159 | |
160 *(nL + 1) = colorB; | |
161 | |
162 dP += 2; | |
163 nL += 2; | |
164 } | |
165 while ((u8 *) bP < finish); | |
166 | |
167 srcPtr += srcPitch; | |
168 dstPtr += dstPitch << 1; | |
169 nextLine += dstPitch << 1; | |
170 } | |
171 while (--height); | |
172 } | |
173 | |
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; | |
179 | |
180 nextLine = dstPtr + dstPitch; | |
181 | |
182 do | |
183 { | |
184 u32 *bP = (u32 *) srcPtr; | |
185 u32 *dP = (u32 *) dstPtr; | |
186 u32 *nL = (u32 *) nextLine; | |
187 u32 currentPixel; | |
188 u32 nextPixel; | |
189 | |
190 finish = (u8 *) bP + ((width + 1) << 2); | |
191 nextPixel = *bP++; | |
192 | |
193 do | |
194 { | |
195 currentPixel = nextPixel; | |
196 nextPixel = *bP++; | |
197 | |
198 u32 colorA, colorB, temp; | |
199 | |
200 colorA = currentPixel; | |
201 colorB = nextPixel; | |
202 | |
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); | |
210 | |
211 *(nL) = colorA; | |
212 *(nL + 1) = temp; | |
213 | |
214 dP += 2; | |
215 nL += 2; | |
216 } | |
217 while ((u8 *) bP < finish); | |
218 | |
219 srcPtr += srcPitch; | |
220 dstPtr += dstPitch << 1; | |
221 nextLine += dstPitch << 1; | |
222 } | |
223 while (--height); | |
224 } | |
225 |