jdk/src/solaris/native/sun/awt/medialib/mlib_v_ImageLookUp.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
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * FUNCTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *      mlib_ImageLookUp - table lookup
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * SYNOPSIS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *      mlib_status mlib_ImageLookUp(mlib_image       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *                                   const mlib_image *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *                                   void             **table)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * ARGUMENT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *      dst      Pointer to destination image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *      src      Pointer to source image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *      table    Lookup table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * DESCRIPTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *      The mlib_ImageLookUp function performs general table lookup on an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *      image. The destination image is obtained by passing a source image
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *      through a lookup table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *      The source image may be 1-, 2-, 3-, or 4-channeled of data types
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *      MLIB_BIT, MLIB_BYTE, MLIB_SHORT, or MLIB_INT. The lookup table may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *      1-, 2-, 3-, or 4-channeled of data types MLIB_BYTE, MLIB_SHORT, MLIB_INT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *      MLIB_FLOAT, or MLIB_DOUBLE. The destination image must have the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *      number of channels as either source image or the lookup table,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *      whichever is greater, and the same data type as the lookup table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *      It is the user's responsibility to make sure that the lookup table
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *      supplied is suitable for the source image. Specifically, the table
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *      entries cover the entire range of source data. Otherwise, the result
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *      of this function is undefined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *      The pixel values of the destination image are defined as the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *      If the source image is single-channeled and the destination image is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *      multi-channeled, then the lookup table has the same number of channels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *      as the destination image:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *          dst[x][y][c] = table[c][src[x][y][0]]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *      If the source image is multi-channeled and the destination image is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *      multi-channeled, with the same number of channels as the source image,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *      then the lookup table will have the same number of channels as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *      the source image:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 *          dst[x][y][c] = table[c][src[x][y][c]]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
#include "mlib_image.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
#include "mlib_ImageCheck.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
#include "mlib_ImageLookUp.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
#include "mlib_v_ImageLookUpFunc.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
#define CALL_SIFUNC(STYPE, DTYPE, TYPE)                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
  switch (nchan) {                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    case 2:                                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
      mlib_v_ImageLookUpSI_##STYPE##_##DTYPE##_2(sa, slb, da, dlb, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
          xsize, ysize, (const TYPE **) table);                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
      break;                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    case 3:                                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
      mlib_v_ImageLookUpSI_##STYPE##_##DTYPE##_3(sa, slb, da, dlb, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
          xsize, ysize, (const TYPE **) table);                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
      break;                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    case 4:                                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
      mlib_v_ImageLookUpSI_##STYPE##_##DTYPE##_4(sa, slb, da, dlb, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
          xsize, ysize, (const TYPE **) table);                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
      break;                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    default:                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
      return MLIB_FAILURE;                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
  }                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
  return MLIB_SUCCESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
#define CALL_FUNC(STYPE, DTYPE, TYPE)                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
  switch (nchan) {                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    case 1:                                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
      mlib_v_ImageLookUp_##STYPE##_##DTYPE##_1(sa, slb, da, dlb, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
          xsize, ysize, (const TYPE **) table);                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
      break;                                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    case 2:                                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
      mlib_v_ImageLookUp_##STYPE##_##DTYPE##_2(sa, slb, da, dlb, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
          xsize, ysize, (const TYPE **) table);                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
      break;                                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    case 3:                                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
      mlib_v_ImageLookUp_##STYPE##_##DTYPE##_3(sa, slb, da, dlb, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
          xsize, ysize, (const TYPE **) table);                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
      break;                                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    case 4:                                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
      mlib_v_ImageLookUp_##STYPE##_##DTYPE##_4(sa, slb, da, dlb, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
          xsize, ysize, (const TYPE **) table);                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
      break;                                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    default:                                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
      return MLIB_FAILURE;                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
  }                                                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
  return MLIB_SUCCESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
