jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_S16.c
author chegar
Sun, 17 Aug 2014 15:54:13 +0100
changeset 25859 3317bb8137f4
parent 5506 jdk/src/solaris/native/sun/awt/medialib/mlib_v_ImageAffine_BL_S16.c@202f599c92aa
child 38415 acea5f7d354b
permissions -rw-r--r--
8054834: Modular Source Code Reviewed-by: alanb, chegar, ihse, mduigou Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, magnus.ihse.bursie@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, paul.sandoz@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
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *      The functions step along the lines from xLeft to xRight and apply
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *      the bilinear filtering.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "vis_proto.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "mlib_image.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include "mlib_ImageColormap.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#include "mlib_ImageCopy.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include "mlib_ImageAffine.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#include "mlib_v_ImageFilters.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#include "mlib_v_ImageChannelExtract.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
/*#define MLIB_VIS2*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
#define DTYPE mlib_s16
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#define FUN_NAME(CHAN) mlib_ImageAffine_s16_##CHAN##_bl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
static mlib_status FUN_NAME(2ch_na)(mlib_affine_param *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
static mlib_status FUN_NAME(4ch_na)(mlib_affine_param *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
const mlib_u64 mlib_dmask_arr[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
  0x0000000000000000, 0x000000000000FFFF, 0x00000000FFFF0000, 0x00000000FFFFFFFF,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
  0x0000FFFF00000000, 0x0000FFFF0000FFFF, 0x0000FFFFFFFF0000, 0x0000FFFFFFFFFFFF,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
  0xFFFF000000000000, 0xFFFF00000000FFFF, 0xFFFF0000FFFF0000, 0xFFFF0000FFFFFFFF,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
  0xFFFFFFFF00000000, 0xFFFFFFFF0000FFFF, 0xFFFFFFFFFFFF0000, 0xFFFFFFFFFFFFFFFF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
#define XOR_8000(x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
#ifdef MLIB_VIS2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
#define MLIB_WRITE_BMASK(bmask) vis_write_bmask(bmask, 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
#define MLIB_WRITE_BMASK(bmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
#undef  DECLAREVAR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
#define DECLAREVAR()                                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
  DECLAREVAR0();                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
  mlib_s32  *warp_tbl   = param -> warp_tbl;                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
  mlib_s32  srcYStride = param -> srcYStride;                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
  mlib_u8   *dl;                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
  mlib_s32  i, size;                                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
  /*mlib_d64  mask_8000 = vis_to_double_dup(0x80008000);*/      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
  mlib_d64  mask_7fff = vis_to_double_dup(0x7FFF7FFF);          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
  mlib_d64  dx64, dy64, deltax, deltay, delta1_x, delta1_y;     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
  mlib_d64  s0, s1, s2, s3;                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
  mlib_d64  d0, d1, d2, d3, dd
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
/* arguments (x, y) are swapped to prevent overflow */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
#define FMUL_16x16(x, y)                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
  vis_fpadd16(vis_fmul8sux16(y, x),             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
              vis_fmul8ulx16(y, x))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
