jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_16ext.c
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
child 8939 04615dca2a76
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2003, 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 KSIZE1 (KSIZE - 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
#define PARAM                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
  mlib_image       *dst,                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
  const mlib_image *src,                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
  mlib_s32         dx_l,                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
  mlib_s32         dx_r,                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
  mlib_s32         dy_t,                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
  mlib_s32         dy_b,                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
  const mlib_s32   *kern,                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
  mlib_s32         scalef_expon,                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
  mlib_s32         cmask
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
#define PARAM_MxN                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
  mlib_image       *dst,                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
  const mlib_image *src,                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
  const mlib_s32   *kernel,                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
  mlib_s32         m,                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
  mlib_s32         n,                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
  mlib_s32         dx_l,                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
  mlib_s32         dx_r,                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
  mlib_s32         dy_t,                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
  mlib_s32         dy_b,                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
  mlib_s32         scale,                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
  mlib_s32         cmask
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
#define FTYPE mlib_d64
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
#ifndef MLIB_USE_FTOI_CLAMPING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
#define CLAMP_S32(x)                                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
  (((x) <= MLIB_S32_MIN) ? MLIB_S32_MIN : (((x) >= MLIB_S32_MAX) ? MLIB_S32_MAX : (mlib_s32)(x)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
#define CLAMP_S32(x) ((mlib_s32)(x))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
#endif /* MLIB_USE_FTOI_CLAMPING */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
#define D2I(x) CLAMP_S32((x) SAT_OFF)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
#define STORE2(res0, res1)                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
  dp[0    ] = res1;                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
  dp[chan1] = res0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
#define STORE2(res0, res1)                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
  dp[0    ] = res0;                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
  dp[chan1] = res1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
#endif /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
#ifdef _NO_LONGLONG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
#define LOAD_BUFF(buff)                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
  buff[i    ] = sp[0];                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
  buff[i + 1] = sp[chan1]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
#else /* _NO_LONGLONG */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
#define LOAD_BUFF(buff)                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
  *(mlib_s64*)(buff + i) = (((mlib_s64)sp[chan1]) << 32) | S64TOS32((mlib_s64)sp[0])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
#else /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
#define LOAD_BUFF(buff)                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
  *(mlib_s64*)(buff + i) = (((mlib_s64)sp[0]) << 32) | S64TOS32((mlib_s64)sp[chan1])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
#endif /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
#endif /* _NO_LONGLONG */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
#define MLIB_D2_24 16777216.0f
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
typedef union {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
  mlib_d64 d64;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
  struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    mlib_s32 i0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    mlib_s32 i1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
  } i32s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
} d64_2x32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
#define BUFF_LINE 256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
#define DEF_VARS(type)                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
  type     *adr_src, *sl, *sp, *sl1;                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
  type     *adr_dst, *dl, *dp;                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
  FTYPE    *pbuff = buff;                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
  mlib_s32 *buffi, *buffo;                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
  mlib_s32 wid, hgt, sll, dll;                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
  mlib_s32 nchannel, chan1, chan2;                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
  mlib_s32 i, j, c, swid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
#define LOAD_KERNEL3()                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
  FTYPE    scalef = DSCALE;                                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8;                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
  FTYPE    p00, p01, p02, p03,                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
           p10, p11, p12, p13,                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
           p20, p21, p22, p23;                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                                                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
  while (scalef_expon > 30) {                                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    scalef /= (1 << 30);                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    scalef_expon -= 30;                                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
  }                                                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                                                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
  scalef /= (1 << scalef_expon);                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                                                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
  /* keep kernel in regs */                                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
  k0 = scalef * kern[0];  k1 = scalef * kern[1];  k2 = scalef * kern[2]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
  k3 = scalef * kern[3];  k4 = scalef * kern[4];  k5 = scalef * kern[5]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
  k6 = scalef * kern[6];  k7 = scalef * kern[7];  k8 = scalef * kern[8]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
#define LOAD_KERNEL(SIZE)                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
  FTYPE    scalef = DSCALE;                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
  while (scalef_expon > 30) {                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    scalef /= (1 << 30);                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    scalef_expon -= 30;                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
  }                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
  scalef /= (1 << scalef_expon);                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
  for (j = 0; j < SIZE; j++) k[j] = scalef * kern[j]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
#define GET_SRC_DST_PARAMETERS(type)                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
  hgt = mlib_ImageGetHeight(src);                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
  wid = mlib_ImageGetWidth(src);                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
  nchannel = mlib_ImageGetChannels(src);                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
  sll = mlib_ImageGetStride(src) / sizeof(type);                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
  dll = mlib_ImageGetStride(dst) / sizeof(type);                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
  adr_src = (type *)mlib_ImageGetData(src);                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
  adr_dst = (type *)mlib_ImageGetData(dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
#ifndef __sparc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
#if IMG_TYPE == 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
 * Test for the presence of any "1" bit in bits
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
   8 to 31 of val. If present, then val is either
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
   negative or >255. If over/underflows of 8 bits
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
   are uncommon, then this technique can be a win,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
   since only a single test, rather than two, is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
   necessary to determine if clamping is needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
   On the other hand, if over/underflows are common,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
   it adds an extra test.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
#define CLAMP_STORE(dst, val)                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
  if (val & 0xffffff00) {                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    if (val < MLIB_U8_MIN)                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
      dst = MLIB_U8_MIN;                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    else                                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
      dst = MLIB_U8_MAX;                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
  } else {                                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    dst = (mlib_u8)val;                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
#elif IMG_TYPE == 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
#define CLAMP_STORE(dst, val)                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
  if (val >= MLIB_S16_MAX)                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    dst = MLIB_S16_MAX;                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
  else if (val <= MLIB_S16_MIN)                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    dst = MLIB_S16_MIN;                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
  else                                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    dst = (mlib_s16)val
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
#elif IMG_TYPE == 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
#define CLAMP_STORE(dst, val)                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
  if (val >= MLIB_U16_MAX)                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    dst = MLIB_U16_MAX;                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
  else if (val <= MLIB_U16_MIN)                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    dst = MLIB_U16_MIN;                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
  else                                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    dst = (mlib_u16)val
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
#endif /* IMG_TYPE == 1 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
#endif /* __sparc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
#define KSIZE  3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
mlib_status CONV_FUNC(3x3)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
  FTYPE    buff[(KSIZE + 2)*BUFF_LINE], *buff0, *buff1, *buff2, *buff3, *buffT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
  DEF_VARS(DTYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
  DTYPE *sl2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
#ifndef __sparc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
  mlib_s32 d0, d1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
#endif /* __sparc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
  LOAD_KERNEL3();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
  GET_SRC_DST_PARAMETERS(DTYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
  swid = wid + KSIZE1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
  if (swid > BUFF_LINE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    pbuff = mlib_malloc((KSIZE + 2)*sizeof(FTYPE   )*swid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    if (pbuff == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
  buff0 = pbuff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
  buff1 = buff0 + swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
  buff2 = buff1 + swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
  buff3 = buff2 + swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
  buffo = (mlib_s32*)(buff3 + swid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
  buffi = buffo + (swid &~ 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
  swid -= (dx_l + dx_r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
  chan1 = nchannel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
  chan2 = chan1 + chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
  for (c = 0; c < nchannel; c++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    sl = adr_src + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    dl = adr_dst + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    else sl1 = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    if ((hgt - dy_b) > 0) sl2 = sl1 + sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    else sl2 = sl1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    for (i = 0; i < dx_l; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
      buff0[i] = (FTYPE)sl[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
      buff1[i] = (FTYPE)sl1[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
      buff2[i] = (FTYPE)sl2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    for (i = 0; i < swid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
      buff0[i + dx_l] = (FTYPE)sl[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
      buff1[i + dx_l] = (FTYPE)sl1[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
      buff2[i + dx_l] = (FTYPE)sl2[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    for (i = 0; i < dx_r; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
      buff0[swid + dx_l + i] = buff0[swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
      buff1[swid + dx_l + i] = buff1[swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
      buff2[swid + dx_l + i] = buff2[swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    if ((hgt - dy_b) > 1) sl = sl2 + sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    else sl = sl2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    for (j = 0; j < hgt; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
      FTYPE    s0, s1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
      p02 = buff0[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
      p12 = buff1[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
      p22 = buff2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
      p03 = buff0[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
      p13 = buff1[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
      p23 = buff2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
      s1 = p03 * k0 + p13 * k3 + p23 * k6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
      sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
      dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
      for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
#ifdef __sparc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
#ifdef _NO_LONGLONG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        mlib_s32 o64_1, o64_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
#else /* _NO_LONGLONG */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        mlib_s64 o64;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
#endif /* _NO_LONGLONG */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
#endif /* __sparc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        d64_2x32 dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        LOAD_BUFF(buffi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        dd.d64 = *(FTYPE   *)(buffi + i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        buff3[i + dx_l    ] = (FTYPE)dd.i32s.i0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        buff3[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
#ifndef __sparc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        d0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        d1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        s1 = p03 * k0 + p13 * k3 + p23 * k6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        dp[0    ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        dp[chan1] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
#else /* __sparc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        dd.i32s.i0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        dd.i32s.i1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        *(FTYPE   *)(buffo + i) = dd.d64;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        s1 = p03 * k0 + p13 * k3 + p23 * k6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
#ifdef _NO_LONGLONG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        o64_1 = buffo[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        o64_2 = buffo[i+1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
#if IMG_TYPE != 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        STORE2(FROM_S32(o64_1), FROM_S32(o64_2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        STORE2(o64_1 >> 24, o64_2 >> 24);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
#endif /* IMG_TYPE != 1 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
#else /* _NO_LONGLONG */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        o64 = *(mlib_s64*)(buffo + i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
#if IMG_TYPE != 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        STORE2(FROM_S32(o64 >> 32), FROM_S32(o64));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        STORE2(o64 >> 56, o64 >> 24);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
#endif /* IMG_TYPE != 1 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
#endif /* _NO_LONGLONG */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
#endif /* __sparc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
      for (; i < wid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        buffi[i] = (mlib_s32)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        buff3[i + dx_l] = (FTYPE)buffi[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
#ifndef __sparc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                 p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        dp[0] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
#else  /* __sparc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        buffo[i] = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                       p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
#if IMG_TYPE != 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        dp[0] = FROM_S32(buffo[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        dp[0] = buffo[i] >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
#endif /* IMG_TYPE != 1 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
#endif /* __sparc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        sp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        dp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
      for (; i < swid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        buffi[i] = (mlib_s32)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        buff3[i + dx_l] = (FTYPE)buffi[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        sp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
      for (i = 0; i < dx_l; i++) buff3[i] = buff3[dx_l];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
      for (i = 0; i < dx_r; i++) buff3[swid + dx_l + i] = buff3[swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
      if (j < hgt - dy_b - 2) sl += sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
      dl += dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
      buffT = buff0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
      buff0 = buff1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
      buff1 = buff2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
      buff2 = buff3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
      buff3 = buffT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
#ifdef __sparc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
#if IMG_TYPE == 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    mlib_s32 amask = (1 << nchannel) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    if ((cmask & amask) != amask) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
      mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
      mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
#endif /* IMG_TYPE == 1 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
#endif /* __sparc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
  if (pbuff != buff) mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
#ifndef __sparc /* for x86, using integer multiplies is faster */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
mlib_status CONV_FUNC_I(3x3)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
  DTYPE    *adr_src, *sl, *sp0, *sp1, *sp2, *sp_1, *sp_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
  DTYPE    *adr_dst, *dl, *dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
  mlib_s32 wid, hgt, sll, dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
  mlib_s32 nchannel, chan1, chan2, delta_chan;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
  mlib_s32 i, j, c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
  mlib_s32 shift1, shift2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
  mlib_s32 p02, p03,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
           p12, p13,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
           p22, p23;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
#if IMG_TYPE != 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
  shift1 = 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
  shift1 = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
#endif /* IMG_TYPE != 1 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
  shift2 = scalef_expon - shift1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
  /* keep kernel in regs */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
  k0 = kern[0] >> shift1;  k1 = kern[1] >> shift1;  k2 = kern[2] >> shift1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
  k3 = kern[3] >> shift1;  k4 = kern[4] >> shift1;  k5 = kern[5] >> shift1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
  k6 = kern[6] >> shift1;  k7 = kern[7] >> shift1;  k8 = kern[8] >> shift1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
  GET_SRC_DST_PARAMETERS(DTYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
  chan1 = nchannel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
  chan2 = chan1 + chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
  delta_chan = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
  if ((1 > dx_l) && (1 < wid + KSIZE1 - dx_r)) delta_chan = chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
  for (c = 0; c < chan1; c++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    sl = adr_src + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    dl = adr_dst + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
    sp_1 = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl += sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    sp_2 = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    if ((hgt - dy_b) > 0) sl += sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    for (j = 0; j < hgt; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
      mlib_s32 s0, s1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
      mlib_s32 pix0, pix1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
      dp  = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
      sp0 = sp_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
      sp_1 = sp_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
      sp_2 = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
      sp1 = sp_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
      sp2 = sp_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
      p02 = sp0[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
      p12 = sp1[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
      p22 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
      p03 = sp0[delta_chan];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
      p13 = sp1[delta_chan];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
      p23 = sp2[delta_chan];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
      s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
      s1 = p03 * k0 + p13 * k3 + p23 * k6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
      sp0 += (chan1 + delta_chan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
      sp1 += (chan1 + delta_chan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
      sp2 += (chan1 + delta_chan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        p02 = sp0[0];     p12 = sp1[0];     p22 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        pix1 = (s1 + p02 * k1 + p03 * k2 + p12 * k4 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                p13 * k5 + p22 * k7 + p23 * k8) >> shift2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        CLAMP_STORE(dp[0],     pix0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        CLAMP_STORE(dp[chan1], pix1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        s1 = p03 * k0 + p13 * k3 + p23 * k6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        sp0 += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        sp1 += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        sp2 += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
      p02 = p03; p12 = p13; p22 = p23;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
      for (; i < wid - dx_r; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        p03 = sp0[0]; p13 = sp1[0]; p23 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        pix0 = (s0 + p03 * k2 + p13 * k5 + p23 * k8) >> shift2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        CLAMP_STORE(dp[0], pix0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
        p02 = p03; p12 = p13; p22 = p23;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        sp0 += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        sp1 += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        sp2 += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        dp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
      sp0 -= chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
      sp1 -= chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
      sp2 -= chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
      for (; i < wid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        p03 = sp0[0]; p13 = sp1[0]; p23 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        pix0 = (s0 + p03 * k2 + p13 * k5 + p23 * k8) >> shift2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        CLAMP_STORE(dp[0], pix0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        p02 = p03; p12 = p13; p22 = p23;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        dp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
      if (j < hgt - dy_b - 1) sl += sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
      dl += dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
#endif /* __sparc ( for x86, using integer multiplies is faster ) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
#undef  KSIZE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
#define KSIZE 4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
mlib_status CONV_FUNC(4x4)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buffd, *buffT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
  FTYPE    k[KSIZE*KSIZE];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
  mlib_s32 d0, d1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
  FTYPE    p00, p01, p02, p03, p04,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
           p10, p11, p12, p13, p14,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
           p20, p21, p22, p23,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
           p30, p31, p32, p33;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
  DEF_VARS(DTYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
  DTYPE *sl2, *sl3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
  LOAD_KERNEL(KSIZE*KSIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
  GET_SRC_DST_PARAMETERS(DTYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
  swid = wid + KSIZE1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
  if (swid > BUFF_LINE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE   )*swid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    if (pbuff == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
  buff0 = pbuff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
  buff1 = buff0 + swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
  buff2 = buff1 + swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
  buff3 = buff2 + swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
  buff4 = buff3 + swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
  buffd = buff4 + swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
  buffo = (mlib_s32*)(buffd + swid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
  buffi = buffo + (swid &~ 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
  swid -= (dx_l + dx_r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
  chan1 = nchannel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
  chan2 = chan1 + chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
  for (c = 0; c < nchannel; c++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
    sl = adr_src + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
    dl = adr_dst + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
    else sl1 = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
    else sl2 = sl1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    if ((hgt - dy_b) > 0) sl3 = sl2 + sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    else sl3 = sl2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
    for (i = 0; i < dx_l; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
      buff0[i] = (FTYPE)sl[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
      buff1[i] = (FTYPE)sl1[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
      buff2[i] = (FTYPE)sl2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
      buff3[i] = (FTYPE)sl3[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    for (i = 0; i < swid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
      buff0[i + dx_l] = (FTYPE)sl[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
      buff1[i + dx_l] = (FTYPE)sl1[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
      buff2[i + dx_l] = (FTYPE)sl2[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
      buff3[i + dx_l] = (FTYPE)sl3[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
    for (i = 0; i < dx_r; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
      buff0[swid + dx_l + i] = buff0[swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
      buff1[swid + dx_l + i] = buff1[swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
      buff2[swid + dx_l + i] = buff2[swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
      buff3[swid + dx_l + i] = buff3[swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
    if ((hgt - dy_b) > 1) sl = sl3 + sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    else sl = sl3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
    for (j = 0; j < hgt; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
      d64_2x32 dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
      /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
       *  First loop on two first lines of kernel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
       */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
      k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
      sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
      dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
      p02 = buff0[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
      p12 = buff1[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
      p03 = buff0[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
      p13 = buff1[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
      p04 = buff0[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
      for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        p00 = p02; p10 = p12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        p01 = p03; p11 = p13;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
        p02 = p04; p12 = buff1[i + 2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        p03 = buff0[i + 3]; p13 = buff1[i + 3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
        p04 = buff0[i + 4]; p14 = buff1[i + 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        LOAD_BUFF(buffi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        dd.d64 = *(FTYPE   *)(buffi + i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
        buff4[i + dx_l    ] = (FTYPE)dd.i32s.i0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        buff4[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
                        p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
                        p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
        sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
      /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
       *  Second loop on two last lines of kernel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
       */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
      k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
      k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
      p02 = buff2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
      p12 = buff3[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
      p03 = buff2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
      p13 = buff3[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
      p04 = buff2[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
      for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
        p00 = p02; p10 = p12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
        p01 = p03; p11 = p13;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
        p02 = p04; p12 = buff3[i + 2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
        p03 = buff2[i + 3]; p13 = buff3[i + 3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
        p04 = buff2[i + 4]; p14 = buff3[i + 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
                 p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buffd[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
                 p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        dp[0    ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
        dp[chan1] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
        dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
      /* last pixels */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
      for (; i < wid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
        buff4[i + dx_l] = (FTYPE)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
                       p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
                       p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
                       p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
        dp[0] = FROM_S32(buffo[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
        sp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        dp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
      for (; i < swid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
        buff4[i + dx_l] = (FTYPE)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
        sp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
      for (i = 0; i < dx_l; i++) buff4[i] = buff4[dx_l];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
      for (i = 0; i < dx_r; i++) buff4[swid + dx_l + i] = buff4[swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
      /* next line */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
      if (j < hgt - dy_b - 2) sl += sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
      dl += dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
      buffT = buff0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
      buff0 = buff1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
      buff1 = buff2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
      buff2 = buff3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
      buff3 = buff4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
      buff4 = buffT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
  if (pbuff != buff) mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
#undef  KSIZE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
#define KSIZE 5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
mlib_status CONV_FUNC(5x5)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
  FTYPE    buff[(KSIZE + 3)*BUFF_LINE];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
  FTYPE    *buff0, *buff1, *buff2, *buff3, *buff4, *buff5, *buffd, *buffT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
  FTYPE    k[KSIZE*KSIZE];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
  mlib_s32 d0, d1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
  FTYPE    k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
  FTYPE    p00, p01, p02, p03, p04, p05,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
           p10, p11, p12, p13, p14, p15,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
           p20, p21, p22, p23, p24,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
           p30, p31, p32, p33, p34,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
           p40, p41, p42, p43, p44;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
  DEF_VARS(DTYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
  DTYPE *sl2, *sl3, *sl4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
  LOAD_KERNEL(KSIZE*KSIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
  GET_SRC_DST_PARAMETERS(DTYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
  swid = wid + KSIZE1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
  if (swid > BUFF_LINE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE   )*swid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
    if (pbuff == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
  buff0 = pbuff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
  buff1 = buff0 + swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
  buff2 = buff1 + swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
  buff3 = buff2 + swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
  buff4 = buff3 + swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
  buff5 = buff4 + swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
  buffd = buff5 + swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
  buffo = (mlib_s32*)(buffd + swid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
  buffi = buffo + (swid &~ 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
  swid -= (dx_l + dx_r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
  chan1 = nchannel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
  chan2 = chan1 + chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
  for (c = 0; c < nchannel; c++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
    sl = adr_src + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
    dl = adr_dst + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
    else sl1 = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
    else sl2 = sl1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
    if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl3 = sl2 + sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
    else sl3 = sl2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
    if ((hgt - dy_b) > 0) sl4 = sl3 + sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
    else sl4 = sl3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
    for (i = 0; i < dx_l; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
      buff0[i] = (FTYPE)sl[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
      buff1[i] = (FTYPE)sl1[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
      buff2[i] = (FTYPE)sl2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
      buff3[i] = (FTYPE)sl3[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
      buff4[i] = (FTYPE)sl4[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
    for (i = 0; i < swid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
      buff0[i + dx_l] = (FTYPE)sl[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
      buff1[i + dx_l] = (FTYPE)sl1[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
      buff2[i + dx_l] = (FTYPE)sl2[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
      buff3[i + dx_l] = (FTYPE)sl3[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
      buff4[i + dx_l] = (FTYPE)sl4[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
    for (i = 0; i < dx_r; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
      buff0[swid + dx_l + i] = buff0[swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
      buff1[swid + dx_l + i] = buff1[swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
      buff2[swid + dx_l + i] = buff2[swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
      buff3[swid + dx_l + i] = buff3[swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
      buff4[swid + dx_l + i] = buff4[swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
    if ((hgt - dy_b) > 1) sl = sl4 + sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
    else sl = sl4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
    for (j = 0; j < hgt; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
      d64_2x32 dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
      /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
       *  First loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
       */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
      sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
      dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
      p02 = buff0[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
      p12 = buff1[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
      p03 = buff0[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
      p13 = buff1[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
      p04 = buff0[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
      p14 = buff1[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
      for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
        p00 = p02; p10 = p12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
        p01 = p03; p11 = p13;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
        p02 = p04; p12 = p14;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
        LOAD_BUFF(buffi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
        p03 = buff0[i + 3]; p13 = buff1[i + 3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
        p04 = buff0[i + 4]; p14 = buff1[i + 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
        p05 = buff0[i + 5]; p15 = buff1[i + 5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
        sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
      /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
       *  Second loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
       */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
      p02 = buff2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
      p12 = buff3[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
      p03 = buff2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
      p13 = buff3[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
      for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
        p00 = p02; p10 = p12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
        p01 = p03; p11 = p13;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
        p02 = buff2[i + 2]; p12 = buff3[i + 2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
        p03 = buff2[i + 3]; p13 = buff3[i + 3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
        p04 = buff2[i + 4]; p14 = buff3[i + 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
        p05 = buff2[i + 5]; p15 = buff3[i + 5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
        dd.d64 = *(FTYPE   *)(buffi + i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
        buff5[i + dx_l    ] = (FTYPE)dd.i32s.i0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
        buff5[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
      /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
       *  3 loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
       */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
      p02 = buff4[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
      p03 = buff4[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
      p04 = buff4[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
      p05 = buff4[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
      for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
        p04 = buff4[i + 4]; p05 = buff4[i + 5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
        d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buffd[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
        d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
        dp[0    ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
        dp[chan1] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
        dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
      /* last pixels */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
      for (; i < wid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
        p00 = buff0[i];     p10 = buff1[i];     p20 = buff2[i];     p30 = buff3[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
        p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
        p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
        p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
        p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
        p40 = buff4[i];     p41 = buff4[i + 1]; p42 = buff4[i + 2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
        p43 = buff4[i + 3]; p44 = buff4[i + 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
        buff5[i + dx_l] = (FTYPE)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
        buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
                       p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
                       p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
                       p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
                       p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
        dp[0] = FROM_S32(buffo[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
        sp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
        dp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
      for (; i < swid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
        buff5[i + dx_l] = (FTYPE)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
        sp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
      for (i = 0; i < dx_l; i++) buff5[i] = buff5[dx_l];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
      for (i = 0; i < dx_r; i++) buff5[swid + dx_l + i] = buff5[swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
      /* next line */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
      if (j < hgt - dy_b - 2) sl += sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
      dl += dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
      buffT = buff0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
      buff0 = buff1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
      buff1 = buff2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
      buff2 = buff3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
      buff3 = buff4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
      buff4 = buff5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
      buff5 = buffT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
  if (pbuff != buff) mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
#ifndef __sparc /* for x86, using integer multiplies is faster */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
mlib_status CONV_FUNC_I(5x5)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
  mlib_s32 buff[BUFF_LINE];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
  mlib_s32 *buffd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
  mlib_s32 k[KSIZE*KSIZE];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
  mlib_s32 shift1, shift2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
  mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
  mlib_s32 p00, p01, p02, p03, p04, p05,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
           p10, p11, p12, p13, p14, p15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
  DTYPE    *adr_src, *sl, *sp0, *sp1, *sp2, *sp3, *sp4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
  DTYPE    *sp_1, *sp_2, *sp_3, *sp_4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
  DTYPE    *adr_dst, *dl, *dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
  mlib_s32 *pbuff = buff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
  mlib_s32 wid, hgt, sll, dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
  mlib_s32 nchannel, chan1, chan2, chan4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
  mlib_s32 delta_chan1, delta_chan2, delta_chan3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
  mlib_s32 i, j, c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
#if IMG_TYPE != 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
  shift1 = 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
  shift1 = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
#endif /* IMG_TYPE != 1 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
  shift2 = scalef_expon - shift1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
  for (j = 0; j < KSIZE*KSIZE; j++) k[j] = kern[j] >> shift1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
  GET_SRC_DST_PARAMETERS(DTYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
  if (wid > BUFF_LINE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
    pbuff = mlib_malloc(sizeof(mlib_s32)*wid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
    if (pbuff == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
  buffd = pbuff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
  chan1 = nchannel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
  chan2 = chan1 + chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
  if ((1 > dx_l) && (1 < wid + KSIZE1 - dx_r)) delta_chan1 = chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
  else delta_chan1 = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
  if ((2 > dx_l) && (2 < wid + KSIZE1 - dx_r)) delta_chan2 = delta_chan1 + chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
  else delta_chan2 = delta_chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
  if ((3 > dx_l) && (3 < wid + KSIZE1 - dx_r)) delta_chan3 = delta_chan2 + chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
  else delta_chan3 = delta_chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
  chan4 = chan1 + delta_chan3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
  for (c = 0; c < chan1; c++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
    sl = adr_src + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
    dl = adr_dst + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
    sp_1 = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl += sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
    sp_2 = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl += sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
    sp_3 = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
    if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl += sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
    sp_4 = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
    if ((hgt - dy_b) > 0) sl += sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
    for (j = 0; j < hgt; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
      mlib_s32 pix0, pix1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
      dp  = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
      sp0 = sp_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
      sp_1 = sp_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
      sp_2 = sp_3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
      sp_3 = sp_4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
      sp_4 = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
      sp1 = sp_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
      sp2 = sp_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
      sp3 = sp_3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
      sp4 = sp_4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
      /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
       *  First loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
       */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
      k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
      k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
      p02 = sp0[0];           p12 = sp1[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
      p03 = sp0[delta_chan1]; p13 = sp1[delta_chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
      p04 = sp0[delta_chan2]; p14 = sp1[delta_chan2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
      p05 = sp0[delta_chan3]; p15 = sp1[delta_chan3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
      sp0 += chan4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
      sp1 += chan4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
        p00 = p02; p10 = p12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
        p01 = p03; p11 = p13;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
        p02 = p04; p12 = p14;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
        p03 = p05; p13 = p15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
        p04 = sp0[0];     p14 = sp1[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
        p05 = sp0[chan1]; p15 = sp1[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
        buffd[i    ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
                        p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
        buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
                        p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
        sp0 += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
        sp1 += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
      p01 = p02; p02 = p03; p03 = p04; p04 = p05;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
      p11 = p12; p12 = p13; p13 = p14; p14 = p15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
      for (; i < wid - dx_r; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
        p00 = p01; p10 = p11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
        p01 = p02; p11 = p12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
        p02 = p03; p12 = p13;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
        p03 = p04; p13 = p14;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
        p04 = sp0[0];     p14 = sp1[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
        buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
                    p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
        sp0 += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
        sp1 += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
      sp0 -= chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
      sp1 -= chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
      for (; i < wid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
        p00 = p01; p10 = p11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
        p01 = p02; p11 = p12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
        p02 = p03; p12 = p13;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
        p03 = p04; p13 = p14;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
        p04 = sp0[0];     p14 = sp1[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
        buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
                    p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
      /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
       *  Second loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
       */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
      k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
      k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
      p02 = sp2[0];           p12 = sp3[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
      p03 = sp2[delta_chan1]; p13 = sp3[delta_chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
      p04 = sp2[delta_chan2]; p14 = sp3[delta_chan2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
      p05 = sp2[delta_chan3]; p15 = sp3[delta_chan3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
      sp2 += chan4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
      sp3 += chan4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
        p00 = p02; p10 = p12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
        p01 = p03; p11 = p13;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
        p02 = p04; p12 = p14;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
        p03 = p05; p13 = p15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
        p04 = sp2[0];     p14 = sp3[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
        p05 = sp2[chan1]; p15 = sp3[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
        buffd[i    ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
                         p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
        buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
                         p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
        sp2 += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
        sp3 += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
      p01 = p02; p02 = p03; p03 = p04; p04 = p05;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
      p11 = p12; p12 = p13; p13 = p14; p14 = p15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
      for (; i < wid - dx_r; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
        p00 = p01; p10 = p11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
        p01 = p02; p11 = p12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
        p02 = p03; p12 = p13;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
        p03 = p04; p13 = p14;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
        p04 = sp2[0];     p14 = sp3[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
        buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
        sp2 += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
        sp3 += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
      sp2 -= chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
      sp3 -= chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
      for (; i < wid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
        p00 = p01; p10 = p11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
        p01 = p02; p11 = p12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
        p02 = p03; p12 = p13;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
        p03 = p04; p13 = p14;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
        p04 = sp2[0];     p14 = sp3[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
        buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
                     p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
      /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
       *  3 loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
       */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
      k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
      p02 = sp4[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
      p03 = sp4[delta_chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
      p04 = sp4[delta_chan2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
      p05 = sp4[delta_chan3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
      sp4 += chan4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
      for (i = 0; i <= (wid - dx_r - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
        p00 = p02; p01 = p03; p02 = p04; p03 = p05;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
        p04 = sp4[0]; p05 = sp4[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
                p03 * k3 + p04 * k4) >> shift2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
        pix1 = (buffd[i + 1] + p01 * k0 + p02 * k1 + p03 * k2 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
                p04 * k3 + p05 * k4) >> shift2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
        CLAMP_STORE(dp[0],     pix0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
        CLAMP_STORE(dp[chan1], pix1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
        dp  += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
        sp4 += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
      p01 = p02; p02 = p03; p03 = p04; p04 = p05;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
      for (; i < wid - dx_r; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
        p00 = p01; p01 = p02; p02 = p03; p03 = p04;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
        p04 = sp4[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
                p03 * k3 + p04 * k4) >> shift2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
        CLAMP_STORE(dp[0],     pix0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
        dp  += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
        sp4 += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
      sp4 -= chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
      for (; i < wid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
        p00 = p01; p01 = p02; p02 = p03; p03 = p04;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
        p04 = sp4[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
        pix0 = (buffd[i    ] + p00 * k0 + p01 * k1 + p02 * k2 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
                p03 * k3 + p04 * k4) >> shift2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
        CLAMP_STORE(dp[0],     pix0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
        dp  += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
      /* next line */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
      if (j < hgt - dy_b - 1) sl += sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
      dl += dll;
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
  if (pbuff != buff) mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
#endif /* __sparc ( for x86, using integer multiplies is faster ) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
#if IMG_TYPE == 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
#undef  KSIZE
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
#define KSIZE 7
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
mlib_status CONV_FUNC(7x7)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
  FTYPE    buff[(KSIZE + 3)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
  FTYPE    k[KSIZE*KSIZE];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
  mlib_s32 l, m, buff_ind;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
  mlib_s32 d0, d1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
  FTYPE    k0, k1, k2, k3, k4, k5, k6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
  FTYPE    p0, p1, p2, p3, p4, p5, p6, p7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
  DTYPE *sl2, *sl3, *sl4, *sl5, *sl6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
  DEF_VARS(DTYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
  LOAD_KERNEL(KSIZE*KSIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
  GET_SRC_DST_PARAMETERS(DTYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
  swid = wid + KSIZE1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
  if (wid > BUFF_LINE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
    pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE   )*wid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
    if (pbuff == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
  for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
  for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
  buffd = buffs[KSIZE] + swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
  buffo = (mlib_s32*)(buffd + swid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
  buffi = buffo + (swid &~ 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
  swid -= (dx_l + dx_r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
  chan1 = nchannel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
  chan2 = chan1 + chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
  for (c = 0; c < nchannel; c++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
    sl = adr_src + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
    dl = adr_dst + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
    if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
    else sl1 = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
    if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
    else sl2 = sl1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
    if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl3 = sl2 + sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
    else sl3 = sl2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
    if ((4 > dy_t) && (4 < hgt + KSIZE1 - dy_b)) sl4 = sl3 + sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
    else sl4 = sl3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
    if ((5 > dy_t) && (5 < hgt + KSIZE1 - dy_b)) sl5 = sl4 + sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
    else sl5 = sl4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
    if ((hgt - dy_b) > 0) sl6 = sl5 + sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
    else sl6 = sl5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
    for (i = 0; i < dx_l; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
      buffs[0][i] = (FTYPE)sl[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
      buffs[1][i] = (FTYPE)sl1[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
      buffs[2][i] = (FTYPE)sl2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
      buffs[3][i] = (FTYPE)sl3[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
      buffs[4][i] = (FTYPE)sl4[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
      buffs[5][i] = (FTYPE)sl5[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
      buffs[6][i] = (FTYPE)sl6[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
    for (i = 0; i < swid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
      buffs[0][i + dx_l] = (FTYPE)sl[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
      buffs[1][i + dx_l] = (FTYPE)sl1[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
      buffs[2][i + dx_l] = (FTYPE)sl2[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
      buffs[3][i + dx_l] = (FTYPE)sl3[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
      buffs[4][i + dx_l] = (FTYPE)sl4[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
      buffs[5][i + dx_l] = (FTYPE)sl5[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
      buffs[6][i + dx_l] = (FTYPE)sl6[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
    for (i = 0; i < dx_r; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
      buffs[0][swid + dx_l + i] = buffs[0][swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
      buffs[1][swid + dx_l + i] = buffs[1][swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
      buffs[2][swid + dx_l + i] = buffs[2][swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
      buffs[3][swid + dx_l + i] = buffs[3][swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
      buffs[4][swid + dx_l + i] = buffs[4][swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
      buffs[5][swid + dx_l + i] = buffs[5][swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
      buffs[6][swid + dx_l + i] = buffs[6][swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
    buff_ind = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
    for (i = 0; i < wid; i++) buffd[i] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
    if ((hgt - dy_b) > 1) sl = sl6 + sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
    else sl = sl6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
    for (j = 0; j < hgt; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
      FTYPE    **buffc = buffs + buff_ind;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
      FTYPE    *buffn = buffc[KSIZE];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
      FTYPE    *pk = k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
      for (l = 0; l < KSIZE; l++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
        FTYPE    *buff = buffc[l];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
        d64_2x32 dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
        sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
        dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
        p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
        p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
        k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
        k4 = *pk++; k5 = *pk++; k6 = *pk++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
        if (l < (KSIZE - 1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
          for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
            p6 = buff[i + 6]; p7 = buff[i + 7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
            buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
            buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
          for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
            p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
            p6 = buff[i + 6]; p7 = buff[i + 7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
            LOAD_BUFF(buffi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1543
            dd.d64 = *(FTYPE   *)(buffi + i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1544
            buffn[i + dx_l    ] = (FTYPE)dd.i32s.i0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
            buffn[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1546
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1547
            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
  1548
            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
  1549
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1550
            dp[0    ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
            dp[chan1] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
            buffd[i    ] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
            buffd[i + 1] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
            sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
            dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
      /* last pixels */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1563
      for (; i < wid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1564
        FTYPE    *pk = k, s = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1565
        mlib_s32 d0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1566
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1567
        for (l = 0; l < KSIZE; l++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
          FTYPE    *buff = buffc[l] + i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
          for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
        d0 = D2I(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
        dp[0] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1575
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
        buffn[i + dx_l] = (FTYPE)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1578
        sp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
        dp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1582
      for (; i < swid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
        buffn[i + dx_l] = (FTYPE)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
        sp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
      for (i = 0; i < dx_l; i++) buffn[i] = buffn[dx_l];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1588
      for (i = 0; i < dx_r; i++) buffn[swid + dx_l + i] = buffn[swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
      /* next line */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
      if (j < hgt - dy_b - 2) sl += sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
      dl += dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1594
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1595
      buff_ind++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1596
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
      if (buff_ind >= KSIZE + 1) buff_ind = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1599
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
  if (pbuff != buff) mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
#endif /* IMG_TYPE == 1 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
#define MAX_KER   7
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
#define MAX_N    15
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1611
#define BUFF_SIZE   1600
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1612
#define CACHE_SIZE  (64*1024)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1613
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
static mlib_status mlib_ImageConv1xN_ext(mlib_image       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
                                         const mlib_image *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1616
                                         const mlib_d64   *k,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
                                         mlib_s32         n,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1618
                                         mlib_s32         dy_t,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1619
                                         mlib_s32         dy_b,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
                                         mlib_s32         cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
  DTYPE    *adr_src, *sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
  DTYPE    *adr_dst, *dl, *dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
  FTYPE    buff[BUFF_SIZE];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
  FTYPE    *buffd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1626
  FTYPE    *pbuff = buff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1627
  const FTYPE    *pk;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1628
  FTYPE    k0, k1, k2, k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1629
  FTYPE    p0, p1, p2, p3, p4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
  FTYPE    *sbuff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1631
  mlib_s32 l, k_off, off, bsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
  mlib_s32 max_hsize, smax_hsize, shgt, hsize, kh;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1633
  mlib_s32 d0, d1, ii;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1634
  mlib_s32 wid, hgt, sll, dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1635
  mlib_s32 nchannel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
  mlib_s32 i, j, c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1637
  GET_SRC_DST_PARAMETERS(DTYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1638
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1639
  max_hsize = ((CACHE_SIZE/sizeof(DTYPE))/sll) - (n - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
  if (max_hsize < 1) max_hsize = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1642
  if (max_hsize > hgt) max_hsize = hgt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
  shgt = hgt + (n - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1645
  smax_hsize = max_hsize + (n - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
  bsize = 2 * (smax_hsize + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1648
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
  if (bsize > BUFF_SIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1650
    pbuff = mlib_malloc(sizeof(FTYPE)*bsize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1651
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1652
    if (pbuff == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1653
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1654
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
  sbuff = pbuff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1656
  buffd = sbuff + smax_hsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1657
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1658
  shgt -= (dy_t + dy_b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1659
  k_off = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
  for (l = 0; l < hgt; l += hsize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1662
    hsize = hgt - l;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1664
    if (hsize > max_hsize) hsize = max_hsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1665
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1666
    smax_hsize = hsize + (n - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1667
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1668
    for (c = 0; c < nchannel; c++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1669
      if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1670
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1671
      sl = adr_src + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1672
      dl = adr_dst + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1673
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1674
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1675
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1676
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1677
      for (i = 0; i < hsize; i++) buffd[i] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1678
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1679
      for (j = 0; j < wid; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1680
        FTYPE    *buff = sbuff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1681
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1682
        for (i = k_off, ii = 0; (i < dy_t) && (ii < smax_hsize); i++, ii++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1683
          sbuff[i - k_off] = (FTYPE)sl[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1684
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1685
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1686
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1687
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1688
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1689
        for (; (i < shgt + dy_t) && (ii < smax_hsize); i++, ii++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1690
          sbuff[i - k_off] = (FTYPE)sl[(i - dy_t)*sll];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1691
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1692
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1693
        for (; (i < shgt + dy_t + dy_b) && (ii < smax_hsize); i++, ii++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1694
          sbuff[i - k_off] = (FTYPE)sl[(shgt - 1)*sll];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1695
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1696
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1697
        pk = k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1698
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1699
        for (off = 0; off < (n - 4); off += 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1700
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1701
          p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1702
          k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1703
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1704
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1705
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1706
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1707
          for (i = 0; i < hsize; i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1708
            p0 = p2; p1 = p3; p2 = p4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1709
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1710
            p3 = buff[i + 3]; p4 = buff[i + 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1711
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1712
            buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1713
            buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1714
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1715
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1716
          pk += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1717
          buff += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1718
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1719
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1720
        dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1721
        kh = n - off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1722
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1723
        if (kh == 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1724
          p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1725
          k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1726
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1727
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1728
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1729
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1730
          for (i = 0; i <= (hsize - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1731
            p0 = p2; p1 = p3; p2 = p4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1732
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1733
            p3 = buff[i + 3]; p4 = buff[i + 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1734
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1735
            d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1736
            d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1737
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1738
            dp[0  ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1739
            dp[dll] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1740
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1741
            buffd[i    ] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1742
            buffd[i + 1] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1743
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1744
            dp += 2*dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1745
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1746
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1747
          if (i < hsize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1748
            p0 = p2; p1 = p3; p2 = p4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1749
            p3 = buff[i + 3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1750
            d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + buffd[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1751
            dp[0] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1752
            buffd[i] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1753
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1754
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1755
        } else if (kh == 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1756
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1757
          p2 = buff[0]; p3 = buff[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1758
          k0 = pk[0]; k1 = pk[1]; k2 = pk[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1759
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1760
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1761
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1762
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1763
          for (i = 0; i <= (hsize - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1764
            p0 = p2; p1 = p3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1765
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1766
            p2 = buff[i + 2]; p3 = buff[i + 3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1767
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1768
            d0 = D2I(p0*k0 + p1*k1 + p2*k2 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1769
            d1 = D2I(p1*k0 + p2*k1 + p3*k2 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1770
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1771
            dp[0  ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1772
            dp[dll] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1773
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1774
            buffd[i    ] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1775
            buffd[i + 1] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1776
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1777
            dp += 2*dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1778
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1779
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1780
          if (i < hsize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1781
            p0 = p2; p1 = p3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1782
            p2 = buff[i + 2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1783
            d0 = D2I(p0*k0 + p1*k1 + p2*k2 + buffd[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1784
            dp[0] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1785
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1786
            buffd[i] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1787
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1788
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1789
        } else if (kh == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1790
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1791
          p2 = buff[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1792
          k0 = pk[0]; k1 = pk[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1793
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1794
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1795
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1796
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1797
          for (i = 0; i <= (hsize - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1798
            p0 = p2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1799
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1800
            p1 = buff[i + 1]; p2 = buff[i + 2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1801
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1802
            d0 = D2I(p0*k0 + p1*k1 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1803
            d1 = D2I(p1*k0 + p2*k1 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1804
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1805
            dp[0  ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1806
            dp[dll] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1807
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1808
            buffd[i    ] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1809
            buffd[i + 1] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1810
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1811
            dp += 2*dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1812
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1813
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1814
          if (i < hsize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1815
            p0 = p2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1816
            p1 = buff[i + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1817
            d0 = D2I(p0*k0 + p1*k1 + buffd[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1818
            dp[0] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1819
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1820
            buffd[i] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1821
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1822
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1823
        } else /* kh == 1 */{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1824
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1825
          k0 = pk[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1826
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1827
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1828
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1829
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1830
          for (i = 0; i <= (hsize - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1831
            p0 = buff[i]; p1 = buff[i + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1832
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1833
            d0 = D2I(p0*k0 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1834
            d1 = D2I(p1*k0 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1835
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1836
            dp[0  ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1837
            dp[dll] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1838
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1839
            buffd[i    ] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1840
            buffd[i + 1] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1841
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1842
            dp += 2*dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1843
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1844
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1845
          if (i < hsize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1846
            p0 = buff[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1847
            d0 = D2I(p0*k0 + buffd[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1848
            dp[0] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1849
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1850
            buffd[i] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1851
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1852
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1853
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1854
        /* next line */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1855
        sl += nchannel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1856
        dl += nchannel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1857
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1858
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1859
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1860
    k_off += max_hsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1861
    adr_dst += max_hsize*dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1862
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1863
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1864
  if (pbuff != buff) mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1865
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1866
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1867
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1868
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1869
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1870
mlib_status CONV_FUNC_MxN
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1871
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1872
  DTYPE    *adr_src, *sl, *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1873
  DTYPE    *adr_dst, *dl, *dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1874
  FTYPE    buff[BUFF_SIZE], *buffs_arr[2*(MAX_N + 1)];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1875
  FTYPE    **buffs = buffs_arr, *buffd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1876
  FTYPE    akernel[256], *k = akernel, fscale = DSCALE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1877
  FTYPE    *pbuff = buff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1878
  FTYPE    k0, k1, k2, k3, k4, k5, k6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1879
  FTYPE    p0, p1, p2, p3, p4, p5, p6, p7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1880
  mlib_s32 *buffi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1881
  mlib_s32 mn, l, off, kw, bsize, buff_ind;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1882
  mlib_s32 d0, d1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1883
  mlib_s32 wid, hgt, sll, dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1884
  mlib_s32 nchannel, chan1, chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1885
  mlib_s32 i, j, c, swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1886
  d64_2x32 dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1887
  GET_SRC_DST_PARAMETERS(DTYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1888
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1889
  if (scale > 30) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1890
    fscale *= 1.0/(1 << 30);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1891
    scale -= 30;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1892
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1893
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1894
  fscale /= (1 << scale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1895
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1896
  mn = m*n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1897
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1898
  if (mn > 256) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1899
    k = mlib_malloc(mn*sizeof(mlib_d64));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1900
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1901
    if (k == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1902
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1903
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1904
  for (i = 0; i < mn; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1905
    k[i] = kernel[i]*fscale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1906
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1907
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1908
  if (m == 1) return mlib_ImageConv1xN_ext(dst, src, k, n, dy_t, dy_b, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1909
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1910
  swid = wid + (m - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1911
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1912
  bsize = (n + 3)*swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1913
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1914
  if ((bsize > BUFF_SIZE) || (n > MAX_N)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1915
    pbuff = mlib_malloc(sizeof(FTYPE)*bsize + sizeof(FTYPE *)*2*(n + 1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1916
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1917
    if (pbuff == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1918
    buffs = (FTYPE   **)(pbuff + bsize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1919
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1920
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1921
  for (l = 0; l < (n + 1); l++) buffs[l] = pbuff + l*swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1922
  for (l = 0; l < (n + 1); l++) buffs[l + (n + 1)] = buffs[l];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1923
  buffd = buffs[n] + swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1924
  buffi = (mlib_s32*)(buffd + swid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1925
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1926
  chan1 = nchannel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1927
  chan2 = chan1 + chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1928
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1929
  swid -= (dx_l + dx_r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1930
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1931
  for (c = 0; c < nchannel; c++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1932
    if (!(cmask & (1 << (chan1 - 1 - c)))) continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1933
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1934
    sl = adr_src + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1935
    dl = adr_dst + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1936
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1937
    for (l = 0; l < n; l++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1938
      FTYPE    *buff = buffs[l];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1939
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1940
      for (i = 0; i < dx_l; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1941
        buff[i] = (FTYPE)sl[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1942
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1943
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1944
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1945
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1946
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1947
      for (i = 0; i < swid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1948
        buff[i + dx_l] = (FTYPE)sl[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1949
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1950
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1951
      for (i = 0; i < dx_r; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1952
        buff[swid + dx_l + i] = buff[swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1953
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1954
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1955
      if ((l >= dy_t) && (l < hgt + n - dy_b - 2)) sl += sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1956
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1957
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1958
    buff_ind = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1959
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1960
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1961
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1962
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1963
    for (i = 0; i < wid; i++) buffd[i] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1964
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1965
    for (j = 0; j < hgt; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1966
      FTYPE    **buffc = buffs + buff_ind;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1967
      FTYPE    *buffn = buffc[n];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1968
      FTYPE    *pk = k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1969
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1970
      for (l = 0; l < n; l++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1971
        FTYPE    *buff_l = buffc[l];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1972
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1973
        for (off = 0; off < m;) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1974
          FTYPE    *buff = buff_l + off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1975
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1976
          kw = m - off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1977
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1978
          if (kw > 2*MAX_KER) kw = MAX_KER; else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1979
            if (kw > MAX_KER) kw = kw/2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1980
          off += kw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1981
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1982
          sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1983
          dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1984
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1985
          if (kw == 7) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1986
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1987
            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1988
            p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1989
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1990
            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1991
            k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1992
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1993
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1994
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1995
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1996
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1997
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1998
                p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1999
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2000
                p6 = buff[i + 6]; p7 = buff[i + 7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2001
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2002
                buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2003
                buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2004
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2005
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2006
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2007
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2008
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2009
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2010
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2011
                p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2012
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2013
                p6 = buff[i + 6]; p7 = buff[i + 7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2014
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2015
                LOAD_BUFF(buffi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2016
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2017
                dd.d64 = *(FTYPE   *)(buffi + i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2018
                buffn[i + dx_l    ] = (FTYPE)dd.i32s.i0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2019
                buffn[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2020
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2021
                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
  2022
                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
  2023
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2024
                dp[0    ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2025
                dp[chan1] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2026
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2027
                buffd[i    ] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2028
                buffd[i + 1] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2029
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2030
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2031
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2032
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2033
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2034
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2035
          } else if (kw == 6) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2036
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2037
            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2038
            p5 = buff[3]; p6 = buff[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2039
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2040
            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2041
            k4 = pk[4]; k5 = pk[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2042
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2043
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2044
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2045
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2046
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2047
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2048
                p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2049
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2050
                p5 = buff[i + 5]; p6 = buff[i + 6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2051
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2052
                buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2053
                buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2054
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2055
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2056
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2057
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2058
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2059
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2060
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2061
                p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2062
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2063
                p5 = buff[i + 5]; p6 = buff[i + 6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2064
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2065
                LOAD_BUFF(buffi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2066
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2067
                dd.d64 = *(FTYPE   *)(buffi + i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2068
                buffn[i + dx_l    ] = (FTYPE)dd.i32s.i0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2069
                buffn[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2070
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2071
                d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2072
                d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2073
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2074
                dp[0    ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2075
                dp[chan1] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2076
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2077
                buffd[i    ] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2078
                buffd[i + 1] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2079
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2080
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2081
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2082
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2083
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2084
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2085
          } else if (kw == 5) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2086
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2087
            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2088
            p5 = buff[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2089
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2090
            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2091
            k4 = pk[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2092
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2093
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2094
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2095
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2096
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2097
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2098
                p0 = p2; p1 = p3; p2 = p4; p3 = p5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2099
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2100
                p4 = buff[i + 4]; p5 = buff[i + 5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2101
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2102
                buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2103
                buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2104
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2105
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2106
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2107
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2108
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2109
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2110
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2111
                p0 = p2; p1 = p3; p2 = p4; p3 = p5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2112
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2113
                p4 = buff[i + 4]; p5 = buff[i + 5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2114
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2115
                LOAD_BUFF(buffi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2116
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2117
                dd.d64 = *(FTYPE   *)(buffi + i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2118
                buffn[i + dx_l    ] = (FTYPE)dd.i32s.i0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2119
                buffn[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2120
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2121
                d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2122
                d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2123
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2124
                dp[0    ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2125
                dp[chan1] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2126
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2127
                buffd[i    ] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2128
                buffd[i + 1] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2129
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2130
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2131
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2132
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2133
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2134
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2135
          } else if (kw == 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2136
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2137
            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2138
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2139
            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2140
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2141
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2142
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2143
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2144
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2145
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2146
                p0 = p2; p1 = p3; p2 = p4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2147
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2148
                p3 = buff[i + 3]; p4 = buff[i + 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2149
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2150
                buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2151
                buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2152
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2153
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2154
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2155
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2156
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2157
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2158
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2159
                p0 = p2; p1 = p3; p2 = p4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2160
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2161
                p3 = buff[i + 3]; p4 = buff[i + 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2162
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2163
                LOAD_BUFF(buffi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2164
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2165
                dd.d64 = *(FTYPE   *)(buffi + i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2166
                buffn[i + dx_l    ] = (FTYPE)dd.i32s.i0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2167
                buffn[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2168
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2169
                d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2170
                d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2171
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2172
                dp[0    ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2173
                dp[chan1] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2174
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2175
                buffd[i    ] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2176
                buffd[i + 1] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2177
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2178
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2179
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2180
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2181
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2182
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2183
          } else if (kw == 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2184
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2185
            p2 = buff[0]; p3 = buff[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2186
            k0 = pk[0]; k1 = pk[1]; k2 = pk[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2187
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2188
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2189
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2190
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2191
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2192
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2193
                p0 = p2; p1 = p3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2194
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2195
                p2 = buff[i + 2]; p3 = buff[i + 3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2196
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2197
                buffd[i    ] += p0*k0 + p1*k1 + p2*k2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2198
                buffd[i + 1] += p1*k0 + p2*k1 + p3*k2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2199
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2200
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2201
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2202
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2203
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2204
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2205
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2206
                p0 = p2; p1 = p3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2207
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2208
                p2 = buff[i + 2]; p3 = buff[i + 3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2209
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2210
                LOAD_BUFF(buffi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2211
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2212
                dd.d64 = *(FTYPE   *)(buffi + i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2213
                buffn[i + dx_l    ] = (FTYPE)dd.i32s.i0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2214
                buffn[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2215
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2216
                d0 = D2I(p0*k0 + p1*k1 + p2*k2 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2217
                d1 = D2I(p1*k0 + p2*k1 + p3*k2 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2218
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2219
                dp[0    ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2220
                dp[chan1] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2221
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2222
                buffd[i    ] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2223
                buffd[i + 1] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2224
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2225
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2226
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2227
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2228
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2229
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2230
          } else /* if (kw == 2) */ {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2231
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2232
            p2 = buff[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2233
            k0 = pk[0]; k1 = pk[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2234
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2235
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2236
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2237
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2238
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2239
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2240
                p0 = p2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2241
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2242
                p1 = buff[i + 1]; p2 = buff[i + 2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2243
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2244
                buffd[i    ] += p0*k0 + p1*k1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2245
                buffd[i + 1] += p1*k0 + p2*k1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2246
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2247
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2248
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2249
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2250
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2251
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2252
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2253
                p0 = p2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2254
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2255
                p1 = buff[i + 1]; p2 = buff[i + 2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2256
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2257
                LOAD_BUFF(buffi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2258
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2259
                dd.d64 = *(FTYPE   *)(buffi + i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2260
                buffn[i + dx_l    ] = (FTYPE)dd.i32s.i0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2261
                buffn[i + dx_l + 1] = (FTYPE)dd.i32s.i1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2262
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2263
                d0 = D2I(p0*k0 + p1*k1 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2264
                d1 = D2I(p1*k0 + p2*k1 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2265
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2266
                dp[0    ] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2267
                dp[chan1] = FROM_S32(d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2268
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2269
                buffd[i    ] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2270
                buffd[i + 1] = 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2271
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2272
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2273
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2274
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2275
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2276
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2277
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2278
          pk += kw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2279
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2280
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2281
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2282
      /* last pixels */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2283
      for (; i < wid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2284
        FTYPE    *pk = k, s = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2285
        mlib_s32 x, d0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2286
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2287
        for (l = 0; l < n; l++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2288
          FTYPE    *buff = buffc[l] + i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2289
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2290
          for (x = 0; x < m; x++) s += buff[x] * (*pk++);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2291
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2292
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2293
        d0 = D2I(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2294
        dp[0] = FROM_S32(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2295
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2296
        buffn[i + dx_l] = (FTYPE)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2297
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2298
        sp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2299
        dp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2300
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2301
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2302
      for (; i < swid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2303
        buffn[i + dx_l] = (FTYPE)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2304
        sp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2305
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2306
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2307
      for (i = 0; i < dx_l; i++) buffn[i] = buffn[dx_l];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2308
      for (i = 0; i < dx_r; i++) buffn[swid + dx_l + i] = buffn[swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2309
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2310
      /* next line */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2311
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2312
      if (j < hgt - dy_b - 2) sl += sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2313
      dl += dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2314
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2315
      buff_ind++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2316
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2317
      if (buff_ind >= n + 1) buff_ind = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2318
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2319
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2320
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2321
  if (pbuff != buff) mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2322
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2323
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2324
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2325
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2326
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2327
#ifndef __sparc /* for x86, using integer multiplies is faster */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2328
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2329
#define STORE_RES(res, x)                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2330
  x >>= shift2;                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2331
  CLAMP_STORE(res, x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2332
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2333
mlib_status CONV_FUNC_MxN_I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2334
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2335
  DTYPE    *adr_src, *sl, *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2336
  DTYPE    *adr_dst, *dl, *dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2337
  mlib_s32 buff[BUFF_SIZE], *buffs_arr[2*(MAX_N + 1)];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2338
  mlib_s32 *pbuff = buff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2339
  mlib_s32 **buffs = buffs_arr, *buffd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2340
  mlib_s32 l, off, kw, bsize, buff_ind;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2341
  mlib_s32 d0, d1, shift1, shift2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2342
  mlib_s32 k0, k1, k2, k3, k4, k5, k6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2343
  mlib_s32 p0, p1, p2, p3, p4, p5, p6, p7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2344
  mlib_s32 wid, hgt, sll, dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2345
  mlib_s32 nchannel, chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2346
  mlib_s32 i, j, c, swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2347
  mlib_s32 chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2348
  mlib_s32 k_locl[MAX_N*MAX_N], *k = k_locl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2349
  GET_SRC_DST_PARAMETERS(DTYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2350
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2351
#if IMG_TYPE != 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2352
  shift1 = 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2353
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2354
  shift1 = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2355
#endif /* IMG_TYPE != 1 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2356
  shift2 = scale - shift1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2357
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2358
  chan1 = nchannel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2359
  chan2 = chan1 + chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2360
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2361
  swid = wid + (m - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2362
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2363
  bsize = (n + 2)*swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2364
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2365
  if ((bsize > BUFF_SIZE) || (n > MAX_N)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2366
    pbuff = mlib_malloc(sizeof(mlib_s32)*bsize + sizeof(mlib_s32 *)*2*(n + 1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2367
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2368
    if (pbuff == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2369
    buffs = (mlib_s32 **)(pbuff + bsize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2370
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2371
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2372
  for (l = 0; l < (n + 1); l++) buffs[l] = pbuff + l*swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2373
  for (l = 0; l < (n + 1); l++) buffs[l + (n + 1)] = buffs[l];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2374
  buffd = buffs[n] + swid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2375
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2376
  if (m*n > MAX_N*MAX_N) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2377
    k = mlib_malloc(sizeof(mlib_s32)*(m*n));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2378
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2379
    if (k == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2380
      if (pbuff != buff) mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2381
      return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2382
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2383
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2384
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2385
  for (i = 0; i < m*n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2386
    k[i] = kernel[i] >> shift1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2387
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2388
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2389
  swid -= (dx_l + dx_r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2390
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2391
  for (c = 0; c < nchannel; c++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2392
    if (!(cmask & (1 << (nchannel - 1 - c)))) continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2393
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2394
    sl = adr_src + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2395
    dl = adr_dst + c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2396
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2397
    for (l = 0; l < n; l++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2398
      mlib_s32  *buff = buffs[l];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2399
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2400
      for (i = 0; i < dx_l; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2401
        buff[i] = (mlib_s32)sl[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2402
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2403
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2404
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2405
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2406
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2407
      for (i = 0; i < swid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2408
        buff[i + dx_l] = (mlib_s32)sl[i*chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2409
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2410
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2411
      for (i = 0; i < dx_r; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2412
        buff[swid + dx_l + i] = buff[swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2413
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2414
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2415
      if ((l >= dy_t) && (l < hgt + n - dy_b - 2)) sl += sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2416
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2417
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2418
    buff_ind = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2419
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2420
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2421
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2422
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2423
    for (i = 0; i < wid; i++) buffd[i] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2424
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2425
    for (j = 0; j < hgt; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2426
      mlib_s32 **buffc = buffs + buff_ind;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2427
      mlib_s32 *buffn = buffc[n];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2428
      mlib_s32 *pk = k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2429
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2430
      for (l = 0; l < n; l++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2431
        mlib_s32  *buff_l = buffc[l];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2432
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2433
        for (off = 0; off < m;) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2434
          mlib_s32 *buff = buff_l + off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2435
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2436
          sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2437
          dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2438
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2439
          kw = m - off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2440
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2441
          if (kw > 2*MAX_KER) kw = MAX_KER; else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2442
            if (kw > MAX_KER) kw = kw/2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2443
          off += kw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2444
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2445
          if (kw == 7) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2446
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2447
            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2448
            p5 = buff[3]; p6 = buff[4]; p7 = buff[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2449
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2450
            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2451
            k4 = pk[4]; k5 = pk[5]; k6 = pk[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2452
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2453
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2454
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2455
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2456
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2457
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2458
                p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2459
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2460
                p6 = buff[i + 6]; p7 = buff[i + 7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2461
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2462
                buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2463
                buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2464
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2465
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2466
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2467
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2468
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2469
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2470
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2471
                p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2472
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2473
                p6 = buff[i + 6]; p7 = buff[i + 7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2474
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2475
                buffn[i + dx_l    ] = (mlib_s32)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2476
                buffn[i + dx_l + 1] = (mlib_s32)sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2477
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2478
                d0 = (p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2479
                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
  2480
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2481
                STORE_RES(dp[0    ], d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2482
                STORE_RES(dp[chan1], d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2483
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2484
                buffd[i    ] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2485
                buffd[i + 1] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2486
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2487
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2488
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2489
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2490
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2491
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2492
          } else if (kw == 6) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2493
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2494
            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2495
            p5 = buff[3]; p6 = buff[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2496
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2497
            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2498
            k4 = pk[4]; k5 = pk[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2499
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2500
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2501
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2502
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2503
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2504
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2505
                p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2506
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2507
                p5 = buff[i + 5]; p6 = buff[i + 6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2508
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2509
                buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2510
                buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2511
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2512
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2513
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2514
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2515
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2516
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2517
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2518
                p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2519
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2520
                p5 = buff[i + 5]; p6 = buff[i + 6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2521
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2522
                buffn[i + dx_l    ] = (mlib_s32)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2523
                buffn[i + dx_l + 1] = (mlib_s32)sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2524
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2525
                d0 = (p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2526
                d1 = (p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2527
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2528
                STORE_RES(dp[0    ], d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2529
                STORE_RES(dp[chan1], d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2530
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2531
                buffd[i    ] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2532
                buffd[i + 1] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2533
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2534
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2535
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2536
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2537
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2538
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2539
          } else if (kw == 5) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2540
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2541
            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2542
            p5 = buff[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2543
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2544
            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2545
            k4 = pk[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2546
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2547
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2548
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2549
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2550
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2551
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2552
                p0 = p2; p1 = p3; p2 = p4; p3 = p5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2553
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2554
                p4 = buff[i + 4]; p5 = buff[i + 5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2555
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2556
                buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2557
                buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2558
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2559
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2560
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2561
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2562
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2563
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2564
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2565
                p0 = p2; p1 = p3; p2 = p4; p3 = p5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2566
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2567
                p4 = buff[i + 4]; p5 = buff[i + 5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2568
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2569
                buffn[i + dx_l    ] = (mlib_s32)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2570
                buffn[i + dx_l + 1] = (mlib_s32)sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2571
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2572
                d0 = (p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2573
                d1 = (p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2574
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2575
                STORE_RES(dp[0    ], d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2576
                STORE_RES(dp[chan1], d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2577
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2578
                buffd[i    ] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2579
                buffd[i + 1] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2580
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2581
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2582
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2583
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2584
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2585
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2586
          } else if (kw == 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2587
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2588
            p2 = buff[0]; p3 = buff[1]; p4 = buff[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2589
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2590
            k0 = pk[0]; k1 = pk[1]; k2 = pk[2]; k3 = pk[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2591
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2592
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2593
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2594
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2595
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2596
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2597
                p0 = p2; p1 = p3; p2 = p4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2598
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2599
                p3 = buff[i + 3]; p4 = buff[i + 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2600
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2601
                buffd[i    ] += p0*k0 + p1*k1 + p2*k2 + p3*k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2602
                buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2603
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2604
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2605
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2606
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2607
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2608
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2609
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2610
                p0 = p2; p1 = p3; p2 = p4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2611
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2612
                p3 = buff[i + 3]; p4 = buff[i + 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2613
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2614
                buffn[i + dx_l    ] = (mlib_s32)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2615
                buffn[i + dx_l + 1] = (mlib_s32)sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2616
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2617
                d0 = (p0*k0 + p1*k1 + p2*k2 + p3*k3 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2618
                d1 = (p1*k0 + p2*k1 + p3*k2 + p4*k3 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2619
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2620
                STORE_RES(dp[0    ], d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2621
                STORE_RES(dp[chan1], d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2622
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2623
                buffd[i    ] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2624
                buffd[i + 1] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2625
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2626
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2627
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2628
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2629
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2630
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2631
          } else if (kw == 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2632
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2633
            p2 = buff[0]; p3 = buff[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2634
            k0 = pk[0]; k1 = pk[1]; k2 = pk[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2635
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2636
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2637
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2638
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2639
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2640
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2641
                p0 = p2; p1 = p3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2642
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2643
                p2 = buff[i + 2]; p3 = buff[i + 3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2644
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2645
                buffd[i    ] += p0*k0 + p1*k1 + p2*k2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2646
                buffd[i + 1] += p1*k0 + p2*k1 + p3*k2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2647
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2648
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2649
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2650
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2651
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2652
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2653
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2654
                p0 = p2; p1 = p3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2655
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2656
                p2 = buff[i + 2]; p3 = buff[i + 3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2657
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2658
                buffn[i + dx_l    ] = (mlib_s32)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2659
                buffn[i + dx_l + 1] = (mlib_s32)sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2660
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2661
                d0 = (p0*k0 + p1*k1 + p2*k2 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2662
                d1 = (p1*k0 + p2*k1 + p3*k2 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2663
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2664
                STORE_RES(dp[0    ], d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2665
                STORE_RES(dp[chan1], d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2666
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2667
                buffd[i    ] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2668
                buffd[i + 1] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2669
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2670
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2671
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2672
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2673
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2674
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2675
          } else if (kw == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2676
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2677
            p2 = buff[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2678
            k0 = pk[0]; k1 = pk[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2679
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2680
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2681
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2682
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2683
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2684
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2685
                p0 = p2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2686
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2687
                p1 = buff[i + 1]; p2 = buff[i + 2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2688
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2689
                buffd[i    ] += p0*k0 + p1*k1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2690
                buffd[i + 1] += p1*k0 + p2*k1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2691
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2692
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2693
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2694
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2695
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2696
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2697
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2698
                p0 = p2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2699
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2700
                p1 = buff[i + 1]; p2 = buff[i + 2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2701
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2702
                buffn[i + dx_l    ] = (mlib_s32)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2703
                buffn[i + dx_l + 1] = (mlib_s32)sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2704
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2705
                d0 = (p0*k0 + p1*k1 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2706
                d1 = (p1*k0 + p2*k1 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2707
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2708
                STORE_RES(dp[0    ], d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2709
                STORE_RES(dp[chan1], d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2710
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2711
                buffd[i    ] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2712
                buffd[i + 1] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2713
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2714
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2715
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2716
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2717
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2718
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2719
          } else /* kw == 1 */{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2720
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2721
            k0 = pk[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2722
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2723
            if (l < (n - 1) || off < m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2724
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2725
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2726
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2727
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2728
                p0 = buff[i]; p1 = buff[i + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2729
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2730
                buffd[i    ] += p0*k0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2731
                buffd[i + 1] += p1*k0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2732
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2733
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2734
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2735
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2736
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2737
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2738
              for (i = 0; i <= (wid - 2); i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2739
                p0 = buff[i]; p1 = buff[i + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2740
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2741
                buffn[i + dx_l    ] = (mlib_s32)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2742
                buffn[i + dx_l + 1] = (mlib_s32)sp[chan1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2743
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2744
                d0 = (p0*k0 + buffd[i    ]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2745
                d1 = (p1*k0 + buffd[i + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2746
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2747
                STORE_RES(dp[0    ], d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2748
                STORE_RES(dp[chan1], d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2749
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2750
                buffd[i    ] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2751
                buffd[i + 1] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2752
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2753
                sp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2754
                dp += chan2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2755
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2756
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2757
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2758
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2759
          pk += kw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2760
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2761
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2762
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2763
      /* last pixels */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2764
      for (; i < wid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2765
        mlib_s32 *pk = k, x, s = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2766
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2767
        for (l = 0; l < n; l++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2768
          mlib_s32 *buff = buffc[l] + i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2769
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2770
          for (x = 0; x < m; x++) s += buff[x] * (*pk++);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2771
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2772
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2773
        STORE_RES(dp[0], s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2774
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2775
        buffn[i + dx_l] = (mlib_s32)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2776
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2777
        sp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2778
        dp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2779
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2780
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2781
      for (; i < swid; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2782
        buffn[i + dx_l] = (mlib_s32)sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2783
        sp += chan1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2784
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2785
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2786
      for (i = 0; i < dx_l; i++) buffn[i] = buffn[dx_l];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2787
      for (i = 0; i < dx_r; i++) buffn[swid + dx_l + i] = buffn[swid + dx_l - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2788
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2789
      /* next line */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2790
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2791
      if (j < hgt - dy_b - 2) sl += sll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2792
      dl += dll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2793
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2794
      buff_ind++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2795
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2796
      if (buff_ind >= n + 1) buff_ind = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2797
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2798
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2799
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2800
  if (pbuff != buff) mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2801
  if (k != k_locl) mlib_free(k);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2802
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2803
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2804
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2805
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2806
#endif /* __sparc ( for x86, using integer multiplies is faster ) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2807
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2808
/***************************************************************/