mlib_status mlib_ImageLookUp(mlib_image       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                             const mlib_image *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                             const void       **table)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
  mlib_s32 slb, dlb, xsize, ysize, nchan, ichan, bitoff_src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
  mlib_type stype, dtype;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
  void *sa, *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
  MLIB_IMAGE_CHECK(src);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
  MLIB_IMAGE_CHECK(dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
  MLIB_IMAGE_SIZE_EQUAL(src, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
  MLIB_IMAGE_CHAN_SRC1_OR_EQ(src, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
  stype = mlib_ImageGetType(src);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
  dtype = mlib_ImageGetType(dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
  ichan = mlib_ImageGetChannels(src);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
  nchan = mlib_ImageGetChannels(dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
  xsize = mlib_ImageGetWidth(src);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
  ysize = mlib_ImageGetHeight(src);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
  slb = mlib_ImageGetStride(src);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
  dlb = mlib_ImageGetStride(dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
  sa = mlib_ImageGetData(src);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
  da = mlib_ImageGetData(dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
  if (ichan == nchan) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    if (dtype == MLIB_BYTE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
      if (stype == MLIB_BYTE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        CALL_FUNC(U8, U8, mlib_u8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
      else if (stype == MLIB_SHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        CALL_FUNC(S16, U8, mlib_u8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
      else if (stype == MLIB_USHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        CALL_FUNC(U16, U8, mlib_u8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
      else if (stype == MLIB_INT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        CALL_FUNC(S32, U8, mlib_u8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
      else if (stype == MLIB_BIT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        if (nchan != 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
          return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        bitoff_src = mlib_ImageGetBitOffset(src); /* bits to first byte */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        return mlib_ImageLookUp_Bit_U8_1(sa, slb, da, dlb, xsize, ysize, nchan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                                         bitoff_src, (const mlib_u8 **) table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    else if (dtype == MLIB_SHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
      if (stype == MLIB_BYTE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        CALL_FUNC(U8, S16, mlib_s16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
      else if (stype == MLIB_SHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        CALL_FUNC(S16, S16, mlib_s16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
      else if (stype == MLIB_USHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        CALL_FUNC(U16, S16, mlib_s16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
      else if (stype == MLIB_INT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        CALL_FUNC(S32, S16, mlib_s16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    else if (dtype == MLIB_USHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
      if (stype == MLIB_BYTE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        CALL_FUNC(U8, U16, mlib_u16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
      else if (stype == MLIB_SHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        CALL_FUNC(S16, U16, mlib_u16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
      else if (stype == MLIB_USHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        CALL_FUNC(U16, U16, mlib_u16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
      else if (stype == MLIB_INT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        CALL_FUNC(S32, U16, mlib_u16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    else if (dtype == MLIB_INT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
      if (stype == MLIB_BYTE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        CALL_FUNC(U8, S32, mlib_s32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
      else if (stype == MLIB_SHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        CALL_FUNC(S16, S32, mlib_s32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
      else if (stype == MLIB_USHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        CALL_FUNC(U16, S32, mlib_s32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
      else if (stype == MLIB_INT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        if ((nchan >= 1) && (nchan <= 4)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
          mlib_v_ImageLookUp_S32_S32(sa, slb, da, dlb, xsize, ysize, (const mlib_s32 **) table,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                                     nchan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
          return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
          return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    else if (dtype == MLIB_FLOAT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
      if (stype == MLIB_BYTE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        CALL_FUNC(U8, S32, mlib_s32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
      else if (stype == MLIB_SHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        CALL_FUNC(S16, S32, mlib_s32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
      else if (stype == MLIB_USHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        CALL_FUNC(U16, S32, mlib_s32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
      else if (stype == MLIB_INT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        if ((nchan >= 1) && (nchan <= 4)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
          mlib_v_ImageLookUp_S32_S32(sa, slb, da, dlb, xsize, ysize, (const mlib_s32 **) table,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                                     nchan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
          return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
          return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    else if (dtype == MLIB_DOUBLE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
      if (stype == MLIB_BYTE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        mlib_ImageLookUp_U8_D64(sa, slb, da, dlb / 8, xsize, ysize, nchan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                                (const mlib_d64 **) table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
      else if (stype == MLIB_SHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        mlib_ImageLookUp_S16_D64(sa, slb / 2, da, dlb / 8, xsize, ysize, nchan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                                 (const mlib_d64 **) table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
      else if (stype == MLIB_USHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        mlib_ImageLookUp_U16_D64(sa, slb / 2, da, dlb / 8, xsize, ysize, nchan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                                 (const mlib_d64 **) table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
      else if (stype == MLIB_INT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        mlib_ImageLookUp_S32_D64(sa, slb / 4, da, dlb / 8, xsize, ysize, nchan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                                 (const mlib_d64 **) table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
  else if (ichan == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    if (dtype == MLIB_BYTE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
      if (stype == MLIB_BYTE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        CALL_SIFUNC(U8, U8, mlib_u8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
      else if (stype == MLIB_SHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        CALL_SIFUNC(S16, U8, mlib_u8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
      else if (stype == MLIB_USHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        CALL_SIFUNC(U16, U8, mlib_u8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
      else if (stype == MLIB_INT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        CALL_SIFUNC(S32, U8, mlib_u8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
      else if (stype == MLIB_BIT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        bitoff_src = mlib_ImageGetBitOffset(src); /* bits to first byte */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        if (nchan == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
          return mlib_ImageLookUp_Bit_U8_2(sa, slb, da, dlb, xsize, ysize, nchan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                                           bitoff_src, (const mlib_u8 **) table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        else if (nchan == 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
          return mlib_ImageLookUp_Bit_U8_3(sa, slb, da, dlb, xsize, ysize, nchan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                                           bitoff_src, (const mlib_u8 **) table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        else {                              /* (nchan == 4) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
          return mlib_ImageLookUp_Bit_U8_4(sa, slb, da, dlb, xsize, ysize, nchan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                                           bitoff_src, (const mlib_u8 **) table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    else if (dtype == MLIB_SHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
      if (stype == MLIB_BYTE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        CALL_SIFUNC(U8, S16, mlib_s16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
      else if (stype == MLIB_SHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        CALL_SIFUNC(S16, S16, mlib_s16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
      else if (stype == MLIB_USHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        CALL_SIFUNC(U16, S16, mlib_s16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
      else if (stype == MLIB_INT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        CALL_SIFUNC(S32, S16, mlib_s16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    else if (dtype == MLIB_USHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
      if (stype == MLIB_BYTE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        CALL_SIFUNC(U8, U16, mlib_u16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
      else if (stype == MLIB_SHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        CALL_SIFUNC(S16, U16, mlib_u16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
      else if (stype == MLIB_USHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        CALL_SIFUNC(U16, U16, mlib_u16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
      else if (stype == MLIB_INT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        CALL_SIFUNC(S32, U16, mlib_u16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    else if (dtype == MLIB_INT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
      if (stype == MLIB_BYTE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        CALL_SIFUNC(U8, S32, mlib_s32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
      else if (stype == MLIB_SHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        CALL_SIFUNC(S16, S32, mlib_s32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
      else if (stype == MLIB_USHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        CALL_SIFUNC(U16, S32, mlib_s32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
      else if (stype == MLIB_INT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        if ((nchan >= 1) && (nchan <= 4)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
          mlib_v_ImageLookUpSI_S32_S32(sa, slb, da, dlb, xsize, ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                                       (const mlib_s32 **) table, nchan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
          return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
          return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    else if (dtype == MLIB_FLOAT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
      if (stype == MLIB_BYTE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        CALL_SIFUNC(U8, S32, mlib_s32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
      else if (stype == MLIB_SHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        CALL_SIFUNC(S16, S32, mlib_s32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
      else if (stype == MLIB_USHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        CALL_SIFUNC(U16, S32, mlib_s32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
      else if (stype == MLIB_INT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        if ((nchan >= 1) && (nchan <= 4)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
          mlib_v_ImageLookUpSI_S32_S32(sa, slb, da, dlb, xsize, ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                                       (const mlib_s32 **) table, nchan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
          return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
          return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    else if (dtype == MLIB_DOUBLE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
      if (stype == MLIB_BYTE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        mlib_ImageLookUpSI_U8_D64(sa, slb, da, dlb / 8, xsize, ysize, nchan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                                  (const mlib_d64 **) table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
      else if (stype == MLIB_SHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        mlib_ImageLookUpSI_S16_D64(sa, slb / 2, da, dlb / 8, xsize, ysize, nchan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                                   (const mlib_d64 **) table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
      else if (stype == MLIB_USHORT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        mlib_ImageLookUpSI_U16_D64(sa, slb / 2, da, dlb / 8, xsize, ysize, nchan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                                   (const mlib_d64 **) table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
      else if (stype == MLIB_INT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        mlib_ImageLookUpSI_S32_D64(sa, slb / 4, da, dlb / 8, xsize, ysize, nchan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                                   (const mlib_d64 **) table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
  return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
/***************************************************************/