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