< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 2003, 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


  61 #include "mlib_ImageConv.h"
  62 
  63 /***************************************************************/
  64 #ifdef __sparc
  65 
  66 #define CLAMP_S32(dst, src)                                     \
  67   dst = (mlib_s32)(src)
  68 
  69 #else
  70 
  71 #define CLAMP_S32(dst, src) {                                   \
  72   mlib_d64 s0 = (mlib_d64)(src);                                \
  73   if (s0 > (mlib_d64)MLIB_S32_MAX) s0 = (mlib_d64)MLIB_S32_MAX; \
  74   if (s0 < (mlib_d64)MLIB_S32_MIN) s0 = (mlib_d64)MLIB_S32_MIN; \
  75   dst = (mlib_s32)s0;                                           \
  76 }
  77 
  78 #endif /* __sparc */
  79 
  80 /***************************************************************/
  81 JNIEXPORT mlib_status JNICALL mlib_ImageConvKernelConvert(mlib_s32       *ikernel,

  82                                         mlib_s32       *iscale,
  83                                         const mlib_d64 *fkernel,
  84                                         mlib_s32       m,
  85                                         mlib_s32       n,
  86                                         mlib_type      type)
  87 {
  88   mlib_d64 sum_pos, sum_neg, sum, norm, max, f;
  89   mlib_s32 isum_pos, isum_neg, isum, test;
  90   mlib_s32 i, scale, scale1, chk_flag;
  91 
  92   if (ikernel == NULL || iscale == NULL || fkernel == NULL || m < 1 || n < 1) {
  93     return MLIB_FAILURE;
  94   }
  95 
  96   if ((type == MLIB_BYTE) || (type == MLIB_SHORT) || (type == MLIB_USHORT)) {
  97 
  98     if (type != MLIB_SHORT) {               /* MLIB_BYTE, MLIB_USHORT */
  99       sum_pos = 0;
 100       sum_neg = 0;
 101 


   1 /*
   2  * Copyright (c) 2003, 2018, 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


  61 #include "mlib_ImageConv.h"
  62 
  63 /***************************************************************/
  64 #ifdef __sparc
  65 
  66 #define CLAMP_S32(dst, src)                                     \
  67   dst = (mlib_s32)(src)
  68 
  69 #else
  70 
  71 #define CLAMP_S32(dst, src) {                                   \
  72   mlib_d64 s0 = (mlib_d64)(src);                                \
  73   if (s0 > (mlib_d64)MLIB_S32_MAX) s0 = (mlib_d64)MLIB_S32_MAX; \
  74   if (s0 < (mlib_d64)MLIB_S32_MIN) s0 = (mlib_d64)MLIB_S32_MIN; \
  75   dst = (mlib_s32)s0;                                           \
  76 }
  77 
  78 #endif /* __sparc */
  79 
  80 /***************************************************************/
  81 JNIEXPORT
  82 mlib_status mlib_ImageConvKernelConvert(mlib_s32       *ikernel,
  83                                         mlib_s32       *iscale,
  84                                         const mlib_d64 *fkernel,
  85                                         mlib_s32       m,
  86                                         mlib_s32       n,
  87                                         mlib_type      type)
  88 {
  89   mlib_d64 sum_pos, sum_neg, sum, norm, max, f;
  90   mlib_s32 isum_pos, isum_neg, isum, test;
  91   mlib_s32 i, scale, scale1, chk_flag;
  92 
  93   if (ikernel == NULL || iscale == NULL || fkernel == NULL || m < 1 || n < 1) {
  94     return MLIB_FAILURE;
  95   }
  96 
  97   if ((type == MLIB_BYTE) || (type == MLIB_SHORT) || (type == MLIB_USHORT)) {
  98 
  99     if (type != MLIB_SHORT) {               /* MLIB_BYTE, MLIB_USHORT */
 100       sum_pos = 0;
 101       sum_neg = 0;
 102 


< prev index next >