< prev index next >

src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16ext.c

Print this page




 512     fscale *= 1.0/(1 << 30);
 513     scale -= 30;
 514   }
 515 
 516   fscale /= (1 << scale);
 517 
 518   mn = m*n;
 519 
 520   if (mn > 256) {
 521     k = mlib_malloc(mn*sizeof(mlib_d64));
 522 
 523     if (k == NULL) return MLIB_FAILURE;
 524   }
 525 
 526   for (i = 0; i < mn; i++) {
 527     k[i] = kernel[i]*fscale;
 528   }
 529 
 530   if (m == 1) {
 531     status = mlib_ImageConv1xN_ext(dst, src, k, n, dy_t, dy_b, cmask);
 532     FREE_AND_RETURN_STATUS;
 533   }
 534 
 535   swid = wid + (m - 1);
 536 
 537   bsize = (n + 3)*swid;
 538 
 539   if ((bsize > BUFF_SIZE) || (n > MAX_N)) {
 540     pbuff = mlib_malloc(sizeof(FTYPE)*bsize + sizeof(FTYPE *)*2*(n + 1));
 541 
 542     if (pbuff == NULL) {
 543       status = MLIB_FAILURE;
 544       FREE_AND_RETURN_STATUS;
 545     }
 546     buffs = (FTYPE   **)(pbuff + bsize);
 547   }
 548 
 549   for (l = 0; l < (n + 1); l++) buffs[l] = pbuff + l*swid;
 550   for (l = 0; l < (n + 1); l++) buffs[l + (n + 1)] = buffs[l];
 551   buffd = buffs[n] + swid;
 552   buffi = (mlib_s32*)(buffd + swid);
 553 
 554   chan1 = nchannel;
 555   chan2 = chan1 + chan1;
 556 
 557   swid -= (dx_l + dx_r);
 558 
 559   for (c = 0; c < nchannel; c++) {
 560     if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
 561 
 562     sl = adr_src + c;
 563     dl = adr_dst + c;
 564 


 929 
 930       for (; i < swid; i++) {
 931         buffn[i + dx_l] = (FTYPE)sp[0];
 932         sp += chan1;
 933       }
 934 
 935       for (i = 0; i < dx_l; i++) buffn[i] = buffn[dx_l];
 936       for (i = 0; i < dx_r; i++) buffn[swid + dx_l + i] = buffn[swid + dx_l - 1];
 937 
 938       /* next line */
 939 
 940       if (j < hgt - dy_b - 2) sl += sll;
 941       dl += dll;
 942 
 943       buff_ind++;
 944 
 945       if (buff_ind >= n + 1) buff_ind = 0;
 946     }
 947   }
 948 
 949   FREE_AND_RETURN_STATUS;
 950 }
 951 
 952 /***************************************************************/
 953 #ifndef __sparc /* for x86, using integer multiplies is faster */
 954 
 955 #define STORE_RES(res, x)                                       \
 956   x >>= shift2;                                                 \
 957   CLAMP_STORE(res, x)
 958 
 959 mlib_status CONV_FUNC_MxN_I
 960 {
 961   DTYPE    *adr_src, *sl, *sp = NULL;
 962   DTYPE    *adr_dst, *dl, *dp = NULL;
 963   mlib_s32 buff[BUFF_SIZE], *buffs_arr[2*(MAX_N + 1)];
 964   mlib_s32 *pbuff = buff;
 965   mlib_s32 **buffs = buffs_arr, *buffd;
 966   mlib_s32 l, off, kw, bsize, buff_ind;
 967   mlib_s32 d0, d1, shift1, shift2;
 968   mlib_s32 k0, k1, k2, k3, k4, k5, k6;
 969   mlib_s32 p0, p1, p2, p3, p4, p5, p6, p7;




 512     fscale *= 1.0/(1 << 30);
 513     scale -= 30;
 514   }
 515 
 516   fscale /= (1 << scale);
 517 
 518   mn = m*n;
 519 
 520   if (mn > 256) {
 521     k = mlib_malloc(mn*sizeof(mlib_d64));
 522 
 523     if (k == NULL) return MLIB_FAILURE;
 524   }
 525 
 526   for (i = 0; i < mn; i++) {
 527     k[i] = kernel[i]*fscale;
 528   }
 529 
 530   if (m == 1) {
 531     status = mlib_ImageConv1xN_ext(dst, src, k, n, dy_t, dy_b, cmask);
 532     FREE_AND_RETURN_STATUS
 533   }
 534 
 535   swid = wid + (m - 1);
 536 
 537   bsize = (n + 3)*swid;
 538 
 539   if ((bsize > BUFF_SIZE) || (n > MAX_N)) {
 540     pbuff = mlib_malloc(sizeof(FTYPE)*bsize + sizeof(FTYPE *)*2*(n + 1));
 541 
 542     if (pbuff == NULL) {
 543       status = MLIB_FAILURE;
 544       FREE_AND_RETURN_STATUS
 545     }
 546     buffs = (FTYPE   **)(pbuff + bsize);
 547   }
 548 
 549   for (l = 0; l < (n + 1); l++) buffs[l] = pbuff + l*swid;
 550   for (l = 0; l < (n + 1); l++) buffs[l + (n + 1)] = buffs[l];
 551   buffd = buffs[n] + swid;
 552   buffi = (mlib_s32*)(buffd + swid);
 553 
 554   chan1 = nchannel;
 555   chan2 = chan1 + chan1;
 556 
 557   swid -= (dx_l + dx_r);
 558 
 559   for (c = 0; c < nchannel; c++) {
 560     if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
 561 
 562     sl = adr_src + c;
 563     dl = adr_dst + c;
 564 


 929 
 930       for (; i < swid; i++) {
 931         buffn[i + dx_l] = (FTYPE)sp[0];
 932         sp += chan1;
 933       }
 934 
 935       for (i = 0; i < dx_l; i++) buffn[i] = buffn[dx_l];
 936       for (i = 0; i < dx_r; i++) buffn[swid + dx_l + i] = buffn[swid + dx_l - 1];
 937 
 938       /* next line */
 939 
 940       if (j < hgt - dy_b - 2) sl += sll;
 941       dl += dll;
 942 
 943       buff_ind++;
 944 
 945       if (buff_ind >= n + 1) buff_ind = 0;
 946     }
 947   }
 948 
 949   FREE_AND_RETURN_STATUS
 950 }
 951 
 952 /***************************************************************/
 953 #ifndef __sparc /* for x86, using integer multiplies is faster */
 954 
 955 #define STORE_RES(res, x)                                       \
 956   x >>= shift2;                                                 \
 957   CLAMP_STORE(res, x)
 958 
 959 mlib_status CONV_FUNC_MxN_I
 960 {
 961   DTYPE    *adr_src, *sl, *sp = NULL;
 962   DTYPE    *adr_dst, *dl, *dp = NULL;
 963   mlib_s32 buff[BUFF_SIZE], *buffs_arr[2*(MAX_N + 1)];
 964   mlib_s32 *pbuff = buff;
 965   mlib_s32 **buffs = buffs_arr, *buffd;
 966   mlib_s32 l, off, kw, bsize, buff_ind;
 967   mlib_s32 d0, d1, shift1, shift2;
 968   mlib_s32 k0, k1, k2, k3, k4, k5, k6;
 969   mlib_s32 p0, p1, p2, p3, p4, p5, p6, p7;


< prev index next >