#define BUF_SIZE  512
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
#define DOUBLE_4U16(x0, x1, x2, x3)                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
  vis_to_double(((((x0) & 0xFFFE) << 15) | (((x1) & 0xFFFE) >> 1)), \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                ((((x2) & 0xFFFE) << 15) | (((x3) & 0xFFFE) >> 1)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
#define BL_SUM()                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
  XOR_8000(s0);                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
  XOR_8000(s1);                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
  XOR_8000(s2);                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
  XOR_8000(s3);                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
  delta1_x = vis_fpsub16(mask_7fff, deltax);                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
  delta1_y = vis_fpsub16(mask_7fff, deltay);                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
  d0 = FMUL_16x16(s0, delta1_x);                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
  d1 = FMUL_16x16(s1, deltax);                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
  d0 = vis_fpadd16(d0, d1);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
  d0 = vis_fpadd16(d0, d0);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
  d0 = FMUL_16x16(d0, delta1_y);                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
  d2 = FMUL_16x16(s2, delta1_x);                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
  d3 = FMUL_16x16(s3, deltax);                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
  d2 = vis_fpadd16(d2, d3);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
  d2 = vis_fpadd16(d2, d2);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
  d2 = FMUL_16x16(d2, deltay);                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
  dd = vis_fpadd16(d0, d2);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
  dd = vis_fpadd16(dd, dd);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
  XOR_8000(dd);                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
  deltax = vis_fpadd16(deltax, dx64);                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
  deltay = vis_fpadd16(deltay, dy64);                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
  deltax = vis_fand(deltax, mask_7fff);                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
  deltay = vis_fand(deltay, mask_7fff)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
#define BL_SUM_3CH()                                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
  XOR_8000(s0);                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
  XOR_8000(s1);                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
  XOR_8000(s2);                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
  XOR_8000(s3);                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
  delta1_x = vis_fpsub16(mask_7fff, deltax);                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
  delta1_y = vis_fpsub16(mask_7fff, deltay);                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
  d0 = FMUL_16x16(s0, delta1_y);                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
  d2 = FMUL_16x16(s2, deltay);                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
  d0 = vis_fpadd16(d0, d2);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
  d0 = vis_fpadd16(d0, d0);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
  d0 = FMUL_16x16(d0, delta1_x);                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
  d1 = FMUL_16x16(s1, delta1_y);                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
  d3 = FMUL_16x16(s3, deltay);                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
  d1 = vis_fpadd16(d1, d3);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
  d1 = vis_fpadd16(d1, d1);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
  d1 = FMUL_16x16(d1, deltax);                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
  vis_alignaddr((void*)0, 2);                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
  d0 = vis_faligndata(d0, d0);                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
  dd = vis_fpadd16(d0, d1);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
  dd = vis_fpadd16(dd, dd);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
  XOR_8000(dd);                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
  deltax = vis_fpadd16(deltax, dx64);                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
  deltay = vis_fpadd16(deltay, dy64);                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
  deltax = vis_fand(deltax, mask_7fff);                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
  deltay = vis_fand(deltay, mask_7fff)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
#define LD_U16(sp, ind) vis_ld_u16(sp + ind)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
#ifndef MLIB_VIS2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
#define LOAD_1CH()                                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
  s0 = vis_faligndata(LD_U16(sp3, 0), mask_7fff);               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
  s1 = vis_faligndata(LD_U16(sp3, 2), mask_7fff);               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
  s2 = vis_faligndata(LD_U16(sp3, srcYStride), mask_7fff);      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
  s3 = vis_faligndata(LD_U16(sp3, srcYStride + 2), mask_7fff);  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
  s0 = vis_faligndata(LD_U16(sp2, 0), s0);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
  s1 = vis_faligndata(LD_U16(sp2, 2), s1);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
  s2 = vis_faligndata(LD_U16(sp2, srcYStride), s2);             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
  s3 = vis_faligndata(LD_U16(sp2, srcYStride + 2), s3);         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
  s0 = vis_faligndata(LD_U16(sp1, 0), s0);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
  s1 = vis_faligndata(LD_U16(sp1, 2), s1);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
  s2 = vis_faligndata(LD_U16(sp1, srcYStride), s2);             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
  s3 = vis_faligndata(LD_U16(sp1, srcYStride + 2), s3);         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
  s0 = vis_faligndata(LD_U16(sp0, 0), s0);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
  s1 = vis_faligndata(LD_U16(sp0, 2), s1);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
  s2 = vis_faligndata(LD_U16(sp0, srcYStride), s2);             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
  s3 = vis_faligndata(LD_U16(sp0, srcYStride + 2), s3)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
#define LOAD_1CH()                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
  s0 = vis_bshuffle(LD_U16(sp0, 0), LD_U16(sp2, 0));                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
  s1 = vis_bshuffle(LD_U16(sp0, 2), LD_U16(sp2, 2));                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
  s2 = vis_bshuffle(LD_U16(sp0, srcYStride), LD_U16(sp2, srcYStride));         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
  s3 = vis_bshuffle(LD_U16(sp0, srcYStride + 2), LD_U16(sp2, srcYStride + 2)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
  t0 = vis_bshuffle(LD_U16(sp1, 0), LD_U16(sp3, 0));                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
  t1 = vis_bshuffle(LD_U16(sp1, 2), LD_U16(sp3, 2));                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
  t2 = vis_bshuffle(LD_U16(sp1, srcYStride), LD_U16(sp3, srcYStride));         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
  t3 = vis_bshuffle(LD_U16(sp1, srcYStride + 2), LD_U16(sp3, srcYStride + 2)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
  s0 = vis_bshuffle(s0, t0);                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
  s1 = vis_bshuffle(s1, t1);                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
  s2 = vis_bshuffle(s2, t2);                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
  s3 = vis_bshuffle(s3, t3)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
#define GET_POINTER(sp)                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
  sp = *(mlib_u8**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + 2*(X >> MLIB_SHIFT); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
  X += dX;                                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
  Y += dY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
#undef  PREPARE_DELTAS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
#define PREPARE_DELTAS                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
  if (warp_tbl != NULL) {                                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    dX = warp_tbl[2*j    ];                                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    dY = warp_tbl[2*j + 1];                                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    dx64 = vis_to_double_dup((((dX << 1) & 0xFFFF) << 16) | ((dX << 1) & 0xFFFF)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    dy64 = vis_to_double_dup((((dY << 1) & 0xFFFF) << 16) | ((dY << 1) & 0xFFFF)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
mlib_status FUN_NAME(1ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
  DECLAREVAR();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
  mlib_s32 off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
  mlib_s32 x0, x1, x2, x3, y0, y1, y2, y3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
#ifdef MLIB_VIS2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
  mlib_d64 t0, t1, t2, t3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
  vis_write_bmask(0x45CD67EF, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
  vis_alignaddr((void*)0, 6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
  dx64 = vis_to_double_dup((((dX << 1) & 0xFFFF) << 16) | ((dX << 1) & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
  dy64 = vis_to_double_dup((((dY << 1) & 0xFFFF) << 16) | ((dY << 1) & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    mlib_u8  *sp0, *sp1, *sp2, *sp3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    mlib_d64 *dp, dmask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    NEW_LINE(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    off = (mlib_s32)dl & 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    dp = (mlib_d64*)(dl - off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    off >>= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    x0 = X - off*dX; y0 = Y - off*dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    x1 = x0 + dX;    y1 = y0 + dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    x2 = x1 + dX;    y2 = y1 + dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    x3 = x2 + dX;    y3 = y2 + dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    deltax = DOUBLE_4U16(x0, x1, x2, x3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    deltay = DOUBLE_4U16(y0, y1, y2, y3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    if (off) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
      mlib_s32 emask = vis_edge16((void*)(2*off), (void*)(2*(off + size - 1)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
      off = 4 - off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
      GET_POINTER(sp3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
      sp0 = sp1 = sp2 = sp3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
      if (off > 1 && size > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        GET_POINTER(sp3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
      if (off > 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        sp2 = sp3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        if (size > 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
          GET_POINTER(sp3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
      LOAD_1CH();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
      dmask = ((mlib_d64*)mlib_dmask_arr)[emask];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
      *dp++ = vis_for (vis_fand(dmask, dd), vis_fandnot(dmask, dp[0]));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
      size -= off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
      if (size < 0) size = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    for (i = 0; i < size/4; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
      GET_POINTER(sp0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
      GET_POINTER(sp1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
      GET_POINTER(sp2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
      GET_POINTER(sp3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
      LOAD_1CH();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
      dp[i] = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    off = size & 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    if (off) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
      GET_POINTER(sp0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
      sp1 = sp2 = sp3 = sp0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
      if (off > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        GET_POINTER(sp1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
      if (off > 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        GET_POINTER(sp2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
      LOAD_1CH();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
      dmask = ((mlib_d64*)mlib_dmask_arr)[(0xF0 >> off) & 0x0F];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
      dp[i] = vis_for (vis_fand(dmask, dd), vis_fandnot(dmask, dp[i]));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
#undef  GET_POINTER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
#define GET_POINTER(sp)                                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
  sp = *(mlib_f32**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
  X += dX;                                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
  Y += dY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
#define LOAD_2CH()                                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
  s0 = vis_freg_pair(sp0[0], sp1[0]);                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
  s1 = vis_freg_pair(sp0[1], sp1[1]);                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
  s2 = vis_freg_pair(sp0[srcYStride], sp1[srcYStride]);         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
  s3 = vis_freg_pair(sp0[srcYStride + 1], sp1[srcYStride + 1])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
#undef  PREPARE_DELTAS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
#define PREPARE_DELTAS                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
  if (warp_tbl != NULL) {                                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    dX = warp_tbl[2*j    ];                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    dY = warp_tbl[2*j + 1];                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    dx64 = vis_to_double_dup(((dX & 0xFFFF) << 16) | (dX & 0xFFFF)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    dy64 = vis_to_double_dup(((dY & 0xFFFF) << 16) | (dY & 0xFFFF)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
mlib_status FUN_NAME(2ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
  DECLAREVAR();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
  mlib_s32 off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
  mlib_s32 x0, x1, y0, y1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
  if (((mlib_s32)lineAddr[0] | (mlib_s32)dstData | srcYStride | dstYStride) & 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    return FUN_NAME(2ch_na)(param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
  srcYStride >>= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
  dx64 = vis_to_double_dup(((dX & 0xFFFF) << 16) | (dX & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
  dy64 = vis_to_double_dup(((dY & 0xFFFF) << 16) | (dY & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    mlib_f32 *sp0, *sp1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    mlib_d64 *dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    NEW_LINE(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    off = (mlib_s32)dl & 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    dp = (mlib_d64*)(dl - off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    if (off) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
      x0 = X - dX; y0 = Y - dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
      x1 = X;      y1 = Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
      x0 = X;      y0 = Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
      x1 = X + dX; y1 = Y + dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    deltax = DOUBLE_4U16(x0, x0, x1, x1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    deltay = DOUBLE_4U16(y0, y0, y1, y1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    if (off) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
      GET_POINTER(sp1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
      sp0 = sp1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
      LOAD_2CH();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
      ((mlib_f32*)dp)[1] = vis_read_lo(dd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
      dp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
      size--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    for (i = 0; i < size/2; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
      GET_POINTER(sp0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
      GET_POINTER(sp1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
      LOAD_2CH();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
      *dp++ = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    if (size & 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
      GET_POINTER(sp0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
      sp1 = sp0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
      LOAD_2CH();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
      ((mlib_f32*)dp)[0] = vis_read_hi(dd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
#undef  GET_POINTER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
#define GET_POINTER(sp)                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
  sp = *(mlib_u8**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + 4*(X >> MLIB_SHIFT); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
  X += dX;                                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
  Y += dY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
#ifndef MLIB_VIS2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
#define LOAD_2CH_NA()                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
  s0 = vis_faligndata(LD_U16(sp1, 2), mask_7fff);               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
  s1 = vis_faligndata(LD_U16(sp1, 6), mask_7fff);               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
  s2 = vis_faligndata(LD_U16(sp1, srcYStride + 2), mask_7fff);  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
  s3 = vis_faligndata(LD_U16(sp1, srcYStride + 6), mask_7fff);  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
  s0 = vis_faligndata(LD_U16(sp1, 0), s0);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
  s1 = vis_faligndata(LD_U16(sp1, 4), s1);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
  s2 = vis_faligndata(LD_U16(sp1, srcYStride), s2);             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
  s3 = vis_faligndata(LD_U16(sp1, srcYStride + 4), s3);         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
  s0 = vis_faligndata(LD_U16(sp0, 2), s0);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
  s1 = vis_faligndata(LD_U16(sp0, 6), s1);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
  s2 = vis_faligndata(LD_U16(sp0, srcYStride + 2), s2);         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
  s3 = vis_faligndata(LD_U16(sp0, srcYStride + 6), s3);         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
  s0 = vis_faligndata(LD_U16(sp0, 0), s0);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
  s1 = vis_faligndata(LD_U16(sp0, 4), s1);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
  s2 = vis_faligndata(LD_U16(sp0, srcYStride), s2);             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
  s3 = vis_faligndata(LD_U16(sp0, srcYStride + 4), s3)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
#define LOAD_2CH_NA()                                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
  s0 = vis_bshuffle(LD_U16(sp0, 0), LD_U16(sp1, 0));                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
  s1 = vis_bshuffle(LD_U16(sp0, 4), LD_U16(sp1, 4));                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
  s2 = vis_bshuffle(LD_U16(sp0, srcYStride), LD_U16(sp1, srcYStride));         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
  s3 = vis_bshuffle(LD_U16(sp0, srcYStride + 4), LD_U16(sp1, srcYStride + 4)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
  t0 = vis_bshuffle(LD_U16(sp0, 2), LD_U16(sp1, 2));                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
  t1 = vis_bshuffle(LD_U16(sp0, 6), LD_U16(sp1, 6));                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
  t2 = vis_bshuffle(LD_U16(sp0, srcYStride + 2), LD_U16(sp1, srcYStride + 2)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
  t3 = vis_bshuffle(LD_U16(sp0, srcYStride + 6), LD_U16(sp1, srcYStride + 6)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
  s0 = vis_bshuffle(s0, t0);                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
  s1 = vis_bshuffle(s1, t1);                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
  s2 = vis_bshuffle(s2, t2);                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
  s3 = vis_bshuffle(s3, t3)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
mlib_status FUN_NAME(2ch_na)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
  DECLAREVAR();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
  mlib_s32 max_xsize = param -> max_xsize, bsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
  mlib_s32 x0, x1, y0, y1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
  mlib_d64 buff[BUF_SIZE], *pbuff = buff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
#ifdef MLIB_VIS2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
  mlib_d64 t0, t1, t2, t3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
  bsize = (max_xsize + 1)/2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
  if (bsize > BUF_SIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    pbuff = mlib_malloc(bsize*sizeof(mlib_d64));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    if (pbuff == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
  MLIB_WRITE_BMASK(0x45CD67EF);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
  dx64 = vis_to_double_dup(((dX & 0xFFFF) << 16) | (dX & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
  dy64 = vis_to_double_dup(((dY & 0xFFFF) << 16) | (dY & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    mlib_u8 *sp0, *sp1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
#ifndef MLIB_VIS2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    vis_alignaddr((void*)0, 6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    NEW_LINE(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    x0 = X;      y0 = Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    x1 = X + dX; y1 = Y + dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    deltax = DOUBLE_4U16(x0, x0, x1, x1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    deltay = DOUBLE_4U16(y0, y0, y1, y1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    for (i = 0; i < size/2; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
      GET_POINTER(sp0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
      GET_POINTER(sp1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
      LOAD_2CH_NA();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
      pbuff[i] = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    if (size & 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
      GET_POINTER(sp0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
      sp1 = sp0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
      LOAD_2CH_NA();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
      pbuff[i] = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    mlib_ImageCopy_na((mlib_u8*)pbuff, dl, 4*size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
  if (pbuff != buff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
#undef  PREPARE_DELTAS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
#define PREPARE_DELTAS                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
  if (warp_tbl != NULL) {                                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    dX = warp_tbl[2*j    ];                                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    dY = warp_tbl[2*j + 1];                                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    dX = (dX - (dX >> 31)) &~ 1; /* rounding towards ZERO */                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    dY = (dY - (dY >> 31)) &~ 1; /* rounding towards ZERO */                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    dx64 = vis_to_double_dup((((dX >> 1) & 0xFFFF) << 16) | ((dX >> 1) & 0xFFFF)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
    dy64 = vis_to_double_dup((((dY >> 1) & 0xFFFF) << 16) | ((dY >> 1) & 0xFFFF)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
mlib_status FUN_NAME(3ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
  DECLAREVAR();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
  mlib_s32 max_xsize = param -> max_xsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
  mlib_d64 buff[BUF_SIZE], *pbuff = buff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
  if (max_xsize > BUF_SIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
    pbuff = mlib_malloc(max_xsize*sizeof(mlib_d64));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
    if (pbuff == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
  dX = (dX - (dX >> 31)) &~ 1; /* rounding towards ZERO */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
  dY = (dY - (dY >> 31)) &~ 1; /* rounding towards ZERO */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
  dx64 = vis_to_double_dup((((dX >> 1) & 0xFFFF) << 16) | ((dX >> 1) & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
  dy64 = vis_to_double_dup((((dY >> 1) & 0xFFFF) << 16) | ((dY >> 1) & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    mlib_u8  *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
    mlib_d64 *sp0, *sp1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    NEW_LINE(3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
    deltax = DOUBLE_4U16(X, X, X, X);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
    deltay = DOUBLE_4U16(Y, Y, Y, Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
    for (i = 0; i < size; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
      sp = *(mlib_u8**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + 6*(X >> MLIB_SHIFT) - 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
      vis_alignaddr(sp, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
      sp0 = AL_ADDR(sp, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
      s0 = vis_faligndata(sp0[0], sp0[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
      s1 = vis_faligndata(sp0[1], sp0[2]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
      vis_alignaddr(sp, srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
      sp1 = AL_ADDR(sp, srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
      s2 = vis_faligndata(sp1[0], sp1[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
      s3 = vis_faligndata(sp1[1], sp1[2]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
      BL_SUM_3CH();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
      pbuff[i] = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
      X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
      Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
    mlib_v_ImageChannelExtract_S16_43L_D1((void *)pbuff, (void *)dl, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
  if (pbuff != buff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
mlib_status FUN_NAME(4ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
  DECLAREVAR();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
  if (((mlib_s32)lineAddr[0] | (mlib_s32)dstData | srcYStride | dstYStride) & 7) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    return FUN_NAME(4ch_na)(param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
  srcYStride >>= 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
  dX = (dX - (dX >> 31)) &~ 1; /* rounding towards ZERO */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
  dY = (dY - (dY >> 31)) &~ 1; /* rounding towards ZERO */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
  dx64 = vis_to_double_dup((((dX >> 1) & 0xFFFF) << 16) | ((dX >> 1) & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
  dy64 = vis_to_double_dup((((dY >> 1) & 0xFFFF) << 16) | ((dY >> 1) & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    mlib_d64 *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    NEW_LINE(4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    deltax = DOUBLE_4U16(X, X, X, X);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    deltay = DOUBLE_4U16(Y, Y, Y, Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    for (i = 0; i < size; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
      sp = *(mlib_d64**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
      s0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
      s1 = sp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
      s2 = sp[srcYStride];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
      s3 = sp[srcYStride + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
      ((mlib_d64*)dl)[i] = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
      X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
      Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
mlib_status FUN_NAME(4ch_na)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
  DECLAREVAR();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
  mlib_s32 max_xsize = param -> max_xsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
  mlib_d64 buff[BUF_SIZE], *pbuff = buff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
  if (max_xsize > BUF_SIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    pbuff = mlib_malloc(max_xsize*sizeof(mlib_d64));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    if (pbuff == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
  dX = (dX - (dX >> 31)) &~ 1; /* rounding towards ZERO */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
  dY = (dY - (dY >> 31)) &~ 1; /* rounding towards ZERO */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
  dx64 = vis_to_double_dup((((dX >> 1) & 0xFFFF) << 16) | ((dX >> 1) & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
  dy64 = vis_to_double_dup((((dY >> 1) & 0xFFFF) << 16) | ((dY >> 1) & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    mlib_u8  *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
    mlib_d64 *sp0, *sp1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
    NEW_LINE(4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    deltax = DOUBLE_4U16(X, X, X, X);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
    deltay = DOUBLE_4U16(Y, Y, Y, Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
    for (i = 0; i < size; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
      sp = *(mlib_u8**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + 8*(X >> MLIB_SHIFT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
      vis_alignaddr(sp, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
      sp0 = AL_ADDR(sp, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
      s0 = vis_faligndata(sp0[0], sp0[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
      s1 = vis_faligndata(sp0[1], sp0[2]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
      vis_alignaddr(sp, srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
      sp1 = AL_ADDR(sp, srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
      s2 = vis_faligndata(sp1[0], sp1[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
      s3 = vis_faligndata(sp1[1], sp1[2]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
      pbuff[i] = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
      X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
      Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    mlib_ImageCopy_na((mlib_u8*)pbuff, dl, 8*size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
  if (pbuff != buff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
    mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
#define LUT(x)  plut[x]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
mlib_status FUN_NAME(s16_i)(mlib_affine_param *param,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
                            const void        *colormap)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
  DECLAREVAR();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
  mlib_s32 nchan   = mlib_ImageGetLutChannels(colormap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
  mlib_s32 lut_off = mlib_ImageGetLutOffset(colormap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
  mlib_d64 *plut = (mlib_d64*)mlib_ImageGetLutNormalTable(colormap) - lut_off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
  mlib_s32 max_xsize = param -> max_xsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
  mlib_d64 buff[BUF_SIZE], *pbuff = buff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
  srcYStride /= sizeof(DTYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
  if (max_xsize > BUF_SIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
    pbuff = mlib_malloc(max_xsize*sizeof(mlib_d64));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
    if (pbuff == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
  dX = (dX - (dX >> 31)) &~ 1; /* rounding towards ZERO */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
  dY = (dY - (dY >> 31)) &~ 1; /* rounding towards ZERO */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
  dx64 = vis_to_double_dup((((dX >> 1) & 0xFFFF) << 16) | ((dX >> 1) & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
  dy64 = vis_to_double_dup((((dY >> 1) & 0xFFFF) << 16) | ((dY >> 1) & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
    DTYPE *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
    NEW_LINE(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    deltax = DOUBLE_4U16(X, X, X, X);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
    deltay = DOUBLE_4U16(Y, Y, Y, Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
    for (i = 0; i < size; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
      sp = *(DTYPE**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
      s0 = LUT(sp[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
      s1 = LUT(sp[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
      s2 = LUT(sp[srcYStride]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
      s3 = LUT(sp[srcYStride + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
      pbuff[i] = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
      X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
      Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
    if (nchan == 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
      mlib_ImageColorTrue2IndexLine_S16_S16_3_in_4((void*)pbuff, (void*)dl, size, colormap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
      mlib_ImageColorTrue2IndexLine_S16_S16_4((void*)pbuff, (void*)dl, size, colormap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
  if (pbuff != buff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
    mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
#undef  DTYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
#define DTYPE mlib_u8
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
mlib_status FUN_NAME(u8_i)(mlib_affine_param *param,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
                           const void        *colormap)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
  DECLAREVAR();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
  mlib_s32 nchan   = mlib_ImageGetLutChannels(colormap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
  mlib_s32 lut_off = mlib_ImageGetLutOffset(colormap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
  mlib_d64 *plut = (mlib_d64*)mlib_ImageGetLutNormalTable(colormap) - lut_off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
  mlib_s32 max_xsize = param -> max_xsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
  mlib_d64 buff[BUF_SIZE], *pbuff = buff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
  if (max_xsize > BUF_SIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
    pbuff = mlib_malloc(max_xsize*sizeof(mlib_d64));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
    if (pbuff == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
  dX = (dX - (dX >> 31)) &~ 1; /* rounding towards ZERO */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
  dY = (dY - (dY >> 31)) &~ 1; /* rounding towards ZERO */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
  dx64 = vis_to_double_dup((((dX >> 1) & 0xFFFF) << 16) | ((dX >> 1) & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
  dy64 = vis_to_double_dup((((dY >> 1) & 0xFFFF) << 16) | ((dY >> 1) & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
    DTYPE *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
    NEW_LINE(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
    deltax = DOUBLE_4U16(X, X, X, X);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
    deltay = DOUBLE_4U16(Y, Y, Y, Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
    for (i = 0; i < size; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
      sp = *(DTYPE**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
      s0 = LUT(sp[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
      s1 = LUT(sp[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
      s2 = LUT(sp[srcYStride]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
      s3 = LUT(sp[srcYStride + 1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
      pbuff[i] = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
      X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
      Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
    if (nchan == 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
      mlib_ImageColorTrue2IndexLine_S16_U8_3_in_4((void*)pbuff, (void*)dl, size, colormap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
      mlib_ImageColorTrue2IndexLine_S16_U8_4((void*)pbuff, (void*)dl, size, colormap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
  if (pbuff != buff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
    mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
/***************************************************************/