jdk/src/solaris/native/sun/awt/medialib/mlib_v_ImageAffine_BL_U16.c
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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
#include "mlib_v_ImageAffine_BL_S16.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
/*#define MLIB_VIS2*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#define DTYPE mlib_s16
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
#define FUN_NAME(CHAN) mlib_ImageAffine_u16_##CHAN##_bl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
mlib_status FUN_NAME(2ch_na)(mlib_affine_param *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
mlib_status FUN_NAME(4ch_na)(mlib_affine_param *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
#define XOR_8000(x) x = vis_fxor(x, mask_8000)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
#ifdef MLIB_VIS2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
#define MLIB_WRITE_BMASK(bmask) vis_write_bmask(bmask, 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
#define MLIB_WRITE_BMASK(bmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
#endif /* MLIB_VIS2 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
#undef  DECLAREVAR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
#define DECLAREVAR()                                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
  DECLAREVAR0();                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
  mlib_s32  *warp_tbl   = param -> warp_tbl;                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
  mlib_s32  srcYStride = param -> srcYStride;                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
  mlib_u8   *dl;                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
  mlib_s32  i, size;                                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
  mlib_d64  mask_8000 = vis_to_double_dup(0x80008000);          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
  mlib_d64  mask_7fff = vis_to_double_dup(0x7FFF7FFF);          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
  mlib_d64  dx64, dy64, deltax, deltay, delta1_x, delta1_y;     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
  mlib_d64  s0, s1, s2, s3;                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
  mlib_d64  d0, d1, d2, d3, dd
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
/* arguments (x, y) are swapped to prevent overflow */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
#define FMUL_16x16(x, y)                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
  vis_fpadd16(vis_fmul8sux16(y, x),             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
              vis_fmul8ulx16(y, x))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
