jdk/src/share/native/sun/awt/medialib/mlib_ImageAffine_BL_S32.c
author jgodinez
Fri, 08 Feb 2013 11:25:42 -0800
changeset 15628 228422512f97
parent 5506 202f599c92aa
permissions -rw-r--r--
8005129: [parfait] #1122 - #1130 native/sun/awt/medialib/mlib_Image*.c Memory leak of pointer 'k' allocated with mlib_malloc Reviewed-by: prr, vadim Contributed-by: jia-hong.chen@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * FUNCTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *   Internal functions for mlib_ImageAffine with bilinear filtering.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "mlib_ImageAffine.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#define DTYPE  mlib_s32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#define FTYPE  mlib_d64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/* handle FTYPE to DTYPE conversion like in mlib_ImageAffine_BC_S32.c */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#define STORE(res, x)  SAT_32(res, x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#define FUN_NAME(CHAN) mlib_ImageAffine_s32_##CHAN##_bl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
mlib_status FUN_NAME(1ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
  DECLAREVAR_BL();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
  DTYPE *dstLineEnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
  FTYPE scale = ONE / MLIB_PREC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
  mlib_s32 srcYStride1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
  srcYStride /= sizeof(DTYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
  srcYStride1 = srcYStride + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    FTYPE t, u, k0, k1, k2, k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    FTYPE a00_0, a01_0, a10_0, a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    FTYPE pix0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    CLIP(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    dstLineEnd = (DTYPE *) dstData + xRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    t = (X & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    u = (Y & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    ySrc = MLIB_POINTER_SHIFT(Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    xSrc = X >> MLIB_SHIFT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + xSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    k3 = t * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    k2 = (ONE - t) * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    k1 = t * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    k0 = (ONE - t) * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    a00_0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    a01_0 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    a10_0 = srcPixelPtr[srcYStride];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    a11_0 = srcPixelPtr[srcYStride1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    for (; dstPixelPtr < dstLineEnd; dstPixelPtr++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
      pix0 = k0 * a00_0 + k1 * a01_0 + k2 * a10_0 + k3 * a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
      t = (X & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
      u = (Y & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
      ySrc = MLIB_POINTER_SHIFT(Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
      Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
      xSrc = X >> MLIB_SHIFT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
      X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
      srcPixelPtr = *(DTYPE **) ((mlib_u8 *) lineAddr + ySrc) + xSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
      k3 = t * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
      k2 = (ONE - t) * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
      k1 = t * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
      k0 = (ONE - t) * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
      a00_0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
      a01_0 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
      a10_0 = srcPixelPtr[srcYStride];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
      a11_0 = srcPixelPtr[srcYStride1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
      STORE(dstPixelPtr[0], pix0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    pix0 = k0 * a00_0 + k1 * a01_0 + k2 * a10_0 + k3 * a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    STORE(dstPixelPtr[0], pix0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
mlib_status FUN_NAME(2ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
  DECLAREVAR_BL();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
  DTYPE *dstLineEnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
  FTYPE scale = ONE / MLIB_PREC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    DTYPE *srcPixelPtr2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    FTYPE t, u, k0, k1, k2, k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    FTYPE a00_0, a01_0, a10_0, a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    FTYPE a00_1, a01_1, a10_1, a11_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    FTYPE pix0, pix1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    CLIP(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    dstLineEnd = (DTYPE *) dstData + 2 * xRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    t = (X & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    u = (Y & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    ySrc = MLIB_POINTER_SHIFT(Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    xSrc = X >> MLIB_SHIFT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 2 * xSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    srcPixelPtr2 = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    k3 = t * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    k2 = (ONE - t) * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    k1 = t * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    k0 = (ONE - t) * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    a00_0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    a00_1 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    a01_0 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    a01_1 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    a10_0 = srcPixelPtr2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    a10_1 = srcPixelPtr2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    a11_0 = srcPixelPtr2[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    a11_1 = srcPixelPtr2[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    for (; dstPixelPtr < dstLineEnd; dstPixelPtr += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
      pix0 = k0 * a00_0 + k1 * a01_0 + k2 * a10_0 + k3 * a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
      pix1 = k0 * a00_1 + k1 * a01_1 + k2 * a10_1 + k3 * a11_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
      t = (X & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
      u = (Y & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
      ySrc = MLIB_POINTER_SHIFT(Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
      Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
      xSrc = X >> MLIB_SHIFT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
      X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
      srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 2 * xSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
      srcPixelPtr2 = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
      k3 = t * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
      k2 = (ONE - t) * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
      k1 = t * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
      k0 = (ONE - t) * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
      a01_0 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
      a01_1 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
      a00_0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
      a00_1 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
      a10_0 = srcPixelPtr2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
      a10_1 = srcPixelPtr2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
      a11_0 = srcPixelPtr2[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
      a11_1 = srcPixelPtr2[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
      STORE(dstPixelPtr[0], pix0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
      STORE(dstPixelPtr[1], pix1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    pix0 = k0 * a00_0 + k1 * a01_0 + k2 * a10_0 + k3 * a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    pix1 = k0 * a00_1 + k1 * a01_1 + k2 * a10_1 + k3 * a11_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    STORE(dstPixelPtr[0], pix0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    STORE(dstPixelPtr[1], pix1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
mlib_status FUN_NAME(3ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
  DECLAREVAR_BL();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
  DTYPE *dstLineEnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
  FTYPE scale = ONE / MLIB_PREC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    DTYPE *srcPixelPtr2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    FTYPE t, u, k0, k1, k2, k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    FTYPE a00_0, a01_0, a10_0, a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    FTYPE a00_1, a01_1, a10_1, a11_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    FTYPE a00_2, a01_2, a10_2, a11_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    FTYPE pix0, pix1, pix2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    CLIP(3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    dstLineEnd = (DTYPE *) dstData + 3 * xRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    t = (X & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    u = (Y & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    ySrc = MLIB_POINTER_SHIFT(Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    xSrc = X >> MLIB_SHIFT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 3 * xSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    srcPixelPtr2 = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    k3 = t * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    k2 = (ONE - t) * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    k1 = t * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    k0 = (ONE - t) * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    a00_0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    a00_1 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    a00_2 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    a01_0 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    a01_1 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    a01_2 = srcPixelPtr[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    a10_0 = srcPixelPtr2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    a10_1 = srcPixelPtr2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    a10_2 = srcPixelPtr2[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    a11_0 = srcPixelPtr2[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    a11_1 = srcPixelPtr2[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    a11_2 = srcPixelPtr2[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    for (; dstPixelPtr < dstLineEnd; dstPixelPtr += 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
      pix0 = k0 * a00_0 + k1 * a01_0 + k2 * a10_0 + k3 * a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
      pix1 = k0 * a00_1 + k1 * a01_1 + k2 * a10_1 + k3 * a11_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
      pix2 = k0 * a00_2 + k1 * a01_2 + k2 * a10_2 + k3 * a11_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
      t = (X & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
      u = (Y & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
      ySrc = MLIB_POINTER_SHIFT(Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
      Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
      xSrc = X >> MLIB_SHIFT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
      X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
      srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 3 * xSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
      srcPixelPtr2 = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
      k3 = t * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
      k2 = (ONE - t) * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
      k1 = t * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
      k0 = (ONE - t) * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
      a01_0 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
      a01_1 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
      a01_2 = srcPixelPtr[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
      a00_0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
      a00_1 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
      a00_2 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
      a10_0 = srcPixelPtr2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
      a10_1 = srcPixelPtr2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
      a10_2 = srcPixelPtr2[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
      a11_0 = srcPixelPtr2[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
      a11_1 = srcPixelPtr2[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
      a11_2 = srcPixelPtr2[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
      STORE(dstPixelPtr[0], pix0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
      STORE(dstPixelPtr[1], pix1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
      STORE(dstPixelPtr[2], pix2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    pix0 = k0 * a00_0 + k1 * a01_0 + k2 * a10_0 + k3 * a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    pix1 = k0 * a00_1 + k1 * a01_1 + k2 * a10_1 + k3 * a11_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    pix2 = k0 * a00_2 + k1 * a01_2 + k2 * a10_2 + k3 * a11_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    STORE(dstPixelPtr[0], pix0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    STORE(dstPixelPtr[1], pix1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    STORE(dstPixelPtr[2], pix2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
mlib_status FUN_NAME(4ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
  DECLAREVAR_BL();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
  DTYPE *dstLineEnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
  FTYPE scale = ONE / MLIB_PREC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    DTYPE *srcPixelPtr2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    FTYPE t, u, k0, k1, k2, k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    FTYPE a00_0, a01_0, a10_0, a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    FTYPE a00_1, a01_1, a10_1, a11_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    FTYPE a00_2, a01_2, a10_2, a11_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    FTYPE a00_3, a01_3, a10_3, a11_3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    FTYPE pix0, pix1, pix2, pix3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    CLIP(4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    dstLineEnd = (DTYPE *) dstData + 4 * xRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    t = (X & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    u = (Y & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    ySrc = MLIB_POINTER_SHIFT(Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    xSrc = X >> MLIB_SHIFT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 4 * xSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    srcPixelPtr2 = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    k3 = t * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    k2 = (ONE - t) * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    k1 = t * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    k0 = (ONE - t) * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    a00_0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    a00_1 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    a00_2 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    a00_3 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    a01_0 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    a01_1 = srcPixelPtr[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    a01_2 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    a01_3 = srcPixelPtr[7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    a10_0 = srcPixelPtr2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    a10_1 = srcPixelPtr2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    a10_2 = srcPixelPtr2[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    a10_3 = srcPixelPtr2[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    a11_0 = srcPixelPtr2[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    a11_1 = srcPixelPtr2[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    a11_2 = srcPixelPtr2[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    a11_3 = srcPixelPtr2[7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    for (; dstPixelPtr < dstLineEnd; dstPixelPtr += 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
      pix0 = k0 * a00_0 + k1 * a01_0 + k2 * a10_0 + k3 * a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
      pix1 = k0 * a00_1 + k1 * a01_1 + k2 * a10_1 + k3 * a11_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
      pix2 = k0 * a00_2 + k1 * a01_2 + k2 * a10_2 + k3 * a11_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
      pix3 = k0 * a00_3 + k1 * a01_3 + k2 * a10_3 + k3 * a11_3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
      t = (X & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
      u = (Y & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
      ySrc = MLIB_POINTER_SHIFT(Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
      Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
      xSrc = X >> (MLIB_SHIFT - 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
      X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
      srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + (xSrc & ~3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
      srcPixelPtr2 = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
      k3 = t * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
      k2 = (ONE - t) * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
      k1 = t * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
      k0 = (ONE - t) * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
      a00_3 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
      a01_3 = srcPixelPtr[7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
      a10_3 = srcPixelPtr2[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
      a11_3 = srcPixelPtr2[7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
      a00_0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
      a00_1 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
      a00_2 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
      a01_0 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
      a01_1 = srcPixelPtr[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
      a01_2 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
      a10_0 = srcPixelPtr2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
      a10_1 = srcPixelPtr2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
      a10_2 = srcPixelPtr2[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
      a11_0 = srcPixelPtr2[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
      a11_1 = srcPixelPtr2[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
      a11_2 = srcPixelPtr2[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
      STORE(dstPixelPtr[0], pix0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
      STORE(dstPixelPtr[1], pix1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
      STORE(dstPixelPtr[2], pix2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
      STORE(dstPixelPtr[3], pix3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    pix0 = k0 * a00_0 + k1 * a01_0 + k2 * a10_0 + k3 * a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    pix1 = k0 * a00_1 + k1 * a01_1 + k2 * a10_1 + k3 * a11_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    pix2 = k0 * a00_2 + k1 * a01_2 + k2 * a10_2 + k3 * a11_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    pix3 = k0 * a00_3 + k1 * a01_3 + k2 * a10_3 + k3 * a11_3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    STORE(dstPixelPtr[0], pix0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    STORE(dstPixelPtr[1], pix1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    STORE(dstPixelPtr[2], pix2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    STORE(dstPixelPtr[3], pix3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
/***************************************************************/