jdk/src/solaris/native/sun/awt/medialib/mlib_v_ImageChannelInsert_1.c
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1998-2003 Sun Microsystems, Inc.  All Rights Reserved.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * FUNCTIONS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *      mlib_v_ImageChannelInsert_U8
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 *      mlib_v_ImageChannelInsert_U8_12_A8D1X8
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *      mlib_v_ImageChannelInsert_U8_12_A8D2X8
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *      mlib_v_ImageChannelInsert_U8_12_D1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *      mlib_v_ImageChannelInsert_U8_12
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *      mlib_v_ImageChannelInsert_U8_13_A8D1X8
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *      mlib_v_ImageChannelInsert_U8_13_A8D2X8
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *      mlib_v_ImageChannelInsert_U8_13_D1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *      mlib_v_ImageChannelInsert_U8_13
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *      mlib_v_ImageChannelInsert_U8_14_A8D1X8
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *      mlib_v_ImageChannelInsert_U8_14_A8D2X8
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *      mlib_v_ImageChannelInsert_U8_14_D1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *      mlib_v_ImageChannelInsert_U8_14
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *      mlib_v_ImageChannelInsert_S16
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *      mlib_v_ImageChannelInsert_S16_12_A8D1X4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *      mlib_v_ImageChannelInsert_S16_12_A8D2X4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *      mlib_v_ImageChannelInsert_S16_12_D1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *      mlib_v_ImageChannelInsert_S16_12
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *      mlib_v_ImageChannelInsert_S16_13_A8D1X4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *      mlib_v_ImageChannelInsert_S16_13_A8D2X4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *      mlib_v_ImageChannelInsert_S16_13_D1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *      mlib_v_ImageChannelInsert_S16_13
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *      mlib_v_ImageChannelInsert_S16_14_A8D1X4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *      mlib_v_ImageChannelInsert_S16_14_A8D2X4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *      mlib_v_ImageChannelInsert_S16_14_D1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *      mlib_v_ImageChannelInsert_S16_14
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *      mlib_v_ImageChannelInsert_S32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *      mlib_v_ImageChannelInsert_D64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * ARGUMENT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 *      src     pointer to source image data
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *      dst     pointer to destination image data
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *      slb     source image line stride in bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *      dlb     destination image line stride in bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *      dsize   image data size in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *      xsize   image width in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *      ysize   image height in lines
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *      cmask   channel mask
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * DESCRIPTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *      Copy the 1-channel source image into the selected channel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 *      of the destination image -- VIS version low level functions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * NOTE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 *      These functions are separated from mlib_v_ImageChannelInsert.c
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *      for loop unrolling and structure clarity.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
#include "vis_proto.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
#include "mlib_image.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
#include "mlib_v_ImageChannelInsert.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
/* general channel insertion: slower due to the inner loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
void mlib_v_ImageChannelInsert_U8(const mlib_u8 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
                                  mlib_s32      slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                                  mlib_u8       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                                  mlib_s32      dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                                  mlib_s32      channels,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                                  mlib_s32      channeld,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                                  mlib_s32      width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                                  mlib_s32      height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                                  mlib_s32      cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
  mlib_u8 *sp;                                        /* pointer for pixel in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
  mlib_u8 *sl;                                        /* pointer for line in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
  mlib_u8 *dp;                                        /* pointer for pixel in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
  mlib_u8 *dl;                                        /* pointer for line in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
  mlib_s32 i, j, k;                                   /* indices for x, y, channel */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
  mlib_s32 deltac[5] = { 0, 1, 1, 1, 1 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
  mlib_s32 inc0, inc1, inc2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
  mlib_u8 s0, s1, s2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
  deltac[channels] = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
  for (i = (channeld - 1), k = 0; i >= 0; i--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    if ((cmask & (1 << i)) == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
      deltac[k]++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
      k++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
  deltac[channels] = channeld;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
  for (i = 1; i < channels; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    deltac[channels] -= deltac[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
  sp = sl = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
  dp = dl = dst + deltac[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
  if (channels == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    inc0 = deltac[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    inc1 = deltac[2] + inc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
      for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        s0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        s1 = sp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        dp[0] = s0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        dp[inc0] = s1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        dp += inc1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        sp += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
      sp = sl += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
      dp = dl += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
  else if (channels == 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    inc0 = deltac[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    inc1 = deltac[2] + inc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    inc2 = deltac[3] + inc1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
      for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        s0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        s1 = sp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        s2 = sp[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        dp[0] = s0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        dp[inc0] = s1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        dp[inc1] = s2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        dp += inc2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        sp += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
      sp = sl += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
      dp = dl += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
/* general channel insertion: slower due to the inner loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
void mlib_v_ImageChannelInsert_D64(const mlib_d64 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                                   mlib_s32       slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                                   mlib_d64       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                                   mlib_s32       dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                                   mlib_s32       channels,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                                   mlib_s32       channeld,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                                   mlib_s32       width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                                   mlib_s32       height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                                   mlib_s32       cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
  mlib_d64 *sp;                                       /* pointer for pixel in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
  mlib_d64 *sl;                                       /* pointer for line in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
  mlib_d64 *dp;                                       /* pointer for pixel in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
  mlib_d64 *dl;                                       /* pointer for line in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
  mlib_s32 i, j, k;                                   /* indices for x, y, channel */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
  mlib_s32 deltac[5] = { 0, 1, 1, 1, 1 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
  mlib_s32 inc0, inc1, inc2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
  mlib_d64 s0, s1, s2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
  deltac[channels] = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
  for (i = (channeld - 1), k = 0; i >= 0; i--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    if ((cmask & (1 << i)) == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
      deltac[k]++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
      k++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
  deltac[channels] = channeld;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
  for (i = 1; i < channels; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    deltac[channels] -= deltac[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
  sp = sl = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
  dp = dl = dst + deltac[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
  if (channels == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
      for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        s0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        dp[0] = s0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        dp += channeld;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
  else if (channels == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    inc0 = deltac[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    inc1 = deltac[2] + inc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
      for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        s0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        s1 = sp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        dp[0] = s0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        dp[inc0] = s1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        dp += inc1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        sp += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
  else if (channels == 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    inc0 = deltac[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    inc1 = deltac[2] + inc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    inc2 = deltac[3] + inc1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
      for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        s0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        s1 = sp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        s2 = sp[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        dp[0] = s0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        dp[inc0] = s1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        dp[inc1] = s2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        dp += inc2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        sp += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
      sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
      dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
/* general channel insertion: slower due to the inner loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
void mlib_v_ImageChannelInsert_S16(const mlib_s16 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                                   mlib_s32       slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                                   mlib_s16       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                                   mlib_s32       dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                                   mlib_s32       channels,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                                   mlib_s32       channeld,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                                   mlib_s32       width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                                   mlib_s32       height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                                   mlib_s32       cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
  mlib_s16 *sp;                                       /* pointer for pixel in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
  mlib_s16 *sl;                                       /* pointer for line in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
  mlib_s16 *dp;                                       /* pointer for pixel in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
  mlib_s16 *dl;                                       /* pointer for line in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
  mlib_s32 i, j, k;                                   /* indices for x, y, channel */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
  mlib_s32 deltac[5] = { 0, 1, 1, 1, 1 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
  mlib_s32 inc0, inc1, inc2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
  mlib_s16 s0, s1, s2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
  deltac[channels] = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
  for (i = (channeld - 1), k = 0; i >= 0; i--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    if ((cmask & (1 << i)) == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
      deltac[k]++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
      k++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
  deltac[channels] = channeld;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
  for (i = 1; i < channels; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    deltac[channels] -= deltac[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
  sp = sl = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
  dp = dl = dst + deltac[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
  if (channels == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    inc0 = deltac[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    inc1 = deltac[2] + inc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
      for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        s0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        s1 = sp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        dp[0] = s0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        dp[inc0] = s1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        dp += inc1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        sp += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
      sp = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
      dp = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
  else if (channels == 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    inc0 = deltac[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    inc1 = deltac[2] + inc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    inc2 = deltac[3] + inc1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
      for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        s0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        s1 = sp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        s2 = sp[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        dp[0] = s0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        dp[inc0] = s1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        dp[inc1] = s2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        dp += inc2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        sp += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
      sp = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
      dp = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
/* general channel insertion: slower due to the inner loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
void mlib_v_ImageChannelInsert_S32(const mlib_s32 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                                   mlib_s32       slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                                   mlib_s32       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                                   mlib_s32       dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                                   mlib_s32       channels,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                                   mlib_s32       channeld,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                                   mlib_s32       width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                                   mlib_s32       height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                                   mlib_s32       cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
  mlib_s32 *sp;                                       /* pointer for pixel in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
  mlib_s32 *sl;                                       /* pointer for line in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
  mlib_s32 *dp;                                       /* pointer for pixel in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
  mlib_s32 *dl;                                       /* pointer for line in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
  mlib_s32 i, j, k;                                   /* indices for x, y, channel */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
  mlib_s32 deltac[5] = { 0, 1, 1, 1, 1 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
  mlib_s32 inc0, inc1, inc2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
  mlib_s32 s0, s1, s2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
  deltac[channels] = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
  for (i = (channeld - 1), k = 0; i >= 0; i--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    if ((cmask & (1 << i)) == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
      deltac[k]++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
      k++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
  deltac[channels] = channeld;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
  for (i = 1; i < channels; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    deltac[channels] -= deltac[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
  sp = sl = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
  dp = dl = dst + deltac[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
  if (channels == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
      for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        s0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        dp[0] = s0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        dp += channeld;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
      sp = sl = (mlib_s32 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
      dp = dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
  else if (channels == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    inc0 = deltac[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    inc1 = deltac[2] + inc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
      for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        s0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        s1 = sp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        dp[0] = s0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        dp[inc0] = s1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        dp += inc1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        sp += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
      sp = sl = (mlib_s32 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
      dp = dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
  else if (channels == 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    inc0 = deltac[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    inc1 = deltac[2] + inc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    inc2 = deltac[3] + inc1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
      for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        s0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        s1 = sp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        s2 = sp[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        dp[0] = s0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        dp[inc0] = s1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        dp[inc1] = s2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        dp += inc2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        sp += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
      sp = sl = (mlib_s32 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
      dp = dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
#define INSERT_U8_12(sd0, dd0, dd1)     /* channel duplicate */ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
  dd0 = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd0));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
  dd1 = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd0))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
/* insert one channel to a 2-channel image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
 * both source and destination image data are 8-byte aligned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
 * dsize is multiple of 8.
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_v_ImageChannelInsert_U8_12_A8D1X8(const mlib_u8 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                                            mlib_u8       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                                            mlib_s32      dsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                                            mlib_s32      cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
  mlib_d64 *sp, *dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
  mlib_d64 sd0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
  mlib_d64 dd0, dd1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
  mlib_s32 bmask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
  mlib_s32 i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
  bmask = cmask | (cmask << 2) | (cmask << 4) | (cmask << 6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
  sp = (mlib_d64 *) src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
  dp = (mlib_d64 *) dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
  for (i = 0; i < dsize / 8; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    sd0 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    INSERT_U8_12(sd0, dd0, dd1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    vis_pst_8(dd0, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    vis_pst_8(dd1, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
/* insert one channel to a 2-channel image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
 * both source and destination image data are 8-byte aligned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
 * xsize is multiple of 8.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
void mlib_v_ImageChannelInsert_U8_12_A8D2X8(const mlib_u8 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                                            mlib_s32      slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                                            mlib_u8       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                                            mlib_s32      dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                                            mlib_s32      xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                                            mlib_s32      ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                                            mlib_s32      cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
  mlib_d64 *sp, *dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
  mlib_d64 *sl, *dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
  mlib_d64 sd0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
  mlib_d64 dd0, dd1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
  mlib_s32 bmask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
  mlib_s32 i, j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
  bmask = cmask | (cmask << 2) | (cmask << 4) | (cmask << 6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
  sp = sl = (mlib_d64 *) src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
  dp = dl = (mlib_d64 *) dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    for (i = 0; i < xsize / 8; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
      sd0 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
      INSERT_U8_12(sd0, dd0, dd1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
      vis_pst_8(dd0, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
      vis_pst_8(dd1, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
/* insert one channel to a 2-channel image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
void mlib_v_ImageChannelInsert_U8_12_D1(const mlib_u8 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
                                        mlib_u8       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
                                        mlib_s32      dsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
                                        mlib_s32      cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
  mlib_u8 *sa, *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
  mlib_u8 *dend, *dend2;                              /* end points in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
  mlib_d64 *dp;                                       /* 8-byte aligned start points in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
  mlib_d64 *sp;                                       /* 8-byte aligned start point in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
  mlib_d64 sd0, sd1;                                  /* 8-byte source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
  mlib_d64 dd0, dd1, dd2, dd3;                        /* 8-byte destination data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
  mlib_s32 soff;                                      /* offset of address in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
  mlib_s32 doff;                                      /* offset of address in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
  mlib_s32 off;                                       /* offset of src over dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
  mlib_s32 emask;                                     /* edge mask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
  mlib_s32 bmask;                                     /* channel mask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
  mlib_s32 i, n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
  bmask = cmask | (cmask << 2) | (cmask << 4) | (cmask << 6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
  sa = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
  da = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
  /* prepare the source address */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
  soff = ((mlib_addr) sa & 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
  /* prepare the destination addresses */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
  dp = (mlib_d64 *) ((mlib_addr) da & (~7));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
  doff = ((mlib_addr) da & 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
  dend = da + dsize * 2 - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
  dend2 = dend - 15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
  /* calculate the src's offset over dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
  off = soff * 2 - doff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
  if (doff % 2 != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    bmask = (~bmask) & 0xff;
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 (off == 0) {                           /* src and dst have same alignment */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    /* load 8 bytes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    sd0 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    /* insert, including some garbage at the start point */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    INSERT_U8_12(sd0, dd0, dd1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    /* store 16 bytes result */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    emask = vis_edge8(da, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    vis_pst_8(dd0, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
      emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
      vis_pst_8(dd1, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    if ((mlib_addr) dp <= (mlib_addr) dend2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
      n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 16 + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
      /* 8-pixel column loop, emask not needed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
      for (i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        sd0 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        INSERT_U8_12(sd0, dd0, dd1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        vis_pst_8(dd0, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        vis_pst_8(dd1, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    /* end point handling */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
      sd0 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
      INSERT_U8_12(sd0, dd0, dd1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
      emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
      vis_pst_8(dd0, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
      if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        vis_pst_8(dd1, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
  else if (off < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
    vis_alignaddr((void *)0, off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
    /* generate edge mask for the start point */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    emask = vis_edge8(da, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
    /* load 8 bytes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
    sd0 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
    /* insert and store 16 bytes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
    INSERT_U8_12(sd0, dd0, dd1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
    if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
      emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
      vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
    if ((mlib_addr) dp <= (mlib_addr) dend2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
      n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 16 + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
      /* 8-pixel column loop, emask not needed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
      for (i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        dd2 = dd1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        sd0 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        INSERT_U8_12(sd0, dd0, dd1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        vis_pst_8(vis_faligndata(dd2, dd0), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
        vis_pst_8(vis_faligndata(dd0, dd1), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    /* end point handling */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
    if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
      emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
      dd2 = dd1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
      sd0 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
      INSERT_U8_12(sd0, dd0, dd1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
      vis_pst_8(vis_faligndata(dd2, dd0), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
      if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
  else if (off < 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    vis_alignaddr((void *)0, off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    /* generate edge mask for the start point */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
    emask = vis_edge8(da, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    /* load 16 bytes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    sd0 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    sd1 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    /* insert and store 16 bytes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    INSERT_U8_12(sd0, dd0, dd1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    INSERT_U8_12(sd1, dd2, dd3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
      emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
      vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    if ((mlib_addr) dp <= (mlib_addr) dend2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
      n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 16 + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
      /* 8-pixel column loop, emask not needed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
      for (i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        dd0 = dd2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        dd1 = dd3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        sd1 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        INSERT_U8_12(sd1, dd2, dd3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        vis_pst_8(vis_faligndata(dd0, dd1), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        vis_pst_8(vis_faligndata(dd1, dd2), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    /* end point handling */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
      emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
      dd0 = dd2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
      dd1 = dd3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
      sd1 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
      INSERT_U8_12(sd1, dd2, dd3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
      vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
      if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
      }
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 {                                    /* (off >= 8) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    vis_alignaddr((void *)0, off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    /* generate edge mask for the start point */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
    emask = vis_edge8(da, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
    /* load 16 bytes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    sd0 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    sd1 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
    /* insert and store 16 bytes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
    INSERT_U8_12(sd0, dd0, dd1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
    INSERT_U8_12(sd1, dd2, dd3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
    if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
      emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
      vis_pst_8(vis_faligndata(dd2, dd3), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    if ((mlib_addr) dp <= (mlib_addr) dend2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
      n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 16 + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
      /* 8-pixel column loop, emask not needed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
      for (i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        dd0 = dd2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        dd1 = dd3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
        sd1 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
        INSERT_U8_12(sd1, dd2, dd3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        vis_pst_8(vis_faligndata(dd1, dd2), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
        vis_pst_8(vis_faligndata(dd2, dd3), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
    /* end point handling */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
      emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
      dd0 = dd2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
      dd1 = dd3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
      sd1 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
      INSERT_U8_12(sd1, dd2, dd3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
      vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
      if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
        emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
        vis_pst_8(vis_faligndata(dd2, dd3), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
    }
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
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
/* insert one channel to a 2-channel image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
void mlib_v_ImageChannelInsert_U8_12(const mlib_u8 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
                                     mlib_s32      slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
                                     mlib_u8       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
                                     mlib_s32      dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
                                     mlib_s32      xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
                                     mlib_s32      ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
                                     mlib_s32      cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
  mlib_u8 *sa, *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
  mlib_u8 *sl, *dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
  mlib_s32 j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
  sa = sl = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
  da = dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
    mlib_v_ImageChannelInsert_U8_12_D1(sa, da, xsize, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
    sa = sl += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    da = dl += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
#define INSERT_U8_13(sd0, dd0, dd1, dd2)                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd0));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
  sdb = vis_fpmerge(vis_read_hi(sda), vis_read_lo(sda));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
  sdc = vis_fpmerge(vis_read_hi(sdb), vis_read_hi(sdb));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
  sdd = vis_fpmerge(vis_read_lo(sdb), vis_read_lo(sdb));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
  dd0 = vis_fpmerge(vis_read_hi(sdc), vis_read_hi(sdd));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
  sde = vis_fpmerge(vis_read_lo(sdc), vis_read_lo(sdd));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
  dd1 = vis_freg_pair(vis_read_lo(dd0), vis_read_hi(sde));      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
  dd2 = vis_freg_pair(vis_read_lo(sde), vis_read_lo(sde))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
#define LOAD_INSERT_STORE_U8_A8(channeld)                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
  sd = *sp++;                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
#define LOAD_INSERT_STORE_U8(channeld)                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
  vis_alignaddr((void *)0, off);                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
  sd0 = sd1;                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
  sd1 = *sp++;                                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
  sd  = vis_faligndata(sd0, sd1);                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
  vis_alignaddr((void *)0, 1);                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld;   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
  vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
void mlib_v_ImageChannelInsert_U8_13_A8D1X8(const mlib_u8 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
                                            mlib_u8       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
                                            mlib_s32      dsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
                                            mlib_s32      cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
  mlib_u8 *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
  mlib_d64 *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
  mlib_d64 sd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
  mlib_s32 i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
  vis_alignaddr((void *)0, 1);              /* for 1-byte left shift */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
  sp = (mlib_d64 *) src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
  da = dst + (2 / cmask);                   /* 4,2,1 -> 0,1,2 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
  for (i = 0; i < dsize / 8; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
    LOAD_INSERT_STORE_U8_A8(3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
void mlib_v_ImageChannelInsert_U8_13_A8D2X8(const mlib_u8 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
                                            mlib_s32      slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
                                            mlib_u8       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
                                            mlib_s32      dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
                                            mlib_s32      xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
                                            mlib_s32      ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
                                            mlib_s32      cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
  mlib_u8 *da, *dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
  mlib_d64 *sp, *sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
  mlib_d64 sd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
  mlib_s32 i, j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
  vis_alignaddr((void *)0, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
  sp = sl = (mlib_d64 *) src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
  da = dl = dst + (2 / cmask);              /* 4,2,1 -> 0,1,2 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
    for (i = 0; i < xsize / 8; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
      LOAD_INSERT_STORE_U8_A8(3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
    da = dl = (mlib_u8 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
void mlib_v_ImageChannelInsert_U8_13_D1(const mlib_u8 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
                                        mlib_u8       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
                                        mlib_s32      dsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
                                        mlib_s32      cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
  mlib_u8 *sa, *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
  mlib_u8 *dend;                                      /* end point in destination */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
  mlib_d64 *sp;                                       /* 8-byte aligned start points in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
  mlib_d64 sd0, sd1, sd;                              /* 8-byte registers for source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
  mlib_s32 off;                                       /* offset of address alignment in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
  mlib_s32 i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
  /* prepare the src address */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
  sa = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
  off = (mlib_addr) sa & 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
  /* prepare the dst address */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
  da = dst + (2 / cmask);                   /* 4,2,1 -> 0,1,2 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
  dend = da + dsize * 3 - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
  sd1 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
  for (i = 0; i < dsize / 8; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
    LOAD_INSERT_STORE_U8(3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
  /* right end handling */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
  if ((mlib_addr) da <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
    vis_alignaddr((void *)0, off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
    sd0 = sd1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
    sd1 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
    sd = vis_faligndata(sd0, sd1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
    vis_alignaddr((void *)0, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
    vis_st_u8(sd = vis_faligndata(sd, sd), da);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
    da += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
    if ((mlib_addr) da <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
      vis_st_u8(sd = vis_faligndata(sd, sd), da);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
      da += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
      if ((mlib_addr) da <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        vis_st_u8(sd = vis_faligndata(sd, sd), da);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
        da += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        if ((mlib_addr) da <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
          vis_st_u8(sd = vis_faligndata(sd, sd), da);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
          da += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
          if ((mlib_addr) da <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
            vis_st_u8(sd = vis_faligndata(sd, sd), da);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
            da += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
            if ((mlib_addr) da <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
              vis_st_u8(sd = vis_faligndata(sd, sd), da);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
              da += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
              if ((mlib_addr) da <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
                vis_st_u8(sd = vis_faligndata(sd, sd), da);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
void mlib_v_ImageChannelInsert_U8_13(const mlib_u8 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
                                     mlib_s32      slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
                                     mlib_u8       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
                                     mlib_s32      dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
                                     mlib_s32      xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
                                     mlib_s32      ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
                                     mlib_s32      cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
  mlib_u8 *sa, *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
  mlib_u8 *sl, *dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
  mlib_s32 j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
  sa = sl = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
  da = dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
    mlib_v_ImageChannelInsert_U8_13_D1(sa, da, xsize, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
    sa = sl += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
    da = dl += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
#define INSERT_U8_14(sd0, dd0, dd1, dd2, dd3)                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd0));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
  sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd0));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
  dd0 = vis_fpmerge(vis_read_hi(sda), vis_read_hi(sda));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
  dd1 = vis_fpmerge(vis_read_lo(sda), vis_read_lo(sda));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
  dd2 = vis_fpmerge(vis_read_hi(sdb), vis_read_hi(sdb));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
  dd3 = vis_fpmerge(vis_read_lo(sdb), vis_read_lo(sdb))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
void mlib_v_ImageChannelInsert_U8_14_A8D1X8(const mlib_u8 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
                                            mlib_u8       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
                                            mlib_s32      dsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
                                            mlib_s32      cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
  mlib_d64 *sp, *dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
  mlib_d64 sd0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
  mlib_d64 sda, sdb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
  mlib_d64 dd0, dd1, dd2, dd3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
  mlib_s32 bmask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
  mlib_s32 i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
  bmask = cmask | (cmask << 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
  sp = (mlib_d64 *) src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
  dp = (mlib_d64 *) dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
  for (i = 0; i < dsize / 8; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
    sd0 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
    INSERT_U8_14(sd0, dd0, dd1, dd2, dd3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
    vis_pst_8(dd0, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
    vis_pst_8(dd1, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
    vis_pst_8(dd2, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
    vis_pst_8(dd3, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
void mlib_v_ImageChannelInsert_U8_14_A8D2X8(const mlib_u8 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
                                            mlib_s32      slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
                                            mlib_u8       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
                                            mlib_s32      dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
                                            mlib_s32      xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
                                            mlib_s32      ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
                                            mlib_s32      cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
  mlib_d64 *sp, *dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
  mlib_d64 *sl, *dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
  mlib_d64 sd0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
  mlib_d64 sda, sdb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
  mlib_d64 dd0, dd1, dd2, dd3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
  mlib_s32 bmask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
  mlib_s32 i, j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
  bmask = cmask | (cmask << 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
  sp = sl = (mlib_d64 *) src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
  dp = dl = (mlib_d64 *) dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
    for (i = 0; i < xsize / 8; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
      sd0 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
      INSERT_U8_14(sd0, dd0, dd1, dd2, dd3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
      vis_pst_8(dd0, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
      vis_pst_8(dd1, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
      vis_pst_8(dd2, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
      vis_pst_8(dd3, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
    dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
void mlib_v_ImageChannelInsert_U8_14_D1(const mlib_u8 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
                                        mlib_u8       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
                                        mlib_s32      dsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
                                        mlib_s32      cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
  mlib_u8 *sa, *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
  mlib_u8 *dend, *dend2;                              /* end points in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
  mlib_d64 *dp;                                       /* 8-byte aligned start points in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
  mlib_d64 *sp;                                       /* 8-byte aligned start point in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
  mlib_d64 sd0, sd1, sd;                              /* 8-byte source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
  mlib_d64 sda, sdb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
  mlib_d64 dd0, dd1, dd2, dd3, dd4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
  mlib_s32 soff;                                      /* offset of address in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
  mlib_s32 doff;                                      /* offset of address in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
  mlib_s32 emask;                                     /* edge mask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
  mlib_s32 bmask;                                     /* channel mask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
  mlib_s32 i, n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
  sa = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
  da = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
  bmask = cmask | (cmask << 4) | (cmask << 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
  /* prepare the source address */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
  soff = ((mlib_addr) sa & 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
  /* prepare the destination addresses */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
  dp = (mlib_d64 *) ((mlib_addr) da & (~7));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
  doff = ((mlib_addr) da & 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
  dend = da + dsize * 4 - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
  dend2 = dend - 31;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
  bmask = (bmask >> (doff % 4)) & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
  if (doff == 0) {                          /* dst is 8-byte aligned */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
    vis_alignaddr((void *)0, soff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
    sd0 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
    sd1 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
    sd = vis_faligndata(sd0, sd1);          /* the intermediate is aligned */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
    INSERT_U8_14(sd, dd0, dd1, dd2, dd3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
    emask = vis_edge8(da, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
    vis_pst_8(dd0, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
    if ((mlib_addr) dp <= (mlib_addr) dend) { /* for very small size */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
      emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
      vis_pst_8(dd1, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
      if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
        emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
        vis_pst_8(dd2, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
        if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
          emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
          vis_pst_8(dd3, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
    if ((mlib_addr) dp <= (mlib_addr) dend2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
      n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 32 + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
      /* 8-pixel column loop, emask not needed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
      for (i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
        sd0 = sd1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
        sd1 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
        sd = vis_faligndata(sd0, sd1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
        INSERT_U8_14(sd, dd0, dd1, dd2, dd3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
        vis_pst_8(dd0, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
        vis_pst_8(dd1, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
        vis_pst_8(dd2, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
        vis_pst_8(dd3, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
    /* end point handling */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
    if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
      sd0 = sd1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
      sd1 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
      sd = vis_faligndata(sd0, sd1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
      INSERT_U8_14(sd, dd0, dd1, dd2, dd3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
      emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
      vis_pst_8(dd0, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
      if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
        emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
        vis_pst_8(dd1, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
        if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
          emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
          vis_pst_8(dd2, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
          if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
            emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
            vis_pst_8(dd3, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
  else {                                    /* dst is not 8-byte aligned */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
    vis_alignaddr((void *)0, soff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
    sd0 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
    sd1 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
    sd = vis_faligndata(sd0, sd1);          /* the intermediate is aligned */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
    INSERT_U8_14(sd, dd0, dd1, dd2, dd3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
    vis_alignaddr((void *)0, -doff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
    emask = vis_edge8(da, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
    vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
    if ((mlib_addr) dp <= (mlib_addr) dend) { /* for very small size */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
      emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
      vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
      if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
        emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
        vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
        if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
          emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
          vis_pst_8(vis_faligndata(dd2, dd3), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
    if ((mlib_addr) dp <= (mlib_addr) dend2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
      n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 32 + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
      /* 8-pixel column loop, emask not needed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
      for (i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
        dd4 = dd3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
        vis_alignaddr((void *)0, soff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
        sd0 = sd1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
        sd1 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
        sd = vis_faligndata(sd0, sd1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
        INSERT_U8_14(sd, dd0, dd1, dd2, dd3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
        vis_alignaddr((void *)0, -doff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
        vis_pst_8(vis_faligndata(dd4, dd0), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
        vis_pst_8(vis_faligndata(dd0, dd1), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
        vis_pst_8(vis_faligndata(dd1, dd2), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
        vis_pst_8(vis_faligndata(dd2, dd3), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
    /* end point handling */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
    if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
      dd4 = dd3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
      vis_alignaddr((void *)0, soff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
      sd0 = sd1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
      sd1 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
      sd = vis_faligndata(sd0, sd1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
      INSERT_U8_14(sd, dd0, dd1, dd2, dd3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
      vis_alignaddr((void *)0, -doff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
      emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
      vis_pst_8(vis_faligndata(dd4, dd0), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
      if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
        emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
        vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
        if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
          emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
          vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
          if ((mlib_addr) dp <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
            emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
            vis_pst_8(vis_faligndata(dd2, dd3), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
void mlib_v_ImageChannelInsert_U8_14(const mlib_u8 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
                                     mlib_s32      slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
                                     mlib_u8       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
                                     mlib_s32      dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
                                     mlib_s32      xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
                                     mlib_s32      ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
                                     mlib_s32      cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
  mlib_u8 *sa, *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
  mlib_u8 *sl, *dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
  mlib_s32 j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
  sa = sl = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
  da = dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
    mlib_v_ImageChannelInsert_U8_14_D1(sa, da, xsize, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
    sa = sl += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
    da = dl += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
#define LOAD_INSERT_STORE_S16_1X_A8(channeld)                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
  sd  = *sp++;                                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld;  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld;  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld;  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
#define LOAD_INSERT_STORE_S16_1X(channeld)                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
  vis_alignaddr((void *)0, off);                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
  sd0 = sd1;                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
  sd1 = *sp++;                                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
  sd  = vis_faligndata(sd0, sd1);                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
  vis_alignaddr((void *)0, 2);                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld;  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld;  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld;  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
  vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
void mlib_v_ImageChannelInsert_S16_12_A8D1X4(const mlib_s16 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
                                             mlib_s16       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
                                             mlib_s32       dsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
                                             mlib_s32       cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
  mlib_s16 *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
  mlib_d64 *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
  mlib_d64 sd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
  mlib_s32 i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
  sp = (mlib_d64 *) src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
  da = dst + (2 - cmask);                   /* 2,1 -> 0,1 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
  vis_alignaddr((void *)0, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
  for (i = 0; i < dsize / 4; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
    LOAD_INSERT_STORE_S16_1X_A8(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
void mlib_v_ImageChannelInsert_S16_12_A8D2X4(const mlib_s16 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
                                             mlib_s32       slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
                                             mlib_s16       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
                                             mlib_s32       dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
                                             mlib_s32       xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
                                             mlib_s32       ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
                                             mlib_s32       cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
  mlib_s16 *da, *dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
  mlib_d64 *sp, *sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
  mlib_d64 sd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
  mlib_s32 i, j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
  sp = sl = (mlib_d64 *) src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
  da = dl = dst + (2 - cmask);              /* 2,1 -> 0,1 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
  vis_alignaddr((void *)0, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
    for (i = 0; i < xsize / 4; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
      LOAD_INSERT_STORE_S16_1X_A8(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
void mlib_v_ImageChannelInsert_S16_12_D1(const mlib_s16 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
                                         mlib_s16       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
                                         mlib_s32       dsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
                                         mlib_s32       cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
  mlib_s16 *sa, *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
  mlib_s16 *dend;                                     /* end point in destination */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
  mlib_d64 *sp;                                       /* 8-byte aligned start points in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
  mlib_d64 sd0, sd1, sd;                              /* 8-byte registers for source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
  mlib_s32 off;                                       /* offset of address alignment in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
  mlib_s32 i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
  sa = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
  da = dst + (2 - cmask);                   /* 2,1 -> 0,1 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
  /* prepare the src address */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
  off = (mlib_addr) sa & 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
  dend = da + dsize * 2 - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
  sd1 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
  for (i = 0; i < dsize / 4; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
    LOAD_INSERT_STORE_S16_1X(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
  /* right end handling */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
  if ((mlib_addr) da <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
    vis_alignaddr((void *)0, off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
    sd0 = sd1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
    sd1 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
    sd = vis_faligndata(sd0, sd1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
    vis_alignaddr((void *)0, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
    vis_st_u16(sd = vis_faligndata(sd, sd), da);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
    da += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
    if ((mlib_addr) da <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
      vis_st_u16(sd = vis_faligndata(sd, sd), da);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
      da += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
      if ((mlib_addr) da <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
        vis_st_u16(sd = vis_faligndata(sd, sd), da);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
void mlib_v_ImageChannelInsert_S16_12(const mlib_s16 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
                                      mlib_s32       slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
                                      mlib_s16       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
                                      mlib_s32       dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
                                      mlib_s32       xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
                                      mlib_s32       ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
                                      mlib_s32       cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
  mlib_s16 *sa, *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
  mlib_s16 *sl, *dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
  mlib_s32 j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
  sa = sl = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
  da = dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
    mlib_v_ImageChannelInsert_S16_12_D1(sa, da, xsize, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
    sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
void mlib_v_ImageChannelInsert_S16_13_A8D1X4(const mlib_s16 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
                                             mlib_s16       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
                                             mlib_s32       dsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
                                             mlib_s32       cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
  mlib_s16 *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
  mlib_d64 *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
  mlib_d64 sd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
  mlib_s32 i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
  sp = (mlib_d64 *) src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
  da = dst + (2 / cmask);                   /* 4,2,1 -> 0,1,2 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
  vis_alignaddr((void *)0, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
  for (i = 0; i < dsize / 4; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
    LOAD_INSERT_STORE_S16_1X_A8(3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
void mlib_v_ImageChannelInsert_S16_13_A8D2X4(const mlib_s16 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
                                             mlib_s32       slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
                                             mlib_s16       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
                                             mlib_s32       dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
                                             mlib_s32       xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
                                             mlib_s32       ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
                                             mlib_s32       cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
  mlib_s16 *da, *dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
  mlib_d64 *sp, *sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
  mlib_d64 sd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
  mlib_s32 i, j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
  sp = sl = (mlib_d64 *) src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
  da = dl = dst + (2 / cmask);              /* 4,2,1 -> 0,1,2 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
  vis_alignaddr((void *)0, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
    for (i = 0; i < xsize / 4; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
      LOAD_INSERT_STORE_S16_1X_A8(3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
void mlib_v_ImageChannelInsert_S16_13_D1(const mlib_s16 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
                                         mlib_s16       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
                                         mlib_s32       dsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
                                         mlib_s32       cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
  mlib_s16 *sa, *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
  mlib_s16 *dend;                                     /* end point in destination */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
  mlib_d64 *sp;                                       /* 8-byte aligned start points in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
  mlib_d64 sd0, sd1, sd;                              /* 8-byte registers for source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
  mlib_s32 off;                                       /* offset of address alignment in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
  mlib_s32 i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
  sa = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
  da = dst + (2 / cmask);                   /* 4,2,1 -> 0,1,2 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
  /* prepare the src address */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
  off = (mlib_addr) sa & 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
  dend = da + dsize * 3 - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
  sd1 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
  for (i = 0; i < dsize / 4; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
    LOAD_INSERT_STORE_S16_1X(3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
  /* right end handling */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
  if ((mlib_addr) da <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
    vis_alignaddr((void *)0, off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
    sd0 = sd1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
    sd1 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
    sd = vis_faligndata(sd0, sd1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
    vis_alignaddr((void *)0, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
    vis_st_u16(sd = vis_faligndata(sd, sd), da);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
    da += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
    if ((mlib_addr) da <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
      vis_st_u16(sd = vis_faligndata(sd, sd), da);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
      da += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
      if ((mlib_addr) da <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
        vis_st_u16(sd = vis_faligndata(sd, sd), da);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
void mlib_v_ImageChannelInsert_S16_13(const mlib_s16 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
                                      mlib_s32       slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
                                      mlib_s16       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
                                      mlib_s32       dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
                                      mlib_s32       xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
                                      mlib_s32       ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
                                      mlib_s32       cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
  mlib_s16 *sa, *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
  mlib_s16 *sl, *dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
  mlib_s32 j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
  sa = sl = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
  da = dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
    mlib_v_ImageChannelInsert_S16_13_D1(sa, da, xsize, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
    sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
#define INSERT_S16_14(sp, dp, bmask)    /* channel duplicate */ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
  /* obsolete: it is slower than the vis_st_u16() version*/     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
  sd0 = *sp++;                                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd0));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
  sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd0));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
  sdc = vis_fpmerge(vis_read_hi(sda), vis_read_hi(sda));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
  sdd = vis_fpmerge(vis_read_lo(sda), vis_read_lo(sda));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
  sde = vis_fpmerge(vis_read_hi(sdb), vis_read_hi(sdb));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
  sdf = vis_fpmerge(vis_read_lo(sdb), vis_read_lo(sdb));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
  dd0 = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
  dd1 = vis_fpmerge(vis_read_hi(sdd), vis_read_lo(sdd));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
  dd2 = vis_fpmerge(vis_read_hi(sde), vis_read_lo(sde));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
  dd3 = vis_fpmerge(vis_read_hi(sdf), vis_read_lo(sdf));        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
  vis_pst_16(dd0, dp++, bmask);                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
  vis_pst_16(dd1, dp++, bmask);                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
  vis_pst_16(dd2, dp++, bmask);                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
  vis_pst_16(dd3, dp++, bmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
void mlib_v_ImageChannelInsert_S16_14_A8D1X4(const mlib_s16 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
                                             mlib_s16       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
                                             mlib_s32       dsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
                                             mlib_s32       cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
  mlib_s16 *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
  mlib_d64 *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
  mlib_d64 sd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
  mlib_s32 i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
  sp = (mlib_d64 *) src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
  da = dst + (6 / cmask + 1) / 2;           /* 8,4,2,1 -> 0,1,2,3 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
  vis_alignaddr((void *)0, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
  for (i = 0; i < dsize / 4; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
    LOAD_INSERT_STORE_S16_1X_A8(4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
void mlib_v_ImageChannelInsert_S16_14_A8D2X4(const mlib_s16 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
                                             mlib_s32       slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
                                             mlib_s16       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
                                             mlib_s32       dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
                                             mlib_s32       xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
                                             mlib_s32       ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
                                             mlib_s32       cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
  mlib_s16 *da, *dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
  mlib_d64 *sp, *sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
  mlib_d64 sd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
  mlib_s32 i, j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
  sp = sl = (mlib_d64 *) src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1543
  da = dl = dst + (6 / cmask + 1) / 2;      /* 8,4,2,1 -> 0,1,2,3 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1544
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
  vis_alignaddr((void *)0, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1546
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1547
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1548
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1549
    for (i = 0; i < xsize / 4; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1550
      LOAD_INSERT_STORE_S16_1X_A8(4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
    sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
void mlib_v_ImageChannelInsert_S16_14_D1(const mlib_s16 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
                                         mlib_s16       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
                                         mlib_s32       dsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
                                         mlib_s32       cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1563
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1564
  mlib_s16 *sa, *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1565
  mlib_s16 *dend;                                     /* end point in destination */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1566
  mlib_d64 *sp;                                       /* 8-byte aligned start points in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1567
  mlib_d64 sd0, sd1, sd;                              /* 8-byte registers for source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
  mlib_s32 off;                                       /* offset of address alignment in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
  mlib_s32 i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
  sa = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
  da = dst + (6 / cmask + 1) / 2;           /* 8,4,2,1 -> 0,1,2,3 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
  /* prepare the src address */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1575
  sp = (mlib_d64 *) ((mlib_addr) sa & (~7));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
  off = (mlib_addr) sa & 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1578
  dend = da + dsize * 4 - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
  sd1 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1582
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
  for (i = 0; i < dsize / 4; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
    LOAD_INSERT_STORE_S16_1X(4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
  /* right end handling */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1588
  if ((mlib_addr) da <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
    vis_alignaddr((void *)0, off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
    sd0 = sd1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
    sd1 = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
    sd = vis_faligndata(sd0, sd1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1594
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1595
    vis_alignaddr((void *)0, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1596
    vis_st_u16(sd = vis_faligndata(sd, sd), da);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
    da += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
    if ((mlib_addr) da <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1599
      vis_st_u16(sd = vis_faligndata(sd, sd), da);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
      da += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
      if ((mlib_addr) da <= (mlib_addr) dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
        vis_st_u16(sd = vis_faligndata(sd, sd), da);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
void mlib_v_ImageChannelInsert_S16_14(const mlib_s16 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
                                      mlib_s32       slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1611
                                      mlib_s16       *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1612
                                      mlib_s32       dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1613
                                      mlib_s32       xsize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
                                      mlib_s32       ysize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
                                      mlib_s32       cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1616
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
  mlib_s16 *sa, *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1618
  mlib_s16 *sl, *dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1619
  mlib_s32 j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
  sa = sl = (void *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
  da = dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1626
    mlib_v_ImageChannelInsert_S16_14_D1(sa, da, xsize, cmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1627
    sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1628
    da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1629
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1631
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
/***************************************************************/