jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageLookUp_Bit.c
author vadim
Fri, 13 May 2016 11:31:05 +0300
changeset 38415 acea5f7d354b
parent 25859 3317bb8137f4
permissions -rw-r--r--
8047931: Remove unused medialib code Reviewed-by: bae
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
 * FUNCTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *      mlib_ImageLookUp_Bit_U8 - table lookup
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * SYNOPSIS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *      void mlib_ImageLookUp_Bit_U8(src, slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *                                   dst, dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *                                   xsize, ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *                                   csize, 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
 *      src     pointer to input image (BIT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *      slb     stride of input image (in pixels)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *      dst     pointer to output image (BYTE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *      dlb     stride of output image (in pixels)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *      xsize   image width
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *      ysize   image height
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *      csize   number of channels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *      table   lookup table
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * DESCRIPTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *      dst = table[src] (c, vis version)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#include "mlib_image.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#include "mlib_ImageLookUp.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
#define MAX_WIDTH  512
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
#ifdef i386 /* do not copy by double data type for x86 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
  mlib_u32 int0, int1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
} two_uint;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
#define TYPE_64BIT two_uint
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
#define TYPE_32BIT mlib_u32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
#define DTYPE      two_uint
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
#elif defined(_NO_LONGLONG)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
#define TYPE_64BIT mlib_d64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
#define TYPE_32BIT mlib_f32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
#define DTYPE      mlib_d64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
#define TYPE_64BIT mlib_d64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
#define TYPE_32BIT mlib_f32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
#define DTYPE      mlib_u64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
#endif /* i386 ( do not copy by double data type for x86 ) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
typedef union {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
  TYPE_64BIT d64;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
  struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    TYPE_32BIT f0, f1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
  } f32s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
} d64_2_f32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
static const mlib_u32 mlib_bit_mask[16] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
  0x00000000u, 0xFF000000u, 0x00FF0000u, 0xFFFF0000u,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
  0x0000FF00u, 0xFF00FF00u, 0x00FFFF00u, 0xFFFFFF00u,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
  0x000000FFu, 0xFF0000FFu, 0x00FF00FFu, 0xFFFF00FFu,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
  0x0000FFFFu, 0xFF00FFFFu, 0x00FFFFFFu, 0xFFFFFFFFu
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
static const mlib_u32 mlib_bit_mask_2[4] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
  0x00000000u, 0xFFFF0000u, 0x0000FFFFu, 0xFFFFFFFFu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
static const mlib_u32 mlib_bit_mask_3[3*4] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
  0x00000000u, 0xFF000000u, 0x00FFFFFFu, 0xFFFFFFFFu,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
  0x00000000u, 0xFFFF0000u, 0x0000FFFFu, 0xFFFFFFFFu,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
  0x00000000u, 0xFFFFFF00u, 0x000000FFu, 0xFFFFFFFFu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
static const mlib_u32 mlib_bit_mask[16] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
  0x00000000u, 0x000000FFu, 0x0000FF00u, 0x0000FFFFu,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
  0x00FF0000u, 0x00FF00FFu, 0x00FFFF00u, 0x00FFFFFFu,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
  0xFF000000u, 0xFF0000FFu, 0xFF00FF00u, 0xFF00FFFFu,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
  0xFFFF0000u, 0xFFFF00FFu, 0xFFFFFF00u, 0xFFFFFFFFu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
static const mlib_u32 mlib_bit_mask_2[4] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
  0x00000000u, 0x0000FFFFu, 0xFFFF0000u, 0xFFFFFFFFu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
static const mlib_u32 mlib_bit_mask_3[3*4] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
  0x00000000u, 0x000000FFu, 0xFFFFFF00u, 0xFFFFFFFFu,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
  0x00000000u, 0x0000FFFFu, 0xFFFF0000u, 0xFFFFFFFFu,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
  0x00000000u, 0x00FFFFFFu, 0xFF000000u, 0xFFFFFFFFu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
#endif /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
mlib_status mlib_ImageLookUp_Bit_U8_1(const mlib_u8 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                                      mlib_s32      slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                                      mlib_u8       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                                      mlib_s32      dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                                      mlib_s32      xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                                      mlib_s32      ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                                      mlib_s32      nchan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                                      mlib_s32      bitoff,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                                      const mlib_u8 **table)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
  mlib_s32 i, j, n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
  TYPE_64BIT dd_array[256];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
  mlib_u8  buff_lcl[MAX_WIDTH/8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
  mlib_u8  *buff = (mlib_u8*)buff_lcl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
  mlib_u32 val0, val1, *p_dd = (mlib_u32*)dd_array;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
  if (xsize > MAX_WIDTH) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    buff = mlib_malloc((xsize + 7)/8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    if (buff == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
  val0 = table[0][0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
  val1 = table[0][1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
  val0 |= (val0 << 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
  val1 |= (val1 << 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
  val0 |= (val0 << 16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
  val1 |= (val1 << 16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
  /* calculate lookup table */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
  for (i = 0; i < 16; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    mlib_u32 v, mask = mlib_bit_mask[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    v = (val0 &~ mask) | (val1 & mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    for (j = 0; j < 16; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
      p_dd[2*(16*i + j)] = v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    for (j = 0; j < 16; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
      p_dd[2*(i + 16*j) + 1] = v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    mlib_s32 s0, size = xsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    mlib_u8  *dp = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    mlib_u8  *sp = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    mlib_u8  *sa;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    TYPE_64BIT *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    mlib_s32 doff, boff = bitoff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    if ((mlib_addr)dp & 7) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
      /* result of (dp & 7) certainly fits into mlib_s32 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
      doff = 8 - ((mlib_s32) ((mlib_addr)dp & 7));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
      if (doff > xsize) doff = xsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
      for (n = 0; n < doff; n++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        dp[n] = table[0][(sp[0] >> (7 - boff)) & 0x1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        boff++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        if (boff >= 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
          sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
          boff -= 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        size--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
      dp += doff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    if (boff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
      mlib_ImageCopy_bit_na(sp, buff, size, boff, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
      sp = buff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    sa = (mlib_u8*)sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    da = (TYPE_64BIT*)dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    i  = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    if ((mlib_addr)sa & 1 && size >= 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
      *da++ = dd_array[*sa++];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
      i += 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    for (; i <= (size - 16); i += 16) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
      s0 = *(mlib_u16*)sa;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
      *da++ = dd_array[s0 & 0xFF];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
      *da++ = dd_array[s0 >> 8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
      *da++ = dd_array[s0 >> 8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
      *da++ = dd_array[s0 & 0xFF];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
#endif /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
      sa += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    if (i <= (size - 8)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
      *da++ = dd_array[*sa++];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
      i += 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    if (i < size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
#ifdef _NO_LONGLONG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
      mlib_u32 emask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
      val0 = sa[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
      val1 = p_dd[2*val0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
      if (i < (size - 4)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        ((mlib_u32*)da)[0] = val1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        da = (TYPE_64BIT *) ((mlib_u8 *)da + 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        i += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        val1 = p_dd[2*val0+1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
      emask = (mlib_u32)((mlib_s32)(-1)) >> ((4 - (size - i)) * 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
      emask = (mlib_s32)(-1) << ((4 - (size - i)) * 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
#endif /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
      ((mlib_u32*)da)[0] = (val1 & emask) | (((mlib_u32*)da)[0] &~ emask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
#else /* _NO_LONGLONG */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
      mlib_u64 emask = (mlib_u64)((mlib_s64)(-1)) >> ((8 - (size - i)) * 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
      mlib_u64 emask = (mlib_s64)(-1) << ((8 - (size - i)) * 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
#endif /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
      ((mlib_u64*)da)[0] = (((mlib_u64*)dd_array)[sa[0]] & emask) | (((mlib_u64*)da)[0] &~ emask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
#endif /* _NO_LONGLONG */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    src += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    dst += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
  if (buff != (mlib_u8*)buff_lcl) mlib_free(buff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
mlib_status mlib_ImageLookUp_Bit_U8_2(const mlib_u8 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                                      mlib_s32      slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                                      mlib_u8       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                                      mlib_s32      dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                                      mlib_s32      xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                                      mlib_s32      ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                                      mlib_s32      nchan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                                      mlib_s32      bitoff,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                                      const mlib_u8 **table)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
  mlib_s32 i, j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
  mlib_s32 s0, size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
#ifdef _NO_LONGLONG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
  mlib_u32 emask, dd1, dd2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
#else /* _NO_LONGLONG */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
  mlib_u64 emask, dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
#endif /* _NO_LONGLONG */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
  DTYPE    dd_array[16];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
  mlib_u32 *p_dd = (mlib_u32*)dd_array;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
  mlib_d64 buff_lcl[(MAX_WIDTH + MAX_WIDTH/8)/8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
  mlib_u8  *buff = (mlib_u8*)buff_lcl, *buffs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
  mlib_u32 val0, val1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
  size = xsize * 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
  if (size > MAX_WIDTH) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    buff = mlib_malloc(size + (size + 7)/8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    if (buff == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
  buffs = buff + size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
  val0 = table[0][0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
  val1 = table[0][1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
  val0 = val0 | (table[1][0] << 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
  val1 = val1 | (table[1][1] << 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
  val0 = (val0 << 8) | table[1][0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
  val1 = (val1 << 8) | table[1][1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
#endif /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
  val0 |= (val0 << 16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
  val1 |= (val1 << 16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
  /* calculate lookup table */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
  for (i = 0; i < 4; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    mlib_u32 v, mask = mlib_bit_mask_2[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    v = (val0 &~ mask) | (val1 & mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    for (j = 0; j < 4; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
      p_dd[2*(4*i + j)] = v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
      p_dd[2*(i + 4*j) + 1] = v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    mlib_u8  *dp = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    mlib_u8  *sp = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    mlib_u8  *sa;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    DTYPE    *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    if ((mlib_addr)dp & 7) dp = buff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    if (bitoff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
      mlib_ImageCopy_bit_na(sp, buffs, size, bitoff, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
      sp = buffs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    sa = (mlib_u8*)sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    da = (DTYPE*)dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    for (i = 0; i <= (size - 16); i += 16) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
      s0 = *sa++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
      *da++ = dd_array[s0 >> 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
      *da++ = dd_array[s0 & 0xF];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    if (i < size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
      s0 = *sa++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
#ifdef _NO_LONGLONG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
      dd1 = p_dd[2*(s0 >> 4)];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
      dd2 = p_dd[2*(s0 >> 4)+1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
      if (i < (size - 8)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        ((mlib_u32*)da)[0] = dd1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        ((mlib_u32*)da)[1] = dd2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        da++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        i += 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        dd1 = p_dd[2*(s0 & 0xf)];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        dd2 = p_dd[2*(s0 & 0xf)+1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
      if (i < (size - 4)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        ((mlib_u32*)da)[0] = dd1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        da = (DTYPE *) ((mlib_u8 *)da + 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        i += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        dd1 = dd2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
      emask = (mlib_u32)((mlib_s32)(-1)) >> ((4 - (size - i)) * 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
      emask = (mlib_s32)(-1) << ((4 - (size - i)) * 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
#endif /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
      ((mlib_u32*)da)[0] = (dd1 & emask) | (((mlib_u32*)da)[0] &~ emask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
#else /* _NO_LONGLONG */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
      dd = ((mlib_u64*)dd_array)[s0 >> 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
      if (i < (size - 8)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        ((mlib_u64*)da)[0] = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        da++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        i += 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        dd = ((mlib_u64*)dd_array)[s0 & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
      emask = (mlib_u64)((mlib_s64)(-1)) >> ((8 - (size - i)) * 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
      emask = (mlib_s64)(-1) << ((8 - (size - i)) * 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
#endif /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
      ((mlib_u64*)da)[0] = (dd & emask) | (((mlib_u64*)da)[0] &~ emask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
#endif /* _NO_LONGLONG */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    if (dp != dst) mlib_ImageCopy_na(dp, dst, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    src += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    dst += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
  if (buff != (mlib_u8*)buff_lcl) mlib_free(buff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
mlib_status mlib_ImageLookUp_Bit_U8_3(const mlib_u8 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                                      mlib_s32      slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                                      mlib_u8       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                                      mlib_s32      dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                                      mlib_s32      xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                                      mlib_s32      ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                                      mlib_s32      nchan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                                      mlib_s32      bitoff,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                                      const mlib_u8 **table)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
  mlib_s32 i, j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
  mlib_s32 s0, size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
  mlib_u32 emask, dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
  TYPE_64BIT d_array01[16], d_array12[16];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
  TYPE_64BIT buff_lcl[(MAX_WIDTH + MAX_WIDTH/8)/8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
  mlib_u8  *buff = (mlib_u8*)buff_lcl, *buffs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
  mlib_u32 l0, h0, v0, l1, h1, v1, l2, h2, v2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
  size = 3 * xsize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
  if (size > MAX_WIDTH) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    buff = mlib_malloc(size + (size + 7)/8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    if (buff == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
  buffs = buff + size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
  l0 = (table[0][0] << 24) | (table[2][0] << 16) | (table[1][0] << 8) | (table[0][0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
  h0 = (table[0][1] << 24) | (table[2][1] << 16) | (table[1][1] << 8) | (table[0][1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
  l1 = (l0 >> 8); l1 |= (l1 << 24);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
  h1 = (h0 >> 8); h1 |= (h1 << 24);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
  l2 = (l1 >> 8); l2 |= (l2 << 24);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
  h2 = (h1 >> 8); h2 |= (h2 << 24);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
  l0 = (table[0][0] << 24) | (table[1][0] << 16) | (table[2][0] << 8) | (table[0][0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
  h0 = (table[0][1] << 24) | (table[1][1] << 16) | (table[2][1] << 8) | (table[0][1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
  l1 = (l0 << 8); l1 |= (l1 >> 24);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
  h1 = (h0 << 8); h1 |= (h1 >> 24);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
  l2 = (l1 << 8); l2 |= (l2 >> 24);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
  h2 = (h1 << 8); h2 |= (h2 >> 24);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
#endif /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
  /* calculate lookup table */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
  for (i = 0; i < 16; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    mlib_u32 mask0 = mlib_bit_mask_3[i >> 2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    mlib_u32 mask1 = mlib_bit_mask_3[4 + ((i >> 1) & 3)];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    mlib_u32 mask2 = mlib_bit_mask_3[8 + (i & 3)];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    v0 = (l0 &~ mask0) | (h0 & mask0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    v1 = (l1 &~ mask1) | (h1 & mask1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    v2 = (l2 &~ mask2) | (h2 & mask2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    ((mlib_u32*)d_array01)[2*i    ] = v0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    ((mlib_u32*)d_array01)[2*i + 1] = v1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    ((mlib_u32*)d_array12)[2*i    ] = v1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    ((mlib_u32*)d_array12)[2*i + 1] = v2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    mlib_u8  *dp = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    mlib_u8  *sp = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    mlib_u8  *sa;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    mlib_u32 *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    if ((mlib_addr)dp & 7) dp = buff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    if (bitoff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
      mlib_ImageCopy_bit_na(sp, buffs, size, bitoff, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
      sp = buffs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    sa = (mlib_u8*)sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    da = (mlib_u32*)dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    for (i = 0; i <= (size - 24); i += 24) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
      d64_2_f32 dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
      s0 = *sa++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
      ((TYPE_64BIT*)da)[0] = *(d_array01 + (s0 >> 4));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
      dd.f32s.f0 = ((TYPE_32BIT*)(d_array12 + (s0 >> 4)))[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
      dd.f32s.f1 = ((TYPE_32BIT*)(d_array01 + (s0 & 0xF)))[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
      ((TYPE_64BIT*)da)[1] = dd.d64;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
      ((TYPE_64BIT*)da)[2] = *(d_array12 + (s0 & 0xF));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
      da += 6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    if (i < size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
      s0 = *sa++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
      dd = ((mlib_u32*)(d_array01 + (s0 >> 4)))[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
      if (i < (size - 4)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        *da++ = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        i += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        dd = ((mlib_u32*)(d_array12 + (s0 >> 4)))[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
      if (i < (size - 4)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        *da++ = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        i += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        dd = ((mlib_u32*)(d_array12 + (s0 >> 4)))[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
      if (i < (size - 4)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        *da++ = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        i += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        dd = ((mlib_u32*)(d_array01 + (s0 & 0xF)))[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
      if (i < (size - 4)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        *da++ = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        i += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        dd = ((mlib_u32*)(d_array12 + (s0 & 0xF)))[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
      if (i < (size - 4)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        *da++ = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        i += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        dd = ((mlib_u32*)(d_array12 + (s0 & 0xF)))[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
      emask = (mlib_u32)((mlib_s32)(-1)) >> ((4 - (size - i)) * 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
      emask = (mlib_s32)(-1) << ((4 - (size - i)) * 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
#endif /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
      da[0] = (dd & emask) | (da[0] &~ emask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    if (dp != dst) mlib_ImageCopy_na(dp, dst, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
    src += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    dst += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
  if (buff != (mlib_u8*)buff_lcl) mlib_free(buff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
mlib_status mlib_ImageLookUp_Bit_U8_4(const mlib_u8 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                                      mlib_s32      slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                                      mlib_u8       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                                      mlib_s32      dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                                      mlib_s32      xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                                      mlib_s32      ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                                      mlib_s32      nchan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                                      mlib_s32      bitoff,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                                      const mlib_u8 **table)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
  mlib_s32 i, j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
  mlib_s32 s0, size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
  DTYPE    dd_array0[16], dd_array1[16], lh[4], dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
  mlib_d64 buff_lcl[(MAX_WIDTH + MAX_WIDTH/8)/8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
  mlib_u8  *buff = (mlib_u8*)buff_lcl, *buffs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
  mlib_u32 l, h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
  size = xsize * 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
  if (size > MAX_WIDTH) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
    buff = mlib_malloc(size + (size + 7)/8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    if (buff == NULL) return MLIB_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
  buffs = buff + size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
  l = (table[3][0] << 24) | (table[2][0] << 16) | (table[1][0] << 8) | (table[0][0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
  h = (table[3][1] << 24) | (table[2][1] << 16) | (table[1][1] << 8) | (table[0][1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
  l = (table[0][0] << 24) | (table[1][0] << 16) | (table[2][0] << 8) | (table[3][0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
  h = (table[0][1] << 24) | (table[1][1] << 16) | (table[2][1] << 8) | (table[3][1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
#endif /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
  ((mlib_u32*)lh)[0] = l;  ((mlib_u32*)lh)[1] = l;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
  ((mlib_u32*)lh)[2] = l;  ((mlib_u32*)lh)[3] = h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
  ((mlib_u32*)lh)[4] = h;  ((mlib_u32*)lh)[5] = l;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
  ((mlib_u32*)lh)[6] = h;  ((mlib_u32*)lh)[7] = h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
  /* calculate lookup table */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
  dd_array0[ 0] = lh[0];  dd_array1[ 0] = lh[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
  dd_array0[ 1] = lh[0];  dd_array1[ 1] = lh[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
  dd_array0[ 2] = lh[0];  dd_array1[ 2] = lh[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
  dd_array0[ 3] = lh[0];  dd_array1[ 3] = lh[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
  dd_array0[ 4] = lh[1];  dd_array1[ 4] = lh[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
  dd_array0[ 5] = lh[1];  dd_array1[ 5] = lh[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
  dd_array0[ 6] = lh[1];  dd_array1[ 6] = lh[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
  dd_array0[ 7] = lh[1];  dd_array1[ 7] = lh[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
  dd_array0[ 8] = lh[2];  dd_array1[ 8] = lh[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
  dd_array0[ 9] = lh[2];  dd_array1[ 9] = lh[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
  dd_array0[10] = lh[2];  dd_array1[10] = lh[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
  dd_array0[11] = lh[2];  dd_array1[11] = lh[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
  dd_array0[12] = lh[3];  dd_array1[12] = lh[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
  dd_array0[13] = lh[3];  dd_array1[13] = lh[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
  dd_array0[14] = lh[3];  dd_array1[14] = lh[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
  dd_array0[15] = lh[3];  dd_array1[15] = lh[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    mlib_u8  *dp = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    mlib_u8  *sp = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    mlib_u8  *sa;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
    DTYPE    *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    if ((mlib_addr)dp & 7) dp = buff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    if (bitoff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
      mlib_ImageCopy_bit_na(sp, buffs, size, bitoff, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
      sp = buffs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    sa = (mlib_u8*)sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    da = (DTYPE*)dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    for (i = 0; i <= (size - 32); i += 32) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
      s0 = *sa++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
      *da++ = dd_array0[s0 >> 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
      *da++ = dd_array1[s0 >> 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
      *da++ = dd_array0[s0 & 0xF];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
      *da++ = dd_array1[s0 & 0xF];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    if (i < size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
      s0 = *sa++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
      dd = dd_array0[s0 >> 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
      if (i <= (size - 8)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        *da++ = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        i += 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        dd = dd_array1[s0 >> 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
      if (i <= (size - 8)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        *da++ = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
        i += 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
        dd = dd_array0[s0 & 0xF];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
      if (i <= (size - 8)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        *da++ = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        i += 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        dd = dd_array1[s0 & 0xF];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
      if (i < size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        *(mlib_u32*)da = *(mlib_u32*) & dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    if (dp != dst) mlib_ImageCopy_na(dp, dst, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    src += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
    dst += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
  if (buff != (mlib_u8*)buff_lcl) mlib_free(buff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
/***************************************************************/