jdk/src/solaris/native/sun/awt/medialib/mlib_v_ImageLookUpS32U16Func.c
author bae
Fri, 15 Oct 2010 10:42:39 +0400
changeset 6814 c6e347fb5b20
parent 5506 202f599c92aa
child 7668 d4a77089c587
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) 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_U16_124_D1(const mlib_s32 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
                                              mlib_u16       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
                                              mlib_s32       xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
                                              const mlib_u16 *table0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
                                              const mlib_u16 *table1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
                                              const mlib_u16 *table2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
                                              const mlib_u16 *table3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
static void mlib_v_ImageLookUp_S32_U16_3_D1(const mlib_s32 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
                                            mlib_u16       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
                                            mlib_s32       xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
                                            const mlib_u16 *table0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
                                            const mlib_u16 *table1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
                                            const mlib_u16 *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_U16_124_D1(const mlib_s32 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
                                       mlib_u16       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
                                       mlib_s32       xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
                                       const mlib_u16 *table0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
                                       const mlib_u16 *table1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
                                       const mlib_u16 *table2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
                                       const mlib_u16 *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_u16 *dl;                        /* pointer to start of destination */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
  mlib_u16 *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_u16 *) dend - (mlib_u16 *) 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_U16_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_u16       *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,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                                  const mlib_u16 **table)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
  mlib_s32 *sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
  mlib_u16 *dl;
6814
c6e347fb5b20 6725821: Compiler warnings in medialib code
bae
parents: 5506
diff changeset
   173
  mlib_u32 shift = 2147483648u;
c6e347fb5b20 6725821: Compiler warnings in medialib code
bae
parents: 5506
diff changeset
   174
  const mlib_u16 *tab = &table[0][shift];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
  mlib_s32 j, i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
  sl = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
  dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
  /* row loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    mlib_s32 *sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    mlib_u16 *dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    mlib_s32 off, size = xsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    off = (mlib_s32) (((8 - ((mlib_addr) dp & 7)) & 7) >> 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    off = (off < size) ? off : size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    for (i = 0; i < off; i++, sp++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
      *dp++ = tab[sp[0]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
      size--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    if (size > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
      mlib_v_ImageLookUp_S32_U16_124_D1(sp, dp, size, tab, tab, tab, tab);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    sl = (mlib_s32 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    dl = (mlib_u16 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
void mlib_v_ImageLookUp_S32_U16_2(const mlib_s32 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                                  mlib_s32       slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                                  mlib_u16       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                                  mlib_s32       dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                                  mlib_s32       xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                                  mlib_s32       ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                                  const mlib_u16 **table)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
  mlib_s32 *sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
  mlib_u16 *dl;
6814
c6e347fb5b20 6725821: Compiler warnings in medialib code
bae
parents: 5506
diff changeset
   215
  mlib_u32 shift = 2147483648u;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
  const mlib_u16 *tab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
  mlib_s32 j, i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
  sl = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
  dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
  /* row loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    mlib_s32 *sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    mlib_u16 *dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    mlib_s32 off, size = xsize * 2;
6814
c6e347fb5b20 6725821: Compiler warnings in medialib code
bae
parents: 5506
diff changeset
   227
    const mlib_u16 *tab0 = &table[0][shift];
c6e347fb5b20 6725821: Compiler warnings in medialib code
bae
parents: 5506
diff changeset
   228
    const mlib_u16 *tab1 = &table[1][shift];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    off = (mlib_s32) (((8 - ((mlib_addr) dp & 7)) & 7) >> 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    off = (off < size) ? off : size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    for (i = 0; i < off - 1; i += 2, sp += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
      *dp++ = tab0[sp[0]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
      *dp++ = tab1[sp[1]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
      size -= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    if ((off & 1) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
      *dp++ = tab0[sp[0]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
      size--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
      sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
      tab = tab0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
      tab0 = tab1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
      tab1 = tab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    if (size > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
      mlib_v_ImageLookUp_S32_U16_124_D1(sp, dp, size, tab0, tab1, tab0, tab1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    sl = (mlib_s32 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    dl = (mlib_u16 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
void mlib_v_ImageLookUp_S32_U16_4(const mlib_s32 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                                  mlib_s32       slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                                  mlib_u16       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                                  mlib_s32       dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                                  mlib_s32       xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                                  mlib_s32       ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                                  const mlib_u16 **table)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
  mlib_s32 *sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
  mlib_u16 *dl;
6814
c6e347fb5b20 6725821: Compiler warnings in medialib code
bae
parents: 5506
diff changeset
   269
  mlib_u32 shift = 2147483648u;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
  const mlib_u16 *tab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
  mlib_s32 j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
  sl = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
  dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
  /* row loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    mlib_s32 *sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    mlib_u16 *dp = dl;
6814
c6e347fb5b20 6725821: Compiler warnings in medialib code
bae
parents: 5506
diff changeset
   280
    const mlib_u16 *tab0 = &table[0][shift];
c6e347fb5b20 6725821: Compiler warnings in medialib code
bae
parents: 5506
diff changeset
   281
    const mlib_u16 *tab1 = &table[1][shift];
c6e347fb5b20 6725821: Compiler warnings in medialib code
bae
parents: 5506
diff changeset
   282
    const mlib_u16 *tab2 = &table[2][shift];
c6e347fb5b20 6725821: Compiler warnings in medialib code
bae
parents: 5506
diff changeset
   283
    const mlib_u16 *tab3 = &table[3][shift];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    mlib_s32 off, size = xsize * 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    off = (mlib_s32) (((8 - ((mlib_addr) dp & 7)) & 7) >> 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    off = (off < size) ? off : size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    if (off == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
      *dp++ = tab0[sp[0]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
      tab = tab0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
      tab0 = tab1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
      tab1 = tab2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
      tab2 = tab3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
      tab3 = tab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
      size--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
      sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    else if (off == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
      *dp++ = tab0[sp[0]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
      *dp++ = tab1[sp[1]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
      tab = tab0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
      tab0 = tab2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
      tab2 = tab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
      tab = tab1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
      tab1 = tab3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
      tab3 = tab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
      size -= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
      sp += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    else if (off == 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
      *dp++ = tab0[sp[0]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
      *dp++ = tab1[sp[1]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
      *dp++ = tab2[sp[2]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
      tab = tab3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
      tab3 = tab2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
      tab2 = tab1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
      tab1 = tab0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
      tab0 = tab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
      size -= 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
      sp += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    if (size > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
      mlib_v_ImageLookUp_S32_U16_124_D1(sp, dp, size, tab0, tab1, tab2, tab3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    sl = (mlib_s32 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    dl = (mlib_u16 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
void mlib_v_ImageLookUp_S32_U16_3_D1(const mlib_s32 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                                     mlib_u16       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                                     mlib_s32       xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                                     const mlib_u16 *table0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                                     const mlib_u16 *table1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                                     const mlib_u16 *table2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
  mlib_s32 *sp;                        /* pointer to source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
  mlib_s32 s0, s1, s2, s3;             /* source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
  mlib_u16 *dl;                        /* pointer to start of destination */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
  mlib_u16 *dend;                      /* pointer to end of destination */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
  mlib_d64 *dp;                        /* aligned pointer to destination */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
  mlib_d64 t0, t1, t2, t3;             /* destination data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
  mlib_d64 acc0;                       /* destination data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
  mlib_s32 emask;                      /* edge mask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
  mlib_s32 i, num;                     /* loop variable */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
  const mlib_u16 *table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
  dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
  sp = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
  dp = (mlib_d64 *) dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
  dend = dl + xsize - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
  vis_alignaddr((void *)0, 6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
  if (xsize >= 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    s0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    s1 = sp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    s2 = sp[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    s3 = sp[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    sp += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    for (i = 0; i <= xsize - 8; i += 4, sp += 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
      t3 = VIS_LD_U16_I(table0, ((mlib_addr) 2 * s3));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
      t2 = VIS_LD_U16_I(table2, ((mlib_addr) 2 * s2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
      t1 = VIS_LD_U16_I(table1, ((mlib_addr) 2 * s1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
      t0 = VIS_LD_U16_I(table0, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
      acc0 = vis_faligndata(t3, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
      acc0 = vis_faligndata(t2, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
      acc0 = vis_faligndata(t1, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
      acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
      s0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
      s1 = sp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
      s2 = sp[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
      s3 = sp[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
      *dp++ = acc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
      table = table0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
      table0 = table1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
      table1 = table2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
      table2 = table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    t3 = VIS_LD_U16_I(table0, ((mlib_addr) 2 * s3));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    t2 = VIS_LD_U16_I(table2, ((mlib_addr) 2 * s2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    t1 = VIS_LD_U16_I(table1, ((mlib_addr) 2 * s1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    t0 = VIS_LD_U16_I(table0, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    acc0 = vis_faligndata(t3, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    acc0 = vis_faligndata(t2, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    acc0 = vis_faligndata(t1, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    *dp++ = acc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    table = table0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    table0 = table1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    table1 = table2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    table2 = table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
  if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    num = (mlib_s32) ((mlib_u16 *) dend - (mlib_u16 *) dp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    sp += num;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    num++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    if (num == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
      s0 = *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
      t0 = VIS_LD_U16_I(table0, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
      acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    else if (num == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
      s0 = *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
      sp--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
      t0 = VIS_LD_U16_I(table1, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
      acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
      s0 = *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
      t0 = VIS_LD_U16_I(table0, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
      acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    else if (num == 3) {
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(table2, ((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
      sp--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
      t0 = VIS_LD_U16_I(table1, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
      acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
      s0 = *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
      t0 = VIS_LD_U16_I(table0, ((mlib_addr) 2 * s0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
      acc0 = vis_faligndata(t0, acc0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    vis_pst_16(acc0, dp, emask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
void mlib_v_ImageLookUp_S32_U16_3(const mlib_s32 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                                  mlib_s32       slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                                  mlib_u16       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                                  mlib_s32       dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                                  mlib_s32       xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                                  mlib_s32       ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
                                  const mlib_u16 **table)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
  mlib_s32 *sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
  mlib_u16 *dl;
6814
c6e347fb5b20 6725821: Compiler warnings in medialib code
bae
parents: 5506
diff changeset
   463
  mlib_u32 shift = 2147483648u;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
  const mlib_u16 *tab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
  mlib_s32 j, i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
  sl = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
  dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
  /* row loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    mlib_s32 *sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    mlib_u16 *dp = dl;
6814
c6e347fb5b20 6725821: Compiler warnings in medialib code
bae
parents: 5506
diff changeset
   474
    const mlib_u16 *tab0 = &table[0][shift];
c6e347fb5b20 6725821: Compiler warnings in medialib code
bae
parents: 5506
diff changeset
   475
    const mlib_u16 *tab1 = &table[1][shift];
c6e347fb5b20 6725821: Compiler warnings in medialib code
bae
parents: 5506
diff changeset
   476
    const mlib_u16 *tab2 = &table[2][shift];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    mlib_s32 off, size = xsize * 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    off = (mlib_s32) (((8 - ((mlib_addr) dp & 7)) & 7) >> 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    off = (off < size) ? off : size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    for (i = 0; i < off - 2; i += 3, sp += 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
      *dp++ = tab0[sp[0]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
      *dp++ = tab1[sp[1]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
      *dp++ = tab2[sp[2]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
      size -= 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    off -= i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    if (off == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
      *dp++ = tab0[sp[0]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
      tab = tab0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
      tab0 = tab1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
      tab1 = tab2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
      tab2 = tab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
      size--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
      sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    else if (off == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
      *dp++ = tab0[sp[0]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
      *dp++ = tab1[sp[1]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
      tab = tab2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
      tab2 = tab1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
      tab1 = tab0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
      tab0 = tab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
      size -= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
      sp += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    if (size > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
      mlib_v_ImageLookUp_S32_U16_3_D1(sp, dp, size, tab0, tab1, tab2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    sl = (mlib_s32 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    dl = (mlib_u16 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
/***************************************************************/