44 #include "allheaders.h" 46 static l_int32 NUM_SELS_GENERATED = 4;
47 static char SEL_NAMES[][10] = {
"flipsel1",
52 static l_int32 flipfhmtgen_low(l_uint32 *, l_int32, l_int32, l_int32, l_uint32 *, l_int32, l_int32);
54 static void fhmt_1_0(l_uint32 *, l_int32, l_int32, l_int32, l_uint32 *, l_int32);
55 static void fhmt_1_1(l_uint32 *, l_int32, l_int32, l_int32, l_uint32 *, l_int32);
56 static void fhmt_1_2(l_uint32 *, l_int32, l_int32, l_int32, l_uint32 *, l_int32);
57 static void fhmt_1_3(l_uint32 *, l_int32, l_int32, l_int32, l_uint32 *, l_int32);
77 pixFlipFHMTGen(
PIX *pixd,
81 l_int32 i, index, found, w, h, wpls, wpld;
82 l_uint32 *datad, *datas, *datat;
85 PROCNAME(
"pixFlipFHMTGen");
88 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, pixd);
89 if (pixGetDepth(pixs) != 1)
90 return (
PIX *)ERROR_PTR(
"pixs must be 1 bpp", procName, pixd);
93 for (i = 0; i < NUM_SELS_GENERATED; i++) {
94 if (strcmp(selname, SEL_NAMES[i]) == 0) {
101 return (
PIX *)ERROR_PTR(
"sel index not found", procName, pixd);
105 return (
PIX *)ERROR_PTR(
"sizes not equal", procName, pixd);
108 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
111 wpls = pixGetWpl(pixs);
112 wpld = pixGetWpl(pixd);
124 if ((pixt =
pixCopy(NULL, pixs)) == NULL)
125 return (
PIX *)ERROR_PTR(
"pixt not made", procName, pixd);
127 flipfhmtgen_low(datad, w, h, wpld, datat, wpls, index);
130 flipfhmtgen_low(datad, w, h, wpld, datas, wpls, index);
146 flipfhmtgen_low(l_uint32 *datad,
158 fhmt_1_0(datad, w, h, wpld, datas, wpls);
161 fhmt_1_1(datad, w, h, wpld, datas, wpls);
164 fhmt_1_2(datad, w, h, wpld, datas, wpls);
167 fhmt_1_3(datad, w, h, wpld, datas, wpls);
188 fhmt_1_0(l_uint32 *datad,
196 register l_int32 j, pwpls;
197 register l_uint32 *sptr, *dptr;
198 l_int32 wpls2, wpls3;
202 pwpls = (l_uint32)(w + 31) / 32;
204 for (i = 0; i < h; i++) {
205 sptr = datas + i * wpls;
206 dptr = datad + i * wpld;
207 for (j = 0; j < pwpls; j++, sptr++, dptr++) {
208 *dptr = ((*(sptr - wpls) >> 3) | (*(sptr - wpls - 1) << 29)) &
210 ((~*(sptr - wpls) << 1) | (~*(sptr - wpls + 1) >> 31)) &
211 ((*(sptr) >> 3) | (*(sptr - 1) << 29)) &
212 ((~*(sptr) >> 1) | (~*(sptr - 1) << 31)) &
214 ((~*(sptr) << 1) | (~*(sptr + 1) >> 31)) &
215 ((*(sptr + wpls) >> 3) | (*(sptr + wpls - 1) << 29)) &
217 ((*(sptr + wpls2) >> 3) | (*(sptr + wpls2 - 1) << 29)) &
218 ((*(sptr + wpls3) >> 3) | (*(sptr + wpls3 - 1) << 29)) &
219 ((*(sptr + wpls3) >> 2) | (*(sptr + wpls3 - 1) << 30)) &
220 ((*(sptr + wpls3) >> 1) | (*(sptr + wpls3 - 1) << 31)) &
222 ((*(sptr + wpls3) << 1) | (*(sptr + wpls3 + 1) >> 31)) &
223 ((*(sptr + wpls3) << 2) | (*(sptr + wpls3 + 1) >> 30));
230 fhmt_1_1(l_uint32 *datad,
238 register l_int32 j, pwpls;
239 register l_uint32 *sptr, *dptr;
240 l_int32 wpls2, wpls3;
244 pwpls = (l_uint32)(w + 31) / 32;
246 for (i = 0; i < h; i++) {
247 sptr = datas + i * wpls;
248 dptr = datad + i * wpld;
249 for (j = 0; j < pwpls; j++, sptr++, dptr++) {
250 *dptr = ((~*(sptr - wpls) >> 1) | (~*(sptr - wpls - 1) << 31)) &
252 ((*(sptr - wpls) << 3) | (*(sptr - wpls + 1) >> 29)) &
253 ((~*(sptr) >> 1) | (~*(sptr - 1) << 31)) &
255 ((~*(sptr) << 1) | (~*(sptr + 1) >> 31)) &
256 ((*(sptr) << 3) | (*(sptr + 1) >> 29)) &
258 ((*(sptr + wpls) << 3) | (*(sptr + wpls + 1) >> 29)) &
259 ((*(sptr + wpls2) << 3) | (*(sptr + wpls2 + 1) >> 29)) &
260 ((*(sptr + wpls3) >> 2) | (*(sptr + wpls3 - 1) << 30)) &
261 ((*(sptr + wpls3) >> 1) | (*(sptr + wpls3 - 1) << 31)) &
263 ((*(sptr + wpls3) << 1) | (*(sptr + wpls3 + 1) >> 31)) &
264 ((*(sptr + wpls3) << 2) | (*(sptr + wpls3 + 1) >> 30)) &
265 ((*(sptr + wpls3) << 3) | (*(sptr + wpls3 + 1) >> 29));
272 fhmt_1_2(l_uint32 *datad,
280 register l_int32 j, pwpls;
281 register l_uint32 *sptr, *dptr;
282 l_int32 wpls2, wpls3;
286 pwpls = (l_uint32)(w + 31) / 32;
288 for (i = 0; i < h; i++) {
289 sptr = datas + i * wpls;
290 dptr = datad + i * wpld;
291 for (j = 0; j < pwpls; j++, sptr++, dptr++) {
292 *dptr = ((*(sptr - wpls3) >> 3) | (*(sptr - wpls3 - 1) << 29)) &
293 ((*(sptr - wpls3) >> 2) | (*(sptr - wpls3 - 1) << 30)) &
294 ((*(sptr - wpls3) >> 1) | (*(sptr - wpls3 - 1) << 31)) &
296 ((*(sptr - wpls3) << 1) | (*(sptr - wpls3 + 1) >> 31)) &
297 ((*(sptr - wpls3) << 2) | (*(sptr - wpls3 + 1) >> 30)) &
298 ((*(sptr - wpls2) >> 3) | (*(sptr - wpls2 - 1) << 29)) &
299 ((*(sptr - wpls) >> 3) | (*(sptr - wpls - 1) << 29)) &
301 ((*(sptr) >> 3) | (*(sptr - 1) << 29)) &
302 ((~*(sptr) >> 1) | (~*(sptr - 1) << 31)) &
304 ((~*(sptr) << 1) | (~*(sptr + 1) >> 31)) &
305 ((*(sptr + wpls) >> 3) | (*(sptr + wpls - 1) << 29)) &
307 ((~*(sptr + wpls) << 1) | (~*(sptr + wpls + 1) >> 31));
314 fhmt_1_3(l_uint32 *datad,
322 register l_int32 j, pwpls;
323 register l_uint32 *sptr, *dptr;
324 l_int32 wpls2, wpls3;
328 pwpls = (l_uint32)(w + 31) / 32;
330 for (i = 0; i < h; i++) {
331 sptr = datas + i * wpls;
332 dptr = datad + i * wpld;
333 for (j = 0; j < pwpls; j++, sptr++, dptr++) {
334 *dptr = ((*(sptr - wpls3) >> 2) | (*(sptr - wpls3 - 1) << 30)) &
335 ((*(sptr - wpls3) >> 1) | (*(sptr - wpls3 - 1) << 31)) &
337 ((*(sptr - wpls3) << 1) | (*(sptr - wpls3 + 1) >> 31)) &
338 ((*(sptr - wpls3) << 2) | (*(sptr - wpls3 + 1) >> 30)) &
339 ((*(sptr - wpls3) << 3) | (*(sptr - wpls3 + 1) >> 29)) &
340 ((*(sptr - wpls2) << 3) | (*(sptr - wpls2 + 1) >> 29)) &
342 ((*(sptr - wpls) << 3) | (*(sptr - wpls + 1) >> 29)) &
343 ((~*(sptr) >> 1) | (~*(sptr - 1) << 31)) &
345 ((~*(sptr) << 1) | (~*(sptr + 1) >> 31)) &
346 ((*(sptr) << 3) | (*(sptr + 1) >> 29)) &
347 ((~*(sptr + wpls) >> 1) | (~*(sptr + wpls - 1) << 31)) &
349 ((*(sptr + wpls) << 3) | (*(sptr + wpls + 1) >> 29));
static const l_int32 ADDED_BORDER
l_uint32 * pixGetData(PIX *pix)
pixGetData()
PIX * pixCreateTemplate(PIX *pixs)
pixCreateTemplate()
void pixDestroy(PIX **ppix)
pixDestroy()
PIX * pixCopy(PIX *pixd, PIX *pixs)
pixCopy()
l_int32 pixSizesEqual(const PIX *pix1, const PIX *pix2)
pixSizesEqual()