src/java.desktop/share/native/libmlib_image/mlib_ImageConvMxN.c
author ihse
Tue, 13 Feb 2018 13:02:19 +0100
branchihse-remove-mapfiles-branch
changeset 56110 e2bb6d2abb5d
parent 47216 71c04702a3d5
child 56721 01b558efd286
permissions -rw-r--r--
Remove the libmlib_image mapfile.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
56110
e2bb6d2abb5d Remove the libmlib_image mapfile.
ihse
parents: 47216
diff changeset
     2
 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * FUNCTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *      mlib_ImageConvMxN - image convolution with edge condition
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * SYNOPSIS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *      mlib_status mlib_ImageConvMxN(mlib_image       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *                                    const mlib_image *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *                                    const mlib_s32   *kernel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *                                    mlib_s32         m,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *                                    mlib_s32         n,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *                                    mlib_s32         dm,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *                                    mlib_s32         dn,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *                                    mlib_s32         scale,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *                                    mlib_s32         cmask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *                                    mlib_edge        edge)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * ARGUMENTS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *      dst       Pointer to destination image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *      src       Pointer to source image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *      m         Kernel width (m must be not less than 1).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *      n         Kernel height (n must be not less than 1).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *      dm, dn    Position of key element in convolution kernel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *      kernel    Pointer to convolution kernel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *      scale     The scaling factor to convert the input integer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *                coefficients into floating-point coefficients:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *                floating-point coefficient = integer coefficient * 2^(-scale)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *      cmask     Channel mask to indicate the channels to be convolved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *                Each bit of which represents a channel in the image. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *                channels corresponded to 1 bits are those to be processed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *      edge      Type of edge condition.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * DESCRIPTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *      2-D convolution, MxN kernel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *      The center of the source image is mapped to the center of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *      destination image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *      The unselected channels are not overwritten. If both src and dst have
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *      just one channel, cmask is ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *      The edge condition can be one of the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *              MLIB_EDGE_DST_NO_WRITE  (default)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *              MLIB_EDGE_DST_FILL_ZERO
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *              MLIB_EDGE_DST_COPY_SRC
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *              MLIB_EDGE_SRC_EXTEND
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * RESTRICTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 *      The src and the dst must be the same type and have same number
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 *      of channels (1, 2, 3, or 4). They can be in MLIB_BIT, MLIB_BYTE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *      MLIB_SHORT, MLIB_USHORT or MLIB_INT data type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *      m >= 1, n >= 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 *      0 <= dm < m, 0 <= dn < n.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *      For data type MLIB_BYTE:   16 <= scale <= 31 (to be compatible with VIS version)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 *      For data type MLIB_SHORT:  17 <= scale <= 32 (to be compatible with VIS version)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 *      For data type MLIB_USHORT: 17 <= scale <= 32 (to be compatible with VIS version)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 *      For data type MLIB_INT:    scale >= 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
56110
e2bb6d2abb5d Remove the libmlib_image mapfile.
ihse
parents: 47216
diff changeset
    84
#include "jni.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
#include "mlib_image.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
#include "mlib_ImageCheck.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
#include "mlib_ImageConv.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
#include "mlib_ImageCreate.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
#include "mlib_c_ImageConv.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
#include "mlib_ImageClipping.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
#include "mlib_ImageConvEdge.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
/***************************************************************/
56110
e2bb6d2abb5d Remove the libmlib_image mapfile.
ihse
parents: 47216
diff changeset
    94
