jdk/src/share/native/sun/awt/medialib/mlib_c_ImageAffine_BC_S16.c
author lana
Thu, 26 Dec 2013 12:04:16 -0800
changeset 23010 6dadb192ad81
parent 5506 202f599c92aa
permissions -rw-r--r--
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013 Summary: updated files with 2011, 2012 and 2013 years according to the file's last updated date Reviewed-by: tbell, lancea, chegar
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
 *      Image affine transformation with Bicubic filtering
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * SYNOPSIS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 *      mlib_status mlib_ImageAffine_[u8|s16|u16]_?ch_bc(mlib_s32 *leftEdges,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *                                                       mlib_s32 *rightEdges,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *                                                       mlib_s32 *xStarts,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *                                                       mlib_s32 *yStarts,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *                                                       mlib_s32 *sides,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *                                                       mlib_u8  *dstData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *                                                       mlib_u8  **lineAddr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *                                                       mlib_s32 dstYStride,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *                                                       mlib_s32 is_affine,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *                                                       mlib_s32 srcYStride,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *                                                       mlib_filter filter)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * ARGUMENTS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *      leftEdges  array[dstHeight] of xLeft coordinates
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *      RightEdges array[dstHeight] of xRight coordinates
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *      xStarts    array[dstHeight] of xStart * 65536 coordinates
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *      yStarts    array[dstHeight] of yStart * 65536 coordinates
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *      sides      output array[4]. sides[0] is yStart, sides[1] is yFinish,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *                 sides[2] is dx * 65536, sides[3] is dy * 65536
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *      dstData    pointer to the first pixel on (yStart - 1) line
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *      lineAddr   array[srcHeight] of pointers to the first pixel on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *                 the corresponding lines
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *      dstYStride stride of destination image
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *      is_affine  indicator (Affine - GridWarp)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *      srcYStride stride of source image
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *      filter     type of resampling filter
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * DESCRIPTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *      The functions step along the lines from xLeft to xRight and apply
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 *      the bicubic filtering.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
#include "mlib_ImageAffine.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
#define DTYPE           mlib_s16
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
#define FILTER_BITS     9
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
#define FUN_NAME(CHAN)  mlib_ImageAffine_s16_##CHAN##_bc
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
#ifdef __sparc /* for SPARC, using floating-point multiplies is faster */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
#undef  FILTER_ELEM_BITS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
#define FILTER_ELEM_BITS  4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
#ifdef MLIB_USE_FTOI_CLAMPING
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
#define SAT16(DST)                                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
  DST = ((mlib_s32)val0) >> 16
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
#define SAT16(DST)                                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
  if (val0 >= MLIB_S32_MAX)                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    DST = MLIB_S16_MAX;                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
  else if (val0 <= MLIB_S32_MIN)                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    DST = MLIB_S16_MIN;                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
  else                                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    DST = ((mlib_s32)val0) >> 16
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
#endif /* MLIB_USE_FTOI_CLAMPING */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
mlib_status FUN_NAME(1ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
  DECLAREVAR_BC();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
  DTYPE *dstLineEnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
  const mlib_f32 *mlib_filters_table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
  if (filter == MLIB_BICUBIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    mlib_filters_table = mlib_filters_s16f_bc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
  else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    mlib_filters_table = mlib_filters_s16f_bc2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    mlib_d64 xf0, xf1, xf2, xf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    mlib_d64 yf0, yf1, yf2, yf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    mlib_d64 c0, c1, c2, c3, val0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    mlib_s32 filterpos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    mlib_f32 *fptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    mlib_s32 s0, s1, s2, s3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    mlib_s32 s4, s5, s6, s7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    CLIP(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    dstLineEnd = (DTYPE *) dstData + xRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    filterpos = (X >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    fptr = (mlib_f32 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    xf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    xf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    xf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    xf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    filterpos = (Y >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    fptr = (mlib_f32 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    yf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    yf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    yf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    yf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    xSrc = (X >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    ySrc = (Y >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + xSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    s1 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    s2 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    s3 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    s5 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    s6 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    s7 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    for (; dstPixelPtr <= (dstLineEnd - 1); dstPixelPtr++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
      X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
      Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
      c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
      c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
      c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[1] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            srcPixelPtr[2] * xf2 + srcPixelPtr[3] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
      c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[1] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            srcPixelPtr[2] * xf2 + srcPixelPtr[3] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
      filterpos = (X >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
      fptr = (mlib_f32 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
      xf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
      xf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
      xf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
      xf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
      val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
      filterpos = (Y >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
      fptr = (mlib_f32 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
      yf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
      yf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
      yf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
      yf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
      SAT16(dstPixelPtr[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
      xSrc = (X >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
      ySrc = (Y >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
      srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + xSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
      s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
      s1 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
      s2 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
      s3 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
      s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
      s5 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
      s6 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
      s7 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[1] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
          srcPixelPtr[2] * xf2 + srcPixelPtr[3] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[1] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
          srcPixelPtr[2] * xf2 + srcPixelPtr[3] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    SAT16(dstPixelPtr[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
mlib_status FUN_NAME(2ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
  DECLAREVAR_BC();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
  DTYPE *dstLineEnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
  const mlib_f32 *mlib_filters_table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
  if (filter == MLIB_BICUBIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    mlib_filters_table = mlib_filters_s16f_bc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
  else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    mlib_filters_table = mlib_filters_s16f_bc2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    mlib_d64 xf0, xf1, xf2, xf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    mlib_d64 yf0, yf1, yf2, yf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    mlib_d64 c0, c1, c2, c3, val0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    mlib_s32 filterpos, k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    mlib_f32 *fptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    mlib_s32 s0, s1, s2, s3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    mlib_s32 s4, s5, s6, s7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    CLIP(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    dstLineEnd = (DTYPE *) dstData + 2 * xRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    for (k = 0; k < 2; k++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
      mlib_s32 X1 = X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
      mlib_s32 Y1 = Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
      DTYPE *dPtr = dstPixelPtr + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
      filterpos = (X1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
      fptr = (mlib_f32 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
      xf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
      xf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
      xf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
      xf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
      filterpos = (Y1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
      fptr = (mlib_f32 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
      yf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
      yf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
      yf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
      yf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
      xSrc = (X1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
      ySrc = (Y1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
      srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + 2 * xSrc + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
      s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
      s1 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
      s2 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
      s3 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
      s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
      s5 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
      s6 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
      s7 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
      for (; dPtr <= (dstLineEnd - 1); dPtr += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        X1 += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        Y1 += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[2] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
              srcPixelPtr[4] * xf2 + srcPixelPtr[6] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[2] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
              srcPixelPtr[4] * xf2 + srcPixelPtr[6] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        filterpos = (X1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        fptr = (mlib_f32 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        xf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        xf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        xf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        xf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        filterpos = (Y1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        fptr = (mlib_f32 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        yf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        yf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        yf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        yf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        SAT16(dPtr[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        xSrc = (X1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        ySrc = (Y1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + 2 * xSrc + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        s1 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        s2 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        s3 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        s5 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        s6 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        s7 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
      c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
      c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
      c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[2] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            srcPixelPtr[4] * xf2 + srcPixelPtr[6] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
      c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[2] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
            srcPixelPtr[4] * xf2 + srcPixelPtr[6] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
      val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
      SAT16(dPtr[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
mlib_status FUN_NAME(3ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
  DECLAREVAR_BC();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
  DTYPE *dstLineEnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
  const mlib_f32 *mlib_filters_table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
  if (filter == MLIB_BICUBIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    mlib_filters_table = mlib_filters_s16f_bc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
  else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    mlib_filters_table = mlib_filters_s16f_bc2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    mlib_d64 xf0, xf1, xf2, xf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    mlib_d64 yf0, yf1, yf2, yf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    mlib_d64 c0, c1, c2, c3, val0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    mlib_s32 filterpos, k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    mlib_f32 *fptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    mlib_s32 s0, s1, s2, s3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    mlib_s32 s4, s5, s6, s7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    CLIP(3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    dstLineEnd = (DTYPE *) dstData + 3 * xRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    for (k = 0; k < 3; k++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
      mlib_s32 X1 = X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
      mlib_s32 Y1 = Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
      DTYPE *dPtr = dstPixelPtr + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
      filterpos = (X1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
      fptr = (mlib_f32 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
      xf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
      xf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
      xf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
      xf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
      filterpos = (Y1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
      fptr = (mlib_f32 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
      yf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
      yf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
      yf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
      yf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
      xSrc = (X1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
      ySrc = (Y1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
      srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + 3 * xSrc + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
      s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
      s1 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
      s2 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
      s3 = srcPixelPtr[9];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
      s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
      s5 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
      s6 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
      s7 = srcPixelPtr[9];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
      for (; dPtr <= (dstLineEnd - 1); dPtr += 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        X1 += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        Y1 += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[3] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
              srcPixelPtr[6] * xf2 + srcPixelPtr[9] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[3] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
              srcPixelPtr[6] * xf2 + srcPixelPtr[9] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        filterpos = (X1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        fptr = (mlib_f32 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        xf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        xf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        xf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        xf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        filterpos = (Y1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        fptr = (mlib_f32 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        yf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        yf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        yf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        yf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        SAT16(dPtr[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        xSrc = (X1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        ySrc = (Y1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + 3 * xSrc + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        s1 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        s2 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        s3 = srcPixelPtr[9];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        s5 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        s6 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        s7 = srcPixelPtr[9];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
      c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
      c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
      c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[3] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            srcPixelPtr[6] * xf2 + srcPixelPtr[9] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
      c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[3] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
            srcPixelPtr[6] * xf2 + srcPixelPtr[9] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
      val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
      SAT16(dPtr[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
mlib_status FUN_NAME(4ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
  DECLAREVAR_BC();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
  DTYPE *dstLineEnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
  const mlib_f32 *mlib_filters_table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
  if (filter == MLIB_BICUBIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    mlib_filters_table = mlib_filters_s16f_bc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
  else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    mlib_filters_table = mlib_filters_s16f_bc2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    mlib_d64 xf0, xf1, xf2, xf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    mlib_d64 yf0, yf1, yf2, yf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    mlib_d64 c0, c1, c2, c3, val0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    mlib_s32 filterpos, k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    mlib_f32 *fptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    mlib_s32 s0, s1, s2, s3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    mlib_s32 s4, s5, s6, s7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    CLIP(4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    dstLineEnd = (DTYPE *) dstData + 4 * xRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    for (k = 0; k < 4; k++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
      mlib_s32 X1 = X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
      mlib_s32 Y1 = Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
      DTYPE *dPtr = dstPixelPtr + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
      filterpos = (X1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
      fptr = (mlib_f32 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
      xf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
      xf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
      xf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
      xf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
      filterpos = (Y1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
      fptr = (mlib_f32 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
      yf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
      yf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
      yf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
      yf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
      xSrc = (X1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
      ySrc = (Y1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
      srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + 4 * xSrc + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
      s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
      s1 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
      s2 = srcPixelPtr[8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
      s3 = srcPixelPtr[12];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
      s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
      s5 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
      s6 = srcPixelPtr[8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
      s7 = srcPixelPtr[12];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
      for (; dPtr <= (dstLineEnd - 1); dPtr += 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        X1 += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        Y1 += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[4] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
              srcPixelPtr[8] * xf2 + srcPixelPtr[12] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[4] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
              srcPixelPtr[8] * xf2 + srcPixelPtr[12] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        filterpos = (X1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        fptr = (mlib_f32 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        xf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        xf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        xf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        xf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        filterpos = (Y1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        fptr = (mlib_f32 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        yf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        yf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        yf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        yf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        SAT16(dPtr[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        xSrc = (X1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        ySrc = (Y1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + 4 * xSrc + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        s1 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        s2 = srcPixelPtr[8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        s3 = srcPixelPtr[12];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        s5 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        s6 = srcPixelPtr[8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        s7 = srcPixelPtr[12];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
      c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
      c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
      c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[4] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            srcPixelPtr[8] * xf2 + srcPixelPtr[12] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
      c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[4] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            srcPixelPtr[8] * xf2 + srcPixelPtr[12] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
      val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
      SAT16(dPtr[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
#else       /* for x86, using integer multiplies is faster */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
#define SHIFT_X  15
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
#define ROUND_X  0 /* (1 << (SHIFT_X - 1)) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
#define SHIFT_Y  (15 + 15 - SHIFT_X)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
#define ROUND_Y  (1 << (SHIFT_Y - 1))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
#define S32_TO_S16_SAT(DST)                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
  if (val0 >= MLIB_S16_MAX)                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    DST = MLIB_S16_MAX;                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
  else if (val0 <= MLIB_S16_MIN)                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    DST = MLIB_S16_MIN;                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
  else                                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    DST = (mlib_s16)val0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
mlib_status FUN_NAME(1ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
  DECLAREVAR_BC();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
  DTYPE *dstLineEnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
  const mlib_s16 *mlib_filters_table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
  if (filter == MLIB_BICUBIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
    mlib_filters_table = (mlib_s16 *) mlib_filters_s16_bc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
  else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    mlib_filters_table = (mlib_s16 *) mlib_filters_s16_bc2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    mlib_s32 xf0, xf1, xf2, xf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
    mlib_s32 yf0, yf1, yf2, yf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    mlib_s32 c0, c1, c2, c3, val0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
    mlib_s32 filterpos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
    mlib_s16 *fptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    mlib_s32 s0, s1, s2, s3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    mlib_s32 s4, s5, s6, s7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    CLIP(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    dstLineEnd = (DTYPE *) dstData + xRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    filterpos = (X >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    fptr = (mlib_s16 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
    xf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    xf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    xf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    xf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    filterpos = (Y >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
    fptr = (mlib_s16 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    yf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    yf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    yf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    yf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    xSrc = (X >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    ySrc = (Y >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + xSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    s1 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    s2 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    s3 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    s5 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    s6 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    s7 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    for (; dstPixelPtr <= (dstLineEnd - 1); dstPixelPtr++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
      X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
      Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
      c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
      c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
      c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[1] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
            srcPixelPtr[2] * xf2 + srcPixelPtr[3] * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
      c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[1] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
            srcPixelPtr[2] * xf2 + srcPixelPtr[3] * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
      filterpos = (X >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
      fptr = (mlib_s16 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
      xf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
      xf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
      xf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
      xf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
      val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3 + ROUND_Y) >> SHIFT_Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
      filterpos = (Y >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
      fptr = (mlib_s16 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
      yf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
      yf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
      yf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
      yf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
      S32_TO_S16_SAT(dstPixelPtr[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
      xSrc = (X >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
      ySrc = (Y >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
      srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + xSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
      s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
      s1 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
      s2 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
      s3 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
      s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
      s5 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
      s6 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
      s7 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
    c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
    c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[1] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
          srcPixelPtr[2] * xf2 + srcPixelPtr[3] * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
    srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
    c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[1] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
          srcPixelPtr[2] * xf2 + srcPixelPtr[3] * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
    val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3 + ROUND_Y) >> SHIFT_Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    S32_TO_S16_SAT(dstPixelPtr[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
mlib_status FUN_NAME(2ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
  DECLAREVAR_BC();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
  DTYPE *dstLineEnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
  const mlib_s16 *mlib_filters_table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
  if (filter == MLIB_BICUBIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
    mlib_filters_table = (mlib_s16 *) mlib_filters_s16_bc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
  else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
    mlib_filters_table = (mlib_s16 *) mlib_filters_s16_bc2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
    mlib_s32 xf0, xf1, xf2, xf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
    mlib_s32 yf0, yf1, yf2, yf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
    mlib_s32 c0, c1, c2, c3, val0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
    mlib_s32 filterpos, k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
    mlib_s16 *fptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
    mlib_s32 s0, s1, s2, s3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
    mlib_s32 s4, s5, s6, s7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
    CLIP(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
    dstLineEnd = (DTYPE *) dstData + 2 * xRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
    for (k = 0; k < 2; k++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
      mlib_s32 X1 = X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
      mlib_s32 Y1 = Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
      DTYPE *dPtr = dstPixelPtr + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
      filterpos = (X1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
      fptr = (mlib_s16 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
      xf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
      xf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
      xf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
      xf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
      filterpos = (Y1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
      fptr = (mlib_s16 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
      yf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
      yf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
      yf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
      yf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
      xSrc = (X1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
      ySrc = (Y1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
      srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + 2 * xSrc + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
      s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
      s1 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
      s2 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
      s3 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
      s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
      s5 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
      s6 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
      s7 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
      for (; dPtr <= (dstLineEnd - 1); dPtr += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
        X1 += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
        Y1 += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
        c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
        srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
        c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[2] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
              srcPixelPtr[4] * xf2 + srcPixelPtr[6] * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
        srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
        c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[2] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
              srcPixelPtr[4] * xf2 + srcPixelPtr[6] * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
        filterpos = (X1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        fptr = (mlib_s16 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        xf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
        xf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        xf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        xf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3 + ROUND_Y) >> SHIFT_Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
        filterpos = (Y1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
        fptr = (mlib_s16 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        yf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        yf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
        yf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
        yf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        S32_TO_S16_SAT(dPtr[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        xSrc = (X1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
        ySrc = (Y1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
        srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + 2 * xSrc + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
        s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
        s1 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
        s2 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
        s3 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
        srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
        s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
        s5 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
        s6 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
        s7 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
      c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
      c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
      c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[2] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
            srcPixelPtr[4] * xf2 + srcPixelPtr[6] * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
      c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[2] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
            srcPixelPtr[4] * xf2 + srcPixelPtr[6] * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
      val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3 + ROUND_Y) >> SHIFT_Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
      S32_TO_S16_SAT(dPtr[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
mlib_status FUN_NAME(3ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
  DECLAREVAR_BC();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
  DTYPE *dstLineEnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
  const mlib_s16 *mlib_filters_table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
  if (filter == MLIB_BICUBIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
    mlib_filters_table = (mlib_s16 *) mlib_filters_s16_bc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
  else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
    mlib_filters_table = (mlib_s16 *) mlib_filters_s16_bc2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
    mlib_s32 xf0, xf1, xf2, xf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
    mlib_s32 yf0, yf1, yf2, yf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
    mlib_s32 c0, c1, c2, c3, val0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
    mlib_s32 filterpos, k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
    mlib_s16 *fptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
    mlib_s32 s0, s1, s2, s3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
    mlib_s32 s4, s5, s6, s7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
    CLIP(3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
    dstLineEnd = (DTYPE *) dstData + 3 * xRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
    for (k = 0; k < 3; k++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
      mlib_s32 X1 = X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
      mlib_s32 Y1 = Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
      DTYPE *dPtr = dstPixelPtr + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
      filterpos = (X1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
      fptr = (mlib_s16 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
      xf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
      xf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
      xf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
      xf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
      filterpos = (Y1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
      fptr = (mlib_s16 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
      yf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
      yf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
      yf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
      yf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
      xSrc = (X1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
      ySrc = (Y1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
      srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + 3 * xSrc + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
      s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
      s1 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
      s2 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
      s3 = srcPixelPtr[9];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
      s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
      s5 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
      s6 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
      s7 = srcPixelPtr[9];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
      for (; dPtr <= (dstLineEnd - 1); dPtr += 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
        X1 += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
        Y1 += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
        c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
        c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
        srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
        c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[3] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
              srcPixelPtr[6] * xf2 + srcPixelPtr[9] * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
        srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
        c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[3] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
              srcPixelPtr[6] * xf2 + srcPixelPtr[9] * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
        filterpos = (X1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
        fptr = (mlib_s16 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
        xf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
        xf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
        xf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
        xf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
        val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3 + ROUND_Y) >> SHIFT_Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
        filterpos = (Y1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
        fptr = (mlib_s16 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
        yf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
        yf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
        yf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
        yf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
        S32_TO_S16_SAT(dPtr[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
        xSrc = (X1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
        ySrc = (Y1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
        srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + 3 * xSrc + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
        s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
        s1 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
        s2 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
        s3 = srcPixelPtr[9];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
        srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
        s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
        s5 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
        s6 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
        s7 = srcPixelPtr[9];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
      c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
      c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
      c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[3] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
            srcPixelPtr[6] * xf2 + srcPixelPtr[9] * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
      c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[3] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
            srcPixelPtr[6] * xf2 + srcPixelPtr[9] * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
      val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3 + ROUND_Y) >> SHIFT_Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
      S32_TO_S16_SAT(dPtr[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
mlib_status FUN_NAME(4ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
  DECLAREVAR_BC();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
  DTYPE *dstLineEnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
  const mlib_s16 *mlib_filters_table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
  if (filter == MLIB_BICUBIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
    mlib_filters_table = (mlib_s16 *) mlib_filters_s16_bc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
  else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
    mlib_filters_table = (mlib_s16 *) mlib_filters_s16_bc2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
    mlib_s32 xf0, xf1, xf2, xf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
    mlib_s32 yf0, yf1, yf2, yf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
    mlib_s32 c0, c1, c2, c3, val0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
    mlib_s32 filterpos, k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
    mlib_s16 *fptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
    mlib_s32 s0, s1, s2, s3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
    mlib_s32 s4, s5, s6, s7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
    CLIP(4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
    dstLineEnd = (DTYPE *) dstData + 4 * xRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
    for (k = 0; k < 4; k++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
      mlib_s32 X1 = X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
      mlib_s32 Y1 = Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
      DTYPE *dPtr = dstPixelPtr + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
      filterpos = (X1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
      fptr = (mlib_s16 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
      xf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
      xf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
      xf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
      xf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
      filterpos = (Y1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
      fptr = (mlib_s16 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
      yf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
      yf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
      yf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
      yf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
      xSrc = (X1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
      ySrc = (Y1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
      srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + 4 * xSrc + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
      s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
      s1 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
      s2 = srcPixelPtr[8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
      s3 = srcPixelPtr[12];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
      s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
      s5 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
      s6 = srcPixelPtr[8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
      s7 = srcPixelPtr[12];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
      for (; dPtr <= (dstLineEnd - 1); dPtr += 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
        X1 += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
        Y1 += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
        c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
        c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
        srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
        c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[4] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
              srcPixelPtr[8] * xf2 + srcPixelPtr[12] * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
        srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
        c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[4] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
              srcPixelPtr[8] * xf2 + srcPixelPtr[12] * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
        filterpos = (X1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
        fptr = (mlib_s16 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
        xf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
        xf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
        xf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
        xf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
        val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3 + ROUND_Y) >> SHIFT_Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
        filterpos = (Y1 >> FILTER_SHIFT) & FILTER_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
        fptr = (mlib_s16 *) ((mlib_u8 *) mlib_filters_table + filterpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
        yf0 = fptr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
        yf1 = fptr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
        yf2 = fptr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
        yf3 = fptr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
        S32_TO_S16_SAT(dPtr[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
        xSrc = (X1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
        ySrc = (Y1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
        srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + 4 * xSrc + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
        s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
        s1 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
        s2 = srcPixelPtr[8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
        s3 = srcPixelPtr[12];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
        srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
        s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
        s5 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
        s6 = srcPixelPtr[8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
        s7 = srcPixelPtr[12];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
      c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
      c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
      c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[4] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
            srcPixelPtr[8] * xf2 + srcPixelPtr[12] * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
      srcPixelPtr = (DTYPE *) ((mlib_addr) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
      c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[4] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
            srcPixelPtr[8] * xf2 + srcPixelPtr[12] * xf3 + ROUND_X) >> SHIFT_X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
      val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3 + ROUND_Y) >> SHIFT_Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
      S32_TO_S16_SAT(dPtr[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
#endif /* __sparc ( for SPARC, using floating-point multiplies is faster ) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
/***************************************************************/