jdk/src/share/native/sun/awt/medialib/mlib_c_ImageCopy.c
author bae
Fri, 25 Mar 2011 12:50:59 +0300
changeset 8939 04615dca2a76
parent 5506 202f599c92aa
permissions -rw-r--r--
6989717: media native code compiler warnings Reviewed-by: jgodinez, prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * FUNCTIONS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *      mlib_ImageCopy - Direct copy from one image to another.
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
 *      mlib_status mlib_ImageCopy(mlib_image       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *                                 const mlib_image *src);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * ARGUMENT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *      dst     pointer to output or destination image
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *      src     pointer to input or source image
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * RESTRICTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *      src and dst must have the same size, type and number of channels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *      They can have 1, 2, 3 or 4 channels of MLIB_BIT, MLIB_BYTE, MLIB_SHORT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *      MLIB_USHORT, MLIB_INT, MLIB_FLOAT or MLIB_DOUBLE data type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * DESCRIPTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *      Direct copy from one image to another
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
#include <stdlib.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#include "mlib_image.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#include "mlib_ImageCheck.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#include "mlib_ImageCopy.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
#ifdef _MSC_VER
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
#pragma optimize("", off)                   /* Fix bug 4195132 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
#endif /* _MSC_VER */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
/* do not perform the coping by mlib_d64 data type for x86 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
#ifdef i386
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
  mlib_s32 int0, int1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
} two_int;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
#define TYPE_64BIT two_int
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
#else /* i386 */
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
#endif /* i386 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
static void mlib_c_ImageCopy_u8(const mlib_image *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                                mlib_image       *dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
static void mlib_c_ImageCopy_s16(const mlib_image *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                                 mlib_image       *dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
static void mlib_c_ImageCopy_s32(const mlib_image *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                                 mlib_image       *dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
static void mlib_c_ImageCopy_d64(const mlib_image *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
                                 mlib_image       *dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
static void mlib_c_ImageCopy_a1(const TYPE_64BIT *sp,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                                TYPE_64BIT       *dp,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                                mlib_s32         size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
mlib_status mlib_ImageCopy(mlib_image       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                           const mlib_image *src)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
  mlib_s32 s_offset, d_offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
  mlib_s32 size, s_stride, d_stride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
  mlib_s32 width;                                     /* width in bytes of src and dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
  mlib_s32 height;                                    /* height in lines of src and dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
  mlib_u8 *sa, *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
  mlib_s32 j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
  MLIB_IMAGE_CHECK(src);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
  MLIB_IMAGE_CHECK(dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
  MLIB_IMAGE_TYPE_EQUAL(src, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
  MLIB_IMAGE_CHAN_EQUAL(src, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
  MLIB_IMAGE_SIZE_EQUAL(src, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
  switch (mlib_ImageGetType(dst)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    case MLIB_BIT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
      width = mlib_ImageGetWidth(dst) * mlib_ImageGetChannels(dst); /* size in bits */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
      height = mlib_ImageGetHeight(src);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
      sa = (mlib_u8 *) mlib_ImageGetData(src);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
      da = (mlib_u8 *) mlib_ImageGetData(dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
      if (!mlib_ImageIsNotOneDvector(src) && !mlib_ImageIsNotOneDvector(dst)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        size = height * (width >> 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        if (!mlib_ImageIsNotAligned8(src) && !mlib_ImageIsNotAligned8(dst) && ((size & 7) == 0)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
          mlib_c_ImageCopy_a1((TYPE_64BIT *) sa, (TYPE_64BIT *) da, size >> 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
          mlib_ImageCopy_na(sa, da, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
      else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        s_stride = mlib_ImageGetStride(src);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        d_stride = mlib_ImageGetStride(dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        s_offset = mlib_ImageGetBitOffset(src); /* in bits */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        d_offset = mlib_ImageGetBitOffset(dst); /* in bits */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        if (s_offset == d_offset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
          for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            mlib_ImageCopy_bit_al(sa, da, width, s_offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            sa += s_stride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            da += d_stride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
          for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            mlib_ImageCopy_bit_na(sa, da, width, s_offset, d_offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            sa += s_stride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            da += d_stride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
      break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    case MLIB_BYTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
      mlib_c_ImageCopy_u8(src, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
      break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    case MLIB_SHORT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    case MLIB_USHORT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
      mlib_c_ImageCopy_s16(src, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
      break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    case MLIB_INT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    case MLIB_FLOAT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
      mlib_c_ImageCopy_s32(src, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
      break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    case MLIB_DOUBLE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
      mlib_c_ImageCopy_d64(src, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
      break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
      return MLIB_FAILURE;                  /* MLIB_BIT is not supported here */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
  return MLIB_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
#define PREPAREVARS(type)                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
  type *psrc = (type *) mlib_ImageGetData(src);                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
  type *pdst = (type *) mlib_ImageGetData(dst);                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
  mlib_s32 src_height = mlib_ImageGetHeight(src);                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
  mlib_s32 src_width  = mlib_ImageGetWidth(src);                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
  mlib_s32 src_stride = mlib_ImageGetStride(src) / sizeof(type); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
  mlib_s32 dst_stride = mlib_ImageGetStride(dst) / sizeof(type); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
  mlib_s32 chan = mlib_ImageGetChannels(dst);                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
  mlib_s32 i, j;                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
  src_width *= chan;                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
  if (src_width == src_stride && src_width == dst_stride) {      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    src_width *= src_height;                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    src_height = 1;                                              \
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
#define STRIP(pd, ps, w, h, data_type) {                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
  data_type s0, s1;                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
  for ( i = 0; i < h; i++ ) {                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    if (j = w & 1)                                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
      pd[i * dst_stride] = ps[i * src_stride];                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    for (; j < w; j += 2) {                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
      s0 = ps[i * src_stride + j];                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
      s1 = ps[i * src_stride + j + 1];                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
      pd[i * dst_stride + j]   = s0;                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
      pd[i * dst_stride + j + 1] = s1;                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    }                                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
  }                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
 * Both bit offsets of source and distination are the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
void mlib_ImageCopy_bit_al(const mlib_u8 *sa,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                           mlib_u8       *da,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                           mlib_s32      size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                           mlib_s32      offset)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
  mlib_s32 b_size, i, j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
  TYPE_64BIT *sp, *dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
  mlib_u8 mask0 = 0xFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
  mlib_u8 src, mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
  if (size <= 0) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
  if (size <= (8 - offset)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    mask = mask0 << (8 - size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    mask >>= offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    src = da[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    da[0] = (src & (~mask)) | (sa[0] & mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
  mask = mask0 >> offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
  src = da[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
  da[0] = (src & (~mask)) | (sa[0] & mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
  da++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
  sa++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
  size = size - 8 + offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
  b_size = size >> 3;                       /* size in bytes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
  for (j = 0; (j < b_size) && (((mlib_addr) da & 7) != 0); j++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    *da++ = *sa++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
  if ((((mlib_addr) sa ^ (mlib_addr) da) & 7) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    sp = (TYPE_64BIT *) sa;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    dp = (TYPE_64BIT *) da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    for (i = 0; j <= (b_size - 8); j += 8, i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
      dp[i] = sp[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    sa += i << 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    da += i << 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
  else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
#ifdef _NO_LONGLONG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    if ((((mlib_addr) sa ^ (mlib_addr) da) & 3) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
      mlib_u32 *pws, *pwd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
      pws = (mlib_u32 *) sa;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
      pwd = (mlib_u32 *) da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
      for (i = 0; j <= (b_size - 4); j += 4, i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        pwd[i] = pws[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
      sa += i << 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
      da += i << 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
      mlib_u32 *pws, *pwd, src0, src1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
      mlib_s32 lshift = (mlib_addr) sa & 3, rshift;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
      pwd = (mlib_u32 *) da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
      pws = (mlib_u32 *) (sa - lshift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
      lshift <<= 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
      rshift = 32 - lshift;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
      src1 = pws[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
      for (i = 0; j <= (b_size - 4); j += 4, i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        src0 = src1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        src1 = pws[i + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        pwd[i] = (src0 >> lshift) | (src1 << rshift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        pwd[i] = (src0 << lshift) | (src1 >> rshift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
#endif /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
      sa += i << 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
      da += i << 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    mlib_u64 *pws, *pwd, src0, src1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    mlib_s32 lshift = (mlib_s32) ((mlib_addr) sa & 7), rshift;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    pwd = (mlib_u64 *) da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    pws = (mlib_u64 *) (sa - lshift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    lshift <<= 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    rshift = 64 - lshift;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    src1 = pws[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    for (i = 0; j <= (b_size - 8); j += 8, i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
      src0 = src1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
      src1 = pws[i + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
      pwd[i] = (src0 << lshift) | (src1 >> rshift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    sa += i << 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    da += i << 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
#endif /* _NO_LONGLONG */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
  for (; j < b_size; j++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    *da++ = *sa++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
  j = size & 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
  if (j > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    mask = mask0 << (8 - j);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    src = da[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    da[0] = (src & (~mask)) | (sa[0] & mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
void mlib_c_ImageCopy_u8(const mlib_image *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                         mlib_image       *dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
  PREPAREVARS(mlib_u8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
  if (src_width < 16) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    STRIP(pdst, psrc, src_width, src_height, mlib_u8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
  for (i = 0; i < src_height; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    mlib_u8 *psrc_row = psrc + i * src_stride, *pdst_row = pdst + i * dst_stride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    if (!(((mlib_addr) psrc_row ^ (mlib_addr) pdst_row) & 7)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
      for (j = 0; j < (mlib_s32) ((8 - (mlib_addr) psrc_row) & 7); j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        pdst_row[j] = psrc_row[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
      for (; j <= (src_width - 8); j += 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        TYPE_64BIT dsrc0 = *((TYPE_64BIT *) (psrc_row + j));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        *((TYPE_64BIT *) (pdst_row + j)) = dsrc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
#ifdef _NO_LONGLONG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
      for (j = 0; j < (mlib_s32) ((4 - (mlib_addr) pdst_row) & 3); j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        pdst_row[j] = psrc_row[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
      if (!(((mlib_addr) psrc_row ^ (mlib_addr) pdst_row) & 3)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        for (; j <= (src_width - 4); j += 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
          *((mlib_s32 *) (pdst_row + j)) = *((mlib_s32 *) (psrc_row + j));
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 {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        mlib_u32 *ps, shl, shr, src0, src1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        ps = (mlib_u32 *) (psrc_row + j);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        shl = (mlib_addr) ps & 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        ps = (mlib_u32 *) ((mlib_addr) ps - shl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        shl <<= 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        shr = 32 - shl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        src1 = ps[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        for (; j <= (src_width - 4); j += 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
          src0 = src1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
          src1 = ps[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
          *((mlib_s32 *) (pdst_row + j)) = (src0 >> shl) | (src1 << shr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
          *((mlib_s32 *) (pdst_row + j)) = (src0 << shl) | (src1 >> shr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
#endif /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
          ps++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
      for (j = 0; j < (mlib_s32) ((8 - (mlib_addr) pdst_row) & 7); j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        pdst_row[j] = psrc_row[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        mlib_s32 shl, shr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        mlib_u64 *ps, src0, src1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        ps = (mlib_u64 *) (psrc_row + j);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        /* shl and shr are in range [0, 64] */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        shl = (mlib_s32) ((mlib_addr) ps & 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        ps = (mlib_u64 *) ((mlib_addr) ps - shl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        shl <<= 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        shr = 64 - shl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        src1 = ps[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        for (; j <= (src_width - 8); j += 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
          src0 = src1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
          src1 = ps[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
          *((mlib_s64 *) (pdst_row + j)) = (src0 >> shl) | (src1 << shr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
          *((mlib_s64 *) (pdst_row + j)) = (src0 << shl) | (src1 >> shr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
#endif /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
          ps++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
#endif /* _NO_LONGLONG */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    for (; j < src_width; j++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
      pdst_row[j] = psrc_row[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
void mlib_c_ImageCopy_s16(const mlib_image       *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                          mlib_image *dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
  PREPAREVARS(mlib_u16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
  if (src_width < 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    STRIP(pdst, psrc, src_width, src_height, mlib_u16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
  for (i = 0; i < src_height; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    mlib_u16 *psrc_row = psrc + i * src_stride, *pdst_row = pdst + i * dst_stride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    if (!(((mlib_addr) psrc_row ^ (mlib_addr) pdst_row) & 7)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
      for (j = 0; j < (mlib_s32) (((8 - (mlib_addr) psrc_row) & 7) >> 1); j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        pdst_row[j] = psrc_row[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
      for (; j <= (src_width - 4); j += 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        TYPE_64BIT dsrc0 = *((TYPE_64BIT *) (psrc_row + j));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        *((TYPE_64BIT *) (pdst_row + j)) = dsrc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
#ifdef _NO_LONGLONG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
      if (j = (((mlib_addr) pdst_row & 2) != 0)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        pdst_row[0] = psrc_row[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
      if (!(((mlib_addr) psrc_row ^ (mlib_addr) pdst_row) & 3)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        for (; j <= (src_width - 2); j += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
          *((mlib_s32 *) (pdst_row + j)) = *((mlib_s32 *) (psrc_row + j));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
      else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        mlib_u32 *ps, src0, src1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        ps = (mlib_u32 *) (psrc_row + j - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        src1 = ps[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        for (; j <= (src_width - 2); j += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
          src0 = src1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
          src1 = ps[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
          *((mlib_s32 *) (pdst_row + j)) = (src0 >> 16) | (src1 << 16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
          *((mlib_s32 *) (pdst_row + j)) = (src0 << 16) | (src1 >> 16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
#endif /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
          ps++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
      for (j = 0; j < (mlib_s32) (((8 - (mlib_addr) pdst_row) & 7) >> 1); j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        pdst_row[j] = psrc_row[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        mlib_s32 shl, shr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        mlib_u64 *ps, src0, src1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        ps = (mlib_u64 *) (psrc_row + j);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        shl = (mlib_s32) ((mlib_addr) ps & 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        ps = (mlib_u64 *) ((mlib_addr) ps - shl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        shl <<= 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        shr = 64 - shl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        src1 = ps[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        for (; j <= (src_width - 4); j += 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
          src0 = src1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
          src1 = ps[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
          *((mlib_s64 *) (pdst_row + j)) = (src0 >> shl) | (src1 << shr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
          *((mlib_s64 *) (pdst_row + j)) = (src0 << shl) | (src1 >> shr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
#endif /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
          ps++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
#endif /* _NO_LONGLONG */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    for (; j < src_width; j++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
      pdst_row[j] = psrc_row[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
void mlib_c_ImageCopy_s32(const mlib_image       *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                          mlib_image *dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
  PREPAREVARS(mlib_u32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
  if (src_width < 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    STRIP(pdst, psrc, src_width, src_height, mlib_u32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
  for (i = 0; i < src_height; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    mlib_u32 *psrc_row = psrc + i * src_stride, *pdst_row = pdst + i * dst_stride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    if (!(((mlib_addr) psrc_row ^ (mlib_addr) pdst_row) & 7)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
      if (j = ((mlib_s32) ((mlib_addr) psrc_row & 4) >> 2)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        pdst_row[0] = psrc_row[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
      for (; j <= (src_width - 2); j += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        TYPE_64BIT dsrc0 = *((TYPE_64BIT *) (psrc_row + j));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        *((TYPE_64BIT *) (pdst_row + j)) = dsrc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
#ifdef _NO_LONGLONG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
      for (j = 0; j <= (src_width - 1); j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        *((mlib_s32 *) (pdst_row + j)) = *((mlib_s32 *) (psrc_row + j));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        mlib_u64 *ps, src0, src1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        if (j = ((mlib_s32) ((mlib_addr) pdst_row & 4) >> 2))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
          pdst_row[0] = psrc_row[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        ps = (mlib_u64 *) (psrc_row + j - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        src1 = ps[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        for (; j <= (src_width - 2); j += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
          src0 = src1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
          src1 = ps[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
          *((mlib_s64 *) (pdst_row + j)) = (src0 >> 32) | (src1 << 32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
          *((mlib_s64 *) (pdst_row + j)) = (src0 << 32) | (src1 >> 32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
#endif /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
          ps++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
#endif /* _NO_LONGLONG */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
    for (; j < src_width; j++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
      pdst_row[j] = psrc_row[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
void mlib_c_ImageCopy_d64(const mlib_image       *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                          mlib_image *dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
  PREPAREVARS(mlib_d64);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
  for (i = 0; i < src_height; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    mlib_d64 *psrc_row = psrc + i * src_stride, *pdst_row = pdst + i * dst_stride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    for (j = 0; j < src_width; j++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
      *((mlib_d64 *) (pdst_row + j)) = *((mlib_d64 *) (psrc_row + j));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
 * Both source and destination image data are 1 - d vectors and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
 * 8 - byte aligned. And size is in 8 - bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
void mlib_c_ImageCopy_a1(const TYPE_64BIT *sp,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
                         TYPE_64BIT       *dp,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
                         mlib_s32         size)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
  mlib_s32 i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
  for (i = 0; i < size; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    *dp++ = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
#ifndef _NO_LONGLONG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
#define TYPE    mlib_u64
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
#define BSIZE   64
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
#define SIZE    8
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
#define TYPE    mlib_u32
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
#define BSIZE   32
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
#define SIZE    4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
#endif /* _NO_LONGLONG */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
void mlib_ImageCopy_na(const mlib_u8 *sp,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
                       mlib_u8       *dp,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                       mlib_s32      n)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
  mlib_s32 shr, shl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
  TYPE *tmp, s0, s1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
  if (((mlib_addr) sp ^ (mlib_addr) dp) & 7) {
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 (; (n > 0) && (mlib_addr) dp & (SIZE - 1); n--)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
      *dp++ = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
#ifdef _NO_LONGLONG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    if (((mlib_addr) sp & (SIZE - 1)) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
      for (; n > SIZE; n -= SIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        *(TYPE *) dp = *(TYPE *) sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        dp += SIZE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        sp += SIZE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
#endif /* _NO_LONGLONG */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
      tmp = (TYPE *) ((mlib_addr) sp & ~(SIZE - 1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
      /* shl and shr do not exceed 64 here */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
      shl = (mlib_s32) (((mlib_addr) sp & (SIZE - 1)) << 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
      shr = BSIZE - shl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
      s0 = *tmp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
      for (; n > SIZE; n -= SIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        s1 = *tmp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        *(TYPE *) dp = (s0 >> shl) | (s1 << shr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        *(TYPE *) dp = (s0 << shl) | (s1 >> shr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
#endif /* _LITTLE_ENDIAN */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        s0 = s1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        dp += SIZE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        sp += SIZE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
  else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
    for (; (n > 0) && (mlib_addr) dp & 7; n--)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
      *dp++ = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    for (; n > 8; n -= 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
      *(TYPE_64BIT *) dp = *(TYPE_64BIT *) sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
      dp += 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
      sp += 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
#ifdef __SUNPRO_C
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
#endif /* __SUNPRO_C */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
  for (; n > 0; n--)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
    *dp++ = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
#ifdef _MSC_VER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
#pragma optimize("", on)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
#endif /* _MSC_VER */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
/***************************************************************/