172 #define DEF_VARS(type) \
173 type *adr_src, *sl, *sp, *sl1; \
174 type *adr_dst, *dl, *dp; \
175 FTYPE *pbuff = buff; \
176 mlib_s32 *buffi, *buffo; \
177 mlib_s32 wid, hgt, sll, dll; \
178 mlib_s32 nchannel, chan1, chan2; \
179 mlib_s32 i, j, c, swid
180
181 /***************************************************************/
182 #define GET_SRC_DST_PARAMETERS(type) \
183 hgt = mlib_ImageGetHeight(src); \
184 wid = mlib_ImageGetWidth(src); \
185 nchannel = mlib_ImageGetChannels(src); \
186 sll = mlib_ImageGetStride(src) / sizeof(type); \
187 dll = mlib_ImageGetStride(dst) / sizeof(type); \
188 adr_src = (type *)mlib_ImageGetData(src); \
189 adr_dst = (type *)mlib_ImageGetData(dst)
190
191 /***************************************************************/
192 #ifndef __sparc
193 #if IMG_TYPE == 1
194
195 /*
196 * Test for the presence of any "1" bit in bits
197 8 to 31 of val. If present, then val is either
198 negative or >255. If over/underflows of 8 bits
199 are uncommon, then this technique can be a win,
200 since only a single test, rather than two, is
201 necessary to determine if clamping is needed.
202 On the other hand, if over/underflows are common,
203 it adds an extra test.
204 */
205 #define CLAMP_STORE(dst, val) \
206 if (val & 0xffffff00) { \
207 if (val < MLIB_U8_MIN) \
208 dst = MLIB_U8_MIN; \
209 else \
210 dst = MLIB_U8_MAX; \
211 } else { \
212 dst = (mlib_u8)val; \
216
217 #define CLAMP_STORE(dst, val) \
218 if (val >= MLIB_S16_MAX) \
219 dst = MLIB_S16_MAX; \
220 else if (val <= MLIB_S16_MIN) \
221 dst = MLIB_S16_MIN; \
222 else \
223 dst = (mlib_s16)val
224
225 #elif IMG_TYPE == 3
226
227 #define CLAMP_STORE(dst, val) \
228 if (val >= MLIB_U16_MAX) \
229 dst = MLIB_U16_MAX; \
230 else if (val <= MLIB_U16_MIN) \
231 dst = MLIB_U16_MIN; \
232 else \
233 dst = (mlib_u16)val
234
235 #endif /* IMG_TYPE == 1 */
236 #endif /* __sparc */
237
238 /***************************************************************/
239 #define MAX_KER 7
240 #define MAX_N 15
241 #define BUFF_SIZE 1600
242 #define CACHE_SIZE (64*1024)
243
244 static mlib_status mlib_ImageConv1xN_ext(mlib_image *dst,
245 const mlib_image *src,
246 const mlib_d64 *k,
247 mlib_s32 n,
248 mlib_s32 dy_t,
249 mlib_s32 dy_b,
250 mlib_s32 cmask)
251 {
252 DTYPE *adr_src, *sl;
253 DTYPE *adr_dst, *dl, *dp;
254 FTYPE buff[BUFF_SIZE];
255 FTYPE *buffd;
256 FTYPE *pbuff = buff;
943 }
944
945 for (i = 0; i < dx_l; i++) buffn[i] = buffn[dx_l];
946 for (i = 0; i < dx_r; i++) buffn[swid + dx_l + i] = buffn[swid + dx_l - 1];
947
948 /* next line */
949
950 if (j < hgt - dy_b - 2) sl += sll;
951 dl += dll;
952
953 buff_ind++;
954
955 if (buff_ind >= n + 1) buff_ind = 0;
956 }
957 }
958
959 FREE_AND_RETURN_STATUS;
960 }
961
962 /***************************************************************/
963 #ifndef __sparc /* for x86, using integer multiplies is faster */
964
965 #define STORE_RES(res, x) \
966 x >>= shift2; \
967 CLAMP_STORE(res, x)
968
969 mlib_status CONV_FUNC_MxN_I
970 {
971 DTYPE *adr_src, *sl, *sp = NULL;
972 DTYPE *adr_dst, *dl, *dp = NULL;
973 mlib_s32 buff[BUFF_SIZE], *buffs_arr[2*(MAX_N + 1)];
974 mlib_s32 *pbuff = buff;
975 mlib_s32 **buffs = buffs_arr, *buffd;
976 mlib_s32 l, off, kw, bsize, buff_ind;
977 mlib_s32 d0, d1, shift1, shift2;
978 mlib_s32 k0, k1, k2, k3, k4, k5, k6;
979 mlib_s32 p0, p1, p2, p3, p4, p5, p6, p7;
980 mlib_s32 wid, hgt, sll, dll;
981 mlib_s32 nchannel, chan1;
982 mlib_s32 i, j, c, swid;
983 mlib_s32 chan2;
984 mlib_s32 k_locl[MAX_N*MAX_N], *k = k_locl;
1421
1422 for (i = 0; i < dx_l; i++) buffn[i] = buffn[dx_l];
1423 for (i = 0; i < dx_r; i++) buffn[swid + dx_l + i] = buffn[swid + dx_l - 1];
1424
1425 /* next line */
1426
1427 if (j < hgt - dy_b - 2) sl += sll;
1428 dl += dll;
1429
1430 buff_ind++;
1431
1432 if (buff_ind >= n + 1) buff_ind = 0;
1433 }
1434 }
1435
1436 if (pbuff != buff) mlib_free(pbuff);
1437 if (k != k_locl) mlib_free(k);
1438
1439 return MLIB_SUCCESS;
1440 }
1441
1442 #endif /* __sparc ( for x86, using integer multiplies is faster ) */
1443
1444 /***************************************************************/
|
172 #define DEF_VARS(type) \
173 type *adr_src, *sl, *sp, *sl1; \
174 type *adr_dst, *dl, *dp; \
175 FTYPE *pbuff = buff; \
176 mlib_s32 *buffi, *buffo; \
177 mlib_s32 wid, hgt, sll, dll; \
178 mlib_s32 nchannel, chan1, chan2; \
179 mlib_s32 i, j, c, swid
180
181 /***************************************************************/
182 #define GET_SRC_DST_PARAMETERS(type) \
183 hgt = mlib_ImageGetHeight(src); \
184 wid = mlib_ImageGetWidth(src); \
185 nchannel = mlib_ImageGetChannels(src); \
186 sll = mlib_ImageGetStride(src) / sizeof(type); \
187 dll = mlib_ImageGetStride(dst) / sizeof(type); \
188 adr_src = (type *)mlib_ImageGetData(src); \
189 adr_dst = (type *)mlib_ImageGetData(dst)
190
191 /***************************************************************/
192 #if IMG_TYPE == 1
193
194 /*
195 * Test for the presence of any "1" bit in bits
196 8 to 31 of val. If present, then val is either
197 negative or >255. If over/underflows of 8 bits
198 are uncommon, then this technique can be a win,
199 since only a single test, rather than two, is
200 necessary to determine if clamping is needed.
201 On the other hand, if over/underflows are common,
202 it adds an extra test.
203 */
204 #define CLAMP_STORE(dst, val) \
205 if (val & 0xffffff00) { \
206 if (val < MLIB_U8_MIN) \
207 dst = MLIB_U8_MIN; \
208 else \
209 dst = MLIB_U8_MAX; \
210 } else { \
211 dst = (mlib_u8)val; \
215
216 #define CLAMP_STORE(dst, val) \
217 if (val >= MLIB_S16_MAX) \
218 dst = MLIB_S16_MAX; \
219 else if (val <= MLIB_S16_MIN) \
220 dst = MLIB_S16_MIN; \
221 else \
222 dst = (mlib_s16)val
223
224 #elif IMG_TYPE == 3
225
226 #define CLAMP_STORE(dst, val) \
227 if (val >= MLIB_U16_MAX) \
228 dst = MLIB_U16_MAX; \
229 else if (val <= MLIB_U16_MIN) \
230 dst = MLIB_U16_MIN; \
231 else \
232 dst = (mlib_u16)val
233
234 #endif /* IMG_TYPE == 1 */
235
236 /***************************************************************/
237 #define MAX_KER 7
238 #define MAX_N 15
239 #define BUFF_SIZE 1600
240 #define CACHE_SIZE (64*1024)
241
242 static mlib_status mlib_ImageConv1xN_ext(mlib_image *dst,
243 const mlib_image *src,
244 const mlib_d64 *k,
245 mlib_s32 n,
246 mlib_s32 dy_t,
247 mlib_s32 dy_b,
248 mlib_s32 cmask)
249 {
250 DTYPE *adr_src, *sl;
251 DTYPE *adr_dst, *dl, *dp;
252 FTYPE buff[BUFF_SIZE];
253 FTYPE *buffd;
254 FTYPE *pbuff = buff;
941 }
942
943 for (i = 0; i < dx_l; i++) buffn[i] = buffn[dx_l];
944 for (i = 0; i < dx_r; i++) buffn[swid + dx_l + i] = buffn[swid + dx_l - 1];
945
946 /* next line */
947
948 if (j < hgt - dy_b - 2) sl += sll;
949 dl += dll;
950
951 buff_ind++;
952
953 if (buff_ind >= n + 1) buff_ind = 0;
954 }
955 }
956
957 FREE_AND_RETURN_STATUS;
958 }
959
960 /***************************************************************/
961 #define STORE_RES(res, x) \
962 x >>= shift2; \
963 CLAMP_STORE(res, x)
964
965 mlib_status CONV_FUNC_MxN_I
966 {
967 DTYPE *adr_src, *sl, *sp = NULL;
968 DTYPE *adr_dst, *dl, *dp = NULL;
969 mlib_s32 buff[BUFF_SIZE], *buffs_arr[2*(MAX_N + 1)];
970 mlib_s32 *pbuff = buff;
971 mlib_s32 **buffs = buffs_arr, *buffd;
972 mlib_s32 l, off, kw, bsize, buff_ind;
973 mlib_s32 d0, d1, shift1, shift2;
974 mlib_s32 k0, k1, k2, k3, k4, k5, k6;
975 mlib_s32 p0, p1, p2, p3, p4, p5, p6, p7;
976 mlib_s32 wid, hgt, sll, dll;
977 mlib_s32 nchannel, chan1;
978 mlib_s32 i, j, c, swid;
979 mlib_s32 chan2;
980 mlib_s32 k_locl[MAX_N*MAX_N], *k = k_locl;
1417
1418 for (i = 0; i < dx_l; i++) buffn[i] = buffn[dx_l];
1419 for (i = 0; i < dx_r; i++) buffn[swid + dx_l + i] = buffn[swid + dx_l - 1];
1420
1421 /* next line */
1422
1423 if (j < hgt - dy_b - 2) sl += sll;
1424 dl += dll;
1425
1426 buff_ind++;
1427
1428 if (buff_ind >= n + 1) buff_ind = 0;
1429 }
1430 }
1431
1432 if (pbuff != buff) mlib_free(pbuff);
1433 if (k != k_locl) mlib_free(k);
1434
1435 return MLIB_SUCCESS;
1436 }
1437
1438 /***************************************************************/
|