jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine_BC_S32.c
author vadim
Fri, 13 May 2016 11:31:05 +0300
changeset 38415 acea5f7d354b
parent 25859 3317bb8137f4
permissions -rw-r--r--
8047931: Remove unused medialib code Reviewed-by: bae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
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_[s32|f32|d64]_?ch_bc
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *                                  (mlib_s32 *leftEdges,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *                                   mlib_s32 *rightEdges,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *                                   mlib_s32 *xStarts,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *                                   mlib_s32 *yStarts,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *                                   mlib_s32 *sides,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *                                   mlib_u8  *dstData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *                                   mlib_u8  **lineAddr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *                                   mlib_s32 dstYStride,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *                                   mlib_s32 is_affine,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *                                   mlib_s32 srcYStride,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *                                   mlib_filter filter)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * ARGUMENTS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *      leftEdges  array[dstHeight] of xLeft coordinates
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *      RightEdges array[dstHeight] of xRight coordinates
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *      xStarts    array[dstHeight] of xStart * 65536 coordinates
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *      yStarts    array[dstHeight] of yStart * 65536 coordinates
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *      sides      output array[4]. sides[0] is yStart, sides[1] is yFinish,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *                 sides[2] is dx * 65536, sides[3] is dy * 65536
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *      dstData    pointer to the first pixel on (yStart - 1) line
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *      lineAddr   array[srcHeight] of pointers to the first pixel on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *                 the corresponding lines
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *      dstYStride stride of destination image
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *      is_affine  indicator (Affine - GridWarp)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *      srcYStride stride of source image
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *      filter     type of resampling filter
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * DESCRIPTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 *      The functions step along the lines from xLeft to xRight and apply
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *      the Bicubic and Bicubic2 filtering.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
#include "mlib_ImageAffine.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
#define IMG_TYPE  3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
#if IMG_TYPE == 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
#define DTYPE  mlib_s32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
#define FTYPE  mlib_d64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
#define FUN_NAME(CHAN) mlib_ImageAffine_s32_##CHAN##_bc
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
#define STORE(res, x) SAT32(res)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
#elif IMG_TYPE == 4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
#define DTYPE  mlib_f32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
#define FTYPE  DTYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
#define FUN_NAME(CHAN) mlib_ImageAffine_f32_##CHAN##_bc
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
#define STORE(res, x) res = (x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
#elif IMG_TYPE == 5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
#define DTYPE  mlib_d64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
#define FTYPE  DTYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
#define FUN_NAME(CHAN) mlib_ImageAffine_d64_##CHAN##_bc
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
#define STORE(res, x) res = (x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
#define CREATE_COEF_BICUBIC( X, Y, OPERATOR )                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
  dx = (X & MLIB_MASK) * scale;                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
  dy = (Y & MLIB_MASK) * scale;                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
  dx_2  = ((FTYPE)0.5)  * dx;                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
  dy_2  = ((FTYPE)0.5)  * dy;                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
  dx2   = dx   * dx;    dy2   = dy   * dy;                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
  dx3_2 = dx_2 * dx2;   dy3_2 = dy_2 * dy2;                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
  dx3_3 = ((FTYPE)3.0)  * dx3_2;                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
  dy3_3 = ((FTYPE)3.0)  * dy3_2;                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
  xf0 = dx2 - dx3_2 - dx_2;                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
  xf1 = dx3_3 - ((FTYPE)2.5) * dx2 + ((FTYPE)1.0);              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
  xf2 = ((FTYPE)2.0) * dx2 - dx3_3 + dx_2;                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
  xf3 = dx3_2 - ((FTYPE)0.5) * dx2;                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
  OPERATOR;                                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
  yf0 = dy2 - dy3_2 - dy_2;                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
  yf1 = dy3_3 - ((FTYPE)2.5) * dy2 + ((FTYPE)1.0);              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
  yf2 = ((FTYPE)2.0) * dy2 - dy3_3 + dy_2;                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
  yf3 = dy3_2 - ((FTYPE)0.5) * dy2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