#define BUF_SIZE  512
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
#define DOUBLE_4U16(x0, x1, x2, x3)                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
  vis_to_double(((((x0) & 0xFFFE) << 15) | (((x1) & 0xFFFE) >> 1)), \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                ((((x2) & 0xFFFE) << 15) | (((x3) & 0xFFFE) >> 1)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
#define BL_SUM()                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
  XOR_8000(s0);                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
  XOR_8000(s1);                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
  XOR_8000(s2);                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
  XOR_8000(s3);                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
  delta1_x = vis_fpsub16(mask_7fff, deltax);                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
  delta1_y = vis_fpsub16(mask_7fff, deltay);                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
  d0 = FMUL_16x16(s0, delta1_x);                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
  d1 = FMUL_16x16(s1, deltax);                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
  d0 = vis_fpadd16(d0, d1);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
  d0 = vis_fpadd16(d0, d0);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
  d0 = FMUL_16x16(d0, delta1_y);                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
  d2 = FMUL_16x16(s2, delta1_x);                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
  d3 = FMUL_16x16(s3, deltax);                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
  d2 = vis_fpadd16(d2, d3);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
  d2 = vis_fpadd16(d2, d2);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
  d2 = FMUL_16x16(d2, deltay);                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
  dd = vis_fpadd16(d0, d2);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
  dd = vis_fpadd16(dd, dd);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
  XOR_8000(dd);                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
  deltax = vis_fpadd16(deltax, dx64);                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
  deltay = vis_fpadd16(deltay, dy64);                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
  deltax = vis_fand(deltax, mask_7fff);                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
  deltay = vis_fand(deltay, mask_7fff)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
#define BL_SUM_3CH()                                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
  XOR_8000(s0);                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
  XOR_8000(s1);                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
  XOR_8000(s2);                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
  XOR_8000(s3);                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
  delta1_x = vis_fpsub16(mask_7fff, deltax);                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
  delta1_y = vis_fpsub16(mask_7fff, deltay);                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
  d0 = FMUL_16x16(s0, delta1_y);                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
  d2 = FMUL_16x16(s2, deltay);                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
  d0 = vis_fpadd16(d0, d2);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
  d0 = vis_fpadd16(d0, d0);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
  d0 = FMUL_16x16(d0, delta1_x);                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
  d1 = FMUL_16x16(s1, delta1_y);                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
  d3 = FMUL_16x16(s3, deltay);                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
  d1 = vis_fpadd16(d1, d3);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
  d1 = vis_fpadd16(d1, d1);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
  d1 = FMUL_16x16(d1, deltax);                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
  vis_alignaddr((void*)0, 2);                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
  d0 = vis_faligndata(d0, d0);                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
  dd = vis_fpadd16(d0, d1);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
  dd = vis_fpadd16(dd, dd);                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
  XOR_8000(dd);                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
  deltax = vis_fpadd16(deltax, dx64);                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
  deltay = vis_fpadd16(deltay, dy64);                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
  deltax = vis_fand(deltax, mask_7fff);                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
  deltay = vis_fand(deltay, mask_7fff)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
#define LD_U16(sp, ind) vis_ld_u16(sp + ind)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
#ifndef MLIB_VIS2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
#define LOAD_1CH()                                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
  s0 = vis_faligndata(LD_U16(sp3, 0), mask_7fff);               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
  s1 = vis_faligndata(LD_U16(sp3, 2), mask_7fff);               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
  s2 = vis_faligndata(LD_U16(sp3, srcYStride), mask_7fff);      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
  s3 = vis_faligndata(LD_U16(sp3, srcYStride + 2), mask_7fff);  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
  s0 = vis_faligndata(LD_U16(sp2, 0), s0);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
  s1 = vis_faligndata(LD_U16(sp2, 2), s1);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
  s2 = vis_faligndata(LD_U16(sp2, srcYStride), s2);             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
  s3 = vis_faligndata(LD_U16(sp2, srcYStride + 2), s3);         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
  s0 = vis_faligndata(LD_U16(sp1, 0), s0);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
  s1 = vis_faligndata(LD_U16(sp1, 2), s1);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
  s2 = vis_faligndata(LD_U16(sp1, srcYStride), s2);             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
  s3 = vis_faligndata(LD_U16(sp1, srcYStride + 2), s3);         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
  s0 = vis_faligndata(LD_U16(sp0, 0), s0);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
  s1 = vis_faligndata(LD_U16(sp0, 2), s1);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
  s2 = vis_faligndata(LD_U16(sp0, srcYStride), s2);             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
  s3 = vis_faligndata(LD_U16(sp0, srcYStride + 2), s3)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
#define LOAD_1CH()                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
  s0 = vis_bshuffle(LD_U16(sp0, 0), LD_U16(sp2, 0));                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
  s1 = vis_bshuffle(LD_U16(sp0, 2), LD_U16(sp2, 2));                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
  s2 = vis_bshuffle(LD_U16(sp0, srcYStride), LD_U16(sp2, srcYStride));         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
  s3 = vis_bshuffle(LD_U16(sp0, srcYStride + 2), LD_U16(sp2, srcYStride + 2)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
  t0 = vis_bshuffle(LD_U16(sp1, 0), LD_U16(sp3, 0));                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
  t1 = vis_bshuffle(LD_U16(sp1, 2), LD_U16(sp3, 2));                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
  t2 = vis_bshuffle(LD_U16(sp1, srcYStride), LD_U16(sp3, srcYStride));         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
  t3 = vis_bshuffle(LD_U16(sp1, srcYStride + 2), LD_U16(sp3, srcYStride + 2)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
  s0 = vis_bshuffle(s0, t0);                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
  s1 = vis_bshuffle(s1, t1);                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
  s2 = vis_bshuffle(s2, t2);                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
  s3 = vis_bshuffle(s3, t3)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
#endif /* MLIB_VIS2 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
#define GET_POINTER(sp)                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
  sp = *(mlib_u8**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + 2*(X >> MLIB_SHIFT); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
  X += dX;                                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
  Y += dY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
#undef  PREPARE_DELTAS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
#define PREPARE_DELTAS                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
  if (warp_tbl != NULL) {                                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    dX = warp_tbl[2*j    ];                                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    dY = warp_tbl[2*j + 1];                                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    dx64 = vis_to_double_dup((((dX << 1) & 0xFFFF) << 16) | ((dX << 1) & 0xFFFF)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    dy64 = vis_to_double_dup((((dY << 1) & 0xFFFF) << 16) | ((dY << 1) & 0xFFFF)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
mlib_status FUN_NAME(1ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
  DECLAREVAR();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
  mlib_s32 off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
  mlib_s32 x0, x1, x2, x3, y0, y1, y2, y3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
#ifdef MLIB_VIS2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
  mlib_d64 t0, t1, t2, t3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
  vis_write_bmask(0x45CD67EF, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
  vis_alignaddr((void*)0, 6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
#endif /* MLIB_VIS2 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
  dx64 = vis_to_double_dup((((dX << 1) & 0xFFFF) << 16) | ((dX << 1) & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
  dy64 = vis_to_double_dup((((dY << 1) & 0xFFFF) << 16) | ((dY << 1) & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    mlib_u8  *sp0, *sp1, *sp2, *sp3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    mlib_d64 *dp, dmask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    NEW_LINE(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    off = (mlib_s32)dl & 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    dp = (mlib_d64*)(dl - off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    off >>= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    x0 = X - off*dX; y0 = Y - off*dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    x1 = x0 + dX;    y1 = y0 + dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    x2 = x1 + dX;    y2 = y1 + dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    x3 = x2 + dX;    y3 = y2 + dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    deltax = DOUBLE_4U16(x0, x1, x2, x3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    deltay = DOUBLE_4U16(y0, y1, y2, y3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    if (off) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
      mlib_s32 emask = vis_edge16((void*)(2*off), (void*)(2*(off + size - 1)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
      off = 4 - off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
      GET_POINTER(sp3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
      sp0 = sp1 = sp2 = sp3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
      if (off > 1 && size > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        GET_POINTER(sp3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
      if (off > 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        sp2 = sp3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        if (size > 2) {
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
      LOAD_1CH();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
      dmask = ((mlib_d64*)mlib_dmask_arr)[emask];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
      *dp++ = vis_for (vis_fand(dmask, dd), vis_fandnot(dmask, dp[0]));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
      size -= off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
      if (size < 0) size = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    for (i = 0; i < size/4; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
      GET_POINTER(sp0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
      GET_POINTER(sp1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
      GET_POINTER(sp2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
      GET_POINTER(sp3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
      LOAD_1CH();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
      dp[i] = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    off = size & 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    if (off) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
      GET_POINTER(sp0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
      sp1 = sp2 = sp3 = sp0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
      if (off > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        GET_POINTER(sp1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
      if (off > 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        GET_POINTER(sp2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
      LOAD_1CH();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
      dmask = ((mlib_d64*)mlib_dmask_arr)[(0xF0 >> off) & 0x0F];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
      dp[i] = vis_for (vis_fand(dmask, dd), vis_fandnot(dmask, dp[i]));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
#undef  GET_POINTER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
#define GET_POINTER(sp)                                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
  sp = *(mlib_f32**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
  X += dX;                                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
  Y += dY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
#define LOAD_2CH()                                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
  s0 = vis_freg_pair(sp0[0], sp1[0]);                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
  s1 = vis_freg_pair(sp0[1], sp1[1]);                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
  s2 = vis_freg_pair(sp0[srcYStride], sp1[srcYStride]);         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
  s3 = vis_freg_pair(sp0[srcYStride + 1], sp1[srcYStride + 1])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
#undef  PREPARE_DELTAS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
#define PREPARE_DELTAS                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
  if (warp_tbl != NULL) {                                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    dX = warp_tbl[2*j    ];                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    dY = warp_tbl[2*j + 1];                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    dx64 = vis_to_double_dup(((dX & 0xFFFF) << 16) | (dX & 0xFFFF)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    dy64 = vis_to_double_dup(((dY & 0xFFFF) << 16) | (dY & 0xFFFF)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
mlib_status FUN_NAME(2ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
  DECLAREVAR();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
  mlib_s32 off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
  mlib_s32 x0, x1, y0, y1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
  if (((mlib_s32)lineAddr[0] | (mlib_s32)dstData | srcYStride | dstYStride) & 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    return FUN_NAME(2ch_na)(param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
  srcYStride >>= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
  dx64 = vis_to_double_dup(((dX & 0xFFFF) << 16) | (dX & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
  dy64 = vis_to_double_dup(((dY & 0xFFFF) << 16) | (dY & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    mlib_f32 *sp0, *sp1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    mlib_d64 *dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    NEW_LINE(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    off = (mlib_s32)dl & 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    dp = (mlib_d64*)(dl - off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    if (off) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
      x0 = X - dX; y0 = Y - dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
      x1 = X;      y1 = Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
      x0 = X;      y0 = Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
      x1 = X + dX; y1 = Y + dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    deltax = DOUBLE_4U16(x0, x0, x1, x1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    deltay = DOUBLE_4U16(y0, y0, y1, y1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    if (off) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
      GET_POINTER(sp1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
      sp0 = sp1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
      LOAD_2CH();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
      ((mlib_f32*)dp)[1] = vis_read_lo(dd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
      dp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
      size--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    for (i = 0; i < size/2; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
      GET_POINTER(sp0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
      GET_POINTER(sp1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
      LOAD_2CH();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
      *dp++ = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    if (size & 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
      GET_POINTER(sp0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
      sp1 = sp0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
      LOAD_2CH();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
      ((mlib_f32*)dp)[0] = vis_read_hi(dd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
#undef  GET_POINTER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
#define GET_POINTER(sp)                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
  sp = *(mlib_u8**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + 4*(X >> MLIB_SHIFT); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
  X += dX;                                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
  Y += dY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
#ifndef MLIB_VIS2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
#define LOAD_2CH_NA()                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
  s0 = vis_faligndata(LD_U16(sp1, 2), mask_7fff);               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
  s1 = vis_faligndata(LD_U16(sp1, 6), mask_7fff);               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
  s2 = vis_faligndata(LD_U16(sp1, srcYStride + 2), mask_7fff);  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
  s3 = vis_faligndata(LD_U16(sp1, srcYStride + 6), mask_7fff);  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
  s0 = vis_faligndata(LD_U16(sp1, 0), s0);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
  s1 = vis_faligndata(LD_U16(sp1, 4), s1);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
  s2 = vis_faligndata(LD_U16(sp1, srcYStride), s2);             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
  s3 = vis_faligndata(LD_U16(sp1, srcYStride + 4), s3);         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
  s0 = vis_faligndata(LD_U16(sp0, 2), s0);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
  s1 = vis_faligndata(LD_U16(sp0, 6), s1);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
  s2 = vis_faligndata(LD_U16(sp0, srcYStride + 2), s2);         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
  s3 = vis_faligndata(LD_U16(sp0, srcYStride + 6), s3);         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
  s0 = vis_faligndata(LD_U16(sp0, 0), s0);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
  s1 = vis_faligndata(LD_U16(sp0, 4), s1);                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
  s2 = vis_faligndata(LD_U16(sp0, srcYStride), s2);             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
  s3 = vis_faligndata(LD_U16(sp0, srcYStride + 4), s3)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
#define LOAD_2CH_NA()                                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
  s0 = vis_bshuffle(LD_U16(sp0, 0), LD_U16(sp1, 0));                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
  s1 = vis_bshuffle(LD_U16(sp0, 4), LD_U16(sp1, 4));                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
  s2 = vis_bshuffle(LD_U16(sp0, srcYStride), LD_U16(sp1, srcYStride));         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
  s3 = vis_bshuffle(LD_U16(sp0, srcYStride + 4), LD_U16(sp1, srcYStride + 4)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
  t0 = vis_bshuffle(LD_U16(sp0, 2), LD_U16(sp1, 2));                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
  t1 = vis_bshuffle(LD_U16(sp0, 6), LD_U16(sp1, 6));                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
  t2 = vis_bshuffle(LD_U16(sp0, srcYStride + 2), LD_U16(sp1, srcYStride + 2)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
  t3 = vis_bshuffle(LD_U16(sp0, srcYStride + 6), LD_U16(sp1, srcYStride + 6)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
  s0 = vis_bshuffle(s0, t0);                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
  s1 = vis_bshuffle(s1, t1);                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
  s2 = vis_bshuffle(s2, t2);                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
  s3 = vis_bshuffle(s3, t3)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
#endif /* MLIB_VIS2 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
mlib_status FUN_NAME(2ch_na)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
  DECLAREVAR();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
  mlib_s32 max_xsize = param -> max_xsize, bsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
  mlib_s32 x0, x1, y0, y1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
  mlib_d64 buff[BUF_SIZE], *pbuff = buff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
#ifdef MLIB_VIS2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
  mlib_d64 t0, t1, t2, t3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
#endif /* MLIB_VIS2 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
  bsize = (max_xsize + 1)/2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
  if (bsize > BUF_SIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    pbuff = mlib_malloc(bsize*sizeof(mlib_d64));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    if (pbuff == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
  MLIB_WRITE_BMASK(0x45CD67EF);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
  dx64 = vis_to_double_dup(((dX & 0xFFFF) << 16) | (dX & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
  dy64 = vis_to_double_dup(((dY & 0xFFFF) << 16) | (dY & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    mlib_u8 *sp0, *sp1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
#ifndef MLIB_VIS2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    vis_alignaddr((void*)0, 6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
#endif /* MLIB_VIS2 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    NEW_LINE(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    x0 = X;      y0 = Y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    x1 = X + dX; y1 = Y + dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    deltax = DOUBLE_4U16(x0, x0, x1, x1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    deltay = DOUBLE_4U16(y0, y0, y1, y1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    for (i = 0; i < size/2; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
      GET_POINTER(sp0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
      GET_POINTER(sp1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
      LOAD_2CH_NA();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
      pbuff[i] = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    if (size & 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
      GET_POINTER(sp0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
      sp1 = sp0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
      LOAD_2CH_NA();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
      pbuff[i] = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    mlib_ImageCopy_na((mlib_u8*)pbuff, dl, 4*size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
  if (pbuff != buff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
#undef  PREPARE_DELTAS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
#define PREPARE_DELTAS                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
  if (warp_tbl != NULL) {                                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    dX = warp_tbl[2*j    ];                                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    dY = warp_tbl[2*j + 1];                                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    dX = (dX - (dX >> 31)) &~ 1; /* rounding towards ZERO */                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
    dY = (dY - (dY >> 31)) &~ 1; /* rounding towards ZERO */                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    dx64 = vis_to_double_dup((((dX >> 1) & 0xFFFF) << 16) | ((dX >> 1) & 0xFFFF)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    dy64 = vis_to_double_dup((((dY >> 1) & 0xFFFF) << 16) | ((dY >> 1) & 0xFFFF)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
mlib_status FUN_NAME(3ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
  DECLAREVAR();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
  mlib_s32 max_xsize = param -> max_xsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
  mlib_d64 buff[BUF_SIZE], *pbuff = buff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
  if (max_xsize > BUF_SIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    pbuff = mlib_malloc(max_xsize*sizeof(mlib_d64));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
    if (pbuff == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
  dX = (dX - (dX >> 31)) &~ 1; /* rounding towards ZERO */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
  dY = (dY - (dY >> 31)) &~ 1; /* rounding towards ZERO */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
  dx64 = vis_to_double_dup((((dX >> 1) & 0xFFFF) << 16) | ((dX >> 1) & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
  dy64 = vis_to_double_dup((((dY >> 1) & 0xFFFF) << 16) | ((dY >> 1) & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
    mlib_u8  *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    mlib_d64 *sp0, *sp1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
    NEW_LINE(3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    deltax = DOUBLE_4U16(X, X, X, X);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
    deltay = DOUBLE_4U16(Y, Y, Y, Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    for (i = 0; i < size; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
      sp = *(mlib_u8**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + 6*(X >> MLIB_SHIFT) - 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
      vis_alignaddr(sp, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
      sp0 = AL_ADDR(sp, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
      s0 = vis_faligndata(sp0[0], sp0[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
      s1 = vis_faligndata(sp0[1], sp0[2]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
      vis_alignaddr(sp, srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
      sp1 = AL_ADDR(sp, srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
      s2 = vis_faligndata(sp1[0], sp1[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
      s3 = vis_faligndata(sp1[1], sp1[2]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
      BL_SUM_3CH();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
      pbuff[i] = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
      X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
      Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
    mlib_v_ImageChannelExtract_S16_43L_D1((void *)pbuff, (void *)dl, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
  if (pbuff != buff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
mlib_status FUN_NAME(4ch)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
  DECLAREVAR();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
  if (((mlib_s32)lineAddr[0] | (mlib_s32)dstData | srcYStride | dstYStride) & 7) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
    return FUN_NAME(4ch_na)(param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
  srcYStride >>= 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
  dX = (dX - (dX >> 31)) &~ 1; /* rounding towards ZERO */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
  dY = (dY - (dY >> 31)) &~ 1; /* rounding towards ZERO */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
  dx64 = vis_to_double_dup((((dX >> 1) & 0xFFFF) << 16) | ((dX >> 1) & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
  dy64 = vis_to_double_dup((((dY >> 1) & 0xFFFF) << 16) | ((dY >> 1) & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    mlib_d64 *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    NEW_LINE(4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    deltax = DOUBLE_4U16(X, X, X, X);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
    deltay = DOUBLE_4U16(Y, Y, Y, Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    for (i = 0; i < size; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
      sp = *(mlib_d64**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
      s0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
      s1 = sp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
      s2 = sp[srcYStride];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
      s3 = sp[srcYStride + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
      ((mlib_d64*)dl)[i] = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
      X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
      Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
mlib_status FUN_NAME(4ch_na)(mlib_affine_param *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
  DECLAREVAR();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
  mlib_s32 max_xsize = param -> max_xsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
  mlib_d64 buff[BUF_SIZE], *pbuff = buff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
  if (max_xsize > BUF_SIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    pbuff = mlib_malloc(max_xsize*sizeof(mlib_d64));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    if (pbuff == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
  dX = (dX - (dX >> 31)) &~ 1; /* rounding towards ZERO */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
  dY = (dY - (dY >> 31)) &~ 1; /* rounding towards ZERO */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
  dx64 = vis_to_double_dup((((dX >> 1) & 0xFFFF) << 16) | ((dX >> 1) & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
  dy64 = vis_to_double_dup((((dY >> 1) & 0xFFFF) << 16) | ((dY >> 1) & 0xFFFF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
  for (j = yStart; j <= yFinish; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    mlib_u8  *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
    mlib_d64 *sp0, *sp1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    NEW_LINE(4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    deltax = DOUBLE_4U16(X, X, X, X);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    deltay = DOUBLE_4U16(Y, Y, Y, Y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    for (i = 0; i < size; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
      sp = *(mlib_u8**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + 8*(X >> MLIB_SHIFT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
      vis_alignaddr(sp, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
      sp0 = AL_ADDR(sp, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
      s0 = vis_faligndata(sp0[0], sp0[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
      s1 = vis_faligndata(sp0[1], sp0[2]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
      vis_alignaddr(sp, srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
      sp1 = AL_ADDR(sp, srcYStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
      s2 = vis_faligndata(sp1[0], sp1[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
      s3 = vis_faligndata(sp1[1], sp1[2]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
      BL_SUM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
      pbuff[i] = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
      X += dX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
      Y += dY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    mlib_ImageCopy_na((mlib_u8*)pbuff, dl, 8*size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
  if (pbuff != buff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
    mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
/***************************************************************/