jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8nw.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: 15632
diff changeset
     2
 * Copyright (c) 2003, 2013, 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
 *   Internal functions for mlib_ImageConv* on U8/S16/U16 types and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *   MLIB_EDGE_DST_NO_WRITE mask
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "mlib_image.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "mlib_ImageConv.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "mlib_c_ImageConv.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
  This define switches between functions of different data types
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#define IMG_TYPE 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#if IMG_TYPE == 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
#define DTYPE             mlib_u8
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#define CONV_FUNC(KERN)   mlib_c_conv##KERN##nw_u8
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#define CONV_FUNC_I(KERN) mlib_i_conv##KERN##nw_u8
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
#define DSCALE            (1 << 24)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#define FROM_S32(x)       (((x) >> 24) ^ 128)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#define S64TOS32(x)       (x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#define SAT_OFF           -(1u << 31)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
#elif IMG_TYPE == 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
#define DTYPE             mlib_s16
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
#define CONV_FUNC(KERN)   mlib_conv##KERN##nw_s16
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
#define CONV_FUNC_I(KERN) mlib_i_conv##KERN##nw_s16
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
#define DSCALE            65536.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
#define FROM_S32(x)       ((x) >> 16)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
#define S64TOS32(x)       ((x) & 0xffffffff)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
#define SAT_OFF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
#elif IMG_TYPE == 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
#define DTYPE             mlib_u16
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
#define CONV_FUNC(KERN)   mlib_conv##KERN##nw_u16
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
#define CONV_FUNC_I(KERN) mlib_i_conv##KERN##nw_u16
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
#define DSCALE            65536.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
#define FROM_S32(x)       (((x) >> 16) ^ 0x8000)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
#define S64TOS32(x)       (x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
#define SAT_OFF           -(1u << 31)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
#endif /* IMG_TYPE == 1 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
#define BUFF_SIZE   1600
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
#define CACHE_SIZE  (64*1024)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
#define FTYPE mlib_d64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
#ifndef MLIB_USE_FTOI_CLAMPING
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
#define CLAMP_S32(x)                                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
  (((x) <= MLIB_S32_MIN) ? MLIB_S32_MIN : (((x) >= MLIB_S32_MAX) ? MLIB_S32_MAX : (mlib_s32)(x)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
#define CLAMP_S32(x) ((mlib_s32)(x))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
#endif /* MLIB_USE_FTOI_CLAMPING */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
#define D2I(x) CLAMP_S32((x) SAT_OFF)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
#define STORE2(res0, res1)                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
  dp[0    ] = res1;                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
  dp[chan1] = res0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
#define STORE2(res0, res1)                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
  dp[0    ] = res0;                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
  dp[chan1] = res1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
#endif /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
#ifdef _NO_LONGLONG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
#define LOAD_BUFF(buff)                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
  buff[i    ] = sp[0];                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
  buff[i + 1] = sp[chan1]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
#else /* _NO_LONGLONG */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
#define LOAD_BUFF(buff)                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
  *(mlib_s64*)(buff + i) = (((mlib_s64)sp[chan1]) << 32) | S64TOS32((mlib_s64)sp[0])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
#else /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
#define LOAD_BUFF(buff)                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
  *(mlib_s64*)(buff + i) = (((mlib_s64)sp[0]) << 32) | S64TOS32((mlib_s64)sp[chan1])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
#endif /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
#endif /* _NO_LONGLONG */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
typedef union {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
  mlib_d64 d64;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
  struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    mlib_s32 i0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    mlib_s32 i1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
  } i32s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
  struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    mlib_s32 f0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    mlib_s32 f1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
  } f32s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
} d64_2x32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
#define DEF_VARS(type)                                          \
8939
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   149
  type     *adr_src, *sl, *sp = NULL;                           \
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   150
  type     *adr_dst, *dl, *dp = NULL;                           \
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
  FTYPE    *pbuff = buff;                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
  mlib_s32 wid, hgt, sll, dll;                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
  mlib_s32 nchannel, chan1;                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
  mlib_s32 i, j, c
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
#define GET_SRC_DST_PARAMETERS(type)                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
  hgt = mlib_ImageGetHeight(src);                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
  wid = mlib_ImageGetWidth(src);                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
  nchannel = mlib_ImageGetChannels(src);                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
  sll = mlib_ImageGetStride(src) / sizeof(type);                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
  dll = mlib_ImageGetStride(dst) / sizeof(type);                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
  adr_src = (type *)mlib_ImageGetData(src);                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
  adr_dst = (type *)mlib_ImageGetData(dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
#ifndef __sparc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
#if IMG_TYPE == 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
/* Test for the presence of any "1" bit in bits
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
   8 to 31 of val. If present, then val is either
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
   negative or >255. If over/underflows of 8 bits
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
   are uncommon, then this technique can be a win,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
   since only a single test, rather than two, is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
   necessary to determine if clamping is needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
   On the other hand, if over/underflows are common,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
   it adds an extra test.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
#define CLAMP_STORE(dst, val)                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
  if (val & 0xffffff00) {                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    if (val < MLIB_U8_MIN)                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
      dst = MLIB_U8_MIN;                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    else                                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
      dst = MLIB_U8_MAX;                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
  } else {                                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    dst = (mlib_u8)val;                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
#elif IMG_TYPE == 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
#define CLAMP_STORE(dst, val)                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
  if (val >= MLIB_S16_MAX)                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    dst = MLIB_S16_MAX;                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
  else if (val <= MLIB_S16_MIN)                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    dst = MLIB_S16_MIN;                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
  else                                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    dst = (mlib_s16)val
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
#elif IMG_TYPE == 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
#define CLAMP_STORE(dst, val)                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
  if (val >= MLIB_U16_MAX)                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    dst = MLIB_U16_MAX;                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
  else if (val <= MLIB_U16_MIN)                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    dst = MLIB_U16_MIN;                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
  else                                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    dst = (mlib_u16)val
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
#endif /* IMG_TYPE == 1 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
#endif /* __sparc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
#define MAX_KER   7
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
#define MAX_N    15
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
static mlib_status mlib_ImageConv1xN(mlib_image       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                                     const mlib_image *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                                     const mlib_d64   *k,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                                     mlib_s32         n,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                                     mlib_s32         dn,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                                     mlib_s32         cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
  FTYPE    buff[BUFF_SIZE];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
  mlib_s32 off, kh;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
  mlib_s32 d0, d1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
  const FTYPE    *pk;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
  FTYPE    k0, k1, k2, k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
  FTYPE    p0, p1, p2, p3, p4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
  DEF_VARS(DTYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
  DTYPE    *sl_c, *dl_c, *sl0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
  mlib_s32 l, hsize, max_hsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
  GET_SRC_DST_PARAMETERS(DTYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
  hgt -= (n - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
  adr_dst += dn*dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
  max_hsize = (CACHE_SIZE/sizeof(DTYPE))/sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
  if (!max_hsize) max_hsize = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
  if (max_hsize > BUFF_SIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    pbuff = mlib_malloc(sizeof(FTYPE)*max_hsize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
  chan1 = nchannel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
  sl_c = adr_src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
  dl_c = adr_dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
  for (l = 0; l < hgt; l += hsize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    hsize = hgt - l;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    if (hsize > max_hsize) hsize = max_hsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    for (c = 0; c < nchannel; c++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
      if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
      sl = sl_c + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
      dl = dl_c + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
      for (j = 0; j < hsize; j++) pbuff[j] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
      for (i = 0; i < wid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        sl0 = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        for (off = 0; off < (n - 4); off += 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
          pk = k + off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
          sp = sl0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
          k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
          p2 = sp[0]; p3 = sp[sll]; p4 = sp[2*sll];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
          sp += 3*sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
          for (j = 0; j < hsize; j += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            p0 = p2; p1 = p3; p2 = p4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            p3 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            p4 = sp[sll];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            pbuff[j    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            pbuff[j + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            sp += 2*sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
          sl0 += 4*sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        pk = k + off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        sp = sl0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        p2 = sp[0]; p3 = sp[sll]; p4 = sp[2*sll];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        kh = n - off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        if (kh == 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
          sp += 3*sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
          for (j = 0; j <= (hsize - 2); j += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            p0 = p2; p1 = p3; p2 = p4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            p3 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            p4 = sp[sll];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + pbuff[j]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
            d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + pbuff[j + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
            dp[0  ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            dp[dll] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
            pbuff[j] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
            pbuff[j + 1] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
            sp += 2*sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            dp += 2*dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
          if (j < hsize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            p0 = p2; p1 = p3; p2 = p4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            p3 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
            d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + pbuff[j]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            pbuff[j] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            dp[0] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        } else if (kh == 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
          sp += 2*sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
          for (j = 0; j <= (hsize - 2); j += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            p0 = p2; p1 = p3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
            p2 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
            p3 = sp[sll];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            d0 = D2I(p0*k0 + p1*k1 + p2*k2 + pbuff[j]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
            d1 = D2I(p1*k0 + p2*k1 + p3*k2 + pbuff[j + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            dp[0  ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            dp[dll] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            pbuff[j] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            pbuff[j + 1] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
            sp += 2*sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
            dp += 2*dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
          if (j < hsize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
            p0 = p2; p1 = p3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
            p2 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            d0 = D2I(p0*k0 + p1*k1 + p2*k2 + pbuff[j]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            pbuff[j] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            dp[0] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        } else if (kh == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
          sp += sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
          for (j = 0; j <= (hsize - 2); j += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
            p0 = p2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
            p1 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
            p2 = sp[sll];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            d0 = D2I(p0*k0 + p1*k1 + pbuff[j]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
            d1 = D2I(p1*k0 + p2*k1 + pbuff[j + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
            dp[0  ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
            dp[dll] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
            pbuff[j] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
            pbuff[j + 1] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
            sp += 2*sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
            dp += 2*dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
          if (j < hsize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            p0 = p2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
            p1 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
            d0 = D2I(p0*k0 + p1*k1 + pbuff[j]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            pbuff[j] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
            dp[0] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        } else /* if (kh == 1) */ {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
          for (j = 0; j < hsize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            p0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            d0 = D2I(p0*k0 + pbuff[j]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            dp[0] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            pbuff[j] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
            sp += sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            dp += dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        sl += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        dl += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    sl_c += max_hsize*sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    dl_c += max_hsize*dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
  if (pbuff != buff) mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
mlib_status CONV_FUNC(MxN)(mlib_image       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                           const mlib_image *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                           const mlib_s32   *kernel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                           mlib_s32         m,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                           mlib_s32         n,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                           mlib_s32         dm,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                           mlib_s32         dn,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                           mlib_s32         scale,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                           mlib_s32         cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
  FTYPE    buff[BUFF_SIZE], *buffs_arr[2*(MAX_N + 1)];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
  FTYPE    **buffs = buffs_arr, *buffd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
  FTYPE    akernel[256], *k = akernel, fscale = DSCALE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
  mlib_s32 mn, l, off, kw, bsize, buff_ind;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
  mlib_s32 d0, d1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
  FTYPE    k0, k1, k2, k3, k4, k5, k6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
  FTYPE    p0, p1, p2, p3, p4, p5, p6, p7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
  d64_2x32 dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
  DEF_VARS(DTYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
  mlib_s32 chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
  mlib_s32 *buffo, *buffi;
15632
3d36eadad78f 8008017: The fix for 8005129 does not build on Windows
prr
parents: 15628
diff changeset
   463
  mlib_status status = MLIB_SUCCESS;
3d36eadad78f 8008017: The fix for 8005129 does not build on Windows
prr
parents: 15628
diff changeset
   464
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
  GET_SRC_DST_PARAMETERS(DTYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
  if (scale > 30) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    fscale *= 1.0/(1 << 30);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    scale -= 30;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
  fscale /= (1 << scale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
  mn = m*n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
  if (mn > 256) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    k = mlib_malloc(mn*sizeof(mlib_d64));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    if (k == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
  for (i = 0; i < mn; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    k[i] = kernel[i]*fscale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
15628
228422512f97 8005129: [parfait] #1122 - #1130 native/sun/awt/medialib/mlib_Image*.c Memory leak of pointer 'k' allocated with mlib_malloc
jgodinez
parents: 8939
diff changeset
   486
  if (m == 1) {
228422512f97 8005129: [parfait] #1122 - #1130 native/sun/awt/medialib/mlib_Image*.c Memory leak of pointer 'k' allocated with mlib_malloc
jgodinez
parents: 8939
diff changeset
   487
    status = mlib_ImageConv1xN(dst, src, k, n, dn, cmask);
228422512f97 8005129: [parfait] #1122 - #1130 native/sun/awt/medialib/mlib_Image*.c Memory leak of pointer 'k' allocated with mlib_malloc
jgodinez
parents: 8939
diff changeset
   488
    FREE_AND_RETURN_STATUS;
228422512f97 8005129: [parfait] #1122 - #1130 native/sun/awt/medialib/mlib_Image*.c Memory leak of pointer 'k' allocated with mlib_malloc
jgodinez
parents: 8939
diff changeset
   489
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
  bsize = (n + 3)*wid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
  if ((bsize > BUFF_SIZE) || (n > MAX_N)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    pbuff = mlib_malloc(sizeof(FTYPE)*bsize + sizeof(FTYPE *)*2*(n + 1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
15628
228422512f97 8005129: [parfait] #1122 - #1130 native/sun/awt/medialib/mlib_Image*.c Memory leak of pointer 'k' allocated with mlib_malloc
jgodinez
parents: 8939
diff changeset
   496
    if (pbuff == NULL) {
228422512f97 8005129: [parfait] #1122 - #1130 native/sun/awt/medialib/mlib_Image*.c Memory leak of pointer 'k' allocated with mlib_malloc
jgodinez
parents: 8939
diff changeset
   497
      status = MLIB_FAILURE;
228422512f97 8005129: [parfait] #1122 - #1130 native/sun/awt/medialib/mlib_Image*.c Memory leak of pointer 'k' allocated with mlib_malloc
jgodinez
parents: 8939
diff changeset
   498
      FREE_AND_RETURN_STATUS;
228422512f97 8005129: [parfait] #1122 - #1130 native/sun/awt/medialib/mlib_Image*.c Memory leak of pointer 'k' allocated with mlib_malloc
jgodinez
parents: 8939
diff changeset
   499
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    buffs = (FTYPE   **)(pbuff + bsize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
  for (l = 0; l < (n + 1); l++) buffs[l] = pbuff + l*wid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
  for (l = 0; l < (n + 1); l++) buffs[l + (n + 1)] = buffs[l];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
  buffd = buffs[n] + wid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
  buffo = (mlib_s32*)(buffd + wid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
  buffi = buffo + (wid &~ 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
  chan1 = nchannel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
  chan2 = chan1 + chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
  wid -= (m - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
  hgt -= (n - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
  adr_dst += dn*dll + dm*nchannel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
  for (c = 0; c < nchannel; c++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    sl = adr_src + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    dl = adr_dst + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    for (l = 0; l < n; l++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
      FTYPE    *buff = buffs[l];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
      for (i = 0; i < wid + (m - 1); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        buff[i] = (FTYPE)sl[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
      sl += sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    buff_ind = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    for (i = 0; i < wid; i++) buffd[i] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    for (j = 0; j < hgt; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
      FTYPE    **buffc = buffs + buff_ind;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
      FTYPE    *buffn = buffc[n];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
      FTYPE    *pk = k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
      for (l = 0; l < n; l++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        FTYPE    *buff_l = buffc[l];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        for (off = 0; off < m;) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
          FTYPE    *buff = buff_l + off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
          kw = m - off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
          if (kw > 2*MAX_KER) kw = MAX_KER; else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
            if (kw > MAX_KER) kw = kw/2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
          off += kw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
          sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
          dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
          p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
          p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
          k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
          k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
          pk += kw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
          if (kw == 7) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                p6 = buff[i + 6]; p7 = buff[i + 7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                p6 = buff[i + 6]; p7 = buff[i + 7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                LOAD_BUFF(buffi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                dd.d64 = *(FTYPE   *)(buffi + i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                buffn[i    ] = (FTYPE)dd.i32s.i0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                buffn[i + 1] = (FTYPE)dd.i32s.i1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                dp[0    ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                dp[chan1] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                buffd[i    ] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                buffd[i + 1] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
          } else if (kw == 6) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
                p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
                p5 = buff[i + 5]; p6 = buff[i + 6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
                buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
                buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                p5 = buff[i + 5]; p6 = buff[i + 6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
                buffn[i    ] = (FTYPE)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
                buffn[i + 1] = (FTYPE)sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
                d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
                d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
                dp[0    ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
                dp[chan1] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
                buffd[i    ] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
                buffd[i + 1] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
          } else if (kw == 5) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
                p0 = p2; p1 = p3; p2 = p4; p3 = p5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
                p4 = buff[i + 4]; p5 = buff[i + 5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
                buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
                buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
                p0 = p2; p1 = p3; p2 = p4; p3 = p5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
                p4 = buff[i + 4]; p5 = buff[i + 5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
                buffn[i    ] = (FTYPE)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
                buffn[i + 1] = (FTYPE)sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
                d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
                d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
                dp[0    ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
                dp[chan1] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
                buffd[i    ] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
                buffd[i + 1] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
          } else if (kw == 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
                p0 = p2; p1 = p3; p2 = p4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
                p3 = buff[i + 3]; p4 = buff[i + 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
                buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
                p0 = p2; p1 = p3; p2 = p4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
                p3 = buff[i + 3]; p4 = buff[i + 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
                buffn[i    ] = (FTYPE)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
                buffn[i + 1] = (FTYPE)sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
                d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
                d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
                dp[0    ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
                dp[chan1] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
                buffd[i    ] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
                buffd[i + 1] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
          } else if (kw == 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
                p0 = p2; p1 = p3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
                p2 = buff[i + 2]; p3 = buff[i + 3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
                buffd[i    ] += p0*k0 + p1*k1 + p2*k2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
                buffd[i + 1] += p1*k0 + p2*k1 + p3*k2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
                p0 = p2; p1 = p3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
                p2 = buff[i + 2]; p3 = buff[i + 3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
                buffn[i    ] = (FTYPE)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                buffn[i + 1] = (FTYPE)sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
                d0 = D2I(p0*k0 + p1*k1 + p2*k2 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
                d1 = D2I(p1*k0 + p2*k1 + p3*k2 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
                dp[0    ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
                dp[chan1] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
                buffd[i    ] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
                buffd[i + 1] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
          } else /*if (kw == 2)*/ {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
                p0 = p2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
                p1 = buff[i + 1]; p2 = buff[i + 2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
                buffd[i    ] += p0*k0 + p1*k1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
                buffd[i + 1] += p1*k0 + p2*k1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
                p0 = p2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
                p1 = buff[i + 1]; p2 = buff[i + 2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
                buffn[i    ] = (FTYPE)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
                buffn[i + 1] = (FTYPE)sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
                d0 = D2I(p0*k0 + p1*k1 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
                d1 = D2I(p1*k0 + p2*k1 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
                dp[0    ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
                dp[chan1] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
                buffd[i    ] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
                buffd[i + 1] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
      /* last pixels */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
      for (; i < wid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
        FTYPE    *pk = k, s = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        mlib_s32 x, d0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        for (l = 0; l < n; l++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
          FTYPE    *buff = buffc[l] + i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
          for (x = 0; x < m; x++) s += buff[x] * (*pk++);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        d0 = D2I(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
        dp[0] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
        buffn[i] = (FTYPE)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
        sp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
        dp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
      for (l = 0; l < (m - 1); l++) buffn[wid + l] = sp[l*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
      /* next line */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
      sl += sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
      dl += dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
      buff_ind++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
      if (buff_ind >= n + 1) buff_ind = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
15628
228422512f97 8005129: [parfait] #1122 - #1130 native/sun/awt/medialib/mlib_Image*.c Memory leak of pointer 'k' allocated with mlib_malloc
jgodinez
parents: 8939
diff changeset
   853
  FREE_AND_RETURN_STATUS;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
#ifndef __sparc /* for x86, using integer multiplies is faster */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
#define STORE_RES(res, x)                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
  x >>= shift2;                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
  CLAMP_STORE(res, x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
mlib_status CONV_FUNC_I(MxN)(mlib_image       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
                             const mlib_image *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
                             const mlib_s32   *kernel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
                             mlib_s32         m,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
                             mlib_s32         n,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
                             mlib_s32         dm,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
                             mlib_s32         dn,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
                             mlib_s32         scale,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
                             mlib_s32         cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
  mlib_s32 buff[BUFF_SIZE], *buffd = buff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
  mlib_s32 l, off, kw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
  mlib_s32 d0, d1, shift1, shift2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
  mlib_s32 k0, k1, k2, k3, k4, k5, k6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
  mlib_s32 p0, p1, p2, p3, p4, p5, p6, p7;
8939
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   878
  DTYPE    *adr_src, *sl, *sp = NULL;
04615dca2a76 6989717: media native code compiler warnings
bae
parents: 5506
diff changeset
   879
  DTYPE    *adr_dst, *dl, *dp = NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
  mlib_s32 wid, hgt, sll, dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
  mlib_s32 nchannel, chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
  mlib_s32 i, j, c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
  mlib_s32 chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
  mlib_s32 k_locl[MAX_N*MAX_N], *k = k_locl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
  GET_SRC_DST_PARAMETERS(DTYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
#if IMG_TYPE != 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
  shift1 = 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
  shift1 = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
#endif /* IMG_TYPE != 1 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
  shift2 = scale - shift1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
  chan1 = nchannel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
  chan2 = chan1 + chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
  wid -= (m - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
  hgt -= (n - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
  adr_dst += dn*dll + dm*nchannel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
  if (wid > BUFF_SIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
    buffd = mlib_malloc(sizeof(mlib_s32)*wid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
    if (buffd == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
  if (m*n > MAX_N*MAX_N) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
    k = mlib_malloc(sizeof(mlib_s32)*(m*n));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
    if (k == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
      if (buffd != buff) mlib_free(buffd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
      return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
  for (i = 0; i < m*n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
    k[i] = kernel[i] >> shift1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
  for (c = 0; c < nchannel; c++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
    sl = adr_src + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
    dl = adr_dst + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
    for (i = 0; i < wid; i++) buffd[i] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
    for (j = 0; j < hgt; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
      mlib_s32 *pk = k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
      for (l = 0; l < n; l++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
        DTYPE *sp0 = sl + l*sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
        for (off = 0; off < m;) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
          sp = sp0 + off*chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
          dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
          kw = m - off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
          if (kw > 2*MAX_KER) kw = MAX_KER; else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
            if (kw > MAX_KER) kw = kw/2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
          off += kw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
          p2 = sp[0]; p3 = sp[chan1]; p4 = sp[chan2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
          p5 = sp[chan2 + chan1]; p6 = sp[chan2 + chan2]; p7 = sp[5*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
          k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
          k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
          pk += kw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
          sp += (kw - 1)*chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
          if (kw == 7) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
                p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
                p6 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
                p7 = sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
                buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
                buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
                p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
                p6 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
                p7 = sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
                d0 = (p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
                d1 = (p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
                STORE_RES(dp[0    ], d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
                STORE_RES(dp[chan1], d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
                buffd[i    ] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
                buffd[i + 1] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
          } else if (kw == 6) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
                p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
                p5 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
                p6 = sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
                buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
                buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
                p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
                p5 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
                p6 = sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
                d0 = (p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
                d1 = (p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
                STORE_RES(dp[0    ], d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
                STORE_RES(dp[chan1], d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
                buffd[i    ] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
                buffd[i + 1] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
          } else if (kw == 5) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
                p0 = p2; p1 = p3; p2 = p4; p3 = p5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
                p4 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
                p5 = sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
                buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
                buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
                p0 = p2; p1 = p3; p2 = p4; p3 = p5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
                p4 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
                p5 = sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
                d0 = (p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
                d1 = (p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
                STORE_RES(dp[0    ], d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
                STORE_RES(dp[chan1], d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
                buffd[i    ] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
                buffd[i + 1] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
          } else if (kw == 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
                p0 = p2; p1 = p3; p2 = p4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
                p3 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
                p4 = sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
                buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
                buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
                p0 = p2; p1 = p3; p2 = p4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
                p3 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
                p4 = sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
                d0 = (p0*k0 + p1*k1 + p2*k2 + p3*k3 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
                d1 = (p1*k0 + p2*k1 + p3*k2 + p4*k3 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
                STORE_RES(dp[0    ], d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
                STORE_RES(dp[chan1], d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
                buffd[i    ] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
                buffd[i + 1] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
          } else if (kw == 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
                p0 = p2; p1 = p3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
                p2 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
                p3 = sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
                buffd[i    ] += p0*k0 + p1*k1 + p2*k2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
                buffd[i + 1] += p1*k0 + p2*k1 + p3*k2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
                p0 = p2; p1 = p3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
                p2 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
                p3 = sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
                d0 = (p0*k0 + p1*k1 + p2*k2 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
                d1 = (p1*k0 + p2*k1 + p3*k2 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
                STORE_RES(dp[0    ], d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
                STORE_RES(dp[chan1], d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
                buffd[i    ] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
                buffd[i + 1] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
          } else if (kw == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
                p0 = p2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
                p1 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
                p2 = sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
                buffd[i    ] += p0*k0 + p1*k1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
                buffd[i + 1] += p1*k0 + p2*k1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
                p0 = p2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
                p1 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
                p2 = sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
                d0 = (p0*k0 + p1*k1 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
                d1 = (p1*k0 + p2*k1 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
                STORE_RES(dp[0    ], d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
                STORE_RES(dp[chan1], d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
                buffd[i    ] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
                buffd[i + 1] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
          } else /*if (kw == 1)*/ {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
                p0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
                p1 = sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
                buffd[i    ] += p0*k0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
                buffd[i + 1] += p1*k0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
                p0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
                p1 = sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
                d0 = (p0*k0 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
                d1 = (p1*k0 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
                STORE_RES(dp[0    ], d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
                STORE_RES(dp[chan1], d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
                buffd[i    ] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
                buffd[i + 1] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
      /* last pixels */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
      for (; i < wid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
        mlib_s32 *pk = k, s = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
        mlib_s32 x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
        for (l = 0; l < n; l++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
          sp = sl + l*sll + i*chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
          for (x = 0; x < m; x++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
            s += sp[0] * pk[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
            sp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
            pk ++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
        STORE_RES(dp[0], s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
        sp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
        dp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
      sl += sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
      dl += dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
  if (buffd != buff) mlib_free(buffd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
  if (k != k_locl) mlib_free(k);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
#endif /* __sparc ( for x86, using integer multiplies is faster ) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
/***************************************************************/