File: | jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_D64nw.c |
Warning: | line 221, column 37 The right operand of '+' is a garbage value |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* | |||
2 | * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. | |||
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |||
4 | * | |||
5 | * This code is free software; you can redistribute it and/or modify it | |||
6 | * under the terms of the GNU General Public License version 2 only, as | |||
7 | * published by the Free Software Foundation. Oracle designates this | |||
8 | * particular file as subject to the "Classpath" exception as provided | |||
9 | * by Oracle in the LICENSE file that accompanied this code. | |||
10 | * | |||
11 | * This code is distributed in the hope that it will be useful, but WITHOUT | |||
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |||
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |||
14 | * version 2 for more details (a copy is included in the LICENSE file that | |||
15 | * accompanied this code). | |||
16 | * | |||
17 | * You should have received a copy of the GNU General Public License version | |||
18 | * 2 along with this work; if not, write to the Free Software Foundation, | |||
19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |||
20 | * | |||
21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |||
22 | * or visit www.oracle.com if you need additional information or have any | |||
23 | * questions. | |||
24 | */ | |||
25 | ||||
26 | ||||
27 | /* | |||
28 | * FUNCTION | |||
29 | * Internal functions for mlib_ImageConv* on D64/F32 type and | |||
30 | * MLIB_EDGE_DST_NO_WRITE mask | |||
31 | * | |||
32 | */ | |||
33 | ||||
34 | #include "mlib_image.h" | |||
35 | #include "mlib_ImageConv.h" | |||
36 | ||||
37 | /***************************************************************/ | |||
38 | /* | |||
39 | This define switches between functions of MLIB_DOUBLE and MLIB_FLOAT types: | |||
40 | Files mlib_ImageConv_D64nw.c and mlib_ImageConv_F32nw.c | |||
41 | */ | |||
42 | ||||
43 | #define TYPE_DOUBLE | |||
44 | ||||
45 | /***************************************************************/ | |||
46 | #ifdef TYPE_DOUBLE | |||
47 | ||||
48 | #define CONV_FUNC(KERN)mlib_convKERNnw_d64 mlib_conv##KERN##nw_d64 | |||
49 | ||||
50 | #define DTYPEmlib_d64 mlib_d64 | |||
51 | ||||
52 | #else | |||
53 | ||||
54 | #define CONV_FUNC(KERN)mlib_convKERNnw_d64 mlib_conv##KERN##nw_f32 | |||
55 | ||||
56 | #define DTYPEmlib_d64 mlib_f32 | |||
57 | ||||
58 | #endif /* TYPE_DOUBLE */ | |||
59 | ||||
60 | /***************************************************************/ | |||
61 | #define GET_SRC_DST_PARAMETERS(type)mlib_s32 hgt = mlib_ImageGetHeight(src); mlib_s32 wid = mlib_ImageGetWidth (src); mlib_s32 sll = mlib_ImageGetStride(src) / sizeof(type) ; mlib_s32 dll = mlib_ImageGetStride(dst) / sizeof(type); type * adr_src = mlib_ImageGetData(src); type* adr_dst = mlib_ImageGetData (dst); mlib_s32 chan1 = mlib_ImageGetChannels(src) \ | |||
62 | mlib_s32 hgt = mlib_ImageGetHeight(src); \ | |||
63 | mlib_s32 wid = mlib_ImageGetWidth(src); \ | |||
64 | mlib_s32 sll = mlib_ImageGetStride(src) / sizeof(type); \ | |||
65 | mlib_s32 dll = mlib_ImageGetStride(dst) / sizeof(type); \ | |||
66 | type* adr_src = mlib_ImageGetData(src); \ | |||
67 | type* adr_dst = mlib_ImageGetData(dst); \ | |||
68 | mlib_s32 chan1 = mlib_ImageGetChannels(src) | |||
69 | ||||
70 | /***************************************************************/ | |||
71 | #define DEF_VARS(type)mlib_s32 hgt = mlib_ImageGetHeight(src); mlib_s32 wid = mlib_ImageGetWidth (src); mlib_s32 sll = mlib_ImageGetStride(src) / sizeof(type) ; mlib_s32 dll = mlib_ImageGetStride(dst) / sizeof(type); type * adr_src = mlib_ImageGetData(src); type* adr_dst = mlib_ImageGetData (dst); mlib_s32 chan1 = mlib_ImageGetChannels(src); type *sl; type *dl, *dp = ((void*)0); mlib_s32 i = 0, j, c \ | |||
72 | GET_SRC_DST_PARAMETERS(type)mlib_s32 hgt = mlib_ImageGetHeight(src); mlib_s32 wid = mlib_ImageGetWidth (src); mlib_s32 sll = mlib_ImageGetStride(src) / sizeof(type) ; mlib_s32 dll = mlib_ImageGetStride(dst) / sizeof(type); type * adr_src = mlib_ImageGetData(src); type* adr_dst = mlib_ImageGetData (dst); mlib_s32 chan1 = mlib_ImageGetChannels(src); \ | |||
73 | type *sl; \ | |||
74 | type *dl, *dp = NULL((void*)0); \ | |||
75 | mlib_s32 i = 0, j, c | |||
76 | ||||
77 | /***************************************************************/ | |||
78 | #define BUFF_SIZE1600 1600 | |||
79 | ||||
80 | #define CACHE_SIZE(64*1024) (64*1024) | |||
81 | ||||
82 | static mlib_status mlib_ImageConv1xN(mlib_image *dst, | |||
83 | const mlib_image *src, | |||
84 | const DTYPEmlib_d64 *k, | |||
85 | mlib_s32 n, | |||
86 | mlib_s32 dn, | |||
87 | mlib_s32 cmask) | |||
88 | { | |||
89 | DTYPEmlib_d64 buff[BUFF_SIZE1600], *pbuff = buff; | |||
90 | const DTYPEmlib_d64 *pk; | |||
91 | DTYPEmlib_d64 k0, k1, k2, k3; | |||
92 | DTYPEmlib_d64 p0, p1, p2, p3, p4; | |||
93 | DTYPEmlib_d64 *sp, *sl_c, *dl_c, *sl0; | |||
94 | DEF_VARS(DTYPE)mlib_s32 hgt = mlib_ImageGetHeight(src); mlib_s32 wid = mlib_ImageGetWidth (src); mlib_s32 sll = mlib_ImageGetStride(src) / sizeof(mlib_d64 ); mlib_s32 dll = mlib_ImageGetStride(dst) / sizeof(mlib_d64) ; mlib_d64* adr_src = mlib_ImageGetData(src); mlib_d64* adr_dst = mlib_ImageGetData(dst); mlib_s32 chan1 = mlib_ImageGetChannels (src); mlib_d64 *sl; mlib_d64 *dl, *dp = ((void*)0); mlib_s32 i = 0, j, c; | |||
95 | mlib_s32 off, kh; | |||
96 | mlib_s32 l, hsize, max_hsize; | |||
97 | ||||
98 | hgt -= (n - 1); | |||
99 | adr_dst += dn*dll; | |||
100 | ||||
101 | max_hsize = (CACHE_SIZE(64*1024)/sizeof(DTYPEmlib_d64))/sll; | |||
102 | ||||
103 | if (!max_hsize) max_hsize = 1; | |||
104 | ||||
105 | if (max_hsize > BUFF_SIZE1600) { | |||
106 | pbuff = mlib_malloc(sizeof(DTYPEmlib_d64)*max_hsize); | |||
107 | } | |||
108 | ||||
109 | sl_c = adr_src; | |||
110 | dl_c = adr_dst; | |||
111 | ||||
112 | for (l = 0; l < hgt; l += hsize) { | |||
113 | hsize = hgt - l; | |||
114 | ||||
115 | if (hsize > max_hsize) hsize = max_hsize; | |||
116 | ||||
117 | for (c = 0; c < chan1; c++) { | |||
118 | if (!(cmask & (1 << (chan1 - 1 - c)))) continue; | |||
119 | ||||
120 | sl = sl_c + c; | |||
121 | dl = dl_c + c; | |||
122 | ||||
123 | for (j = 0; j < hsize; j++) pbuff[j] = 0.0; | |||
124 | ||||
125 | for (i = 0; i < wid; i++) { | |||
126 | sl0 = sl; | |||
127 | ||||
128 | for (off = 0; off < (n - 4); off += 4) { | |||
129 | pk = k + off; | |||
130 | sp = sl0; | |||
131 | ||||
132 | k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3]; | |||
133 | p2 = sp[0]; p3 = sp[sll]; p4 = sp[2*sll]; | |||
134 | sp += 3*sll; | |||
135 | ||||
136 | for (j = 0; j < hsize; j += 2) { | |||
137 | p0 = p2; p1 = p3; p2 = p4; | |||
138 | p3 = sp[0]; | |||
139 | p4 = sp[sll]; | |||
140 | ||||
141 | pbuff[j ] += p0*k0 + p1*k1 + p2*k2 + p3*k3; | |||
142 | pbuff[j + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3; | |||
143 | ||||
144 | sp += 2*sll; | |||
145 | } | |||
146 | ||||
147 | sl0 += 4*sll; | |||
148 | } | |||
149 | ||||
150 | pk = k + off; | |||
151 | sp = sl0; | |||
152 | ||||
153 | k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3]; | |||
154 | p2 = sp[0]; p3 = sp[sll]; p4 = sp[2*sll]; | |||
155 | ||||
156 | dp = dl; | |||
157 | kh = n - off; | |||
158 | ||||
159 | if (kh == 4) { | |||
160 | sp += 3*sll; | |||
161 | ||||
162 | for (j = 0; j <= (hsize - 2); j += 2) { | |||
163 | p0 = p2; p1 = p3; p2 = p4; | |||
164 | p3 = sp[0]; | |||
165 | p4 = sp[sll]; | |||
166 | ||||
167 | dp[0 ] = p0*k0 + p1*k1 + p2*k2 + p3*k3 + pbuff[j]; | |||
168 | dp[dll] = p1*k0 + p2*k1 + p3*k2 + p4*k3 + pbuff[j + 1]; | |||
169 | ||||
170 | pbuff[j] = 0; | |||
171 | pbuff[j + 1] = 0; | |||
172 | ||||
173 | sp += 2*sll; | |||
174 | dp += 2*dll; | |||
175 | } | |||
176 | ||||
177 | if (j < hsize) { | |||
178 | p0 = p2; p1 = p3; p2 = p4; | |||
179 | p3 = sp[0]; | |||
180 | ||||
181 | dp[0] = p0*k0 + p1*k1 + p2*k2 + p3*k3 + pbuff[j]; | |||
182 | ||||
183 | pbuff[j] = 0; | |||
184 | } | |||
185 | ||||
186 | } else if (kh == 3) { | |||
187 | sp += 2*sll; | |||
188 | ||||
189 | for (j = 0; j <= (hsize - 2); j += 2) { | |||
190 | p0 = p2; p1 = p3; | |||
191 | p2 = sp[0]; | |||
192 | p3 = sp[sll]; | |||
193 | ||||
194 | dp[0 ] = p0*k0 + p1*k1 + p2*k2 + pbuff[j]; | |||
195 | dp[dll] = p1*k0 + p2*k1 + p3*k2 + pbuff[j + 1]; | |||
196 | ||||
197 | pbuff[j] = 0; | |||
198 | pbuff[j + 1] = 0; | |||
199 | ||||
200 | sp += 2*sll; | |||
201 | dp += 2*dll; | |||
202 | } | |||
203 | ||||
204 | if (j < hsize) { | |||
205 | p0 = p2; p1 = p3; | |||
206 | p2 = sp[0]; | |||
207 | ||||
208 | dp[0] = p0*k0 + p1*k1 + p2*k2 + pbuff[j]; | |||
209 | ||||
210 | pbuff[j] = 0; | |||
211 | } | |||
212 | ||||
213 | } else if (kh == 2) { | |||
214 | sp += sll; | |||
215 | ||||
216 | for (j = 0; j <= (hsize - 2); j += 2) { | |||
217 | p0 = p2; | |||
218 | p1 = sp[0]; | |||
219 | p2 = sp[sll]; | |||
220 | ||||
221 | dp[0 ] = p0*k0 + p1*k1 + pbuff[j]; | |||
| ||||
222 | dp[dll] = p1*k0 + p2*k1 + pbuff[j + 1]; | |||
223 | ||||
224 | pbuff[j] = 0; | |||
225 | pbuff[j + 1] = 0; | |||
226 | ||||
227 | sp += 2*sll; | |||
228 | dp += 2*dll; | |||
229 | } | |||
230 | ||||
231 | if (j < hsize) { | |||
232 | p0 = p2; | |||
233 | p1 = sp[0]; | |||
234 | ||||
235 | dp[0] = p0*k0 + p1*k1 + pbuff[j]; | |||
236 | ||||
237 | pbuff[j] = 0; | |||
238 | } | |||
239 | ||||
240 | } else /* if (kh == 1) */ { | |||
241 | for (j = 0; j < hsize; j++) { | |||
242 | p0 = sp[0]; | |||
243 | ||||
244 | dp[0] = p0*k0 + pbuff[j]; | |||
245 | ||||
246 | pbuff[j] = 0; | |||
247 | ||||
248 | sp += sll; | |||
249 | dp += dll; | |||
250 | } | |||
251 | } | |||
252 | ||||
253 | sl += chan1; | |||
254 | dl += chan1; | |||
255 | } | |||
256 | } | |||
257 | ||||
258 | sl_c += max_hsize*sll; | |||
259 | dl_c += max_hsize*dll; | |||
260 | } | |||
261 | ||||
262 | if (pbuff != buff) mlib_free(pbuff); | |||
263 | ||||
264 | return MLIB_SUCCESS; | |||
265 | } | |||
266 | ||||
267 | /***************************************************************/ | |||
268 | #define MAX_KER7 7 | |||
269 | #define MAX_NM81 81 | |||
270 | ||||
271 | mlib_status CONV_FUNC(MxN)mlib_convMxNnw_d64(mlib_image *dst, | |||
272 | const mlib_image *src, | |||
273 | const mlib_d64 *ker, | |||
274 | mlib_s32 m, | |||
275 | mlib_s32 n, | |||
276 | mlib_s32 dm, | |||
277 | mlib_s32 dn, | |||
278 | mlib_s32 cmask) | |||
279 | { | |||
280 | DTYPEmlib_d64 k0, k1, k2, k3, k4, k5, k6, *sp; | |||
281 | DTYPEmlib_d64 p0, p1, p2, p3, p4, p5, p6, p7; | |||
282 | mlib_s32 l, off, kw; | |||
283 | DEF_VARS(DTYPE)mlib_s32 hgt = mlib_ImageGetHeight(src); mlib_s32 wid = mlib_ImageGetWidth (src); mlib_s32 sll = mlib_ImageGetStride(src) / sizeof(mlib_d64 ); mlib_s32 dll = mlib_ImageGetStride(dst) / sizeof(mlib_d64) ; mlib_d64* adr_src = mlib_ImageGetData(src); mlib_d64* adr_dst = mlib_ImageGetData(dst); mlib_s32 chan1 = mlib_ImageGetChannels (src); mlib_d64 *sl; mlib_d64 *dl, *dp = ((void*)0); mlib_s32 i = 0, j, c; | |||
284 | mlib_s32 chan2 = chan1 + chan1; | |||
285 | mlib_s32 chan3 = chan1 + chan2; | |||
286 | ||||
287 | #ifdef TYPE_DOUBLE | |||
288 | const mlib_d64 *k = ker; | |||
289 | #else | |||
290 | mlib_f32 k_arr[MAX_NM81], *k = k_arr; | |||
291 | ||||
292 | if (n*m > MAX_NM81) { | |||
293 | k = mlib_malloc(n*m*sizeof(mlib_f32)); | |||
294 | ||||
295 | if (k == NULL((void*)0)) return MLIB_FAILURE; | |||
296 | } | |||
297 | ||||
298 | for (i = 0; i < n*m; i++) k[i] = (mlib_f32)ker[i]; | |||
299 | #endif /* TYPE_DOUBLE */ | |||
300 | ||||
301 | if (m == 1) return mlib_ImageConv1xN(dst, src, k, n, dn, cmask); | |||
| ||||
302 | ||||
303 | wid -= (m - 1); | |||
304 | hgt -= (n - 1); | |||
305 | adr_dst += dn*dll + dm*chan1; | |||
306 | ||||
307 | for (c = 0; c < chan1; c++) { | |||
308 | if (!(cmask & (1 << (chan1 - 1 - c)))) continue; | |||
309 | ||||
310 | sl = adr_src + c; | |||
311 | dl = adr_dst + c; | |||
312 | ||||
313 | for (j = 0; j < hgt; j++) { | |||
314 | const DTYPEmlib_d64 *pk = k; | |||
315 | ||||
316 | for (l = 0; l < n; l++) { | |||
317 | DTYPEmlib_d64 *sp0 = sl + l*sll; | |||
318 | ||||
319 | for (off = 0; off < m; off += kw, pk += kw, sp0 += chan1) { | |||
320 | kw = m - off; | |||
321 | ||||
322 | if (kw > 2*MAX_KER7) kw = MAX_KER7; else | |||
323 | if (kw > MAX_KER7) kw = kw/2; | |||
324 | ||||
325 | p2 = sp0[0]; p3 = sp0[chan1]; p4 = sp0[chan2]; | |||
326 | sp0 += chan3; | |||
327 | p5 = sp0[0]; p6 = sp0[chan1]; p7 = sp0[chan2]; | |||
328 | ||||
329 | k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3]; | |||
330 | k4 = pk[4]; k5 = pk[5]; k6 = pk[6]; | |||
331 | ||||
332 | dp = dl; | |||
333 | ||||
334 | if (kw == 7) { | |||
335 | sp = sp0 += chan3; | |||
336 | ||||
337 | if (pk == k) { | |||
338 | for (i = 0; i <= (wid - 2); i += 2) { | |||
339 | p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; | |||
340 | ||||
341 | p5 = sp[- chan1]; p6 = sp[0]; p7 = sp[chan1]; | |||
342 | ||||
343 | dp[0 ] = p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6; | |||
344 | dp[chan1] = p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6; | |||
345 | ||||
346 | sp += chan2; | |||
347 | dp += chan2; | |||
348 | } | |||
349 | ||||
350 | } else { | |||
351 | for (i = 0; i <= (wid - 2); i += 2) { | |||
352 | p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; | |||
353 | ||||
354 | p5 = sp[- chan1]; p6 = sp[0]; p7 = sp[chan1]; | |||
355 | ||||
356 | dp[0 ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6; | |||
357 | dp[chan1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6; | |||
358 | ||||
359 | sp += chan2; | |||
360 | dp += chan2; | |||
361 | } | |||
362 | } | |||
363 | ||||
364 | } else if (kw == 6) { | |||
365 | sp = sp0 += chan2; | |||
366 | ||||
367 | if (pk == k) { | |||
368 | for (i = 0; i <= (wid - 2); i += 2) { | |||
369 | p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; | |||
370 | ||||
371 | p5 = sp[0]; p6 = sp[chan1]; | |||
372 | ||||
373 | dp[0 ] = p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5; | |||
374 | dp[chan1] = p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5; | |||
375 | ||||
376 | sp += chan2; | |||
377 | dp += chan2; | |||
378 | } | |||
379 | ||||
380 | } else { | |||
381 | for (i = 0; i <= (wid - 2); i += 2) { | |||
382 | p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; | |||
383 | ||||
384 | p5 = sp[0]; p6 = sp[chan1]; | |||
385 | ||||
386 | dp[0 ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5; | |||
387 | dp[chan1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5; | |||
388 | ||||
389 | sp += chan2; | |||
390 | dp += chan2; | |||
391 | } | |||
392 | } | |||
393 | ||||
394 | } else if (kw == 5) { | |||
395 | sp = sp0 += chan1; | |||
396 | ||||
397 | if (pk == k) { | |||
398 | for (i = 0; i <= (wid - 2); i += 2) { | |||
399 | p0 = p2; p1 = p3; p2 = p4; p3 = p5; | |||
400 | ||||
401 | p4 = sp[0]; p5 = sp[chan1]; | |||
402 | ||||
403 | dp[0 ] = p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4; | |||
404 | dp[chan1] = p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4; | |||
405 | ||||
406 | sp += chan2; | |||
407 | dp += chan2; | |||
408 | } | |||
409 | ||||
410 | } else { | |||
411 | for (i = 0; i <= (wid - 2); i += 2) { | |||
412 | p0 = p2; p1 = p3; p2 = p4; p3 = p5; | |||
413 | ||||
414 | p4 = sp[0]; p5 = sp[chan1]; | |||
415 | ||||
416 | dp[0 ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4; | |||
417 | dp[chan1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4; | |||
418 | ||||
419 | sp += chan2; | |||
420 | dp += chan2; | |||
421 | } | |||
422 | } | |||
423 | ||||
424 | } else if (kw == 4) { | |||
425 | ||||
426 | sp = sp0; | |||
427 | ||||
428 | if (pk == k) { | |||
429 | for (i = 0; i <= (wid - 2); i += 2) { | |||
430 | p0 = p2; p1 = p3; p2 = p4; | |||
431 | ||||
432 | p3 = sp[0]; p4 = sp[chan1]; | |||
433 | ||||
434 | dp[0 ] = p0*k0 + p1*k1 + p2*k2 + p3*k3; | |||
435 | dp[chan1] = p1*k0 + p2*k1 + p3*k2 + p4*k3; | |||
436 | ||||
437 | sp += chan2; | |||
438 | dp += chan2; | |||
439 | } | |||
440 | ||||
441 | } else { | |||
442 | for (i = 0; i <= (wid - 2); i += 2) { | |||
443 | p0 = p2; p1 = p3; p2 = p4; | |||
444 | ||||
445 | p3 = sp[0]; p4 = sp[chan1]; | |||
446 | ||||
447 | dp[0 ] += p0*k0 + p1*k1 + p2*k2 + p3*k3; | |||
448 | dp[chan1] += p1*k0 + p2*k1 + p3*k2 + p4*k3; | |||
449 | ||||
450 | sp += chan2; | |||
451 | dp += chan2; | |||
452 | } | |||
453 | } | |||
454 | ||||
455 | } else if (kw == 3) { | |||
456 | sp = sp0 -= chan1; | |||
457 | ||||
458 | if (pk == k) { | |||
459 | for (i = 0; i <= (wid - 2); i += 2) { | |||
460 | p0 = p2; p1 = p3; | |||
461 | ||||
462 | p2 = sp[0]; p3 = sp[chan1]; | |||
463 | ||||
464 | dp[0 ] = p0*k0 + p1*k1 + p2*k2; | |||
465 | dp[chan1] = p1*k0 + p2*k1 + p3*k2; | |||
466 | ||||
467 | sp += chan2; | |||
468 | dp += chan2; | |||
469 | } | |||
470 | ||||
471 | } else { | |||
472 | for (i = 0; i <= (wid - 2); i += 2) { | |||
473 | p0 = p2; p1 = p3; | |||
474 | ||||
475 | p2 = sp[0]; p3 = sp[chan1]; | |||
476 | ||||
477 | dp[0 ] += p0*k0 + p1*k1 + p2*k2; | |||
478 | dp[chan1] += p1*k0 + p2*k1 + p3*k2; | |||
479 | ||||
480 | sp += chan2; | |||
481 | dp += chan2; | |||
482 | } | |||
483 | } | |||
484 | ||||
485 | } else { /* kw == 2 */ | |||
486 | sp = sp0 -= chan2; | |||
487 | ||||
488 | if (pk == k) { | |||
489 | for (i = 0; i <= (wid - 2); i += 2) { | |||
490 | p0 = p2; | |||
491 | ||||
492 | p1 = sp[0]; p2 = sp[chan1]; | |||
493 | ||||
494 | dp[0 ] = p0*k0 + p1*k1; | |||
495 | dp[chan1] = p1*k0 + p2*k1; | |||
496 | ||||
497 | sp += chan2; | |||
498 | dp += chan2; | |||
499 | } | |||
500 | ||||
501 | } else { | |||
502 | for (i = 0; i <= (wid - 2); i += 2) { | |||
503 | p0 = p2; | |||
504 | ||||
505 | p1 = sp[0]; p2 = sp[chan1]; | |||
506 | ||||
507 | dp[0 ] += p0*k0 + p1*k1; | |||
508 | dp[chan1] += p1*k0 + p2*k1; | |||
509 | ||||
510 | sp += chan2; | |||
511 | dp += chan2; | |||
512 | } | |||
513 | } | |||
514 | } | |||
515 | } | |||
516 | } | |||
517 | ||||
518 | /* last pixels */ | |||
519 | ||||
520 | if (wid & 1) { | |||
521 | DTYPEmlib_d64 *sp0 = sl + i*chan1, s = 0; | |||
522 | const DTYPEmlib_d64 *pk = k; | |||
523 | mlib_s32 x; | |||
524 | ||||
525 | for (l = 0; l < n; l++) { | |||
526 | DTYPEmlib_d64 *sp = sp0 + l*sll; | |||
527 | ||||
528 | for (x = 0; x < m; x++) s += sp[x*chan1] * (*pk++); | |||
529 | } | |||
530 | ||||
531 | dp[0] = s; | |||
532 | } | |||
533 | ||||
534 | /* next line */ | |||
535 | sl += sll; | |||
536 | dl += dll; | |||
537 | } | |||
538 | } | |||
539 | ||||
540 | #ifndef TYPE_DOUBLE | |||
541 | ||||
542 | if (k != k_arr) mlib_free(k); | |||
543 | #endif /* TYPE_DOUBLE */ | |||
544 | ||||
545 | return MLIB_SUCCESS; | |||
546 | } | |||
547 | ||||
548 | /***************************************************************/ |