< prev index next >

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

Print this page




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


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




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


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


< prev index next >