#define CREATE_COEF_BICUBIC_2( X, Y, OPERATOR )                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
  dx = (X & MLIB_MASK) * scale;                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
  dy = (Y & MLIB_MASK) * scale;                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
  dx2   = dx  * dx;    dy2   = dy  * dy;                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
  dx3_2 = dx  * dx2;   dy3_2 = dy  * dy2;                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
  dx3_3 = ((FTYPE)2.0) * dx2;                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
  dy3_3 = ((FTYPE)2.0) * dy2;                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
  xf0 = dx3_3 - dx3_2 - dx;                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
  xf1 = dx3_2 - dx3_3 + ((FTYPE)1.0);                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
  xf2 = dx2   - dx3_2   + dx;                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
  xf3 = dx3_2 - dx2;                                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
  OPERATOR;                                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
  yf0 = dy3_3 - dy3_2 - dy;                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
  yf1 = dy3_2 - dy3_3 + ((FTYPE)1.0);                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
  yf2 = dy2   - dy3_2   + dy;                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
  yf3 = dy3_2 - dy2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
mlib_status FUN_NAME(1ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
  DECLAREVAR_BC();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
  DTYPE *dstLineEnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    FTYPE xf0, xf1, xf2, xf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    FTYPE yf0, yf1, yf2, yf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    FTYPE dx, dx_2, dx2, dx3_2, dx3_3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    FTYPE dy, dy_2, dy2, dy3_2, dy3_3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    FTYPE c0, c1, c2, c3, val0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    FTYPE scale = 1 / 65536.f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    FTYPE s0, s1, s2, s3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    FTYPE s4, s5, s6, s7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    CLIP(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    dstLineEnd = (DTYPE *) dstData + xRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    if (filter == MLIB_BICUBIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
      CREATE_COEF_BICUBIC(X, Y,;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
      CREATE_COEF_BICUBIC_2(X, Y,;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    xSrc = (X >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    ySrc = (Y >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + xSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    s1 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    s2 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    s3 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    s5 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    s6 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    s7 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    if (filter == MLIB_BICUBIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
      for (; dstPixelPtr <= (dstLineEnd - 1); dstPixelPtr++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[1] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
              srcPixelPtr[2] * xf2 + srcPixelPtr[3] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[1] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
              srcPixelPtr[2] * xf2 + srcPixelPtr[3] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        CREATE_COEF_BICUBIC(X, Y, val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        STORE(dstPixelPtr[0], val0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        xSrc = (X >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        ySrc = (Y >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + xSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        s1 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        s2 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        s3 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        s5 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        s6 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        s7 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
      for (; dstPixelPtr <= (dstLineEnd - 1); dstPixelPtr++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[1] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
              srcPixelPtr[2] * xf2 + srcPixelPtr[3] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[1] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
              srcPixelPtr[2] * xf2 + srcPixelPtr[3] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        CREATE_COEF_BICUBIC_2(X, Y, val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        STORE(dstPixelPtr[0], val0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        xSrc = (X >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        ySrc = (Y >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + xSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        s1 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        s2 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        s3 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        s5 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        s6 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        s7 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[1] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
          srcPixelPtr[2] * xf2 + srcPixelPtr[3] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[1] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
          srcPixelPtr[2] * xf2 + srcPixelPtr[3] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    STORE(dstPixelPtr[0], val0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
mlib_status FUN_NAME(2ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
  DECLAREVAR_BC();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
  DTYPE *dstLineEnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    FTYPE xf0, xf1, xf2, xf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    FTYPE yf0, yf1, yf2, yf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    FTYPE dx, dx_2, dx2, dx3_2, dx3_3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    FTYPE dy, dy_2, dy2, dy3_2, dy3_3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    FTYPE c0, c1, c2, c3, val0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    FTYPE scale = 1 / 65536.f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    FTYPE s0, s1, s2, s3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    FTYPE s4, s5, s6, s7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    mlib_s32 k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    CLIP(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    dstLineEnd = (DTYPE *) dstData + 2 * xRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    for (k = 0; k < 2; k++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
      mlib_s32 X1 = X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
      mlib_s32 Y1 = Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
      DTYPE *dPtr = dstPixelPtr + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
      if (filter == MLIB_BICUBIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        CREATE_COEF_BICUBIC(X1, Y1,;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
          );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
      else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        CREATE_COEF_BICUBIC_2(X1, Y1,;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
          );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
      xSrc = (X1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
      ySrc = (Y1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
      srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + 2 * xSrc + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
      s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
      s1 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
      s2 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
      s3 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
      srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
      s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
      s5 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
      s6 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
      s7 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
      if (filter == MLIB_BICUBIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        for (; dPtr <= (dstLineEnd - 1); dPtr += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
          X1 += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
          Y1 += dY;
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_u8 *) 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_u8 *) 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
          CREATE_COEF_BICUBIC(X1, Y1, val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
          STORE(dPtr[0], val0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
          xSrc = (X1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
          ySrc = (Y1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
          srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + 2 * xSrc + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
          s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
          s1 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
          s2 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
          s3 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
          srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
          s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
          s5 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
          s6 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
          s7 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
      else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        for (; dPtr <= (dstLineEnd - 1); dPtr += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
          X1 += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
          Y1 += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
          c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
          c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
          srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
          c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[2] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                srcPixelPtr[4] * xf2 + srcPixelPtr[6] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
          srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
          c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[2] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                srcPixelPtr[4] * xf2 + srcPixelPtr[6] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
          CREATE_COEF_BICUBIC_2(X1, Y1, val0 =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                                (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
          STORE(dPtr[0], val0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
          xSrc = (X1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
          ySrc = (Y1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
          srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + 2 * xSrc + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
          s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
          s1 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
          s2 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
          s3 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
          srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
          s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
          s5 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
          s6 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
          s7 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
      c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
      c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
      srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
      c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[2] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
            srcPixelPtr[4] * xf2 + srcPixelPtr[6] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
      srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
      c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[2] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            srcPixelPtr[4] * xf2 + srcPixelPtr[6] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
      val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
      STORE(dPtr[0], val0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
mlib_status FUN_NAME(3ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
  DECLAREVAR_BC();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
  DTYPE *dstLineEnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    FTYPE xf0, xf1, xf2, xf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    FTYPE yf0, yf1, yf2, yf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    FTYPE dx, dx_2, dx2, dx3_2, dx3_3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    FTYPE dy, dy_2, dy2, dy3_2, dy3_3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    FTYPE c0, c1, c2, c3, val0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    FTYPE scale = 1 / 65536.f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    FTYPE s0, s1, s2, s3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    FTYPE s4, s5, s6, s7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    mlib_s32 k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    CLIP(3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    dstLineEnd = (DTYPE *) dstData + 3 * xRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    for (k = 0; k < 3; k++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
      mlib_s32 X1 = X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
      mlib_s32 Y1 = Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
      DTYPE *dPtr = dstPixelPtr + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
      if (filter == MLIB_BICUBIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        CREATE_COEF_BICUBIC(X1, Y1,;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
          );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
      else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        CREATE_COEF_BICUBIC_2(X1, Y1,;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
          );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
      xSrc = (X1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
      ySrc = (Y1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
      srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + 3 * xSrc + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
      s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
      s1 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
      s2 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
      s3 = srcPixelPtr[9];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
      srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
      s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
      s5 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
      s6 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
      s7 = srcPixelPtr[9];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
      if (filter == MLIB_BICUBIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        for (; dPtr <= (dstLineEnd - 1); dPtr += 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
          X1 += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
          Y1 += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
          c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
          c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
          srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
          c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[3] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                srcPixelPtr[6] * xf2 + srcPixelPtr[9] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
          srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
          c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[3] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                srcPixelPtr[6] * xf2 + srcPixelPtr[9] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
          CREATE_COEF_BICUBIC(X1, Y1, val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
          STORE(dPtr[0], val0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
          xSrc = (X1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
          ySrc = (Y1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
          srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + 3 * xSrc + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
          s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
          s1 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
          s2 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
          s3 = srcPixelPtr[9];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
          srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
          s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
          s5 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
          s6 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
          s7 = srcPixelPtr[9];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
      else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        for (; dPtr <= (dstLineEnd - 1); dPtr += 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
          X1 += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
          Y1 += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
          c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
          c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
          srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
          c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[3] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
                srcPixelPtr[6] * xf2 + srcPixelPtr[9] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
          srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
          c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[3] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
                srcPixelPtr[6] * xf2 + srcPixelPtr[9] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
          CREATE_COEF_BICUBIC_2(X1, Y1, val0 =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
                                (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
          STORE(dPtr[0], val0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
          xSrc = (X1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
          ySrc = (Y1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
          srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + 3 * xSrc + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
          s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
          s1 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
          s2 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
          s3 = srcPixelPtr[9];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
          srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
          s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
          s5 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
          s6 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
          s7 = srcPixelPtr[9];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
      c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
      c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
      srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
      c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[3] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
            srcPixelPtr[6] * xf2 + srcPixelPtr[9] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
      srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
      c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[3] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
            srcPixelPtr[6] * xf2 + srcPixelPtr[9] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
      val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
      STORE(dPtr[0], val0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
mlib_status FUN_NAME(4ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
  DECLAREVAR_BC();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
  DTYPE *dstLineEnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    FTYPE xf0, xf1, xf2, xf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    FTYPE yf0, yf1, yf2, yf3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    FTYPE dx, dx_2, dx2, dx3_2, dx3_3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
    FTYPE dy, dy_2, dy2, dy3_2, dy3_3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    FTYPE c0, c1, c2, c3, val0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    FTYPE scale = 1 / 65536.f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    FTYPE s0, s1, s2, s3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    FTYPE s4, s5, s6, s7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    mlib_s32 k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    CLIP(4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
    dstLineEnd = (DTYPE *) dstData + 4 * xRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    for (k = 0; k < 4; k++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
      mlib_s32 X1 = X;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
      mlib_s32 Y1 = Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
      DTYPE *dPtr = dstPixelPtr + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
      if (filter == MLIB_BICUBIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        CREATE_COEF_BICUBIC(X1, Y1,;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
          );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
      else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        CREATE_COEF_BICUBIC_2(X1, Y1,;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
          );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
      xSrc = (X1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
      ySrc = (Y1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
      srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + 4 * xSrc + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
      s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
      s1 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
      s2 = srcPixelPtr[8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
      s3 = srcPixelPtr[12];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
      srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
      s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
      s5 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
      s6 = srcPixelPtr[8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
      s7 = srcPixelPtr[12];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
      if (filter == MLIB_BICUBIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        for (; dPtr <= (dstLineEnd - 1); dPtr += 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
          X1 += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
          Y1 += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
          c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
          c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
          srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
          c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[4] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                srcPixelPtr[8] * xf2 + srcPixelPtr[12] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
          srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
          c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[4] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                srcPixelPtr[8] * xf2 + srcPixelPtr[12] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
          CREATE_COEF_BICUBIC(X1, Y1, val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
          STORE(dPtr[0], val0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
          xSrc = (X1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
          ySrc = (Y1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
          srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + 4 * xSrc + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
          s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
          s1 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
          s2 = srcPixelPtr[8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
          s3 = srcPixelPtr[12];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
          srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
          s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
          s5 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
          s6 = srcPixelPtr[8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
          s7 = srcPixelPtr[12];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
      else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        for (; dPtr <= (dstLineEnd - 1); dPtr += 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
          X1 += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
          Y1 += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
          c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
          c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
          srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
          c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[4] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
                srcPixelPtr[8] * xf2 + srcPixelPtr[12] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
          srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
          c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[4] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
                srcPixelPtr[8] * xf2 + srcPixelPtr[12] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
          CREATE_COEF_BICUBIC_2(X1, Y1, val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
          STORE(dPtr[0], val0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
          xSrc = (X1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
          ySrc = (Y1 >> MLIB_SHIFT) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
          srcPixelPtr = ((DTYPE **) lineAddr)[ySrc] + 4 * xSrc + k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
          s0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
          s1 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
          s2 = srcPixelPtr[8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
          s3 = srcPixelPtr[12];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
          srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
          s4 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
          s5 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
          s6 = srcPixelPtr[8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
          s7 = srcPixelPtr[12];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
      c0 = (s0 * xf0 + s1 * xf1 + s2 * xf2 + s3 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
      c1 = (s4 * xf0 + s5 * xf1 + s6 * xf2 + s7 * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
      srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
      c2 = (srcPixelPtr[0] * xf0 + srcPixelPtr[4] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
            srcPixelPtr[8] * xf2 + srcPixelPtr[12] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
      srcPixelPtr = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
      c3 = (srcPixelPtr[0] * xf0 + srcPixelPtr[4] * xf1 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
            srcPixelPtr[8] * xf2 + srcPixelPtr[12] * xf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
      val0 = (c0 * yf0 + c1 * yf1 + c2 * yf2 + c3 * yf3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
      STORE(dPtr[0], val0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
/***************************************************************/