1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
#ifndef EVAS_MACROS_H
#define EVAS_MACROS_H
#undef ABS
#define ABS(x) (((x) < 0) ? -(x) : (x))
#undef SGN
#define SGN(x) (((x) < 0) ? -1 : 1)
#undef MIN
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#undef MAX
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define SWAP32(x) (x) = \
((((x) & 0x000000ff ) << 24) | \
(((x) & 0x0000ff00 ) << 8) | \
(((x) & 0x00ff0000 ) >> 8) | \
(((x) & 0xff000000 ) >> 24))
#define SWAP16(x) (x) = \
((((x) & 0x00ff ) << 8) | \
(((x) & 0xff00 ) >> 8))
#define SPANS_COMMON(x1, w1, x2, w2) \
(!(( (int)((x2) + (int)(w2)) <= (int)(x1)) || (int)((x2) >= (int)((x1) + (int)(w1)))))
#define RECTS_INTERSECT(x, y, w, h, xx, yy, ww, hh) \
((SPANS_COMMON((x), (w), (xx), (ww))) && (SPANS_COMMON((y), (h), (yy), (hh))))
#define RECTS_CLIP_TO_RECT(_x, _y, _w, _h, _cx, _cy, _cw, _ch) \
{ \
if (RECTS_INTERSECT(_x, _y, _w, _h, _cx, _cy, _cw, _ch)) \
{ \
if ((int)_x < (int)(_cx)) \
{ \
if ((int)_w + ((int)_x - (int)(_cx)) < 0) _w = 0; \
else _w += ((int)_x - (int)(_cx)); \
_x = (_cx); \
} \
if ((int)(_x + _w) > (int)((_cx) + (_cw))) \
_w = (_cx) + (_cw) - _x; \
if ((int)_y < (int)(_cy)) \
{ \
if ((int)_h + ((int)_y - (int)(_cy)) < 0) _h = 0; \
else _h += ((int)_y - (int)(_cy)); \
_y = (_cy); \
} \
if ((int)(_y + _h) > (int)((_cy) + (_ch))) \
_h = (_cy) + (_ch) - _y; \
} \
else \
{ \
_w = 0; _h = 0; \
} \
}
#define INTERP_VAL(out, in1, in2, in3, in4, interp_x, interp_y) \
{ \
int _v, _vv; \
\
_v = (256 - (interp_x)) * (in1); \
if ((interp_x) > 0) _v += (interp_x) * (in2); \
_v *= (256 - (interp_y)); \
if ((interp_y) > 0) \
{ \
_vv = (256 - (interp_x)) * (in3); \
if ((interp_x) > 0) _vv += (interp_x) * (in4); \
_vv *= (interp_y); \
(out) = ((_v + _vv) >> 16); \
} \
else (out) = (_v >> 16); \
}
#define INTERP_2(in1, in2, interp, interp_inv) \
((in1 * interp_inv) + (in2 * interp)) >> 8
#define CONVERT_LOOP_START_ROT_0() \
src_ptr = src; \
for (y = 0; y < h; y++) \
{ \
for (x = 0; x < w; x++) \
{
#define CONVERT_LOOP_END_ROT_0() \
dst_ptr++; \
src_ptr++; \
} \
src_ptr += src_jump; \
dst_ptr += dst_jump; \
}
#define CONVERT_LOOP_START_ROT_180() \
src_ptr = src + (w - 1) + ((h - 1) * (w + src_jump)); \
for (y = 0; y < h; y++) \
{ \
for (x = 0; x < w; x++) \
{
#define CONVERT_LOOP_END_ROT_180() \
dst_ptr++; \
src_ptr--; \
} \
src_ptr = src + (w - 1) + ((h - y - 2) * (w + src_jump)); \
dst_ptr += dst_jump; \
}
#define CONVERT_LOOP_START_ROT_270() \
src_ptr = src + ((w - 1) * (h + src_jump)); \
for (y = 0; y < h; y++) \
{ \
for (x = 0; x < w; x++) \
{
#define CONVERT_LOOP_END_ROT_270() \
dst_ptr++; \
src_ptr -= (h + src_jump); \
} \
src_ptr = src + ((w - 1) * (h + src_jump)) + (y + 1); \
dst_ptr += dst_jump; \
}
#define CONVERT_LOOP_START_ROT_90() \
src_ptr = src + (h - 1); \
for (y = 0; y < h; y++) \
{ \
for (x = 0; x < w; x++) \
{
#define CONVERT_LOOP_END_ROT_90() \
dst_ptr++; \
src_ptr += (h + src_jump); \
} \
src_ptr = src + (h - 1) - y - 1; \
dst_ptr += dst_jump; \
}
#define CONVERT_LOOP2_START_ROT_0() \
src_ptr = src; \
for (y = 0; y < h; y++) \
{ \
for (x = 0; x < w; x++) \
{
#define CONVERT_LOOP2_INC_ROT_0() \
src_ptr++; \
x++;
#define CONVERT_LOOP2_END_ROT_0() \
dst_ptr+=2; \
src_ptr++; \
} \
src_ptr += src_jump; \
dst_ptr += dst_jump; \
}
#define CONVERT_LOOP2_START_ROT_180() \
src_ptr = src + (w - 1) + ((h - 1) * (w + src_jump)); \
for (y = 0; y < h; y++) \
{ \
for (x = 0; x < w; x++) \
{
#define CONVERT_LOOP2_INC_ROT_180() \
src_ptr--; \
x++;
#define CONVERT_LOOP2_END_ROT_180() \
dst_ptr+=2; \
src_ptr--; \
} \
src_ptr = src + (w - 1) + ((h - y - 2) * (w + src_jump)); \
dst_ptr += dst_jump; \
}
#define CONVERT_LOOP2_START_ROT_270() \
src_ptr = src + ((w - 1) * (h + src_jump)); \
for (y = 0; y < h; y++) \
{ \
for (x = 0; x < w; x++) \
{
#define CONVERT_LOOP2_INC_ROT_270() \
src_ptr -= (h + src_jump); \
x++;
#define CONVERT_LOOP2_END_ROT_270() \
dst_ptr+=2; \
src_ptr -= (h + src_jump); \
} \
src_ptr = src + ((w - 1) * (h + src_jump)) + (y + 1); \
dst_ptr += dst_jump; \
}
#define CONVERT_LOOP2_START_ROT_90() \
src_ptr = src + (h - 1); \
for (y = 0; y < h; y++) \
{ \
for (x = 0; x < w; x++) \
{
#define CONVERT_LOOP2_INC_ROT_90() \
src_ptr += (h + src_jump); \
x++;
#define CONVERT_LOOP2_END_ROT_90() \
dst_ptr+=2; \
src_ptr += (h + src_jump); \
} \
src_ptr = src + (h - 1) - y - 1; \
dst_ptr += dst_jump; \
}
#endif
|