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