JNIEXPORT
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
mlib_status mlib_ImageConvMxN(mlib_image       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                              const mlib_image *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                              const mlib_s32   *kernel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                              mlib_s32         m,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                              mlib_s32         n,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                              mlib_s32         dm,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                              mlib_s32         dn,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                              mlib_s32         scale,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                              mlib_s32         cmask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                              mlib_edge        edge)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
  MLIB_IMAGE_CHECK(dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
  switch (mlib_ImageGetType(dst)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    case MLIB_BYTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
      if (scale < 16 || scale > 31)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
      break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    case MLIB_SHORT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    case MLIB_USHORT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
      if (scale < 17 || scale > 32)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
      break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    case MLIB_INT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
      if (scale < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
      break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
      return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
  return mlib_ImageConvMxN_f(dst, src, kernel, m, n, dm, dn, scale, cmask, edge);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
mlib_status mlib_ImageConvMxN_f(mlib_image       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                                const mlib_image *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                                const void       *kernel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                                mlib_s32         m,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                                mlib_s32         n,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                                mlib_s32         dm,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                                mlib_s32         dn,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                                mlib_s32         scale,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                                mlib_s32         cmask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                                mlib_edge        edge)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
  mlib_image dst_i[1], src_i[1], dst_e[1], src_e[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
  mlib_type type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
  mlib_s32 nchan, dx_l, dx_r, dy_t, dy_b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
  mlib_s32 edg_sizes[8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
  mlib_status ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
  if (m < 1 || n < 1 || dm < 0 || dm > m - 1 || dn < 0 || dn > n - 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
  if (kernel == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    return MLIB_NULLPOINTER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
  ret =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    mlib_ImageClippingMxN(dst_i, src_i, dst_e, src_e, edg_sizes, dst, src, m, n, dm, dn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
  if (ret != MLIB_SUCCESS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
  nchan = mlib_ImageGetChannels(dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
  type = mlib_ImageGetType(dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
  if (nchan == 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    cmask = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
  if ((cmask & ((1 << nchan) - 1)) == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
  dx_l = edg_sizes[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
  dx_r = edg_sizes[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
  dy_t = edg_sizes[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
  dy_b = edg_sizes[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
  if (dx_l + dx_r + dy_t + dy_b == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    edge = MLIB_EDGE_DST_NO_WRITE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
  if (edge != MLIB_EDGE_SRC_EXTEND) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    if (mlib_ImageGetWidth(dst_i) >= m && mlib_ImageGetHeight(dst_i) >= n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
      switch (type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        case MLIB_BYTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
          ret = mlib_convMxNnw_u8(dst_i, src_i, kernel, m, n, dm, dn, scale, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        case MLIB_SHORT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
#ifdef __sparc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
          ret = mlib_convMxNnw_s16(dst_i, src_i, kernel, m, n, dm, dn, scale, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
          if (mlib_ImageConvVersion(m, n, scale, type) == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            ret = mlib_convMxNnw_s16(dst_i, src_i, kernel, m, n, dm, dn, scale, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
          else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            ret = mlib_i_convMxNnw_s16(dst_i, src_i, kernel, m, n, dm, dn, scale, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
#endif /* __sparc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        case MLIB_USHORT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
#ifdef __sparc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
          ret = mlib_convMxNnw_u16(dst_i, src_i, kernel, m, n, dm, dn, scale, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
          if (mlib_ImageConvVersion(m, n, scale, type) == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            ret = mlib_convMxNnw_u16(dst_i, src_i, kernel, m, n, dm, dn, scale, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
          else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            ret = mlib_i_convMxNnw_u16(dst_i, src_i, kernel, m, n, dm, dn, scale, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
#endif /* __sparc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        case MLIB_INT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
          ret = mlib_convMxNnw_s32(dst_i, src_i, kernel, m, n, dm, dn, scale, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        case MLIB_FLOAT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
          ret = mlib_convMxNnw_f32(dst_i, src_i, kernel, m, n, dm, dn, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        case MLIB_DOUBLE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
          ret = mlib_convMxNnw_d64(dst_i, src_i, kernel, m, n, dm, dn, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
          break;
8939
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   216
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   217
      default:
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   218
        /* For some reasons, there is no convolution routine for type MLIB_BIT.
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   219
         * For now, we silently ignore it (because this image type is not used by java),
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   220
         * but probably we have to report an error.
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   221
         */
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   222
        break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    switch (edge) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
      case MLIB_EDGE_DST_FILL_ZERO:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        mlib_ImageConvZeroEdge(dst_e, dx_l, dx_r, dy_t, dy_b, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
      case MLIB_EDGE_DST_COPY_SRC:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        mlib_ImageConvCopyEdge(dst_e, src_e, dx_l, dx_r, dy_t, dy_b, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        break;
8939
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   233
    default:
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   234
      /* Other edge conditions do not need additional handling.
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   235
       *  Note also that they are not exposed in public Java API
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   236
       */
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   237
      break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
  else {                                    /* MLIB_EDGE_SRC_EXTEND */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    /* adjust src_e image */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    mlib_ImageSetSubimage(src_e, src_e, dx_l - dm, dy_t - dn,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                          mlib_ImageGetWidth(src_e), mlib_ImageGetHeight(src_e));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    switch (type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
      case MLIB_BYTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        ret =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
          mlib_convMxNext_u8(dst_e, src_e, kernel, m, n, dx_l, dx_r, dy_t, dy_b, scale,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                             cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
      case MLIB_SHORT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
#ifdef __sparc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        ret =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
          mlib_convMxNext_s16(dst_e, src_e, kernel, m, n, dx_l, dx_r, dy_t, dy_b, scale,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                              cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        if (mlib_ImageConvVersion(m, n, scale, type) == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
          ret =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            mlib_convMxNext_s16(dst_e, src_e, kernel, m, n, dx_l, dx_r, dy_t, dy_b, scale,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                                cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
          ret =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            mlib_i_convMxNext_s16(dst_e, src_e, kernel, m, n, dx_l, dx_r, dy_t, dy_b,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                                  scale, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
#endif /* __sparc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
      case MLIB_USHORT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
#ifdef __sparc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        ret =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
          mlib_convMxNext_u16(dst_e, src_e, kernel, m, n, dx_l, dx_r, dy_t, dy_b, scale,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                              cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        if (mlib_ImageConvVersion(m, n, scale, type) == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
          ret =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            mlib_convMxNext_u16(dst_e, src_e, kernel, m, n, dx_l, dx_r, dy_t, dy_b, scale,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                                cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
          ret =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            mlib_i_convMxNext_u16(dst_e, src_e, kernel, m, n, dx_l, dx_r, dy_t, dy_b,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                                  scale, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
#endif /* __sparc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
      case MLIB_INT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        ret =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
          mlib_convMxNext_s32(dst_e, src_e, kernel, m, n, dx_l, dx_r, dy_t, dy_b, scale,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                              cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
      case MLIB_FLOAT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        mlib_convMxNext_f32(dst_e, src_e, kernel, m, n, dx_l, dx_r, dy_t, dy_b, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
      case MLIB_DOUBLE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        mlib_convMxNext_d64(dst_e, src_e, kernel, m, n, dx_l, dx_r, dy_t, dy_b, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        break;
8939
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   296
    default:
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   297
      /* For some reasons, there is no convolution routine for type MLIB_BIT.
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   298
       * For now, we silently ignore it (because this image type is not used by java),
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   299
       * but probably we have to report an error.
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   300
       */
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   301
      break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
  return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
/***************************************************************/