< prev index next >

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

Print this page




 468     fscale *= 1.0/(1 << 30);
 469     scale -= 30;
 470   }
 471 
 472   fscale /= (1 << scale);
 473 
 474   mn = m*n;
 475 
 476   if (mn > 256) {
 477     k = mlib_malloc(mn*sizeof(mlib_d64));
 478 
 479     if (k == NULL) return MLIB_FAILURE;
 480   }
 481 
 482   for (i = 0; i < mn; i++) {
 483     k[i] = kernel[i]*fscale;
 484   }
 485 
 486   if (m == 1) {
 487     status = mlib_ImageConv1xN(dst, src, k, n, dn, cmask);
 488     FREE_AND_RETURN_STATUS;
 489   }
 490 
 491   bsize = (n + 3)*wid;
 492 
 493   if ((bsize > BUFF_SIZE) || (n > MAX_N)) {
 494     pbuff = mlib_malloc(sizeof(FTYPE)*bsize + sizeof(FTYPE *)*2*(n + 1));
 495 
 496     if (pbuff == NULL) {
 497       status = MLIB_FAILURE;
 498       FREE_AND_RETURN_STATUS;
 499     }
 500     buffs = (FTYPE   **)(pbuff + bsize);
 501   }
 502 
 503   for (l = 0; l < (n + 1); l++) buffs[l] = pbuff + l*wid;
 504   for (l = 0; l < (n + 1); l++) buffs[l + (n + 1)] = buffs[l];
 505   buffd = buffs[n] + wid;
 506   buffo = (mlib_s32*)(buffd + wid);
 507   buffi = buffo + (wid &~ 1);
 508 
 509   chan1 = nchannel;
 510   chan2 = chan1 + chan1;
 511 
 512   wid -= (m - 1);
 513   hgt -= (n - 1);
 514   adr_dst += dn*dll + dm*nchannel;
 515 
 516   for (c = 0; c < nchannel; c++) {
 517     if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
 518 


 833         dp[0] = FROM_S32(d0);
 834 
 835         buffn[i] = (FTYPE)sp[0];
 836 
 837         sp += chan1;
 838         dp += chan1;
 839       }
 840 
 841       for (l = 0; l < (m - 1); l++) buffn[wid + l] = sp[l*chan1];
 842 
 843       /* next line */
 844       sl += sll;
 845       dl += dll;
 846 
 847       buff_ind++;
 848 
 849       if (buff_ind >= n + 1) buff_ind = 0;
 850     }
 851   }
 852 
 853   FREE_AND_RETURN_STATUS;
 854 }
 855 
 856 /***************************************************************/
 857 #ifndef __sparc /* for x86, using integer multiplies is faster */
 858 
 859 #define STORE_RES(res, x)                                       \
 860   x >>= shift2;                                                 \
 861   CLAMP_STORE(res, x)
 862 
 863 mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
 864                              const mlib_image *src,
 865                              const mlib_s32   *kernel,
 866                              mlib_s32         m,
 867                              mlib_s32         n,
 868                              mlib_s32         dm,
 869                              mlib_s32         dn,
 870                              mlib_s32         scale,
 871                              mlib_s32         cmask)
 872 {
 873   mlib_s32 buff[BUFF_SIZE], *buffd = buff;




 468     fscale *= 1.0/(1 << 30);
 469     scale -= 30;
 470   }
 471 
 472   fscale /= (1 << scale);
 473 
 474   mn = m*n;
 475 
 476   if (mn > 256) {
 477     k = mlib_malloc(mn*sizeof(mlib_d64));
 478 
 479     if (k == NULL) return MLIB_FAILURE;
 480   }
 481 
 482   for (i = 0; i < mn; i++) {
 483     k[i] = kernel[i]*fscale;
 484   }
 485 
 486   if (m == 1) {
 487     status = mlib_ImageConv1xN(dst, src, k, n, dn, cmask);
 488     FREE_AND_RETURN_STATUS
 489   }
 490 
 491   bsize = (n + 3)*wid;
 492 
 493   if ((bsize > BUFF_SIZE) || (n > MAX_N)) {
 494     pbuff = mlib_malloc(sizeof(FTYPE)*bsize + sizeof(FTYPE *)*2*(n + 1));
 495 
 496     if (pbuff == NULL) {
 497       status = MLIB_FAILURE;
 498       FREE_AND_RETURN_STATUS
 499     }
 500     buffs = (FTYPE   **)(pbuff + bsize);
 501   }
 502 
 503   for (l = 0; l < (n + 1); l++) buffs[l] = pbuff + l*wid;
 504   for (l = 0; l < (n + 1); l++) buffs[l + (n + 1)] = buffs[l];
 505   buffd = buffs[n] + wid;
 506   buffo = (mlib_s32*)(buffd + wid);
 507   buffi = buffo + (wid &~ 1);
 508 
 509   chan1 = nchannel;
 510   chan2 = chan1 + chan1;
 511 
 512   wid -= (m - 1);
 513   hgt -= (n - 1);
 514   adr_dst += dn*dll + dm*nchannel;
 515 
 516   for (c = 0; c < nchannel; c++) {
 517     if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
 518 


 833         dp[0] = FROM_S32(d0);
 834 
 835         buffn[i] = (FTYPE)sp[0];
 836 
 837         sp += chan1;
 838         dp += chan1;
 839       }
 840 
 841       for (l = 0; l < (m - 1); l++) buffn[wid + l] = sp[l*chan1];
 842 
 843       /* next line */
 844       sl += sll;
 845       dl += dll;
 846 
 847       buff_ind++;
 848 
 849       if (buff_ind >= n + 1) buff_ind = 0;
 850     }
 851   }
 852 
 853   FREE_AND_RETURN_STATUS
 854 }
 855 
 856 /***************************************************************/
 857 #ifndef __sparc /* for x86, using integer multiplies is faster */
 858 
 859 #define STORE_RES(res, x)                                       \
 860   x >>= shift2;                                                 \
 861   CLAMP_STORE(res, x)
 862 
 863 mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
 864                              const mlib_image *src,
 865                              const mlib_s32   *kernel,
 866                              mlib_s32         m,
 867                              mlib_s32         n,
 868                              mlib_s32         dm,
 869                              mlib_s32         dn,
 870                              mlib_s32         scale,
 871                              mlib_s32         cmask)
 872 {
 873   mlib_s32 buff[BUFF_SIZE], *buffd = buff;


< prev index next >