jdk/src/solaris/native/sun/awt/medialib/mlib_v_ImageLookUpS32S16Func.c
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
child 6814 c6e347fb5b20
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
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) 1998, 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
#include "vis_proto.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "mlib_image.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "mlib_v_ImageLookUpFunc.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
static void mlib_v_ImageLookUp_S32_S16_124_D1(const mlib_s32 * src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
                                              mlib_s16 * dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
                                              mlib_s32 xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
                                              const mlib_s16 * table0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
                                              const mlib_s16 * table1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
                                              const mlib_s16 * table2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
                                              const mlib_s16 * table3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
static void mlib_v_ImageLookUp_S32_S16_3_D1(const mlib_s32 * src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
                                            mlib_s16 * dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
                                            mlib_s32 xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
                                            const mlib_s16 * table0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
                                            const mlib_s16 * table1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
                                            const mlib_s16 * table2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#define VIS_LD_U16_I(X, Y)      vis_ld_u16_i((void *)(X), (Y))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
void mlib_v_ImageLookUp_S32_S16_124_D1(const mlib_s32 * src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
                                       mlib_s16 * dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
                                       mlib_s32 xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
                                       const mlib_s16 * table0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
                                       const mlib_s16 * table1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
                                       const mlib_s16 * table2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
                                       const mlib_s16 * table3)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
  mlib_s32 *sp;                        /* pointer to source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
  mlib_s32 s0, s1, s2, s3;             /* source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
  mlib_s16 *dl;                        /* pointer to start of destination */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
  mlib_s16 *dend;                      /* pointer to end of destination */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
  mlib_d64 *dp;                        /* aligned pointer to destination */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
  mlib_d64 t0, t1, t2;                 /* destination data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
  mlib_d64 t3, acc0;                   /* destination data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
  mlib_s32 emask;                      /* edge mask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
  mlib_s32 i, num;                     /* loop variable */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
  dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
  sp = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
  dp = (mlib_d64 *) dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
  dend = dl + xsize - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
  vis_alignaddr((void *)0, 6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
  if (xsize >= 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    s0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    s1 = sp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    s2 = sp[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    s3 = sp[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    sp += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    for (i = 0; i <= xsize - 8; i += 4, sp += 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
      t3 = VIS_LD_U16_I(table3, ((mlib_addr) 2 * s3));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
      t2 = VIS_LD_U16_I(table2, ((mlib_addr) 2 * s2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
      t1 = VIS_LD_U16_I(table1, ((mlib_addr) 2 * s1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
      t0 = VIS_LD_U16_I(table0, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
      acc0 = vis_faligndata(t3, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
      acc0 = vis_faligndata(t2, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
      acc0 = vis_faligndata(t1, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
      acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
      s0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
      s1 = sp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
      s2 = sp[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
      s3 = sp[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
      *dp++ = acc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    t3 = VIS_LD_U16_I(table3, ((mlib_addr) 2 * s3));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    t2 = VIS_LD_U16_I(table2, ((mlib_addr) 2 * s2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    t1 = VIS_LD_U16_I(table1, ((mlib_addr) 2 * s1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    t0 = VIS_LD_U16_I(table0, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    acc0 = vis_faligndata(t3, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    acc0 = vis_faligndata(t2, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    acc0 = vis_faligndata(t1, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    *dp++ = acc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
  if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    num = (mlib_s32) ((mlib_s16 *) dend - (mlib_s16 *) dp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    sp += num;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    num++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    if (num == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
      s0 = *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
      t0 = VIS_LD_U16_I(table0, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
      acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    else if (num == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
      s0 = *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
      sp--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
      t0 = VIS_LD_U16_I(table1, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
      acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
      s0 = *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
      t0 = VIS_LD_U16_I(table0, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
      acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    else if (num == 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
      s0 = *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
      sp--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
      t0 = VIS_LD_U16_I(table2, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
      acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
      s0 = *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
      sp--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
      t0 = VIS_LD_U16_I(table1, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
      acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
      s0 = *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
      t0 = VIS_LD_U16_I(table0, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
      acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    vis_pst_16(acc0, dp, emask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
void mlib_v_ImageLookUp_S32_S16_1(const mlib_s32 * src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                                  mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                                  mlib_s16 * dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                                  mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                                  mlib_s32 xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                                  mlib_s32 ysize, const mlib_s16 ** table)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
  mlib_s32 *sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
  mlib_s16 *dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
  const mlib_s16 *tab = &table[0][(mlib_u32) 2147483648u];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
  mlib_s32 j, i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
  sl = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
  dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
  /* row loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    mlib_s32 *sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    mlib_s16 *dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    mlib_s32 off, size = xsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    off = (mlib_s32) (((8 - ((mlib_addr) dp & 7)) & 7) >> 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    off = (off < size) ? off : size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    for (i = 0; i < off; i++, sp++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
      *dp++ = tab[sp[0]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
      size--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    if (size > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
      mlib_v_ImageLookUp_S32_S16_124_D1(sp, dp, size, tab, tab, tab, tab);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    sl = (mlib_s32 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
void mlib_v_ImageLookUp_S32_S16_2(const mlib_s32 * src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                                  mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                                  mlib_s16 * dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                                  mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                                  mlib_s32 xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                                  mlib_s32 ysize, const mlib_s16 ** table)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
  mlib_s32 *sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
  mlib_s16 *dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
  const mlib_s16 *tab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
  mlib_s32 j, i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
  sl = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
  dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
  /* row loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    mlib_s32 *sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    mlib_s16 *dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    mlib_s32 off, size = xsize * 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    const mlib_s16 *tab0 = &table[0][(mlib_u32) 2147483648u];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    const mlib_s16 *tab1 = &table[1][(mlib_u32) 2147483648u];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    off = (mlib_s32) (((8 - ((mlib_addr) dp & 7)) & 7) >> 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    off = (off < size) ? off : size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    for (i = 0; i < off - 1; i += 2, sp += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
      *dp++ = tab0[sp[0]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
      *dp++ = tab1[sp[1]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
      size -= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    if ((off & 1) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
      *dp++ = tab0[sp[0]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
      size--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
      sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
      tab = tab0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
      tab0 = tab1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
      tab1 = tab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    if (size > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
      mlib_v_ImageLookUp_S32_S16_124_D1(sp, dp, size, tab0, tab1, tab0, tab1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    sl = (mlib_s32 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
void mlib_v_ImageLookUp_S32_S16_4(const mlib_s32 * src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                                  mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                                  mlib_s16 * dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                                  mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                                  mlib_s32 xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                                  mlib_s32 ysize, const mlib_s16 ** table)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
  mlib_s32 *sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
  mlib_s16 *dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
  const mlib_s16 *tab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
  mlib_s32 j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
  sl = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
  dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
  /* row loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    mlib_s32 *sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    mlib_s16 *dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    const mlib_s16 *tab0 = &table[0][(mlib_u32) 2147483648u];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    const mlib_s16 *tab1 = &table[1][(mlib_u32) 2147483648u];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    const mlib_s16 *tab2 = &table[2][(mlib_u32) 2147483648u];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    const mlib_s16 *tab3 = &table[3][(mlib_u32) 2147483648u];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    mlib_s32 off, size = xsize * 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    off = (mlib_s32) (((8 - ((mlib_addr) dp & 7)) & 7) >> 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    off = (off < size) ? off : size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    if (off == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
      *dp++ = tab0[sp[0]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
      tab = tab0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
      tab0 = tab1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
      tab1 = tab2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
      tab2 = tab3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
      tab3 = tab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
      size--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
      sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    else if (off == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
      *dp++ = tab0[sp[0]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
      *dp++ = tab1[sp[1]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
      tab = tab0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
      tab0 = tab2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
      tab2 = tab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
      tab = tab1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
      tab1 = tab3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
      tab3 = tab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
      size -= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
      sp += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    else if (off == 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
      *dp++ = tab0[sp[0]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
      *dp++ = tab1[sp[1]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
      *dp++ = tab2[sp[2]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
      tab = tab3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
      tab3 = tab2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
      tab2 = tab1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
      tab1 = tab0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
      tab0 = tab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
      size -= 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
      sp += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    if (size > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
      mlib_v_ImageLookUp_S32_S16_124_D1(sp, dp, size, tab0, tab1, tab2, tab3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    sl = (mlib_s32 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
void mlib_v_ImageLookUp_S32_S16_3_D1(const mlib_s32 * src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                                     mlib_s16 * dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                                     mlib_s32 xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                                     const mlib_s16 * table0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                                     const mlib_s16 * table1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                                     const mlib_s16 * table2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
  mlib_s32 *sp;                        /* pointer to source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
  mlib_s32 s0, s1, s2, s3;             /* source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
  mlib_s16 *dl;                        /* pointer to start of destination */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
  mlib_s16 *dend;                      /* pointer to end of destination */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
  mlib_d64 *dp;                        /* aligned pointer to destination */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
  mlib_d64 t0, t1, t2, t3;             /* destination data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
  mlib_d64 acc0;                       /* destination data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
  mlib_s32 emask;                      /* edge mask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
  mlib_s32 i, num;                     /* loop variable */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
  const mlib_s16 *table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
  dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
  sp = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
  dp = (mlib_d64 *) dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
  dend = dl + xsize - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
  vis_alignaddr((void *)0, 6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
  if (xsize >= 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    s0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    s1 = sp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    s2 = sp[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    s3 = sp[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    sp += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    for (i = 0; i <= xsize - 8; i += 4, sp += 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
      t3 = VIS_LD_U16_I(table0, ((mlib_addr) 2 * s3));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
      t2 = VIS_LD_U16_I(table2, ((mlib_addr) 2 * s2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
      t1 = VIS_LD_U16_I(table1, ((mlib_addr) 2 * s1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
      t0 = VIS_LD_U16_I(table0, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
      acc0 = vis_faligndata(t3, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
      acc0 = vis_faligndata(t2, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
      acc0 = vis_faligndata(t1, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
      acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
      s0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
      s1 = sp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
      s2 = sp[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
      s3 = sp[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
      *dp++ = acc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
      table = table0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
      table0 = table1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
      table1 = table2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
      table2 = table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    t3 = VIS_LD_U16_I(table0, ((mlib_addr) 2 * s3));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    t2 = VIS_LD_U16_I(table2, ((mlib_addr) 2 * s2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    t1 = VIS_LD_U16_I(table1, ((mlib_addr) 2 * s1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    t0 = VIS_LD_U16_I(table0, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    acc0 = vis_faligndata(t3, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    acc0 = vis_faligndata(t2, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    acc0 = vis_faligndata(t1, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    *dp++ = acc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    table = table0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    table0 = table1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    table1 = table2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    table2 = table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
  if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    num = (mlib_s32) ((mlib_s16 *) dend - (mlib_s16 *) dp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    sp += num;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    num++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    if (num == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
      s0 = *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
      t0 = VIS_LD_U16_I(table0, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
      acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    else if (num == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
      s0 = *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
      sp--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
      t0 = VIS_LD_U16_I(table1, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
      acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
      s0 = *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
      t0 = VIS_LD_U16_I(table0, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
      acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    else if (num == 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
      s0 = *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
      sp--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
      t0 = VIS_LD_U16_I(table2, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
      acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
      s0 = *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
      sp--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
      t0 = VIS_LD_U16_I(table1, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
      acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
      s0 = *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
      t0 = VIS_LD_U16_I(table0, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
      acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    vis_pst_16(acc0, dp, emask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
void mlib_v_ImageLookUp_S32_S16_3(const mlib_s32 * src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                                  mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                                  mlib_s16 * dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                                  mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                                  mlib_s32 xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                                  mlib_s32 ysize, const mlib_s16 ** table)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
  mlib_s32 *sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
  mlib_s16 *dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
  const mlib_s16 *tab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
  mlib_s32 j, i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
  sl = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
  dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
  /* row loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    mlib_s32 *sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    mlib_s16 *dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    const mlib_s16 *tab0 = &table[0][(mlib_u32) 2147483648u];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    const mlib_s16 *tab1 = &table[1][(mlib_u32) 2147483648u];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    const mlib_s16 *tab2 = &table[2][(mlib_u32) 2147483648u];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    mlib_s32 off, size = xsize * 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    off = (mlib_s32) (((8 - ((mlib_addr) dp & 7)) & 7) >> 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    off = (off < size) ? off : size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    for (i = 0; i < off - 2; i += 3, sp += 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
      *dp++ = tab0[sp[0]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
      *dp++ = tab1[sp[1]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
      *dp++ = tab2[sp[2]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
      size -= 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    off -= i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    if (off == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
      *dp++ = tab0[sp[0]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
      tab = tab0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
      tab0 = tab1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
      tab1 = tab2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
      tab2 = tab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
      size--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
      sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    else if (off == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
      *dp++ = tab0[sp[0]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
      *dp++ = tab1[sp[1]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
      tab = tab2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
      tab2 = tab1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
      tab1 = tab0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
      tab0 = tab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
      size -= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
      sp += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    if (size > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
      mlib_v_ImageLookUp_S32_S16_3_D1(sp, dp, size, tab0, tab1, tab2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    sl = (mlib_s32 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
/***************************************************************/