jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConvMxN.c
author vadim
Fri, 13 May 2016 11:31:05 +0300
changeset 38415 acea5f7d354b
parent 25859 3317bb8137f4
permissions -rw-r--r--
8047931: Remove unused medialib code Reviewed-by: bae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 8939
diff changeset
     2
 * Copyright (c) 2003, 2011, 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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
#include "mlib_image.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
#include "mlib_ImageCheck.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
#include "mlib_ImageConv.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
#include "mlib_ImageCreate.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
#include "mlib_c_ImageConv.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
#include "mlib_ImageClipping.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
#include "mlib_ImageConvEdge.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
mlib_status mlib_ImageConvMxN(mlib_image       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                              const mlib_image *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                              const mlib_s32   *kernel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                              mlib_s32         m,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                              mlib_s32         n,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                              mlib_s32         dm,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                              mlib_s32         dn,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                              mlib_s32         scale,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                              mlib_s32         cmask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                              mlib_edge        edge)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
  MLIB_IMAGE_CHECK(dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
  switch (mlib_ImageGetType(dst)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    case MLIB_BYTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
      if (scale < 16 || scale > 31)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
      break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    case MLIB_SHORT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    case MLIB_USHORT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
      if (scale < 17 || scale > 32)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
      break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    case MLIB_INT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
      if (scale < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
      break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
      return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
  return mlib_ImageConvMxN_f(dst, src, kernel, m, n, dm, dn, scale, cmask, edge);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
mlib_status mlib_ImageConvMxN_f(mlib_image       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                                const mlib_image *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                                const void       *kernel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                                mlib_s32         m,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                                mlib_s32         n,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                                mlib_s32         dm,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                                mlib_s32         dn,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                                mlib_s32         scale,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                                mlib_s32         cmask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                                mlib_edge        edge)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
  mlib_image dst_i[1], src_i[1], dst_e[1], src_e[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
  mlib_type type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
  mlib_s32 nchan, dx_l, dx_r, dy_t, dy_b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
  mlib_s32 edg_sizes[8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
  mlib_status ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
  if (m < 1 || n < 1 || dm < 0 || dm > m - 1 || dn < 0 || dn > n - 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
  if (kernel == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    return MLIB_NULLPOINTER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
  ret =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    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
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
  if (ret != MLIB_SUCCESS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
  nchan = mlib_ImageGetChannels(dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
  type = mlib_ImageGetType(dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
  if (nchan == 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    cmask = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
  if ((cmask & ((1 << nchan) - 1)) == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
  dx_l = edg_sizes[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
  dx_r = edg_sizes[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
  dy_t = edg_sizes[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
  dy_b = edg_sizes[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
  if (dx_l + dx_r + dy_t + dy_b == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    edge = MLIB_EDGE_DST_NO_WRITE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
  if (edge != MLIB_EDGE_SRC_EXTEND) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    if (mlib_ImageGetWidth(dst_i) >= m && mlib_ImageGetHeight(dst_i) >= n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
      switch (type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        case MLIB_BYTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
          ret = mlib_convMxNnw_u8(dst_i, src_i, kernel, m, n, dm, dn, scale, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        case MLIB_SHORT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
#ifdef __sparc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
          ret = mlib_convMxNnw_s16(dst_i, src_i, kernel, m, n, dm, dn, scale, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
          if (mlib_ImageConvVersion(m, n, scale, type) == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            ret = mlib_convMxNnw_s16(dst_i, src_i, kernel, m, n, dm, dn, scale, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
          else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            ret = mlib_i_convMxNnw_s16(dst_i, src_i, kernel, m, n, dm, dn, scale, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
#endif /* __sparc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        case MLIB_USHORT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
#ifdef __sparc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
          ret = mlib_convMxNnw_u16(dst_i, src_i, kernel, m, n, dm, dn, scale, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
          if (mlib_ImageConvVersion(m, n, scale, type) == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            ret = mlib_convMxNnw_u16(dst_i, src_i, kernel, m, n, dm, dn, scale, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
          else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            ret = mlib_i_convMxNnw_u16(dst_i, src_i, kernel, m, n, dm, dn, scale, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
#endif /* __sparc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        case MLIB_INT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
          ret = mlib_convMxNnw_s32(dst_i, src_i, kernel, m, n, dm, dn, scale, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        case MLIB_FLOAT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
          ret = mlib_convMxNnw_f32(dst_i, src_i, kernel, m, n, dm, dn, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        case MLIB_DOUBLE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
          ret = mlib_convMxNnw_d64(dst_i, src_i, kernel, m, n, dm, dn, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
          break;
8939
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   214
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   215
      default:
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   216
        /* For some reasons, there is no convolution routine for type MLIB_BIT.
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   217
         * 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
   218
         * but probably we have to report an error.
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   219
         */
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   220
        break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    switch (edge) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
      case MLIB_EDGE_DST_FILL_ZERO:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        mlib_ImageConvZeroEdge(dst_e, dx_l, dx_r, dy_t, dy_b, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
      case MLIB_EDGE_DST_COPY_SRC:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        mlib_ImageConvCopyEdge(dst_e, src_e, dx_l, dx_r, dy_t, dy_b, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        break;
8939
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   231
    default:
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   232
      /* Other edge conditions do not need additional handling.
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   233
       *  Note also that they are not exposed in public Java API
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   234
       */
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   235
      break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
  else {                                    /* MLIB_EDGE_SRC_EXTEND */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    /* adjust src_e image */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    mlib_ImageSetSubimage(src_e, src_e, dx_l - dm, dy_t - dn,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                          mlib_ImageGetWidth(src_e), mlib_ImageGetHeight(src_e));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    switch (type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
      case MLIB_BYTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        ret =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
          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
   247
                             cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
      case MLIB_SHORT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
#ifdef __sparc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        ret =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
          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
   253
                              cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        if (mlib_ImageConvVersion(m, n, scale, type) == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
          ret =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            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
   259
                                cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
          ret =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            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
   263
                                  scale, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
#endif /* __sparc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
      case MLIB_USHORT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
#ifdef __sparc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        ret =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
          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
   270
                              cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        if (mlib_ImageConvVersion(m, n, scale, type) == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
          ret =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            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
   276
                                cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
          ret =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            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
   280
                                  scale, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
#endif /* __sparc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
      case MLIB_INT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        ret =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
          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
   286
                              cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
      case MLIB_FLOAT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        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
   290
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
      case MLIB_DOUBLE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        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
   293
        break;
8939
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   294
    default:
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   295
      /* For some reasons, there is no convolution routine for type MLIB_BIT.
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   296
       * 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
   297
       * but probably we have to report an error.
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   298
       */
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   299
      break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
  return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
/***************************************************************/