jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine_BL_F32.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
 *   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_f32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#define FTYPE  DTYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#define FUN_NAME(CHAN) mlib_ImageAffine_f32_##CHAN##_bl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
mlib_status FUN_NAME(1ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
  DECLAREVAR_BL();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
  DTYPE *dstLineEnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
  FTYPE scale = ONE / MLIB_PREC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
  mlib_s32 srcYStride1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
  srcYStride /= sizeof(DTYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
  srcYStride1 = srcYStride + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    FTYPE t, u, k0, k1, k2, k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    FTYPE a00_0, a01_0, a10_0, a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    FTYPE pix0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    CLIP(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    dstLineEnd = (DTYPE *) dstData + xRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    t = (X & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    u = (Y & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    ySrc = MLIB_POINTER_SHIFT(Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    xSrc = X >> MLIB_SHIFT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + xSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    k3 = t * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    k2 = (ONE - t) * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    k1 = t * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    k0 = (ONE - t) * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    a00_0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    a01_0 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    a10_0 = srcPixelPtr[srcYStride];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    a11_0 = srcPixelPtr[srcYStride1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    for (; dstPixelPtr < dstLineEnd; dstPixelPtr++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
      pix0 = k0 * a00_0 + k1 * a01_0 + k2 * a10_0 + k3 * a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
      t = (X & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
      u = (Y & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
      ySrc = MLIB_POINTER_SHIFT(Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
      Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
      xSrc = X >> MLIB_SHIFT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
      X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
      srcPixelPtr = *(DTYPE **) ((mlib_u8 *) lineAddr + ySrc) + xSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
      k3 = t * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
      k2 = (ONE - t) * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
      k1 = t * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
      k0 = (ONE - t) * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
      a00_0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
      a01_0 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
      a10_0 = srcPixelPtr[srcYStride];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
      a11_0 = srcPixelPtr[srcYStride1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
      dstPixelPtr[0] = pix0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    pix0 = k0 * a00_0 + k1 * a01_0 + k2 * a10_0 + k3 * a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    dstPixelPtr[0] = pix0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
mlib_status FUN_NAME(2ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
  DECLAREVAR_BL();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
  DTYPE *dstLineEnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
  FTYPE scale = ONE / MLIB_PREC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    DTYPE *srcPixelPtr2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    FTYPE t, u, k0, k1, k2, k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    FTYPE a00_0, a01_0, a10_0, a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    FTYPE a00_1, a01_1, a10_1, a11_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    FTYPE pix0, pix1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    CLIP(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    dstLineEnd = (DTYPE *) dstData + 2 * xRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    t = (X & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    u = (Y & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    ySrc = MLIB_POINTER_SHIFT(Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    xSrc = X >> MLIB_SHIFT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 2 * xSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    srcPixelPtr2 = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    k3 = t * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    k2 = (ONE - t) * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    k1 = t * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    k0 = (ONE - t) * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    a00_0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    a00_1 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    a01_0 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    a01_1 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    a10_0 = srcPixelPtr2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    a10_1 = srcPixelPtr2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    a11_0 = srcPixelPtr2[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    a11_1 = srcPixelPtr2[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    for (; dstPixelPtr < dstLineEnd; dstPixelPtr += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
      pix0 = k0 * a00_0 + k1 * a01_0 + k2 * a10_0 + k3 * a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
      pix1 = k0 * a00_1 + k1 * a01_1 + k2 * a10_1 + k3 * a11_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
      t = (X & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
      u = (Y & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
      ySrc = MLIB_POINTER_SHIFT(Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
      Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
      xSrc = X >> MLIB_SHIFT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
      X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
      srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 2 * xSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
      srcPixelPtr2 = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
      k3 = t * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
      k2 = (ONE - t) * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
      k1 = t * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
      k0 = (ONE - t) * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
      a01_0 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
      a01_1 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
      a00_0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
      a00_1 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
      a10_0 = srcPixelPtr2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
      a10_1 = srcPixelPtr2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
      a11_0 = srcPixelPtr2[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
      a11_1 = srcPixelPtr2[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
      dstPixelPtr[0] = pix0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
      dstPixelPtr[1] = pix1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    pix0 = k0 * a00_0 + k1 * a01_0 + k2 * a10_0 + k3 * a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    pix1 = k0 * a00_1 + k1 * a01_1 + k2 * a10_1 + k3 * a11_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    dstPixelPtr[0] = pix0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    dstPixelPtr[1] = pix1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
mlib_status FUN_NAME(3ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
  DECLAREVAR_BL();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
  DTYPE *dstLineEnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
  FTYPE scale = ONE / MLIB_PREC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    DTYPE *srcPixelPtr2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    FTYPE t, u, k0, k1, k2, k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    FTYPE a00_0, a01_0, a10_0, a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    FTYPE a00_1, a01_1, a10_1, a11_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    FTYPE a00_2, a01_2, a10_2, a11_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    FTYPE pix0, pix1, pix2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    CLIP(3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    dstLineEnd = (DTYPE *) dstData + 3 * xRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    t = (X & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    u = (Y & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    ySrc = MLIB_POINTER_SHIFT(Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    xSrc = X >> MLIB_SHIFT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 3 * xSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    srcPixelPtr2 = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    k3 = t * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    k2 = (ONE - t) * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    k1 = t * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    k0 = (ONE - t) * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    a00_0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    a00_1 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    a00_2 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    a01_0 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    a01_1 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    a01_2 = srcPixelPtr[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    a10_0 = srcPixelPtr2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    a10_1 = srcPixelPtr2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    a10_2 = srcPixelPtr2[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    a11_0 = srcPixelPtr2[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    a11_1 = srcPixelPtr2[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    a11_2 = srcPixelPtr2[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    for (; dstPixelPtr < dstLineEnd; dstPixelPtr += 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
      pix0 = k0 * a00_0 + k1 * a01_0 + k2 * a10_0 + k3 * a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
      pix1 = k0 * a00_1 + k1 * a01_1 + k2 * a10_1 + k3 * a11_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
      pix2 = k0 * a00_2 + k1 * a01_2 + k2 * a10_2 + k3 * a11_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
      t = (X & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
      u = (Y & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
      ySrc = MLIB_POINTER_SHIFT(Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
      Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
      xSrc = X >> MLIB_SHIFT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
      X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
      srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 3 * xSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
      srcPixelPtr2 = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
      k3 = t * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
      k2 = (ONE - t) * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
      k1 = t * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
      k0 = (ONE - t) * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
      a01_0 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
      a01_1 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
      a01_2 = srcPixelPtr[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
      a00_0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
      a00_1 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
      a00_2 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
      a10_0 = srcPixelPtr2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
      a10_1 = srcPixelPtr2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
      a10_2 = srcPixelPtr2[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
      a11_0 = srcPixelPtr2[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
      a11_1 = srcPixelPtr2[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
      a11_2 = srcPixelPtr2[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
      dstPixelPtr[0] = pix0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
      dstPixelPtr[1] = pix1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
      dstPixelPtr[2] = pix2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    pix0 = k0 * a00_0 + k1 * a01_0 + k2 * a10_0 + k3 * a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    pix1 = k0 * a00_1 + k1 * a01_1 + k2 * a10_1 + k3 * a11_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    pix2 = k0 * a00_2 + k1 * a01_2 + k2 * a10_2 + k3 * a11_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    dstPixelPtr[0] = pix0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    dstPixelPtr[1] = pix1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    dstPixelPtr[2] = pix2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
mlib_status FUN_NAME(4ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
  DECLAREVAR_BL();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
  DTYPE *dstLineEnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
  FTYPE scale = ONE / MLIB_PREC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    DTYPE *srcPixelPtr2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    FTYPE t, u, k0, k1, k2, k3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    FTYPE a00_0, a01_0, a10_0, a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    FTYPE a00_1, a01_1, a10_1, a11_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    FTYPE a00_2, a01_2, a10_2, a11_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    FTYPE a00_3, a01_3, a10_3, a11_3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    FTYPE pix0, pix1, pix2, pix3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    CLIP(4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    dstLineEnd = (DTYPE *) dstData + 4 * xRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    t = (X & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    u = (Y & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    ySrc = MLIB_POINTER_SHIFT(Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    xSrc = X >> MLIB_SHIFT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 4 * xSrc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    srcPixelPtr2 = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    k3 = t * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    k2 = (ONE - t) * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    k1 = t * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    k0 = (ONE - t) * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    a00_0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    a00_1 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    a00_2 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    a00_3 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    a01_0 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    a01_1 = srcPixelPtr[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    a01_2 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    a01_3 = srcPixelPtr[7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    a10_0 = srcPixelPtr2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    a10_1 = srcPixelPtr2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    a10_2 = srcPixelPtr2[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    a10_3 = srcPixelPtr2[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    a11_0 = srcPixelPtr2[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    a11_1 = srcPixelPtr2[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    a11_2 = srcPixelPtr2[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    a11_3 = srcPixelPtr2[7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    for (; dstPixelPtr < dstLineEnd; dstPixelPtr += 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
      pix0 = k0 * a00_0 + k1 * a01_0 + k2 * a10_0 + k3 * a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
      pix1 = k0 * a00_1 + k1 * a01_1 + k2 * a10_1 + k3 * a11_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
      pix2 = k0 * a00_2 + k1 * a01_2 + k2 * a10_2 + k3 * a11_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
      pix3 = k0 * a00_3 + k1 * a01_3 + k2 * a10_3 + k3 * a11_3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
      t = (X & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
      u = (Y & MLIB_MASK) * scale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
      ySrc = MLIB_POINTER_SHIFT(Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
      Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
      xSrc = X >> (MLIB_SHIFT - 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
      X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
      srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + (xSrc & ~3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
      srcPixelPtr2 = (DTYPE *) ((mlib_u8 *) srcPixelPtr + srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
      k3 = t * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
      k2 = (ONE - t) * u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
      k1 = t * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
      k0 = (ONE - t) * (ONE - u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
      a00_3 = srcPixelPtr[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
      a01_3 = srcPixelPtr[7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
      a10_3 = srcPixelPtr2[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
      a11_3 = srcPixelPtr2[7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
      a00_0 = srcPixelPtr[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
      a00_1 = srcPixelPtr[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
      a00_2 = srcPixelPtr[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
      a01_0 = srcPixelPtr[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
      a01_1 = srcPixelPtr[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
      a01_2 = srcPixelPtr[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
      a10_0 = srcPixelPtr2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
      a10_1 = srcPixelPtr2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
      a10_2 = srcPixelPtr2[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
      a11_0 = srcPixelPtr2[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
      a11_1 = srcPixelPtr2[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
      a11_2 = srcPixelPtr2[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
      dstPixelPtr[0] = pix0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
      dstPixelPtr[1] = pix1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
      dstPixelPtr[2] = pix2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
      dstPixelPtr[3] = pix3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    pix0 = k0 * a00_0 + k1 * a01_0 + k2 * a10_0 + k3 * a11_0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    pix1 = k0 * a00_1 + k1 * a01_1 + k2 * a10_1 + k3 * a11_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    pix2 = k0 * a00_2 + k1 * a01_2 + k2 * a10_2 + k3 * a11_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    pix3 = k0 * a00_3 + k1 * a01_3 + k2 * a10_3 + k3 * a11_3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    dstPixelPtr[0] = pix0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    dstPixelPtr[1] = pix1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    dstPixelPtr[2] = pix2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    dstPixelPtr[3] = pix3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
/***************************************************************/